pymor.bindings.fenicsx¶
Classes
Wraps a parameterized FEniCSx linear or bilinear form as an |
|
Wraps a FEniCSx matrix as an |
|
Wraps an UFL form as an |
|
Wraps a FEniCSx vector to make it usable with ListVectorArray. |
|
Visualize a FEniCSx grid function. |
|
Restricted |
- class pymor.bindings.fenicsx.ComplexifiedFenicsxVector(real_part, imag_part)[source]¶
Bases:
ComplexifiedVectorAttributes
- class pymor.bindings.fenicsx.FenicsxLinearSolver(comm, method=petsc4py.PETSc.KSP.Type.PREONLY, preconditioner=petsc4py.PETSc.PC.Type.LU, keep_solver=True)[source]¶
Bases:
ComplexifiedListVectorArrayBasedSolverMethods
Attributes
- class pymor.bindings.fenicsx.FenicsxMatrixBasedOperator(ufl_form, params=None, bcs=(), diag=1.0, ufl_lifting_form=None, alpha=1.0, functional=False, solver=None, name=None)[source]¶
Bases:
OperatorWraps a parameterized FEniCSx linear or bilinear form as an
Operator.- Parameters:
ufl_form – The ufl
Formobject which is assembled to a matrix or vector.params – Dict mapping parameters to dolfinx
Constants.bcs – dolfinx
DirichletBCobjects to be applied.diag – Value to put on the diagonal when applying Dirichlet conditions.
ufl_lifting_form – If not
Noneandufl_formrepresents a linear form,apply_liftingis called with this form for the assembled vector.functional – If
Trueandufl_formrepresents a linear form, return aVectorFunctionalinstead of aVectorOperator.solver – The
Solverfor the operator.name – Name of the operator.
Methods
apply,apply_adjoint,as_range_array,as_source_array,assemble_assemble_lincomb,apply2,apply_inverse,apply_inverse_adjoint,as_vector,d_mu,jacobian,pairwise_apply2,restrictedAttributes
parameters,parameters_inherited,parameters_internal,parameters_own,parametric- 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.fenicsx.FenicsxMatrixOperator(matrix, range_space, source_space, solver=None, name=None)[source]¶
Bases:
LinearComplexifiedListVectorArrayOperatorBaseWraps a FEniCSx matrix as an
Operator.
- class pymor.bindings.fenicsx.FenicsxOperator(ufl_form, source_function, params=None, bcs=(), alpha=None, linear=False, apply_lifting_with_jacobian=False, solver=None, name=None)[source]¶
Bases:
OperatorWraps an UFL form as an
Operator.Methods
_assemble_lincomb,apply2,apply_adjoint,apply_inverse,apply_inverse_adjoint,as_range_array,as_source_array,as_vector,assemble,d_mu,pairwise_apply2Attributes
parameters,parameters_inherited,parameters_internal,parameters_own,parametric- 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.fenicsx.FenicsxVector(impl)[source]¶
Bases:
CopyOnWriteVectorWraps a FEniCSx vector to make it usable with ListVectorArray.
Attributes
- class pymor.bindings.fenicsx.FenicsxVectorSpace(V)[source]¶
Bases:
ComplexifiedListVectorSpaceMethods
Attributes
- real_vector_type[source]¶
alias of
FenicsxVector
- vector_type[source]¶
alias of
ComplexifiedFenicsxVector
- class pymor.bindings.fenicsx.FenicsxVisualizer(space)[source]¶
Bases:
ImmutableObjectVisualize a FEniCSx grid function.
- Parameters:
space – The
FenicsxVectorSpacefor which we want to visualize DOF vectors.
Methods
Attributes
- 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.fenicsx.RestrictedFenicsxOperator(op, restricted_range_dofs, solver=None)[source]¶
Bases:
OperatorRestricted
FenicsxOperator.Methods
_assemble_lincomb,apply2,apply_adjoint,apply_inverse,apply_inverse_adjoint,as_range_array,as_source_array,as_vector,assemble,d_mu,pairwise_apply2,restrictedAttributes
parameters,parameters_inherited,parameters_internal,parameters_own,parametric- 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.