63 for (
unsigned int i_time =
time_step_vector.size() - 1; i_time > 0; --i_time)
176 case Method::steady_bdf:
185 case Method::sdirk22:
188 case Method::sdirk33:
191 case Method::sdirk45:
198 "Unknown TimeSteppingMethod passed to "
199 "get_number_of_stages(). Please add the number of stages of the new method in core/simulation_control.cc."));
215 std::string filename = prefix +
".simulationcontrol";
216 std::ofstream output(filename.c_str());
217 output <<
"Simulation control" << std::endl;
221 output << std::fixed << std::setprecision(17);
225 output <<
"CFL " <<
CFL << std::endl;
233 std::string filename = prefix +
".simulationcontrol";
235 "checkpoint file of the simulation control, given by "
236 "'subsection restart' - 'set filename'");
237 std::ifstream input(filename.c_str());
240 std::getline(input, buffer);
242 input >> buffer >> time_step_value;
243 input >> buffer >>
CFL;
258 const std::string &prefix)
260 std::string filename = prefix +
".simulationcontrol";
262 "checkpoint file of the simulation control, given by "
263 "'subsection restart' - 'set filename'");
264 std::ifstream input(filename.c_str());
269 double last_checkpointed_time;
272 std::vector<double> simulation_control_info(2);
275 std::getline(input, buffer);
277 input >> buffer >> time_steps[i];
278 input >> buffer >> buffer;
279 input >> buffer >> last_checkpointed_time;
280 input >> buffer >> buffer;
283 simulation_control_info[0] = last_checkpointed_time;
286 simulation_control_info[1] = time_steps[0];
288 return simulation_control_info;
308 ExcMessage(
"The output time frequency must be strictly positive. "
309 "Set it to -1 to disable it."));
320 std::stringstream ss;
324 ss <<
"Transient iteration: " << std::setw(8) << std::left <<
iteration_number
325 <<
" Time: " << std::setw(8) << std::left <<
current_time
326 <<
" Time step: " << std::setw(8) << std::left <<
time_step
327 <<
" CFL: " << std::setw(8) << std::left << this->
get_CFL();
329 unsigned int first_line_size = ss.str().size();
334 std::stringstream cfl_ss;
335 cfl_ss << std::setprecision(this->
log_precision) << std::setw(8)
336 << std::left << this->
get_CFL();
337 const unsigned int cfl_value_length = cfl_ss.str().size();
338 const unsigned int blank_space_length =
339 first_line_size - std::strlen(
" CFL: ") - cfl_value_length;
343 << std::setw(blank_space_length) <<
" "
344 <<
" CTR: " << std::setw(8) << std::left
415 new_time_step = std::min(new_time_step,
max_dt);
419 double capillary_time_step =
421 new_time_step = std::min(new_time_step, capillary_time_step);
430 return new_time_step;
437 return new_time_step;
496 const auto output_time_index = [&](
const double time) {
526 const double upper_bound = next_time + margin;
529 [&](
const double output_time) {
530 return output_time > lower_bound &&
531 output_time <= upper_bound;
540 bool is_output_time =
546 is_output_time =
true;
551 is_output_time =
true;
553 return is_output_time;
570 const double old_CFL =
CFL;
584 const ConditionalOStream &pcout)
590 std::stringstream ss;
593 ss <<
"Transient iteration: " << std::setw(8) << std::left <<
iteration_number
594 <<
" Time: " << std::setw(8) << std::left <<
current_time
595 <<
" Time step: " << std::setw(8) << std::left <<
time_step;
631 std::stringstream ss;
634 ss <<
"Steady iteration: " << std::setw(8) << std::right <<
iteration_number
654 const ConditionalOStream &pcout)
661 std::stringstream ss;
665 ss <<
"Pseudo steady-state iteration: " << std::setw(8) << std::left
682 Particles::ParticleHandler<3> &input_photon_handler)
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.
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.
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 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.
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.
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_σ).
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.
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.
unsigned int output_iteration_frequency
Output iteration frequency.
unsigned int iteration_number
Iteration number.
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 update_assembly_method()
Define the assembly method to use while integrating.
double previous_time
Time of the previous iteration.
double max_CFL
Maximal CFL condition for adaptive time stepping.
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_checkpointed_simulation_control_info(const std::string &prefix)
Read and return simulation control information from checkpoint without updating.
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.
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.
double max_capillary_time_step_ratio
The user inputted ratio between the time step and the capillary time-step constraint (Δt/Δt_σ).
void set_current_capillary_time_step_ratio()
Set the current capillary time-step ratio (Δt/Δt_σ).
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.
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.
unsigned int subdivision
Number of mesh subdivisions to be used when outputting the results.
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.
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.
void check_file_exists(const std::string &file_name, const std::string &file_description)
Verify that a file that Lethe must read exists and can be opened, and raise an error stated in the us...
void announce_string(const ConditionalOStream &pcout, const std::string &expression, const char delimiter='-')
Prints a string and then adds a line above and below made with dashes containing as many dashes as th...
Simulation control classes for managing time-stepping and iteration control in Lethe.
MeshAdaption - Parameters that control dynamic mesh adaptation. Dynamic mesh adaptation in Lethe is v...
bool refinement_at_frequency
SimulationControl - Defines the parameter that control the flow of the simulation as well as the freq...