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

Public Member Functions | |
| FireCoupler (const FireCouplingParams ¶ms, std::unique_ptr< FireEngine > engine) | |
| void | initialize (const ERF &erf, int lev, const SurfaceLayer *surface_layer, const amrex::MultiFab *z_phys_nd_atm) |
| Check the configuration, build the fire grid and set the engine up. More... | |
| void | set_fire_grid (int lev, const FireGrid &fg, const amrex::BoxArray &ba_atm, const amrex::DistributionMapping &dm_atm, const amrex::Geometry &geom_atm) |
| Lay the coupling out on a fire grid: what initialize() does after its start-up checks and before it sets the engine up. More... | |
| void | advance (double time, double dt, const amrex::MultiFab &S_old, const amrex::MultiFab &xvel_old, const amrex::MultiFab &yvel_old, const amrex::MultiFab &xvel_new, const amrex::MultiFab &yvel_new, const amrex::MultiFab &z_phys_cc, const amrex::BoxArray &ba2d, const amrex::Geometry &geom, const SurfacePrecipAccumulationSources &precip_sources) |
| Advance the fire one step of its level and refill the lagged fluxes. More... | |
| void | add_sources (amrex::MultiFab &cc_source, const amrex::MultiFab &S_old, const amrex::MultiFab &z_phys_cc, const amrex::MultiFab *z_phys_nd, const amrex::Geometry &geom, bool has_moisture, int step) |
| Inject the lagged fire heat, vapor and smoke into the cell sources. More... | |
| void | write_checkpoint (const std::string &checkpointname) const |
| Write the fire to a checkpoint: the engine's state (FireEngine::write_checkpoint), then the coupling's lagged fluxes (FireQAtmPrev and FireQLatAtmPrev) under checkpointname/Level_<lev>/. More... | |
| std::string | checkpoint_mismatch (int chk_lev, const amrex::Box &chk_region) const |
| Why a checkpoint's lagged fluxes do not belong to this run's fire grid, or an empty string when they do. More... | |
| void | read_checkpoint (const std::string &restart_chkfile, int max_level, int step) |
| Restore the engine's state, then the lagged fluxes, on a restart. More... | |
| const std::vector< std::string > & | plot_var_names () const |
| 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 fire field name. More... | |
| int | level () const |
| The level the fire grid refines (erf.fire.anchor_level, resolved at initialize). More... | |
| const FireCouplingParams & | params () const |
| The coupling inputs. More... | |
| FireEngine & | engine () |
| The fire engine. More... | |
| const FireEngine & | engine () const |
| const FireGrid & | fire_grid () const |
| The fire 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... | |
| const amrex::MultiFab * | get_Q_atm_prev () const |
| Sensible heat flux [W/m2] of the previous fire step on the atmospheric columns of the fire grid's level, with 5 ghost columns (for a reader that samples a halo around each tile, such as a boundary-layer scheme taking the fire's heat into its mixing); zero outside the fire region. Allocated at initialize, so never null afterwards. More... | |
| const amrex::MultiFab * | get_Q_lat_atm_prev () const |
| Latent heat flux [W/m2] of the previous fire step, laid out as get_Q_atm_prev(). More... | |
Private Member Functions | |
| void | update_flux_buffer (const amrex::Geometry &geom_atm) |
| Average the engine's fluxes onto the atmospheric columns for the next step. More... | |
Private Attributes | |
| FireCouplingParams | m_params |
| std::unique_ptr< FireEngine > | m_engine |
| FireGrid | m_fg |
| int | m_lev = 0 |
| amrex::Geometry | m_geom_atm |
| geometry of the fire grid's level More... | |
| double | m_fields_time = 0.0 |
| the time the engine's fields belong to (fields_time()) More... | |
| std::unique_ptr< amrex::MultiFab > | m_Q_atm_prev |
| sensible [W/m2] More... | |
| std::unique_ptr< amrex::MultiFab > | m_Q_lat_atm_prev |
| latent [W/m2] More... | |
| std::vector< std::string > | m_plot_var_names |
| FireEngine::plot_var_names(), read at construction. More... | |
| FireCoupler::FireCoupler | ( | const FireCouplingParams & | params, |
| std::unique_ptr< FireEngine > | engine | ||
| ) |
| [in] | params | The coupling inputs (FireCouplingParams::read()) |
| [in] | engine | The fire engine erf.fire.engine selects |

| void FireCoupler::add_sources | ( | amrex::MultiFab & | cc_source, |
| const amrex::MultiFab & | S_old, | ||
| const amrex::MultiFab & | z_phys_cc, | ||
| const amrex::MultiFab * | z_phys_nd, | ||
| const amrex::Geometry & | geom, | ||
| bool | has_moisture, | ||
| int | step | ||
| ) |
Inject the lagged fire heat, vapor and smoke into the cell sources.
Called from the slow right-hand side at every Runge-Kutta stage on the fire grid's level, after make_sources has rebuilt cc_source. The lagged fluxes are fixed over the step, so every stage receives the same tendency (erf.fire.source_mode decides whether it replaces or adds to the theta and vapor sources). Heat and vapor only with lagged or synchronous coupling; smoke with erf.fire.smoke_enable.
| [in,out] | cc_source | Cell-centered sources of the level |
| [in] | S_old | Conserved state at the start of the step (density) |
| [in] | z_phys_cc | Cell-center height [m] |
| [in] | z_phys_nd | Nodal height [m] (ERF always passes it): the cell thickness and roof datum of the heat, and the smoke cell's thickness |
| [in] | geom | Geometry of the level |
| [in] | has_moisture | The vapor source exists |
| [in] | step | Step of the level, for the debug output |

| void FireCoupler::advance | ( | double | time, |
| double | dt, | ||
| const amrex::MultiFab & | S_old, | ||
| const amrex::MultiFab & | xvel_old, | ||
| const amrex::MultiFab & | yvel_old, | ||
| const amrex::MultiFab & | xvel_new, | ||
| const amrex::MultiFab & | yvel_new, | ||
| const amrex::MultiFab & | z_phys_cc, | ||
| const amrex::BoxArray & | ba2d, | ||
| const amrex::Geometry & | geom, | ||
| const SurfacePrecipAccumulationSources & | precip_sources | ||
| ) |
Advance the fire one step of its level and refill the lagged fluxes.
Called from ERF::Advance() once per step of the fire grid's level, after that level's dycore. The air temperature and humidity at k = 0 come from the state before the dycore; the wind from before the dycore (passive and lagged coupling) or after it (synchronous).
| [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] | S_old | Conserved state before the dycore |
| [in] | xvel_old,yvel_old | Face velocities before the dycore [m/s] |
| [in] | xvel_new,yvel_new | Face velocities after the dycore [m/s] |
| [in] | z_phys_cc | Cell-center height of the level [m] |
| [in] | ba2d | The level's boxes coarsened to one cell in z |
| [in] | geom | Geometry of the level |
| [in] | precip_sources | The microphysics surface precipitation accumulators of the level |

| std::string FireCoupler::checkpoint_mismatch | ( | int | chk_lev, |
| const amrex::Box & | chk_region | ||
| ) | const |
Why a checkpoint's lagged fluxes do not belong to this run's fire grid, or an empty string when they do.
| [in] | chk_lev | The level the checkpoint holds them on |
| [in] | chk_region | The columns they cover (minimal box of their boxes) |
Referenced by read_checkpoint().


|
inline |
The fire engine.
|
inline |
|
inline |
The time the engine's fields belong to [s], in ERF's double time.
ERF sets it to the fire level's time at start-up and on a restart (set_fields_time), advance() to the end of the step, and ERF again to the coarser level's time once the finer levels' substeps have reached it, so that it equals the time ERF assigns to the level and carries no round-off from summing substeps.
| void FireCoupler::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 fire field name.
On the fire grid's level, the k = 0 cell of each column holds the mean of the engine's field (FireEngine::plot_var) over the fire cells under it; every other cell, every other level and a field the engine returns as nullptr hold zero.
| [in] | name | One of plot_var_names() |
| [out] | dst | Cell-centered MultiFab on the boxes of level lev |
| [in] | dcomp | Component of dst to fill |
| [in] | lev | The level dst belongs to |

