![]() |
Lethe Open-Source Library version 1.2.0
Developer Guide
|
#include <simulation_control.h>
Public Member Functions | |
| SimulationControlTransient (const Parameters::SimulationControl ¶m) | |
| 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 ¶m) | |
| 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 () |
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) |
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:
Definition at line 930 of file simulation_control.h.
| SimulationControlTransient::SimulationControlTransient | ( | const Parameters::SimulationControl & | param | ) |
Construct a transient simulation control object.
| [in] | param | Structure 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.
|
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.
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.
|
overridevirtual |
Proceed with the simulation until the end condition is reached.
Advances the simulation by incrementing time and iteration number.
Implements SimulationControl.
Definition at line 353 of file simulation_control.cc.
References SimulationControl::adapt_with_capillary_time_step_ratio, SimulationControl::add_time_step(), calculate_time_step(), SimulationControl::current_time, SimulationControl::first_assembly, is_at_end(), SimulationControl::is_bdf(), SimulationControl::iteration_number, SimulationControl::previous_time, SimulationControl::set_current_capillary_time_step_ratio(), SimulationControl::time_step, SimulationControl::update_assembly_method(), and SimulationControl::update_bdf_coefficients().
|
inlineoverridevirtual |
Indicate if the simulation uses adaptive time stepping or not.
Implements SimulationControl.
Definition at line 1042 of file simulation_control.h.
References time_step_adaptation_required.
|
overridevirtual |
End the simulation when the end condition is reached.
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.
|
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.
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.
|
overridevirtual |
Print the current progress status of the simulation.
| [in] | pcout | Parallel conditional output stream used to print the information |
Implements SimulationControl.
Reimplemented in SimulationControlAdjointSteady, and SimulationControlTransientDEM.
Definition at line 313 of file simulation_control.cc.
References SimulationControl::adapt_with_capillary_time_step_ratio, announce_string(), SimulationControl::current_time, SimulationControl::get_CFL(), SimulationControl::get_current_capillary_time_step_ratio(), SimulationControl::is_verbose_iteration(), SimulationControl::iteration_number, SimulationControl::log_precision, and SimulationControl::time_step.
|
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.
| [in] | prefix | The 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.
|
protected |
Boolean indicating if the CFL condition should be controlling the simulation time step.
Definition at line 944 of file simulation_control.h.
|
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.
|
protected |
End control type: iteration-based or time-based.
Definition at line 996 of file simulation_control.h.
|
protected |
Maximum allowed time step.
Definition at line 955 of file simulation_control.h.
|
protected |
Output control type: iteration-based or time-based.
Definition at line 999 of file simulation_control.h.
|
protected |
Output frequency for time-based output control.
Definition at line 973 of file simulation_control.h.
|
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.
|
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.
|
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.
|
protected |
Flag to override the time step with the set value upon restart.
Definition at line 985 of file simulation_control.h.
|
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.