ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_GroundAverageDown.H File Reference
#include <AMReX_MultiFab.H>
Include dependency graph for ERF_GroundAverageDown.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  GroundAverageDown
 

Functions

void groundFillFromCoarse (amrex::MultiFab &a_fine, const amrex::MultiFab &a_crse, const amrex::IntVect &a_rr, const int a_kf, const int a_kc, const amrex::Real a_scale, const int a_fcomp=0, const int a_ccomp=0)
 

Function Documentation

◆ groundFillFromCoarse()

void groundFillFromCoarse ( amrex::MultiFab &  a_fine,
const amrex::MultiFab &  a_crse,
const amrex::IntVect &  a_rr,
const int  a_kf,
const int  a_kc,
const amrex::Real  a_scale,
const int  a_fcomp = 0,
const int  a_ccomp = 0 
)
inline

The reverse of GroundAverageDown: each ground cell of a_fine (component a_fcomp) gets a_scale times the coarse ground cell of a_crse (component a_ccomp) it lies over – 1/(rr[0]*rr[1]) for an amount per cell, which keeps the amount under each coarse cell. a_crse must cover the fine ground boxes, coarsened.

88 {
89  const amrex::BoxArray& fba = a_fine.boxArray();
90  amrex::BoxList bl;
91  amrex::Vector<int> fine_box, pmap;
92  for (int ib = 0; ib < fba.size(); ++ib) {
93  if (fba[ib].smallEnd(2) != a_kf) { continue; }
94  amrex::Box s = amrex::coarsen(fba[ib], a_rr);
95  s.setRange(2, a_kc);
96  bl.push_back(s);
97  fine_box.push_back(ib);
98  pmap.push_back(a_fine.DistributionMap()[ib]);
99  }
100  if (bl.isEmpty()) { return; }
101  amrex::MultiFab tmp(amrex::BoxArray(std::move(bl)), amrex::DistributionMapping(std::move(pmap)), 1, 0);
102  tmp.setVal(0.0);
103  tmp.ParallelCopy(a_crse, a_ccomp, 0, 1);
104  const amrex::IntVect rr = a_rr;
105  for (amrex::MFIter mfi(tmp); mfi.isValid(); ++mfi) {
106  const int ib = fine_box[mfi.index()];
107  const auto c = tmp.const_array(mfi);
108  const auto f = a_fine.array(ib, a_fcomp);
109  amrex::Box gbx = fba[ib];
110  gbx.setRange(2, a_kf);
111  amrex::ParallelFor(gbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
112  {
113  // floor division: the coarse cell over fine cell (i, j)
114  const int ic = (i >= 0) ? i / rr[0] : -((-i - 1) / rr[0]) - 1;
115  const int jc = (j >= 0) ? j / rr[1] : -((-j - 1) / rr[1]) - 1;
116  f(i,j,k) = a_scale * c(ic,jc,a_kc);
117  });
118  }
119 }
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);})
@ tmp
Definition: ERF_AdvanceWSM6.cpp:116
real(c_double), private rr
Definition: ERF_module_mp_morr_two_moment.F90:224
Here is the call graph for this function: