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.CopyOnWriteVector
Wraps a FEniCS vector to make it usable with ListVectorArray.
- class pymor.bindings.fenics.ComplexifiedFenicsVector(real_part, imag_part)[source]¶
Bases:
pymor.vectorarrays.list.ComplexifiedVector
Interface for vectors used in conjunction with
ListVectorArray
.This interface must be satisfied by the individual entries of the vector
list
managed byListVectorArray
. All interface methods have a direct counterpart in theVectorArray
interface.
- 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.LinearComplexifiedListVectorArrayOperatorBase
Wraps 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
Operator
which represents the sumc_1*O_1 + ... + c_N*O_N + s*I
where
O_i
areOperators
,c_i
,s
scalar coefficients andI
the identity.This method is called in the
assemble
method ofLincombOperator
on 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 returnsNone
to indicate that assembly is not possible.Parameters
- operators
List of
Operators
O_i
whose linear combination is formed.- coefficients
List of the corresponding linear coefficients
c_i
.- identity_shift
The coefficient
s
.- solver_options
solver_options
for the assembled operator.- name
Name of the assembled operator.
Returns
The assembled
Operator
if 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.Operator
Wraps a FEniCS form as an
Operator
.- apply(self, U, mu=None)[source]¶
Apply the operator to a
VectorArray
.Parameters
- U
VectorArray
of vectors to which the operator is applied.- mu
The
parameter values
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.
- jacobian(self, U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator
.Parameters
- U
Length 1
VectorArray
containing the vector for which to compute the Jacobian.- mu
The
parameter values
for which to compute the Jacobian.
Returns
Linear
Operator
representing 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_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the 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 interpolation
where 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_dofs
will 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 array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
- restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
.- source_dofs
One-dimensional
NumPy array
of source degrees of freedom as defined above.
- class pymor.bindings.fenics.RestrictedFenicsOperator(op, restricted_range_dofs)[source]¶
Bases:
pymor.operators.interface.Operator
Interface for
Parameter
dependent discrete operators.An operator in pyMOR is simply a mapping which for any given
parameter values
maps vectors from itssource
VectorSpace
to vectors in itsrange
VectorSpace
.Note that there is no special distinction between functionals and operators in pyMOR. A functional is simply an operator with
NumpyVectorSpace
(1)
as itsrange
VectorSpace
.- 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_options
isNone
or 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_options
should 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
VectorArray
of vectors to which the operator is applied.- mu
The
parameter values
for which to evaluate the operator.
Returns
VectorArray
of the operator evaluations.
- jacobian(self, U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator
.Parameters
- U
Length 1
VectorArray
containing the vector for which to compute the Jacobian.- mu
The
parameter values
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.
- class pymor.bindings.fenics.FenicsVisualizer(space, mesh_refinements=0)[source]¶
Bases:
pymor.core.base.ImmutableObject
Visualize a FEniCS grid function.
Parameters
- space
The
FenicsVectorSpace
for 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
VectorArray
of the data to visualize (length must be 1). Alternatively, a tuple ofVectorArrays
which will be visualized in separate windows. Iffilename
is specified, only oneVectorArray
may 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
U
is a tuple ofVectorArrays
,legend
has to be a tuple of the same length.- filename
If specified, write the data to that file.
filename
needs 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.