# How to define a tensor space

Hi,

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?

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

[code]
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,gf.components,
gf.components,gf.components), dims=(2,2) )
Draw(gfm,mesh,“gfm”)[/code]

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.

Attachment: matrixl2.py