Exemple #1
0
    def __init__(self,
                 V: functionspace.FunctionSpace,
                 x: typing.Optional[PETSc.Vec] = None,
                 name: typing.Optional[str] = None):
        """Initialize finite element Function."""

        # Create cpp Function
        if x is not None:
            self._cpp_object = cpp.function.Function(V._cpp_object, x)
        else:
            self._cpp_object = cpp.function.Function(V._cpp_object)

        # Initialize the ufl.FunctionSpace
        super().__init__(V.ufl_function_space(), count=self._cpp_object.id)

        # Set name
        if name is None:
            self.rename("f_{}".format(self.count()))
        else:
            self.rename(name)

        # Store DOLFIN FunctionSpace object
        self._V = V
Exemple #2
0
 def __init__(self, V: FunctionSpace, number: int, part: int = None):
     """Create a UFL/DOLFIN Argument"""
     ufl.Argument.__init__(self, V.ufl_function_space(), number, part)
     self._V = V