1 #ifndef AMREX_HYPRE_ML_ABECLAP_2D_K_H_
2 #define AMREX_HYPRE_ML_ABECLAP_2D_K_H_
14 IntVect const& refratio,
int not_covered)
17 for (
auto&
x : tmp) {
x = Real(0.0); }
20 for (
auto&
x : used) {
x = 0; }
23 auto const face = ori();
24 int const idir = face.coordDir();
25 int const idir1 = 1-
idir;
29 auto const& msk = bmask[face];
30 if (msk.contains(cell_out) && msk(cell_out) == not_covered) {
38 offset_t[idir1] = refratio[idir1];
39 Real bcoeff =
b[
idir] ?
b[
idir](face.isLow() ? cell : cell_out) : Real(1.0);
42 Real xx[3] = {Real(-0.5)*Real(refratio[
idir]), Real(0.5), Real(1.5)};
43 poly_interp_coeff<3>(Real(-0.5), xx, poly_coef);
45 Real fac = -(sb / (dx[
idir]*dx[
idir])) * bcoeff * poly_coef[0];
46 int const rr1 = refratio[idir1];
47 int const i1 = cell[idir1];
49 Real xInt = Real(-0.5) + (i1-i1c*rr1+Real(0.5))/Real(rr1);
50 Real xc[] = {Real(-1.0), Real(0.0), Real(1.0)};
51 Real c[] = {Real(0.0), Real(0.0), Real(0.0)};
53 if (msk(cell_out-offset_t) == not_covered &&
54 msk(cell_out+offset_t) == not_covered)
56 poly_interp_coeff<3>(xInt, xc, c);
57 cc[0] = cc[1] = cc[2] = 1;
58 }
else if (msk(cell_out+offset_t) == not_covered) {
59 poly_interp_coeff<2>(xInt, &(xc[1]), &(c[1]));
62 poly_interp_coeff<2>(xInt, xc, c);
66 for (
int m = 0; m < 3; ++m) {
67 tmp(-1,m-1) += c[m] * fac;
68 used(-1,m-1) += cc[m];
71 for (
int m = 0; m < 3; ++m) {
72 tmp(1,m-1) += c[m] * fac;
76 for (
int m = 0; m < 3; ++m) {
77 tmp(m-1,-1) += c[m] * fac;
78 used(m-1,-1) += cc[m];
81 for (
int m = 0; m < 3; ++m) {
82 tmp(m-1,1) += c[m] * fac;
89 auto const* ptmp = tmp.
begin();
90 auto const* pused = used.
begin();
91 for (
int m = 0; m < 9; ++m) {
103 int* entry_offset, Real* entry_values,
110 Real
const* bx, Real
const* by,
114 if (fine_mask(i,j,k)) {
116 for (
int m = 1; m < 2*AMREX_SPACEDIM+1; ++m) {
117 stencil(i,j,k)[m] = Real(0.0);
119 }
else if (nentries_to(i,j,k) > 0) {
120 int const fromoff = offset_from(i,j,k);
123 nentries[fromoff] = nentries_to(i,j,k);
124 int foff = offset_to(i,j,k);
125 entry_offset[fromoff] = foff;
134 if (fine_mask(i,j-1,k)) {
135 stencil(i,j,k)[0] += stencil(i,j,k)[3];
136 stencil(i,j,k)[3] = Real(0.0);
139 Real dyf = dx[1] / Real(rr[1]);
140 Real dycinv = Real(1.0) / dx[1];
141 Real dyfinv = Real(1.0) / dyf;
143 Real yy[3] = {dx[1]*Real(-0.5), dyf*Real(0.5), dyf*Real(1.5)};
144 poly_interp_coeff<3>(dyf*Real(-0.5), yy, cc);
145 for (
int irx = 0; irx < rr[0]; ++irx) {
146 Real bym = by ? by[offset_by(i,j,k)+irx] : Real(1.0);
147 Real fac = sb*dycinv*dyfinv*bym/Real(rr[0]);
155 entry_values[foff+irx ] += fac* cc[2];
156 entry_values[foff+irx+rr[0]] += fac*(cc[1]-Real(1.0));
159 Real xInt = Real(-0.5) + (irx+Real(0.5))/Real(rr[0]);
160 Real xc[3] = {Real(-1.0), Real(0.0), Real(1.0)};
161 Real ct[3] = {Real(0.0), Real(0.0), Real(0.0)};
162 if ( fine_mask(i-1,j,k) ||
165 poly_interp_coeff<2>(xInt, &(xc[1]), &(ct[1]));
166 }
else if ( fine_mask(i+1,j,k) ||
169 poly_interp_coeff<2>(xInt, xc, ct);
171 poly_interp_coeff<3>(xInt, xc, ct);
174 stencil(i,j,k)[0] += (fac*cc[0])*ct[1];
175 stencil(i,j,k)[1] += (fac*cc[0])*ct[0];
176 stencil(i,j,k)[2] += (fac*cc[0])*ct[2];
181 if (fine_mask(i-1,j,k)) {
182 stencil(i,j,k)[0] += stencil(i,j,k)[1];
183 stencil(i,j,k)[1] = Real(0.0);
186 Real dxf = dx[0] / Real(rr[0]);
187 Real dxcinv = Real(1.0) / dx[0];
188 Real dxfinv = Real(1.0) / dxf;
190 Real xx[3] = {dx[0]*Real(-0.5), dxf*Real(0.5), dxf*Real(1.5)};
191 poly_interp_coeff<3>(dxf*Real(-0.5), xx, cc);
192 for (
int iry = 0; iry < rr[1]; ++iry) {
193 Real bxm = bx ? bx[offset_bx(i,j,k)+iry] : Real(1.0);
194 Real fac = sb*dxcinv*dxfinv*bxm/Real(rr[1]);
202 entry_values[foff++] = fac* cc[2];
203 entry_values[foff++] = fac*(cc[1] - Real(1.0));
206 Real yInt = Real(-0.5) + (iry+Real(0.5))/Real(rr[1]);
207 Real yc[3] = {Real(-1.0), Real(0.0), Real(1.0)};
208 Real ct[3] = {Real(0.0), Real(0.0), Real(0.0)};
209 if ( fine_mask(i,j-1,k) ||
212 poly_interp_coeff<2>(yInt, &(yc[1]), &(ct[1]));
213 }
else if ( fine_mask(i,j+1,k) ||
216 poly_interp_coeff<2>(yInt, yc, ct);
218 poly_interp_coeff<3>(yInt, yc, ct);
221 stencil(i,j,k)[0] += (fac*cc[0])*ct[1];
222 stencil(i,j,k)[3] += (fac*cc[0])*ct[0];
223 stencil(i,j,k)[4] += (fac*cc[0])*ct[2];
227 if (fine_mask(i+1,j,k)) {
228 stencil(i,j,k)[0] += stencil(i,j,k)[2];
229 stencil(i,j,k)[2] = Real(0.0);
232 Real dxf = dx[0] / Real(rr[0]);
233 Real dxcinv = Real(1.0) / dx[0];
234 Real dxfinv = Real(1.0) / dxf;
236 Real xx[3] = {dx[0]*Real(-0.5), dxf*Real(0.5), dxf*Real(1.5)};
237 poly_interp_coeff<3>(dxf*Real(-0.5), xx, cc);
238 for (
int iry = 0; iry < rr[1]; ++iry) {
239 Real bxp = bx ? bx[offset_bx(i+1,j,k)+iry] : Real(1.0);
240 Real fac = sb*dxcinv*dxfinv*bxp/Real(rr[1]);
248 entry_values[foff++] = fac*(cc[1] - Real(1.0));
249 entry_values[foff++] = fac* cc[2];
252 Real yInt = Real(-0.5) + (iry+Real(0.5))/Real(rr[1]);
253 Real yc[3] = {Real(-1.0), Real(0.0), Real(1.0)};
254 Real ct[3] = {Real(0.0), Real(0.0), Real(0.0)};
255 if ( fine_mask(i,j-1,k) ||
258 poly_interp_coeff<2>(yInt, &(yc[1]), &(ct[1]));
259 }
else if ( fine_mask(i,j+1,k) ||
262 poly_interp_coeff<2>(yInt, yc, ct);
264 poly_interp_coeff<3>(yInt, yc, ct);
267 stencil(i,j,k)[0] += (fac*cc[0])*ct[1];
268 stencil(i,j,k)[3] += (fac*cc[0])*ct[0];
269 stencil(i,j,k)[4] += (fac*cc[0])*ct[2];
273 if (fine_mask(i,j+1,k)) {
274 stencil(i,j,k)[0] += stencil(i,j,k)[4];
275 stencil(i,j,k)[4] = Real(0.0);
278 Real dyf = dx[1] / Real(rr[1]);
279 Real dycinv = Real(1.0) / dx[1];
280 Real dyfinv = Real(1.0) / dyf;
282 Real yy[3] = {dx[1]*Real(-0.5), dyf*Real(0.5), dyf*Real(1.5)};
283 poly_interp_coeff<3>(dyf*Real(-0.5), yy, cc);
284 for (
int irx = 0; irx < rr[0]; ++irx) {
285 Real byp = by ? by[offset_by(i,j+1,k)+irx] : Real(1.0);
286 Real fac = sb*dycinv*dyfinv*byp/Real(rr[0]);
294 entry_values[foff+irx ] += fac*(cc[1]-Real(1.0));
295 entry_values[foff+irx+rr[0]] += fac* cc[2];
298 Real xInt = Real(-0.5) + (irx+Real(0.5))/Real(rr[0]);
299 Real xc[3] = {Real(-1.0), Real(0.0), Real(1.0)};
300 Real ct[3] = {Real(0.0), Real(0.0), Real(0.0)};
301 if ( fine_mask(i-1,j,k) ||
304 poly_interp_coeff<2>(xInt, &(xc[1]), &(ct[1]));
305 }
else if ( fine_mask(i+1,j,k) ||
308 poly_interp_coeff<2>(xInt, xc, ct);
310 poly_interp_coeff<3>(xInt, xc, ct);
313 stencil(i,j,k)[0] += (fac*cc[0])*ct[1];
314 stencil(i,j,k)[1] += (fac*cc[0])*ct[0];
315 stencil(i,j,k)[2] += (fac*cc[0])*ct[2];
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_DEVICE
Definition: AMReX_GpuQualifiers.H:18
int idir
Definition: AMReX_HypreMLABecLap.cpp:1093
Array4< int const > offset
Definition: AMReX_HypreMLABecLap.cpp:1089
An Iterator over the Orientation of Faces of a Box.
Definition: AMReX_Orientation.H:135
Encapsulation of the Orientation of the Faces of a Box.
Definition: AMReX_Orientation.H:29
@ low
Definition: AMReX_Orientation.H:34
@ high
Definition: AMReX_Orientation.H:34
Definition: AMReX_Amr.cpp:49
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void hypmlabeclap_c2f(int i, int j, int k, Array4< GpuArray< Real, 2 *AMREX_SPACEDIM+1 >> const &stencil, GpuArray< HYPRE_Int, AMREX_SPACEDIM > *civ, HYPRE_Int *nentries, int *entry_offset, Real *entry_values, Array4< int const > const &offset_from, Array4< int const > const &nentries_to, Array4< int const > const &offset_to, GpuArray< Real, AMREX_SPACEDIM > const &dx, Real sb, Array4< int const > const &offset_bx, Array4< int const > const &offset_by, Real const *bx, Real const *by, Array4< int const > const &fine_mask, IntVect const &rr, Array4< int const > const &crse_mask)
Definition: AMReX_HypreMLABecLap_2D_K.H:100
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void hypmlabeclap_f2c_set_values(IntVect const &cell, Real *values, GpuArray< Real, AMREX_SPACEDIM > const &dx, Real sb, GpuArray< Array4< Real const >, AMREX_SPACEDIM > const &b, GpuArray< Array4< int const >, AMREX_SPACEDIM *2 > const &bmask, IntVect const &refratio, int not_covered)
Definition: AMReX_HypreMLABecLap_2D_K.H:10
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > coarsen(const BoxND< dim > &b, int ref_ratio) noexcept
Coarsen BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo/rati...
Definition: AMReX_Box.H:1304
const int[]
Definition: AMReX_BLProfiler.cpp:1664
Definition: AMReX_Array.H:282
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T * begin() const noexcept
Definition: AMReX_Array.H:341
Definition: AMReX_Array4.H:61