def __new__(cls, mesh, family, degree=None, shape=None, symmetry=None, name=None, vfamily=None, vdegree=None): mesh.init() mesh_t = mesh.topology # TensorFunctionSpace shape defaults to the (gdim, gdim) shape = shape or (mesh.ufl_cell().geometric_dimension(), ) * 2 if isinstance(mesh_t.ufl_cell(), ufl.OuterProductCell): raise NotImplementedError( "TensorFunctionSpace on extruded meshes not implemented") else: element = ufl.TensorElement(family, cell=mesh_t.ufl_cell(), degree=degree, shape=shape, symmetry=symmetry) self = super(TensorFunctionSpace, cls).__new__(cls, mesh_t, element, name=name, shape=shape) if mesh is not mesh_t: self = WithGeometry(self, mesh) return self
def __new__(cls, mesh, family, degree=None, dim=None, name=None, vfamily=None, vdegree=None): mesh.init() mesh_t = mesh.topology # VectorFunctionSpace dimension defaults to the geometric dimension of the mesh. dim = dim or mesh.ufl_cell().geometric_dimension() if isinstance(mesh_t.ufl_cell(), ufl.OuterProductCell) and isinstance(family, ufl.OuterProductElement): element = ufl.OuterProductVectorElement(family, dim=dim) elif isinstance(mesh_t.ufl_cell(), ufl.OuterProductCell) and vfamily is not None and vdegree is not None: la = ufl.FiniteElement(family, cell=mesh_t._base_mesh.ufl_cell(), degree=degree) lb = ufl.FiniteElement(vfamily, cell=ufl.interval, degree=vdegree) element = ufl.OuterProductVectorElement(la, lb, dim=dim) else: element = ufl.VectorElement(family, cell=mesh_t.ufl_cell(), degree=degree, dim=dim) self = super(VectorFunctionSpace, cls).__new__(cls, mesh_t, element, name=name, shape=(dim,)) if mesh is not mesh_t: self = WithGeometry(self, mesh) return self
def __new__(cls, mesh, family, degree=None, name=None, vfamily=None, vdegree=None): """Create a function space :arg mesh: mesh to build the function space on :arg family: string describing function space family, or an :class:`~ufl.finiteelement.outerproductelement.OuterProductElement` :arg degree: degree of the function space :arg name: (optional) name of the function space :arg vfamily: family of function space in vertical dimension (extruded meshes only) :arg vdegree: degree of function space in vertical dimension (extruded meshes only) If the mesh is an extruded mesh, and the ``family`` argument is a :class:`~ufl.finiteelement.outerproductelement.OuterProductElement`, ``degree``, ``vfamily`` and ``vdegree`` are ignored, since the ``family`` provides all necessary information, otherwise a :class:`~ufl.finiteelement.outerproductelement.OuterProductElement` is built from the (``family``, ``degree``) and (``vfamily``, ``vdegree``) pair. If the ``vfamily`` and ``vdegree`` are not provided, the vertical element defaults to the same as the (``family``, ``degree``) pair. If the mesh is not an extruded mesh, ``vfamily`` and ``vdegree`` are ignored. """ mesh.init() mesh_t = mesh.topology # Two choices: # 1) Pass in mesh, family, degree to generate a simple function space. # 2) Set up the function space using FiniteElement, EnrichedElement, # OuterProductElement and so on. if isinstance(family, ufl.FiniteElementBase): # Second case... element = family else: # First case... if isinstance(mesh_t.ufl_cell(), ufl.OuterProductCell) and vfamily is not None and vdegree is not None: # If OuterProductCell, make the OuterProductElement la = ufl.FiniteElement(family, cell=mesh_t._base_mesh.ufl_cell(), degree=degree) # If second element was passed in, use it lb = ufl.FiniteElement(vfamily, cell=ufl.interval, degree=vdegree) # Now make the OuterProductElement element = ufl.OuterProductElement(la, lb) else: # Otherwise, just make the element element = ufl.FiniteElement(family, cell=mesh_t.ufl_cell(), degree=degree) self = super(FunctionSpace, cls).__new__(cls, mesh_t, element, name=name) if mesh is not mesh_t: self = WithGeometry(self, mesh) return self
def __new__(cls, mesh, family, degree=None, shape=None, symmetry=None, name=None, vfamily=None, vdegree=None): mesh.init() mesh_t = mesh.topology # TensorFunctionSpace shape defaults to the (gdim, gdim) shape = shape or (mesh.ufl_cell().geometric_dimension(),) * 2 if isinstance(mesh_t.ufl_cell(), ufl.OuterProductCell): raise NotImplementedError("TensorFunctionSpace on extruded meshes not implemented") else: element = ufl.TensorElement(family, cell=mesh_t.ufl_cell(), degree=degree, shape=shape, symmetry=symmetry) self = super(TensorFunctionSpace, cls).__new__(cls, mesh_t, element, name=name, shape=shape) if mesh is not mesh_t: self = WithGeometry(self, mesh) return self
def __new__(cls, mesh, family, degree=None, dim=None, name=None, vfamily=None, vdegree=None): mesh.init() mesh_t = mesh.topology # VectorFunctionSpace dimension defaults to the geometric dimension of the mesh. dim = dim or mesh.ufl_cell().geometric_dimension() if isinstance(mesh_t.ufl_cell(), ufl.OuterProductCell) and isinstance( family, ufl.OuterProductElement): element = ufl.OuterProductVectorElement(family, dim=dim) elif isinstance(mesh_t.ufl_cell(), ufl.OuterProductCell ) and vfamily is not None and vdegree is not None: la = ufl.FiniteElement(family, cell=mesh_t._base_mesh.ufl_cell(), degree=degree) lb = ufl.FiniteElement(vfamily, cell=ufl.interval, degree=vdegree) element = ufl.OuterProductVectorElement(la, lb, dim=dim) else: element = ufl.VectorElement(family, cell=mesh_t.ufl_cell(), degree=degree, dim=dim) self = super(VectorFunctionSpace, cls).__new__(cls, mesh_t, element, name=name, shape=(dim, )) if mesh is not mesh_t: self = WithGeometry(self, mesh) return self
def __new__(cls, mesh, family, degree=None, name=None, vfamily=None, vdegree=None): """Create a function space :arg mesh: mesh to build the function space on :arg family: string describing function space family, or an :class:`~ufl.finiteelement.outerproductelement.OuterProductElement` :arg degree: degree of the function space :arg name: (optional) name of the function space :arg vfamily: family of function space in vertical dimension (extruded meshes only) :arg vdegree: degree of function space in vertical dimension (extruded meshes only) If the mesh is an extruded mesh, and the ``family`` argument is a :class:`~ufl.finiteelement.outerproductelement.OuterProductElement`, ``degree``, ``vfamily`` and ``vdegree`` are ignored, since the ``family`` provides all necessary information, otherwise a :class:`~ufl.finiteelement.outerproductelement.OuterProductElement` is built from the (``family``, ``degree``) and (``vfamily``, ``vdegree``) pair. If the ``vfamily`` and ``vdegree`` are not provided, the vertical element defaults to the same as the (``family``, ``degree``) pair. If the mesh is not an extruded mesh, ``vfamily`` and ``vdegree`` are ignored. """ mesh.init() mesh_t = mesh.topology # Two choices: # 1) Pass in mesh, family, degree to generate a simple function space. # 2) Set up the function space using FiniteElement, EnrichedElement, # OuterProductElement and so on. if isinstance(family, ufl.FiniteElementBase): # Second case... element = family else: # First case... if isinstance(mesh_t.ufl_cell(), ufl.OuterProductCell ) and vfamily is not None and vdegree is not None: # If OuterProductCell, make the OuterProductElement la = ufl.FiniteElement(family, cell=mesh_t._base_mesh.ufl_cell(), degree=degree) # If second element was passed in, use it lb = ufl.FiniteElement(vfamily, cell=ufl.interval, degree=vdegree) # Now make the OuterProductElement element = ufl.OuterProductElement(la, lb) else: # Otherwise, just make the element element = ufl.FiniteElement(family, cell=mesh_t.ufl_cell(), degree=degree) self = super(FunctionSpace, cls).__new__(cls, mesh_t, element, name=name) if mesh is not mesh_t: self = WithGeometry(self, mesh) return self