AbstractTimestepper< VectorType_, SparseMatrixType_, dim_ > Class Template Reference#

DiFfRG: AbstractTimestepper< VectorType_, SparseMatrixType_, dim_ > Class Template Reference
DiFfRG
Discretization Framework for functional Renormalization Group flows
AbstractTimestepper< VectorType_, SparseMatrixType_, dim_ > Class Template Referenceabstract

Base class of all timesteppers. More...

#include <abstract_timestepper.hh>

Classes

struct  ExplicitParameters
 
struct  ImplicitParameters
 

Public Member Functions

 AbstractTimestepper (const ConfigTree &config, AbstractAssembler< VectorType, SparseMatrixType, dim > &assembler, OutputSession_impl< dim, VectorType > &data_out, const bool implicit_stepper, const bool explicit_stepper)
 Construct without mesh adaptation.
 
 AbstractTimestepper (const ConfigTree &config, AbstractAssembler< VectorType, SparseMatrixType, dim > &assembler, OutputSession_impl< dim, VectorType > &data_out, AbstractAdaptor< VectorType > &adaptor, const bool implicit_stepper, const bool explicit_stepper)
 Construct with a mesh adaptor, which is called between steps (where the stepper supports it, see abstract_timestepper.hh).
 
void run (AbstractFlowingVariables< NumberType, VectorType > &initial_condition, double t_start, const double t_stop)
 Evolve initial_condition from t_start to t_stop.
 
bool is_implicit () const
 Whether this stepper reads /timestepping/implicit.
 
bool is_explicit () const
 Whether this stepper reads /timestepping/explicit.
 

Protected Types

using VectorType = VectorType_
 
using NumberType = typename get_type::NumberType<VectorType>
 
using SparseMatrixType = SparseMatrixType_
 
using BlockVectorType = typename get_type::BlockVectorType<VectorType>
 

Protected Member Functions

void drain_output ()
 
template<typename EmitFinalFrame >
void finalize_output_after_failure (EmitFinalFrame &&emit_final_frame)
 Best-effort output cleanup while a timestepping failure is being reported.
 
void require_no_adaptor (const std::string &stepper) const
 Throw unless the mesh adaptor is NoAdaptivity; for steppers that cannot adapt the mesh.
 
void require_no_variables (const AbstractFlowingVariables< NumberType, VectorType > &state, const std::string &stepper) const
 Throw if the flow has variables; for steppers that integrate only the FE/FV unknowns.
 
virtual void run_segment (AbstractFlowingVariables< NumberType, VectorType > &initial_condition, const double t_start, const double t_stop)=0
 Any derived class must implement this method to run the timestepping algorithm.
 

Protected Attributes

const ConfigTree config
 
NoAdaptivity< VectorType > adaptor_default
 
AbstractAssembler< VectorType, SparseMatrixType, dim > & assembler
 
OutputSession_impl< dim, VectorType > & data_out
 
AbstractAdaptor< VectorType > & adaptor
 
ReportPort log
 
const bool m_is_implicit
 
const bool m_is_explicit
 
double output_dt
 
struct DiFfRG::AbstractTimestepper::ImplicitParameters impl
 
struct DiFfRG::AbstractTimestepper::ExplicitParameters expl
 
std::size_t next_jacobian_build_id = 0
 
TimestepperJacobianDiagnosticsState jacobian_diagnostics_state
 

Static Protected Attributes

static constexpr uint dim = dim_
 

Detailed Description

template<typename VectorType_, typename SparseMatrixType_, uint dim_>
class DiFfRG::AbstractTimestepper< VectorType_, SparseMatrixType_, dim_ >

Base class of all timesteppers.

Reads the /timestepping parameters (see abstract_timestepper.hh for the list), and implements run(), which handles snapshots and restarts around the stepper's run_segment().

Template Parameters
VectorType_vector type of the assembler: dealii::Vector<double>, or a PETSc MPI vector in an MPI build.
SparseMatrixType_sparse matrix type of the assembler.
dim_spatial dimension; 0 for a pure-variables system.

Member Typedef Documentation

◆ BlockVectorType

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
using BlockVectorType = typename get_type::BlockVectorType<VectorType>
protected

◆ NumberType

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
using NumberType = typename get_type::NumberType<VectorType>
protected

◆ SparseMatrixType

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
using SparseMatrixType = SparseMatrixType_
protected

◆ VectorType

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
using VectorType = VectorType_
protected

Constructor & Destructor Documentation

◆ AbstractTimestepper() [1/2]

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
AbstractTimestepper ( const ConfigTree & config,
AbstractAssembler< VectorType, SparseMatrixType, dim > & assembler,
OutputSession_impl< dim, VectorType > & data_out,
const bool implicit_stepper,
const bool explicit_stepper )
inline

Construct without mesh adaptation.

Parameters
configparameters; see abstract_timestepper.hh.
assemblerassembles residuals and Jacobians.
data_outwhere the output frames go.
implicit_stepperwhether to read /timestepping/implicit.
explicit_stepperwhether to read /timestepping/explicit.

◆ AbstractTimestepper() [2/2]

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
AbstractTimestepper ( const ConfigTree & config,
AbstractAssembler< VectorType, SparseMatrixType, dim > & assembler,
OutputSession_impl< dim, VectorType > & data_out,
AbstractAdaptor< VectorType > & adaptor,
const bool implicit_stepper,
const bool explicit_stepper )
inline

