### Error when introducing multifunctional spaces to a 3D domain

244

views

0

Dear all

I have this error message when I change from 2D domain to 3D domain. The problem come from the definition of multi-functional spaces.

If you have any ideas, please let me know.

Best regards

Code:

Error message:

I have this error message when I change from 2D domain to 3D domain. The problem come from the definition of multi-functional spaces.

If you have any ideas, please let me know.

Best regards

Code:

```
from __future__ import print_function
from fenics import *
import numpy as np
from pylab import show, triplot
from mshr import *
xLength = 100.0
yLength = 100.0
zLength = 20.0
#mesh = UnitSquareMesh(30,30) # Work correctly
mesh = BoxMesh(Point(0.0, 0.0, 0.0), Point(xLength, yLength, zLength), 40, 40, 2) # Get error
# Define functional space
Q = FiniteElement('Lagrange', triangle, 1)
V = FiniteElement('Lagrange', triangle, 1)
element = Q*V
W = FunctionSpace(mesh, element)
# Hold plot
interactive()
```

Error message:

```
W = FunctionSpace(mesh, element)
File "/usr/lib/python2.7/dist-packages/dolfin/functions/functionspace.py", line 197, in __init__
self._init_from_ufl(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/dolfin/functions/functionspace.py", line 215, in _init_from_ufl
ufl.FunctionSpace.__init__(self, mesh.ufl_domain(), element)
File "/usr/lib/python2.7/dist-packages/ufl/functionspace.py", line 58, in __init__
error("Non-matching cell of finite element and domain.")
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: Non-matching cell of finite element and domain.
Aborted (core dumped)
```

Community: FEniCS Project

### 1 Answer

3

3D meshes have elements defined on tetrahedra, not triangles.

I replace triangle by tetrahedron and it works. Thank you.

written
9 months ago by
Duy Duc NGUYEN

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