ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_FireGrid.cpp File Reference
#include <ERF_FireGrid.H>
#include <AMReX_IntVect.H>
#include <AMReX_BoxList.H>
#include <string>
Include dependency graph for ERF_FireGrid.cpp:

Functions

FireGrid create_fire_grid (const BoxArray &ba_atm, const DistributionMapping &dm_atm, const Geometry &geom_atm, int C)
 

Function Documentation

◆ create_fire_grid()

FireGrid create_fire_grid ( const BoxArray &  ba_atm,
const DistributionMapping &  dm_atm,
const Geometry &  geom_atm,
int  C 
)
14 {
15  FireGrid fg;
16  fg.C = C;
17 
18  // Step 1: the k = 0 slab of each atmospheric box, in the order of ba_atm, so
19  // that fire box n refines atmospheric box n.
20  Vector<Box> box_list_2d;
21  for (int i = 0; i < ba_atm.size(); ++i) {
22  Box b = ba_atm[i];
23  b.setSmall(2, 0);
24  b.setBig(2, 0);
25  box_list_2d.push_back(b);
26  }
27  BoxList bl_2d(std::move(box_list_2d)); // rvalue — matches Vector<Box>&&
28  BoxArray ba_2d(bl_2d);
29 
30  // Step 2: the region the fire grid covers, the bounding rectangle of the
31  // level's boxes: the domain on level 0, the refined region on a finer level.
32  // The fire grid treats the region's edges as its domain edges, so the boxes
33  // must cover it without holes (verify_fire_prerequisites says so first with
34  // the inputs to change).
35  const Box region = ba_2d.minimalBox();
36  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(region.numPts() == ba_2d.numPts(),
37  "[FIRE] create_fire_grid: the boxes of the atmospheric level do not form one rectangle");
38  const IntVect atm_lo(region.smallEnd(0), region.smallEnd(1), 0);
39 
40  // Step 3: shift to the region's corner and refine by {C, C, 1}. The fire
41  // grid's index space starts at zero there, as every AMReX Geometry does, so
42  // positions from ProbLo + (i + 1/2) dx, the fuel map rows and the plotfile
43  // header are those of the region as they stand; only the map back to the
44  // atmosphere adds atm_lo. refine() and shift() keep the number and order of
45  // the boxes, so dm_atm maps identically (box n of the fire grid is owned by
46  // the rank of atmospheric box n).
47  BoxArray ba_fire = ba_2d;
48  ba_fire.shift(-atm_lo);
49  ba_fire.refine(IntVect(C, C, 1));
50  DistributionMapping dm_fire = dm_atm;
51 
52  // Step 4: the 2D Geometry over the region. Where the region spans the
53  // domain the domain's own bounds are used, so a level-0 fire grid is the
54  // same to the last bit as before the region was introduced; elsewhere the
55  // bounds are the atmospheric cell faces at the region's edges.
56  const Box& dom_atm = geom_atm.Domain();
57  Box fire_domain(IntVect(0, 0, 0),
58  IntVect(region.length(0) * C - 1, region.length(1) * C - 1, 0));
59 
60  Array<Real, AMREX_SPACEDIM> lo {geom_atm.ProbLo(0), geom_atm.ProbLo(1), geom_atm.ProbLo(2)};
61  Array<Real, AMREX_SPACEDIM> hi {geom_atm.ProbHi(0), geom_atm.ProbHi(1), geom_atm.ProbLo(2) + Real(1.0)}; // z extent = 1 m (dummy)
62  Array<int, AMREX_SPACEDIM> is_per {0, 0, 0};
63  for (int d = 0; d < 2; ++d) {
64  const bool spans = (region.smallEnd(d) == dom_atm.smallEnd(d)) && (region.bigEnd(d) == dom_atm.bigEnd(d));
65  if (!spans) {
66  lo[d] = geom_atm.ProbLo(d) + Real(region.smallEnd(d) - dom_atm.smallEnd(d)) * geom_atm.CellSize(d);
67  hi[d] = geom_atm.ProbLo(d) + Real(region.bigEnd(d) - dom_atm.smallEnd(d) + 1) * geom_atm.CellSize(d);
68  }
69  // Inherit the atmospheric periodicity in x and y where the region spans
70  // the domain. Hard-coding this non-periodic silently disabled every
71  // FillBoundary on the fire grid: the fire grid is one box spanning the
72  // domain, so all of its ghost cells are domain-boundary ghosts, and a
73  // non-periodic Periodicity() leaves them untouched. The level-set stage
74  // fields carry three ghost cells past the box edge and were reading
75  // whatever the allocator happened to supply. A region narrower than the
76  // domain has edges of its own and is not periodic there.
77  is_per[d] = (spans && geom_atm.isPeriodic(d)) ? 1 : 0;
78  }
79  RealBox prob_domain_2d(lo, hi);
80 
81  Geometry geom_fire_2d(fire_domain, prob_domain_2d, CoordSys::cartesian, is_per);
82 
83  fg.ba = ba_fire;
84  fg.dm = dm_fire;
85  fg.geom = geom_fire_2d;
86  fg.atm_lo = atm_lo;
87 
88  return fg;
89 }
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ fg
Definition: ERF_AdvanceMorrison.cpp:111
2D horizontal fire computational grid
Definition: ERF_FireGrid.H:29

Referenced by FireCoupler::initialize().

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