ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
erf_detail_MakeNewLevel Namespace Reference

Functions

void fill_time_average_sum (MultiFab &new_sum, const MultiFab *old_sum, double fine_cnt, const MultiFab *crse_sum, double crse_cnt, const Geometry &crse_geom, const Geometry &fine_geom, const IntVect &ratio)
 
void fill_qmoist_restart_var (MultiFab &dst, const MultiFab *old_mf, const MultiFab *crse_mf, const Geometry &crse_geom, const Geometry &fine_geom, const IntVect &ratio)
 
void mask_thin_body_faces (iMultiFab &imask, const Vector< IntVect > &faces, int dir, const char *name)
 

Function Documentation

◆ fill_qmoist_restart_var()

void erf_detail_MakeNewLevel::fill_qmoist_restart_var ( MultiFab &  dst,
const MultiFab *  old_mf,
const MultiFab *  crse_mf,
const Geometry &  crse_geom,
const Geometry &  fine_geom,
const IntVect &  ratio 
)
572 {
573  const int ncomp = dst.nComp();
574  if (crse_mf != nullptr) {
575  MultiFab tmp(dst.boxArray(), dst.DistributionMap(), ncomp, 0);
576  Vector<BCRec> bcs(ncomp); // unused by pc_interp, which needs no coarse ghost cells
577  for (int n = 0; n < ncomp; ++n) {
578  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
579  bcs[n].setLo(dir, BCType::foextrap);
580  bcs[n].setHi(dir, BCType::foextrap);
581  }
582  }
583  InterpFromCoarseLevel(tmp, IntVect(0), IntVect(0), *crse_mf, 0, 0, ncomp,
584  crse_geom, fine_geom, ratio, &pc_interp, bcs, 0);
585  const int klo = fine_geom.Domain().smallEnd(2);
586  for (MFIter mfi(dst, TilingIfNotGPU()); mfi.isValid(); ++mfi) {
587  Box bx = mfi.tilebox();
588  if (bx.smallEnd(2) > klo) { continue; }
589  bx.setBig(2, klo);
590  const auto& dst_arr = dst.array(mfi);
591  const auto& tmp_arr = tmp.const_array(mfi);
592  ParallelFor(bx, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
593  {
594  dst_arr(i,j,k,n) = tmp_arr(i,j,k,n);
595  });
596  }
597  }
598  if (old_mf != nullptr) { dst.ParallelCopy(*old_mf, 0, 0, ncomp); }
599  dst.FillBoundary(fine_geom.periodicity());
600 }
const int klo
Definition: ERF_InitCustomPert_KE.H:9
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);})
@ foextrap
Definition: ERF_IndexDefines.H:316
@ tmp
Definition: ERF_AdvanceWSM6.cpp:116

Referenced by ERF::MakeNewLevelFromCoarse(), and ERF::RemakeLevel().

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

◆ fill_time_average_sum()

void erf_detail_MakeNewLevel::fill_time_average_sum ( MultiFab &  new_sum,
const MultiFab *  old_sum,
double  fine_cnt,
const MultiFab *  crse_sum,
double  crse_cnt,
const Geometry &  crse_geom,
const Geometry &  fine_geom,
const IntVect &  ratio 
)
39 {
40  const int ncomp = new_sum.nComp();
41  new_sum.setVal(zero);
42 
43  if (crse_sum != nullptr && crse_cnt > 0.0) {
44  MultiFab crse_scaled(crse_sum->boxArray(), crse_sum->DistributionMap(), ncomp, 0);
45  MultiFab::Copy(crse_scaled, *crse_sum, 0, 0, ncomp, 0);
46  crse_scaled.mult(static_cast<Real>(fine_cnt / crse_cnt), 0, ncomp, 0);
47  // Piecewise-constant interpolation reads no coarse ghost cells, so no boundary
48  // condition is ever applied; the BCRecs are only required by the interface.
49  Vector<BCRec> bcs(ncomp);
50  for (auto& bc : bcs) {
51  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
52  bc.setLo(dir, BCType::foextrap);
53  bc.setHi(dir, BCType::foextrap);
54  }
55  }
56  InterpFromCoarseLevel(new_sum, IntVect(0), IntVect(0), crse_scaled, 0, 0, ncomp,
57  crse_geom, fine_geom, ratio, &pc_interp, bcs, 0);
58  }
59 
60  if (old_sum != nullptr) {
61  new_sum.ParallelCopy(*old_sum, 0, 0, ncomp);
62  }
63 }
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
real(c_double), private bc
Definition: ERF_module_mp_morr_two_moment.F90:182

Referenced by ERF::MakeNewLevelFromCoarse(), and ERF::RemakeLevel().

Here is the caller graph for this function:

◆ mask_thin_body_faces()

void erf_detail_MakeNewLevel::mask_thin_body_faces ( iMultiFab &  imask,
const Vector< IntVect > &  faces,
int  dir,
const char *  name 
)

Set the thin-body flux mask to 0 on the listed faces. The mask lives in the default arena, which is device memory on GPU builds, so the faces are copied to the device and set in a kernel; the diagnostic print loops over the host list and reads no device memory.

2127 {
2128  if (faces.empty()) { return; }
2129  const int nf = static_cast<int>(faces.size());
2130  Gpu::DeviceVector<IntVect> d_faces(nf);
2131  Gpu::copy(Gpu::hostToDevice, faces.begin(), faces.end(), d_faces.begin());
2132  const IntVect* f = d_faces.data();
2133  for (MFIter mfi(imask, TilingIfNotGPU()); mfi.isValid(); ++mfi)
2134  {
2135  Array4<int> const& imask_arr = imask.array(mfi);
2136  const Box fbx = mfi.nodaltilebox(dir);
2137  ParallelFor(nf, [=] AMREX_GPU_DEVICE (int iv) noexcept
2138  {
2139  if (fbx.contains(f[iv])) { imask_arr(f[iv]) = 0; }
2140  });
2141  for (const auto& faceidx : faces) {
2142  if (fbx.contains(faceidx)) {
2143  amrex::AllPrint() << " mask " << name << " at " << faceidx << std::endl;
2144  }
2145  }
2146  }
2147  // The MFIter may have launched on several streams; wait for all of them before d_faces
2148  // goes out of scope (a one-time setup, so a device-wide sync costs nothing)
2149  Gpu::synchronize();
2150 }
std::string name
Definition: ERF_Plotfile2DCatalog.cpp:139

Referenced by ERF::init_thin_body().

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