ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_FloodEngine.H File Reference

The interface between the flood coupling and a flood engine. More...

#include <AMReX.H>
#include <AMReX_MultiFab.H>
#include <AMReX_REAL.H>
#include <string>
#include <vector>
#include <ERF_FloodGrid.H>
Include dependency graph for ERF_FloodEngine.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  FloodForcing
 The atmospheric state a flood engine reads for one step. More...
 
class  FloodEngine
 A flood engine behind the shared coupling layer. More...
 

Detailed Description

The interface between the flood coupling and a flood engine.

A flood engine is a surface-water model (shallow water, a runoff or routing model) that runs on the flood grid and takes the atmosphere's surface precipitation as its source. The shared coupling layer (FloodCoupler) owns everything that touches the atmosphere: the flood grid's placement on one level, the precipitation of each step taken from the microphysics accumulators, the wind handed to the engine, the engine's fields in the ERF plotfile and the check that a restart uses the same flood grid. An engine sees only this interface, FloodForcing and the helpers of ERF_FloodGrid.H.

The flood coupling is one-way in this version: the engine reads the atmosphere and returns nothing to it.

ERF itself contains no engine. An engine lives in its own directory outside ERF (FLOOD_HOME in GNU make, ERF_FLOOD_ENGINE_DIRS in CMake) and registers itself with ERF_REGISTER_FLOOD_ENGINE (ERF_FloodEngineRegistry.H). ERF_FloodEngineTemplate.H declares every method below for new engines: a method added to FloodEngine is declared there too (a pure virtual one that is missing fails the build; an optional one does not).

Memory contract. Every MultiFab the coupling hands an engine (FloodForcing, the FloodGrid layout) and every one the engine hands back (plot_var) is an ordinary AMReX MultiFab in the default arena, so on a GPU build its data is on the device. An engine that runs on the host:

  • copies what it reads from FloodForcing to the host inside advance(), because those fields are temporaries of that call, and synchronizes the GPU stream (amrex::Gpu::streamSynchronize()) before it reads them there;
  • owns the MultiFabs it returns, allocated on fg.ba and fg.dm, keeps them alive until its next advance(), and copies them back to device memory before returning them. The coupling never frees, resizes or keeps across steps a pointer an engine returns.