7 #ifndef ABLASTR_COARSEN_AVERAGE_H_
8 #define ABLASTR_COARSEN_AVERAGE_H_
64 using namespace amrex::literals;
71 int const ic[3] = {
i, j, k};
74 int np[3], idx_min[3];
77 for (
int l = 0; l < 3; ++l) {
81 np[l] =
cr[l] * (1 - sf[l]) * (1 - sc[l])
82 + (2 * (
cr[l] - 1) + 1) * sf[l] * sc[l];
86 for (
int l = 0; l < 3; ++l) {
90 idx_min[l] = ic[l] *
cr[l] * (1 - sf[l]) * (1 - sc[l])
91 + (ic[l] *
cr[l] -
cr[l] + 1) * sf[l] * sc[l];
95 int const numx = np[0];
96 int const numy = np[1];
97 int const numz = np[2];
98 int const imin = idx_min[0];
99 int const jmin = idx_min[1];
100 int const kmin = idx_min[2];
101 int const sfx = sf[0];
102 int const sfy = sf[1];
103 int const sfz = sf[2];
104 int const scx = sc[0];
105 int const scy = sc[1];
106 int const scz = sc[2];
107 int const crx =
cr[0];
108 int const cry =
cr[1];
109 int const crz =
cr[2];
111 amrex::Real wx, wy, wz;
114 auto const arr_src_safe = [arr_src]
115 AMREX_GPU_DEVICE(
int const ix,
int const iy,
int const iz,
int const n) noexcept {
116 return arr_src.
contains(ix, iy, iz) ? arr_src(ix, iy, iz,
n) : 0.0_rt;
127 amrex::Real
c = 0.0_rt;
128 for (
int kref = 0; kref < numz; ++kref) {
129 for (
int jref = 0; jref < numy; ++jref) {
130 for (
int iref = 0; iref < numx; ++iref) {
134 wx = (1.0_rt /
static_cast<amrex::Real
>(numx)) * (1 - sfx) * (1 - scx)
135 + ((amrex::Math::abs(crx - amrex::Math::abs(
ii -
i * crx))) /
136 static_cast<amrex::Real
>(crx * crx)) * sfx * scx;
137 wy = (1.0_rt /
static_cast<amrex::Real
>(numy)) * (1 - sfy) * (1 - scy)
138 + ((amrex::Math::abs(cry - amrex::Math::abs(
jj - j * cry))) /
139 static_cast<amrex::Real
>(cry * cry)) * sfy * scy;
140 wz = (1.0_rt /
static_cast<amrex::Real
>(numz)) * (1 - sfz) * (1 - scz)
141 + ((amrex::Math::abs(crz - amrex::Math::abs(kk - k * crz))) /
142 static_cast<amrex::Real
>(crz * crz)) * sfz * scz;
143 c += wx * wy * wz * arr_src_safe(
ii,
jj, kk, comp);
#define AMREX_ASSERT_WITH_MESSAGE(EX, MSG)
#define AMREX_FORCE_INLINE
Definition: average.cpp:23
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Interp(amrex::Array4< amrex::Real const > const &arr_src, amrex::GpuArray< int, 3 > const &sf, amrex::GpuArray< int, 3 > const &sc, amrex::GpuArray< int, 3 > const &cr, int const i, int const j, int const k, int const comp)
Interpolates the floating point data contained in the source Array4 arr_src, extracted from a fine Mu...
Definition: average.H:53
void Coarsen(amrex::MultiFab &mf_dst, amrex::MultiFab const &mf_src, amrex::IntVect const crse_ratio)
Stores in the coarsened MultiFab mf_dst the values obtained by interpolating the data contained in th...
Definition: average.cpp:96
void Loop(amrex::MultiFab &mf_dst, amrex::MultiFab const &mf_src, int const ncomp, amrex::IntVect const ngrow, amrex::IntVect const crse_ratio)
Loops over the boxes of the coarsened MultiFab mf_dst and fills them by interpolating the data contai...
Definition: average.cpp:25
static constexpr auto c
vacuum speed of light [m/s]
Definition: constant.H:44
i
Definition: check_interp_points_and_weights.py:174
ii
Definition: check_interp_points_and_weights.py:148
jj
Definition: check_interp_points_and_weights.py:160
imin
Definition: check_interp_points_and_weights.py:124
cr
TODO Coarsening for IO: interpolation points and weights def coarsening_points_and_weights_for_IO( i,...
Definition: check_interp_points_and_weights.py:101
int n
Definition: run_libensemble_on_warpx.py:67
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool contains(int i, int j, int k) const noexcept