ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_FloodEngineTemplate.H
Go to the documentation of this file.
1 #ifndef ERF_FLOOD_ENGINE_TEMPLATE_H
2 #define ERF_FLOOD_ENGINE_TEMPLATE_H
3 
4 #include <ERF_FloodEngine.H>
5 
6 /**
7  * @file ERF_FloodEngineTemplate.H
8  * @brief A starting point for a new flood engine: declarations only
9  *
10  * This class declares every FloodEngine method a new flood model provides.
11  * Nothing here has a body, no input selects it and nothing creates one, so it
12  * adds no code to ERF. Tests/FloodEngineExample is the smallest engine that
13  * works, and a complete engine directory to copy.
14  *
15  * To start a new engine:
16  * 1. Copy this file into the new model's engine directory (outside ERF),
17  * rename the class and the include guard, and write the bodies in a .cpp
18  * file there. Delete the declarations of the optional methods the engine
19  * does not provide (their defaults in FloodEngine then apply); a
20  * declaration left without a body fails to link.
21  * 2. Read the model's inputs under its own prefix (flood.<engine>.* is
22  * recommended), so they never mix with the coupling's keys
23  * (FloodCouplingParams, erf.flood.*) or another engine's.
24  * 3. Register the engine in that .cpp, at namespace scope:
25  * ERF_REGISTER_FLOOD_ENGINE(MyEngine, "my_flood")
26  * (ERF_FloodEngineRegistry.H), and give the engine directory a
27  * Make.package (GNU make, FLOOD_HOME) and an ERFFloodEngine.cmake defining
28  * erf_flood_engine_add(target) (CMake, ERF_FLOOD_ENGINE_DIRS).
29  * 4. Run a restart of a coupled run against a straight run: the atmosphere
30  * and flood plotfiles must agree at zero tolerance.
31  *
32  * The call order is the one documented on FloodEngine (ERF_FloodEngine.H).
33  * ERF_FloodCoupler.cpp checks at compile time that this class declares every
34  * method FloodEngine requires (the pure virtual ones), and override checks the
35  * signature of every method declared here. The optional methods are listed by
36  * hand: a new optional method in FloodEngine is added here too.
37  */
39 {
40 public:
41  /// The name erf.flood.engine selects this engine by, for example "my_flood".
42  const char* name () const override;
43 
44  /**
45  * Check the engine's own inputs against the ERF configuration, once at
46  * start-up, before the flood grid is built. Abort naming the input on
47  * anything the engine cannot run (a missing terrain file, a grid ratio it
48  * does not support).
49  */
50  void verify_prerequisites (const ERF& erf, int lev) override;
51 
52  /**
53  * Allocate the engine's fields on fg.ba and fg.dm and set its initial
54  * state. z_phys_nd_atm is the terrain the atmosphere sees.
55  */
56  void initialize (const ERF& erf, int lev, const FloodGrid& fg,
57  const amrex::MultiFab* z_phys_nd_atm) override;
58 
59  /// Optional: the run's end, once known (stop time, max_step, substeps).
60  void start_run (amrex::Real stop_time, int max_step, int steps_per_coarse_step) override;
61 
62  /**
63  * Advance over [forcing.time, forcing.time + forcing.dt]. forcing.precip_k0
64  * holds this step's liquid and frozen precipitation per atmospheric column
65  * [kg/m2]; fill_flood_from_atm_k0 (ERF_FloodGrid.H) copies a component onto
66  * the flood grid.
67  */
68  void advance (const FloodForcing& forcing) override;
69 
70  /// Optional: false for an engine that reads no precipitation (default true).
71  bool wants_surface_precip () const override;
72 
73  /// Optional: the engine's state under checkpointname/Level_<lev>/.
74  void write_checkpoint (const std::string& checkpointname) const override;
75 
76  /// Optional: restore what write_checkpoint wrote (the default aborts).
77  void read_checkpoint (const std::string& restart_chkfile, int step) override;
78 
79  /// Optional: the engine's own plotfile of the flood grid.
80  void write_plotfile (const std::string& plotfile_prefix, amrex::Real time, int step) const override;
81 
82  /// Optional: fields for the ERF plotfile, each named "flood_...".
83  std::vector<std::string> plot_var_names () const override;
84 
85  /// Optional: the field plot_var_names() lists as name, on the flood grid.
86  const amrex::MultiFab* plot_var (const std::string& name) const override;
87 };
88 
89 #endif
The interface between the flood coupling and a flood engine.
Definition: ERF_FloodEngineTemplate.H:39
void verify_prerequisites(const ERF &erf, int lev) override
void write_plotfile(const std::string &plotfile_prefix, amrex::Real time, int step) const override
Optional: the engine's own plotfile of the flood grid.
void write_checkpoint(const std::string &checkpointname) const override
Optional: the engine's state under checkpointname/Level_<lev>/.
const amrex::MultiFab * plot_var(const std::string &name) const override
Optional: the field plot_var_names() lists as name, on the flood grid.
void initialize(const ERF &erf, int lev, const FloodGrid &fg, const amrex::MultiFab *z_phys_nd_atm) override
void read_checkpoint(const std::string &restart_chkfile, int step) override
Optional: restore what write_checkpoint wrote (the default aborts).
void start_run(amrex::Real stop_time, int max_step, int steps_per_coarse_step) override
Optional: the run's end, once known (stop time, max_step, substeps).
void advance(const FloodForcing &forcing) override
bool wants_surface_precip() const override
Optional: false for an engine that reads no precipitation (default true).
std::vector< std::string > plot_var_names() const override
Optional: fields for the ERF plotfile, each named "flood_...".
const char * name() const override
The name erf.flood.engine selects this engine by, for example "my_flood".
A flood engine behind the shared coupling layer.
Definition: ERF_FloodEngine.H:109
Definition: ERF_InterpolationUtils.H:15
@ fg
Definition: ERF_AdvanceMorrison.cpp:111
The atmospheric state a flood engine reads for one step.
Definition: ERF_FloodEngine.H:62
2D horizontal flood grid
Definition: ERF_FloodGrid.H:42