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

Start-up checks of the atmosphere side of the fire coupling. More...

#include <AMReX_MultiFab.H>
#include <string>
#include <AMReX_Geometry.H>
#include <ERF_SurfacePrecipitation.H>
Include dependency graph for ERF_FirePrerequisites.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int fire_anchor_level (int anchor_level, int finest_level)
 The AMR level the fire grid refines: erf.fire.anchor_level, or the finest level when it is -1 (the default). More...
 
void verify_fire_precip_source (const std::string &engine_name, const SurfacePrecipAccumulationSources &sources)
 Start-up check for an engine that reads the rain of every column (FireEngine::wants_surface_precip): the microphysics scheme must provide surface precipitation accumulators. More...
 
void verify_fire_prerequisites (const ERF &erf, int lev, const SurfaceLayer *surface_layer, int grid_ratio, bool needs_surface_layer=true)
 Verify the ERF configuration the fire coupling needs. More...
 

Detailed Description

Start-up checks of the atmosphere side of the fire coupling.

Verifies that ERF is configured so that a fire grid can be coupled to it, whichever fire engine runs on that grid:

  • MOST surface layer is active with proper boundary conditions
  • The level the fire grid refines exists and keeps its boxes
  • No z-direction MPI decomposition (all z-levels on same rank)
  • The level's boxes cover one rectangle
  • Grid divisibility by refinement factor

Each engine checks its own inputs after these (FireEngine::verify_prerequisites).

The checks on the level the fire grid refines are those of every surface coupling (verify_surface_grid_level, ERF_SurfacePrerequisites.H); each check aborts with a message that names the input to change.

Function Documentation

◆ fire_anchor_level()

int fire_anchor_level ( int  anchor_level,
int  finest_level 
)

The AMR level the fire grid refines: erf.fire.anchor_level, or the finest level when it is -1 (the default).

Aborts, naming the input, when the level is above the finest level.

Parameters
[in]anchor_levelerf.fire.anchor_level (-1 = the finest level)
[in]finest_levelFinest level of the run at start-up
54 {
55  return surface_anchor_level(anchor_level, finest_level, fire_coupling_names());
56 }
const SurfaceCouplingNames & fire_coupling_names()
The fire coupling's names: erf.fire.<key>, "[FIRE]", "fire grid".
Definition: ERF_FireGrid.H:25
int surface_anchor_level(int anchor_level, int finest_level, const SurfaceCouplingNames &names)
The level the surface grid refines: anchor_level, or the finest level when it is -1....
Definition: ERF_SurfacePrerequisites.cpp:10

Referenced by ERF::InitData_post().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verify_fire_precip_source()

void verify_fire_precip_source ( const std::string &  engine_name,
const SurfacePrecipAccumulationSources &  sources 
)

Start-up check for an engine that reads the rain of every column (FireEngine::wants_surface_precip): the microphysics scheme must provide surface precipitation accumulators.

Aborts, naming the engine and erf.moisture_model, when the sources are empty (no moisture model, Kessler_NoRain, saturation adjustment only, ...). Called after the microphysics of the fire grid's level is initialized.

Parameters
[in]engine_nameThe engine's name (FireEngine::name)
[in]sourcesMicrophysics::Get_Surface_Precip_Accumulation_Ptrs(lev)
60 {
61  verify_surface_precip_source(engine_name, sources, "rain", fire_coupling_names());
62 }
void verify_surface_precip_source(const std::string &engine_name, const SurfacePrecipAccumulationSources &sources, const std::string &what, const SurfaceCouplingNames &names)
Aborts, naming erf.moisture_model, when no microphysics surface precipitation accumulator exists for ...
Definition: ERF_SurfacePrerequisites.cpp:23

Referenced by ERF::InitData_post().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verify_fire_prerequisites()

void verify_fire_prerequisites ( const ERF &  erf,
int  lev,
const SurfaceLayer *  surface_layer,
int  grid_ratio,
bool  needs_surface_layer = true 
)

Verify the ERF configuration the fire coupling needs.

Called once at startup from FireCoupler::initialize() after the SurfaceLayer is ready, before the engine's own checks. Aborts with clear diagnostic messages if any requirement is not met.

Parameters
[in]erfERF instance (for grids, dmap, Geom access)
[in]levAMR level the fire grid refines (fire_anchor_level)
[in]surface_layerPointer to initialized SurfaceLayer
[in]grid_ratioerf.fire.grid_ratio, fire cells per atmospheric cell in x and y

Checks performed (in order):

  1. SurfaceLayer pointer is not null (zlo.type = surface_layer), unless needs_surface_layer is false (FireEngine::needs_surface_layer) 2-7b, 11. verify_surface_grid_level: 0 <= lev <= finest level; on a level above 0 static refinement (erf.regrid_int <= 0); every box of the level spans its full height (no z-decomposition); the level's boxes cover one rectangle in x and y; the domain starts at index 0
  2. grid_ratio >= 1
  3. All boxes divisible by grid_ratio in x and y
  4. Distribution map size matches grid size
69 {
70  // Check 1: Surface layer BC type is "surface_layer", for an engine that reads it
72  !needs_surface_layer || surface_layer != nullptr,
73  "fire module requires SurfaceLayer. "
74  "Check: phys_bc_type[zlo] == surface_layer AND erf.most.z0 is set");
75 
76  // Checks 2-7b and 11: the checks every surface coupling makes on the level
77  // its grid refines (ERF_SurfacePrerequisites.H): the level exists, keeps
78  // its boxes above level 0, its boxes span the full height and cover one
79  // rectangle, and its domain starts at index 0.
81 
82  const BoxArray& ba = erf.boxArray(lev);
83 
84  // Check 8: grid_ratio >= 1
86  grid_ratio >= 1,
87  "[FIRE] Fire grid_ratio requires value >= 1. Set: erf.fire.grid_ratio >= 1");
88 
89  // Check 9: All boxes divisible by grid_ratio in x,y (box_ratio_advice says
90  // which inputs to change).
91  int C = grid_ratio;
92  for (int i = 0; i < ba.size(); ++i) {
93  const Box& b = ba[i];
94  int nx = b.length(0);
95  int ny = b.length(1);
96  if (nx % C != 0 || ny % C != 0) {
97  Abort("[FIRE] Box sizes not divisible by grid_ratio: box " + std::to_string(i)
98  + " of level " + std::to_string(lev) + " is " + std::to_string(nx) + " x "
99  + std::to_string(ny) + " cells, and every x,y box length on that level must "
100  "be divisible by erf.fire.grid_ratio = " + std::to_string(C) + ". "
101  + box_ratio_advice(C, lev));
102  }
103  }
104 
105  // Check 10: DistributionMapping size matches grid size
106  // Use the public boxArray() accessor here too
108  erf.DistributionMap(lev).size() == erf.boxArray(lev).size(),
109  "[FIRE] Internal error: dmap size != grids size");
110 }
const int nx
Definition: ERF_InitCustomPertVels_CloudChamber.H:14
const int ny
Definition: ERF_InitCustomPertVels_CloudChamber.H:15
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
void verify_surface_grid_level(const ERF &erf, int lev, const SurfaceCouplingNames &names)
The checks on the level the surface grid refines, each naming the inputs to change.
Definition: ERF_SurfacePrerequisites.cpp:41

Referenced by FireCoupler::initialize().

Here is the call graph for this function:
Here is the caller graph for this function: