def __init__(self, mesh, ufc_finite_element, ufc_dofmap): self._mesh = mesh self._finite_element = cpp.FiniteElement(ufc_finite_element) self._dofmap = cpp.DofMap(ufc_dofmap, mesh) self._ufc_finite_element = ufc_finite_element self._ufc_dofmap = ufc_dofmap cpp.FunctionSpace.__init__(self, mesh, finite_element, dofmap)
def __init__(self, mesh, element, constrained_domain=None): """Create function space on given mesh for given finite element. *Arguments* mesh A :py:class:`Mesh <dolfin.cpp.Mesh>` element A :py:class:`(UFL) FiniteElement <ufl.FiniteElementBase>` """ # Store reference to constrained domain to avoid possible SWIG # director memory error (see # https://bitbucket.org/fenics-project/dolfin/issue/71) self.constrained_domain = constrained_domain # Check arguments if not isinstance(mesh, (cpp.Mesh, cpp.Restriction)): cpp.dolfin_error( "functionspace.py", "create function space", "Illegal argument, not a mesh or restriction: " + str(mesh)) if not isinstance(element, (ufl.FiniteElementBase)): cpp.dolfin_error( "functionspace.py", "create function space", "Illegal argument, not a finite element: " + str(element)) if constrained_domain is not None: if not isinstance(constrained_domain, cpp.SubDomain): cpp.dolfin_error( "functionspace.py", "create function space", "Illegal argument, not a subdomain: " + str(constrained_domain)) # Store element Note: self._ufl_element cannot be a private # attribute as we want to be able to set the element from a # derived class. self._ufl_element = element # JIT-compile element to get ufc_element and ufc_dofmap ufc_element, ufc_dofmap = jit(self._ufl_element, mpi_comm=mesh.mpi_comm()) # Instantiate DOLFIN FiniteElement and DofMap self._dolfin_element = cpp.FiniteElement(ufc_element) if constrained_domain is not None: if isinstance(mesh, cpp.Restriction): cpp.dolfin_error( "functionspace.py", "create function space", "Cannot use constrained domains together with restrictions." ) dolfin_dofmap = cpp.DofMap(ufc_dofmap, mesh, constrained_domain) else: if isinstance(mesh, cpp.Restriction): dolfin_dofmap = cpp.DofMap(ufc_dofmap, mesh) mesh = mesh.mesh() else: dolfin_dofmap = cpp.DofMap(ufc_dofmap, mesh) # Initialize the cpp_FunctionSpace cpp.FunctionSpace.__init__(self, mesh, self._dolfin_element, dolfin_dofmap)
def __init__(self, mesh, element, constrained_domain=None): """Create function space on given mesh for given finite element. *Arguments* mesh A :py:class:`Mesh <dolfin.cpp.Mesh>` element A :py:class:`(UFL) FiniteElement <ufl.FiniteElementBase>` """ # Check arguments if not isinstance(mesh, (cpp.Mesh, cpp.Restriction)): cpp.dolfin_error("functionspace.py", "create function space", "Illegal argument, not a mesh or restriction: " + str(mesh)) if not isinstance(element, (ufl.FiniteElementBase)): cpp.dolfin_error("functionspace.py", "create function space", "Illegal argument, not a finite element: " + str(element)) if constrained_domain is not None: if not isinstance(constrained_domain, cpp.SubDomain): cpp.dolfin_error("functionspace.py", "create function space", "Illegal argument, not a subdomain: " + str(constrained_domain)) # Store element # Note: self._element cannot be a private attribute as we want to be able to # set the element from a derived class. self._ufl_element = element # JIT-compile element to get ufc_element and ufc_dofmap ufc_element, ufc_dofmap = jit(self._ufl_element) # Instantiate DOLFIN FiniteElement and DofMap self._dolfin_element = cpp.FiniteElement(ufc_element) if constrained_domain is not None: if isinstance(mesh, cpp.Restriction): cpp.dolfin_error("functionspace.py", "create function space", "Cannot use constrained domains together with restrictions.") dolfin_dofmap = cpp.DofMap(ufc_dofmap, mesh, constrained_domain) else: if isinstance(mesh, cpp.Restriction): dolfin_dofmap = cpp.DofMap(ufc_dofmap, mesh) mesh = mesh.mesh() else: dolfin_dofmap = cpp.DofMap(ufc_dofmap, mesh) # Initialize the cpp_FunctionSpace cpp.FunctionSpace.__init__(self, mesh, self._dolfin_element, dolfin_dofmap)
def __init__(self, mesh, ufc_finite_element, ufc_dofmap, constrained_domain=None): " Initialize a FunctionSpace from ufc data " self._mesh = mesh self._finite_element = cpp.FiniteElement(ufc_finite_element) if constrained_domain is None: self._dofmap = cpp.DofMap(ufc_dofmap, mesh) else: self._dofmap = cpp.DofMap(ufc_dofmap, mesh, constrained_domain) self._ufc_finite_element = ufc_finite_element self._ufc_dofmap = ufc_dofmap cpp.FunctionSpace.__init__(self, self._mesh, self._finite_element, \ self._dofmap)
def _compile_dolfin_element(element, mesh, constrained_domain=None): "Instantiate DOLFIN FiniteElement and DofMap from ufl element." # JIT-compile element to get ufc_element and ufc_dofmap ufc_element, ufc_dofmap = jit(element, mpi_comm=mesh.mpi_comm()) dolfin_element = cpp.FiniteElement(ufc_element) if constrained_domain is None: dolfin_dofmap = cpp.DofMap(ufc_dofmap, mesh) else: dolfin_dofmap = cpp.DofMap(ufc_dofmap, mesh, constrained_domain) return dolfin_element, dolfin_dofmap
def __init__(self, mesh, ufc_finite_element, ufc_dofmap, constrained_domain=None): " Initialize a FunctionSpace from ufc data " self._mesh = mesh self._finite_element = cpp.FiniteElement(ufc_finite_element) if constrained_domain is None: self._dofmap = cpp.DofMap(ufc_dofmap, mesh) else: self._dofmap = cpp.DofMap(ufc_dofmap, mesh, constrained_domain) self._ufc_finite_element = ufc_finite_element self._ufc_dofmap = ufc_dofmap cpp.FunctionSpace.__init__(self, self._mesh, self._finite_element, \ self._dofmap) # Store reference to constrained domain to avoid possible SWIG # director memory error (see # https://bitbucket.org/fenics-project/dolfin/issue/71) self.constrained_domain = constrained_domain