From 128e8ce6ef61efcf997941d46f6873b1d5343af1 Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Mon, 14 Oct 2024 10:00:55 -0600 Subject: [PATCH 1/3] Add dry run capability --- amr-wind/incflo.H | 4 ++++ amr-wind/incflo.cpp | 8 ++++++-- amr-wind/setup/init.cpp | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/amr-wind/incflo.H b/amr-wind/incflo.H index dc8174c4b6..406af2077e 100644 --- a/amr-wind/incflo.H +++ b/amr-wind/incflo.H @@ -174,6 +174,9 @@ private: // Prescribe advection velocity bool m_prescribe_vel = false; + // Perform a dry run (0 steps, output plotfile) + bool m_dry_run = false; + // Fixed point iterations every timestep int m_fixed_point_iterations{1}; @@ -204,6 +207,7 @@ private: // /////////////////////////////////////////////////////////////////////////// + void CheckAndSetUpDryRun(); void ReadParameters(); void InitialProjection(); void InitialIterations(); diff --git a/amr-wind/incflo.cpp b/amr-wind/incflo.cpp index fbcfa4b656..2bfaa16e30 100644 --- a/amr-wind/incflo.cpp +++ b/amr-wind/incflo.cpp @@ -23,8 +23,11 @@ incflo::incflo() // constructor. No valid BoxArray and DistributionMapping have been defined. // But the arrays for them have been resized. + // Check if dry run is requested and set up if so + CheckAndSetUpDryRun(); + + // Read top-level parameters using ParmParse m_time.parse_parameters(); - // Read inputs file using ParmParse ReadParameters(); init_physics_and_pde(); @@ -124,7 +127,8 @@ void incflo::prepare_for_time_integration() { BL_PROFILE("amr-wind::incflo::prepare_for_time_integration"); // Don't perform initial work if this is a restart - if (m_sim.io_manager().is_restart()) { + // but still need to write plot file for dry run of restart + if (m_sim.io_manager().is_restart() && !m_dry_run) { return; } diff --git a/amr-wind/setup/init.cpp b/amr-wind/setup/init.cpp index 5ad166e110..1138aae36f 100644 --- a/amr-wind/setup/init.cpp +++ b/amr-wind/setup/init.cpp @@ -10,6 +10,38 @@ using namespace amrex; +void incflo::CheckAndSetUpDryRun() +{ + // Check if dry run is requested; exit if not + { + ParmParse pp("incflo"); + pp.query("dry_run", m_dry_run); + if (!m_dry_run) { + return; + } + } + // Disable additional computations associated with initialization + { + ParmParse pp("incflo"); + pp.add("initial_iterations", (int)0); + pp.add("do_initial_proj", (bool)false); + } + // Zero time steps, write plotfile and not checkpoint + { + ParmParse pp("time"); + pp.add("max_step",(int)0); + pp.add("plot_interval", (int)1); + pp.add("checkpoint_inteval", (int)-1); + } + // Give prefix to plotfile + { + ParmParse pp("io"); + std::string current_plt{"plt"}; + pp.query("plot_file", current_plt); + pp.add("plot_file", (std::string) "dry_run_" + current_plt); + } +} + /** Parse the input file and populate parameters */ void incflo::ReadParameters() From 91be66d50f905e13909e692cd4348808d24bc7c5 Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Mon, 14 Oct 2024 10:08:46 -0600 Subject: [PATCH 2/3] formatting --- amr-wind/setup/init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amr-wind/setup/init.cpp b/amr-wind/setup/init.cpp index 1138aae36f..f4baec5098 100644 --- a/amr-wind/setup/init.cpp +++ b/amr-wind/setup/init.cpp @@ -29,7 +29,7 @@ void incflo::CheckAndSetUpDryRun() // Zero time steps, write plotfile and not checkpoint { ParmParse pp("time"); - pp.add("max_step",(int)0); + pp.add("max_step", (int)0); pp.add("plot_interval", (int)1); pp.add("checkpoint_inteval", (int)-1); } From 241e6a84bfba84a6f27726a93d092477e71e9559 Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Mon, 14 Oct 2024 13:40:44 -0600 Subject: [PATCH 3/3] dry run noted in documentation (input file reference) --- docs/sphinx/user/inputs_incflo.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/sphinx/user/inputs_incflo.rst b/docs/sphinx/user/inputs_incflo.rst index ab18572887..0b1d2114f6 100644 --- a/docs/sphinx/user/inputs_incflo.rst +++ b/docs/sphinx/user/inputs_incflo.rst @@ -69,6 +69,16 @@ as initial conditions and discretization options. Godunov the default approach and has many advantages over the method of lines (MOL): better accuracy, stability at larger CFL numbers, and greater computational efficiency. Setting this argument to false is not recommended, and active use or development relying on the method of lines (MOL) is very sparse. + +.. input_param:: incflo.dry_run + + **type** Boolean, optional, default = false + + Setting this option to true enables a "dry run" of the code. This is intended for checking if an input + file is set up properly and for investigating the initial state of a simulation. A dry run will make sure + that initial iterations and the initial projection are skipped, and it will complete no time steps. This is + to minimize the computational demands of such a run. A plot file with the prefix ``dry_run`` will be output + regardless of whether the simulation restarts from a checkpoint file or from scratch. .. _inputs_incflo_advection: