Comments (3)
Projection
A best-fit approximation is used to project values at quadrature-points to mesh-points.
where
or assembled as (system) sparse-matrix for continuous approximations.
Note
The 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())
from felupe.
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)
from felupe.
This one is the continuous projection. Hopefully efficient enough 🚀.
- works for quads, hexahedrons and all the lagrange bi/tri quadratic versions
- test serendipity elements
- works for triangles with quadrature
order=2
- works for quadratic triangles with quadrature
order=5
(4 is not implemented) - test tetrahedrons
Some Thoughts
- The reference triangle is defined in (0, 1) whereas the rectangle is in (-1, 1).
- The sum of the volume matrix is the volume, correct result.
- For cell-wise constant values, switch to the existing method (
mean=True
).
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)
from felupe.
Related Issues (20)
- Launch Binder badge does not start
- Add `SolidBody.assemble.mass(density=1.0)`
- Fix the doctests and add it to the code coverage report
- Implement optimization of constitutive material parameters HOT 1
- `MaterialStrain.plot()` shows wrong preview
- `NeoHookeCompressible(mu=1, lmbda=None)`
- The `constitution` module should be splitted and re-organized
- The Alexander-model is incomplete
- The Ogden-Roxburgh model should be also implemented with automatic differentiation
- The optimization of material parameters should optionally be based on relative residuals
- Collection of Ideas
- Deprecate `MaterialAD` and use `Hyperelastic` everywhere instead HOT 2
- The material parameters are overwritten in-place in `ConstitutiveMaterial.optimize()`
- Material-parameter scalars are converted to arrays in `ConstitutiveMaterial.optimize()`
- Add the MORPH X material model
- The state variables are not-resetted after finishing a load case in the plot of a constitutive material
- Prepare for Numpy 2.0
- Enhance the performance of uniform grid meshes
- `FormItem()` needs an `update()` method
- Include some hello-world lines of code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from felupe.