ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
MultiBlockContainer Class Reference

#include <ERF_MultiBlockContainer.H>

Collaboration diagram for MultiBlockContainer:

Public Member Functions

 MultiBlockContainer (const std::vector< amrex::RealBox > &rb_v, std::vector< int > max_level_in_v, const std::vector< amrex::Vector< int >> &n_cell_in_v, std::vector< int > coord_v, const std::vector< amrex::Vector< amrex::IntVect >> &ref_ratios_v, const std::vector< amrex::Array< int, AMREX_SPACEDIM >> &is_per_v, std::vector< std::string > prefix_v, int max_step)
 
 ~MultiBlockContainer ()
 
void InitializeBlocks ()
 
void SetBoxLists ()
 
void SetBlockCommMetaData ()
 
void AdvanceBlocks ()
 
void FillPatchBlocks (int src_ind, int dst_ind)
 

Private Attributes

int m_max_step
 
ERF erf1
 
ERF erf2
 
amrex::NonLocalBC::MultiBlockIndexMapping dtos
 
std::vector< std::vector< amrex::NonLocalBC::MultiBlockCommMetaData * > > cmd
 
std::vector< amrex::BoxList > blv
 

Constructor & Destructor Documentation

◆ MultiBlockContainer()

MultiBlockContainer::MultiBlockContainer ( const std::vector< amrex::RealBox > &  rb_v,
std::vector< int >  max_level_in_v,
const std::vector< amrex::Vector< int >> &  n_cell_in_v,
std::vector< int >  coord_v,
const std::vector< amrex::Vector< amrex::IntVect >> &  ref_ratios_v,
const std::vector< amrex::Array< int, AMREX_SPACEDIM >> &  is_per_v,
std::vector< std::string >  prefix_v,
int  max_step 
)

Constructor for the MultiBlockContainer class capable of taking a vector of boxes as input.

Inputs that are vectors are used to define the two ERF instances in the MultiBlock class.

Parameters
[in]rb_vVector of RealBoxes to define this MultiBlock
[in]max_level_in_vMaximum level vector
[in]n_cell_in_vNumber of cells vector
[in]coord_vCoordinate selection vector
[in]ref_ratios_vRefinement ratio vector
[in]is_per_vDefines whether the domain is periodic in each coordinate direction
[in]prefix_vPrefixes for ParmParse as a vector
[in]max_stepMaximum number of timesteps to take
29 : m_max_step(max_step),
30  erf1(rb_v[0],max_level_in_v[0],n_cell_in_v[0],coord_v[0],ref_ratios_v[0],is_per_v[0],prefix_v[0]),
31  erf2(rb_v[1],max_level_in_v[1],n_cell_in_v[1],coord_v[1],ref_ratios_v[1],is_per_v[1],prefix_v[1])
32 {
33  // Store ptr to container to call member functions
34  erf1.SetMultiBlockPointer(this);
35  erf2.SetMultiBlockPointer(this);
36 
37  // Set the permutation/sign of dtos
38  dtos.permutation = IntVect{AMREX_D_DECL( 0, 1, 2)};
39  dtos.sign = IntVect{AMREX_D_DECL( 1, 1, 1)};
40 
41  // Set offset of dtos (NOTE: i_dst = i_src - i_off -> [0] - [1])
42  Real dx = ( rb_v[0].hi(0) - rb_v[0].lo(0) ) / n_cell_in_v[0][0];
43  Real dy = ( rb_v[0].hi(1) - rb_v[0].lo(1) ) / n_cell_in_v[0][1];
44  Real dz = ( rb_v[0].hi(2) - rb_v[0].lo(2) ) / n_cell_in_v[0][2];
45  int offx = amrex::Math::floor(( rb_v[0].lo(0) - rb_v[1].lo(0) ) / dx);
46  int offy = amrex::Math::floor(( rb_v[0].lo(1) - rb_v[1].lo(1) ) / dy);
47  int offz = amrex::Math::floor(( rb_v[0].lo(2) - rb_v[1].lo(2) ) / dz);
48  // DEBUG
49  //offx=0; offy=0; offz=0;
50  dtos.offset = IntVect{AMREX_D_DECL(offx, offy, offz)};
51 }
ERF erf1
Definition: ERF_MultiBlockContainer.H:40
int m_max_step
Definition: ERF_MultiBlockContainer.H:39
amrex::NonLocalBC::MultiBlockIndexMapping dtos
Definition: ERF_MultiBlockContainer.H:42
ERF erf2
Definition: ERF_MultiBlockContainer.H:41

◆ ~MultiBlockContainer()

MultiBlockContainer::~MultiBlockContainer ( )

Destructor for the MultiBlockContainer

57 {
58 }

Member Function Documentation

◆ AdvanceBlocks()

void MultiBlockContainer::AdvanceBlocks ( )

Advance blocks in the MultiBlockContainer by calling each timestep advance sequentially.

155 {
156  Print() << "STARTING MAIN DRIVER FOR: " << m_max_step << " STEPS" << "\n";
157  Print() << "\n";
158 
159  for (int step(1); step <= m_max_step; ++step) {
160  Print() << " STARTING ADVANCE DRIVER: " << step << "\n";
161  Print() << "====================================" << "\n";
162  erf1.Evolve_MB(step,1);
163  Print() << '\n';
164  Print() << " SECOND BLOCK STARTS " << "\n";
165  Print() << "------------------------------------" << "\n";
166  erf2.Evolve_MB(step,1);
167  Print() << "COMPLETE" << "\n";
168  Print() << "\n";
169  }
170 }

◆ FillPatchBlocks()

void MultiBlockContainer::FillPatchBlocks ( int  src_ind,
int  dst_ind 
)

Wrapper for ParallelCopy between classes

177 {
178  // Hard-coded bounds for now
179  int ndirs = AMREX_SPACEDIM;
180 
181  // Loop faces of box to perform ParallelCopy
182  // NOTE - cmd built with ERF2 so uses dst_ind
183  for (int j(0); j<2*ndirs; ++j)
184  amrex::NonLocalBC::ParallelCopy(erf2.vars_new[0][dst_ind], erf1.vars_new[0][src_ind],
185  *(cmd[dst_ind][j]), 0, 0, 1, dtos);
186 }
amrex::Vector< amrex::Vector< amrex::MultiFab > > vars_new
Definition: ERF.H:741
std::vector< std::vector< amrex::NonLocalBC::MultiBlockCommMetaData * > > cmd
Definition: ERF_MultiBlockContainer.H:43

◆ InitializeBlocks()

void MultiBlockContainer::InitializeBlocks ( )

Initialize block data for the MultiBlockContainer

65 {
66  erf1.InitData();
67  erf2.InitData();
68 }
void InitData()
Definition: ERF.cpp:606
Here is the call graph for this function:

◆ SetBlockCommMetaData()

void MultiBlockContainer::SetBlockCommMetaData ( )

Set up MultiBlock Communication Meta Data

127 {
128  // Hard-coded bounds for now
129  int nvars = erf2.vars_new[0].size(); // Destination MF
130  int ndirs = AMREX_SPACEDIM;
131 
132  // Loop over num_vars to set communicator
133  for (int i(0); i<nvars; ++i) {
134  // Make space
135  cmd.push_back(std::vector<amrex::NonLocalBC::MultiBlockCommMetaData*>());
136  // Get ghost cell vector for multifab growth
137  IntVect nghost = erf2.vars_new[0][i].nGrowVect();
138  for (int j(0); j<2*ndirs; ++j) {
139 
140  // Store temp ptr to communicator for i^th variable
141  amrex::NonLocalBC::MultiBlockCommMetaData *cmd_tmp =
142  new amrex::NonLocalBC::MultiBlockCommMetaData(erf2.vars_new[0][i], (blv[i].data())[j],
143  erf1.vars_new[0][i], nghost, dtos);
144  // Populate cmd vector
145  cmd[i].push_back(cmd_tmp);
146  }
147  }
148 }
@ nvars
Definition: ERF_DataStruct.H:70
std::vector< amrex::BoxList > blv
Definition: ERF_MultiBlockContainer.H:44

◆ SetBoxLists()

void MultiBlockContainer::SetBoxLists ( )

Set up BoxList vector for use with Communication Meta Data

75 {
76  // Hard-coded bounds for now
77  int nvars = erf2.vars_new[0].size();
78  int ndirs = AMREX_SPACEDIM;
79 
80  for (int i(0); i<nvars; ++i) {
81  // Get ghost cells, domain & grown box
82  IntVect nghost = erf2.vars_new[0][i].nGrowVect();
83  Box dom = erf2.domain_p[i];
84  Box gbx = grow(dom,nghost);
85  // Tmp BoxList
86  BoxList bl;
87  bl.clear();
88  bl.set(gbx.ixType());
89  for (int j(0); j<ndirs; ++j) {
90  // Local box copies
91  Box lgbx(gbx);
92  Box ugbx(gbx);
93  // Get lower & upper bound
94  int se = dom.smallEnd(j) - 1;
95  int be = dom.bigEnd(j) + 1;
96  // Modify bounds for nodal vars
97  if (gbx.ixType().nodeCentered(j)) {
98  se += 1;
99  be -= 1;
100  }
101  // Populate BoxList
102  bl.push_back( lgbx.setBig(j,se) );
103  bl.push_back( ugbx.setSmall(j,be) );
104  }
105  blv.push_back(bl);
106  }
107 
108  /*
109  // DEBUG BOX LIST
110  for (int i(0); i<nvars; ++i) {
111  Print() << "DOM: " << erf2.domain_p[i] << "\n";
112  Print() << "BA: " << erf2.vars_new[0][i].boxArray() << "\n";
113  for (int j(0); j<6; ++j)
114  Print() << (blv[i].data())[j] << "\n";
115 
116  Print() << "\n";
117  }
118  exit(0);
119  */
120 }

Member Data Documentation

◆ blv

std::vector<amrex::BoxList> MultiBlockContainer::blv
private

◆ cmd

std::vector<std::vector<amrex::NonLocalBC::MultiBlockCommMetaData*> > MultiBlockContainer::cmd
private

◆ dtos

amrex::NonLocalBC::MultiBlockIndexMapping MultiBlockContainer::dtos
private

◆ erf1

ERF MultiBlockContainer::erf1
private

◆ erf2

◆ m_max_step

int MultiBlockContainer::m_max_step
private

Referenced by AdvanceBlocks().


The documentation for this class was generated from the following files: