Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dry run capability #1286

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions amr-wind/incflo.H
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -204,6 +207,7 @@ private:
//
///////////////////////////////////////////////////////////////////////////

void CheckAndSetUpDryRun();
void ReadParameters();
void InitialProjection();
void InitialIterations();
Expand Down
8 changes: 6 additions & 2 deletions amr-wind/incflo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}

Expand Down
32 changes: 32 additions & 0 deletions amr-wind/setup/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,38 @@

using namespace amrex;

void incflo::CheckAndSetUpDryRun()
marchdf marked this conversation as resolved.
Show resolved Hide resolved
{
// 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()
Expand Down
10 changes: 10 additions & 0 deletions docs/sphinx/user/inputs_incflo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down