## We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

#### Notice

The forum is in read only mode.

# How to define a tensor space

3 years 8 months ago #2869 by Lily
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?

3 years 8 months ago #2870
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[0],gf.components[1], gf.components[1],gf.components[2]), dims=(2,2) ) Draw(gfm,mesh,"gfm")

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.

Best
Michael

#### File Attachment:

File Name: matrixl2.py
File Size:1 KB
##### Attachments:
The following user(s) said Thank You: Manuel Sanchez
Time to create page: 0.099 seconds