|
ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
|
#include <ERF_FloodCoupler.H>

Public Member Functions | |
| FloodCoupler (const FloodCouplingParams ¶ms, std::unique_ptr< FloodEngine > engine) | |
| void | initialize (const ERF &erf, int lev, const amrex::MultiFab *z_phys_nd_atm) |
| Check the configuration, build the flood grid and set the engine up. More... | |
| void | set_flood_grid (int lev, const FloodGrid &fg, const amrex::BoxArray &ba_atm, const amrex::DistributionMapping &dm_atm, const amrex::Geometry &geom_atm) |
| Lay the coupling out on a flood grid: what initialize() does after its start-up checks and before it sets the engine up. More... | |
| void | set_precip_reference (const SurfacePrecipAccumulationSources &precip_sources) |
| Take the current surface precipitation accumulation as the reference the next step's precipitation is measured from. More... | |
| void | advance (double time, double dt, const amrex::MultiFab &xvel, const amrex::MultiFab &yvel, const amrex::MultiFab &z_phys_cc, const SurfacePrecipAccumulationSources &precip_sources) |
| Advance the flood one step of its level. More... | |
| void | write_checkpoint (const std::string &checkpointname) const |
| Write the flood to a checkpoint: the engine's state (FloodEngine::write_checkpoint), then the flood grid's level, ratio and region in checkpointname/Level_<lev>/FloodGrid, and the precipitation reference in Level_<lev>/FloodPrecipRef, or in Level_<lev>/FloodPrecipRefIce for a scheme whose cloud ice counts as frozen (SurfacePrecipAccumulationSources::rest_is_frozen) More... | |
| std::string | checkpoint_mismatch (int chk_lev, int chk_ratio, const amrex::Box &chk_region) const |
| Why a checkpoint's flood state does not belong to this run's flood grid, or an empty string when it does. More... | |
| void | read_checkpoint (const std::string &restart_chkfile, int step) |
| Restore the engine's state on a restart. More... | |
| const std::vector< std::string > & | plot_var_names () const |
| Flood fields the ERF plotfile can carry (FloodEngine::plot_var_names(), read at construction). More... | |
| void | fill_plot_var (const std::string &name, amrex::MultiFab &dst, int dcomp, int lev) const |
| Fill component dcomp of an ERF plotfile MultiFab of level lev with the flood field name. More... | |
| int | level () const |
| The level the flood grid refines (erf.flood.anchor_level, resolved at initialize). More... | |
| const FloodCouplingParams & | params () const |
| The coupling inputs. More... | |
| FloodEngine & | engine () |
| The flood engine. More... | |
| const FloodEngine & | engine () const |
| const FloodGrid & | flood_grid () const |
| The flood grid. More... | |
| double | fields_time () const |
| The time the engine's fields belong to [s], in ERF's double time. More... | |
| void | set_fields_time (double t) |
| Set fields_time() to t [s] (ERF only: start-up, restart, end of a coarser step). More... | |
Private Member Functions | |
| std::string | precip_ref_name () const |
Private Attributes | |
| FloodCouplingParams | m_params |
| std::unique_ptr< FloodEngine > | m_engine |
| FloodGrid | m_fg |
| int | m_lev = 0 |
| bool | m_grid_set = false |
| amrex::Geometry | m_geom_atm |
| geometry of the flood grid's level More... | |
| amrex::BoxArray | m_ba_cols |
| the k = 0 slab of each box of the level More... | |
| amrex::DistributionMapping | m_dm_cols |
| their owners (the level's) More... | |
| double | m_fields_time = 0.0 |
| std::unique_ptr< amrex::MultiFab > | m_precip_prev |
| bool | m_precip_rest_frozen = false |
| The sources' rest_is_frozen at set_precip_reference(): which split the reference holds. More... | |
| std::vector< std::string > | m_plot_var_names |
| FloodCoupler::FloodCoupler | ( | const FloodCouplingParams & | params, |
| std::unique_ptr< FloodEngine > | engine | ||
| ) |
| [in] | params | The coupling inputs (FloodCouplingParams::read()) |
| [in] | engine | The flood engine erf.flood.engine selects |
Aborts when the engine lists a plot field whose name does not start with "flood_" or lists a name twice.

| void FloodCoupler::advance | ( | double | time, |
| double | dt, | ||
| const amrex::MultiFab & | xvel, | ||
| const amrex::MultiFab & | yvel, | ||
| const amrex::MultiFab & | z_phys_cc, | ||
| const SurfacePrecipAccumulationSources & | precip_sources | ||
| ) |
Advance the flood one step of its level.
Called from ERF::Advance() once per step of the flood grid's level, after that level's dycore and microphysics.
| [in] | time | Start of the step [s] |
| [in] | dt | Step of the level [s], ERF's double dt[lev]: fields_time() becomes time + dt, the time ERF assigns to the level |
| [in] | xvel,yvel | Face velocities after the dycore [m/s] |
| [in] | z_phys_cc | Cell-center height of the level [m] |
| [in] | precip_sources | The microphysics surface precipitation accumulators of the level |

| std::string FloodCoupler::checkpoint_mismatch | ( | int | chk_lev, |
| int | chk_ratio, | ||
| const amrex::Box & | chk_region | ||
| ) | const |
Why a checkpoint's flood state does not belong to this run's flood grid, or an empty string when it does.
| [in] | chk_lev | The level the checkpoint's flood grid refines |
| [in] | chk_ratio | Its grid ratio |
| [in] | chk_region | The atmospheric columns it covers |
Referenced by read_checkpoint().


|
inline |
The flood engine.
|
inline |
|
inline |
| void FloodCoupler::fill_plot_var | ( | const std::string & | name, |
| amrex::MultiFab & | dst, | ||
| int | dcomp, | ||
| int | lev | ||
| ) | const |
Fill component dcomp of an ERF plotfile MultiFab of level lev with the flood field name.
On the flood grid's level, the k = 0 cell of each column holds the mean of the engine's field over the flood cells under it; every other cell, every other level and a field the engine returns as nullptr hold zero.

| void FloodCoupler::initialize | ( | const ERF & | erf, |
| int | lev, | ||
| const amrex::MultiFab * | z_phys_nd_atm | ||
| ) |
Check the configuration, build the flood grid and set the engine up.
Called once from ERF::InitData_post(), on a fresh start and on a restart alike. Runs the coupling's checks (verify_flood_prerequisites), then the engine's, builds the flood grid on level lev and initializes the engine.
| [in] | erf | ERF instance (public AmrCore accessors only) |
| [in] | lev | The level the flood grid refines (flood_anchor_level) |
| [in] | z_phys_nd_atm | Nodal height of level lev [m] |

|
inline |
The level the flood grid refines (erf.flood.anchor_level, resolved at initialize).
|
inline |
The coupling inputs.
|
inline |
Flood fields the ERF plotfile can carry (FloodEngine::plot_var_names(), read at construction).
|
inlineprivate |
The checkpoint name of the reference. Before the cloud ice of WSM6 and WDM6 counted as frozen, their reference had it in the liquid part, under FloodPrecipRef.
Referenced by read_checkpoint(), and write_checkpoint().

| void FloodCoupler::read_checkpoint | ( | const std::string & | restart_chkfile, |
| int | step | ||
| ) |
Restore the engine's state on a restart.
A checkpoint written with a flood engine holds Level_<lev>/FloodGrid: the coupler aborts when it names another level, ratio or region than this run, and otherwise calls FloodEngine::read_checkpoint. A checkpoint without it (an atmosphere-only spin-up) leaves the engine in its initial state, said once.
| [in] | restart_chkfile | The checkpoint directory |
| [in] | step | The step count of the flood grid's level at the checkpoint |

|
inline |
Set fields_time() to t [s] (ERF only: start-up, restart, end of a coarser step).
| void FloodCoupler::set_flood_grid | ( | int | lev, |
| const FloodGrid & | fg, | ||
| const amrex::BoxArray & | ba_atm, | ||
| const amrex::DistributionMapping & | dm_atm, | ||
| const amrex::Geometry & | geom_atm | ||
| ) |
Lay the coupling out on a flood grid: what initialize() does after its start-up checks and before it sets the engine up.
Takes the flood grid and the k = 0 slabs of ba_atm. Public so that a test can drive the coupling with an engine of its own without an ERF object.
| [in] | lev | The level the flood grid refines |
| [in] | fg | The flood grid (create_flood_grid) |
| [in] | ba_atm | The level's boxes, each spanning the level's height |
| [in] | dm_atm | Their owners |
| [in] | geom_atm | The level's geometry |
Referenced by initialize().

| void FloodCoupler::set_precip_reference | ( | const SurfacePrecipAccumulationSources & | precip_sources | ) |
Take the current surface precipitation accumulation as the reference the next step's precipitation is measured from.
Called once at start-up, after initialize(), when the engine reads the precipitation (FloodEngine::wants_surface_precip). On a fresh start the accumulators are zero; on a restart they hold the checkpoint's values, so the first restarted step hands the engine the same precipitation as the straight run.
| [in] | precip_sources | The microphysics surface precipitation accumulators of the level |

| void FloodCoupler::write_checkpoint | ( | const std::string & | checkpointname | ) | const |
Write the flood to a checkpoint: the engine's state (FloodEngine::write_checkpoint), then the flood grid's level, ratio and region in checkpointname/Level_<lev>/FloodGrid, and the precipitation reference in Level_<lev>/FloodPrecipRef, or in Level_<lev>/FloodPrecipRefIce for a scheme whose cloud ice counts as frozen (SurfacePrecipAccumulationSources::rest_is_frozen)

|
private |
the k = 0 slab of each box of the level
Referenced by advance(), checkpoint_mismatch(), fill_plot_var(), set_flood_grid(), set_precip_reference(), and write_checkpoint().
|
private |
their owners (the level's)
Referenced by advance(), fill_plot_var(), set_flood_grid(), and set_precip_reference().
|
private |
Referenced by advance(), engine(), fill_plot_var(), FloodCoupler(), initialize(), read_checkpoint(), and write_checkpoint().
|
private |
Referenced by checkpoint_mismatch(), fill_plot_var(), flood_grid(), initialize(), set_flood_grid(), and write_checkpoint().
|
private |
Referenced by advance(), fields_time(), and set_fields_time().
|
private |
geometry of the flood grid's level
Referenced by advance(), fill_plot_var(), set_flood_grid(), and set_precip_reference().
|
private |
Referenced by advance(), checkpoint_mismatch(), fill_plot_var(), read_checkpoint(), set_flood_grid(), set_precip_reference(), and write_checkpoint().
|
private |
Referenced by checkpoint_mismatch(), fill_plot_var(), level(), read_checkpoint(), set_flood_grid(), and write_checkpoint().
|
private |
Referenced by initialize(), and params().
|
private |
Referenced by FloodCoupler(), and plot_var_names().
|
private |
Liquid (0) and frozen (1) accumulation [kg/m2] at the end of the last step, on m_ba_cols; null until set_precip_reference()
Referenced by advance(), read_checkpoint(), set_flood_grid(), set_precip_reference(), and write_checkpoint().
|
private |
The sources' rest_is_frozen at set_precip_reference(): which split the reference holds.
Referenced by precip_ref_name(), and set_precip_reference().