Skip to content
Snippets Groups Projects
Commit 4df4ac52 authored by Martin Nolte's avatar Martin Nolte
Browse files

migrate construction of UFL cell onto separate function

parent 942f7181
Branches uflconstants
No related tags found
No related merge requests found
from __future__ import absolute_import
import ufl
# cell
# ----
def cell(dimDomain):
if isinstance(dimDomain, tuple):
if len(dimDomain) != 2:
raise Exception('dimDomain tuple must contain exactly two elements.')
dimWorld = int(dimDomain[1])
dimDomain = dimDomain[0]
else:
dimWorld = int(dimDomain)
if dimDomain == 1:
return ufl.Cell("interval", dimWorld)
elif dimDomain == 2:
return ufl.Cell("triangle", dimWorld)
elif dimDomain == 3:
return ufl.Cell("tetrahedron", dimWorld)
else:
raise NotImplementedError('UFL cell not implemented for dimension' + str(dimDomain) + '.')
# Space
# -----
class Space(ufl.VectorElement):
def __init__(self, dimDomain, dimRange):
if isinstance(dimDomain, tuple):
if len(dimDomain) != 2:
raise Exception('dimDomain tuple must contain exactly two elements.')
dimWorld = int(dimDomain[1])
dimDomain = dimDomain[0]
else:
dimWorld = int(dimDomain)
if dimDomain == 1:
cell = ufl.Cell("interval", dimWorld)
elif dimDomain == 2:
cell = ufl.Cell("triangle", dimWorld)
elif dimDomain == 3:
cell = ufl.Cell("tetrahedron", dimWorld)
else:
raise NotImplementedError('dune.ufl.Space not implemented for dimension' + str(dimDomain) + '.')
ufl.VectorElement.__init__(self, "Lagrange", cell, 1, dimRange)
ufl.VectorElement.__init__(self, "Lagrange", cell(dimDomain), 1, dimRange)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment