pymor.discretizations package¶
Submodules¶
basic module¶
-
class
pymor.discretizations.basic.DiscretizationBase(operators=None, products=None, estimator=None, visualizer=None, cache_region=None, name=None, **kwargs)[source]¶ Bases:
pymor.discretizations.interfaces.DiscretizationInterfaceBase class for
Discretizationsproviding some common functionality.Methods
Attributes
-
visualize(U, **kwargs)[source]¶ Visualize a solution
VectorArrayU.Parameters
- U
- The
VectorArrayfromsolution_spacethat shall be visualized. - kwargs
- See docstring of
self.visualizer.visualize.
-
-
class
pymor.discretizations.basic.InstationaryDiscretization(T, initial_data, operator, rhs, mass=None, time_stepper=None, num_values=None, products=None, operators=None, parameter_space=None, estimator=None, visualizer=None, cache_region=None, name=None)[source]¶ Bases:
pymor.discretizations.basic.DiscretizationBaseGeneric class for discretizations of instationary problems.
This class describes instationary problems given by the equations:
M * ∂_t u(t, μ) + L(u(μ), t, μ) = F(t, μ) u(0, μ) = u_0(μ)for t in [0,T], where L is a (possibly non-linear) time-dependent
Operator, F is a time-dependent linearFunctional, and u_0 the initial data. The massOperatorM is assumed to be linear, time-independent andParameter-independent.Parameters
- T
- The final time T.
- initial_data
- The initial data
u_0. Either aVectorArrayof length 1 or (for theParameter-dependent case) a vector-likeOperator(i.e. a linearOperatorwithsource.dim == 1) which applied toNumpyVectorArray(np.array([1]))will yield the initial data for a givenParameter. - operator
- The
OperatorL. - rhs
- The
FunctionalF. - mass
- The mass
OperatorM. IfNone, the identity is assumed. - time_stepper
- The
time-stepperto be used bysolve. - num_values
- The number of returned vectors of the solution trajectory. If
None, each intermediate vector that is calculated is returned. - products
- A dict of product
Operatorsdefined on the discrete space the problem is posed on. For each product a corresponding norm is added as a method of the discretization. - operators
- A dict of additional
Operatorsassociated with the discretization. - parameter_space
- The
ParameterSpacefor which the discrete problem is posed. - estimator
- An error estimator for the problem. This can be any object with
an
estimate(U, mu, discretization)method. Ifestimatoris notNone, anestimate(U, mu)method is added to the discretization which will callestimator.estimate(U, mu, self). - visualizer
- A visualizer for the problem. This can be any object with
a
visualize(U, discretization, ...)method. Ifvisualizeris notNone, avisualize(U, *args, **kwargs)method is added to the discretization which forwards its arguments to the visualizer’svisualizemethod. - cache_region
Noneor name of theCacheRegionto use.- name
- Name of the discretization.
Methods
Attributes
-
T¶ The final time T.
-
initial_data¶ The intial data u_0 given by a vector-like
Operator. The same asoperators['initial_data'].
-
rhs¶ The
FunctionalF. The same asoperators['rhs'].
-
mass¶ The mass operator M. The same as
operators['mass'].
-
time_stepper¶ The provided
time-stepper.
-
class
pymor.discretizations.basic.StationaryDiscretization(operator, rhs, products=None, operators=None, parameter_space=None, estimator=None, visualizer=None, cache_region=None, name=None)[source]¶ Bases:
pymor.discretizations.basic.DiscretizationBaseGeneric class for discretizations of stationary problems.
This class describes discrete problems given by the equation:
L(u(μ), μ) = F(μ)
with a linear functional F and a (possibly non-linear) operator L.
Parameters
- operator
- The
OperatorL. - rhs
- The
FunctionalF. - products
- A dict of inner product
Operatorsdefined on the discrete space the problem is posed on. For each product a corresponding norm is added as a method of the discretization. - operators
- A dict of additional
Operatorsassociated with the discretization. - parameter_space
- The
ParameterSpacefor which the discrete problem is posed. - estimator
- An error estimator for the problem. This can be any object with
an
estimate(U, mu, discretization)method. Ifestimatoris notNone, anestimate(U, mu)method is added to the discretization which will callestimator.estimate(U, mu, self). - visualizer
- A visualizer for the problem. This can be any object with
a
visualize(U, discretization, ...)method. Ifvisualizeris notNone, avisualize(U, *args, **kwargs)method is added to the discretization which forwards its arguments to the visualizer’svisualizemethod. - cache_region
Noneor name of theCacheRegionto use.- name
- Name of the discretization.
Methods
Attributes
-
rhs¶ The
FunctionalF. The same asoperators['rhs'].
interfaces module¶
-
class
pymor.discretizations.interfaces.DiscretizationInterface[source]¶ Bases:
pymor.core.cache.CacheableInterface,pymor.parameters.base.ParametricInterface for discretization objects.
A discretization object defines a discrete problem via its
classand theOperatorsit contains. Furthermore, discretizatoins can besolvedfor a givenParameterresulting in a solutionVectorArray.Methods
Attributes
-
solution_space¶ VectorSpaceInterfaceof theVectorArraysreturned bysolve.
-
linear¶ Trueif the discretization describes a linear problem.
-
operators¶ Dictionary of all
Operatorscontained in the discretization (seeGenericRBReductorfor a usage example).
-
estimate(U, mu=None)[source]¶ Estimate the discretization error for a given solution.
The discretization error could be the error w.r.t. the analytical solution of the given problem or the model reduction error w.r.t. a corresponding high-dimensional
Discretization.Returns
The estimated error.
-
solve(mu=None, **kwargs)[source]¶ Solve the discrete problem for the
Parametermu.The result will be
cachedin case caching has been activated for the given discretization.Parameters
- mu
Parameterfor which to solve.
Returns
The solution given as a
VectorArray.
-
visualize(U, **kwargs)[source]¶ Visualize a solution
VectorArrayU.Parameters
- U
- The
VectorArrayfromsolution_spacethat shall be visualized.
-
mpi module¶
-
class
pymor.discretizations.mpi.MPIDiscretization(obj_id, operators, products=None, pickle_local_spaces=True, space_type=<class 'pymor.vectorarrays.mpi.MPIVectorSpace'>)[source]¶ Bases:
pymor.discretizations.basic.DiscretizationBaseWrapper class for MPI distributed
Discretizations.Given a single-rank implementation of a
Discretization, this wrapper class uses the event loop frompymor.tools.mpito allow an MPI distributed usage of theDiscretization. The underlying implementation needs to be MPI aware. In particular, the discretization’ssolvemethod has to perform an MPI parallel solve of the discretization.Note that this class is not intended to be instantiated directly. Instead, you should use
mpi_wrap_discretization.Parameters
- obj_id
ObjectIdof the localDiscretizationon each rank.- operators
- Dictionary of all
Operatorscontained in the discretization, wrapped for use on rank 0. Usempi_wrap_discretizationto automatically wrap all operators of a given MPI-awareDiscretization. - products
- See
operators. - pickle_local_spaces
- See
MPIOperator. - space_type
- See
MPIOperator.
Methods
Attributes
-
class
pymor.discretizations.mpi.MPIVisualizer(d_obj_id)[source]¶
-
pymor.discretizations.mpi.mpi_wrap_discretization(local_discretizations, use_with=False, with_apply2=False, pickle_local_spaces=True, space_type=<class 'pymor.vectorarrays.mpi.MPIVectorSpace'>)[source]¶ Wrap MPI distributed local
Discretizationsto a globalDiscretizationon rank 0.Given MPI distributed local
Discretizationsreferred to by theObjectIdlocal_discretizations, return a newDiscretizationwhich manages these distributed discretizations from rank 0. This is done by first wrapping allOperatorsof theDiscretizationusingmpi_wrap_operator.Alternatively,
local_discretizationscan be a callable (with no arguments) which is then called on each rank to instantiate the localDiscretizations.When
use_withisFalse, anMPIDiscretizationis instantiated with the wrapped operators. A call tosolvewill then use an MPI parallel call to thesolvemethods of the wrapped localDiscretizationsto obtain the solution. This is usually what you want when the actual solve is performed by an implementation in the external solver.When
use_withisTrue,with_is called on the localDiscretizationon rank 0, to obtain a newDiscretizationwith the wrapped MPIOperators. This is mainly useful when the local discretizations are genericDiscretizationsas inpymor.discretizations.basicandsolveis implemented directly in pyMOR via operations on the containedOperators.Parameters
- local_discretizations
ObjectIdof the localDiscretizationson each rank or a callable generating theDiscretizations.- use_with
- See above.
- with_apply2
- See
MPIOperator. - pickle_local_spaces
- See
MPIOperator. - space_type
- See
MPIOperator.