Hi to all of you :)!
I have a problem regarding the integration of a second order tensor over the volume (3D mesh) in post-processing. Let T(uh), be a second order tensor function acting on the discrete displacement field uh at each dof. The integral of the second order tensor (size=(3,3)) over the domain (Omega) is giving an error. First problem was that ufl perform integration only on scalar quantities, the error was:
ufl.log.UFLException: Can only integrate scalar expressions. The integrand is a tensor expression with value shape (3, 3) and free indices with labels ().
Then checking the solution proposed in
Integration of a gradient of function - #11 by Alberto_Lolli,
Then, I modified my formulation in the same fashion to compute the integral of each component of the tensor. A new problem arise when trying to do so, my code is below.
define Ten(u):
eps = ufl.sym(ufl.grad(u))
return ufl.as_tensor(L[p,q,r,s]*eps[r,s],(p,q))Ten2 = Ten(uh)
Q = dolfinx.fem.TensorFunctionSpace(mesh,(âDGâ,0))
Ten2Int = dolfinx.fem.Function(Q)
Ten2Int.interpolate(Ten2)
Ten2Int2 = numpy.zeros((3,3))
for i in range(3):
for j in range(3):
Ten2Int2 = dolfinx.assemble_scalar(Ten2Int[i,j]*ufl.dx)
the error is the following:
File â/home/camilo/.local/lib/python3.8/site-packages/dolfinx/fem/assemble.pyâ, line 128, in assemble_scalar
constants = constants or _pack_constants(M)
TypeError: pack_constants(): incompatible function arguments. The following argument types are supported:
1. (arg0: dolfinx::fem::Form) â numpy.ndarray[numpy.float64]
2. (arg0: dolfinx::fem::Expression) â numpy.ndarray[numpy.float64]
3. (arg0: dolfinx::fem::Form) â numpy.ndarray[numpy.float32]
4. (arg0: dolfinx::fem::Expression) â numpy.ndarray[numpy.float32]
5. (arg0: dolfinx::fem::Form<std::complex >) â numpy.ndarray[numpy.complex128]
6. (arg0: dolfinx::fem::Expression<std::complex >) â numpy.ndarray[numpy.complex128]
Invoked with: Form([Integral(Sum(Indexed(Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement(âLagrangeâ, tetrahedron, 1, variant=âequispacedâ), dim=3, variant=âequispacedâ), 0), TensorElement(FiniteElement(âDiscontinuous Lagrangeâ, tetrahedron, 0), shape=(3, 3), symmetry={})), 2), MultiIndex((FixedIndex(0), FixedIndex(0)))), Indexed(Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement(âLagrangeâ, tetrahedron, 1, variant=âequispacedâ), dim=3, variant=âequispacedâ), 0), TensorElement(FiniteElement(âDiscontinuous Lagrangeâ, tetrahedron, 0), shape=(3, 3), symmetry={})), 3), MultiIndex((FixedIndex(0), FixedIndex(0))))), âcellâ, Mesh(VectorElement(FiniteElement(âLagrangeâ, tetrahedron, 1, variant=âequispacedâ), dim=3, variant=âequispacedâ), 0), âeverywhereâ, {}, None)])
Did you forget to #include <pybind11/stl.h>
? Or <pybind11/complex.h>,
<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic
conversions are optional and require extra headers to be included
when compiling your pybind11 module.
Thanks a lot in adavance !!!