pymor.bindings.fenics¶
Module Contents¶
Classes¶
Wraps a FEniCS vector to make it usable with ListVectorArray. |
|
Interface for vectors used in conjunction with |
|
Wraps a FEniCS matrix as an |
|
Wraps a FEniCS form as an |
|
Interface for |
|
Visualize a FEniCS grid function. |
Functions¶
- 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.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.
- class pymor.bindings.fenics.FenicsVectorSpace(V, id='STATE')[source]¶
- class pymor.bindings.fenics.FenicsMatrixOperator(matrix, source_space, range_space, solver_options=None, name=None)[source]¶
Bases:
pymor.operators.list.LinearComplexifiedListVectorArrayOperatorBaseWraps a FEniCS matrix as an
Operator.- _real_apply_inverse_one_vector(self, v, mu=None, initial_guess=None, least_squares=False, prepare_data=None)[source]¶
- _real_apply_inverse_adjoint_one_vector(self, u, mu=None, initial_guess=None, least_squares=False, prepare_data=None)[source]¶
- _assemble_lincomb(self, operators, coefficients, identity_shift=0.0, solver_options=None, name=None)[source]¶
Try to assemble a linear combination of the given operators.
Returns a new
Operatorwhich represents the sumc_1*O_1 + ... + c_N*O_N + s*I
where
O_iareOperators,c_i,sscalar coefficients andIthe identity.This method is called in the
assemblemethod ofLincombOperatoron the first of its operators. If an assembly of the given linear combination is possible, e.g. the linear combination of the system matrices of the operators can be formed, then the assembled operator is returned. Otherwise, the method returnsNoneto indicate that assembly is not possible.Parameters
- operators
List of
OperatorsO_iwhose linear combination is formed.- coefficients
List of the corresponding linear coefficients
c_i.- identity_shift
The coefficient
s.- solver_options
solver_optionsfor the assembled operator.- name
Name of the assembled operator.
Returns
The assembled
Operatorif assembly is possible, otherwiseNone.
- class pymor.bindings.fenics.FenicsOperator(form, source_space, range_space, source_function, dirichlet_bcs=(), parameter_setter=None, parameters={}, solver_options=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorWraps a FEniCS form as an
Operator.- apply(self, 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
VectorArrayof the operator evaluations.
- jacobian(self, U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator.Parameters
- U
Length 1
VectorArraycontaining the vector for which to compute the Jacobian.- mu
The
parameter valuesfor which to compute the Jacobian.
Returns
Linear
Operatorrepresenting the Jacobian.
- restricted(self, 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(NumpyVectorArray(U.dofs(source_dofs)), mu))
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.RestrictedFenicsOperator(op, restricted_range_dofs)[source]¶
Bases:
pymor.operators.interface.OperatorInterface for
Parameterdependent discrete operators.An operator in pyMOR is simply a mapping which for any given
parameter valuesmaps vectors from itssourceVectorSpaceto vectors in itsrangeVectorSpace.Note that there is no special distinction between functionals and operators in pyMOR. A functional is simply an operator with
NumpyVectorSpace(1)as itsrangeVectorSpace.- solver_options[source]¶
If not
None, a dict which can contain the following keys:- ‘inverse’
solver options used for
apply_inverse- ‘inverse_adjoint’
solver options used for
apply_inverse_adjoint- ‘jacobian’
solver options for the operators returned by
jacobian(has no effect for linear operators)
If
solver_optionsisNoneor a dict entry is missing orNone, default options are used. The interpretation of the given solver options is up to the operator at hand. In general, values insolver_optionsshould either be strings (indicating a solver type) or dicts of options, usually with an entry'type'which specifies the solver type to use and further items which configure this solver.
- source[source]¶
The source
VectorSpace.
- range[source]¶
The range
VectorSpace.
- H[source]¶
The adjoint operator, i.e.
self.H.apply(V, mu) == self.apply_adjoint(V, mu)
for all V, mu.
- apply(self, 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
VectorArrayof the operator evaluations.
- jacobian(self, U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator.Parameters
- U
Length 1
VectorArraycontaining the vector for which to compute the Jacobian.- mu
The
parameter valuesfor which to compute the Jacobian.
Returns
Linear
Operatorrepresenting the Jacobian.
- 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).
- visualize(self, 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.