14#ifndef lethe_simulation_control_h
15#define lethe_simulation_control_h
20#include <deal.II/particles/particle_handler.h>
551 const double p_capillary_time_step_constraint)
572 "You are trying to set a null or negative time step in a SimulationControl. This is not allowed, we cannot go backward in time."));
584 double capillary_time_step =
599 "The current value of the capillary time-step constraint is set to a null or negative value.\n"
600 "This is not allowed. Make sure that the 'capillary_time_step_constraint' is computed and\n"
601 "that the parameter 'adapt time step to respect CTR' is set to 'true'."));
845 for (
unsigned int j = 0; j < i; ++j)
860 Vector<double>
const &
886 save(
const std::string &prefix);
897 read(
const std::string &prefix);
1110 read(
const std::string &prefix)
override;
1263 Particles::ParticleHandler<3> &input_photon_handler);
Vector< double > calculate_bdf_coefficients(Parameters::SimulationControl::TimeSteppingMethod method, const std::vector< double > &time_steps)
Calculate the coefficients required for backward differentiation formula (BDF) integration of order .
unsigned int number_of_previous_solutions(const Parameters::SimulationControl::TimeSteppingMethod method)
Get the number of previous time steps for a specific BDF scheme.
SimulationControlAdjointSteady(const Parameters::SimulationControl ¶m)
Construct an adjoint steady-state simulation control object.
virtual bool is_at_end() override
End the simulation when the desired residual tolerance is reached.
virtual void print_progression(const ConditionalOStream &pcout) override
Print the current progress status of the adjoint simulation.
void print_progression(const ConditionalOStream &pcout) override
Print the current progress status of the ray tracing simulation.
Particles::ParticleHandler< 3 > & photon_handler
Reference to the photon handler used during the ray-tracing simulation.
bool is_at_end() override
End the simulation when there are no longer any photons in the triangulation.
bool is_adaptive_time_stepping() const override
Indicate if the simulation uses adaptive time stepping.
virtual bool integrate() override
Proceed with the simulation until the end condition is reached.
SimulationControlRayTracing(const Parameters::SimulationControl ¶m, Particles::ParticleHandler< 3 > &input_photon_handler)
Construct a ray tracing simulation control object.
virtual bool integrate() override
Proceed with the simulation until the end condition is reached.
SimulationControlSteady(const Parameters::SimulationControl ¶m)
Construct a steady-state simulation control object.
bool is_adaptive_time_stepping() const override
Indicate if the simulation uses adaptive time stepping.
virtual bool is_at_end() override
End the simulation when the number of mesh adaptations is reached.
virtual void print_progression(const ConditionalOStream &pcout) override
Print the current progress status of the steady-state simulation.
SimulationControlTransientDEM(const Parameters::SimulationControl ¶m)
Construct a DEM transient simulation control object.
virtual void print_progression(const ConditionalOStream &pcout) override
Print the current progress status of the DEM simulation.
bool is_adaptive_time_stepping() const override
Indicate if the simulation uses adaptive time stepping or not.
bool override_time_step_on_restart
Flag to override the time step with the set value upon restart.
SimulationControlTransient(const Parameters::SimulationControl ¶m)
Construct a transient simulation control object.
void read(const std::string &prefix) override
Read the simulation control information from a checkpoint file.
std::vector< double > output_time_interval
Time interval for output of transient iterations.
virtual void print_progression(const ConditionalOStream &pcout) override
Print the current progress status of the simulation.
virtual double calculate_time_step() override
Calculate the next value of the time step.
bool time_step_adaptation_required
std::vector< double > output_times_vector
Specific output times for time output control.
static constexpr double output_time_tolerance
Relative tolerance used to decide whether an output time has been reached.
virtual bool integrate() override
Proceed with the simulation until the end condition is reached.
virtual bool is_at_end() override
End the simulation when the end condition is reached.
virtual bool is_output_iteration() override
Check if the current iteration is an output iteration.
double max_dt
Maximum allowed time step.
Parameters::SimulationControl::EndControl end_control
End control type: iteration-based or time-based.
double adaptative_time_step_scaling
Time step scaling factor for adaptive time stepping.
Parameters::SimulationControl::OutputControl output_control
Output control type: iteration-based or time-based.
double output_time_frequency
Output frequency for time-based output control.
virtual bool is_output_iteration()
Check if the present iteration is an output iteration.
virtual bool is_adaptive_time_stepping() const =0
Indicate if the simulation uses adaptive time stepping or not.
virtual double calculate_time_step()
Calculate the next value of the time step.
double startup_timestep_scaling
The time scaling used for small time steps at the startup of the simulation.
bool output_boundaries
Output boundaries flag.
virtual bool is_verbose_iteration()
Check if the present iteration is a verbose iteration.
bool is_sdirk() const
Establish if the method is an SDIRK method.
virtual bool is_first_assembly()
Check if this is the first assembly of the present iteration.
void set_CFL(const double p_CFL)
Set the value of the CFL condition.
Vector< double > bdf_coefs
BDF coefficients used for time-stepping methods.
double current_time
Time of the current iteration being solved for.
double current_capillary_time_step_ratio
Computed ratio between the current time step and the capillary time-step constraint (Δt/Δt_σ).
unsigned int get_group_files() const
Get number of parallel files to generate for output.
bool is_refinement_step(const Parameters::MeshAdaptation &mesh_adaptation)
Check if the current step is a refinement step.
unsigned int get_iteration_number() const
Get current iteration number.
bool output_enabled() const
Check if VTU/PVTU/PVD outputs are disabled.
double stop_tolerance
Residual tolerance at which the simulation stops.
double get_current_time() const
Get current simulation time.
double CFL
Courant-Friedrich-Levy (CFL) condition value.
double initial_time_step
Initial time step given in the parameter file.
virtual void read(const std::string &prefix)
Read the simulation control information from a checkpoint file.
unsigned int group_files
Number of parallel files to generate for output.
void add_time_step(double p_timestep)
Add a time step and store the previous one in the history.
bool is_steady() const
Establish if the simulation is a steady-state simulation.
unsigned int output_iteration_frequency
Output iteration frequency.
unsigned int iteration_number
Iteration number.
unsigned int get_number_subdivision() const
Get number of mesh subdivisions for output.
static unsigned int get_number_of_stages(const Parameters::SimulationControl::TimeSteppingMethod &method)
Return the number of stages associated with the time-stepping method. For SDIRK methods,...
double capillary_time_step_constraint
Capillary time-step constraint for simulation time-stepping.
std::string output_path
Output directory path.
unsigned int number_mesh_adapt
Number of mesh adaptation iterations performed.
void limit_initial_time_step_with_capillary_time_step_constraint()
Update initial time step to respect the capillary time-step constraint. If the initial time step is a...
void update_assembly_method()
Define the assembly method to use while integrating.
Parameters::SimulationControl::TimeSteppingMethod get_assembly_method() const
Get current assembly method.
unsigned int get_log_precision() const
Get log precision.
virtual bool integrate()=0
Pure virtual function to control the progression of the simulation.
void provide_residual(const double new_residual)
Provide the value of the residual at the beginning of the iteration to the simulation controller.
double previous_time
Time of the previous iteration.
double max_CFL
Maximal CFL condition for adaptive time stepping.
unsigned int get_log_frequency() const
Get log frequency.
void set_assembly_method(const Parameters::SimulationControl::TimeSteppingMethod a_method)
Set the assembly method.
std::string output_name
Output file name prefix.
bool time_step_independent_of_end_time
Boolean to keep the time step for the last iteration regardless of the end time.
std::vector< double > get_time_steps_vector() const
Get time step history vector.
std::vector< double > get_checkpointed_simulation_control_info(const std::string &prefix)
Read and return simulation control information from checkpoint without updating.
double get_time_step() const
Get current time step.
void end_stages()
Restore the current time to after all the stages of a multi-stage method have been solved....
virtual void save(const std::string &prefix)
Save the simulation control information to a checkpoint file.
double residual
Current value of the norm of the right-hand side residual.
Vector< double > const & get_bdf_coefficients()
Get BDF coefficients.
unsigned int get_number_of_previous_solution_in_assembly() const
Get number of previous solutions required in assembly.
void set_current_time_step(const double new_time_step)
Manually force the value of the time step for the present iteration.
SimulationControl(const Parameters::SimulationControl ¶m)
Construct a SimulationControl object from parameter structure.
unsigned int log_precision
Log precision.
bool adapt_with_capillary_time_step_ratio
Enable adaptive time-stepping that respects the capillary time-step constraint.
std::string get_output_name() const
Get output file name prefix.
bool get_output_boundaries() const
Check if the boundaries of the domain should be outputted when writing results.
virtual void print_progression(const ConditionalOStream &pcout)=0
Print the current progress status of the simulation.
double max_capillary_time_step_ratio
The user inputted ratio between the time step and the capillary time-step constraint (Δt/Δt_σ).
void set_stage_time(const double c_i)
Move the current time to an intermediate stage of a multi-stage (SDIRK) method, , so that time-depend...
void set_current_capillary_time_step_ratio()
Set the current capillary time-step ratio (Δt/Δt_σ).
virtual ~SimulationControl()=default
Default destructor.
double time_step
Time step linking the previous iteration and the current time.
void update_bdf_coefficients()
Update the BDF coefficients.
Parameters::SimulationControl::BDFStartupMethods bdf_start_method
The method used to start high-order BDF schemes.
double end_time
Simulation end time.
virtual bool is_at_end()=0
Establishes if a simulation has reached its end.
bool first_assembly
Indicator to tell if this is the first assembly of a time step.
bool is_bdf() const
Establish if the method is a BDF method.
std::vector< double > get_simulation_times() const
Get simulation times for current and previous time steps.
unsigned int subdivision
Number of mesh subdivisions to be used when outputting the results.
double get_previous_time() const
Get previous simulation time.
void set_capillary_time_step_constraint(const double p_capillary_time_step_constraint)
Set the value of the current capillary time-step constraint.
bool is_at_start() const
Establish if the iteration is the first iteration or if the simulation has not begun.
static constexpr unsigned int n_previous_time_steps
Number of time steps stored.
unsigned int end_iteration
Simulation end iteration.
unsigned int log_frequency
Log iteration frequency.
std::string get_output_path() const
Get output directory path.
Parameters::SimulationControl::TimeSteppingMethod method
Time stepping method used for the simulation (BDF, SDIRK, steady, etc.).
double get_current_capillary_time_step_ratio() const
Get current capillary time-step ratio (Δt/Δt_σ).
double get_CFL() const
Get current CFL number.
std::vector< double > time_step_vector
Time step vector storing previous time steps.
Parameters::SimulationControl::TimeSteppingMethod assembly_method
Current method used for the present assembly.
MeshAdaption - Parameters that control dynamic mesh adaptation. Dynamic mesh adaptation in Lethe is v...
SimulationControl - Defines the parameter that control the flow of the simulation as well as the freq...