-
Notifications
You must be signed in to change notification settings - Fork 75
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
Coefficient defined on quadrature points in the form definition #564
Comments
Oh, I see |
A scikit-fem/skfem/assembly/basis/basis.py Lines 182 to 183 in 72ba058
I think a similar issue to the coefficient function not belonging to the same finite element space arises in mixed finite element methods as used for Stokes equations (exx 18, 24, 27, 30) scikit-fem/docs/examples/ex18.py Lines 56 to 59 in 91a276a
I think it doesn't matter that that the spaces are different so long as the quadrature points coincide, i.e. the Can you create an One recently introduced way to make a new |
Thanks for your reply! I see. This means simply if Now the problem is that my |
Yes, I thought of this after writing and have been thinking about it. I've only tried what I wrote above for scalars and vectors, not a tensor like stress; there isn't a higher order equivalent of If the thermal stress is an isotropic tensor proportional to the excess temperature, it might be appropriate to use |
Absolutely...Unfortunately my initial stress is neither expressible by Do you think it is possible to tweak |
I think no tweaks are required in this case: import numpy as np
from skfem import *
from skfem.helpers import sym_grad, ddot
mesh = MeshTri()
basis = InteriorBasis(mesh, ElementVector(ElementTriP1()))
Z = basis.zero_w() # has shape Nelems x Nqp
sig0 = DiscreteField(np.array([[Z, Z], [Z, Z]])) # change Z to something nonzero
@LinearForm
def loading(v, w):
return ddot(w["sig0"], sym_grad(v))
b = loading.assemble(basis, sig0=sig0) In long term I have a plan to include something like |
Let me add that if you need the global coordinates corresponding to each element of In [6]: x, y = basis.global_coordinates().value
In [7]: x
Out[7]:
array([[0.16666667, 0.66666667, 0.16666667],
[0.83333333, 0.33333333, 0.83333333]])
In [8]: y
Out[8]:
array([[0.16666667, 0.16666667, 0.66666667],
[0.33333333, 0.83333333, 0.83333333]]) It's not exactly clear to me how you are planning to calculate the components of Edit: Also make sure to fix the version of |
I'm testing the "data-driven computational mechanics" approach, where I need to prescribe initial stress fields computed by a local (at every Gauss point) spatial tree query in the phase space Thanks for the code snippet, so I suppose I could do something like basis = InteriorBasis(mesh, ElementTriP0())) # I think `ElementVector` is not needed right?
sig0_11 = basis.zero_w() # has shape Nelems x Nqp
sig0_11[:, :] = ...
# same for 22 and 12
sig0 = DiscreteField(np.array([[sig0_11, sig0_12], [sig0_12, sig0_22]]) for my displacement in |
Actually, the element used in Edit: Maybe this part of the tutorial will help you or maybe not: https://scikit-fem.readthedocs.io/en/latest/forms.html#forms-return-numpy-arrays Edit 2: If you use two different |
Oh I understand better now! Thank you. I will report if I have something. |
Sorry I may have a quick but related question. From a solution vector |
I found this code snippet from element_sig = ElementTriDG(ElementTriP1())
basis_sig = InteriorBasis(mesh, element_sig)
@BilinearForm
def proj_stress(u, v, w):
return sigma(sym_grad(u))[0, 0] * v
@BilinearForm
def mass(u, v, w):
return u * v
solve(asm(mass, basis_sig), asm(proj_strain, basis, basis_sig) @ u) # for sig_11 I wonder if there is a more "local" way to do this without doing a global solve (like |
Unfortunately, no. I think the "correct" way to do this would be to return here a list of local stiffness matrices:
And then use |
Yes I think it could be useful. However note that here we need in fact the local |
I wasn't thinking anything complicated; in scikit-fem we aim to focus on the assembly part and leave parallelization to other tools. I just wanted to point out that a call to |
If you pass |
It appears to be working fine. Thanks all! |
Is there any way to write 1D and 2D for nonlinear elastic constitutive relations using skfem, I am totally stuck. how to define bilinear form for this. |
I have a the coefficient function that does not belong to the same finite element space as
v
, but is defined for each quadrature point.Is it possible?
Background
In linear elasticity, sometimes the stress - strain is given by
where
sig0
is the initial stress tensor, possibly heterogeneous (different value for each Gauss point). This can be used for instance to model thermal stress.The text was updated successfully, but these errors were encountered: