1 #ifndef AMReX_extrapolater_2D_K_H_
2 #define AMReX_extrapolater_2D_K_H_
3 #include <AMReX_Config.H>
15 using namespace amrex::literals;
17 constexpr
int finecell = 1;
18 constexpr
int crsecell = 0;
25 for (
int n = 0; n <
nComp; n++) {
30 for (
int i = lo.x-1; i <= hi.x+1; ++i) {
31 if (
mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); }
34 for (
int i = lo.x-1; i <= hi.x+1; ++i) {
35 if (
mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); }
40 for (
int j = lo.y-1; j <= hi.y+1; ++j) {
41 if (
mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); }
44 for (
int j = lo.y-1; j <= hi.y+1; ++j) {
45 if (
mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); }
54 if (
mask(i,j,k) == crsecell ) {
55 if ( (
mask(i+1,j,k) == finecell ) ||
56 (
mask(i,j+1,k) == finecell ) ) {
57 data(i,j,k,n) = ( Real(
mask(i+1,j,k)) * data(i+1,j,k,n) + Real(
mask(i,j+1,k)) * data(i,j+1,k,n) )
58 / Real(
mask(i+1,j,k) +
mask(i,j+1,k) );
60 data(i,j,k,n) = data(i+1,j+1,k,n);
68 if (
mask(i,j,k) == crsecell ) {
69 if ( (
mask(i+1,j,k) == finecell ) ||
70 (
mask(i,j-1,k) == finecell ) ) {
71 data(i,j,k,n) = ( Real(
mask(i+1,j,k)) * data(i+1,j,k,n) + Real(
mask(i,j-1,k)) * data(i,j-1,k,n) )
72 / Real(
mask(i+1,j,k) +
mask(i,j-1,k) );
74 data(i,j,k,n) = data(i+1,j-1,k,n);
82 if (
mask(i,j,k) == crsecell ) {
83 if ( (
mask(i-1,j,k) == finecell ) ||
84 (
mask(i,j+1,k) == finecell ) ) {
85 data(i,j,k,n) = ( Real(
mask(i-1,j,k)) * data(i-1,j,k,n) + Real(
mask(i,j+1,k)) * data(i,j+1,k,n) )
86 / Real(
mask(i-1,j,k) +
mask(i,j+1,k) );
88 data(i,j,k,n) = data(i-1,j+1,k,n);
96 if (
mask(i,j,k) == crsecell ) {
97 if ( (
mask(i-1,j,k) == finecell ) ||
98 (
mask(i,j-1,k) == finecell ) ) {
99 data(i,j,k,n) = ( Real(
mask(i-1,j,k)) * data(i-1,j,k,n) + Real(
mask(i,j-1,k)) * data(i,j-1,k,n) )
100 / Real(
mask(i-1,j,k) +
mask(i,j-1,k) );
102 data(i,j,k,n) = data(i-1,j-1,k,n);
110 for (
int j = lo.y; j <= hi.y; ++j) {
111 if (
mask(i,j,k) == crsecell ) {
112 data(i,j,k,n) = ( Real(
mask(i,j-1,k)) * data(i,j-1,k,n) + data(i+1,j,k,n) + Real(
mask(i,j+1,k)) * data(i,j+1,k,n) )
113 / Real(
mask(i,j-1,k) + 1 +
mask(i,j+1,k) );
120 for (
int j = lo.y; j <= hi.y; ++j) {
121 if (
mask(i,j,k) == crsecell ) {
122 data(i,j,k,n) = ( Real(
mask(i,j-1,k)) * data(i,j-1,k,n) + data(i-1,j,k,n) + Real(
mask(i,j+1,k)) * data(i,j+1,k,n) )
123 / Real(
mask(i,j-1,k) + 1 +
mask(i,j+1,k) );
130 for (
int i = lo.x; i <= hi.x; ++i) {
131 if (
mask(i,j,k) == crsecell ) {
132 data(i,j,k,n) = ( Real(
mask(i-1,j,k)) * data(i-1,j,k,n) + Real(
mask(i+1,j,k)) * data(i+1,j,k,n) + data(i,j+1,k,n) )
133 / Real(
mask(i-1,j,k) +
mask(i+1,j,k) + 1 );
140 for (
int i = lo.x; i <= hi.x; ++i) {
141 if (
mask(i,j,k) == crsecell ) {
142 data(i,j,k,n) = ( Real(
mask(i-1,j,k)) * data(i-1,j,k,n) + Real(
mask(i+1,j,k)) * data(i+1,j,k,n) + data(i,j-1,k,n) )
143 / Real(
mask(i-1,j,k) +
mask(i+1,j,k) + 1 );
158 using namespace amrex::literals;
160 constexpr
int finecell = 1;
161 constexpr
int crsecell = 0;
166 if (
mask(i,j,k) == crsecell ) {
169 if ( (i == lo.x-1) && (j == lo.y-1) ) {
170 if ( (
mask(i+1,j,k) == finecell ) ||
171 (
mask(i,j+1,k) == finecell ) ) {
172 data(i,j,k,n) = ( Real(
mask(i+1,j,k)) * data(i+1,j,k,n) + Real(
mask(i,j+1,k)) * data(i,j+1,k,n) )
173 / Real(
mask(i+1,j,k) +
mask(i,j+1,k) );
175 data(i,j,k,n) = data(i+1,j+1,k,n);
178 }
else if ( (i == lo.x-1) && (j == hi.y+1) ) {
179 if ( (
mask(i+1,j,k) == finecell ) ||
180 (
mask(i,j-1,k) == finecell ) ) {
181 data(i,j,k,n) = ( Real(
mask(i+1,j,k)) * data(i+1,j,k,n) + Real(
mask(i,j-1,k)) * data(i,j-1,k,n) )
182 / Real(
mask(i+1,j,k) +
mask(i,j-1,k) );
184 data(i,j,k,n) = data(i+1,j-1,k,n);
187 }
else if ( (i == hi.x+1) && (j == lo.y-1) ) {
188 if ( (
mask(i-1,j,k) == finecell ) ||
189 (
mask(i,j+1,k) == finecell ) ) {
190 data(i,j,k,n) = ( Real(
mask(i-1,j,k)) * data(i-1,j,k,n) + Real(
mask(i,j+1,k)) * data(i,j+1,k,n) )
191 / Real(
mask(i-1,j,k) +
mask(i,j+1,k) );
193 data(i,j,k,n) = data(i-1,j+1,k,n);
196 }
else if ( (i == hi.x+1) && (j == hi.y+1) ) {
197 if ( (
mask(i-1,j,k) == finecell ) ||
198 (
mask(i,j-1,k) == finecell ) ) {
199 data(i,j,k,n) = ( Real(
mask(i-1,j,k)) * data(i-1,j,k,n) + Real(
mask(i,j-1,k)) * data(i,j-1,k,n) )
200 / Real(
mask(i-1,j,k) +
mask(i,j-1,k) );
202 data(i,j,k,n) = data(i-1,j-1,k,n);
206 }
else if ( (i == lo.x-1) && (j >= lo.y) && (j <= hi.y) ) {
207 data(i,j,k,n) = ( Real(
mask(i,j-1,k)) * data(i,j-1,k,n) + data(i+1,j,k,n) + Real(
mask(i,j+1,k)) * data(i,j+1,k,n) )
208 / Real(
mask(i,j-1,k) + 1 +
mask(i,j+1,k) );
210 }
else if ( (i == hi.x+1) && (j >= lo.y) && (j <= hi.y) ) {
211 data(i,j,k,n) = ( Real(
mask(i,j-1,k)) * data(i,j-1,k,n) + data(i-1,j,k,n) + Real(
mask(i,j+1,k)) * data(i,j+1,k,n) )
212 / Real(
mask(i,j-1,k) + 1 +
mask(i,j+1,k) );
214 }
else if ( (i >= lo.x) && (i <= hi.x) && (j == lo.y-1) ) {
215 data(i,j,k,n) = ( Real(
mask(i-1,j,k)) * data(i-1,j,k,n) + Real(
mask(i+1,j,k)) * data(i+1,j,k,n) + data(i,j+1,k,n) )
216 / Real(
mask(i-1,j,k) +
mask(i+1,j,k) + 1 );
218 }
else if ( (i >= lo.x) && (i <= hi.x) && (j == hi.y+1) ) {
219 data(i,j,k,n) = ( Real(
mask(i-1,j,k)) * data(i-1,j,k,n) + Real(
mask(i+1,j,k)) * data(i+1,j,k,n) + data(i,j-1,k,n) )
220 / Real(
mask(i-1,j,k) +
mask(i+1,j,k) + 1 );
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
#define AMREX_GPU_HOST
Definition: AMReX_GpuQualifiers.H:17
Array4< int const > mask
Definition: AMReX_InterpFaceRegister.cpp:93
Definition: AMReX_Amr.cpp:49
int nComp(FabArrayBase const &fa)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 ubound(Array4< T > const &a) noexcept
Definition: AMReX_Array4.H:315
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 lbound(Array4< T > const &a) noexcept
Definition: AMReX_Array4.H:308
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void amrex_first_order_extrap_gpu(int i, int j, int k, int n, amrex::Box const &bx, amrex::Array4< const int > const &mask, amrex::Array4< amrex::Real > const &data) noexcept
Definition: AMReX_extrapolater_1D_K.H:36
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void amrex_first_order_extrap_cpu(amrex::Box const &bx, int nComp, amrex::Array4< const int > const &mask, amrex::Array4< amrex::Real > const &data) noexcept
Definition: AMReX_extrapolater_1D_K.H:10
Definition: AMReX_Array4.H:61