Error when introducing multifunctional spaces to a 3D domain

7 months ago by
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
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

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

7 months ago by
3D meshes have elements defined on tetrahedra, not triangles.
I replace triangle by tetrahedron and it works. Thank you. 
written 7 months ago by Duy Duc NGUYEN  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »