7 #ifndef ABLASTR_COARSEN_AVERAGE_H_
8 #define ABLASTR_COARSEN_AVERAGE_H_
61 using namespace amrex::literals;
68 int const ic[3] = {
i, j, k};
71 int np[3], idx_min[3];
74 for (
int l = 0; l < 3; ++l) {
78 np[l] =
cr[l] * (1 - sf[l]) * (1 - sc[l])
79 + (2 * (
cr[l] - 1) + 1) * sf[l] * sc[l];
84 for (
int l = 0; l < 3; ++l) {
88 idx_min[l] = ic[l] *
cr[l] * (1 - sf[l]) * (1 - sc[l])
89 + (ic[l] *
cr[l] -
cr[l] + 1) * sf[l] * sc[l];
94 int const numx = np[0];
95 int const numy = np[1];
96 int const numz = np[2];
97 int const imin = idx_min[0];
98 int const jmin = idx_min[1];
99 int const kmin = idx_min[2];
100 int const sfx = sf[0];
101 int const sfy = sf[1];
102 int const sfz = sf[2];
103 int const scx = sc[0];
104 int const scy = sc[1];
105 int const scz = sc[2];
106 int const crx =
cr[0];
107 int const cry =
cr[1];
108 int const crz =
cr[2];
111 auto const arr_src_safe = [arr_src]
124 amrex::Real
c = 0.0_rt;
125 for (
int kref = 0; kref < numz; ++kref) {
126 for (
int jref = 0; jref < numy; ++jref) {
127 for (
int iref = 0; iref < numx; ++iref) {
128 const int ii =
imin + iref;
129 const int jj = jmin + jref;
130 const int kk = kmin + kref;
131 const amrex::Real wx = (1.0_rt /
static_cast<amrex::Real
>(numx)) * (1 - sfx) * (1 - scx)
132 + ((amrex::Math::abs(crx - amrex::Math::abs(
ii -
i * crx))) /
133 static_cast<amrex::Real
>(crx * crx)) * sfx * scx;
134 const amrex::Real wy = (1.0_rt /
static_cast<amrex::Real
>(numy)) * (1 - sfy) * (1 - scy)
135 + ((amrex::Math::abs(cry - amrex::Math::abs(
jj - j * cry))) /
136 static_cast<amrex::Real
>(cry * cry)) * sfy * scy;
137 const amrex::Real wz = (1.0_rt /
static_cast<amrex::Real
>(numz)) * (1 - sfz) * (1 - scz)
138 + ((amrex::Math::abs(crz - amrex::Math::abs(kk - k * crz))) /
139 static_cast<amrex::Real
>(crz * crz)) * sfz * scz;
140 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:24
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:50
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:67
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:26
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
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool contains(int i, int j, int k) const noexcept