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

Functions

void overwrite_valid_land_surface_cells (MultiFab &dst, const MultiFab &src, Real scale, const MultiFab *add)
 

Function Documentation

◆ overwrite_valid_land_surface_cells()

void erf_detail_SEBTurbulentFlux::overwrite_valid_land_surface_cells ( MultiFab &  dst,
const MultiFab &  src,
Real  scale,
const MultiFab *  add 
)
18 {
19  // The kernel reads src and add through dst's MFIter, so the boxes themselves (and
20  // their index type), not only their number, must agree.
22  src.boxArray() == dst.boxArray() &&
23  src.DistributionMap() == dst.DistributionMap() &&
24  (add == nullptr || (add->boxArray() == dst.boxArray() &&
25  add->DistributionMap() == dst.DistributionMap())),
26  "SEB land-surface fill: the land-surface fields and the SEB field are laid out differently");
27  const bool has_add = (add != nullptr);
28 #ifdef _OPENMP
29 #pragma omp parallel if (Gpu::notInLaunchRegion())
30 #endif
31  for (MFIter mfi(dst, TilingIfNotGPU()); mfi.isValid(); ++mfi) {
32  const Box& bx = mfi.tilebox();
33  const auto dst_arr = dst.array(mfi);
34  const auto src_arr = src.const_array(mfi);
35  const auto add_arr = has_add ? add->const_array(mfi) : Array4<const Real>{};
36  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
37  {
38  const Real value = src_arr(i, j, k);
39  const Real extra = has_add ? add_arr(i, j, k) : Real(0.0);
40  if (is_valid_lsm_value(value) && is_valid_lsm_value(extra)) {
41  dst_arr(i, j, k) = scale * value + extra;
42  }
43  });
44  }
45 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool is_valid_lsm_value(amrex::Real v)
Definition: ERF_Constants.H:38
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
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);})

Referenced by fill_seb_field_from_land_surface(), and fill_seb_turbulent_flux().

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