How to define a tensor space


I am trying to define a symmetric stress tensor. I wonder if there is any sentence like "TensorL2(mesh, order=1, sym=symmtry) ", and if there is any example that uses tensor space?

Thanks in advance.

Hi Lily,

currently there is no “TensorL2” FESpace directly available in NGSolve. You can use copies of L2 to construct a symmetric tensor space. E.g. in 2D

fesL2 = L2(mesh, order=1)
MatrixL2 = FESpace( [fesL2,fesL2,fesL2] )
(uxx,uxy,uyy),(vxx,vxy,vyy) = MatrixL2.TnT()

um = CoefficientFunction( (uxx, uxy,
uxy, uyy), dims=(2,2))
vm = CoefficientFunction( (vxx, vxy,
vxy, vyy), dims=(2,2))

gf = GridFunction(MatrixL2)
gfm = CoefficientFunction( (gf.components[0],gf.components[1],
gf.components[1],gf.components[2]), dims=(2,2) )

Attached you’ll find a minimal example where a non-symmetric matrix gets projected.

There are matrix-valued spaces in NGSolve: HDivDiv, HCurlCurl, HCurlDiv (the first two are symmetric, the latter is not). The HDivDiv space is used e.g. in the Hellan-Herrmann-Johnson method for forth-order problems.