53 ReduceOps<ReduceOpSum, ReduceOpSum> reduce_op;
54 ReduceData<Long, Long> reduce_data(reduce_op);
55 const auto dx = geom.CellSizeArray();
56 const auto prob_lo = geom.ProbLoArray();
57 const int source_xmax = grid_nx - 1;
58 const int source_ymax = grid_ny - 1;
67 const int k_ref = geom.Domain().smallEnd(2);
69 for (MFIter mfi(target_field, TilingIfNotGPU()); mfi.isValid(); ++mfi) {
70 Box box = mfi.tilebox();
71 if (box.smallEnd(2) > k_ref || box.bigEnd(2) < k_ref) {
continue; }
72 box.setSmall(2, k_ref);
74 reduce_op.eval(box, reduce_data,
75 [=] AMREX_GPU_DEVICE (
int i,
int j,
int ) -> GpuTuple<Long, Long> {
76 const Real
x =
prob_lo[0] + (
static_cast<Real
>(i) + Real(0.5)) *
dx[0];
77 const Real
y =
prob_lo[1] + (
static_cast<Real
>(j) + Real(0.5)) *
dx[1];
79 x, grid_xmin, grid_dx, grid_nx);
81 y, grid_ymin, grid_dy, grid_ny);
82 const Long outside = (x_stencil.inside && y_stencil.inside) ? Long(0) : Long(1);
83 return {Long(1), outside};
87 const auto local = reduce_data.value();
88 Long total_targets = amrex::get<0>(local);
89 Long outside_targets = amrex::get<1>(local);
90 ParallelDescriptor::ReduceLongSum(total_targets);
91 ParallelDescriptor::ReduceLongSum(outside_targets);
92 if (ParallelDescriptor::IOProcessor() && outside_targets > 0) {
93 const Real source_xhi = grid_xmin +
static_cast<Real
>(source_xmax) * grid_dx;
94 const Real source_yhi = grid_ymin +
static_cast<Real
>(source_ymax) * grid_dy;
95 const Real target_xlo = geom.ProbLo(0) + Real(0.5) * geom.CellSize(0);
96 const Real target_ylo = geom.ProbLo(1) + Real(0.5) * geom.CellSize(1);
97 const Real target_xhi = geom.ProbHi(0) - Real(0.5) * geom.CellSize(0);
98 const Real target_yhi = geom.ProbHi(1) - Real(0.5) * geom.CellSize(1);
99 const Real percentage = total_targets > 0
100 ? Real(100.0) *
static_cast<Real
>(outside_targets) /
101 static_cast<Real
>(total_targets) : Real(0.0);
102 Print() <<
"WARNING: Forest source grid does not cover ERF target cell centers"
103 <<
" at level " << level <<
": outside " << outside_targets <<
" of "
104 << total_targets <<
" (" << percentage <<
"%). Source extent x=["
105 << grid_xmin <<
", " << source_xhi <<
"] y=[" << grid_ymin <<
", "
106 << source_yhi <<
"]; target extent x=[" << target_xlo <<
", "
107 << target_xhi <<
"] y=[" << target_ylo <<
", " << target_yhi <<
"].\n";
GpuArray< Real, AMREX_SPACEDIM > dx
Definition: ERF_ActuatorSpreading.cpp:131
const GpuArray< Real, AMREX_SPACEDIM > prob_lo
Definition: ERF_InitCustomPert_CloudChamber.H:34
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE InterpolationStencil uniform_interpolation_stencil(amrex::Real coordinate, amrex::Real origin, amrex::Real spacing, int point_count) noexcept
Definition: ERF_GridUtils.H:305