### Functionspace in 3D problem

377

views

0

Hello,

I work on a 3D elasticity project. I want to create a 3D functionnal space with V, but when the gradient of a function in this space seems to be a (3,2) dimension matrix, so I deduced the the function is a 2D vector. How the define a 3D functional space (it doesn't seems to work in my code ) ?

my code :

I work on a 3D elasticity project. I want to create a 3D functionnal space with V, but when the gradient of a function in this space seems to be a (3,2) dimension matrix, so I deduced the the function is a 2D vector. How the define a 3D functional space (it doesn't seems to work in my code ) ?

my code :

```
[...]
V = VectorFunctionSpace(mesh,"P",1,dim=3)
u_ = TestFunction(V)
v = TrialFunction(V)
u = Function(V, name="Deplacement")
def eps(w):
return sym(grad(w))
def sigma(w):
return lmbda*tr(eps(w))*Identity(2) + 2*mu*eps(w)
Wdef = inner(sigma(v), eps(u_))*dx
Wext = dot (ps, u_)*ds(6)
```

and the error message:```
Cannot take symmetric part of rectangular matrix with dimensions (3, 2).
Traceback (most recent call last):
File "script_tube.py", line 58, in <module>
Wdef = inner(sigma(v), eps(u_))*dx
File "script_tube.py", line 55, in sigma
return lmbda*tr(eps(w))*Identity(2) + 2*mu*eps(w)
File "script_tube.py", line 52, in eps
return sym(grad(w))
File "/usr/lib/python2.7/dist-packages/ufl/operators.py", line 294, in sym
return Sym(A)
File "/usr/lib/python2.7/dist-packages/ufl/tensoralgebra.py", line 466, in __new__
error("Cannot take symmetric part of rectangular matrix with dimensions %s." % (sh,))
File "/usr/lib/python2.7/dist-packages/ufl/log.py", line 172, in error
raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Cannot take symmetric part of rectangular matrix with dimensions (3, 2).
Aborted (core dumped)
```

Best Regards and thank you.
Community: FEniCS Project

### 1 Answer

0

I noticed you are using

`Identity(2)`

when you should be using `Identity(3)`

. This won't fix the issue with `shape(grad(u_))`

though. On another note, have you double checked the geometric and topological dimensions of your mesh once it is loaded? E.g.```
print(mesh.geometry().dim())
print(mesh.topology().dim())
```

Please login to add an answer/comment or follow this question.

If you're working in 2D, your displacement should also have dim=2. Or just omit the dim kwarg in the VectorFunctionSpace creation and let it derive the dim from your mesh argument.

The gradient of a 2D vector on a 2D domain is a 2x2 matrix, the gradient of a 3D vector on a 3D domain is a 3x3 matrix. The gradient of a 3D vector on a 2D domain is a 3x2 matrix.

I defined the vector ps like

and in the command (u_ is defined in my previous code )

the following error message is raised :

`ufl_shape()`

method on objects.If your

`Fs`

is a scalar, your code should work. But I can't try it out myself right now..`.`

I wrote the code :

and I got the answer : So it appears that fenics doesn't understand that my model is 3D altough my mesh is like this.

3Dmesh

It seems your mesh is surface mesh not volume mesh (please refer to above mesh). Define mesh as volume mesh in GMSH.the command "print(mesh.geometry().dim())" returns me 2 for this mesh. I do not understand why my final mesh is interpreted as a 2D mesh in my fenics script. look here, it seems to be a volume mesh. Moreover, gmsh tells me that it is meshing volume. Can I force te dimension of the mesh in fenics ?

My .geo script is the following :

And I use dolfin-convert to convert my .msh to a .xml format.

And my first command lines in my fenics script are : have a good day.

I use Gmesh3 to produce my mesh. I start with my .geo file and I mesh it (in 3D mode of course) and I visualize this mesh in the graphic interface. However when I re-open the .msh file I got this one.

I really don't understand why. how do you got the mesh you showed me hirshikesh?