-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stress projection #681
Comments
ProjectionA best-fit approximation is used to project values at quadrature-points to mesh-points. where or assembled as (system) sparse-matrix for continuous approximations. NoteThe quadrature-scheme of the original region, used to evaluate import felupe as fem
import numpy as np
mesh = fem.Cube(n=11)
region = fem.RegionHexahedron(mesh)
field = fem.Field(region, dim=3).as_container()
y = field.extract()[0]
axes = y.shape[-2:]
dim = np.product(y.shape[:-2])
dV = region.dV
fun = np.eye(dim).reshape(dim, dim, 1, 1)
x = fem.Field(region, dim=dim).as_container()
A = fem.IntegralForm([fun], v=x, dV=dV, u=x, grad_v=[False], grad_u=[False]).assemble()
b = fem.IntegralForm([y.reshape(dim, *axes)], v=x, dV=dV, grad_v=[False]).assemble()
import pypardiso
xh = pypardiso.spsolve(A, b.toarray()) |
It seems to be way more efficient to do this component by component, as it drastically reduces the sparse-matrix size. import felupe as fem
import numpy as np
mesh = fem.Cube(n=31)
region = fem.RegionHexahedron(mesh)
field = fem.Field(region, dim=3).as_container()
y = field.extract()[0][0, 0]
dV = region.dV
fun = np.ones((1, 1))
x = fem.Field(region).as_container()
A = fem.IntegralForm([fun], v=x, dV=dV, u=x, grad_v=[False], grad_u=[False]).assemble()
b = fem.IntegralForm([y], v=x, dV=dV, grad_v=[False]).assemble().toarray()
import pypardiso
xh = pypardiso.spsolve(A, b) |
This one is the continuous projection. Hopefully efficient enough 🚀.
Some Thoughts
import numpy as np
from scipy.sparse.linalg import spsolve
from felupe.assembly import IntegralFormCartesian
from felupe import Field
def project(values, region, solver=spsolve):
"Return given array of values at quadrature-points projected to mesh-points."
shape = values.shape[:-2] # tensor-components
dim = np.prod(shape).astype(int) # tensor-size (enforce int for empty tuple)
axes = values.shape[-2:] # trailing axes
# lhs (volume matrix) is constant for all items
v = u = Field(region, dim=1) # 1d-field for lhs
A = IntegralFormCartesian(np.ones((1, 1)), v=v, dV=region.dV, u=u).assemble()
# field of unknowns with projected values
x = Field(region, dim=dim)
# solve with individual right-hand-sides (per tensor-component of values)
b = IntegralFormCartesian(values.reshape(dim, *axes), v=x, dV=region.dV).assemble()
x.values[:] = spsolve(A, b.toarray().reshape(-1, dim)).reshape(x.values.shape)
return x.values.reshape(-1, *shape)
import felupe as fem
mesh = fem.Rectangle(n=21)
region = fem.RegionQuad(mesh)
field = fem.FieldAxisymmetric(region, dim=2).as_container()
dxdX = field.extract()[0]
values_projected = project(dxdX, region) |
The stress
project(values, region)
function is not well implemented. This must be enhanced. Currently, either the mean-cell values are averaged at the points or for some quadrature rules an extrapolation is done. Optionally, no averaging at points is done for disconnected meshes. The averaging part is fine, however, the projection from the quadrature to the mesh points should be changed.Tasks
project()
toextrapolate()
, see Add the L2-projection and replace it with the oldtools.project()
#683project()
function which works differently but supports the old arguments as well, see Add the L2-projection and replace it with the oldtools.project()
#683The text was updated successfully, but these errors were encountered: