Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
SimulationControlTransient Class Reference

#include <simulation_control.h>

Inheritance diagram for SimulationControlTransient:
[legend]

Public Member Functions

 SimulationControlTransient (const Parameters::SimulationControl &param)
virtual void print_progression (const ConditionalOStream &pcout) override
bool is_adaptive_time_stepping () const override
virtual bool integrate () override
virtual bool is_at_end () override
virtual bool is_output_iteration () override
void read (const std::string &prefix) override
Public Member Functions inherited from SimulationControl
 SimulationControl (const Parameters::SimulationControl &param)
virtual ~SimulationControl ()=default
void add_time_step (double p_timestep)
bool is_at_start () const
bool is_steady () const
bool is_bdf () const
bool is_sdirk () const
bool is_refinement_step (const Parameters::MeshAdaptation &mesh_adaptation)
bool output_enabled () const
bool get_output_boundaries () const
virtual bool is_verbose_iteration ()
virtual bool is_first_assembly ()
void update_assembly_method ()
void set_CFL (const double p_CFL)
void set_capillary_time_step_constraint (const double p_capillary_time_step_constraint)
void set_current_time_step (const double new_time_step)
void limit_initial_time_step_with_capillary_time_step_constraint ()
void set_current_capillary_time_step_ratio ()
void provide_residual (const double new_residual)
double get_time_step () const
unsigned int get_iteration_number () const
std::string get_output_name () const
std::string get_output_path () const
unsigned int get_group_files () const
unsigned int get_log_precision () const
double get_current_time () const
double get_previous_time () const
void set_stage_time (const double c_i)
void end_stages ()
std::vector< double > get_time_steps_vector () const
double get_CFL () const
double get_current_capillary_time_step_ratio () const
unsigned int get_number_subdivision () const
unsigned int get_log_frequency () const
Parameters::SimulationControl::TimeSteppingMethod get_assembly_method () const
void set_assembly_method (const Parameters::SimulationControl::TimeSteppingMethod a_method)
unsigned int get_number_of_previous_solution_in_assembly () const
std::vector< double > get_simulation_times () const
Vector< double > const & get_bdf_coefficients ()
virtual void save (const std::string &prefix)
std::vector< double > get_checkpointed_simulation_control_info (const std::string &prefix)

Protected Member Functions

virtual double calculate_time_step () override
Protected Member Functions inherited from SimulationControl
void update_bdf_coefficients ()

Protected Attributes

bool time_step_adaptation_required
bool adapt_with_cfl
double adaptative_time_step_scaling
double max_dt
double output_time_frequency
std::vector< double > output_times_vector
bool override_time_step_on_restart
std::vector< double > output_time_interval
Parameters::SimulationControl::EndControl end_control
Parameters::SimulationControl::OutputControl output_control
Protected Attributes inherited from SimulationControl
Parameters::SimulationControl::TimeSteppingMethod method
Parameters::SimulationControl::TimeSteppingMethod assembly_method
double current_time
double previous_time
double time_step
double initial_time_step
double end_time
bool time_step_independent_of_end_time
std::vector< double > time_step_vector
unsigned int iteration_number
unsigned int end_iteration
unsigned int number_mesh_adapt
double CFL
double max_CFL
double capillary_time_step_constraint
double max_capillary_time_step_ratio
double current_capillary_time_step_ratio
bool adapt_with_capillary_time_step_ratio
double residual
double stop_tolerance
unsigned int output_iteration_frequency
unsigned int log_frequency
unsigned int log_precision
unsigned int subdivision
unsigned int group_files
std::string output_name
std::string output_path
bool output_boundaries
bool first_assembly
Parameters::SimulationControl::BDFStartupMethods bdf_start_method
double startup_timestep_scaling
Vector< double > bdf_coefs

Static Protected Attributes

static constexpr double output_time_tolerance = 1e-6
Static Protected Attributes inherited from SimulationControl
static constexpr unsigned int n_previous_time_steps = 4

Additional Inherited Members

Static Public Member Functions inherited from SimulationControl
static unsigned int get_number_of_stages (const Parameters::SimulationControl::TimeSteppingMethod &method)

Detailed Description

Simulation control for transient simulations.

