pymor.bindings.fenics¶
Module Contents¶
- class pymor.bindings.fenics.ComplexifiedFenicsVector(real_part, imag_part)[source]¶
Bases:
pymor.vectorarrays.list.ComplexifiedVectorInterface for vectors used in conjunction with
ListVectorArray.This interface must be satisfied by the individual entries of the vector
listmanaged byListVectorArray. All interface methods have a direct counterpart in theVectorArrayinterface.Methods
- class pymor.bindings.fenics.FenicsLinearSolver(method=_DEFAULT_SOLVER, preconditioner=None, keep_solver=True)[source]¶
Bases:
pymor.solvers.list.ComplexifiedListVectorArrayBasedSolverBase class for
SolversforListVectorArray-basedOperators.
- class pymor.bindings.fenics.FenicsMatrixBasedOperator(form, params, bc=None, bc_zero=False, functional=False, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorWraps a parameterized FEniCS linear or bilinear form as an
Operator.- Parameters:
form – The
Formobject which is assembled to a matrix or vector.params – Dict mapping parameters to dolfin
Constantsas returned byto_fenics.bc – dolfin
DirichletBCobject to be applied.bc_zero – If
Truealso clear the diagonal entries of Dirichlet dofs.functional – If
Truereturn aVectorFunctionalinstead of aVectorOperatorin caseformis a linear form.solver – The
Solverfor the operator.name – Name of the operator.
Methods
Apply the operator to a
VectorArray.Apply the adjoint operator.
Return a
VectorArrayrepresentation of the operator in its range space.Return a
VectorArrayrepresentation of the operator in its source space.Assemble the operator for given
parameter values.- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor which to evaluate the operator.
- Returns:
|VectorArray| of the operator evaluations.
- apply_adjoint(V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor which to apply the adjoint operator.
- Returns:
|VectorArray| of the adjoint operator evaluations.
- as_range_array(mu=None)[source]¶
Return a
VectorArrayrepresentation of the operator in its range space.In the case of a linear operator with
NumpyVectorSpaceassource, this method returns for givenparameter valuesmuaVectorArrayVin the operator’srange, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArraysU.- Parameters:
mu – The
parameter valuesfor which to return theVectorArrayrepresentation.- Returns:
V – The
VectorArraydefined above.
- as_source_array(mu=None)[source]¶
Return a
VectorArrayrepresentation of the operator in its source space.In the case of a linear operator with
NumpyVectorSpaceasrange, this method returns for givenparameter valuesmuaVectorArrayVin the operator’ssource, such thatself.range.make_array(V.inner(U)) == self.apply(U, mu)
for all
VectorArraysU.- Parameters:
mu – The
parameter valuesfor which to return theVectorArrayrepresentation.- Returns:
V – The
VectorArraydefined above.
- assemble(mu=None)[source]¶
Assemble the operator for given
parameter values.The result of the method strongly depends on the given operator. For instance, a matrix-based operator will assemble its matrix, a
LincombOperatorwill try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on aParameter.If the operator has a
Solver, the assembledOperatorwill be equipped with the sameSolver.- Parameters:
mu – The
parameter valuesfor which to assemble the operator.- Returns:
Parameter-independent, assembled |Operator|.
- class pymor.bindings.fenics.FenicsMatrixOperator(matrix, source_space, range_space, solver=None, name=None)[source]¶
Bases:
pymor.operators.list.LinearComplexifiedListVectorArrayOperatorBaseWraps a FEniCS matrix as an
Operator.
- class pymor.bindings.fenics.FenicsOperator(form, source_space, range_space, source_function, dirichlet_bcs=(), parameter_setter=None, parameters={}, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorWraps a FEniCS form as an
Operator.Methods
Apply the operator to a
VectorArray.Return the operator's Jacobian as a new
Operator.Restrict the operator range to a given set of degrees of freedom.
- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor which to evaluate the operator.
- Returns:
|VectorArray| of the operator evaluations.
- jacobian(U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator.If the operator has a
Solver, the JacobianOperatorwill be equipped with the solver’sjacobian_solver.- Parameters:
U – Length 1
VectorArraycontaining the vector for which to compute the Jacobian.mu – The
parameter valuesfor which to compute the Jacobian.
- Returns:
Linear |Operator| representing the Jacobian.
- restricted(dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(restricted_op.source.from_numpy(U.dofs(source_dofs)) mu).to_numpy()
Such an operator is mainly useful for
empirical interpolationwhere the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofswill be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.- Parameters:
dofs – One-dimensional
NumPy arrayof degrees of freedom in the operatorrangeto which to restrict.- Returns:
restricted_op – The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.source_dofs – One-dimensional
NumPy arrayof source degrees of freedom as defined above.
- class pymor.bindings.fenics.FenicsVector(impl)[source]¶
Bases:
pymor.vectorarrays.list.CopyOnWriteVectorWraps a FEniCS vector to make it usable with ListVectorArray.
- class pymor.bindings.fenics.FenicsVectorSpace(V)[source]¶
Bases:
pymor.vectorarrays.list.ComplexifiedListVectorSpaceVectorSpaceofListVectorArrays.Methods
- class pymor.bindings.fenics.FenicsVisualizer(space, mesh_refinements=0)[source]¶
Bases:
pymor.core.base.ImmutableObjectVisualize a FEniCS grid function.
- Parameters:
space – The
FenicsVectorSpacefor which we want to visualize DOF vectors.mesh_refinements – Number of uniform mesh refinements to perform for vtk visualization (of functions from higher-order FE spaces).
Methods
Visualize the provided data.
- visualize(U, title='', legend=None, filename=None, block=True, separate_colorbars=True)[source]¶
Visualize the provided data.
- Parameters:
U –
VectorArrayof the data to visualize (length must be 1). Alternatively, a tuple ofVectorArrayswhich will be visualized in separate windows. Iffilenameis specified, only oneVectorArraymay be provided which, however, is allowed to contain multiple vectors that will be interpreted as a time series.title – Title of the plot.
legend – Description of the data that is plotted. If
Uis a tuple ofVectorArrays,legendhas to be a tuple of the same length.filename – If specified, write the data to that file.
filenameneeds to have an extension supported by FEniCS (e.g..pvd).separate_colorbars – If
True, use separate colorbars for each subplot.block – If
True, block execution until the plot window is closed.
- class pymor.bindings.fenics.RestrictedFenicsOperator(op, restricted_range_dofs, solver=None)[source]¶
Bases:
pymor.operators.interface.OperatorRestricted
FenicsOperator.Methods
Apply the operator to a
VectorArray.Return the operator's Jacobian as a new
Operator.- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor which to evaluate the operator.
- Returns:
|VectorArray| of the operator evaluations.
- jacobian(U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator.If the operator has a
Solver, the JacobianOperatorwill be equipped with the solver’sjacobian_solver.- Parameters:
U – Length 1
VectorArraycontaining the vector for which to compute the Jacobian.mu – The
parameter valuesfor which to compute the Jacobian.
- Returns:
Linear |Operator| representing the Jacobian.