Skip to content
New issue

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

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

Already on GitHub? # to your account

Make Waves2AMR routines deterministic by default #1143

Merged
merged 5 commits into from
Jul 22, 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
21 changes: 19 additions & 2 deletions amr-wind/ocean_waves/relaxation_zones/waves2amr_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ struct ReadInputsOp<W2AWaves>
pp.query("HOS_init_time", wdata.t_winit);
}

// Default fftw_plan is deterministic
std::string fftw_planner_flag{"estimate"};
pp.query("fftw_planner_flag", fftw_planner_flag);

amrex::Vector<amrex::Real> prob_lo_input(AMREX_SPACEDIM);
amrex::ParmParse pp_geom("geometry");
pp_geom.getarr("prob_lo", prob_lo_input);
Expand Down Expand Up @@ -300,9 +304,22 @@ struct ReadInputsOp<W2AWaves>
wdata.v_mptr = modes_hosgrid::allocate_complex(wdata.n0, wdata.n1);
wdata.w_mptr = modes_hosgrid::allocate_complex(wdata.n0, wdata.n1);

// Set up planner flag based on input
auto plan_f = modes_hosgrid::planner_flags::estimate;
if (fftw_planner_flag == "patient") {
plan_f = modes_hosgrid::planner_flags::patient;
} else if (fftw_planner_flag == "exhaustive") {
plan_f = modes_hosgrid::planner_flags::exhaustive;
} else if (fftw_planner_flag == "measure") {
plan_f = modes_hosgrid::planner_flags::measure;
} else if (!(fftw_planner_flag == "estimate")) {
amrex::Print()
<< "WARNING (waves2amr_ops): invalid fftw_planner_flag "
"specified; defaulting to estimate (FFTW_ESTIMATE).\n";
}
// Set up plan for FFTW
wdata.plan =
modes_hosgrid::plan_ifftw(wdata.n0, wdata.n1, wdata.eta_mptr);
wdata.plan = modes_hosgrid::plan_ifftw(
wdata.n0, wdata.n1, wdata.eta_mptr, plan_f);

// Create height vector for velocity mode conversion before
// interpolation, with prob_lo as bottom
Expand Down
11 changes: 11 additions & 0 deletions docs/sphinx/user/inputs_ocean_waves.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ The following input arguments are only valid for the W2AWaves wave type:
This argument is only active if HOS_init_timestep is omitted. AMR-Wind will pick the
time step in the modes closest to the specified time.

.. input_param:: OceanWaves.label.fftw_planner_flag

**type:** String, optional, default = estimate

When setting up a plan for the inverse Fourier transform within the Waves2AMR library,
the FFTW algorithm can use different techniques to choose among available methods. Some of these
are faster than others, and the optimal choice can also depend on the architecture. The
default, "estimate", which corresponds to FFTW_ESTIMATE, is deterministic. The other
options are "exhaustive", "patient", and "measure". Variations from nondeterministic
approaches are tiny, on the order of machine precision.

.. input_param:: OceanWaves.label.number_interp_points_in_z

**type:** Integer, mandatory
Expand Down
2 changes: 1 addition & 1 deletion submods/Waves2AMR