From 1a05a2b82808bc400a16ad4f0d886d60bf905810 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Tue, 29 Oct 2024 13:01:11 -0400 Subject: [PATCH 01/28] Add new param and fix time steps accordingly --- include/core/parameters.h | 3 ++ include/core/simulation_control.h | 3 ++ source/core/parameters.cc | 17 +++++--- source/core/simulation_control.cc | 69 ++++++++++++++++++++++++------- 4 files changed, 71 insertions(+), 21 deletions(-) diff --git a/include/core/parameters.h b/include/core/parameters.h index 9c550dc88b..49681f9829 100644 --- a/include/core/parameters.h +++ b/include/core/parameters.h @@ -96,6 +96,9 @@ namespace Parameters // End time double timeEnd; + // Intermediate time + double intermediate_time; + // Adaptative time stepping bool adapt; diff --git a/include/core/simulation_control.h b/include/core/simulation_control.h index d57fba49f3..d0a133ecec 100644 --- a/include/core/simulation_control.h +++ b/include/core/simulation_control.h @@ -40,6 +40,9 @@ class SimulationControl // Simulation end time double end_time; + // Simulation intermediate time in case of controlled restarts + double intermediate_time; + // Time step vector. This vector accumulates the time steps of the previous // iterations. This is required for multiple steps methods such as the bdfs. std::vector time_step_vector; diff --git a/source/core/parameters.cc b/source/core/parameters.cc index df0cd896bc..c94ee4dead 100644 --- a/source/core/parameters.cc +++ b/source/core/parameters.cc @@ -96,6 +96,10 @@ namespace Parameters Patterns::Double(), "Time step value"); prm.declare_entry("time end", "1", Patterns::Double(), "Time step value"); + prm.declare_entry("time intermediate", + "-1", + Patterns::Double(), + "Intermediate time for control restarts"); prm.declare_entry("startup time scaling", "0.4", Patterns::Double(), @@ -225,12 +229,13 @@ namespace Parameters { std::runtime_error("Invalid output control scheme"); } - dt = prm.get_double("time step"); - timeEnd = prm.get_double("time end"); - adapt = prm.get_bool("adapt"); - maxCFL = prm.get_double("max cfl"); - max_dt = prm.get_double("max time step"); - stop_tolerance = prm.get_double("stop tolerance"); + dt = prm.get_double("time step"); + timeEnd = prm.get_double("time end"); + intermediate_time = prm.get_double("time intermediate"); + adapt = prm.get_bool("adapt"); + maxCFL = prm.get_double("max cfl"); + max_dt = prm.get_double("max time step"); + stop_tolerance = prm.get_double("stop tolerance"); adaptative_time_step_scaling = prm.get_double("adaptative time step scaling"); startup_timestep_scaling = prm.get_double("startup time scaling"); diff --git a/source/core/simulation_control.cc b/source/core/simulation_control.cc index 029c2b7796..6bb6fa3972 100644 --- a/source/core/simulation_control.cc +++ b/source/core/simulation_control.cc @@ -16,6 +16,7 @@ SimulationControl::SimulationControl(const Parameters::SimulationControl ¶m) , time_step(param.dt) , initial_time_step(param.dt) , end_time(param.timeEnd) + , intermediate_time(param.intermediate_time) , iteration_number(0) , number_mesh_adapt(param.number_mesh_adaptation) , CFL(0) @@ -44,6 +45,10 @@ SimulationControl::SimulationControl(const Parameters::SimulationControl ¶m) // Resize the bdf_coefficients to ensure they have a default size; bdf_coefs.reinit(n_previous_time_steps + 1); + + // If there is an intermediate time, we change the end_time of the simulation + if (intermediate_time != -1) + end_time = intermediate_time; } void @@ -178,6 +183,10 @@ SimulationControl::read(const std::string &prefix) // Fix time step to be the last time_step that was used time_step = time_step_vector[0]; + + // Verify that the output time specified is valid after a restart + AssertThrow(output_time_frequency > current_time, + ExcMessage("The specified time for output is not valid.")); } std::vector @@ -285,8 +294,13 @@ SimulationControlTransient::calculate_time_step() new_time_step = std::min(new_time_step, max_dt); } - if (current_time + new_time_step > end_time) - new_time_step = end_time - current_time; + + // If there is a control restart, I do not want to change the time step + // to avoid issues with post-processing and more iterations in case of + // adaptive time step when restartting + if (intermediate_time == -1) + if (current_time + new_time_step > end_time) + new_time_step = end_time - current_time; return new_time_step; } @@ -343,13 +357,21 @@ SimulationControlTransientDynamicOutput::calculate_time_step() new_time_step = std::min(new_time_step, max_dt); } - if (current_time + new_time_step > end_time) - new_time_step = end_time - current_time; - - if (current_time + new_time_step > last_output_time + output_time_frequency) + // If there is a control restart, I do not want to change the time step + // to avoid issues with post-processing and more iterations in case of + // adaptive time step when restartting + if (intermediate_time == -1) { - new_time_step = last_output_time + output_time_frequency - current_time; - time_step_forced_output = true; + if (current_time + new_time_step > end_time) + new_time_step = end_time - current_time; + + if (current_time + new_time_step > + last_output_time + output_time_frequency) + { + new_time_step = + last_output_time + output_time_frequency - current_time; + time_step_forced_output = true; + } } return new_time_step; @@ -358,15 +380,32 @@ SimulationControlTransientDynamicOutput::calculate_time_step() bool SimulationControlTransientDynamicOutput::is_output_iteration() { + bool is_output_time = false; + // Check if the current step number matches the output time frequency and // falls within the user-specified time window. - bool is_output_time = - ((current_time - last_output_time) - output_time_frequency > - -1e-12 * output_time_frequency && - get_current_time() >= output_time_interval[0] && - get_current_time() <= output_time_interval[1]); - if (is_output_time) - last_output_time = current_time; + if (intermediate_time == -1) + { + is_output_time = + ((current_time - last_output_time) - output_time_frequency > + -1e-12 * output_time_frequency && + get_current_time() >= output_time_interval[0] && + get_current_time() <= output_time_interval[1]); + if (is_output_time) + last_output_time = current_time; + } + else + { + // Output the previous time step + if (current_time < intermediate_time && + (current_time + calculate_time_step() >= intermediate_time)) + is_output_time = true; + + // Output the next time step + if (current_time >= intermediate_time && + (current_time - time_step_vector[1] < intermediate_time)) + is_output_time = true; + } return is_output_time; } From 035e0e45ff920c79708619abacc8dff2bd490ff8 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Wed, 30 Oct 2024 13:45:36 -0400 Subject: [PATCH 02/28] Add new bool parameter and modify output time frequency --- include/core/parameters.h | 10 +++++----- source/core/parameters.cc | 29 +++++++++++++++++------------ 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/include/core/parameters.h b/include/core/parameters.h index 49681f9829..e75eafce0d 100644 --- a/include/core/parameters.h +++ b/include/core/parameters.h @@ -96,8 +96,9 @@ namespace Parameters // End time double timeEnd; - // Intermediate time - double intermediate_time; + // Boolean to keep the time step for the last iteration regardless of the + // end time specify. Both for fixed time step and adaptive time step. + bool time_step_independent_of_end_time; // Adaptative time stepping bool adapt; @@ -138,11 +139,10 @@ namespace Parameters multiple_step_bdf, } bdf_startup_method; - - // Frequency of the output + // Frequency of the output (for both time and iteration output) unsigned int output_frequency; - // Frequency of the output + // Output at a specific time double output_time; // Time window for file output diff --git a/source/core/parameters.cc b/source/core/parameters.cc index c94ee4dead..cd5c60f333 100644 --- a/source/core/parameters.cc +++ b/source/core/parameters.cc @@ -96,10 +96,6 @@ namespace Parameters Patterns::Double(), "Time step value"); prm.declare_entry("time end", "1", Patterns::Double(), "Time step value"); - prm.declare_entry("time intermediate", - "-1", - Patterns::Double(), - "Intermediate time for control restarts"); prm.declare_entry("startup time scaling", "0.4", Patterns::Double(), @@ -109,6 +105,11 @@ namespace Parameters "false", Patterns::Bool(), "Adaptative time-stepping "); + prm.declare_entry( + "time step independent of end time", + "true", + Patterns::Bool(), + "Ensures that the correct time step is kept when using adaptive time step simulations"); prm.declare_entry("number mesh adapt", "0", Patterns::Integer(), @@ -163,7 +164,10 @@ namespace Parameters "This setting percolates to all output to the log"); - prm.declare_entry("output time", "1", Patterns::Double(), "Output time"); + prm.declare_entry("output time", + "-1", + Patterns::Double(), + "Specific output time for simulation results"); prm.declare_entry( "output control", @@ -229,13 +233,14 @@ namespace Parameters { std::runtime_error("Invalid output control scheme"); } - dt = prm.get_double("time step"); - timeEnd = prm.get_double("time end"); - intermediate_time = prm.get_double("time intermediate"); - adapt = prm.get_bool("adapt"); - maxCFL = prm.get_double("max cfl"); - max_dt = prm.get_double("max time step"); - stop_tolerance = prm.get_double("stop tolerance"); + dt = prm.get_double("time step"); + timeEnd = prm.get_double("time end"); + adapt = prm.get_bool("adapt"); + time_step_independent_of_end_time = + prm.get_bool("time step independent of end time"); + maxCFL = prm.get_double("max cfl"); + max_dt = prm.get_double("max time step"); + stop_tolerance = prm.get_double("stop tolerance"); adaptative_time_step_scaling = prm.get_double("adaptative time step scaling"); startup_timestep_scaling = prm.get_double("startup time scaling"); From de145f8eb03e56eec49d1b16cb279967e967bc7d Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Wed, 30 Oct 2024 13:46:11 -0400 Subject: [PATCH 03/28] Modify functions for output and calculate time step --- include/core/simulation_control.h | 7 +- source/core/simulation_control.cc | 110 +++++++++++++----------------- 2 files changed, 52 insertions(+), 65 deletions(-) diff --git a/include/core/simulation_control.h b/include/core/simulation_control.h index d0a133ecec..086af64783 100644 --- a/include/core/simulation_control.h +++ b/include/core/simulation_control.h @@ -40,8 +40,9 @@ class SimulationControl // Simulation end time double end_time; - // Simulation intermediate time in case of controlled restarts - double intermediate_time; + // Boolean to keep the time step for the last iteration regardless of the end + // time specify. Both for fixed time step and adaptive time step. + bool time_step_independent_of_end_time; // Time step vector. This vector accumulates the time steps of the previous // iterations. This is required for multiple steps methods such as the bdfs. @@ -85,7 +86,7 @@ class SimulationControl // Output time frequency // Controls the output of the simulation results when the output is controlled // by the time - double output_time_frequency; + double output_time; // Adds a condition to the generation of .vtu and .pvd files in addition to // the output generation frequency. If specified in the parameter file, only diff --git a/source/core/simulation_control.cc b/source/core/simulation_control.cc index 6bb6fa3972..db9d1107ea 100644 --- a/source/core/simulation_control.cc +++ b/source/core/simulation_control.cc @@ -16,7 +16,7 @@ SimulationControl::SimulationControl(const Parameters::SimulationControl ¶m) , time_step(param.dt) , initial_time_step(param.dt) , end_time(param.timeEnd) - , intermediate_time(param.intermediate_time) + , time_step_independent_of_end_time(param.time_step_independent_of_end_time) , iteration_number(0) , number_mesh_adapt(param.number_mesh_adaptation) , CFL(0) @@ -24,7 +24,7 @@ SimulationControl::SimulationControl(const Parameters::SimulationControl ¶m) , residual(DBL_MAX) , stop_tolerance(param.stop_tolerance) , output_frequency(param.output_frequency) - , output_time_frequency(param.output_time) + , output_time(param.output_time) , output_time_interval(param.output_time_interval) , log_frequency(param.log_frequency) , log_precision(param.log_precision) @@ -45,10 +45,6 @@ SimulationControl::SimulationControl(const Parameters::SimulationControl ¶m) // Resize the bdf_coefficients to ensure they have a default size; bdf_coefs.reinit(n_previous_time_steps + 1); - - // If there is an intermediate time, we change the end_time of the simulation - if (intermediate_time != -1) - end_time = intermediate_time; } void @@ -72,9 +68,7 @@ SimulationControl::is_output_iteration() { // Check if the current step number matches the output frequency and falls // within the user-specified time window. - return (get_step_number() % output_frequency == 0 && - get_current_time() >= output_time_interval[0] && - get_current_time() <= output_time_interval[1]); + return (get_step_number() % output_frequency == 0); } } @@ -183,10 +177,6 @@ SimulationControl::read(const std::string &prefix) // Fix time step to be the last time_step that was used time_step = time_step_vector[0]; - - // Verify that the output time specified is valid after a restart - AssertThrow(output_time_frequency > current_time, - ExcMessage("The specified time for output is not valid.")); } std::vector @@ -295,12 +285,15 @@ SimulationControlTransient::calculate_time_step() new_time_step = std::min(new_time_step, max_dt); } - // If there is a control restart, I do not want to change the time step - // to avoid issues with post-processing and more iterations in case of - // adaptive time step when restartting - if (intermediate_time == -1) - if (current_time + new_time_step > end_time) - new_time_step = end_time - current_time; + // Ensure that the time step for the last iteration is kept regardless of the + // end time set + if (time_step_independent_of_end_time) + return new_time_step; + + // If we want to ensure that the last iteration is exactly the end time + // regardless of the time step + if (current_time + new_time_step > end_time) + new_time_step = end_time - current_time; return new_time_step; } @@ -343,12 +336,8 @@ double SimulationControlTransientDynamicOutput::calculate_time_step() { double new_time_step = time_step; - if (time_step_forced_output) - { - new_time_step = time_step_vector[1]; - time_step_forced_output = false; - } - else if (iteration_number > 1) + + if (iteration_number > 1) { new_time_step = time_step * adaptative_time_step_scaling; if (CFL > 0 && max_CFL / CFL < adaptative_time_step_scaling) @@ -357,22 +346,16 @@ SimulationControlTransientDynamicOutput::calculate_time_step() new_time_step = std::min(new_time_step, max_dt); } - // If there is a control restart, I do not want to change the time step - // to avoid issues with post-processing and more iterations in case of - // adaptive time step when restartting - if (intermediate_time == -1) - { - if (current_time + new_time_step > end_time) - new_time_step = end_time - current_time; - - if (current_time + new_time_step > - last_output_time + output_time_frequency) - { - new_time_step = - last_output_time + output_time_frequency - current_time; - time_step_forced_output = true; - } - } + // Ensure that the time step for the last iteration is kept regardless of the + // end time set + if (time_step_independent_of_end_time) + return new_time_step; + + // If we want to ensure that the last iteration is exactly the end time + // regardless of the time step + if (current_time + new_time_step > end_time) + new_time_step = end_time - current_time; + return new_time_step; } @@ -380,33 +363,36 @@ SimulationControlTransientDynamicOutput::calculate_time_step() bool SimulationControlTransientDynamicOutput::is_output_iteration() { - bool is_output_time = false; + bool is_output_time = false; + double upper_bound, lower_bound; - // Check if the current step number matches the output time frequency and - // falls within the user-specified time window. - if (intermediate_time == -1) + // If a specific time is given + if (output_time != -1) { - is_output_time = - ((current_time - last_output_time) - output_time_frequency > - -1e-12 * output_time_frequency && - get_current_time() >= output_time_interval[0] && - get_current_time() <= output_time_interval[1]); - if (is_output_time) - last_output_time = current_time; + upper_bound = output_time; + lower_bound = output_time; } - else + else // If an interval is specified { - // Output the previous time step - if (current_time < intermediate_time && - (current_time + calculate_time_step() >= intermediate_time)) - is_output_time = true; - - // Output the next time step - if (current_time >= intermediate_time && - (current_time - time_step_vector[1] < intermediate_time)) - is_output_time = true; + upper_bound = output_time_interval[1]; + lower_bound = output_time_interval[0]; } + // Case 1. If it is within the interval write only according to output + // frequency + is_output_time = + (current_time >= lower_bound && current_time <= upper_bound && + get_step_number() % output_frequency == 0); + + // Case 2. One time step before the interval + double next_time = current_time + calculate_time_step(); + if (current_time < lower_bound && (next_time >= lower_bound)) + is_output_time = true; + + // Case 3. One time step after the interval + if (current_time >= upper_bound && (previous_time < upper_bound)) + is_output_time = true; + return is_output_time; } From 14a66aa9fa4dea2f737906589daf537d6462aa4f Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Wed, 30 Oct 2024 14:24:36 -0400 Subject: [PATCH 04/28] Update coments and removed duplicated calculate time step functions --- include/core/simulation_control.h | 38 +++------------- source/core/simulation_control.cc | 73 +++++-------------------------- 2 files changed, 16 insertions(+), 95 deletions(-) diff --git a/include/core/simulation_control.h b/include/core/simulation_control.h index 086af64783..99acfc06ea 100644 --- a/include/core/simulation_control.h +++ b/include/core/simulation_control.h @@ -508,14 +508,13 @@ class SimulationControlTransient : public SimulationControl * is enabled, the time step is calculated in order to ensure * that the CFL condition is bound by the maximal CFL value. * The new time step is equal to adaptative_time_step_scaling * the previous - * time step. If this surpasses the simulation time or if it surpasses the - * maximal CFL value, the time step is scaled down to ensure that this is - * respected. + * time step. If the time_step_independet_of_end_time is set to false, the + * time step is asjusted to meet exactly the end time; the default is to not + * modify the time step. */ virtual double calculate_time_step() override; - public: SimulationControlTransient(const Parameters::SimulationControl ¶m); @@ -552,31 +551,13 @@ class SimulationControlTransientDynamicOutput : public SimulationControlTransient { protected: - // Time step has been forced - bool time_step_forced_output; - - // Time at which there was a last output - double last_output_time; - - /** - * @brief Calculates the next value of the time step. The time step is calculated in order to ensure - * that the CFL condition is bound by the maximal CFL value. - * The new time step is equal to adaptative_time_step_scaling * the previous - * time step. If this surpasses the simulation time, the output_time or if it - * surpasses the maximal CFL value, the time step is scaled down to ensure - * that these elements are respected. - */ - virtual double - calculate_time_step() override; - public: SimulationControlTransientDynamicOutput( const Parameters::SimulationControl ¶m); - /** - * @brief Output iterations are calculated based on the value of the time - * and the time frequency of the output + * @brief Output iterations are calculated based on the value of the output time + * or the output interval and the output frequency within the interval. */ virtual bool is_output_iteration() override; @@ -611,15 +592,6 @@ class SimulationControlAdjointSteady : public SimulationControlTransient virtual void print_progression(const ConditionalOStream &pcout) override; - /** - * @brief Calculates the next value of the time step. The time step is calculated in order to ensure - * that the CFL condition is bound by the maximal CFL value. - * The new time step is equal to adaptative_time_step_scaling * the previous - * time step. - */ - virtual double - calculate_time_step() override; - /** * @brief Ends the simulation when the desired residual is reached */ diff --git a/source/core/simulation_control.cc b/source/core/simulation_control.cc index db9d1107ea..75215c11aa 100644 --- a/source/core/simulation_control.cc +++ b/source/core/simulation_control.cc @@ -66,8 +66,7 @@ SimulationControl::is_output_iteration() return false; else { - // Check if the current step number matches the output frequency and falls - // within the user-specified time window. + // Check if the current step number matches the output frequency return (get_step_number() % output_frequency == 0); } } @@ -262,8 +261,6 @@ SimulationControlTransient::integrate() return false; } - - bool SimulationControlTransient::is_at_end() { @@ -290,8 +287,8 @@ SimulationControlTransient::calculate_time_step() if (time_step_independent_of_end_time) return new_time_step; - // If we want to ensure that the last iteration is exactly the end time - // regardless of the time step + // Modify last time step to ensure that the last iteration is exactly the end + // time specified in the parameter file if (current_time + new_time_step > end_time) new_time_step = end_time - current_time; @@ -327,39 +324,8 @@ SimulationControlTransientDynamicOutput:: SimulationControlTransientDynamicOutput( const Parameters::SimulationControl ¶m) : SimulationControlTransient(param) - , time_step_forced_output(false) - // To be fixed for restarts - , last_output_time(0.) {} -double -SimulationControlTransientDynamicOutput::calculate_time_step() -{ - double new_time_step = time_step; - - if (iteration_number > 1) - { - new_time_step = time_step * adaptative_time_step_scaling; - if (CFL > 0 && max_CFL / CFL < adaptative_time_step_scaling) - new_time_step = time_step * max_CFL / CFL; - - new_time_step = std::min(new_time_step, max_dt); - } - - // Ensure that the time step for the last iteration is kept regardless of the - // end time set - if (time_step_independent_of_end_time) - return new_time_step; - - // If we want to ensure that the last iteration is exactly the end time - // regardless of the time step - if (current_time + new_time_step > end_time) - new_time_step = end_time - current_time; - - - return new_time_step; -} - bool SimulationControlTransientDynamicOutput::is_output_iteration() { @@ -378,18 +344,18 @@ SimulationControlTransientDynamicOutput::is_output_iteration() lower_bound = output_time_interval[0]; } - // Case 1. If it is within the interval write only according to output + // Case 1. If it is within the interval, write only according to output // frequency is_output_time = (current_time >= lower_bound && current_time <= upper_bound && get_step_number() % output_frequency == 0); - // Case 2. One time step before the interval + // Case 2. Always write one time step before the interval double next_time = current_time + calculate_time_step(); if (current_time < lower_bound && (next_time >= lower_bound)) is_output_time = true; - // Case 3. One time step after the interval + // Case 3. Always write one time step after the interval if (current_time >= upper_bound && (previous_time < upper_bound)) is_output_time = true; @@ -442,6 +408,11 @@ SimulationControlSteady::is_at_end() return iteration_number >= (number_mesh_adapt + 1); } +SimulationControlAdjointSteady::SimulationControlAdjointSteady( + const Parameters::SimulationControl ¶m) + : SimulationControlTransient(param) +{} + void SimulationControlAdjointSteady::print_progression( const ConditionalOStream &pcout) @@ -469,25 +440,3 @@ SimulationControlAdjointSteady::is_at_end() { return residual <= stop_tolerance; } - -SimulationControlAdjointSteady::SimulationControlAdjointSteady( - const Parameters::SimulationControl ¶m) - : SimulationControlTransient(param) -{} - -double -SimulationControlAdjointSteady::calculate_time_step() -{ - double new_time_step = time_step; - - if (adapt && iteration_number > 1) - { - new_time_step = time_step * adaptative_time_step_scaling; - if (CFL > 0 && max_CFL / CFL < adaptative_time_step_scaling) - new_time_step = time_step * max_CFL / CFL; - - new_time_step = std::min(new_time_step, max_dt); - } - - return new_time_step; -} From 03237faf0509fd64ef18188adcfd0c76061f7884 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Wed, 30 Oct 2024 14:28:15 -0400 Subject: [PATCH 05/28] Correct typo --- include/core/simulation_control.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/core/simulation_control.h b/include/core/simulation_control.h index 99acfc06ea..6b9132e9f7 100644 --- a/include/core/simulation_control.h +++ b/include/core/simulation_control.h @@ -508,7 +508,7 @@ class SimulationControlTransient : public SimulationControl * is enabled, the time step is calculated in order to ensure * that the CFL condition is bound by the maximal CFL value. * The new time step is equal to adaptative_time_step_scaling * the previous - * time step. If the time_step_independet_of_end_time is set to false, the + * time step. If the time_step_independent_of_end_time is set to false, the * time step is asjusted to meet exactly the end time; the default is to not * modify the time step. */ From 82313cc41f8e8b1407f4e2ef441df1c8d9fe7f0a Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Wed, 30 Oct 2024 16:24:10 -0400 Subject: [PATCH 06/28] Remove dynamic output control class --- include/core/simulation_control.h | 27 ++++------- source/core/simulation_control.cc | 71 +++++++++++++++------------- source/solvers/navier_stokes_base.cc | 10 +--- 3 files changed, 51 insertions(+), 57 deletions(-) diff --git a/include/core/simulation_control.h b/include/core/simulation_control.h index 6b9132e9f7..4245cc60c8 100644 --- a/include/core/simulation_control.h +++ b/include/core/simulation_control.h @@ -503,6 +503,9 @@ class SimulationControlTransient : public SimulationControl // Max time step double max_dt; + // Output control type: iteration or type + Parameters::SimulationControl::OutputControl output_control; + /** * @brief Calculates the next value of the time step. If adaptation * is enabled, the time step is calculated in order to ensure @@ -527,12 +530,18 @@ class SimulationControlTransient : public SimulationControl virtual bool integrate() override; - /** * @brief Ends the simulation when the end time is reached */ virtual bool is_at_end() override; + + /** + * @brief Output iterations are calculated based on the value of the output time + * or the output interval and the output frequency within the interval. + */ + virtual bool + is_output_iteration() override; }; /** @@ -547,22 +556,6 @@ class SimulationControlTransientDEM : public SimulationControlTransient print_progression(const ConditionalOStream &pcout) override; }; -class SimulationControlTransientDynamicOutput - : public SimulationControlTransient -{ -protected: -public: - SimulationControlTransientDynamicOutput( - const Parameters::SimulationControl ¶m); - - /** - * @brief Output iterations are calculated based on the value of the output time - * or the output interval and the output frequency within the interval. - */ - virtual bool - is_output_iteration() override; -}; - class SimulationControlSteady : public SimulationControl { public: diff --git a/source/core/simulation_control.cc b/source/core/simulation_control.cc index 75215c11aa..f6fe5c3d47 100644 --- a/source/core/simulation_control.cc +++ b/source/core/simulation_control.cc @@ -217,6 +217,7 @@ SimulationControlTransient::SimulationControlTransient( , adapt(param.adapt) , adaptative_time_step_scaling(param.adaptative_time_step_scaling) , max_dt(param.max_dt) + , output_control(param.output_control) {} void @@ -295,40 +296,22 @@ SimulationControlTransient::calculate_time_step() return new_time_step; } -SimulationControlTransientDEM::SimulationControlTransientDEM( - const Parameters::SimulationControl ¶m) - : SimulationControlTransient(param) -{} - -void -SimulationControlTransientDEM::print_progression( - const ConditionalOStream &pcout) -{ - if (!is_verbose_iteration()) - return; - - pcout << std::endl; - std::stringstream ss; - - // Copy information into a string stream - ss << "Transient iteration: " << std::setw(8) << std::left << iteration_number - << " Time: " << std::setw(8) << std::left << current_time - << " Time step: " << std::setw(8) << std::left << time_step; - - // Announce string - announce_string(pcout, ss.str(), '*'); -} - - -SimulationControlTransientDynamicOutput:: - SimulationControlTransientDynamicOutput( - const Parameters::SimulationControl ¶m) - : SimulationControlTransient(param) -{} - bool -SimulationControlTransientDynamicOutput::is_output_iteration() +SimulationControlTransient::is_output_iteration() { + // If iteration control + if (output_control == Parameters::SimulationControl::OutputControl::iteration) + { + if (output_frequency == 0) + return false; + else + { + // Check if the current step number matches the output frequency + return (get_step_number() % output_frequency == 0); + } + } + + // If time control bool is_output_time = false; double upper_bound, lower_bound; @@ -362,6 +345,30 @@ SimulationControlTransientDynamicOutput::is_output_iteration() return is_output_time; } +SimulationControlTransientDEM::SimulationControlTransientDEM( + const Parameters::SimulationControl ¶m) + : SimulationControlTransient(param) +{} + +void +SimulationControlTransientDEM::print_progression( + const ConditionalOStream &pcout) +{ + if (!is_verbose_iteration()) + return; + + pcout << std::endl; + std::stringstream ss; + + // Copy information into a string stream + ss << "Transient iteration: " << std::setw(8) << std::left << iteration_number + << " Time: " << std::setw(8) << std::left << current_time + << " Time step: " << std::setw(8) << std::left << time_step; + + // Announce string + announce_string(pcout, ss.str(), '*'); +} + SimulationControlSteady::SimulationControlSteady( const Parameters::SimulationControl ¶m) diff --git a/source/solvers/navier_stokes_base.cc b/source/solvers/navier_stokes_base.cc index c0f5f3cb87..a426aa8629 100644 --- a/source/solvers/navier_stokes_base.cc +++ b/source/solvers/navier_stokes_base.cc @@ -134,14 +134,8 @@ NavierStokesBase::NavierStokesBase( } else { - if (simulation_parameters.simulation_control.output_control == - Parameters::SimulationControl::OutputControl::time) - simulation_control = - std::make_shared( - simulation_parameters.simulation_control); - else - simulation_control = std::make_shared( - simulation_parameters.simulation_control); + simulation_control = std::make_shared( + simulation_parameters.simulation_control); } // Provide the simulation control object to the physical property manager From 20c4c6b3e61396620644025e8699a59c8d29e1e8 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Wed, 30 Oct 2024 16:24:35 -0400 Subject: [PATCH 07/28] Update output iteration tests --- tests/core/simulation_control_03.cc | 144 ++++++++++++++++++++---- tests/core/simulation_control_03.output | 75 +++++++++--- tests/core/simulation_control_06.cc | 85 -------------- tests/core/simulation_control_06.output | 15 --- 4 files changed, 180 insertions(+), 139 deletions(-) delete mode 100644 tests/core/simulation_control_06.cc delete mode 100644 tests/core/simulation_control_06.output diff --git a/tests/core/simulation_control_03.cc b/tests/core/simulation_control_03.cc index 4c2fa7ead0..f233cfdb0a 100644 --- a/tests/core/simulation_control_03.cc +++ b/tests/core/simulation_control_03.cc @@ -2,13 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later /** - * @brief This test checks that the transient simulation control stops - * at the correct moment and behaves in a correct manner. + * @brief This test checks whether the is_output_iteration behaves correctly for iteration output control and time output control (in the case of constant time step and adaptive time step). */ -// We first check if the constant time-stepping number work -// then we test adaptative time-stepping - // Lethe #include #include @@ -25,25 +21,83 @@ test() simulation_control_parameters.adapt = false; simulation_control_parameters.maxCFL = 2; simulation_control_parameters.method = - Parameters::SimulationControl::TimeSteppingMethod::bdf1; + simulation_control_parameters.timeEnd = 0.5; + simulation_control_parameters.number_mesh_adaptation = 9; + simulation_control_parameters.subdivision = 7; + simulation_control_parameters.output_frequency = 8; + simulation_control_parameters.time_step_independent_of_end_time = true; - simulation_control_parameters.timeEnd = 0.5; - simulation_control_parameters.number_mesh_adaptation = 9; - simulation_control_parameters.output_name = "test"; - simulation_control_parameters.subdivision = 7; - simulation_control_parameters.output_folder = "canard"; - simulation_control_parameters.output_frequency = 8; - simulation_control_parameters.output_time_interval = {0, 1000000000}; + { + SimulationControlTransient simulation_control( + simulation_control_parameters); + + // Constant time-stepping - constant output + deallog << "*************************************************" << std::endl; + deallog << "Constant time stepping - constant output" << std::endl; + deallog << "*************************************************" << std::endl; + deallog << "Iteration : " << simulation_control.get_step_number() + << " Time : " << simulation_control.get_current_time() + << std::endl; + + while (simulation_control.integrate()) + { + deallog << "Iteration : " << simulation_control.get_step_number() + << " Time : " << simulation_control.get_current_time() + << std::endl; + + if (simulation_control.is_at_start()) + deallog << "This is the first time step" << std::endl; + + if (simulation_control.is_output_iteration()) + deallog << "This is an output iteration" << std::endl; + } + } { + simulation_control_parameters.output_time = 0.3; + simulation_control_parameters.output_control = + Parameters::SimulationControl::OutputControl::time; + simulation_control_parameters.output_frequency = 1; + SimulationControlTransient simulation_control( simulation_control_parameters); + // Constant time-stepping - specific time output + deallog << "*************************************************" << std::endl; + deallog << "Constant time stepping - specific time output" << std::endl; + deallog << "*************************************************" << std::endl; + deallog << "Iteration : " << simulation_control.get_step_number() + << " Time : " << simulation_control.get_current_time() + << std::endl; + + while (simulation_control.integrate()) + { + deallog << "Iteration : " << simulation_control.get_step_number() + << " Time : " << simulation_control.get_current_time() + << std::endl; + + if (simulation_control.is_at_start()) + deallog << "This is the first time step" << std::endl; + + if (simulation_control.is_output_iteration()) + deallog << "This is an output iteration" << std::endl; + } + } - // Constant time-stepping + { + simulation_control_parameters.output_time = -1; + simulation_control_parameters.output_time_interval = {0.2, 0.4}; + simulation_control_parameters.output_control = + Parameters::SimulationControl::OutputControl::time; + simulation_control_parameters.output_frequency = 1; + + SimulationControlTransient simulation_control( + simulation_control_parameters); + + // Constant time-stepping - time interval output deallog << "*************************************************" << std::endl; - deallog << "Constant time stepping - constant output" << std::endl; + deallog << "Constant time stepping - specific time interval" << std::endl; deallog << "*************************************************" << std::endl; deallog << "Iteration : " << simulation_control.get_step_number() << " Time : " << simulation_control.get_current_time() @@ -70,12 +124,13 @@ test() simulation_control_parameters.adaptative_time_step_scaling = 1.2; simulation_control_parameters.maxCFL = 2; simulation_control_parameters.max_dt = 1e6; - + simulation_control_parameters.output_control = + Parameters::SimulationControl::OutputControl::iteration; + simulation_control_parameters.output_frequency = 8; SimulationControlTransient simulation_control( simulation_control_parameters); - // Adaptative time-stepping - constant output deallog << "*************************************************" << std::endl; deallog << "Adaptative time stepping - constant output" << std::endl; @@ -101,26 +156,67 @@ test() simulation_control.set_CFL(simulation_control.get_time_step()); } } - { simulation_control_parameters.adapt = true; - simulation_control_parameters.timeEnd = 30; + simulation_control_parameters.timeEnd = 25; simulation_control_parameters.dt = 1; simulation_control_parameters.adaptative_time_step_scaling = 1.2; simulation_control_parameters.maxCFL = 2; simulation_control_parameters.output_time = 7.5; simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.max_dt = 1e6; - + simulation_control_parameters.max_dt = 1e6; + simulation_control_parameters.output_frequency = 1; - SimulationControlTransientDynamicOutput simulation_control( + SimulationControlTransient simulation_control( simulation_control_parameters); + // Adaptative time-stepping - specific time output + deallog << "*************************************************" << std::endl; + deallog << "Adaptative time stepping - specific time output" << std::endl; + deallog << "*************************************************" << std::endl; + deallog << "Iteration : " << simulation_control.get_step_number() + << " Time : " << simulation_control.get_current_time() + << " Time step : " << simulation_control.get_time_step() + << std::endl; + + while (simulation_control.integrate()) + { + deallog << "Iteration : " << simulation_control.get_step_number() + << " Time : " << simulation_control.get_current_time() + << " Time step : " << simulation_control.get_time_step() + << std::endl; + + if (simulation_control.is_at_start()) + deallog << "This is the first time step" << std::endl; + + if (simulation_control.is_output_iteration()) + deallog << "This is an output iteration" << std::endl; + + simulation_control.set_CFL(simulation_control.get_time_step()); + } + } + + { + simulation_control_parameters.adapt = true; + simulation_control_parameters.timeEnd = 25; + simulation_control_parameters.dt = 1; + simulation_control_parameters.adaptative_time_step_scaling = 1.2; + simulation_control_parameters.maxCFL = 2; + simulation_control_parameters.output_time = -1; + simulation_control_parameters.output_time_interval = {7.5, 17}; + simulation_control_parameters.output_control = + Parameters::SimulationControl::OutputControl::time; + simulation_control_parameters.max_dt = 1e6; + simulation_control_parameters.output_frequency = 1; + + + SimulationControlTransient simulation_control( + simulation_control_parameters); - // Adaptative time-stepping - time output + // Adaptative time-stepping - time interval output deallog << "*************************************************" << std::endl; - deallog << "Adaptative time stepping - time output" << std::endl; + deallog << "Adaptative time stepping - interval time output" << std::endl; deallog << "*************************************************" << std::endl; deallog << "Iteration : " << simulation_control.get_step_number() << " Time : " << simulation_control.get_current_time() diff --git a/tests/core/simulation_control_03.output b/tests/core/simulation_control_03.output index 8db6799e44..f7bd53ffc4 100644 --- a/tests/core/simulation_control_03.output +++ b/tests/core/simulation_control_03.output @@ -10,6 +10,32 @@ DEAL::Iteration : 3 Time : 0.300000 DEAL::Iteration : 4 Time : 0.400000 DEAL::Iteration : 5 Time : 0.500000 DEAL::************************************************* +DEAL::Constant time stepping - specific time output +DEAL::************************************************* +DEAL::Iteration : 0 Time : 0.00000 +DEAL::Iteration : 1 Time : 0.100000 +DEAL::This is the first time step +DEAL::Iteration : 2 Time : 0.200000 +DEAL::This is an output iteration +DEAL::Iteration : 3 Time : 0.300000 +DEAL::This is an output iteration +DEAL::Iteration : 4 Time : 0.400000 +DEAL::Iteration : 5 Time : 0.500000 +DEAL::************************************************* +DEAL::Constant time stepping - specific time interval +DEAL::************************************************* +DEAL::Iteration : 0 Time : 0.00000 +DEAL::Iteration : 1 Time : 0.100000 +DEAL::This is the first time step +DEAL::This is an output iteration +DEAL::Iteration : 2 Time : 0.200000 +DEAL::This is an output iteration +DEAL::Iteration : 3 Time : 0.300000 +DEAL::This is an output iteration +DEAL::Iteration : 4 Time : 0.400000 +DEAL::This is an output iteration +DEAL::Iteration : 5 Time : 0.500000 +DEAL::************************************************* DEAL::Adaptative time stepping - constant output DEAL::************************************************* DEAL::Iteration : 0 Time : 0.00000 Time step : 1.00000 @@ -26,9 +52,9 @@ DEAL::This is an output iteration DEAL::Iteration : 9 Time : 15.3680 Time step : 2.00000 DEAL::Iteration : 10 Time : 17.3680 Time step : 2.00000 DEAL::Iteration : 11 Time : 19.3680 Time step : 2.00000 -DEAL::Iteration : 12 Time : 20.0000 Time step : 0.632000 +DEAL::Iteration : 12 Time : 21.3680 Time step : 2.00000 DEAL::************************************************* -DEAL::Adaptative time stepping - time output +DEAL::Adaptative time stepping - specific time output DEAL::************************************************* DEAL::Iteration : 0 Time : 0.00000 Time step : 1.00000 DEAL::Iteration : 1 Time : 1.00000 Time step : 1.00000 @@ -37,20 +63,39 @@ DEAL::Iteration : 2 Time : 2.20000 Time step : 1.20000 DEAL::Iteration : 3 Time : 3.64000 Time step : 1.44000 DEAL::Iteration : 4 Time : 5.36800 Time step : 1.72800 DEAL::Iteration : 5 Time : 7.36800 Time step : 2.00000 -DEAL::Iteration : 6 Time : 7.50000 Time step : 0.132000 DEAL::This is an output iteration -DEAL::Iteration : 7 Time : 9.50000 Time step : 2.00000 -DEAL::Iteration : 8 Time : 11.5000 Time step : 2.00000 -DEAL::Iteration : 9 Time : 13.5000 Time step : 2.00000 -DEAL::Iteration : 10 Time : 15.0000 Time step : 1.50000 +DEAL::Iteration : 6 Time : 9.36800 Time step : 2.00000 DEAL::This is an output iteration -DEAL::Iteration : 11 Time : 17.0000 Time step : 2.00000 -DEAL::Iteration : 12 Time : 19.0000 Time step : 2.00000 -DEAL::Iteration : 13 Time : 21.0000 Time step : 2.00000 -DEAL::Iteration : 14 Time : 22.5000 Time step : 1.50000 +DEAL::Iteration : 7 Time : 11.3680 Time step : 2.00000 +DEAL::Iteration : 8 Time : 13.3680 Time step : 2.00000 +DEAL::Iteration : 9 Time : 15.3680 Time step : 2.00000 +DEAL::Iteration : 10 Time : 17.3680 Time step : 2.00000 +DEAL::Iteration : 11 Time : 19.3680 Time step : 2.00000 +DEAL::Iteration : 12 Time : 21.3680 Time step : 2.00000 +DEAL::Iteration : 13 Time : 23.3680 Time step : 2.00000 +DEAL::Iteration : 14 Time : 25.3680 Time step : 2.00000 +DEAL::************************************************* +DEAL::Adaptative time stepping - interval time output +DEAL::************************************************* +DEAL::Iteration : 0 Time : 0.00000 Time step : 1.00000 +DEAL::Iteration : 1 Time : 1.00000 Time step : 1.00000 +DEAL::This is the first time step +DEAL::Iteration : 2 Time : 2.20000 Time step : 1.20000 +DEAL::Iteration : 3 Time : 3.64000 Time step : 1.44000 +DEAL::Iteration : 4 Time : 5.36800 Time step : 1.72800 +DEAL::Iteration : 5 Time : 7.36800 Time step : 2.00000 +DEAL::This is an output iteration +DEAL::Iteration : 6 Time : 9.36800 Time step : 2.00000 +DEAL::This is an output iteration +DEAL::Iteration : 7 Time : 11.3680 Time step : 2.00000 DEAL::This is an output iteration -DEAL::Iteration : 15 Time : 24.5000 Time step : 2.00000 -DEAL::Iteration : 16 Time : 26.5000 Time step : 2.00000 -DEAL::Iteration : 17 Time : 28.5000 Time step : 2.00000 -DEAL::Iteration : 18 Time : 30.0000 Time step : 1.50000 +DEAL::Iteration : 8 Time : 13.3680 Time step : 2.00000 +DEAL::This is an output iteration +DEAL::Iteration : 9 Time : 15.3680 Time step : 2.00000 DEAL::This is an output iteration +DEAL::Iteration : 10 Time : 17.3680 Time step : 2.00000 +DEAL::This is an output iteration +DEAL::Iteration : 11 Time : 19.3680 Time step : 2.00000 +DEAL::Iteration : 12 Time : 21.3680 Time step : 2.00000 +DEAL::Iteration : 13 Time : 23.3680 Time step : 2.00000 +DEAL::Iteration : 14 Time : 25.3680 Time step : 2.00000 diff --git a/tests/core/simulation_control_06.cc b/tests/core/simulation_control_06.cc deleted file mode 100644 index 3b8076568a..0000000000 --- a/tests/core/simulation_control_06.cc +++ /dev/null @@ -1,85 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2024 The Lethe Authors -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later - -/** - * @brief This test checks if files are only generated within the output time interval - */ - -// Lethe -#include -#include - -// Tests (with common definitions) -#include <../tests/tests.h> - -void -test() -{ - Parameters::SimulationControl simulationControlParameters; - - simulationControlParameters.dt = 0.01; - simulationControlParameters.adapt = false; - simulationControlParameters.maxCFL = 99; - simulationControlParameters.method = - Parameters::SimulationControl::TimeSteppingMethod::bdf1; - - simulationControlParameters.timeEnd = 999; - simulationControlParameters.number_mesh_adaptation = 9; - simulationControlParameters.output_name = "test"; - simulationControlParameters.subdivision = 7; - simulationControlParameters.output_folder = "canard"; - simulationControlParameters.output_frequency = 1; - simulationControlParameters.output_time_interval = {1, 2}; - - SimulationControlSteady simulation_control(simulationControlParameters); - - deallog << "Iteration : " << simulation_control.get_step_number() - << std::endl; - - while (simulation_control.integrate()) - { - deallog << "Iteration : " << simulation_control.get_step_number() - << " Time : " << simulation_control.get_current_time() - << std::endl; - if (simulation_control.is_at_start()) - deallog << "This is the first iteration" << std::endl; - - if (simulation_control.is_output_iteration()) - deallog << "This is an output iteration" << std::endl; - } -} - -int -main() -{ - try - { - initlog(); - test(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" - << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" - << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" - << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" - << std::endl; - return 1; - } -} diff --git a/tests/core/simulation_control_06.output b/tests/core/simulation_control_06.output deleted file mode 100644 index 5f65da23ce..0000000000 --- a/tests/core/simulation_control_06.output +++ /dev/null @@ -1,15 +0,0 @@ - -DEAL::Iteration : 0 -DEAL::Iteration : 1 Time : 1.00000 -DEAL::This is the first iteration -DEAL::This is an output iteration -DEAL::Iteration : 2 Time : 2.00000 -DEAL::This is an output iteration -DEAL::Iteration : 3 Time : 3.00000 -DEAL::Iteration : 4 Time : 4.00000 -DEAL::Iteration : 5 Time : 5.00000 -DEAL::Iteration : 6 Time : 6.00000 -DEAL::Iteration : 7 Time : 7.00000 -DEAL::Iteration : 8 Time : 8.00000 -DEAL::Iteration : 9 Time : 9.00000 -DEAL::Iteration : 10 Time : 10.0000 From c59cb998daf252caedb33a3a329e68826151d3de Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Wed, 30 Oct 2024 16:33:49 -0400 Subject: [PATCH 08/28] Update average velocities test --- tests/solvers/average_velocities_02.cc | 2 +- tests/solvers/average_velocities_02.output | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/solvers/average_velocities_02.cc b/tests/solvers/average_velocities_02.cc index fc33d2bbf6..78ad4b54b1 100644 --- a/tests/solvers/average_velocities_02.cc +++ b/tests/solvers/average_velocities_02.cc @@ -94,7 +94,7 @@ test() mpi_communicator); // Time loop - while (time < (time_end + epsilon)) // Until time reached end time + while (time < (time_end + dt)) // Until time reached end time { if (time > (initial_time - epsilon)) // Time reached the initial time { diff --git a/tests/solvers/average_velocities_02.output b/tests/solvers/average_velocities_02.output index e3151dcab0..2a3660818b 100644 --- a/tests/solvers/average_velocities_02.output +++ b/tests/solvers/average_velocities_02.output @@ -31,7 +31,7 @@ DEAL:: Time : 0.973316 DEAL:: Time step : 0.0540360 DEAL:: Average solution : 0.00000 0.972439 3.88976 59.9801 DEAL:: -DEAL:: Time : 1.00000 -DEAL:: Time step : 0.0266842 -DEAL:: Average solution : 0.00000 0.952921 3.81168 58.7762 -DEAL:: \ No newline at end of file +DEAL:: Time : 1.02465 +DEAL:: Time step : 0.0513342 +DEAL:: Average solution : 0.00000 0.936508 3.74603 57.7638 +DEAL:: From 9d4883d5ee27492debef7976ff253d4b5d2c25bb Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Wed, 30 Oct 2024 16:56:57 -0400 Subject: [PATCH 09/28] Update failing tests due to last time step --- ...ransfer_vof_lpbf_benchmark.mpirun=1.output | 20 ++++---- ...vof_lpbf_benchmark_box_ref.mpirun=1.output | 14 +++--- ...rtex-restart-bdf1-adaptive.mpirun=1.output | 16 +++---- .../vof-velocity-extrapolation.output | 48 +++++++++---------- 4 files changed, 49 insertions(+), 49 deletions(-) diff --git a/applications_tests/lethe-fluid/heat_transfer_vof_lpbf_benchmark.mpirun=1.output b/applications_tests/lethe-fluid/heat_transfer_vof_lpbf_benchmark.mpirun=1.output index de817fa3b9..f16b5b1458 100644 --- a/applications_tests/lethe-fluid/heat_transfer_vof_lpbf_benchmark.mpirun=1.output +++ b/applications_tests/lethe-fluid/heat_transfer_vof_lpbf_benchmark.mpirun=1.output @@ -60,9 +60,9 @@ VOF Mass Conservation time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold 6.412000e-06 1.068750e-01 1.906650e-10 1.502026e-11 5.614625e-14 2.531250e-01 1.118813e-06 4.700371e-11 3.317118e-12 5.000000e-01 -*********************************************************************************** -Transient iteration: 34 Time: 6.612e-06 Time step: 2e-07 CFL: 1.01703e-06 -*********************************************************************************** +********************************************************************************** +Transient iteration: 34 Time: 6.612e-06 Time step: 2e-07 CFL: 1.1299e-06 +********************************************************************************** Temperature statistics on fluid: Min: 298 Max: 1527.51 @@ -165,17 +165,17 @@ VOF Mass Conservation time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold 7.812000e-06 1.068750e-01 1.906650e-10 1.507758e-11 7.716538e-14 2.531250e-01 1.118813e-06 4.705784e-11 2.375080e-12 7.969647e-01 -********************************************************************************** -Transient iteration: 41 Time: 8e-06 Time step: 1.88e-07 CFL: 1.01425e-06 -********************************************************************************** +*********************************************************************************** +Transient iteration: 41 Time: 8.012e-06 Time step: 2e-07 CFL: 1.12828e-06 +*********************************************************************************** Temperature statistics on fluid: Min: 298 - Max: 1735.9 - Average: 310.557 - Std-Dev: 93.1306 + Max: 1737.64 + Average: 310.575 + Std-Dev: 93.2514 ---------------------- VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -8.000000e-06 1.068750e-01 1.906650e-10 1.506384e-11 7.595926e-14 2.531250e-01 1.118813e-06 4.696548e-11 1.409740e-12 7.969647e-01 +8.012000e-06 1.068750e-01 1.906650e-10 1.693655e-11 3.258717e-13 2.531250e-01 1.118813e-06 5.881073e-11 1.713271e-12 7.969647e-01 diff --git a/applications_tests/lethe-fluid/heat_transfer_vof_lpbf_benchmark_box_ref.mpirun=1.output b/applications_tests/lethe-fluid/heat_transfer_vof_lpbf_benchmark_box_ref.mpirun=1.output index 5ae11ca85f..2baff891aa 100644 --- a/applications_tests/lethe-fluid/heat_transfer_vof_lpbf_benchmark_box_ref.mpirun=1.output +++ b/applications_tests/lethe-fluid/heat_transfer_vof_lpbf_benchmark_box_ref.mpirun=1.output @@ -60,17 +60,17 @@ VOF Mass Conservation time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold 6.412000e-06 1.026562e-01 1.831387e-10 1.565452e-11 4.479244e-14 2.573438e-01 1.137459e-06 2.576702e-12 2.965199e-10 5.000000e-01 -********************************************************************************* -Transient iteration: 34 Time: 6.5e-06 Time step: 8.8e-08 CFL: 0.00271917 -********************************************************************************* +********************************************************************************** +Transient iteration: 34 Time: 6.612e-06 Time step: 2e-07 CFL: 0.00271918 +********************************************************************************** Temperature statistics on fluid: Min: 298 - Max: 2110.78 - Average: 306.603 - Std-Dev: 80.8732 + Max: 2125.57 + Average: 306.736 + Std-Dev: 81.7765 ---------------------- VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -6.500000e-06 1.026562e-01 1.831387e-10 1.570767e-11 7.192055e-14 2.573438e-01 1.137459e-06 4.142501e-12 2.074979e-10 5.000000e-01 +6.612000e-06 1.026562e-01 1.831387e-10 1.625213e-11 1.196876e-13 2.573438e-01 1.137459e-06 1.027986e-11 3.396211e-10 5.000000e-01 diff --git a/applications_tests/lethe-fluid/taylor-green-vortex-restart-bdf1-adaptive.mpirun=1.output b/applications_tests/lethe-fluid/taylor-green-vortex-restart-bdf1-adaptive.mpirun=1.output index 38db291f66..451d076e46 100644 --- a/applications_tests/lethe-fluid/taylor-green-vortex-restart-bdf1-adaptive.mpirun=1.output +++ b/applications_tests/lethe-fluid/taylor-green-vortex-restart-bdf1-adaptive.mpirun=1.output @@ -12,20 +12,20 @@ Running on 1 MPI rank(s)... ********************************************************************************* Transient iteration: 19 Time: 0.511589 Time step: 0.0555984 CFL: 0.0937518 ********************************************************************************* -Enstrophy : 0.0686874 -Kinetic energy : 0.0342889 +Enstrophy: 0.0686874 +Kinetic energy: 0.0342889 ********************************************************************************* Transient iteration: 20 Time: 0.572748 Time step: 0.0611582 CFL: 0.0927773 ********************************************************************************* -Enstrophy : 0.0544932 -Kinetic energy : 0.0272031 +Enstrophy: 0.0544932 +Kinetic energy: 0.0272031 ********************************************************************************* -Transient iteration: 21 Time: 0.6 Time step: 0.0272524 CFL: 0.0909005 +Transient iteration: 21 Time: 0.640022 Time step: 0.0672741 CFL: 0.0909005 ********************************************************************************* -Enstrophy : 0.0489892 -Kinetic energy : 0.0244555 +Enstrophy: 0.0423024 +Kinetic energy: 0.0211174 time error_velocity 0.0100 9.702604e-04 0.0210 1.497541e-03 @@ -47,4 +47,4 @@ Kinetic energy : 0.0244555 0.4560 4.412568e-02 0.5116 4.840382e-02 0.5727 5.242945e-02 -0.6000 5.140802e-02 +0.6400 5.603102e-02 diff --git a/applications_tests/lethe-fluid/vof-velocity-extrapolation.output b/applications_tests/lethe-fluid/vof-velocity-extrapolation.output index 83110f86f3..8d3311cd18 100644 --- a/applications_tests/lethe-fluid/vof-velocity-extrapolation.output +++ b/applications_tests/lethe-fluid/vof-velocity-extrapolation.output @@ -38,7 +38,7 @@ Transient iteration: 1 Time: 0.04 Time step: 0.04 CFL: 0 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -4.000000e-02 1.998729e-01 1.998729e-04 -3.153181e-14 1.465966e-08 2.000127e+00 2.000127e+00 -2.930045e-11 -1.733959e-05 5.000000e-01 +4.000000e-02 1.998729e-01 1.998729e-04 -3.160239e-14 1.465966e-08 2.000127e+00 2.000127e+00 -2.931234e-11 -1.733959e-05 5.000000e-01 ******************************************************************************** Transient iteration: 2 Time: 0.106 Time step: 0.066 CFL: 0.0369272 @@ -48,7 +48,7 @@ Transient iteration: 2 Time: 0.106 Time step: 0.066 CFL: 0.0369272 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -1.060000e-01 1.998956e-01 1.998956e-04 -2.425259e-13 3.812792e-08 2.000104e+00 2.000104e+00 -9.525105e-12 -4.094545e-05 5.000000e-01 +1.060000e-01 1.998956e-01 1.998956e-04 -2.432663e-13 3.812792e-08 2.000104e+00 2.000104e+00 -9.809253e-12 -4.094545e-05 5.000000e-01 ******************************************************************************* Transient iteration: 3 Time: 0.216 Time step: 0.11 CFL: 0.145606 @@ -58,7 +58,7 @@ Transient iteration: 3 Time: 0.216 Time step: 0.11 CFL: 0.145606 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -2.160000e-01 1.999246e-01 1.999246e-04 -1.060077e-13 6.931116e-08 2.000075e+00 2.000075e+00 -1.371969e-11 -7.210425e-05 5.000000e-01 +2.160000e-01 1.999246e-01 1.999246e-04 -1.097792e-13 6.931116e-08 2.000075e+00 2.000075e+00 -1.386806e-11 -7.210426e-05 5.000000e-01 ******************************************************************************* Transient iteration: 4 Time: 0.319419 Time step: 0.103419 CFL: 0.425454 @@ -68,7 +68,7 @@ Transient iteration: 4 Time: 0.319419 Time step: 0.103419 CFL: 0.425454 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -3.194190e-01 1.999461e-01 1.999461e-04 -1.825349e-13 8.720432e-08 2.000054e+00 2.000054e+00 -3.762998e-11 -9.007122e-05 5.000000e-01 +3.194190e-01 1.999461e-01 1.999461e-04 -1.827551e-13 8.720432e-08 2.000054e+00 2.000054e+00 -3.803980e-11 -9.007122e-05 5.000000e-01 ******************************************************************************** Transient iteration: 5 Time: 0.40004 Time step: 0.0806207 CFL: 0.513114 @@ -78,7 +78,7 @@ Transient iteration: 5 Time: 0.40004 Time step: 0.0806207 CFL: 0.513114 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -4.000397e-01 1.999615e-01 1.999615e-04 -1.149707e-13 9.162299e-08 2.000039e+00 2.000039e+00 -1.068808e-10 -9.414603e-05 5.000000e-01 +4.000397e-01 1.999615e-01 1.999615e-04 -9.479269e-14 9.162297e-08 2.000039e+00 2.000039e+00 -8.765327e-11 -9.414623e-05 5.000000e-01 ******************************************************************************** Transient iteration: 6 Time: 0.472086 Time step: 0.0720464 CFL: 0.447604 @@ -88,7 +88,7 @@ Transient iteration: 6 Time: 0.472086 Time step: 0.0720464 CFL: 0.447604 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -4.720862e-01 1.999731e-01 1.999731e-04 -2.296281e-13 9.008146e-08 2.000027e+00 2.000027e+00 -1.033014e-10 -9.237841e-05 5.000000e-01 +4.720862e-01 1.999731e-01 1.999731e-04 -2.116659e-13 9.008146e-08 2.000027e+00 2.000027e+00 -7.869427e-11 -9.237840e-05 5.000000e-01 ******************************************************************************** Transient iteration: 7 Time: 0.539958 Time step: 0.0678721 CFL: 0.424601 @@ -98,7 +98,7 @@ Transient iteration: 7 Time: 0.539958 Time step: 0.0678721 CFL: 0.424601 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -5.399583e-01 1.999826e-01 1.999826e-04 -2.696739e-13 8.506966e-08 2.000017e+00 2.000017e+00 -7.400908e-11 -8.744895e-05 5.000000e-01 +5.399583e-01 1.999826e-01 1.999826e-04 -2.509053e-13 8.506966e-08 2.000017e+00 2.000017e+00 -4.779690e-11 -8.744895e-05 5.000000e-01 ******************************************************************************** Transient iteration: 8 Time: 0.605071 Time step: 0.0651127 CFL: 0.416952 @@ -108,7 +108,7 @@ Transient iteration: 8 Time: 0.605071 Time step: 0.0651127 CFL: 0.416952 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -6.050710e-01 1.999920e-01 1.999920e-04 -3.099221e-13 7.709414e-08 2.000008e+00 2.000008e+00 -4.790105e-11 -7.958567e-05 5.000000e-01 +6.050710e-01 1.999920e-01 1.999920e-04 -2.905018e-13 7.709414e-08 2.000008e+00 2.000008e+00 -2.100524e-11 -7.958567e-05 5.000000e-01 ******************************************************************************** Transient iteration: 9 Time: 0.668539 Time step: 0.0634678 CFL: 0.410367 @@ -118,7 +118,7 @@ Transient iteration: 9 Time: 0.668539 Time step: 0.0634678 CFL: 0.410367 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -6.685388e-01 2.000016e-01 2.000016e-04 -3.323852e-13 6.596255e-08 1.999998e+00 1.999998e+00 -3.417262e-11 -6.848673e-05 5.000000e-01 +6.685388e-01 2.000016e-01 2.000016e-04 -3.130787e-13 6.596255e-08 1.999998e+00 1.999998e+00 -7.135564e-12 -6.848673e-05 5.000000e-01 ******************************************************************************** Transient iteration: 10 Time: 0.731211 Time step: 0.0626719 CFL: 0.40508 @@ -128,7 +128,7 @@ Transient iteration: 10 Time: 0.731211 Time step: 0.0626719 CFL: 0.40508 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -7.312107e-01 2.000112e-01 2.000112e-04 -2.942781e-13 5.156979e-08 1.999989e+00 1.999989e+00 3.810976e-11 -5.392560e-05 5.000000e-01 +7.312107e-01 2.000112e-01 2.000112e-04 -2.750099e-13 5.156979e-08 1.999989e+00 1.999989e+00 6.511611e-11 -5.392560e-05 5.000000e-01 ******************************************************************************** Transient iteration: 11 Time: 0.79412 Time step: 0.0629094 CFL: 0.39849 @@ -138,7 +138,7 @@ Transient iteration: 11 Time: 0.79412 Time step: 0.0629094 CFL: 0.39849 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -7.941201e-01 2.000204e-01 2.000204e-04 -2.765529e-13 3.423598e-08 1.999980e+00 1.999980e+00 1.658391e-11 -3.614546e-05 5.000000e-01 +7.941201e-01 2.000204e-01 2.000204e-04 -2.568808e-13 3.423597e-08 1.999980e+00 1.999980e+00 4.284320e-11 -3.614549e-05 5.000000e-01 ******************************************************************************** Transient iteration: 12 Time: 0.858447 Time step: 0.0643273 CFL: 0.391183 @@ -148,7 +148,7 @@ Transient iteration: 12 Time: 0.858447 Time step: 0.0643273 CFL: 0.391183 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -8.584473e-01 2.000282e-01 2.000282e-04 -3.502347e-13 1.534834e-08 1.999972e+00 1.999972e+00 -4.231857e-11 -1.712386e-05 5.000000e-01 +8.584473e-01 2.000282e-01 2.000282e-04 -3.299305e-13 1.534834e-08 1.999972e+00 1.999972e+00 -1.635443e-11 -1.712386e-05 5.000000e-01 ******************************************************************************** Transient iteration: 13 Time: 0.924811 Time step: 0.0663637 CFL: 0.387725 @@ -158,7 +158,7 @@ Transient iteration: 13 Time: 0.924811 Time step: 0.0663637 CFL: 0.387725 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -9.248111e-01 2.000363e-01 2.000363e-04 -3.269328e-13 -3.679444e-09 1.999964e+00 1.999964e+00 -3.260388e-11 1.734790e-06 5.000000e-01 +9.248111e-01 2.000363e-01 2.000363e-04 -3.060822e-13 -3.679444e-09 1.999964e+00 1.999964e+00 -6.483153e-12 1.734794e-06 5.000000e-01 ******************************************************************************** Transient iteration: 14 Time: 0.993555 Time step: 0.0687442 CFL: 0.386149 @@ -168,7 +168,7 @@ Transient iteration: 14 Time: 0.993555 Time step: 0.0687442 CFL: 0.386149 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -9.935553e-01 2.000454e-01 2.000454e-04 -3.382185e-13 -2.241224e-08 1.999955e+00 1.999955e+00 -4.730241e-12 2.033038e-05 5.000000e-01 +9.935553e-01 2.000454e-01 2.000454e-04 -3.181934e-13 -2.241224e-08 1.999955e+00 1.999955e+00 2.134781e-11 2.033038e-05 5.000000e-01 ******************************************************************************** Transient iteration: 15 Time: 1.06493 Time step: 0.0713699 CFL: 0.385284 @@ -178,7 +178,7 @@ Transient iteration: 15 Time: 1.06493 Time step: 0.0713699 CFL: 0.385284 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -1.064925e+00 2.000552e-01 2.000552e-04 -3.312178e-13 -3.932277e-08 1.999945e+00 1.999945e+00 7.517105e-11 3.743794e-05 5.000000e-01 +1.064925e+00 2.000552e-01 2.000552e-04 -3.110473e-13 -3.932277e-08 1.999945e+00 1.999945e+00 1.012938e-10 3.743795e-05 5.000000e-01 ******************************************************************************** Transient iteration: 16 Time: 1.14021 Time step: 0.0752821 CFL: 0.379213 @@ -188,7 +188,7 @@ Transient iteration: 16 Time: 1.14021 Time step: 0.0752821 CFL: 0.379213 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -1.140207e+00 2.000645e-01 2.000645e-04 -2.770356e-13 -5.301125e-08 1.999935e+00 1.999935e+00 1.314207e-10 5.120977e-05 5.000000e-01 +1.140207e+00 2.000645e-01 2.000645e-04 -2.573632e-13 -5.301125e-08 1.999935e+00 1.999935e+00 1.573958e-10 5.120977e-05 5.000000e-01 ******************************************************************************** Transient iteration: 17 Time: 1.22222 Time step: 0.0820177 CFL: 0.367151 @@ -198,7 +198,7 @@ Transient iteration: 17 Time: 1.22222 Time step: 0.0820177 CFL: 0.367151 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -1.222225e+00 2.000741e-01 2.000741e-04 -2.753697e-13 -6.255171e-08 1.999926e+00 1.999926e+00 2.346029e-10 6.068088e-05 5.000000e-01 +1.222225e+00 2.000741e-01 2.000741e-04 -2.561767e-13 -6.255171e-08 1.999926e+00 1.999926e+00 2.608132e-10 6.068088e-05 5.000000e-01 ******************************************************************************** Transient iteration: 18 Time: 1.31244 Time step: 0.0902194 CFL: 0.351978 @@ -208,7 +208,7 @@ Transient iteration: 18 Time: 1.31244 Time step: 0.0902194 CFL: 0.351978 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -1.312444e+00 2.000851e-01 2.000851e-04 -2.571538e-13 -6.701049e-08 1.999915e+00 1.999915e+00 2.741899e-10 6.500909e-05 5.000000e-01 +1.312444e+00 2.000851e-01 2.000851e-04 -2.376066e-13 -6.701049e-08 1.999915e+00 1.999915e+00 3.001884e-10 6.500908e-05 5.000000e-01 ******************************************************************************** Transient iteration: 19 Time: 1.41169 Time step: 0.0992414 CFL: 0.329891 @@ -218,7 +218,7 @@ Transient iteration: 19 Time: 1.41169 Time step: 0.0992414 CFL: 0.329891 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -1.411686e+00 2.000975e-01 2.000975e-04 -2.171524e-13 -6.580788e-08 1.999902e+00 1.999902e+00 3.026559e-10 6.366724e-05 5.000000e-01 +1.411686e+00 2.000975e-01 2.000975e-04 -1.986559e-13 -6.580788e-08 1.999902e+00 1.999902e+00 3.284613e-10 6.366724e-05 5.000000e-01 ******************************************************************************* Transient iteration: 20 Time: 1.52085 Time step: 0.109165 CFL: 0.309595 @@ -228,14 +228,14 @@ Transient iteration: 20 Time: 1.52085 Time step: 0.109165 CFL: 0.309595 VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -1.520851e+00 2.001114e-01 2.001114e-04 -1.106529e-13 -5.713112e-08 1.999889e+00 1.999889e+00 3.371699e-10 5.499842e-05 5.000000e-01 +1.520851e+00 2.001114e-01 2.001114e-04 -9.176963e-14 -5.713112e-08 1.999889e+00 1.999889e+00 3.629224e-10 5.499841e-05 5.000000e-01 -******************************************************************************** -Transient iteration: 21 Time: 1.6 Time step: 0.0791487 CFL: 0.262858 -******************************************************************************** +******************************************************************************* +Transient iteration: 21 Time: 1.64093 Time step: 0.120082 CFL: 0.262858 +******************************************************************************* ---------------------- VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -1.600000e+00 2.001208e-01 2.001208e-04 -2.458844e-13 -4.547878e-08 1.999879e+00 1.999879e+00 3.820259e-10 4.329590e-05 5.000000e-01 +1.640933e+00 2.001256e-01 2.001256e-04 2.384551e-15 -3.763005e-08 1.999874e+00 1.999874e+00 4.077472e-10 3.542519e-05 5.000000e-01 From b5763780af2fcb837f9c532e944320c4636cdba7 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Thu, 31 Oct 2024 11:50:43 -0400 Subject: [PATCH 10/28] Add output time frequency --- include/core/parameters.h | 11 ++-- include/core/simulation_control.h | 9 +++- source/core/parameters.cc | 15 ++++-- source/core/simulation_control.cc | 83 ++++++++++++++++++++++--------- 4 files changed, 85 insertions(+), 33 deletions(-) diff --git a/include/core/parameters.h b/include/core/parameters.h index e75eafce0d..0df3f71a13 100644 --- a/include/core/parameters.h +++ b/include/core/parameters.h @@ -139,13 +139,16 @@ namespace Parameters multiple_step_bdf, } bdf_startup_method; - // Frequency of the output (for both time and iteration output) - unsigned int output_frequency; + // Frequency of the output (for iteration output control) + unsigned int output_iteration_frequency; + + // Time frequency of the output (for time output control) + double output_time_frequency; - // Output at a specific time + // Output at a specific time (for time output control) double output_time; - // Time window for file output + // Time window for file output (for both iteration and time output control) std::vector output_time_interval; // Enable output of the boundaries diff --git a/include/core/simulation_control.h b/include/core/simulation_control.h index 4245cc60c8..67c1680f88 100644 --- a/include/core/simulation_control.h +++ b/include/core/simulation_control.h @@ -81,7 +81,7 @@ class SimulationControl // Output iteration frequency // Controls the output of the simulation results when the output is controlled // by the iteration number. - unsigned int output_frequency; + unsigned int output_iteration_frequency; // Output time frequency // Controls the output of the simulation results when the output is controlled @@ -251,7 +251,7 @@ class SimulationControl bool output_enabled() const { - return output_frequency != 0; + return output_iteration_frequency != 0; } /** @@ -503,6 +503,11 @@ class SimulationControlTransient : public SimulationControl // Max time step double max_dt; + // Time last output + double time_last_output; + + double output_time_frequency; + // Output control type: iteration or type Parameters::SimulationControl::OutputControl output_control; diff --git a/source/core/parameters.cc b/source/core/parameters.cc index cd5c60f333..2cc5dbcd28 100644 --- a/source/core/parameters.cc +++ b/source/core/parameters.cc @@ -141,10 +141,16 @@ namespace Parameters Patterns::FileName(), "File output prefix"); - prm.declare_entry("output frequency", + + prm.declare_entry("output iteration frequency", "1", Patterns::Integer(), - "Output frequency"); + "Output iteration frequency"); + + prm.declare_entry("output time frequency", + "-1", + Patterns::Double(), + "Output time frequency"); prm.declare_entry( "output boundaries", @@ -252,8 +258,9 @@ namespace Parameters output_name.end(), '/'), output_name.end()); - output_frequency = prm.get_integer("output frequency"); - output_time = prm.get_double("output time"); + output_iteration_frequency = prm.get_integer("output frequency"); + output_time_frequency = prm.get_double("output time frequency"); + output_time = prm.get_double("output time"); output_time_interval = convert_string_to_vector(prm, "output time interval"); output_boundaries = prm.get_bool("output boundaries"); diff --git a/source/core/simulation_control.cc b/source/core/simulation_control.cc index f6fe5c3d47..d9e3bec531 100644 --- a/source/core/simulation_control.cc +++ b/source/core/simulation_control.cc @@ -23,7 +23,7 @@ SimulationControl::SimulationControl(const Parameters::SimulationControl ¶m) , max_CFL(param.maxCFL) , residual(DBL_MAX) , stop_tolerance(param.stop_tolerance) - , output_frequency(param.output_frequency) + , output_iteration_frequency(param.output_iteration_frequency) , output_time(param.output_time) , output_time_interval(param.output_time_interval) , log_frequency(param.log_frequency) @@ -62,12 +62,12 @@ SimulationControl::add_time_step(double p_timestep) bool SimulationControl::is_output_iteration() { - if (output_frequency == 0) + if (output_iteration_frequency == 0) return false; else { // Check if the current step number matches the output frequency - return (get_step_number() % output_frequency == 0); + return (get_step_number() % output_iteration_frequency == 0); } } @@ -217,6 +217,7 @@ SimulationControlTransient::SimulationControlTransient( , adapt(param.adapt) , adaptative_time_step_scaling(param.adaptative_time_step_scaling) , max_dt(param.max_dt) + , output_time_frequency(param.output_time_frequency) , output_control(param.output_control) {} @@ -299,48 +300,84 @@ SimulationControlTransient::calculate_time_step() bool SimulationControlTransient::is_output_iteration() { - // If iteration control + // If iteration control the only options are to not print or at certain + // frequency of iterations if (output_control == Parameters::SimulationControl::OutputControl::iteration) { - if (output_frequency == 0) + if (output_iteration_frequency == 0) return false; else { // Check if the current step number matches the output frequency - return (get_step_number() % output_frequency == 0); + return (get_step_number() % output_iteration_frequency == 0 && + get_current_time() >= output_time_interval[0] && + get_current_time() <= output_time_interval[1]); } } - // If time control + // If time control there are several options: bool is_output_time = false; double upper_bound, lower_bound; - // If a specific time is given + // 1. A specific output time is given if (output_time != -1) { upper_bound = output_time; lower_bound = output_time; } - else // If an interval is specified + else if (output_time_frequency != + -1) // 2. A specific time frequency is given. This works with a + // specific time interval or none. + { + double epsilon = 1e-12; + + if ((current_time - time_last_output) - output_time_frequency > + -epsilon * output_time_frequency && + current_time >= output_time_interval[0] && + current_time <= output_time_interval[1]) + { + upper_bound = current_time; + lower_bound = current_time; + + time_last_output = current_time; + } + else + return false; + } + else // 3. If only a specific time interval is specified { upper_bound = output_time_interval[1]; lower_bound = output_time_interval[0]; } - // Case 1. If it is within the interval, write only according to output - // frequency - is_output_time = - (current_time >= lower_bound && current_time <= upper_bound && - get_step_number() % output_frequency == 0); - - // Case 2. Always write one time step before the interval - double next_time = current_time + calculate_time_step(); - if (current_time < lower_bound && (next_time >= lower_bound)) - is_output_time = true; - - // Case 3. Always write one time step after the interval - if (current_time >= upper_bound && (previous_time < upper_bound)) - is_output_time = true; + // If we are in case 1 and 3: + if (output_time_frequency == -1) + { + // We output in the current time. + is_output_time = + (current_time >= lower_bound && current_time <= upper_bound); + + // We always write one step before, in case the specific time or the + // interval lower bound does not correspond exactly to a time iteration + // performed (due to restrictions in time step) + double next_time = current_time + calculate_time_step(); + if (current_time < lower_bound && (next_time >= lower_bound)) + is_output_time = true; + + // We always write one step after, in case the specific time or the + // interval upper bound does not correspond exactly to a time iteration + // performed (due to restrictions in time step) + if (current_time >= upper_bound && (previous_time < upper_bound)) + is_output_time = true; + } + else + { + // We are in case 2. This case only considers the actual time step that + // fulfills the condition with the frequency. + is_output_time = + (current_time >= lower_bound && current_time <= upper_bound && + time_last_output == current_time); + } return is_output_time; } From 7f4c44d83c67a582d0119618b35149f5a4190eb3 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Thu, 31 Oct 2024 12:50:06 -0400 Subject: [PATCH 11/28] Add output time frequency to tests --- source/core/simulation_control.cc | 74 +++++++-------- tests/core/simulation_control_01.cc | 12 +-- tests/core/simulation_control_02.cc | 14 +-- tests/core/simulation_control_03.cc | 114 ++++++++++++++++++++---- tests/core/simulation_control_03.output | 39 ++++++++ tests/core/simulation_control_04.cc | 12 +-- tests/core/simulation_control_05.cc | 12 +-- 7 files changed, 194 insertions(+), 83 deletions(-) diff --git a/source/core/simulation_control.cc b/source/core/simulation_control.cc index d9e3bec531..964d3efd38 100644 --- a/source/core/simulation_control.cc +++ b/source/core/simulation_control.cc @@ -319,20 +319,12 @@ SimulationControlTransient::is_output_iteration() bool is_output_time = false; double upper_bound, lower_bound; - // 1. A specific output time is given - if (output_time != -1) + // Case 1. A specific output time frequency is given (with or without a + // specific time interval): + if (output_time_frequency != -1) { - upper_bound = output_time; - lower_bound = output_time; - } - else if (output_time_frequency != - -1) // 2. A specific time frequency is given. This works with a - // specific time interval or none. - { - double epsilon = 1e-12; - if ((current_time - time_last_output) - output_time_frequency > - -epsilon * output_time_frequency && + -1e-12 * output_time_frequency && current_time >= output_time_interval[0] && current_time <= output_time_interval[1]) { @@ -340,44 +332,44 @@ SimulationControlTransient::is_output_iteration() lower_bound = current_time; time_last_output = current_time; + + is_output_time = + (current_time >= lower_bound && current_time <= upper_bound); + + return is_output_time; } else return false; } - else // 3. If only a specific time interval is specified + else if (output_time != -1) // Case 2. If a specific time is given. + { + upper_bound = output_time; + lower_bound = output_time; + } + else // Case 3. Only a specific time interval is specified { upper_bound = output_time_interval[1]; lower_bound = output_time_interval[0]; } - // If we are in case 1 and 3: - if (output_time_frequency == -1) - { - // We output in the current time. - is_output_time = - (current_time >= lower_bound && current_time <= upper_bound); - - // We always write one step before, in case the specific time or the - // interval lower bound does not correspond exactly to a time iteration - // performed (due to restrictions in time step) - double next_time = current_time + calculate_time_step(); - if (current_time < lower_bound && (next_time >= lower_bound)) - is_output_time = true; - - // We always write one step after, in case the specific time or the - // interval upper bound does not correspond exactly to a time iteration - // performed (due to restrictions in time step) - if (current_time >= upper_bound && (previous_time < upper_bound)) - is_output_time = true; - } - else - { - // We are in case 2. This case only considers the actual time step that - // fulfills the condition with the frequency. - is_output_time = - (current_time >= lower_bound && current_time <= upper_bound && - time_last_output == current_time); - } + + // For cases 2 and 3: + + // We output in the current time. + is_output_time = (current_time >= lower_bound && current_time <= upper_bound); + + // We always write one step before, in case the specific time or the + // interval lower bound does not correspond exactly to a time iteration + // performed (due to time step) + double next_time = current_time + calculate_time_step(); + if (current_time < lower_bound && (next_time >= lower_bound)) + is_output_time = true; + + // We always write one step after, in case the specific time or the + // interval upper bound does not correspond exactly to a time iteration + // performed (due to in time step) + if (current_time >= upper_bound && (previous_time < upper_bound)) + is_output_time = true; return is_output_time; } diff --git a/tests/core/simulation_control_01.cc b/tests/core/simulation_control_01.cc index bc9d5941bd..f634fef3a6 100644 --- a/tests/core/simulation_control_01.cc +++ b/tests/core/simulation_control_01.cc @@ -22,12 +22,12 @@ test() simulationControlParameters.maxCFL = 99; simulationControlParameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulationControlParameters.timeEnd = 999; - simulationControlParameters.number_mesh_adaptation = 9; - simulationControlParameters.output_name = "test"; - simulationControlParameters.subdivision = 7; - simulationControlParameters.output_folder = "canard"; - simulationControlParameters.output_frequency = 8; + simulationControlParameters.timeEnd = 999; + simulationControlParameters.number_mesh_adaptation = 9; + simulationControlParameters.output_name = "test"; + simulationControlParameters.subdivision = 7; + simulationControlParameters.output_folder = "canard"; + simulationControlParameters.output_iteration_frequency = 8; SimulationControlTransient simulationControl(simulationControlParameters); diff --git a/tests/core/simulation_control_02.cc b/tests/core/simulation_control_02.cc index ec4e5afaa1..fadf2c87ce 100644 --- a/tests/core/simulation_control_02.cc +++ b/tests/core/simulation_control_02.cc @@ -24,13 +24,13 @@ test() simulationControlParameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulationControlParameters.timeEnd = 999; - simulationControlParameters.number_mesh_adaptation = 9; - simulationControlParameters.output_name = "test"; - simulationControlParameters.subdivision = 7; - simulationControlParameters.output_folder = "canard"; - simulationControlParameters.output_frequency = 8; - simulationControlParameters.output_time_interval = {0, 1000000000}; + simulationControlParameters.timeEnd = 999; + simulationControlParameters.number_mesh_adaptation = 9; + simulationControlParameters.output_name = "test"; + simulationControlParameters.subdivision = 7; + simulationControlParameters.output_folder = "canard"; + simulationControlParameters.output_iteration_frequency = 8; + simulationControlParameters.output_time_interval = {0, 1000000000}; SimulationControlSteady simulation_control(simulationControlParameters); diff --git a/tests/core/simulation_control_03.cc b/tests/core/simulation_control_03.cc index f233cfdb0a..af69f02109 100644 --- a/tests/core/simulation_control_03.cc +++ b/tests/core/simulation_control_03.cc @@ -23,10 +23,10 @@ test() simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; simulation_control_parameters.timeEnd = 0.5; - simulation_control_parameters.number_mesh_adaptation = 9; - simulation_control_parameters.subdivision = 7; - simulation_control_parameters.output_frequency = 8; + simulation_control_parameters.output_iteration_frequency = 2; simulation_control_parameters.time_step_independent_of_end_time = true; + simulation_control_parameters.output_time_interval = {0, + 1.7976931348623157e3}; { SimulationControlTransient simulation_control( @@ -55,10 +55,12 @@ test() } { - simulation_control_parameters.output_time = 0.3; simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_frequency = 1; + simulation_control_parameters.output_time = 0.3; + simulation_control_parameters.output_time_frequency = -1; + simulation_control_parameters.output_time_interval = {0, + 1.7976931348623157e3}; SimulationControlTransient simulation_control( simulation_control_parameters); @@ -86,11 +88,11 @@ test() } { - simulation_control_parameters.output_time = -1; - simulation_control_parameters.output_time_interval = {0.2, 0.4}; simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_frequency = 1; + simulation_control_parameters.output_time = -1; + simulation_control_parameters.output_time_frequency = -1; + simulation_control_parameters.output_time_interval = {0.2, 0.4}; SimulationControlTransient simulation_control( simulation_control_parameters); @@ -117,6 +119,39 @@ test() } } + { + simulation_control_parameters.output_control = + Parameters::SimulationControl::OutputControl::time; + simulation_control_parameters.output_time = -1; + simulation_control_parameters.output_time_frequency = 0.2; + simulation_control_parameters.output_time_interval = {0, + 1.7976931348623157e3}; + + SimulationControlTransient simulation_control( + simulation_control_parameters); + + // Constant time-stepping - time interval output + deallog << "*************************************************" << std::endl; + deallog << "Constant time stepping - output time frequency" << std::endl; + deallog << "*************************************************" << std::endl; + deallog << "Iteration : " << simulation_control.get_step_number() + << " Time : " << simulation_control.get_current_time() + << std::endl; + + while (simulation_control.integrate()) + { + deallog << "Iteration : " << simulation_control.get_step_number() + << " Time : " << simulation_control.get_current_time() + << std::endl; + + if (simulation_control.is_at_start()) + deallog << "This is the first time step" << std::endl; + + if (simulation_control.is_output_iteration()) + deallog << "This is an output iteration" << std::endl; + } + } + { simulation_control_parameters.adapt = true; simulation_control_parameters.timeEnd = 20; @@ -126,7 +161,9 @@ test() simulation_control_parameters.max_dt = 1e6; simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::iteration; - simulation_control_parameters.output_frequency = 8; + simulation_control_parameters.output_iteration_frequency = 8; + simulation_control_parameters.output_time_interval = {0, + 1.7976931348623157e3}; SimulationControlTransient simulation_control( simulation_control_parameters); @@ -162,11 +199,12 @@ test() simulation_control_parameters.dt = 1; simulation_control_parameters.adaptative_time_step_scaling = 1.2; simulation_control_parameters.maxCFL = 2; - simulation_control_parameters.output_time = 7.5; simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.max_dt = 1e6; - simulation_control_parameters.output_frequency = 1; + simulation_control_parameters.output_time = 7.5; + simulation_control_parameters.output_time_frequency = -1; + simulation_control_parameters.output_time_interval = {0, + 1.7976931348623157e3}; SimulationControlTransient simulation_control( simulation_control_parameters); @@ -203,13 +241,12 @@ test() simulation_control_parameters.dt = 1; simulation_control_parameters.adaptative_time_step_scaling = 1.2; simulation_control_parameters.maxCFL = 2; - simulation_control_parameters.output_time = -1; - simulation_control_parameters.output_time_interval = {7.5, 17}; + simulation_control_parameters.max_dt = 1e6; simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.max_dt = 1e6; - simulation_control_parameters.output_frequency = 1; - + simulation_control_parameters.output_time = -1; + simulation_control_parameters.output_time_frequency = -1; + simulation_control_parameters.output_time_interval = {7.5, 17}; SimulationControlTransient simulation_control( simulation_control_parameters); @@ -239,6 +276,49 @@ test() simulation_control.set_CFL(simulation_control.get_time_step()); } } + + { + simulation_control_parameters.adapt = true; + simulation_control_parameters.timeEnd = 25; + simulation_control_parameters.dt = 1; + simulation_control_parameters.adaptative_time_step_scaling = 1.2; + simulation_control_parameters.maxCFL = 2; + simulation_control_parameters.max_dt = 1e6; + simulation_control_parameters.output_control = + Parameters::SimulationControl::OutputControl::time; + simulation_control_parameters.output_time = -1; + simulation_control_parameters.output_time_frequency = 4; + simulation_control_parameters.output_time_interval = {0, + 1.7976931348623157e3}; + + SimulationControlTransient simulation_control( + simulation_control_parameters); + + // Adaptative time-stepping - output time frequency + deallog << "*************************************************" << std::endl; + deallog << "Adaptative time stepping - output time frequency" << std::endl; + deallog << "*************************************************" << std::endl; + deallog << "Iteration : " << simulation_control.get_step_number() + << " Time : " << simulation_control.get_current_time() + << " Time step : " << simulation_control.get_time_step() + << std::endl; + + while (simulation_control.integrate()) + { + deallog << "Iteration : " << simulation_control.get_step_number() + << " Time : " << simulation_control.get_current_time() + << " Time step : " << simulation_control.get_time_step() + << std::endl; + + if (simulation_control.is_at_start()) + deallog << "This is the first time step" << std::endl; + + if (simulation_control.is_output_iteration()) + deallog << "This is an output iteration" << std::endl; + + simulation_control.set_CFL(simulation_control.get_time_step()); + } + } } int diff --git a/tests/core/simulation_control_03.output b/tests/core/simulation_control_03.output index f7bd53ffc4..068f2d4afa 100644 --- a/tests/core/simulation_control_03.output +++ b/tests/core/simulation_control_03.output @@ -6,8 +6,10 @@ DEAL::Iteration : 0 Time : 0.00000 DEAL::Iteration : 1 Time : 0.100000 DEAL::This is the first time step DEAL::Iteration : 2 Time : 0.200000 +DEAL::This is an output iteration DEAL::Iteration : 3 Time : 0.300000 DEAL::Iteration : 4 Time : 0.400000 +DEAL::This is an output iteration DEAL::Iteration : 5 Time : 0.500000 DEAL::************************************************* DEAL::Constant time stepping - specific time output @@ -36,6 +38,18 @@ DEAL::Iteration : 4 Time : 0.400000 DEAL::This is an output iteration DEAL::Iteration : 5 Time : 0.500000 DEAL::************************************************* +DEAL::Constant time stepping - output time frequency +DEAL::************************************************* +DEAL::Iteration : 0 Time : 0.00000 +DEAL::Iteration : 1 Time : 0.100000 +DEAL::This is the first time step +DEAL::Iteration : 2 Time : 0.200000 +DEAL::This is an output iteration +DEAL::Iteration : 3 Time : 0.300000 +DEAL::Iteration : 4 Time : 0.400000 +DEAL::This is an output iteration +DEAL::Iteration : 5 Time : 0.500000 +DEAL::************************************************* DEAL::Adaptative time stepping - constant output DEAL::************************************************* DEAL::Iteration : 0 Time : 0.00000 Time step : 1.00000 @@ -99,3 +113,28 @@ DEAL::Iteration : 11 Time : 19.3680 Time step : 2.00000 DEAL::Iteration : 12 Time : 21.3680 Time step : 2.00000 DEAL::Iteration : 13 Time : 23.3680 Time step : 2.00000 DEAL::Iteration : 14 Time : 25.3680 Time step : 2.00000 +DEAL::************************************************* +DEAL::Adaptative time stepping - output time frequency +DEAL::************************************************* +DEAL::Iteration : 0 Time : 0.00000 Time step : 1.00000 +DEAL::Iteration : 1 Time : 1.00000 Time step : 1.00000 +DEAL::This is the first time step +DEAL::Iteration : 2 Time : 2.20000 Time step : 1.20000 +DEAL::Iteration : 3 Time : 3.64000 Time step : 1.44000 +DEAL::Iteration : 4 Time : 5.36800 Time step : 1.72800 +DEAL::This is an output iteration +DEAL::Iteration : 5 Time : 7.36800 Time step : 2.00000 +DEAL::Iteration : 6 Time : 9.36800 Time step : 2.00000 +DEAL::This is an output iteration +DEAL::Iteration : 7 Time : 11.3680 Time step : 2.00000 +DEAL::Iteration : 8 Time : 13.3680 Time step : 2.00000 +DEAL::This is an output iteration +DEAL::Iteration : 9 Time : 15.3680 Time step : 2.00000 +DEAL::Iteration : 10 Time : 17.3680 Time step : 2.00000 +DEAL::This is an output iteration +DEAL::Iteration : 11 Time : 19.3680 Time step : 2.00000 +DEAL::Iteration : 12 Time : 21.3680 Time step : 2.00000 +DEAL::This is an output iteration +DEAL::Iteration : 13 Time : 23.3680 Time step : 2.00000 +DEAL::Iteration : 14 Time : 25.3680 Time step : 2.00000 +DEAL::This is an output iteration diff --git a/tests/core/simulation_control_04.cc b/tests/core/simulation_control_04.cc index a23d0217c5..0083c36ca3 100644 --- a/tests/core/simulation_control_04.cc +++ b/tests/core/simulation_control_04.cc @@ -25,12 +25,12 @@ test() Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulation_control_parameters.timeEnd = 20; - simulation_control_parameters.number_mesh_adaptation = 0; - simulation_control_parameters.output_name = "test"; - simulation_control_parameters.subdivision = 7; - simulation_control_parameters.output_folder = "canard"; - simulation_control_parameters.output_frequency = 8; + simulation_control_parameters.timeEnd = 20; + simulation_control_parameters.number_mesh_adaptation = 0; + simulation_control_parameters.output_name = "test"; + simulation_control_parameters.subdivision = 7; + simulation_control_parameters.output_folder = "canard"; + simulation_control_parameters.output_iteration_frequency = 8; { SimulationControlTransient simulation_control( diff --git a/tests/core/simulation_control_05.cc b/tests/core/simulation_control_05.cc index 0d67958af6..79b98190bb 100644 --- a/tests/core/simulation_control_05.cc +++ b/tests/core/simulation_control_05.cc @@ -23,12 +23,12 @@ test() simulation_control_parameters.startup_timestep_scaling = 0.4; simulation_control_parameters.bdf_startup_method = Parameters::SimulationControl::BDFStartupMethods::multiple_step_bdf; - simulation_control_parameters.timeEnd = 4; - simulation_control_parameters.number_mesh_adaptation = 0; - simulation_control_parameters.output_name = "test"; - simulation_control_parameters.subdivision = 7; - simulation_control_parameters.output_folder = "canard"; - simulation_control_parameters.output_frequency = 8; + simulation_control_parameters.timeEnd = 4; + simulation_control_parameters.number_mesh_adaptation = 0; + simulation_control_parameters.output_name = "test"; + simulation_control_parameters.subdivision = 7; + simulation_control_parameters.output_folder = "canard"; + simulation_control_parameters.output_iteration_frequency = 8; { simulation_control_parameters.method = From 7a42c4601a2d1604f80ea0041a8931d4becd2f9a Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Thu, 31 Oct 2024 13:44:58 -0400 Subject: [PATCH 12/28] Fix typo and add default interval to test --- source/core/parameters.cc | 2 +- tests/core/specific_heat_phase_change_01.cc | 14 +++++++------- tests/solvers/average_velocities_02.cc | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/source/core/parameters.cc b/source/core/parameters.cc index 2cc5dbcd28..9b15c70e36 100644 --- a/source/core/parameters.cc +++ b/source/core/parameters.cc @@ -142,7 +142,7 @@ namespace Parameters "File output prefix"); - prm.declare_entry("output iteration frequency", + prm.declare_entry("output frequency", "1", Patterns::Integer(), "Output iteration frequency"); diff --git a/tests/core/specific_heat_phase_change_01.cc b/tests/core/specific_heat_phase_change_01.cc index 32cb101019..eb64ad2669 100644 --- a/tests/core/specific_heat_phase_change_01.cc +++ b/tests/core/specific_heat_phase_change_01.cc @@ -44,13 +44,13 @@ test() simulationControlParameters.maxCFL = 99; simulationControlParameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulationControlParameters.timeEnd = 999; - simulationControlParameters.number_mesh_adaptation = 9; - simulationControlParameters.output_name = "test"; - simulationControlParameters.subdivision = 7; - simulationControlParameters.output_folder = "canard"; - simulationControlParameters.output_frequency = 8; - + simulationControlParameters.timeEnd = 999; + simulationControlParameters.number_mesh_adaptation = 9; + simulationControlParameters.output_name = "test"; + simulationControlParameters.subdivision = 7; + simulationControlParameters.output_folder = "canard"; + simulationControlParameters.output_iteration_frequency = 8; + simulationControlParameters.output_time_interval = {0, 1.7976931348623157e3}; std::shared_ptr simulation_control; simulation_control = diff --git a/tests/solvers/average_velocities_02.cc b/tests/solvers/average_velocities_02.cc index 78ad4b54b1..6ea33aa495 100644 --- a/tests/solvers/average_velocities_02.cc +++ b/tests/solvers/average_velocities_02.cc @@ -40,10 +40,12 @@ test() Parameters::SimulationControl::TimeSteppingMethod::bdf1; simulation_control_parameters.dt = 0.1; simulation_control_parameters.timeEnd = 1.0; - simulation_control_parameters.output_frequency = 1; + simulation_control_parameters.output_iteration_frequency = 1; simulation_control_parameters.adapt = true; simulation_control_parameters.adaptative_time_step_scaling = 0.95; simulation_control_parameters.max_dt = 1e6; + simulation_control_parameters.output_time_interval = {0, + 1.7976931348623157e3}; Parameters::PostProcessing postprocessing_parameters; postprocessing_parameters.calculate_average_velocities = true; From 7253622ac8dd4b4cdff59375e8b41b524438b0fc Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Thu, 31 Oct 2024 14:42:04 -0400 Subject: [PATCH 13/28] Minor simplifications --- source/core/simulation_control.cc | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/source/core/simulation_control.cc b/source/core/simulation_control.cc index 964d3efd38..19e23b63fd 100644 --- a/source/core/simulation_control.cc +++ b/source/core/simulation_control.cc @@ -316,8 +316,6 @@ SimulationControlTransient::is_output_iteration() } // If time control there are several options: - bool is_output_time = false; - double upper_bound, lower_bound; // Case 1. A specific output time frequency is given (with or without a // specific time interval): @@ -328,20 +326,19 @@ SimulationControlTransient::is_output_iteration() current_time >= output_time_interval[0] && current_time <= output_time_interval[1]) { - upper_bound = current_time; - lower_bound = current_time; - time_last_output = current_time; - is_output_time = - (current_time >= lower_bound && current_time <= upper_bound); - - return is_output_time; + return true; } else return false; } - else if (output_time != -1) // Case 2. If a specific time is given. + + // For cases 2 and 3: + bool is_output_time = false; + double upper_bound, lower_bound; + + if (output_time != -1) // Case 2. If a specific time is given. { upper_bound = output_time; lower_bound = output_time; @@ -352,9 +349,6 @@ SimulationControlTransient::is_output_iteration() lower_bound = output_time_interval[0]; } - - // For cases 2 and 3: - // We output in the current time. is_output_time = (current_time >= lower_bound && current_time <= upper_bound); From a29a66cd838afaaf68cd18f1383be3b93a06ca14 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Thu, 31 Oct 2024 16:47:58 -0400 Subject: [PATCH 14/28] Move time parameters to transient simulation control --- include/core/simulation_control.h | 19 ++++++++----------- source/core/simulation_control.cc | 4 ++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/include/core/simulation_control.h b/include/core/simulation_control.h index 67c1680f88..df8c0a150d 100644 --- a/include/core/simulation_control.h +++ b/include/core/simulation_control.h @@ -83,17 +83,6 @@ class SimulationControl // by the iteration number. unsigned int output_iteration_frequency; - // Output time frequency - // Controls the output of the simulation results when the output is controlled - // by the time - double output_time; - - // Adds a condition to the generation of .vtu and .pvd files in addition to - // the output generation frequency. If specified in the parameter file, only - // the results within the specified simulation time interval will be - // generated. - std::vector output_time_interval; - // Log iteration frequency // Controls the frequency at which status of the simulation is written to // the terminal @@ -506,8 +495,16 @@ class SimulationControlTransient : public SimulationControl // Time last output double time_last_output; + // Specific output frequency for time output control double output_time_frequency; + // Specific output time for time output control + double output_time; + + // Time interval for output of transient iterations either with time output + // control or iterations control + std::vector output_time_interval; + // Output control type: iteration or type Parameters::SimulationControl::OutputControl output_control; diff --git a/source/core/simulation_control.cc b/source/core/simulation_control.cc index 19e23b63fd..71ef9c28ff 100644 --- a/source/core/simulation_control.cc +++ b/source/core/simulation_control.cc @@ -24,8 +24,6 @@ SimulationControl::SimulationControl(const Parameters::SimulationControl ¶m) , residual(DBL_MAX) , stop_tolerance(param.stop_tolerance) , output_iteration_frequency(param.output_iteration_frequency) - , output_time(param.output_time) - , output_time_interval(param.output_time_interval) , log_frequency(param.log_frequency) , log_precision(param.log_precision) , subdivision(param.subdivision) @@ -218,6 +216,8 @@ SimulationControlTransient::SimulationControlTransient( , adaptative_time_step_scaling(param.adaptative_time_step_scaling) , max_dt(param.max_dt) , output_time_frequency(param.output_time_frequency) + , output_time(param.output_time) + , output_time_interval(param.output_time_interval) , output_control(param.output_control) {} From 7ff881e5f4e834701ad3aefc0e72461a7f098b7e Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Fri, 1 Nov 2024 17:23:51 -0400 Subject: [PATCH 15/28] Update failing test --- .../heat_transfer_vof_lpbf_benchmark.mpirun=1.output | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/applications_tests/lethe-fluid/heat_transfer_vof_lpbf_benchmark.mpirun=1.output b/applications_tests/lethe-fluid/heat_transfer_vof_lpbf_benchmark.mpirun=1.output index f16b5b1458..e807214936 100644 --- a/applications_tests/lethe-fluid/heat_transfer_vof_lpbf_benchmark.mpirun=1.output +++ b/applications_tests/lethe-fluid/heat_transfer_vof_lpbf_benchmark.mpirun=1.output @@ -60,9 +60,9 @@ VOF Mass Conservation time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold 6.412000e-06 1.068750e-01 1.906650e-10 1.502026e-11 5.614625e-14 2.531250e-01 1.118813e-06 4.700371e-11 3.317118e-12 5.000000e-01 -********************************************************************************** -Transient iteration: 34 Time: 6.612e-06 Time step: 2e-07 CFL: 1.1299e-06 -********************************************************************************** +*********************************************************************************** +Transient iteration: 34 Time: 6.612e-06 Time step: 2e-07 CFL: 1.01703e-06 +*********************************************************************************** Temperature statistics on fluid: Min: 298 Max: 1527.51 @@ -166,7 +166,7 @@ VOF Mass Conservation 7.812000e-06 1.068750e-01 1.906650e-10 1.507758e-11 7.716538e-14 2.531250e-01 1.118813e-06 4.705784e-11 2.375080e-12 7.969647e-01 *********************************************************************************** -Transient iteration: 41 Time: 8.012e-06 Time step: 2e-07 CFL: 1.12828e-06 +Transient iteration: 41 Time: 8.012e-06 Time step: 2e-07 CFL: 1.01425e-06 *********************************************************************************** Temperature statistics on fluid: Min: 298 @@ -178,4 +178,4 @@ Temperature statistics on fluid: VOF Mass Conservation ---------------------- time surface_fluid_0 mass_per_length_fluid_0 momentum-x_fluid_0 momentum-y_fluid_0 surface_fluid_1 mass_per_length_fluid_1 momentum-x_fluid_1 momentum-y_fluid_1 sharpening_threshold -8.012000e-06 1.068750e-01 1.906650e-10 1.693655e-11 3.258717e-13 2.531250e-01 1.118813e-06 5.881073e-11 1.713271e-12 7.969647e-01 +8.012000e-06 1.068750e-01 1.906650e-10 1.506322e-11 7.605316e-14 2.531250e-01 1.118813e-06 4.696060e-11 1.392207e-12 7.969647e-01 From ac77c5ed054885cf78b80dcce2aca9a0206d2511 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Mon, 4 Nov 2024 10:35:07 -0500 Subject: [PATCH 16/28] Allow to specify several output times in a list --- include/core/parameters.h | 4 ++-- include/core/simulation_control.h | 7 +++++-- source/core/parameters.cc | 18 +++++++++++++----- source/core/simulation_control.cc | 24 ++++++++++++++++++------ tests/core/simulation_control_03.cc | 12 ++++++------ 5 files changed, 44 insertions(+), 21 deletions(-) diff --git a/include/core/parameters.h b/include/core/parameters.h index 0df3f71a13..2f053e96dc 100644 --- a/include/core/parameters.h +++ b/include/core/parameters.h @@ -145,8 +145,8 @@ namespace Parameters // Time frequency of the output (for time output control) double output_time_frequency; - // Output at a specific time (for time output control) - double output_time; + // Output at specific times (for time output control) + std::vector output_times_vector; // Time window for file output (for both iteration and time output control) std::vector output_time_interval; diff --git a/include/core/simulation_control.h b/include/core/simulation_control.h index df8c0a150d..e5a54f92c7 100644 --- a/include/core/simulation_control.h +++ b/include/core/simulation_control.h @@ -498,8 +498,11 @@ class SimulationControlTransient : public SimulationControl // Specific output frequency for time output control double output_time_frequency; - // Specific output time for time output control - double output_time; + // Specific output times for time output control + std::vector output_times_vector; + + // Counter to move between output times given in previous vector + unsigned int output_times_counter = 0; // Time interval for output of transient iterations either with time output // control or iterations control diff --git a/source/core/parameters.cc b/source/core/parameters.cc index 9b15c70e36..fd0046bc2b 100644 --- a/source/core/parameters.cc +++ b/source/core/parameters.cc @@ -169,11 +169,10 @@ namespace Parameters "Display precision when writing to log", "This setting percolates to all output to the log"); - - prm.declare_entry("output time", + prm.declare_entry("output times", "-1", - Patterns::Double(), - "Specific output time for simulation results"); + Patterns::List(Patterns::Double()), + "List of specific output times separated with a comma"); prm.declare_entry( "output control", @@ -260,7 +259,16 @@ namespace Parameters output_name.end()); output_iteration_frequency = prm.get_integer("output frequency"); output_time_frequency = prm.get_double("output time frequency"); - output_time = prm.get_double("output time"); + + const std::string output_times_str = prm.get("output times"); + std::vector output_times_vec = + Utilities::split_string_list(output_times_str); + + for (std::vector::size_type i = 0; i != output_times_vec.size(); ++i) + { + output_times_vector.push_back(std::stod(output_times_vec[i])); + } + output_time_interval = convert_string_to_vector(prm, "output time interval"); output_boundaries = prm.get_bool("output boundaries"); diff --git a/source/core/simulation_control.cc b/source/core/simulation_control.cc index 71ef9c28ff..145f1c077e 100644 --- a/source/core/simulation_control.cc +++ b/source/core/simulation_control.cc @@ -216,7 +216,7 @@ SimulationControlTransient::SimulationControlTransient( , adaptative_time_step_scaling(param.adaptative_time_step_scaling) , max_dt(param.max_dt) , output_time_frequency(param.output_time_frequency) - , output_time(param.output_time) + , output_times_vector(param.output_times_vector) , output_time_interval(param.output_time_interval) , output_control(param.output_control) {} @@ -336,12 +336,15 @@ SimulationControlTransient::is_output_iteration() // For cases 2 and 3: bool is_output_time = false; - double upper_bound, lower_bound; + double upper_bound, lower_bound, local_output_time; - if (output_time != -1) // Case 2. If a specific time is given. + // Case 2. If one or several specific output times are given + // We check the vector of output times once at a time + local_output_time = output_times_vector[output_times_counter]; + if (local_output_time != -1) { - upper_bound = output_time; - lower_bound = output_time; + upper_bound = local_output_time; + lower_bound = local_output_time; } else // Case 3. Only a specific time interval is specified { @@ -363,7 +366,16 @@ SimulationControlTransient::is_output_iteration() // interval upper bound does not correspond exactly to a time iteration // performed (due to in time step) if (current_time >= upper_bound && (previous_time < upper_bound)) - is_output_time = true; + { + is_output_time = true; + + if (local_output_time != -1 && + is_output_time) // Update specific time for case 2, only when we have + // written the upper bound + { + output_times_counter++; + } + } return is_output_time; } diff --git a/tests/core/simulation_control_03.cc b/tests/core/simulation_control_03.cc index af69f02109..b4d70973df 100644 --- a/tests/core/simulation_control_03.cc +++ b/tests/core/simulation_control_03.cc @@ -57,7 +57,7 @@ test() { simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_time = 0.3; + simulation_control_parameters.output_times = 0.3; simulation_control_parameters.output_time_frequency = -1; simulation_control_parameters.output_time_interval = {0, 1.7976931348623157e3}; @@ -90,7 +90,7 @@ test() { simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_time = -1; + simulation_control_parameters.output_times = -1; simulation_control_parameters.output_time_frequency = -1; simulation_control_parameters.output_time_interval = {0.2, 0.4}; @@ -122,7 +122,7 @@ test() { simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_time = -1; + simulation_control_parameters.output_times = -1; simulation_control_parameters.output_time_frequency = 0.2; simulation_control_parameters.output_time_interval = {0, 1.7976931348623157e3}; @@ -201,7 +201,7 @@ test() simulation_control_parameters.maxCFL = 2; simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_time = 7.5; + simulation_control_parameters.output_times = 7.5; simulation_control_parameters.output_time_frequency = -1; simulation_control_parameters.output_time_interval = {0, 1.7976931348623157e3}; @@ -244,7 +244,7 @@ test() simulation_control_parameters.max_dt = 1e6; simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_time = -1; + simulation_control_parameters.output_times = -1; simulation_control_parameters.output_time_frequency = -1; simulation_control_parameters.output_time_interval = {7.5, 17}; @@ -286,7 +286,7 @@ test() simulation_control_parameters.max_dt = 1e6; simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_time = -1; + simulation_control_parameters.output_times = -1; simulation_control_parameters.output_time_frequency = 4; simulation_control_parameters.output_time_interval = {0, 1.7976931348623157e3}; From 1dac179de9aeb6e2e1e8ab0b01d1fa7d75cc84ba Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Mon, 4 Nov 2024 10:52:40 -0500 Subject: [PATCH 17/28] Fix tests --- tests/core/simulation_control_03.cc | 12 ++++++------ tests/solvers/average_velocities_02.cc | 17 +++++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/tests/core/simulation_control_03.cc b/tests/core/simulation_control_03.cc index b4d70973df..d422d40a5e 100644 --- a/tests/core/simulation_control_03.cc +++ b/tests/core/simulation_control_03.cc @@ -57,7 +57,7 @@ test() { simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_times = 0.3; + simulation_control_parameters.output_times_vector = {0.3}; simulation_control_parameters.output_time_frequency = -1; simulation_control_parameters.output_time_interval = {0, 1.7976931348623157e3}; @@ -90,7 +90,7 @@ test() { simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_times = -1; + simulation_control_parameters.output_times_vector = {-1}; simulation_control_parameters.output_time_frequency = -1; simulation_control_parameters.output_time_interval = {0.2, 0.4}; @@ -122,7 +122,7 @@ test() { simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_times = -1; + simulation_control_parameters.output_times_vector = {-1}; simulation_control_parameters.output_time_frequency = 0.2; simulation_control_parameters.output_time_interval = {0, 1.7976931348623157e3}; @@ -201,7 +201,7 @@ test() simulation_control_parameters.maxCFL = 2; simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_times = 7.5; + simulation_control_parameters.output_times_vector = {7.5}; simulation_control_parameters.output_time_frequency = -1; simulation_control_parameters.output_time_interval = {0, 1.7976931348623157e3}; @@ -244,7 +244,7 @@ test() simulation_control_parameters.max_dt = 1e6; simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_times = -1; + simulation_control_parameters.output_times_vector = {-1}; simulation_control_parameters.output_time_frequency = -1; simulation_control_parameters.output_time_interval = {7.5, 17}; @@ -286,7 +286,7 @@ test() simulation_control_parameters.max_dt = 1e6; simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_times = -1; + simulation_control_parameters.output_times_vector = {-1}; simulation_control_parameters.output_time_frequency = 4; simulation_control_parameters.output_time_interval = {0, 1.7976931348623157e3}; diff --git a/tests/solvers/average_velocities_02.cc b/tests/solvers/average_velocities_02.cc index 6ea33aa495..c0947eb22e 100644 --- a/tests/solvers/average_velocities_02.cc +++ b/tests/solvers/average_velocities_02.cc @@ -38,14 +38,15 @@ test() Parameters::SimulationControl simulation_control_parameters; simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulation_control_parameters.dt = 0.1; - simulation_control_parameters.timeEnd = 1.0; - simulation_control_parameters.output_iteration_frequency = 1; - simulation_control_parameters.adapt = true; - simulation_control_parameters.adaptative_time_step_scaling = 0.95; - simulation_control_parameters.max_dt = 1e6; - simulation_control_parameters.output_time_interval = {0, - 1.7976931348623157e3}; + simulation_control_parameters.dt = 0.1; + simulation_control_parameters.timeEnd = 1.0; + simulation_control_parameters.output_iteration_frequency = 1; + simulation_control_parameters.adapt = true; + simulation_control_parameters.adaptative_time_step_scaling = 0.95; + simulation_control_parameters.max_dt = 1e6; + simulation_control_parameters.output_time_interval = {0, + 1.7976931348623157e3}; + simulation_control_parameters.time_step_independent_of_end_time = true; Parameters::PostProcessing postprocessing_parameters; postprocessing_parameters.calculate_average_velocities = true; From 0d199f5c32c6993d3d974f2850a553607c8ef3aa Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Mon, 4 Nov 2024 10:54:58 -0500 Subject: [PATCH 18/28] Add specific time for output --- tests/core/simulation_control_03.cc | 2 +- tests/core/simulation_control_03.output | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/core/simulation_control_03.cc b/tests/core/simulation_control_03.cc index d422d40a5e..fdda0915ff 100644 --- a/tests/core/simulation_control_03.cc +++ b/tests/core/simulation_control_03.cc @@ -201,7 +201,7 @@ test() simulation_control_parameters.maxCFL = 2; simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::time; - simulation_control_parameters.output_times_vector = {7.5}; + simulation_control_parameters.output_times_vector = {7.5, 22.1}; simulation_control_parameters.output_time_frequency = -1; simulation_control_parameters.output_time_interval = {0, 1.7976931348623157e3}; diff --git a/tests/core/simulation_control_03.output b/tests/core/simulation_control_03.output index 068f2d4afa..728680a59b 100644 --- a/tests/core/simulation_control_03.output +++ b/tests/core/simulation_control_03.output @@ -86,7 +86,9 @@ DEAL::Iteration : 9 Time : 15.3680 Time step : 2.00000 DEAL::Iteration : 10 Time : 17.3680 Time step : 2.00000 DEAL::Iteration : 11 Time : 19.3680 Time step : 2.00000 DEAL::Iteration : 12 Time : 21.3680 Time step : 2.00000 +DEAL::This is an output iteration DEAL::Iteration : 13 Time : 23.3680 Time step : 2.00000 +DEAL::This is an output iteration DEAL::Iteration : 14 Time : 25.3680 Time step : 2.00000 DEAL::************************************************* DEAL::Adaptative time stepping - interval time output From ce3601edcc39d3b4a8f2205fed3efb5eaace63ae Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Mon, 4 Nov 2024 13:09:02 -0500 Subject: [PATCH 19/28] Use convert string to vector function --- source/core/parameters.cc | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/source/core/parameters.cc b/source/core/parameters.cc index fd0046bc2b..add539579f 100644 --- a/source/core/parameters.cc +++ b/source/core/parameters.cc @@ -259,16 +259,8 @@ namespace Parameters output_name.end()); output_iteration_frequency = prm.get_integer("output frequency"); output_time_frequency = prm.get_double("output time frequency"); - - const std::string output_times_str = prm.get("output times"); - std::vector output_times_vec = - Utilities::split_string_list(output_times_str); - - for (std::vector::size_type i = 0; i != output_times_vec.size(); ++i) - { - output_times_vector.push_back(std::stod(output_times_vec[i])); - } - + output_times_vector = + convert_string_to_vector(prm, "output times"); output_time_interval = convert_string_to_vector(prm, "output time interval"); output_boundaries = prm.get_bool("output boundaries"); From c6fd2e55bb4d5f4b1649ff9add09ee72eb28e37a Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Mon, 4 Nov 2024 13:39:27 -0500 Subject: [PATCH 20/28] Update documentation --- .../parameters/cfd/simulation_control.rst | 154 +++++++++++------- 1 file changed, 92 insertions(+), 62 deletions(-) diff --git a/doc/source/parameters/cfd/simulation_control.rst b/doc/source/parameters/cfd/simulation_control.rst index 378a9008d6..fd7f47f812 100644 --- a/doc/source/parameters/cfd/simulation_control.rst +++ b/doc/source/parameters/cfd/simulation_control.rst @@ -2,97 +2,103 @@ Simulation Control ================== -This subsection contains the general information of the simulation, including the time integration method and the general output names. It is the most commonly modified section for a simulation. +This subsection is the most important in a simulation and therefore, the most commonly modified in a parameter file. It controls the general parameters of the simulation, such as, the time integration method, end time of a simulation and output settings for paraview files. .. tip:: A standard convention in Lethe is to keep this section at the top of the parameter file, since it is generally the most accessed one. .. seealso:: - For further understanding about the numerical method used and advanced parameters, the interested reader is referred to the Theory Documentation. + For further understanding about the numerical method used and advanced parameters, the interested reader is referred to the theory guide. .. code-block:: text subsection simulation control - # Time-stepping method - set method = steady - + # Type of solver or time-stepping scheme + set method = steady + #--------------------------------------------------- # Steady-state simulation parameters #--------------------------------------------------- # Number of mesh adaptation - set number mesh adapt = 0 - + set number mesh adapt = 0 + # Tolerance at which the simulation is stopped - set stop tolerance = 1e-10 - + set stop tolerance = 1e-10 + #--------------------------------------------------- # BDF scheme parameters #--------------------------------------------------- # Method used to startup high order BDF methods - set bdf startup method = multiple step bdf - + set bdf startup method = multiple step bdf + # Scaling factor used in the iterations necessary to startup the BDF schemes - set startup time scaling = 0.4 - + set startup time scaling = 0.4 + #--------------------------------------------------- # Transient simulations parameters #--------------------------------------------------- # End time value of the simulation - set time end = 1 - + set time end = 1 + # Time step value - set time step = 1 - + set time step = 1 + # Adaptative time-stepping - set adapt = false - + set adapt = false + # Maximum CFL value - set max cfl = 1 - + set max cfl = 1 + # Maximum time step value - set max time step = 1e6 - + set max time step = 1e6 + # Adaptative time step scaling set adaptative time step scaling = 1.1 - + + # Time step independent of end time + set time step independent of end time = true + #--------------------------------------------------- # Log file parameters #--------------------------------------------------- # Log frequency - set log frequency = 1 - + set log frequency = 1 + # Display precision when writing to log - set log precision = 6 - + set log precision = 6 + #--------------------------------------------------- # Output file parameters #--------------------------------------------------- # File output path - set output path = ./ - + set output path = ./ + # File output prefix - set output name = out - + set output name = out + # The control for the output of the simulation results - set output control = iteration - - # Output frequency - set output frequency = 1 - - # Output time - set output time = 1 - + set output control = iteration + + # Output iteration frequency + set output frequency = 1 + + # Output time frequency + set output time frequency = -1 + + # List of specific output times + set output times = -1 + # Output time interval - set output time interval = 1, 1.7e308 - + set output time interval = 1, 1.7e308 + # Maximum number of vtu output files - set group files = 1 - + set group files = 1 + # Output the boundaries of the domain along with their ID - set output boundaries = false - + set output boundaries = false + # Subdivision of mesh cell in postprocessing - set subdivision = 1 + set subdivision = 1 end * ``method``: time-stepping method used. The available options are: @@ -102,22 +108,35 @@ This subsection contains the general information of the simulation, including th * ``bdf2``: 2nd order backward differentiation * ``bdf3``: 3rd order backward differentiation -* ``number mesh adapt``: number of mesh adaptations during the steady-sate simulation +----------------------------------- +Steady-state simulation parameters +----------------------------------- + +* ``number mesh adapt``: number of mesh adaptations during the steady-state simulation. * ``stop tolerance``: tolerance at which the adjoint time stepping steady state simulation (``method = steady_bdf``) stops. + .. note:: The adjoint time stepping will stop when the :math:`\mathcal{L}_2` norm of the initial residual is lower than ``stop tolerance`` at the start of a non-linear solution step. +---------------------- +BDF scheme parameters +---------------------- + * ``bdf startup method``: scheme used to start a high order bdf scheme (2nd order and above). The available options are: * ``multiple step bdf`` * ``initial solution`` -* ``startup time scaling``: scaling factor used in the iterations necessary to startup the BDF schemes +* ``startup time scaling``: scaling factor used in the iterations necessary to startup the BDF schemes. + +--------------------------------- +Transient simulations parameters +--------------------------------- -* ``time end``: value of the time to end the transient simulation +* ``time end``: value of the time to end the transient simulation. -* ``time step``: value of the time step +* ``time step``: value of the time step. * ``adapt``: controls if adaptive time-stepping is enabled. If set to ``true``, the time-step will evolve to ensure that the ``max cfl`` value is reached. @@ -125,25 +144,32 @@ This subsection contains the general information of the simulation, including th * ``max time step``: maximum time step value that can be reached during the simulation. This parameter is only used when ``set adapt = true``. It is useful when the problem of interest has an additional time step constraint such as the capillary time step limit described in :doc:`../../examples/multiphysics/capillary-wave/capillary-wave`. -* ``adaptative time step scaling``: rate of increase of the time step value. The new time step value is fixed by ``adaptative time step scaling`` * ``previous value of the time step`` +* ``adaptative time step scaling``: rate of increase of the time step value. The new time step value is fixed by ``adaptative time step scaling`` * ``previous value of the time step``. -* ``log frequency``: frequency at which information is written in terminal +* ``time step independent of end time``: this variable ensures that the time step of the simulation is always consistent at the end of the simulation. If one uses a time step that eventually leads exactly to the end time of the simulation this variable does not do anything. However, if adaptive time stepping is used or the end time is not exactly reached when using certain fixed time step, this flag ensures that the simulation does not change the last time step to reach the end time. For example, if your end time is 20, and you have a time step that leads to a last iteration until 20.1, all your results will be outputted until 20.1. If you wish to have exactly 20, you need to set this flag to ``false``. -* ``log precision``: number of significant digits used when writting in terminal +-------------------- +Log file parameters +-------------------- -* ``output path``: directory for the output files +* ``log frequency``: frequency at which information is written in terminal. -.. warning:: - Lethe will not automatically create the directory specified in ``output path``, it must exists prior to launching the simulation. +* ``log precision``: number of significant digits used when writting in terminal. + +-------------------------------- +Paraview output file parameters +-------------------------------- + +* ``output path``: directory for the output files. * ``output name``: prefix for the Paraview output files (``.pvd`` / ``.vtu``) .. important:: - Lethe saves the simulation results in the Paraview format: ``.vtu`` for one iteration, and ``.pvd`` files linking all iterations together. Use the open-source Software `Paraview `_ to visualize them. + Lethe saves the simulation results in the Paraview format: ``.vtu`` for one iteration, and ``.pvd`` files linking all iterations together. Use the open-source software `Paraview `_ to visualize them. * ``output control``: control for the output of the simulation results. The available options are: - * ``iteration``: results will be outputted at constant iteration frequency - * ``time`` : results will be outputted at constant time + * ``iteration``: results will be outputted at constant iteration frequency. The time interval for this kind of output can also be specified. + * ``time`` : results will be outputted based on time parameters (specific times or time frequency). The results can also be outputted for certain time interval. * ``output frequency``: controls after which number of iterations the ``.pvd`` / ``.vtu`` results are written. This parameter is only used when ``set output control = iteration``. @@ -152,10 +178,14 @@ This subsection contains the general information of the simulation, including th If the ``output frequency`` is set at a higher number than the total number of iterations in the simulation, the startup iteration will still be outputted. +* ``output time frequency``: controls the time frequency when the ``.pvd`` / ``.vtu`` results are written, e.g., if set to 1, paraview files will be outputted every second. This parameter is only used when ``set output control = time``. + +* ``output times``: allows to specify specific times for the output of ``.pvd`` / ``.vtu``. This parameter is only used when ``set output control = time``. As an example, one can output files only at 5 seconds, by setting ``set output times = 5`` or at multiple specific times separating the values with commas: ``set output times = 5, 14``. -* ``output time``: controls the time when the ``.pvd`` / ``.vtu`` results are written. This parameter is only used when ``set output control = time``. +* ``output time interval``: Only writes the ``.pvd`` / ``.vtu`` files when the simulation time is within the closed interval defined by the ``output time interval``. Default values are 0s and 1.7e308s. Used for both ``iteration`` and ``time`` output control. -* ``output time interval``: Only writes the ``.pvd`` / ``.vtu`` files when the simulation time is within the closed interval defined by the ``output time interval``. Default values are 0s and 1.7e308s. +.. warning:: + Since it is possible that the times specified in the interval or in specific output times do not correspond to the time of specific iterations, Lethe will always write the paraview files before and after the time specified. * ``group files``: number of ``.vtu`` files generated in a parallel simulation From dda7dc0b999f4668b51ecc221682a5bbdde31e54 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Mon, 4 Nov 2024 13:45:46 -0500 Subject: [PATCH 21/28] Update documentation and examples --- .../rayleigh-benard-convection/rayleigh-benard-convection.rst | 4 ++-- .../rayleigh-taylor-instability.rst | 2 +- .../rayleigh-benard-convection-Ra10k.prm | 2 +- .../rayleigh-benard-convection-Ra25k.prm | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/source/examples/multiphysics/rayleigh-benard-convection/rayleigh-benard-convection.rst b/doc/source/examples/multiphysics/rayleigh-benard-convection/rayleigh-benard-convection.rst index f34528cea0..ea75585985 100644 --- a/doc/source/examples/multiphysics/rayleigh-benard-convection/rayleigh-benard-convection.rst +++ b/doc/source/examples/multiphysics/rayleigh-benard-convection/rayleigh-benard-convection.rst @@ -73,7 +73,7 @@ time step of :math:`0.01` second. .. note:: This example uses an adaptive time-stepping method, where the - time-step is modified during the simulation to keep the maximum value of the CFL condition below a given threshold (0.5 here). Using ``output control = time``, and ``output time = 25`` the simulation results are written every 25 s. + time-step is modified during the simulation to keep the maximum value of the CFL condition below a given threshold (0.5 here). Using ``output control = time``, and ``output time frequency = 25`` the simulation results are written every 25 s. .. note:: Note that the heating process is slow, and the velocity magnitudes are small inside the fluid. Hence, we expect large time-steps and a long simulation. @@ -91,7 +91,7 @@ time step of :math:`0.01` second. set number mesh adapt = 0 set output name = rayleigh-benard_convection set output control = time - set output time = 25 + set output time frequency = 25 set output path = ./output/ end diff --git a/doc/source/examples/multiphysics/rayleigh-taylor-instability/rayleigh-taylor-instability.rst b/doc/source/examples/multiphysics/rayleigh-taylor-instability/rayleigh-taylor-instability.rst index 2f2d65ab6b..5894a2a0ad 100644 --- a/doc/source/examples/multiphysics/rayleigh-taylor-instability/rayleigh-taylor-instability.rst +++ b/doc/source/examples/multiphysics/rayleigh-taylor-instability/rayleigh-taylor-instability.rst @@ -73,7 +73,7 @@ and the max CFL is :math:`0.8`. .. note:: This example uses an adaptive time-stepping method, where the - time-step is modified during the simulation to keep the maximum value of the CFL condition below a given threshold (:math:`0.9` here). Using ``output control = time``, and ``output time = 0.005`` the simulation results are written every :math:`0.005\, \text{s}`. + time-step is modified during the simulation to keep the maximum value of the CFL condition below a given threshold (:math:`0.8` here). .. code-block:: text diff --git a/examples/multiphysics/rayleigh-benard-convection/rayleigh-benard-convection-Ra10k.prm b/examples/multiphysics/rayleigh-benard-convection/rayleigh-benard-convection-Ra10k.prm index 4ada1401d5..9824015f83 100644 --- a/examples/multiphysics/rayleigh-benard-convection/rayleigh-benard-convection-Ra10k.prm +++ b/examples/multiphysics/rayleigh-benard-convection/rayleigh-benard-convection-Ra10k.prm @@ -21,7 +21,7 @@ subsection simulation control set number mesh adapt = 0 set output name = rayleigh-benard_convection set output control = time - set output time = 25 + set output time frequency = 25 set output path = ./output/ end diff --git a/examples/multiphysics/rayleigh-benard-convection/rayleigh-benard-convection-Ra25k.prm b/examples/multiphysics/rayleigh-benard-convection/rayleigh-benard-convection-Ra25k.prm index fcc2d338a1..be151b51f2 100644 --- a/examples/multiphysics/rayleigh-benard-convection/rayleigh-benard-convection-Ra25k.prm +++ b/examples/multiphysics/rayleigh-benard-convection/rayleigh-benard-convection-Ra25k.prm @@ -21,7 +21,7 @@ subsection simulation control set number mesh adapt = 0 set output name = rayleigh-benard_convection set output control = time - set output time = 25 + set output time frequency = 25 set output path = ./output/ end From 68db48984fceb17410eb3d6672a526d7eab760ab Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Tue, 5 Nov 2024 11:29:52 -0500 Subject: [PATCH 22/28] Add new deafult parameters in all relevant core and solvers tests --- source/solvers/navier_stokes_base.cc | 219 ++++++++++++++++++++++++ tests/core/simulation_control_01.cc | 13 +- tests/core/simulation_control_02.cc | 1 + tests/core/simulation_control_03.cc | 4 +- tests/core/simulation_control_04.cc | 2 +- tests/core/simulation_control_05.cc | 13 +- tests/solvers/average_velocities_01.cc | 7 +- tests/solvers/average_velocities_03.cc | 8 +- tests/solvers/reynolds_stress_01.cc | 7 +- tests/solvers/reynolds_stress_02.cc | 11 +- tests/solvers/reynolds_stress_02.output | 7 - tests/solvers/reynolds_stress_03.cc | 7 +- 12 files changed, 261 insertions(+), 38 deletions(-) diff --git a/source/solvers/navier_stokes_base.cc b/source/solvers/navier_stokes_base.cc index a426aa8629..faeb6c9d3d 100644 --- a/source/solvers/navier_stokes_base.cc +++ b/source/solvers/navier_stokes_base.cc @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -2720,6 +2721,224 @@ NavierStokesBase::write_output_results( write_boundaries_vtu( data_out_faces, folder, time, iter, this->mpi_communicator); } + if constexpr (std::is_same_v>) + { + if constexpr (dim == 3) + { + const int patch_dim = 2; + const int spacedim = 3; + + parallel::distributed::Triangulation tria_slice( + this->mpi_communicator); + parallel::distributed::Triangulation + tria_slice_right(this->mpi_communicator); + parallel::distributed::Triangulation + tria_slice_left(this->mpi_communicator); + + GridGenerator::subdivided_hyper_rectangle( + tria_slice_right, + {1, 4}, + Point(0.5, 0.), + Point(1, 3.14159265359)); + + GridGenerator::subdivided_hyper_rectangle( + tria_slice_left, + {1, 4}, + Point(-0.5, 0.), + Point(-1, 3.14159265359)); + + + GridTools::rotate(Tensor<1, spacedim>({1., 0., 0.}), + numbers::PI_2, + tria_slice_right); + + GridTools::rotate(Tensor<1, spacedim>({0., 0., 1.}), + numbers::PI_2, + tria_slice_right); + + GridTools::rotate(Tensor<1, spacedim>({1., 0., 0.}), + numbers::PI_2, + tria_slice_left); + + GridTools::rotate(Tensor<1, spacedim>({0., 0., 1.}), + numbers::PI_2, + tria_slice_left); + + GridGenerator::merge_triangulations( + {&tria_slice_left, &tria_slice_right}, tria_slice, 1.e-12, true); + + tria_slice.refine_global( + simulation_parameters.mesh.initial_refinement); + + MappingQ mapping_slice( + simulation_parameters.fem_parameters.velocity_order); + DataOutResample data_out_slice( + tria_slice, mapping_slice); + + data_out_slice.set_flags(flags); + + data_out_slice.add_data_vector(dof_handler, + solution, + solution_names, + data_component_interpretation); + + if (this->simulation_parameters.post_processing + .calculate_average_velocities || + this->simulation_parameters.initial_condition->type == + Parameters::InitialConditionType::average_velocity_profile) + { + // Add the interpretation of the average solution. The dim + // first components are the average velocity vectors and the + // following one is the average pressure. (, , ,

) + std::vector average_solution_names( + dim, "average_velocity"); + average_solution_names.emplace_back("average_pressure"); + + std::vector< + DataComponentInterpretation::DataComponentInterpretation> + average_data_component_interpretation( + dim, + DataComponentInterpretation::component_is_part_of_vector); + average_data_component_interpretation.emplace_back( + DataComponentInterpretation::component_is_scalar); + + data_out_slice.add_data_vector( + dof_handler, + this->average_velocities->get_average_velocities(), + average_solution_names, + average_data_component_interpretation); + + // Add the interpretation of the reynolds stresses of + // solution. The dim first components are the normal reynolds + // stress vectors and the following ones are others resolved + // reynolds stresses. + std::vector reynolds_normal_stress_names( + dim, "reynolds_normal_stress"); + reynolds_normal_stress_names.emplace_back( + "turbulent_kinetic_energy"); + std::vector< + DataComponentInterpretation::DataComponentInterpretation> + reynolds_normal_stress_data_component_interpretation( + dim, + DataComponentInterpretation::component_is_part_of_vector); + reynolds_normal_stress_data_component_interpretation.emplace_back( + DataComponentInterpretation::component_is_scalar); + + + std::vector reynolds_shear_stress_names = { + "reynolds_shear_stress_uv"}; + if (dim == 2) + { + reynolds_shear_stress_names.emplace_back("dummy_rss_2d"); + } + if (dim == 3) + { + reynolds_shear_stress_names.emplace_back( + "reynolds_shear_stress_vw"); + reynolds_shear_stress_names.emplace_back( + "reynolds_shear_stress_uw"); + } + reynolds_shear_stress_names.emplace_back("dummy_rss"); + + std::vector< + DataComponentInterpretation::DataComponentInterpretation> + reynolds_shear_stress_data_component_interpretation( + dim, DataComponentInterpretation::component_is_scalar); + reynolds_shear_stress_data_component_interpretation.emplace_back( + DataComponentInterpretation::component_is_scalar); + + data_out_slice.add_data_vector( + dof_handler, + this->average_velocities->get_reynolds_normal_stresses(), + reynolds_normal_stress_names, + reynolds_normal_stress_data_component_interpretation); + + data_out_slice.add_data_vector( + dof_handler, + this->average_velocities->get_reynolds_shear_stresses(), + reynolds_shear_stress_names, + reynolds_shear_stress_data_component_interpretation); + } + + + // Vector subdomain(tria_slice.n_active_cells()); + // for (unsigned int i = 0; i < subdomain.size(); ++i) + // subdomain(i) = tria_slice.locally_owned_subdomain(); + // data_out_slice.add_data_vector(subdomain, "subdomain"); + + // Create the post-processors to have derived information about + // the velocity They are generated outside the if condition for + // smoothing to ensure that the objects still exist when the write + // output of DataOut is called Regular discontinuous + // postprocessors + QCriterionPostprocessor qcriterion; + DivergencePostprocessor divergence; + VorticityPostprocessor vorticity; + data_out_slice.add_data_vector(dof_handler, solution, qcriterion); + data_out_slice.add_data_vector(dof_handler, solution, divergence); + data_out_slice.add_data_vector(dof_handler, solution, vorticity); + + // Build patches + data_out_slice.build_patches( + *this->mapping, + subdivision, + DataOut::curved_inner_cells); + + // Write files + const unsigned int digits = 5; + const int my_id = Utilities::MPI::this_mpi_process(mpi_communicator); + + // Write master files (.pvtu,.pvd,.visit) on the master process + if (my_id == 0) + { + std::vector filenames; + const unsigned int n_processes = + Utilities::MPI::n_mpi_processes(mpi_communicator); + const unsigned int n_files = (group_files == 0) ? + n_processes : + std::min(group_files, n_processes); + + for (unsigned int i = 0; i < n_files; ++i) + filenames.push_back(solution_name + "_slices" + "." + + Utilities::int_to_string(iter, digits) + + "." + Utilities::int_to_string(i, digits) + + ".vtu"); + + std::string pvtu_filename = + (solution_name + "_slices" + "." + + Utilities::int_to_string(iter, digits) + ".pvtu"); + + std::string pvtu_filename_with_folder = folder + pvtu_filename; + std::ofstream master_output(pvtu_filename_with_folder.c_str()); + + data_out_slice.write_pvtu_record(master_output, filenames); + + std::string pvdPrefix = + (folder + solution_name + "_slices" + ".pvd"); + this->pvdhandler.append(time, pvtu_filename); + std::ofstream pvd_output(pvdPrefix.c_str()); + DataOutBase::write_pvd_record(pvd_output, + this->pvdhandler.times_and_names); + } + + const unsigned int my_file_id = + (group_files == 0 ? my_id : my_id % group_files); + int color = my_id % group_files; + + { + MPI_Comm comm; + MPI_Comm_split(mpi_communicator, color, my_id, &comm); + const std::string filename = + (folder + solution_name + "_slices" + "." + + Utilities::int_to_string(iter, digits) + "." + + Utilities::int_to_string(my_file_id, digits) + ".vtu"); + data_out_slice.write_vtu_in_parallel(filename.c_str(), comm); + + MPI_Comm_free(&comm); + } + } + } } template diff --git a/tests/core/simulation_control_01.cc b/tests/core/simulation_control_01.cc index f634fef3a6..576629d3ed 100644 --- a/tests/core/simulation_control_01.cc +++ b/tests/core/simulation_control_01.cc @@ -22,12 +22,13 @@ test() simulationControlParameters.maxCFL = 99; simulationControlParameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulationControlParameters.timeEnd = 999; - simulationControlParameters.number_mesh_adaptation = 9; - simulationControlParameters.output_name = "test"; - simulationControlParameters.subdivision = 7; - simulationControlParameters.output_folder = "canard"; - simulationControlParameters.output_iteration_frequency = 8; + simulationControlParameters.timeEnd = 999; + simulationControlParameters.number_mesh_adaptation = 9; + simulationControlParameters.output_name = "test"; + simulationControlParameters.subdivision = 7; + simulationControlParameters.output_folder = "canard"; + simulationControlParameters.output_iteration_frequency = 8; + simulationControlParameters.time_step_independent_of_end_time = true; SimulationControlTransient simulationControl(simulationControlParameters); diff --git a/tests/core/simulation_control_02.cc b/tests/core/simulation_control_02.cc index fadf2c87ce..8f519be370 100644 --- a/tests/core/simulation_control_02.cc +++ b/tests/core/simulation_control_02.cc @@ -31,6 +31,7 @@ test() simulationControlParameters.output_folder = "canard"; simulationControlParameters.output_iteration_frequency = 8; simulationControlParameters.output_time_interval = {0, 1000000000}; + simulationControlParameters.time_step_independent_of_end_time = true; SimulationControlSteady simulation_control(simulationControlParameters); diff --git a/tests/core/simulation_control_03.cc b/tests/core/simulation_control_03.cc index fdda0915ff..0f10f49a6b 100644 --- a/tests/core/simulation_control_03.cc +++ b/tests/core/simulation_control_03.cc @@ -22,7 +22,9 @@ test() simulation_control_parameters.maxCFL = 2; simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulation_control_parameters.timeEnd = 0.5; + simulation_control_parameters.timeEnd = 0.5; + simulation_control_parameters.output_control = + Parameters::SimulationControl::OutputControl::iteration; simulation_control_parameters.output_iteration_frequency = 2; simulation_control_parameters.time_step_independent_of_end_time = true; simulation_control_parameters.output_time_interval = {0, diff --git a/tests/core/simulation_control_04.cc b/tests/core/simulation_control_04.cc index 0083c36ca3..2951a87ff0 100644 --- a/tests/core/simulation_control_04.cc +++ b/tests/core/simulation_control_04.cc @@ -22,8 +22,8 @@ test() simulation_control_parameters.adapt = false; simulation_control_parameters.maxCFL = 1; simulation_control_parameters.method = - Parameters::SimulationControl::TimeSteppingMethod::bdf1; + simulation_control_parameters.time_step_independent_of_end_time = true; simulation_control_parameters.timeEnd = 20; simulation_control_parameters.number_mesh_adaptation = 0; diff --git a/tests/core/simulation_control_05.cc b/tests/core/simulation_control_05.cc index 79b98190bb..3568e8566c 100644 --- a/tests/core/simulation_control_05.cc +++ b/tests/core/simulation_control_05.cc @@ -23,12 +23,13 @@ test() simulation_control_parameters.startup_timestep_scaling = 0.4; simulation_control_parameters.bdf_startup_method = Parameters::SimulationControl::BDFStartupMethods::multiple_step_bdf; - simulation_control_parameters.timeEnd = 4; - simulation_control_parameters.number_mesh_adaptation = 0; - simulation_control_parameters.output_name = "test"; - simulation_control_parameters.subdivision = 7; - simulation_control_parameters.output_folder = "canard"; - simulation_control_parameters.output_iteration_frequency = 8; + simulation_control_parameters.timeEnd = 4; + simulation_control_parameters.number_mesh_adaptation = 0; + simulation_control_parameters.output_name = "test"; + simulation_control_parameters.subdivision = 7; + simulation_control_parameters.output_folder = "canard"; + simulation_control_parameters.output_iteration_frequency = 8; + simulation_control_parameters.time_step_independent_of_end_time = true; { simulation_control_parameters.method = diff --git a/tests/solvers/average_velocities_01.cc b/tests/solvers/average_velocities_01.cc index 5a2b91f6d7..a21e3874d3 100644 --- a/tests/solvers/average_velocities_01.cc +++ b/tests/solvers/average_velocities_01.cc @@ -36,9 +36,10 @@ test() Parameters::SimulationControl simulation_control_parameters; simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulation_control_parameters.dt = 0.1; - simulation_control_parameters.timeEnd = 1.0; - simulation_control_parameters.adapt = false; + simulation_control_parameters.dt = 0.1; + simulation_control_parameters.timeEnd = 1.0; + simulation_control_parameters.adapt = false; + simulation_control_parameters.time_step_independent_of_end_time = true; Parameters::PostProcessing postprocessing_parameters; postprocessing_parameters.calculate_average_velocities = true; diff --git a/tests/solvers/average_velocities_03.cc b/tests/solvers/average_velocities_03.cc index 6469119905..cafac32523 100644 --- a/tests/solvers/average_velocities_03.cc +++ b/tests/solvers/average_velocities_03.cc @@ -34,9 +34,11 @@ test() Parameters::SimulationControl simulation_control_parameters; simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulation_control_parameters.dt = 0.1; - simulation_control_parameters.timeEnd = 1.0; - simulation_control_parameters.adapt = false; + simulation_control_parameters.dt = 0.1; + simulation_control_parameters.timeEnd = 1.0; + simulation_control_parameters.adapt = false; + simulation_control_parameters.time_step_independent_of_end_time = true; + Parameters::PostProcessing postprocessing_parameters; postprocessing_parameters.calculate_average_velocities = true; diff --git a/tests/solvers/reynolds_stress_01.cc b/tests/solvers/reynolds_stress_01.cc index 38ded835bd..9c20b97bfe 100644 --- a/tests/solvers/reynolds_stress_01.cc +++ b/tests/solvers/reynolds_stress_01.cc @@ -38,9 +38,10 @@ test() Parameters::SimulationControl simulation_control_parameters; simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulation_control_parameters.dt = 0.1; - simulation_control_parameters.timeEnd = 1.0; - simulation_control_parameters.adapt = false; + simulation_control_parameters.dt = 0.1; + simulation_control_parameters.timeEnd = 1.0; + simulation_control_parameters.adapt = false; + simulation_control_parameters.time_step_independent_of_end_time = true; Parameters::PostProcessing postprocessing_parameters; postprocessing_parameters.calculate_average_velocities = true; diff --git a/tests/solvers/reynolds_stress_02.cc b/tests/solvers/reynolds_stress_02.cc index c861c03347..ec212f6617 100644 --- a/tests/solvers/reynolds_stress_02.cc +++ b/tests/solvers/reynolds_stress_02.cc @@ -39,11 +39,12 @@ test() Parameters::SimulationControl simulation_control_parameters; simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulation_control_parameters.dt = 0.1; - simulation_control_parameters.timeEnd = 1.0; - simulation_control_parameters.adapt = true; - simulation_control_parameters.adaptative_time_step_scaling = 0.99; - simulation_control_parameters.max_dt = 1e6; + simulation_control_parameters.dt = 0.1; + simulation_control_parameters.timeEnd = 1.0; + simulation_control_parameters.adapt = true; + simulation_control_parameters.adaptative_time_step_scaling = 0.99; + simulation_control_parameters.max_dt = 1e6; + simulation_control_parameters.time_step_independent_of_end_time = true; Parameters::PostProcessing postprocessing_parameters; postprocessing_parameters.calculate_average_velocities = true; diff --git a/tests/solvers/reynolds_stress_02.output b/tests/solvers/reynolds_stress_02.output index 458f147870..3784ae41d2 100644 --- a/tests/solvers/reynolds_stress_02.output +++ b/tests/solvers/reynolds_stress_02.output @@ -34,10 +34,3 @@ DEAL:: : 3.11600e-05 0.000977178 0.194470 0.00448704 DEAL:: : 0.000623200 0.00436240 0.00000 0.00373920 DEAL:: k : 0.00624758 0.0102261 0.0972348 0.00380152 DEAL:: -DEAL:: Time : 1.00000 -DEAL:: Time step : 0.0438208 -DEAL:: : 0.0156935 0.0245212 0.00000 0.00392339 -DEAL:: : 3.92339e-05 0.00123037 0.244859 0.00564968 -DEAL:: : 0.000784677 0.00549274 0.00000 0.00470806 -DEAL:: k : 0.00786639 0.0128758 0.122429 0.00478653 -DEAL:: \ No newline at end of file diff --git a/tests/solvers/reynolds_stress_03.cc b/tests/solvers/reynolds_stress_03.cc index c8ab03c21d..dfbb83e28b 100644 --- a/tests/solvers/reynolds_stress_03.cc +++ b/tests/solvers/reynolds_stress_03.cc @@ -34,9 +34,10 @@ test() Parameters::SimulationControl simulation_control_parameters; simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulation_control_parameters.dt = 0.1; - simulation_control_parameters.timeEnd = 1.0; - simulation_control_parameters.adapt = false; + simulation_control_parameters.dt = 0.1; + simulation_control_parameters.timeEnd = 1.0; + simulation_control_parameters.adapt = false; + simulation_control_parameters.time_step_independent_of_end_time = true; Parameters::PostProcessing postprocessing_parameters; postprocessing_parameters.calculate_average_velocities = true; From 4e9a9133036e0d1dbff35b48b309dded2c0bf3fd Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Tue, 5 Nov 2024 11:38:24 -0500 Subject: [PATCH 23/28] Remove vtu slice code --- source/solvers/navier_stokes_base.cc | 218 --------------------------- 1 file changed, 218 deletions(-) diff --git a/source/solvers/navier_stokes_base.cc b/source/solvers/navier_stokes_base.cc index faeb6c9d3d..cbbc7d4809 100644 --- a/source/solvers/navier_stokes_base.cc +++ b/source/solvers/navier_stokes_base.cc @@ -2721,224 +2721,6 @@ NavierStokesBase::write_output_results( write_boundaries_vtu( data_out_faces, folder, time, iter, this->mpi_communicator); } - if constexpr (std::is_same_v>) - { - if constexpr (dim == 3) - { - const int patch_dim = 2; - const int spacedim = 3; - - parallel::distributed::Triangulation tria_slice( - this->mpi_communicator); - parallel::distributed::Triangulation - tria_slice_right(this->mpi_communicator); - parallel::distributed::Triangulation - tria_slice_left(this->mpi_communicator); - - GridGenerator::subdivided_hyper_rectangle( - tria_slice_right, - {1, 4}, - Point(0.5, 0.), - Point(1, 3.14159265359)); - - GridGenerator::subdivided_hyper_rectangle( - tria_slice_left, - {1, 4}, - Point(-0.5, 0.), - Point(-1, 3.14159265359)); - - - GridTools::rotate(Tensor<1, spacedim>({1., 0., 0.}), - numbers::PI_2, - tria_slice_right); - - GridTools::rotate(Tensor<1, spacedim>({0., 0., 1.}), - numbers::PI_2, - tria_slice_right); - - GridTools::rotate(Tensor<1, spacedim>({1., 0., 0.}), - numbers::PI_2, - tria_slice_left); - - GridTools::rotate(Tensor<1, spacedim>({0., 0., 1.}), - numbers::PI_2, - tria_slice_left); - - GridGenerator::merge_triangulations( - {&tria_slice_left, &tria_slice_right}, tria_slice, 1.e-12, true); - - tria_slice.refine_global( - simulation_parameters.mesh.initial_refinement); - - MappingQ mapping_slice( - simulation_parameters.fem_parameters.velocity_order); - DataOutResample data_out_slice( - tria_slice, mapping_slice); - - data_out_slice.set_flags(flags); - - data_out_slice.add_data_vector(dof_handler, - solution, - solution_names, - data_component_interpretation); - - if (this->simulation_parameters.post_processing - .calculate_average_velocities || - this->simulation_parameters.initial_condition->type == - Parameters::InitialConditionType::average_velocity_profile) - { - // Add the interpretation of the average solution. The dim - // first components are the average velocity vectors and the - // following one is the average pressure. (, , ,

) - std::vector average_solution_names( - dim, "average_velocity"); - average_solution_names.emplace_back("average_pressure"); - - std::vector< - DataComponentInterpretation::DataComponentInterpretation> - average_data_component_interpretation( - dim, - DataComponentInterpretation::component_is_part_of_vector); - average_data_component_interpretation.emplace_back( - DataComponentInterpretation::component_is_scalar); - - data_out_slice.add_data_vector( - dof_handler, - this->average_velocities->get_average_velocities(), - average_solution_names, - average_data_component_interpretation); - - // Add the interpretation of the reynolds stresses of - // solution. The dim first components are the normal reynolds - // stress vectors and the following ones are others resolved - // reynolds stresses. - std::vector reynolds_normal_stress_names( - dim, "reynolds_normal_stress"); - reynolds_normal_stress_names.emplace_back( - "turbulent_kinetic_energy"); - std::vector< - DataComponentInterpretation::DataComponentInterpretation> - reynolds_normal_stress_data_component_interpretation( - dim, - DataComponentInterpretation::component_is_part_of_vector); - reynolds_normal_stress_data_component_interpretation.emplace_back( - DataComponentInterpretation::component_is_scalar); - - - std::vector reynolds_shear_stress_names = { - "reynolds_shear_stress_uv"}; - if (dim == 2) - { - reynolds_shear_stress_names.emplace_back("dummy_rss_2d"); - } - if (dim == 3) - { - reynolds_shear_stress_names.emplace_back( - "reynolds_shear_stress_vw"); - reynolds_shear_stress_names.emplace_back( - "reynolds_shear_stress_uw"); - } - reynolds_shear_stress_names.emplace_back("dummy_rss"); - - std::vector< - DataComponentInterpretation::DataComponentInterpretation> - reynolds_shear_stress_data_component_interpretation( - dim, DataComponentInterpretation::component_is_scalar); - reynolds_shear_stress_data_component_interpretation.emplace_back( - DataComponentInterpretation::component_is_scalar); - - data_out_slice.add_data_vector( - dof_handler, - this->average_velocities->get_reynolds_normal_stresses(), - reynolds_normal_stress_names, - reynolds_normal_stress_data_component_interpretation); - - data_out_slice.add_data_vector( - dof_handler, - this->average_velocities->get_reynolds_shear_stresses(), - reynolds_shear_stress_names, - reynolds_shear_stress_data_component_interpretation); - } - - - // Vector subdomain(tria_slice.n_active_cells()); - // for (unsigned int i = 0; i < subdomain.size(); ++i) - // subdomain(i) = tria_slice.locally_owned_subdomain(); - // data_out_slice.add_data_vector(subdomain, "subdomain"); - - // Create the post-processors to have derived information about - // the velocity They are generated outside the if condition for - // smoothing to ensure that the objects still exist when the write - // output of DataOut is called Regular discontinuous - // postprocessors - QCriterionPostprocessor qcriterion; - DivergencePostprocessor divergence; - VorticityPostprocessor vorticity; - data_out_slice.add_data_vector(dof_handler, solution, qcriterion); - data_out_slice.add_data_vector(dof_handler, solution, divergence); - data_out_slice.add_data_vector(dof_handler, solution, vorticity); - - // Build patches - data_out_slice.build_patches( - *this->mapping, - subdivision, - DataOut::curved_inner_cells); - - // Write files - const unsigned int digits = 5; - const int my_id = Utilities::MPI::this_mpi_process(mpi_communicator); - - // Write master files (.pvtu,.pvd,.visit) on the master process - if (my_id == 0) - { - std::vector filenames; - const unsigned int n_processes = - Utilities::MPI::n_mpi_processes(mpi_communicator); - const unsigned int n_files = (group_files == 0) ? - n_processes : - std::min(group_files, n_processes); - - for (unsigned int i = 0; i < n_files; ++i) - filenames.push_back(solution_name + "_slices" + "." + - Utilities::int_to_string(iter, digits) + - "." + Utilities::int_to_string(i, digits) + - ".vtu"); - - std::string pvtu_filename = - (solution_name + "_slices" + "." + - Utilities::int_to_string(iter, digits) + ".pvtu"); - - std::string pvtu_filename_with_folder = folder + pvtu_filename; - std::ofstream master_output(pvtu_filename_with_folder.c_str()); - - data_out_slice.write_pvtu_record(master_output, filenames); - - std::string pvdPrefix = - (folder + solution_name + "_slices" + ".pvd"); - this->pvdhandler.append(time, pvtu_filename); - std::ofstream pvd_output(pvdPrefix.c_str()); - DataOutBase::write_pvd_record(pvd_output, - this->pvdhandler.times_and_names); - } - - const unsigned int my_file_id = - (group_files == 0 ? my_id : my_id % group_files); - int color = my_id % group_files; - - { - MPI_Comm comm; - MPI_Comm_split(mpi_communicator, color, my_id, &comm); - const std::string filename = - (folder + solution_name + "_slices" + "." + - Utilities::int_to_string(iter, digits) + "." + - Utilities::int_to_string(my_file_id, digits) + ".vtu"); - data_out_slice.write_vtu_in_parallel(filename.c_str(), comm); - - MPI_Comm_free(&comm); - } - } - } } template From a2d8068ea598f778e4fa78f1464017a52e781191 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Tue, 5 Nov 2024 15:35:41 -0500 Subject: [PATCH 24/28] Add flag to check whether the output times vector has more elements or not --- include/core/simulation_control.h | 4 ++++ source/core/simulation_control.cc | 33 ++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/include/core/simulation_control.h b/include/core/simulation_control.h index e5a54f92c7..18744e6b88 100644 --- a/include/core/simulation_control.h +++ b/include/core/simulation_control.h @@ -504,6 +504,10 @@ class SimulationControlTransient : public SimulationControl // Counter to move between output times given in previous vector unsigned int output_times_counter = 0; + // Variable to check whether we still have specific times to check in output + // times vector + bool no_more_output_times = false; + // Time interval for output of transient iterations either with time output // control or iterations control std::vector output_time_interval; diff --git a/source/core/simulation_control.cc b/source/core/simulation_control.cc index 145f1c077e..fe8c690564 100644 --- a/source/core/simulation_control.cc +++ b/source/core/simulation_control.cc @@ -301,14 +301,15 @@ bool SimulationControlTransient::is_output_iteration() { // If iteration control the only options are to not print or at certain - // frequency of iterations + // frequency of iterations for the time interval given if (output_control == Parameters::SimulationControl::OutputControl::iteration) { if (output_iteration_frequency == 0) return false; else { - // Check if the current step number matches the output frequency + // Check if the current step number matches the output frequency and + // the time interval return (get_step_number() % output_iteration_frequency == 0 && get_current_time() >= output_time_interval[0] && get_current_time() <= output_time_interval[1]); @@ -330,7 +331,7 @@ SimulationControlTransient::is_output_iteration() return true; } - else + else // if it does not match the time frequency we do not output return false; } @@ -339,12 +340,18 @@ SimulationControlTransient::is_output_iteration() double upper_bound, lower_bound, local_output_time; // Case 2. If one or several specific output times are given - // We check the vector of output times once at a time + // We check the vector of output times one at a time. Once the list of + // specific times is over, we do not check anymore. local_output_time = output_times_vector[output_times_counter]; if (local_output_time != -1) { - upper_bound = local_output_time; - lower_bound = local_output_time; + if (!no_more_output_times) + { + upper_bound = local_output_time; + lower_bound = local_output_time; + } + else // if no more output times, we do not output anymore + return false; } else // Case 3. Only a specific time interval is specified { @@ -364,16 +371,20 @@ SimulationControlTransient::is_output_iteration() // We always write one step after, in case the specific time or the // interval upper bound does not correspond exactly to a time iteration - // performed (due to in time step) + // performed (due to time step) if (current_time >= upper_bound && (previous_time < upper_bound)) { is_output_time = true; - if (local_output_time != -1 && - is_output_time) // Update specific time for case 2, only when we have - // written the upper bound + // Update specific time for case 2 once we have written the upper bound + if (local_output_time != -1 && is_output_time) { - output_times_counter++; + // Update the counter only if there are more elements in vector + if (output_times_vector.size() > output_times_counter + 1) + output_times_counter++; + else // otherwise set flag to false as no more times need to be + // checked + no_more_output_times = true; } } From 6c2848712d35bbfa082016a904207ecab54a95f5 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Fri, 8 Nov 2024 11:24:31 -0500 Subject: [PATCH 25/28] Update name of end time parameter in simulation control --- include/core/parameters.h | 2 +- source/core/parameters.cc | 6 +++--- source/core/simulation_control.cc | 2 +- tests/core/simulation_control_01.cc | 2 +- tests/core/simulation_control_02.cc | 2 +- tests/core/simulation_control_03.cc | 10 +++++----- tests/core/simulation_control_04.cc | 2 +- tests/core/simulation_control_05.cc | 2 +- tests/core/specific_heat_phase_change_01.cc | 2 +- tests/solvers/average_velocities_01.cc | 4 ++-- tests/solvers/average_velocities_02.cc | 4 ++-- tests/solvers/average_velocities_03.cc | 4 ++-- tests/solvers/reynolds_stress_01.cc | 4 ++-- tests/solvers/reynolds_stress_02.cc | 4 ++-- tests/solvers/reynolds_stress_03.cc | 4 ++-- 15 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/core/parameters.h b/include/core/parameters.h index 2f053e96dc..246556b934 100644 --- a/include/core/parameters.h +++ b/include/core/parameters.h @@ -94,7 +94,7 @@ namespace Parameters double dt; // End time - double timeEnd; + double time_end; // Boolean to keep the time step for the last iteration regardless of the // end time specify. Both for fixed time step and adaptive time step. diff --git a/source/core/parameters.cc b/source/core/parameters.cc index add539579f..12c3240cb7 100644 --- a/source/core/parameters.cc +++ b/source/core/parameters.cc @@ -238,9 +238,9 @@ namespace Parameters { std::runtime_error("Invalid output control scheme"); } - dt = prm.get_double("time step"); - timeEnd = prm.get_double("time end"); - adapt = prm.get_bool("adapt"); + dt = prm.get_double("time step"); + time_end = prm.get_double("time end"); + adapt = prm.get_bool("adapt"); time_step_independent_of_end_time = prm.get_bool("time step independent of end time"); maxCFL = prm.get_double("max cfl"); diff --git a/source/core/simulation_control.cc b/source/core/simulation_control.cc index fe8c690564..670407f922 100644 --- a/source/core/simulation_control.cc +++ b/source/core/simulation_control.cc @@ -15,7 +15,7 @@ SimulationControl::SimulationControl(const Parameters::SimulationControl ¶m) , current_time(0) , time_step(param.dt) , initial_time_step(param.dt) - , end_time(param.timeEnd) + , end_time(param.time_end) , time_step_independent_of_end_time(param.time_step_independent_of_end_time) , iteration_number(0) , number_mesh_adapt(param.number_mesh_adaptation) diff --git a/tests/core/simulation_control_01.cc b/tests/core/simulation_control_01.cc index 576629d3ed..7af5789e64 100644 --- a/tests/core/simulation_control_01.cc +++ b/tests/core/simulation_control_01.cc @@ -22,7 +22,7 @@ test() simulationControlParameters.maxCFL = 99; simulationControlParameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulationControlParameters.timeEnd = 999; + simulationControlParameters.time_end = 999; simulationControlParameters.number_mesh_adaptation = 9; simulationControlParameters.output_name = "test"; simulationControlParameters.subdivision = 7; diff --git a/tests/core/simulation_control_02.cc b/tests/core/simulation_control_02.cc index 8f519be370..1dd25d757f 100644 --- a/tests/core/simulation_control_02.cc +++ b/tests/core/simulation_control_02.cc @@ -24,7 +24,7 @@ test() simulationControlParameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulationControlParameters.timeEnd = 999; + simulationControlParameters.time_end = 999; simulationControlParameters.number_mesh_adaptation = 9; simulationControlParameters.output_name = "test"; simulationControlParameters.subdivision = 7; diff --git a/tests/core/simulation_control_03.cc b/tests/core/simulation_control_03.cc index 0f10f49a6b..ff022afa41 100644 --- a/tests/core/simulation_control_03.cc +++ b/tests/core/simulation_control_03.cc @@ -22,7 +22,7 @@ test() simulation_control_parameters.maxCFL = 2; simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulation_control_parameters.timeEnd = 0.5; + simulation_control_parameters.time_end = 0.5; simulation_control_parameters.output_control = Parameters::SimulationControl::OutputControl::iteration; simulation_control_parameters.output_iteration_frequency = 2; @@ -156,7 +156,7 @@ test() { simulation_control_parameters.adapt = true; - simulation_control_parameters.timeEnd = 20; + simulation_control_parameters.time_end = 20; simulation_control_parameters.dt = 1; simulation_control_parameters.adaptative_time_step_scaling = 1.2; simulation_control_parameters.maxCFL = 2; @@ -197,7 +197,7 @@ test() } { simulation_control_parameters.adapt = true; - simulation_control_parameters.timeEnd = 25; + simulation_control_parameters.time_end = 25; simulation_control_parameters.dt = 1; simulation_control_parameters.adaptative_time_step_scaling = 1.2; simulation_control_parameters.maxCFL = 2; @@ -239,7 +239,7 @@ test() { simulation_control_parameters.adapt = true; - simulation_control_parameters.timeEnd = 25; + simulation_control_parameters.time_end = 25; simulation_control_parameters.dt = 1; simulation_control_parameters.adaptative_time_step_scaling = 1.2; simulation_control_parameters.maxCFL = 2; @@ -281,7 +281,7 @@ test() { simulation_control_parameters.adapt = true; - simulation_control_parameters.timeEnd = 25; + simulation_control_parameters.time_end = 25; simulation_control_parameters.dt = 1; simulation_control_parameters.adaptative_time_step_scaling = 1.2; simulation_control_parameters.maxCFL = 2; diff --git a/tests/core/simulation_control_04.cc b/tests/core/simulation_control_04.cc index 2951a87ff0..c62cc2f205 100644 --- a/tests/core/simulation_control_04.cc +++ b/tests/core/simulation_control_04.cc @@ -25,7 +25,7 @@ test() Parameters::SimulationControl::TimeSteppingMethod::bdf1; simulation_control_parameters.time_step_independent_of_end_time = true; - simulation_control_parameters.timeEnd = 20; + simulation_control_parameters.time_end = 20; simulation_control_parameters.number_mesh_adaptation = 0; simulation_control_parameters.output_name = "test"; simulation_control_parameters.subdivision = 7; diff --git a/tests/core/simulation_control_05.cc b/tests/core/simulation_control_05.cc index 3568e8566c..022549947d 100644 --- a/tests/core/simulation_control_05.cc +++ b/tests/core/simulation_control_05.cc @@ -23,7 +23,7 @@ test() simulation_control_parameters.startup_timestep_scaling = 0.4; simulation_control_parameters.bdf_startup_method = Parameters::SimulationControl::BDFStartupMethods::multiple_step_bdf; - simulation_control_parameters.timeEnd = 4; + simulation_control_parameters.time_end = 4; simulation_control_parameters.number_mesh_adaptation = 0; simulation_control_parameters.output_name = "test"; simulation_control_parameters.subdivision = 7; diff --git a/tests/core/specific_heat_phase_change_01.cc b/tests/core/specific_heat_phase_change_01.cc index eb64ad2669..f77833ae84 100644 --- a/tests/core/specific_heat_phase_change_01.cc +++ b/tests/core/specific_heat_phase_change_01.cc @@ -44,7 +44,7 @@ test() simulationControlParameters.maxCFL = 99; simulationControlParameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; - simulationControlParameters.timeEnd = 999; + simulationControlParameters.time_end = 999; simulationControlParameters.number_mesh_adaptation = 9; simulationControlParameters.output_name = "test"; simulationControlParameters.subdivision = 7; diff --git a/tests/solvers/average_velocities_01.cc b/tests/solvers/average_velocities_01.cc index a21e3874d3..9dcf8a11dd 100644 --- a/tests/solvers/average_velocities_01.cc +++ b/tests/solvers/average_velocities_01.cc @@ -37,7 +37,7 @@ test() simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; simulation_control_parameters.dt = 0.1; - simulation_control_parameters.timeEnd = 1.0; + simulation_control_parameters.time_end = 1.0; simulation_control_parameters.adapt = false; simulation_control_parameters.time_step_independent_of_end_time = true; @@ -74,7 +74,7 @@ test() GlobalVectorType average_solution; // Time info - const double time_end = simulation_control_parameters.timeEnd; + const double time_end = simulation_control_parameters.time_end; const double initial_time = postprocessing_parameters.initial_time; double time = simulation_control->get_current_time(); double epsilon = 1e-6; diff --git a/tests/solvers/average_velocities_02.cc b/tests/solvers/average_velocities_02.cc index c0947eb22e..b0d7f7d9c5 100644 --- a/tests/solvers/average_velocities_02.cc +++ b/tests/solvers/average_velocities_02.cc @@ -39,7 +39,7 @@ test() simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; simulation_control_parameters.dt = 0.1; - simulation_control_parameters.timeEnd = 1.0; + simulation_control_parameters.time_end = 1.0; simulation_control_parameters.output_iteration_frequency = 1; simulation_control_parameters.adapt = true; simulation_control_parameters.adaptative_time_step_scaling = 0.95; @@ -84,7 +84,7 @@ test() GlobalBlockVectorType average_solution(locally_owned_dofs, mpi_communicator); // Time and output info - const double time_end = simulation_control_parameters.timeEnd; + const double time_end = simulation_control_parameters.time_end; const double initial_time = postprocessing_parameters.initial_time; double time = simulation_control->get_current_time(); double dt = 0.0; diff --git a/tests/solvers/average_velocities_03.cc b/tests/solvers/average_velocities_03.cc index cafac32523..f9b992e725 100644 --- a/tests/solvers/average_velocities_03.cc +++ b/tests/solvers/average_velocities_03.cc @@ -35,7 +35,7 @@ test() simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; simulation_control_parameters.dt = 0.1; - simulation_control_parameters.timeEnd = 1.0; + simulation_control_parameters.time_end = 1.0; simulation_control_parameters.adapt = false; simulation_control_parameters.time_step_independent_of_end_time = true; @@ -79,7 +79,7 @@ test() // average_solution.update_ghost_values(); // Time and output info - const double time_end = simulation_control_parameters.timeEnd; + const double time_end = simulation_control_parameters.time_end; const double initial_time = postprocessing_parameters.initial_time; double time = simulation_control->get_current_time(); const double epsilon = 1e-6; diff --git a/tests/solvers/reynolds_stress_01.cc b/tests/solvers/reynolds_stress_01.cc index 9c20b97bfe..84873ea01a 100644 --- a/tests/solvers/reynolds_stress_01.cc +++ b/tests/solvers/reynolds_stress_01.cc @@ -39,7 +39,7 @@ test() simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; simulation_control_parameters.dt = 0.1; - simulation_control_parameters.timeEnd = 1.0; + simulation_control_parameters.time_end = 1.0; simulation_control_parameters.adapt = false; simulation_control_parameters.time_step_independent_of_end_time = true; @@ -83,7 +83,7 @@ test() GlobalVectorType reynolds_shear_stresses; // Time info - const double time_end = simulation_control_parameters.timeEnd; + const double time_end = simulation_control_parameters.time_end; const double initial_time = postprocessing_parameters.initial_time; double time = simulation_control->get_current_time(); double epsilon = 1e-6; diff --git a/tests/solvers/reynolds_stress_02.cc b/tests/solvers/reynolds_stress_02.cc index ec212f6617..8f9adbdd10 100644 --- a/tests/solvers/reynolds_stress_02.cc +++ b/tests/solvers/reynolds_stress_02.cc @@ -40,7 +40,7 @@ test() simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; simulation_control_parameters.dt = 0.1; - simulation_control_parameters.timeEnd = 1.0; + simulation_control_parameters.time_end = 1.0; simulation_control_parameters.adapt = true; simulation_control_parameters.adaptative_time_step_scaling = 0.99; simulation_control_parameters.max_dt = 1e6; @@ -92,7 +92,7 @@ test() GlobalBlockVectorType reynolds_shear_stresses; // Time info - const double time_end = simulation_control_parameters.timeEnd; + const double time_end = simulation_control_parameters.time_end; const double initial_time = postprocessing_parameters.initial_time; double time = simulation_control->get_current_time(); double dt = 0.0; diff --git a/tests/solvers/reynolds_stress_03.cc b/tests/solvers/reynolds_stress_03.cc index dfbb83e28b..10a033459e 100644 --- a/tests/solvers/reynolds_stress_03.cc +++ b/tests/solvers/reynolds_stress_03.cc @@ -35,7 +35,7 @@ test() simulation_control_parameters.method = Parameters::SimulationControl::TimeSteppingMethod::bdf1; simulation_control_parameters.dt = 0.1; - simulation_control_parameters.timeEnd = 1.0; + simulation_control_parameters.time_end = 1.0; simulation_control_parameters.adapt = false; simulation_control_parameters.time_step_independent_of_end_time = true; @@ -81,7 +81,7 @@ test() LinearAlgebra::distributed::Vector reynolds_shear_stresses; // Time info - const double time_end = simulation_control_parameters.timeEnd; + const double time_end = simulation_control_parameters.time_end; const double initial_time = postprocessing_parameters.initial_time; double time = simulation_control->get_current_time(); double epsilon = 1e-6; From 3b74010d84255f7676b4715a5b0699a6ee98cbe4 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Fri, 8 Nov 2024 16:13:20 -0500 Subject: [PATCH 26/28] Initialize parameters in constructor --- include/core/simulation_control.h | 4 ++-- source/core/simulation_control.cc | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/core/simulation_control.h b/include/core/simulation_control.h index 18744e6b88..aab5311ca8 100644 --- a/include/core/simulation_control.h +++ b/include/core/simulation_control.h @@ -502,11 +502,11 @@ class SimulationControlTransient : public SimulationControl std::vector output_times_vector; // Counter to move between output times given in previous vector - unsigned int output_times_counter = 0; + unsigned int output_times_counter; // Variable to check whether we still have specific times to check in output // times vector - bool no_more_output_times = false; + bool no_more_output_times; // Time interval for output of transient iterations either with time output // control or iterations control diff --git a/source/core/simulation_control.cc b/source/core/simulation_control.cc index 670407f922..eaec8ec0b6 100644 --- a/source/core/simulation_control.cc +++ b/source/core/simulation_control.cc @@ -217,6 +217,8 @@ SimulationControlTransient::SimulationControlTransient( , max_dt(param.max_dt) , output_time_frequency(param.output_time_frequency) , output_times_vector(param.output_times_vector) + , output_times_counter(0) + , no_more_output_times(false) , output_time_interval(param.output_time_interval) , output_control(param.output_control) {} From 33cc7f9bd326d26d1494e640860da78b03802861 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Mon, 11 Nov 2024 09:16:35 -0500 Subject: [PATCH 27/28] Add changelog entry --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11ae9bd4d7..1b28877321 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to the Lethe project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/). +## [Master] - 2024-11-11 + +### Changed + +- MAJOR The time step in the simulation control class is no longer modified by default to be exactly the end time of the simulation. Moreover, the time step is no longer modified to output Paraview files at certain times, therefore, the time output for transient simulations was refactored. [#1336](https://github.com/chaos-polymtl/lethe/pull/1341) + ## [Master] - 2024-11-04 ### Changed @@ -19,7 +25,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/). - MINOR Force chains between local-ghost particle were being written multiple time when running in parallel. An arbitrary rule was added so that only one of the process is writing the force chain.[#1342](https://github.com/chaos-polymtl/lethe/pull/1342) - ### Fix - MINOR It was not possible to differentiate cohesive and repulsive forces with the force chains since the code was using the ".norm()" function. Now, the force chain calculation uses the scalar product between the normal force and the normal unit vector. [#1339](https://github.com/chaos-polymtl/lethe/pull/1339) From 67b96b1551366f4b013530d07df1a1863003ddb5 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra Date: Mon, 11 Nov 2024 11:02:29 -0500 Subject: [PATCH 28/28] write output times vector index when checkpointing --- include/core/simulation_control.h | 24 +++++++++++++-- source/core/simulation_control.cc | 50 ++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/include/core/simulation_control.h b/include/core/simulation_control.h index aab5311ca8..47f38c379e 100644 --- a/include/core/simulation_control.h +++ b/include/core/simulation_control.h @@ -457,7 +457,7 @@ class SimulationControl * * @param prefix The prefix of the checkpoint of the simulation */ - void + virtual void save(const std::string &prefix); /** @@ -465,7 +465,7 @@ class SimulationControl * * @param prefix The prefix of the checkpoint of the simulation */ - void + virtual void read(const std::string &prefix); /** @@ -551,6 +551,26 @@ class SimulationControlTransient : public SimulationControl */ virtual bool is_output_iteration() override; + + /** + * @brief Save the simulation control information from the checkpoint file and + * updates the time step vector, the CFL value, the time, the iteration number + * and the index of the output times vector if time control is used. + * + * @param prefix The prefix of the checkpoint of the simulation + */ + void + save(const std::string &prefix) override; + + /** + * @brief Reads the simulation control information from the checkpoint file and + * updates the time step vector, the CFL value, the time, the iteration number + * and the index of the output times vector if time control is used. + * + * @param prefix The prefix of the checkpoint of the simulation + */ + void + read(const std::string &prefix) override; }; /** diff --git a/source/core/simulation_control.cc b/source/core/simulation_control.cc index eaec8ec0b6..279378a1e7 100644 --- a/source/core/simulation_control.cc +++ b/source/core/simulation_control.cc @@ -369,7 +369,22 @@ SimulationControlTransient::is_output_iteration() // performed (due to time step) double next_time = current_time + calculate_time_step(); if (current_time < lower_bound && (next_time >= lower_bound)) - is_output_time = true; + { + is_output_time = true; + + // If the end time is exactly the output time, there is not one step + // after to output and we need to update the output times counter for + // case 2 + if (is_at_end() && local_output_time != -1 && is_output_time) + { + // Update the counter only if there are more elements in vector + if (output_times_vector.size() > output_times_counter + 1) + output_times_counter++; + else // otherwise set flag to false as no more times need to be + // checked + no_more_output_times = true; + } + } // We always write one step after, in case the specific time or the // interval upper bound does not correspond exactly to a time iteration @@ -393,6 +408,39 @@ SimulationControlTransient::is_output_iteration() return is_output_time; } +void +SimulationControlTransient::save(const std::string &prefix) +{ + SimulationControl::save(prefix); + + if (output_control == Parameters::SimulationControl::OutputControl::time) + { + std::string filename = prefix + ".simulationcontrol"; + std::ofstream output(filename.c_str(), std::ios::app); + output << "Output_index " << output_times_counter << std::endl; + } +} + +void +SimulationControlTransient::read(const std::string &prefix) +{ + SimulationControl::read(prefix); + + if (output_control == Parameters::SimulationControl::OutputControl::time) + { + std::string filename = prefix + ".simulationcontrol"; + std::ifstream input(filename.c_str()); + unsigned int line_no = 0; + std::string buffer; + while (line_no != 8) + { + std::getline(input, buffer); + line_no++; + } + input >> buffer >> output_times_counter; + } +} + SimulationControlTransientDEM::SimulationControlTransientDEM( const Parameters::SimulationControl ¶m) : SimulationControlTransient(param)