SpECTRE  v2025.03.17
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
StepChoosers::ErrorControl< StepChooserUse, EvolvedVariableTag, ErrorControlSelector > Class Template Reference

Sets a goal based on time-stepper truncation error. More...

#include <ErrorControl.hpp>

Classes

struct  AbsoluteTolerance
 
struct  MaxFactor
 
struct  MinFactor
 
struct  RelativeTolerance
 
struct  SafetyFactor
 

Public Types

using options = implementation defined
 
using simple_tags = implementation defined
 
using compute_tags = implementation defined
 
using argument_tags = implementation defined
 

Public Member Functions

 ErrorControl (const double absolute_tolerance, const double relative_tolerance, const double max_factor, const double min_factor, const double safety_factor)
 
TimeStepRequest operator() (const typename ::Tags::StepperErrors< EvolvedVariableTag >::type &errors, const double) const
 
bool uses_local_data () const override
 Whether the result can differ on different elements, so requiring communication to synchronize the result across the domain. This is ignored for LTS step changing. More...
 
bool can_be_delayed () const override
 Whether the result can be applied with a delay. More...
 
StepperErrorTolerances tolerances () const override
 
void pup (PUP::er &p) override
 
- Public Member Functions inherited from StepChooser< StepChooserUse >
 WRAPPED_PUPable_abstract (StepChooser)
 
virtual bool uses_local_data () const =0
 Whether the result can differ on different elements, so requiring communication to synchronize the result across the domain. This is ignored for LTS step changing. More...
 
virtual bool can_be_delayed () const =0
 Whether the result can be applied with a delay. More...
 
template<typename StepChoosersToUse = AllStepChoosers, typename DbTags >
TimeStepRequest desired_step (const double last_step, const db::DataBox< DbTags > &box) const
 The last_step parameter describes the step size to be adjusted. It may be the step size or the slab size, or may be infinite if the appropriate size cannot be determined. More...
 

Static Public Member Functions

static std::string name ()
 

Static Public Attributes

static constexpr Options::String help
 

Detailed Description

template<typename StepChooserUse, typename EvolvedVariableTag, typename ErrorControlSelector = NoSuchType>
class StepChoosers::ErrorControl< StepChooserUse, EvolvedVariableTag, ErrorControlSelector >

Sets a goal based on time-stepper truncation error.

Details

The suggested step is calculated via a simple specialization of the scheme suggested in . We first compute the aggregated error measure from the stepper error:

E=maxi(|Ei|/sci),

where Ei is the ODE error reported for each individual grid point, reported by the time stepper, and sci is the step control measure determined by the tolerances:

sci=Atoli+max(|yi|,|yi+Ei|)Rtoli,

and yi is the value of the function at the previous step at grid point i. (The estimate is more commonly done comparing with the current step, but using the previous step avoids a memory allocation in the TimeStepper and should not have a major effect on the result.)

When choosing a step size for LTS or when no record of previous error is available, the step has size:

hnew=hmin(Fmax,max(Fmin,FsafetyE1/(q+1))),

where hnew is the new suggested step size h is the previous step size, Fmax is the maximum factor by which we allow the step to increase, Fmin is the minimum factor by which we allow the step to decrease. Fsafety is the safety factor on the computed error – this forces the step size slightly lower than we would naively compute so that the result of the step will likely be within the target error. q is the order of the stepper error calculation. Intuitively, we should change the step less drastically for a higher order stepper.

When controlling slab size, after the first error calculation, the error E is recorded in the DataBox, and subsequent error calculations use a simple PI scheme suggested in section 17.2.1:

hnew=hmin(Fmax,max(Fmin,FsafetyE0.7/(q+1)Eprev0.4/(q+1))),

where Eprev is the error computed in the previous step. This method is never used for choosing an LTS step because the restriction of step size changes to factors of two was found to interfere with the more gradual increase chosen by the PI controller.

Note
The template parameter ErrorControlSelector is used to disambiguate in the input-file options between ErrorControl step choosers that are based on different variables. This is needed if multiple systems are evolved in the same executable. The name used for the input file includes ErrorControlSelector::name() if it is provided.

Member Function Documentation

◆ can_be_delayed()

template<typename StepChooserUse , typename EvolvedVariableTag , typename ErrorControlSelector = NoSuchType>
bool StepChoosers::ErrorControl< StepChooserUse, EvolvedVariableTag, ErrorControlSelector >::can_be_delayed ( ) const
inlineoverridevirtual

Whether the result can be applied with a delay.

StepChoosers setting the .end or .end_hard_limit fields of TimeStepRequest must return false here.

Implements StepChooser< StepChooserUse >.

◆ uses_local_data()

template<typename StepChooserUse , typename EvolvedVariableTag , typename ErrorControlSelector = NoSuchType>
bool StepChoosers::ErrorControl< StepChooserUse, EvolvedVariableTag, ErrorControlSelector >::uses_local_data ( ) const
inlineoverridevirtual

Whether the result can differ on different elements, so requiring communication to synchronize the result across the domain. This is ignored for LTS step changing.

Note
As this is only used for slab-size changing, the last_step passed to the call operator is not considered local data.

Implements StepChooser< StepChooserUse >.

Member Data Documentation

◆ help

template<typename StepChooserUse , typename EvolvedVariableTag , typename ErrorControlSelector = NoSuchType>
constexpr Options::String StepChoosers::ErrorControl< StepChooserUse, EvolvedVariableTag, ErrorControlSelector >::help
staticconstexpr
Initial value:
{
"Sets a goal based on time-stepper truncation error."}

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