|
inline |
Sensible heat flux [W/m2] of the previous fire step on the atmospheric columns of the fire grid's level, with 5 ghost columns (for a reader that samples a halo around each tile, such as a boundary-layer scheme taking the fire's heat into its mixing); zero outside the fire region. Allocated at initialize, so never null afterwards.
|
inline |
Latent heat flux [W/m2] of the previous fire step, laid out as get_Q_atm_prev().
| void FireCoupler::initialize | ( | const ERF & | erf, |
| int | lev, | ||
| const SurfaceLayer * | surface_layer, | ||
| const amrex::MultiFab * | z_phys_nd_atm | ||
| ) |
Check the configuration, build the fire grid and set the engine up.
Called once from ERF::InitData_post() after every surface layer exists. Runs the coupling's checks (verify_fire_prerequisites), then the engine's, builds the fire grid on level lev, allocates the lagged flux buffers (zero) and initializes the engine.
| [in] | erf | ERF instance (public AmrCore accessors only) |
| [in] | lev | The level the fire grid refines (fire_anchor_level) |
| [in] | surface_layer | The bottom surface layer, or nullptr (aborts when the engine needs one, FireEngine::needs_surface_layer) |
| [in] | z_phys_nd_atm | Nodal height of level lev [m] (ERF always passes it) |

|
inline |
The level the fire grid refines (erf.fire.anchor_level, resolved at initialize).
|
inline |
The coupling inputs.
|
inline |
Fire fields the ERF plotfile can carry (FireEngine::plot_var_names(), read at construction, before ERF reads erf.plot_vars_*).
| void FireCoupler::read_checkpoint | ( | const std::string & | restart_chkfile, |
| int | max_level, | ||
| int | step | ||
| ) |
Restore the engine's state, then the lagged fluxes, on a restart.
Aborts when the checkpoint holds the lagged fluxes on another level or over another region than this run's fire grid. A checkpoint without them (no fire state, or written before they were checkpointed) leaves them at zero: the first restarted step injects no fire heat.
| [in] | restart_chkfile | The checkpoint directory |
| [in] | max_level | ERF's max_level |
| [in] | step | The step count of the fire grid's level at the checkpoint |

|
inline |
Set fields_time() to t [s] (ERF only: start-up, restart, end of a coarser step).
| void FireCoupler::set_fire_grid | ( | int | lev, |
| const FireGrid & | fg, | ||
| const amrex::BoxArray & | ba_atm, | ||
| const amrex::DistributionMapping & | dm_atm, | ||
| const amrex::Geometry & | geom_atm | ||
| ) |
Lay the coupling out on a fire grid: what initialize() does after its start-up checks and before it sets the engine up.
Takes the fire grid and allocates the lagged flux buffers (zero) on the k = 0 slabs of ba_atm, with 5 ghost columns. Public so that a test can drive the coupling with an engine of its own without an ERF object (erf-model/FLARE: Tests/Unit/Fire/ERF_GTestFireCoupler.cpp).
| [in] | lev | The level the fire grid refines |
| [in] | fg | The fire grid (create_fire_grid) |
| [in] | ba_atm | The level's boxes |
| [in] | dm_atm | Their owners |
| [in] | geom_atm | The level's geometry |
Referenced by initialize().

|
private |
Average the engine's fluxes onto the atmospheric columns for the next step.
Referenced by advance().


| void FireCoupler::write_checkpoint | ( | const std::string & | checkpointname | ) | const |
Write the fire to a checkpoint: the engine's state (FireEngine::write_checkpoint), then the coupling's lagged fluxes (FireQAtmPrev and FireQLatAtmPrev) under checkpointname/Level_<lev>/.
|
private |
Referenced by add_sources(), advance(), engine(), fill_plot_var(), FireCoupler(), initialize(), read_checkpoint(), update_flux_buffer(), and write_checkpoint().
|
private |
Referenced by fill_plot_var(), fire_grid(), initialize(), set_fire_grid(), and update_flux_buffer().
|
private |
the time the engine's fields belong to (fields_time())
Referenced by advance(), fields_time(), and set_fields_time().
|
private |
geometry of the fire grid's level
Referenced by fill_plot_var(), read_checkpoint(), and set_fire_grid().
|
private |
Referenced by checkpoint_mismatch(), fill_plot_var(), level(), read_checkpoint(), set_fire_grid(), and write_checkpoint().
|
private |
Referenced by add_sources(), advance(), initialize(), params(), and update_flux_buffer().
|
private |
FireEngine::plot_var_names(), read at construction.
Referenced by FireCoupler(), and plot_var_names().
|
private |
sensible [W/m2]
Referenced by add_sources(), checkpoint_mismatch(), fill_plot_var(), get_Q_atm_prev(), read_checkpoint(), set_fire_grid(), update_flux_buffer(), and write_checkpoint().
|
private |
latent [W/m2]
Referenced by add_sources(), get_Q_lat_atm_prev(), read_checkpoint(), set_fire_grid(), update_flux_buffer(), and write_checkpoint().