This class extends SimulationControl to handle transient (time-dependent) simulations. It implements adaptive time stepping based on CFL conditions, time-based output control, and ensures the simulation progresses until the end criterion is reached.

Key features:

  • Adaptive time stepping with CFL-based control
  • Time-based or iteration-based output control
  • Specific output times capability
  • Maximum time step limiting

Definition at line 930 of file simulation_control.h.

Constructor & Destructor Documentation

◆ SimulationControlTransient()

SimulationControlTransient::SimulationControlTransient ( const Parameters::SimulationControl & param)

Construct a transient simulation control object.

Parameters
[in]paramStructure of the parameters for the simulation control

Definition at line 291 of file simulation_control.cc.

References adapt_with_cfl, adaptative_time_step_scaling, end_control, max_dt, output_control, output_time_frequency, output_time_interval, output_times_vector, override_time_step_on_restart, SimulationControl::SimulationControl(), Parameters::SimulationControl::time, and time_step_adaptation_required.

Member Function Documentation

◆ calculate_time_step()

double SimulationControlTransient::calculate_time_step ( )
overrideprotectedvirtual

Calculate the next value of the time step.

If SimulationControlTransient::adapt_with_cfl is enabled, the time step is calculated to ensure that the CFL condition is bounded by the maximal CFL value. If SimulationControl::adapt_with_capillary_time_step_ratio is enabled, the time step is calculated to ensure that it is bounded by the maximal CTR value. The new time step is scaled by SimulationControlTransient::adaptative_time_step_scaling. If the SimulationControl::time_step_independent_of_end_time is set to false, the time step is adjusted to meet exactly the end time; the default is to not modify the time step.

Returns
The calculated time-step value

Reimplemented from SimulationControl.

Definition at line 404 of file simulation_control.cc.

References SimulationControl::adapt_with_capillary_time_step_ratio, adapt_with_cfl, adaptative_time_step_scaling, SimulationControl::capillary_time_step_constraint, SimulationControl::CFL, SimulationControl::current_time, end_control, SimulationControl::end_time, Parameters::SimulationControl::iteration, SimulationControl::iteration_number, SimulationControl::max_capillary_time_step_ratio, SimulationControl::max_CFL, max_dt, SimulationControl::time_step, time_step_adaptation_required, and SimulationControl::time_step_independent_of_end_time.

◆ integrate()

bool SimulationControlTransient::integrate ( )
overridevirtual

◆ is_adaptive_time_stepping()

bool SimulationControlTransient::is_adaptive_time_stepping ( ) const
inlineoverridevirtual

Indicate if the simulation uses adaptive time stepping or not.

Returns
true if the simulation has adaptive time stepping, false otherwise

Implements SimulationControl.

Definition at line 1042 of file simulation_control.h.

References time_step_adaptation_required.

◆ is_at_end()

bool SimulationControlTransient::is_at_end ( )
overridevirtual

End the simulation when the end condition is reached.

Returns
true if the current time or transient iteration has reached or exceeded the end time or transient iteration, false otherwise

Implements SimulationControl.

Reimplemented in SimulationControlAdjointSteady.

Definition at line 394 of file simulation_control.cc.

References SimulationControl::current_time, end_control, SimulationControl::end_iteration, SimulationControl::end_time, Parameters::SimulationControl::iteration, SimulationControl::iteration_number, and SimulationControl::time_step.

◆ is_output_iteration()

bool SimulationControlTransient::is_output_iteration ( )
overridevirtual

Check if the current iteration is an output iteration.

Output iterations are determined based on the value of the output time, the output interval, and the output frequency within the interval.

When an output time frequency is used, the output times are \(t_k = t_{\text{start}} + k \Delta t_{\text{output}}\), where \(t_{\text{start}}\) is the lower bound of the output time interval. An iteration is an output iteration if the time step that leads to it reaches or crosses one of these output times. The initial iteration and the last iteration are also output iterations. In all cases, the current time must lie within the output time interval. Both the output times and the bounds of the interval are considered as reached up to SimulationControlTransient::output_time_tolerance times the output time frequency.

When specific output times are used, they may be given in any order. An iteration is an output iteration if the time step that leads to it, or the next time step, reaches or crosses one of these output times. Since the output times do not necessarily correspond to the time of an iteration, the iterations before and after each output time are thus written. At the initial iteration, only the output times equal to the current time are considered. Several output times may lie within the same time step.

These criteria only depend on the current, previous and next times, so calling this function several times within the same iteration always returns the same result.

Returns
true if output should be written at this iteration, false otherwise

Reimplemented from SimulationControl.

Definition at line 441 of file simulation_control.cc.

References calculate_time_step(), SimulationControl::current_time, SimulationControl::get_current_time(), SimulationControl::get_iteration_number(), is_at_end(), Parameters::SimulationControl::iteration, SimulationControl::iteration_number, output_control, SimulationControl::output_iteration_frequency, output_time_frequency, output_time_interval, output_time_tolerance, output_times_vector, SimulationControl::previous_time, and SimulationControl::time_step.

◆ print_progression()

void SimulationControlTransient::print_progression ( const ConditionalOStream & pcout)
overridevirtual

◆ read()

void SimulationControlTransient::read ( const std::string & prefix)
overridevirtual

Read the simulation control information from a checkpoint file.

Reads and updates the time step vector, the CFL value, the time and the iteration number. Allows changing the time step if adaptive time stepping is disabled.

Parameters
[in]prefixThe prefix of the checkpoint file for the simulation

Reimplemented from SimulationControl.

Definition at line 557 of file simulation_control.cc.

References SimulationControl::CFL, SimulationControl::initial_time_step, override_time_step_on_restart, SimulationControl::read(), SimulationControl::set_CFL(), SimulationControl::set_current_time_step(), and SimulationControl::time_step.

Member Data Documentation

◆ adapt_with_cfl

bool SimulationControlTransient::adapt_with_cfl
protected

Boolean indicating if the CFL condition should be controlling the simulation time step.

Definition at line 944 of file simulation_control.h.

◆ adaptative_time_step_scaling

double SimulationControlTransient::adaptative_time_step_scaling
protected

Time step scaling factor for adaptive time stepping.

Used to scale the time step based on the ratio of max_CFL to current CFL when adaptive time stepping is enabled.

Definition at line 952 of file simulation_control.h.

◆ end_control

Parameters::SimulationControl::EndControl SimulationControlTransient::end_control
protected

End control type: iteration-based or time-based.

Definition at line 996 of file simulation_control.h.

◆ max_dt

double SimulationControlTransient::max_dt
protected

Maximum allowed time step.

Definition at line 955 of file simulation_control.h.

◆ output_control

Parameters::SimulationControl::OutputControl SimulationControlTransient::output_control
protected

Output control type: iteration-based or time-based.

Definition at line 999 of file simulation_control.h.

◆ output_time_frequency

double SimulationControlTransient::output_time_frequency
protected

Output frequency for time-based output control.

Definition at line 973 of file simulation_control.h.

◆ output_time_interval

std::vector<double> SimulationControlTransient::output_time_interval
protected

Time interval for output of transient iterations.

Used with either time output control or iteration control to define intervals for output generation.

Definition at line 993 of file simulation_control.h.

◆ output_time_tolerance

double SimulationControlTransient::output_time_tolerance = 1e-6
staticconstexprprotected

Relative tolerance used to decide whether an output time has been reached.

An output time that lies within this tolerance after the current time is considered as reached. This prevents round-off errors accumulated in the current time from delaying or skipping an output. With an output time frequency, the tolerance is relative to the output time frequency, so that it does not change from one iteration to the next and every output time is attributed to exactly one iteration. It also applies to the bounds of the output time interval. With specific output times, the tolerance is relative to the time step.

Definition at line 970 of file simulation_control.h.

◆ output_times_vector

std::vector<double> SimulationControlTransient::output_times_vector
protected

Specific output times for time output control.

Vector containing specific times at which output should be generated.

Definition at line 980 of file simulation_control.h.

◆ override_time_step_on_restart

bool SimulationControlTransient::override_time_step_on_restart
protected

Flag to override the time step with the set value upon restart.

Definition at line 985 of file simulation_control.h.

◆ time_step_adaptation_required

bool SimulationControlTransient::time_step_adaptation_required
protected

Boolean indicating if adaptive time-stepping is enabled. To enable it, enable either SimulationControlTransient::adapt_with_cfl or SimulationControl::adapt_with_capillary_time_step_ratio.

Definition at line 938 of file simulation_control.h.


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