MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / FunctionSpace

Class FunctionSpace

python/dolfinx/fem/function.py:711–865  ·  view source on GitHub ↗

A space on which Functions (fields) can be defined.

Source from the content-addressed store, hash-verified

709
710
711class FunctionSpace(ufl.FunctionSpace, Generic[Real]):
712 """A space on which Functions (fields) can be defined."""
713
714 _cpp_object: _cpp.fem.FunctionSpace_float32 | _cpp.fem.FunctionSpace_float64
715 _mesh: Mesh[Real]
716
717 def __init__(
718 self,
719 mesh: Mesh[Real],
720 element: ufl.finiteelement.AbstractFiniteElement,
721 cppV: (_cpp.fem.FunctionSpace_float32 | _cpp.fem.FunctionSpace_float64),
722 ):
723 """Create a finite element function space.
724
725 Note:
726 This initialiser is for internal use and not normally called
727 in user code. Use :func:`functionspace` to create a function
728 space.
729
730 Args:
731 mesh: Mesh that space is defined on.
732 element: UFL finite element.
733 cppV: Compiled C++ function space.
734 """
735 if mesh._cpp_object is not cppV.mesh:
736 raise RuntimeError("Meshes do not match in function space initialisation.")
737 ufl_domain = mesh.ufl_domain()
738 self._cpp_object = cppV
739 self._mesh = mesh
740 super().__init__(ufl_domain, element)
741
742 def clone(self) -> FunctionSpace[Real]:
743 """Create a FunctionSpace which shares data with this space.
744
745 The new space has a different unique integer ID.
746
747 Create a new FunctionSpace :math:`W` which shares data with this
748 FunctionSpace :math:`V`, but with a different unique integer ID.
749
750 This function is helpful for defining mixed problems and using
751 blocked linear algebra. For example, a matrix block defined on
752 the spaces :math:`V \\times W` where, :math:`V` and :math:`W`
753 are defined on the same finite element and mesh can be
754 identified as an off-diagonal block whereas the :math:`V \\times
755 V` and :math:`V \\times V` matrices can be identified as
756 diagonal blocks. This is relevant for the handling of boundary
757 conditions.
758
759 Returns:
760 A new function space that shares data
761 """ # noqa: D301
762 try:
763 Vcpp = _cpp.fem.FunctionSpace_float64(
764 self._cpp_object.mesh, self._cpp_object.element, self._cpp_object.dofmap
765 ) # type: ignore
766 except TypeError:
767 Vcpp = _cpp.fem.FunctionSpace_float32(
768 self._cpp_object.mesh, self._cpp_object.element, self._cpp_object.dofmap

Callers 6

collapseMethod · 0.70
functionspaceFunction · 0.70
cloneMethod · 0.70
subMethod · 0.70
collapseMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected