dune-pdelab  2.0.0
Public Types | List of all members
Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time > Struct Template Reference

Cache for the CachedMultiStepGridOperatorSpace. More...

#include <dune/pdelab/multistep/cache.hh>

Public Types

typedef MultiStepCachePolicy
< Step, Time > 
Policy
 

Public Member Functions

construction and policy management
 MultiStepCache (const shared_ptr< Policy > &policy_=shared_ptr< Policy >(new Policy))
 
shared_ptr< PolicygetPolicy ()
 
shared_ptr< const PolicygetPolicy () const
 
void setPolicy (const shared_ptr< Policy > &policy_)
 
non-linear caching across time steps
shared_ptr< const VectorV > getResidualValue (std::size_t order, Step step) const
 get residual value from the cache More...
 
void setResidualValue (std::size_t order, Step step, const shared_ptr< const VectorV > &residualValue)
 store a residual value in the cache More...
 
methods for the Jacobians of affine operators
shared_ptr< const Matrix > getJacobian (std::size_t order, Step step)
 get a Jacobian from the cache More...
 
void setJacobian (std::size_t order, Step step, const shared_ptr< const Matrix > &jacobian)
 store a Jacobian in the cache More...
 
methods for the zero-residual of affine operators
shared_ptr< const VectorV > getZeroResidual (std::size_t order, Step step) const
 get zero-residual from the cache More...
 
void setZeroResidual (std::size_t order, Step step, const shared_ptr< const VectorV > &zeroResidual)
 store a zero-residual in the cache More...
 
methods for the composed Jacobian of affine operators
shared_ptr< const Matrix > getComposedJacobian (Step step)
 get a composed Jacobian from the cache More...
 
void setComposedJacobian (Step step, const shared_ptr< const Matrix > &jacobian)
 store a composed Jacobian in the cache More...
 
methods to access old values of the unknowns
shared_ptr< const VectorU > getUnknowns (Step step) const
 get vector of unknowns from the cache More...
 
void setUnknowns (Step step, const shared_ptr< const VectorU > &unknowns_)
 store a vector of unknowns in the cache More...
 
methods to flush the cache
void flushAll ()
 Flush all cached values. More...
 
methods for pre-/post-processing
void preStep (Step step, Step stepsOfScheme, Time endTime, Time dt)
 Do some housekeeping before computing a time-step. More...
 
void postStep ()
 Do some housekeeping after computing a time-step. More...
 

Detailed Description

template<class VectorU, class VectorV, class Matrix, class Step = int, class Time = double>
struct Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >

Cache for the CachedMultiStepGridOperatorSpace.

Template Parameters
VectorUType of vectors for the unknowns.
VectorVType of vectors for the residuals.
MatrixType of the Jacobians.
StepType of the step counters (should be integral).
TimeType of the temporal values (should be floating-point).

The MultiStepCache caches four kinds of data:

In addition, there is one item which is store in the cache just like the cached items, but is present mostly because it is a convenient way for the user code to provide an manage that information:

It is always valid for the cache implementation to silently refuse to store a value (except for the vectors of unknowns). The grid operator space must never expect to be able to store a value and immediately be able to extract it again. The grid operator space must always be prepared to recompute a value that cannot be extracted from the cache, and should try to store that value in the cache afterwards.

Note
The cache keeps pointers to the values it stores. The user code must make sure that any value stored in the cache is not later modified, any such modification results in undefined behaviour.

Member Typedef Documentation

template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
typedef MultiStepCachePolicy<Step, Time> Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::Policy

Constructor & Destructor Documentation

template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::MultiStepCache ( const shared_ptr< Policy > &  policy_ = shared_ptr<Policy>(new Policy))
inline

Member Function Documentation

template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
void Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::flushAll ( )
inline

Flush all cached values.

This is useful for instance after adaption. It is equivalent to recreating the cache.

template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
shared_ptr<const Matrix> Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::getComposedJacobian ( Step  step)
inline

get a composed Jacobian from the cache

Parameters
stepStep for which to extract the jacobian.
Returns
A shared pointer to the Jacobian matrix.
Exceptions
NotInCacheif the requested composed Jacobian is not in the cache.
Note
This function will attempt to copy the composed Jacobian from composed Jacobians of other times steps. As a consequence, this method only works on the mutable cache.
template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
shared_ptr<const Matrix> Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::getJacobian ( std::size_t  order,
Step  step 
)
inline

get a Jacobian from the cache

Parameters
orderExtract the Jacobian matrix of the operator for the order'th temporal derivative.
stepStep for which to extract the jacobian.
Returns
A shared pointer to the Jacobian matrix.
Exceptions
NotInCacheif the requested Jacobian is not in the cache.
Note
This function will attempt to copy the Jacobian from other Jacobians of the same order. As a consequence, this method only works on the mutable cache.
template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
shared_ptr<Policy> Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::getPolicy ( )
inline
template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
shared_ptr<const Policy> Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::getPolicy ( ) const
inline
template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
shared_ptr<const VectorV> Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::getResidualValue ( std::size_t  order,
Step  step 
) const
inline

get residual value from the cache

Parameters
orderExtract the residual value of the operator for the order'th temporal derivative.
stepStep for which to extract the residual value.
Returns
A shared pointer to the residual value vector.
Exceptions
NotInCacheif the requested residual value is not in the cache.
template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
shared_ptr<const VectorU> Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::getUnknowns ( Step  step) const
inline

get vector of unknowns from the cache

Parameters
stepStep for which to extract the vector of unknowns.
Returns
A shared pointer to the vector of unknowns.
Exceptions
NotInCacheif the cache does not contain a vector of unknowns for the given step.
template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
shared_ptr<const VectorV> Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::getZeroResidual ( std::size_t  order,
Step  step 
) const
inline

get zero-residual from the cache

Parameters
orderExtract the zero-residual of the operator for the order'th temporal derivative.
stepStep for which to extract the zero-residual.
Returns
A shared pointer to the zero-residual vector.
Exceptions
NotInCacheif the requested zero-residual is not in the cache.
Note
This function will attempt to copy the zero-residual from other zero-residuals of the same order. As a consequence, this method only works on the mutable cache.
template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
void Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::postStep ( )
inline

Do some housekeeping after computing a time-step.

This just calls postStep() on the policy object.

template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
void Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::preStep ( Step  step,
Step  stepsOfScheme,
Time  endTime,
Time  dt 
)
inline

Do some housekeeping before computing a time-step.

The method first calls preStep on the policy object, passing it the parameters:

Parameters
stepNumber of the step that will be computed, i.e. when $u_n$ is computed, then $n=$step.
stepsOfSchemeNumber of steps in the scheme: the oldest required value is $u_{\text{\tt step}-\text{\tt stepsOfScheme}}$.
endTime$t_n$, the time at step step.
dtTime step size, i.e. $t_n-t_{n-1}$.

It the iterates over each cache item and remove it, if the policy allows that.

template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
void Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::setComposedJacobian ( Step  step,
const shared_ptr< const Matrix > &  jacobian 
)
inline

store a composed Jacobian in the cache

Parameters
stepStep for which to store the composed Jacobian.
jacobianPointer to the composed Jacobian to store.
Exceptions
AlreadyInCacheif the cache already contains a composed Jacobian for the given step.
template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
void Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::setJacobian ( std::size_t  order,
Step  step,
const shared_ptr< const Matrix > &  jacobian 
)
inline

store a Jacobian in the cache

Parameters
orderStore the Jacobian of the operator for the order'th temporal derivative.
stepStep for which to store the jacobian.
jacobianPointer to the Jacobian to store.
Exceptions
AlreadyInCacheif the cache already contains a Jacobian for the given order and step.
template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
void Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::setPolicy ( const shared_ptr< Policy > &  policy_)
inline
template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
void Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::setResidualValue ( std::size_t  order,
Step  step,
const shared_ptr< const VectorV > &  residualValue 
)
inline

store a residual value in the cache

Parameters
orderStore the residual value of the operator for the order'th temporal derivative.
stepStep for which to store the residual value.
residualValuePointer to the residual value to store.
Exceptions
AlreadyInCacheif the cache already contains a residual value for the given order and step.
template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
void Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::setUnknowns ( Step  step,
const shared_ptr< const VectorU > &  unknowns_ 
)
inline

store a vector of unknowns in the cache

Parameters
stepStep for which to store the vector of unknowns.
unknowns_Pointer to the unknowns to store.
Exceptions
AlreadyInCacheif the cache already contains a vector of unknowns for the given order and step.
template<class VectorU , class VectorV , class Matrix , class Step = int, class Time = double>
void Dune::PDELab::MultiStepCache< VectorU, VectorV, Matrix, Step, Time >::setZeroResidual ( std::size_t  order,
Step  step,
const shared_ptr< const VectorV > &  zeroResidual 
)
inline

store a zero-residual in the cache

Parameters
orderStore the zero-residual of the operator for the order'th temporal derivative.
stepStep for which to store the zero-residual.
zeroResidualPointer to the zero-residual to store.
Exceptions
AlreadyInCacheif the cache already contains a zero-residual for the given order and step.

The documentation for this struct was generated from the following file: