ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_ChopGrids.cpp File Reference
#include <ERF_Utils.H>
Include dependency graph for ERF_ChopGrids.cpp:

Functions

BoxArray ERFPostProcessBaseGrids (const Box &domain, bool decompose_in_z)
 
void ChopGrids2D (BoxArray &ba, const Box &domain, int target_size)
 

Function Documentation

◆ ChopGrids2D()

void ChopGrids2D ( BoxArray &  ba,
const Box &  domain,
int  target_size 
)
22 {
23  IntVect chunk = domain.length();
24 
25  while (ba.size() < target_size)
26  {
27  IntVect chunk_prev = chunk;
28 
29  std::array<std::pair<int,int>,AMREX_SPACEDIM>
30  chunk_dir{std::make_pair(chunk[0],int(0)),
31  std::make_pair(chunk[1],int(1))};
32  std::sort(chunk_dir.begin(), chunk_dir.end());
33 
34  // We only decompose in and y
35  for (int idx = 1; idx >= 0; idx--) {
36  int idim = chunk_dir[idx].second;
37  int new_chunk_size = chunk[idim] / 2;
38  if (new_chunk_size != 0)
39  {
40  chunk[idim] = new_chunk_size;
41  ba.maxSize(chunk);
42  break;
43  }
44  }
45 
46  if (chunk == chunk_prev) {
47  break;
48  }
49  }
50 }

Referenced by init_terrain_grid(), and ERF::initHSE().

Here is the caller graph for this function:

◆ ERFPostProcessBaseGrids()

BoxArray ERFPostProcessBaseGrids ( const Box &  domain,
bool  decompose_in_z 
)
7 {
8  //
9  // This is used to avoid the case where the native amrex decomposition makes
10  // too many grids for the number of processors.
11  //
12  // The idea is to not override the user preference if expressed by max_grid_size
13  // but instead to ensure that the default behavior is what we want.
14  //
15  BoxArray ba0 = amrex::decompose(domain, ParallelDescriptor::NProcs(),
16  {true,true,decompose_in_z});
17  return ba0;
18 }

Referenced by ERF::MakeNewLevelFromScratch().

Here is the caller graph for this function: