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

#include <ERF_GroundAverageDown.H>

Collaboration diagram for GroundAverageDown:

Public Member Functions

 GroundAverageDown (const amrex::BoxArray &a_fba, const amrex::DistributionMapping &a_fdm, const amrex::IntVect &a_rr, int a_kf, int a_kc)
 
void apply (const amrex::MultiFab &a_fine, amrex::MultiFab &a_crse, const amrex::Real a_scale, const int a_fcomp=0, const int a_ccomp=0)
 

Private Attributes

amrex::BoxArray m_fba
 
amrex::DistributionMapping m_fdm
 
amrex::IntVect m_rr
 
int m_kf
 
amrex::Vector< int > m_fine_box
 
amrex::MultiFab m_tmp
 

Detailed Description

Restriction of a quantity held in the ground layer of cells (a surface accumulation) from a fine level to the coarse level below it. Each coarse ground cell under a fine box that stands on the ground gets a scale times the sum of the rr[0]*rr[1] fine ground cells above it: the inverse area for a depth, 1 for an amount per cell. The coarse ground boxes, distributed with the fine boxes they lie under, are built once and serve every quantity restricted with them.

Constructor & Destructor Documentation

◆ GroundAverageDown()

GroundAverageDown::GroundAverageDown ( const amrex::BoxArray &  a_fba,
const amrex::DistributionMapping &  a_fdm,
const amrex::IntVect &  a_rr,
int  a_kf,
int  a_kc 
)
inline
Parameters
a_fba,a_fdmBoxArray and DistributionMapping of the fine data
a_rrrefinement ratio between the two levels
a_kf,a_kcindex of the ground layer on the fine and on the coarse level
23  : m_fba(a_fba), m_fdm(a_fdm), m_rr(a_rr), m_kf(a_kf)
24  {
25  amrex::BoxList bl;
26  amrex::Vector<int> pmap;
27  for (int ib = 0; ib < a_fba.size(); ++ib) {
28  if (a_fba[ib].smallEnd(2) != a_kf) { continue; }
29  amrex::Box s = amrex::coarsen(a_fba[ib], a_rr);
30  s.setRange(2, a_kc);
31  bl.push_back(s);
32  m_fine_box.push_back(ib);
33  pmap.push_back(a_fdm[ib]);
34  }
35  if (!bl.isEmpty()) {
36  m_tmp.define(amrex::BoxArray(std::move(bl)), amrex::DistributionMapping(std::move(pmap)), 1, 0);
37  }
38  }
amrex::IntVect m_rr
Definition: ERF_GroundAverageDown.H:72
amrex::BoxArray m_fba
Definition: ERF_GroundAverageDown.H:70
amrex::Vector< int > m_fine_box
Definition: ERF_GroundAverageDown.H:74
amrex::MultiFab m_tmp
Definition: ERF_GroundAverageDown.H:75
int m_kf
Definition: ERF_GroundAverageDown.H:73
amrex::DistributionMapping m_fdm
Definition: ERF_GroundAverageDown.H:71

Member Function Documentation

◆ apply()

void GroundAverageDown::apply ( const amrex::MultiFab &  a_fine,
amrex::MultiFab &  a_crse,
const amrex::Real  a_scale,
const int  a_fcomp = 0,
const int  a_ccomp = 0 
)
inline

Component a_ccomp of a_crse = a_scale times the sum of the fine ground cells of component a_fcomp of a_fine, in the coarse ground cells under the fine level. a_fine must be defined on the fine BoxArray and DistributionMapping given to the constructor.

47  {
48  AMREX_ASSERT(a_fine.boxArray() == m_fba && a_fine.DistributionMap() == m_fdm);
49  if (m_fine_box.empty()) { return; }
50  const amrex::IntVect rr = m_rr;
51  const int kf = m_kf;
52  for (amrex::MFIter mfi(m_tmp); mfi.isValid(); ++mfi) {
53  const auto f = a_fine.const_array(m_fine_box[mfi.index()], a_fcomp);
54  const auto c = m_tmp.array(mfi);
55  amrex::ParallelFor(mfi.validbox(), [=] AMREX_GPU_DEVICE (int ic, int jc, int kc) noexcept
56  {
57  amrex::Real sum = 0.0;
58  for (int j = jc*rr[1]; j < (jc+1)*rr[1]; ++j) {
59  for (int i = ic*rr[0]; i < (ic+1)*rr[0]; ++i) {
60  sum += f(i,j,kf);
61  }
62  }
63  c(ic,jc,kc) = sum * a_scale;
64  });
65  }
66  a_crse.ParallelCopy(m_tmp, 0, a_ccomp, 1);
67  }
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
real(c_double), private rr
Definition: ERF_module_mp_morr_two_moment.F90:224

Referenced by ERF::average_down_precip_accumulators().

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

Member Data Documentation

◆ m_fba

amrex::BoxArray GroundAverageDown::m_fba
private

Referenced by apply().

◆ m_fdm

amrex::DistributionMapping GroundAverageDown::m_fdm
private

Referenced by apply().

◆ m_fine_box

amrex::Vector<int> GroundAverageDown::m_fine_box
private

Referenced by apply(), and GroundAverageDown().

◆ m_kf

int GroundAverageDown::m_kf
private

Referenced by apply().

◆ m_rr

amrex::IntVect GroundAverageDown::m_rr
private

Referenced by apply().

◆ m_tmp

amrex::MultiFab GroundAverageDown::m_tmp
private

Referenced by apply(), and GroundAverageDown().


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