ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
FloodEngine Class Referenceabstract

A flood engine behind the shared coupling layer. More...

#include <ERF_FloodEngine.H>

Inheritance diagram for FloodEngine:

Public Member Functions

virtual ~FloodEngine ()=default
 
virtual const char * name () const =0
 Name of the engine, as erf.flood.engine selects it. More...
 
virtual void verify_prerequisites (const ERF &erf, int lev)=0
 Check the engine's own inputs against the ERF configuration. More...
 
virtual void initialize (const ERF &erf, int lev, const FloodGrid &fg, const amrex::MultiFab *z_phys_nd_atm)=0
 Set the engine up on the flood grid. More...
 
virtual void start_run (amrex::Real stop_time, int max_step, int steps_per_coarse_step)
 Start-up after initialize(), once the run's end is known. More...
 
virtual void advance (const FloodForcing &forcing)=0
 Advance the flood over one step of its level. More...
 
virtual bool wants_surface_precip () const
 The engine takes the surface precipitation in FloodForcing. More...
 
virtual void write_checkpoint (const std::string &checkpointname) const
 Write the engine's own state to the checkpoint directory. More...
 
virtual void read_checkpoint (const std::string &restart_chkfile, int step)
 Restore the engine's state from a checkpoint on a restart. More...
 
virtual void write_plotfile (const std::string &plotfile_prefix, amrex::Real time, int step) const
 Write the engine's plotfile of the flood grid. More...
 
virtual std::vector< std::string > plot_var_names () const
 Flood fields the ERF plotfile can carry, by name. More...
 
virtual const amrex::MultiFab * plot_var (const std::string &name) const
 The field plot_var_names() lists as name, on the flood grid. More...
 

Detailed Description

A flood engine behind the shared coupling layer.

The coupling calls, in this order:

Constructor & Destructor Documentation

◆ ~FloodEngine()

virtual FloodEngine::~FloodEngine ( )
virtualdefault

Member Function Documentation

◆ advance()

virtual void FloodEngine::advance ( const FloodForcing &  forcing)
pure virtual

Advance the flood over one step of its level.

Implemented in FloodEngineTemplate.

◆ initialize()

virtual void FloodEngine::initialize ( const ERF &  erf,
int  lev,
const FloodGrid &  fg,
const amrex::MultiFab *  z_phys_nd_atm 
)
pure virtual

Set the engine up on the flood grid.

Parameters
[in]erfERF instance (public AmrCore accessors only)
[in]levThe level the flood grid refines
[in]fgThe flood grid the coupling built
[in]z_phys_nd_atmNodal height of level lev [m]: the terrain the atmosphere sees, at k = 0

Implemented in FloodEngineTemplate.

◆ name()

virtual const char* FloodEngine::name ( ) const
pure virtual

Name of the engine, as erf.flood.engine selects it.

Implemented in FloodEngineTemplate.

Referenced by plot_var(), and read_checkpoint().

Here is the caller graph for this function:

◆ plot_var()

virtual const amrex::MultiFab* FloodEngine::plot_var ( const std::string &  name) const
inlinevirtual

The field plot_var_names() lists as name, on the flood grid.

One component, on FloodGrid::ba and FloodGrid::dm, valid until the next advance(). The coupler averages it over each atmospheric column (the grid_ratio^2 flood cells under it) and writes it into the k = 0 layer of the ERF plotfile, zero elsewhere. nullptr writes zeros.

Reimplemented in FloodEngineTemplate.

237  {
238  amrex::ignore_unused(name);
239  return nullptr;
240  }
virtual const char * name() const =0
Name of the engine, as erf.flood.engine selects it.
Here is the call graph for this function:

◆ plot_var_names()

virtual std::vector<std::string> FloodEngine::plot_var_names ( ) const
inlinevirtual

Flood fields the ERF plotfile can carry, by name.

The names the deck may list in erf.plot_vars_*. Each must start with "flood_" (the coupler stops otherwise), so they never collide with an ERF variable. The coupler asks once, when it is constructed, so the answer depends on the engine's inputs only. The default lists none.

Reimplemented in FloodEngineTemplate.

226 { return {}; }

◆ read_checkpoint()

virtual void FloodEngine::read_checkpoint ( const std::string &  restart_chkfile,
int  step 
)
inlinevirtual

Restore the engine's state from a checkpoint on a restart.

Called only when the checkpoint holds flood state (it was written with erf.flood.enable = true) and the coupling has checked that it belongs to this run's flood grid. A restart from a checkpoint without flood state (an atmosphere-only spin-up) skips this call, and the engine continues from its initial state.

Parameters
[in]restart_chkfileThe checkpoint directory
[in]stepThe step count of the flood grid's level at the checkpoint

The default stops the run: an engine that does not implement restart says so instead of continuing from its initial state.

Reimplemented in FloodEngineTemplate.

197  {
198  amrex::ignore_unused(restart_chkfile, step);
199  amrex::Abort(std::string("[FLOOD] flood engine \"") + name()
200  + "\" does not support restart from a checkpoint");
201  }
Here is the call graph for this function:

◆ start_run()

virtual void FloodEngine::start_run ( amrex::Real  stop_time,
int  max_step,
int  steps_per_coarse_step 
)
inlinevirtual

Start-up after initialize(), once the run's end is known.

Parameters
[in]stop_timeElapsed time at which the run stops [s], on the clock the engine's step times use (ERF's stop_time less start_time); numeric_limits<amrex::Real>::max() when no stop time is set
[in]max_stepERF's max_step, counting level-0 steps; numeric_limits<int>::max() when unset (never negative)
[in]steps_per_coarse_stepSteps of the flood grid's level per level-0 step

Reimplemented in FloodEngineTemplate.

153  {
154  amrex::ignore_unused(stop_time, max_step, steps_per_coarse_step);
155  }

◆ verify_prerequisites()

virtual void FloodEngine::verify_prerequisites ( const ERF &  erf,
int  lev 
)
pure virtual

Check the engine's own inputs against the ERF configuration.

Called once at start-up, after the coupling's checks of the grid (verify_flood_prerequisites) and before the flood grid is built. Aborts, naming the input, on a configuration the engine cannot run.

Parameters
[in]erfERF instance (public AmrCore accessors only)
[in]levThe level the flood grid refines

Implemented in FloodEngineTemplate.

◆ wants_surface_precip()

virtual bool FloodEngine::wants_surface_precip ( ) const
inlinevirtual

The engine takes the surface precipitation in FloodForcing.

True by default: the coupling then stops at start-up unless the microphysics scheme accumulates surface precipitation. An engine driven by other sources only (an inflow hydrograph) returns false.

Reimplemented in FloodEngineTemplate.

167 { return true; }

◆ write_checkpoint()

virtual void FloodEngine::write_checkpoint ( const std::string &  checkpointname) const
inlinevirtual

Write the engine's own state to the checkpoint directory.

Everything the engine carries from one step to the next, under checkpointname/Level_<lev>/ of the flood grid's level. The default writes nothing; such an engine cannot restart (read_checkpoint).

Reimplemented in FloodEngineTemplate.

177  {
178  amrex::ignore_unused(checkpointname);
179  }

◆ write_plotfile()

virtual void FloodEngine::write_plotfile ( const std::string &  plotfile_prefix,
amrex::Real  time,
int  step 
) const
inlinevirtual

Write the engine's plotfile of the flood grid.

Parameters
[in]plotfile_prefixerf.flood.plot_file (the step is appended)
[in]timeSimulation time [s]
[in]stepLevel-0 step number

The default writes nothing (the engine's fields may still reach the ERF plotfile through plot_var_names()).

Reimplemented in FloodEngineTemplate.

214  {
215  amrex::ignore_unused(plotfile_prefix, time, step);
216  }

The documentation for this class was generated from the following file: