ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_FloodGrid.H
Go to the documentation of this file.
1 #ifndef ERF_FLOOD_GRID_H
2 #define ERF_FLOOD_GRID_H
3 
4 #include <ERF_SurfaceGrid.H>
5 
6 #include <AMReX_BoxArray.H>
7 #include <AMReX_DistributionMapping.H>
8 #include <AMReX_Geometry.H>
9 #include <AMReX_MultiFab.H>
10 
11 /**
12  * @file ERF_FloodGrid.H
13  * @brief Flood grid data structure, construction and the maps between the
14  * flood grid and the atmospheric columns
15  *
16  * A 2D grid on the horizontal plane, refined by grid_ratio relative to one
17  * atmospheric AMR level (erf.flood.anchor_level, the finest level by default).
18  * The flood grid covers that level's boxes, keeps their x-y decomposition and
19  * their MPI owners, and its index space starts at zero at the lower corner of
20  * the region they cover. It is the surface grid of the surface-coupling layer
21  * (ERF_SurfaceGrid.H) under the flood coupling's name, as the fire grid is;
22  * the functions below call that layer with the flood coupling's names.
23  */
24 
25 /// The flood coupling's names: erf.flood.<key>, "[FLOOD]", "flood grid"
27 {
28  static const SurfaceCouplingNames names{"flood", "Flood", "FLOOD"};
29  return names;
30 }
31 
32 /**
33  * @struct FloodGrid
34  * @brief 2D horizontal flood grid
35  *
36  * A slab one cell thick with C*nx x C*ny cells, where C is erf.flood.grid_ratio
37  * and (nx, ny) is the size of the region the atmospheric level's boxes cover:
38  * the whole domain on level 0, the refined region on a finer level. The
39  * members (ba, dm, geom, C, atm_lo, lev) are those of SurfaceGrid.
40  */
42 {
43 };
44 
45 /**
46  * @brief Construct a refined 2D flood grid over one atmospheric level's boxes
47  *
48  * @param[in] ba_atm BoxArray of the atmospheric level
49  * @param[in] dm_atm DistributionMapping of the atmospheric level
50  * @param[in] geom_atm Geometry of the atmospheric level
51  * @param[in] C Refinement factor (erf.flood.grid_ratio, >= 1)
52  *
53  * @return FloodGrid over the region the boxes cover; its lev is left at 0 for
54  * the caller to set. See create_surface_grid() for the algorithm.
55  */
56 FloodGrid create_flood_grid (const amrex::BoxArray& ba_atm,
57  const amrex::DistributionMapping& dm_atm,
58  const amrex::Geometry& geom_atm,
59  int C);
60 
61 /// surface_same_columns: box n of a and box n of b cover the same columns.
62 inline bool flood_same_columns (const amrex::BoxArray& a, const amrex::BoxArray& b)
63 {
64  return surface_same_columns(a, b);
65 }
66 
67 /// surface_pairs_with_atm: box n of the flood grid refines the columns of
68 /// atmospheric box n for every n, with the same owners.
69 inline bool flood_pairs_with_atm (const amrex::MultiFab& flood_mf, const amrex::MultiFab& atm_mf,
70  const FloodGrid& fg)
71 {
72  return surface_pairs_with_atm(flood_mf, atm_mf, fg);
73 }
74 
75 /// surface_fill_boundary: exchange the ghost cells of a cell-centred
76 /// flood-grid MultiFab and fill the ones outside a non-periodic face.
77 inline void flood_fill_boundary (amrex::MultiFab& mf, const amrex::Geometry& geom)
78 {
80 }
81 
82 /**
83  * Copy component acomp of a k = 0 atmospheric field into component fcomp of a
84  * flood-grid field (surface_fill_from_atm_k0): every flood cell takes the
85  * value of the atmospheric column it lies in. A per-area quantity
86  * (precipitation in kg/m2) keeps its column total.
87  */
88 inline void fill_flood_from_atm_k0 (amrex::MultiFab& flood_mf, const amrex::MultiFab& atm_k0,
89  const FloodGrid& fg, int fcomp = 0, int acomp = 0)
90 {
91  surface_fill_from_atm_k0(flood_mf, atm_k0, fg, flood_coupling_names(), fcomp, acomp);
92 }
93 
94 /**
95  * Average a flood-grid field over each atmospheric column (the C x C flood
96  * cells under it) into the k = 0 slabs of the flood grid's level
97  * (surface_coarsen_to_atm). Box n of the output is the k = 0 slab of
98  * atmospheric box n.
99  */
100 inline void coarsen_flood_to_atm (amrex::MultiFab& atm_out, const amrex::MultiFab& flood,
101  const FloodGrid& fg)
102 {
103  surface_coarsen_to_atm(atm_out, flood, fg, flood_coupling_names());
104 }
105 
106 #endif
bool flood_same_columns(const amrex::BoxArray &a, const amrex::BoxArray &b)
surface_same_columns: box n of a and box n of b cover the same columns.
Definition: ERF_FloodGrid.H:62
const SurfaceCouplingNames & flood_coupling_names()
The flood coupling's names: erf.flood.<key>, "[FLOOD]", "flood grid".
Definition: ERF_FloodGrid.H:26
void fill_flood_from_atm_k0(amrex::MultiFab &flood_mf, const amrex::MultiFab &atm_k0, const FloodGrid &fg, int fcomp=0, int acomp=0)
Definition: ERF_FloodGrid.H:88
void flood_fill_boundary(amrex::MultiFab &mf, const amrex::Geometry &geom)
Definition: ERF_FloodGrid.H:77
void coarsen_flood_to_atm(amrex::MultiFab &atm_out, const amrex::MultiFab &flood, const FloodGrid &fg)
Definition: ERF_FloodGrid.H:100
FloodGrid create_flood_grid(const amrex::BoxArray &ba_atm, const amrex::DistributionMapping &dm_atm, const amrex::Geometry &geom_atm, int C)
Construct a refined 2D flood grid over one atmospheric level's boxes.
bool flood_pairs_with_atm(const amrex::MultiFab &flood_mf, const amrex::MultiFab &atm_mf, const FloodGrid &fg)
Definition: ERF_FloodGrid.H:69
The 2D surface grid of the fire and flood couplings, and the maps between it and the atmospheric colu...
bool surface_pairs_with_atm(const amrex::MultiFab &surf_mf, const amrex::MultiFab &atm_mf, const SurfaceGrid &sg)
Definition: ERF_SurfaceGrid.H:98
void surface_fill_boundary(amrex::MultiFab &mf, const amrex::Geometry &geom, const SurfaceCouplingNames &names)
Definition: ERF_SurfaceGrid.H:130
void surface_fill_from_atm_k0(amrex::MultiFab &surf_mf, const amrex::MultiFab &atm_k0, const SurfaceGrid &sg, const SurfaceCouplingNames &names, int scomp=0, int acomp=0)
Definition: ERF_SurfaceGrid.H:170
bool surface_same_columns(const amrex::BoxArray &a, const amrex::BoxArray &b)
Definition: ERF_SurfaceGrid.H:79
void surface_coarsen_to_atm(amrex::MultiFab &atm_out, const amrex::MultiFab &surf, const SurfaceGrid &sg, const SurfaceCouplingNames &names)
Definition: ERF_SurfaceGrid.H:201
@ fg
Definition: ERF_AdvanceMorrison.cpp:111
2D horizontal flood grid
Definition: ERF_FloodGrid.H:42
Definition: ERF_SurfaceCouplingNames.H:18
2D horizontal surface grid
Definition: ERF_SurfaceGrid.H:34