Construct with a mesh adaptor, which is called between steps (where the stepper supports it, see abstract_timestepper.hh).

Member Function Documentation

◆ drain_output()

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
void drain_output ( )
inlineprotected

◆ finalize_output_after_failure()

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
template<typename EmitFinalFrame >
void finalize_output_after_failure ( EmitFinalFrame && emit_final_frame)
inlineprotected

Best-effort output cleanup while a timestepping failure is being reported.

Writes one final frame for the state that failed, then pushes everything pending to disk. Both steps are swallowed on error: a readout that cannot cope with a diverged solution must not replace the failure the caller is actually trying to report, and a drain error is latched anyway and resurfaces at finish().

Callers rethrow the original exception afterwards.

◆ is_explicit()

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
bool is_explicit ( ) const
inline

Whether this stepper reads /timestepping/explicit.

◆ is_implicit()

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
bool is_implicit ( ) const
inline

Whether this stepper reads /timestepping/implicit.

◆ require_no_adaptor()

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
void require_no_adaptor ( const std::string & stepper) const
inlineprotected

Throw unless the mesh adaptor is NoAdaptivity; for steppers that cannot adapt the mesh.

◆ require_no_variables()

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
void require_no_variables ( const AbstractFlowingVariables< NumberType, VectorType > & state,
const std::string & stepper ) const
inlineprotected

Throw if the flow has variables; for steppers that integrate only the FE/FV unknowns.

◆ run()

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
void run ( AbstractFlowingVariables< NumberType, VectorType > & initial_condition,
double t_start,
const double t_stop )
inline

Evolve initial_condition from t_start to t_stop.

The time stepping itself is done by the derived class in run_segment(). Around it, run() provides two optional features, both driven by the configuration:

  • Snapshots. At every time of /timestepping/snapshots (see SnapshotSchedule) the flow is split into segments, and the state at each boundary is written to <run name>_snapshot_<nnn>.h5 next to the run's other output. The stepper is restarted at each snapshot, which costs one solver restart per snapshot.
  • Restart. If /restart/file names a snapshot, the first call to run() restores the mesh, the state, the model's history-dependent state and the adaptation schedule from it, logs every configuration entry that differs from the snapshot's, and starts at the snapshot's time; t_start is then ignored. initial_condition must still have been set up as usual (interpolate()), so that its block structure exists.

Snapshots are never overwritten: run() throws before stepping if one it would write exists. A restart from one of this run's own snapshots continues the run, numbering its snapshots on from there; finding a later one already on disk then means the run has continued before.

Without either, this is exactly one call to run_segment().

Parameters
initial_conditionThe state; on return it holds the state at the end of the run.
t_startThe start time of the simulation.
t_stopThe run method will evolve the system from t_start to t_stop.

◆ run_segment()

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
virtual void run_segment ( AbstractFlowingVariables< NumberType, VectorType > & initial_condition,
const double t_start,
const double t_stop )
protectedpure virtual

Any derived class must implement this method to run the timestepping algorithm.

It must return the state at t_stop in initial_condition, because run() writes snapshots from it. Called once per segment, i.e. possibly several times per run() with consecutive intervals.

Parameters
initial_conditionThe flowing variables object that contains the initial condition.
t_startThe start time of the segment.
t_stopThe end time of the segment.

Implemented in TimeStepperBoostRK_impl< VectorType, SparseMatrixType, dim, prec >, TimeStepperImplicitEuler_impl< VectorType, SparseMatrixType, dim, LinearSolver >, TimeStepperSUNDIALS_IDA_BoostABM_impl< VectorType, SparseMatrixType, dim, LinearSolver >, TimeStepperSUNDIALS_IDA_BoostRK_impl< VectorType, SparseMatrixType, dim, LinearSolver, prec >, TimeStepperSUNDIALS_IDA_impl< VectorType, SparseMatrixType, dim, LinearSolver >, and TimeStepperTRBDF2_impl< VectorType, SparseMatrixType, dim, LinearSolver >.

Member Data Documentation

◆ adaptor

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
AbstractAdaptor<VectorType>& adaptor
protected

◆ adaptor_default

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
NoAdaptivity<VectorType> adaptor_default
protected

◆ assembler

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
AbstractAssembler<VectorType, SparseMatrixType, dim>& assembler
protected

◆ config

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
const ConfigTree config
protected

◆ data_out

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
OutputSession_impl<dim, VectorType>& data_out
protected

◆ dim

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
uint dim = dim_
staticconstexprprotected

◆ expl

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
struct DiFfRG::AbstractTimestepper::ExplicitParameters expl
protected

◆ impl

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
struct DiFfRG::AbstractTimestepper::ImplicitParameters impl
protected

◆ jacobian_diagnostics_state

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
TimestepperJacobianDiagnosticsState jacobian_diagnostics_state
protected

◆ log

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
ReportPort log
protected

◆ m_is_explicit

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
const bool m_is_explicit
protected

◆ m_is_implicit

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
const bool m_is_implicit
protected

◆ next_jacobian_build_id

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
std::size_t next_jacobian_build_id = 0
protected

◆ output_dt

template<typename VectorType_ , typename SparseMatrixType_ , uint dim_>
double output_dt
protected

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