Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
AMReX_MLNodeLap_3D_K.H
Go to the documentation of this file.
1#ifndef AMREX_MLNODELAP_3D_K_H_
2#define AMREX_MLNODELAP_3D_K_H_
3#include <AMReX_Config.H>
4
5namespace amrex {
6
8void mlndlap_zero_fine (int i, int j, int k, Array4<Real> const& phi,
9 Array4<int const> const& msk, int fine_flag) noexcept
10{
11 // Testing if the node is covered by a fine level in computing
12 // coarse sync residual
13 if (msk(i-1,j-1,k-1) == fine_flag &&
14 msk(i ,j-1,k-1) == fine_flag &&
15 msk(i-1,j ,k-1) == fine_flag &&
16 msk(i ,j ,k-1) == fine_flag &&
17 msk(i-1,j-1,k ) == fine_flag &&
18 msk(i ,j-1,k ) == fine_flag &&
19 msk(i-1,j ,k ) == fine_flag &&
20 msk(i ,j ,k ) == fine_flag)
21 {
22 phi(i,j,k) = Real(0.0);
23 }
24}
25
26//
27// coeffs
28//
29
31void mlndlap_avgdown_coeff_x (int i, int j, int k, Array4<Real> const& crse,
32 Array4<Real const> const& fine) noexcept
33{
34 Real cl = fine(2*i ,2*j,2*k )+fine(2*i ,2*j+1,2*k )+
35 fine(2*i ,2*j,2*k+1)+fine(2*i ,2*j+1,2*k+1);
36 Real cr = fine(2*i+1,2*j,2*k )+fine(2*i+1,2*j+1,2*k )+
37 fine(2*i+1,2*j,2*k+1)+fine(2*i+1,2*j+1,2*k+1);
38 crse(i,j,k) = Real(0.5)*cl*cr/(cl+cr);
39}
40
42void mlndlap_avgdown_coeff_y (int i, int j, int k, Array4<Real> const& crse,
43 Array4<Real const> const& fine) noexcept
44{
45 Real cl = fine(2*i,2*j ,2*k )+fine(2*i+1,2*j ,2*k )+
46 fine(2*i,2*j ,2*k+1)+fine(2*i+1,2*j ,2*k+1);
47 Real cr = fine(2*i,2*j+1,2*k )+fine(2*i+1,2*j+1,2*k )+
48 fine(2*i,2*j+1,2*k+1)+fine(2*i+1,2*j+1,2*k+1);
49 crse(i,j,k) = Real(0.5)*cl*cr/(cl+cr);
50}
51
53void mlndlap_avgdown_coeff_z (int i, int j, int k, Array4<Real> const& crse,
54 Array4<Real const> const& fine) noexcept
55{
56 Real cl = fine(2*i,2*j ,2*k )+fine(2*i+1,2*j ,2*k )+
57 fine(2*i,2*j+1,2*k )+fine(2*i+1,2*j+1,2*k );
58 Real cr = fine(2*i,2*j ,2*k+1)+fine(2*i+1,2*j ,2*k+1)+
59 fine(2*i,2*j+1,2*k+1)+fine(2*i+1,2*j+1,2*k+1);
60 crse(i,j,k) = Real(0.5)*cl*cr/(cl+cr);
61}
62
64void mlndlap_semi_avgdown_coeff (int i, int j, int k, Array4<Real> const& crse,
65 Array4<Real const> const& fine, int idir) noexcept
66{
67 if (idir == 2) {
68 Real cl = fine(2*i ,2*j,k) + fine(2*i ,2*j+1,k);
69 Real cr = fine(2*i+1,2*j,k) + fine(2*i+1,2*j+1,k);
70 crse(i,j,k) = cl*cr/(cl+cr);
71 } else if (idir == 1) {
72 Real cl = fine(2*i ,j,2*k) + fine(2*i ,j,2*k+1);
73 Real cr = fine(2*i+1,j,2*k) + fine(2*i+1,j,2*k+1);
74 crse(i,j,k) = cl*cr/(cl+cr);
75 } else {
76 Real cl = fine(i,2*j ,2*k) + fine(i,2*j ,2*k+1);
77 Real cr = fine(i,2*j+1,2*k) + fine(i,2*j+1,2*k+1);
78 crse(i,j,k) = cl*cr/(cl+cr);
79 }
80}
81
82//
83// operator
84//
85
87Real mlndlap_adotx_ha (int i, int j, int k, Array4<Real const> const& x,
88 Array4<Real const> const& sx, Array4<Real const> const& sy,
89 Array4<Real const> const& sz, Array4<int const> const& msk,
90 GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
91{
92 if (msk(i,j,k)) {
93 return Real(0.0);
94 } else {
95 Real facx = Real(1./36.)*dxinv[0]*dxinv[0];
96 Real facy = Real(1./36.)*dxinv[1]*dxinv[1];
97 Real facz = Real(1./36.)*dxinv[2]*dxinv[2];
98 Real y = x(i,j,k)*Real(-4.0)*(facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1)+sx(i-1,j,k-1)+sx(i,j,k-1)
99 +sx(i-1,j-1,k )+sx(i,j-1,k )+sx(i-1,j,k )+sx(i,j,k ))
100 +facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1)+sy(i-1,j,k-1)+sy(i,j,k-1)
101 +sy(i-1,j-1,k )+sy(i,j-1,k )+sy(i-1,j,k )+sy(i,j,k ))
102 +facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)+sz(i-1,j,k-1)+sz(i,j,k-1)
103 +sz(i-1,j-1,k )+sz(i,j-1,k )+sz(i-1,j,k )+sz(i,j,k )));
104 y += x(i-1,j-1,k-1)*(facx*sx(i-1,j-1,k-1)
105 +facy*sy(i-1,j-1,k-1)
106 +facz*sz(i-1,j-1,k-1))
107 + x(i+1,j-1,k-1)*(facx*sx(i ,j-1,k-1)
108 +facy*sy(i ,j-1,k-1)
109 +facz*sz(i ,j-1,k-1))
110 + x(i-1,j+1,k-1)*(facx*sx(i-1,j ,k-1)
111 +facy*sy(i-1,j ,k-1)
112 +facz*sz(i-1,j ,k-1))
113 + x(i+1,j+1,k-1)*(facx*sx(i ,j ,k-1)
114 +facy*sy(i ,j ,k-1)
115 +facz*sz(i ,j ,k-1))
116 + x(i-1,j-1,k+1)*(facx*sx(i-1,j-1,k )
117 +facy*sy(i-1,j-1,k )
118 +facz*sz(i-1,j-1,k ))
119 + x(i+1,j-1,k+1)*(facx*sx(i ,j-1,k )
120 +facy*sy(i ,j-1,k )
121 +facz*sz(i ,j-1,k ))
122 + x(i-1,j+1,k+1)*(facx*sx(i-1,j ,k )
123 +facy*sy(i-1,j ,k )
124 +facz*sz(i-1,j ,k ))
125 + x(i+1,j+1,k+1)*(facx*sx(i ,j ,k )
126 +facy*sy(i ,j ,k )
127 +facz*sz(i ,j ,k ));
128 y += x(i ,j-1,k-1)*( -facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1))
129 +Real(2.0)*facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1))
130 +Real(2.0)*facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)))
131 + x(i ,j+1,k-1)*( -facx*(sx(i-1,j ,k-1)+sx(i,j ,k-1))
132 +Real(2.0)*facy*(sy(i-1,j ,k-1)+sy(i,j ,k-1))
133 +Real(2.0)*facz*(sz(i-1,j ,k-1)+sz(i,j ,k-1)))
134 + x(i ,j-1,k+1)*( -facx*(sx(i-1,j-1,k )+sx(i,j-1,k ))
135 +Real(2.0)*facy*(sy(i-1,j-1,k )+sy(i,j-1,k ))
136 +Real(2.0)*facz*(sz(i-1,j-1,k )+sz(i,j-1,k )))
137 + x(i ,j+1,k+1)*( -facx*(sx(i-1,j ,k )+sx(i,j ,k ))
138 +Real(2.0)*facy*(sy(i-1,j ,k )+sy(i,j ,k ))
139 +Real(2.0)*facz*(sz(i-1,j ,k )+sz(i,j ,k )))
140 + x(i-1,j ,k-1)*( Real(2.0)*facx*(sx(i-1,j-1,k-1)+sx(i-1,j,k-1))
141 -facy*(sy(i-1,j-1,k-1)+sy(i-1,j,k-1))
142 +Real(2.0)*facz*(sz(i-1,j-1,k-1)+sz(i-1,j,k-1)))
143 + x(i+1,j ,k-1)*( Real(2.0)*facx*(sx(i ,j-1,k-1)+sx(i ,j,k-1))
144 -facy*(sy(i ,j-1,k-1)+sy(i ,j,k-1))
145 +Real(2.0)*facz*(sz(i ,j-1,k-1)+sz(i ,j,k-1)))
146 + x(i-1,j ,k+1)*( Real(2.0)*facx*(sx(i-1,j-1,k )+sx(i-1,j,k ))
147 -facy*(sy(i-1,j-1,k )+sy(i-1,j,k ))
148 +Real(2.0)*facz*(sz(i-1,j-1,k )+sz(i-1,j,k )))
149 + x(i+1,j ,k+1)*( Real(2.0)*facx*(sx(i ,j-1,k )+sx(i ,j,k ))
150 -facy*(sy(i ,j-1,k )+sy(i ,j,k ))
151 +Real(2.0)*facz*(sz(i ,j-1,k )+sz(i ,j,k )))
152 + x(i-1,j-1,k )*( Real(2.0)*facx*(sx(i-1,j-1,k-1)+sx(i-1,j-1,k))
153 +Real(2.0)*facy*(sy(i-1,j-1,k-1)+sy(i-1,j-1,k))
154 -facz*(sz(i-1,j-1,k-1)+sz(i-1,j-1,k)))
155 + x(i+1,j-1,k )*( Real(2.0)*facx*(sx(i ,j-1,k-1)+sx(i ,j-1,k))
156 +Real(2.0)*facy*(sy(i ,j-1,k-1)+sy(i ,j-1,k))
157 -facz*(sz(i ,j-1,k-1)+sz(i ,j-1,k)))
158 + x(i-1,j+1,k )*( Real(2.0)*facx*(sx(i-1,j ,k-1)+sx(i-1,j ,k))
159 +Real(2.0)*facy*(sy(i-1,j ,k-1)+sy(i-1,j ,k))
160 -facz*(sz(i-1,j ,k-1)+sz(i-1,j ,k)))
161 + x(i+1,j+1,k )*( Real(2.0)*facx*(sx(i ,j ,k-1)+sx(i ,j ,k))
162 +Real(2.0)*facy*(sy(i ,j ,k-1)+sy(i ,j ,k))
163 -facz*(sz(i ,j ,k-1)+sz(i ,j ,k)));
164 y += Real(2.0)*x(i-1,j,k)*( Real(2.0)*facx*(sx(i-1,j-1,k-1)+sx(i-1,j,k-1)+sx(i-1,j-1,k)+sx(i-1,j,k))
165 -facy*(sy(i-1,j-1,k-1)+sy(i-1,j,k-1)+sy(i-1,j-1,k)+sy(i-1,j,k))
166 -facz*(sz(i-1,j-1,k-1)+sz(i-1,j,k-1)+sz(i-1,j-1,k)+sz(i-1,j,k)))
167 + Real(2.0)*x(i+1,j,k)*( Real(2.0)*facx*(sx(i ,j-1,k-1)+sx(i ,j,k-1)+sx(i ,j-1,k)+sx(i ,j,k))
168 -facy*(sy(i ,j-1,k-1)+sy(i ,j,k-1)+sy(i ,j-1,k)+sy(i ,j,k))
169 -facz*(sz(i ,j-1,k-1)+sz(i ,j,k-1)+sz(i ,j-1,k)+sz(i ,j,k)))
170 + Real(2.0)*x(i,j-1,k)*( -facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1)+sx(i-1,j-1,k)+sx(i,j-1,k))
171 +Real(2.0)*facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1)+sy(i-1,j-1,k)+sy(i,j-1,k))
172 -facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)+sz(i-1,j-1,k)+sz(i,j-1,k)))
173 + Real(2.0)*x(i,j+1,k)*( -facx*(sx(i-1,j ,k-1)+sx(i,j ,k-1)+sx(i-1,j ,k)+sx(i,j ,k))
174 +Real(2.0)*facy*(sy(i-1,j ,k-1)+sy(i,j ,k-1)+sy(i-1,j ,k)+sy(i,j ,k))
175 -facz*(sz(i-1,j ,k-1)+sz(i,j ,k-1)+sz(i-1,j ,k)+sz(i,j ,k)))
176 + Real(2.0)*x(i,j,k-1)*( -facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1)+sx(i-1,j,k-1)+sx(i,j,k-1))
177 -facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1)+sy(i-1,j,k-1)+sy(i,j,k-1))
178 +Real(2.0)*facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)+sz(i-1,j,k-1)+sz(i,j,k-1)))
179 + Real(2.0)*x(i,j,k+1)*( -facx*(sx(i-1,j-1,k )+sx(i,j-1,k )+sx(i-1,j,k )+sx(i,j,k ))
180 -facy*(sy(i-1,j-1,k )+sy(i,j-1,k )+sy(i-1,j,k )+sy(i,j,k ))
181 +Real(2.0)*facz*(sz(i-1,j-1,k )+sz(i,j-1,k )+sz(i-1,j,k )+sz(i,j,k )));
182 return y;
183 }
184}
185
187Real mlndlap_adotx_aa (int i, int j, int k, Array4<Real const> const& x,
188 Array4<Real const> const& sig, Array4<int const> const& msk,
189 GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
190{
191 if (msk(i,j,k)) {
192 return Real(0.0);
193 } else {
194 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
195 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
196 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
197 Real fxyz = facx + facy + facz;
198 Real fmx2y2z = -facx + Real(2.0)*facy + Real(2.0)*facz;
199 Real f2xmy2z = Real(2.0)*facx - facy + Real(2.0)*facz;
200 Real f2x2ymz = Real(2.0)*facx + Real(2.0)*facy - facz;
201 Real f4xm2ym2z = Real(4.0)*facx - Real(2.0)*facy - Real(2.0)*facz;
202 Real fm2x4ym2z = -Real(2.0)*facx + Real(4.0)*facy - Real(2.0)*facz;
203 Real fm2xm2y4z = -Real(2.0)*facx - Real(2.0)*facy + Real(4.0)*facz;
204 return x(i,j,k)*Real(-4.0)*fxyz*
205 (sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1)
206 +sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k ))
207 + fxyz*(x(i-1,j-1,k-1)*sig(i-1,j-1,k-1)
208 + x(i+1,j-1,k-1)*sig(i ,j-1,k-1)
209 + x(i-1,j+1,k-1)*sig(i-1,j ,k-1)
210 + x(i+1,j+1,k-1)*sig(i ,j ,k-1)
211 + x(i-1,j-1,k+1)*sig(i-1,j-1,k )
212 + x(i+1,j-1,k+1)*sig(i ,j-1,k )
213 + x(i-1,j+1,k+1)*sig(i-1,j ,k )
214 + x(i+1,j+1,k+1)*sig(i ,j ,k ))
215 + fmx2y2z*(x(i ,j-1,k-1)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1))
216 + x(i ,j+1,k-1)*(sig(i-1,j ,k-1)+sig(i,j ,k-1))
217 + x(i ,j-1,k+1)*(sig(i-1,j-1,k )+sig(i,j-1,k ))
218 + x(i ,j+1,k+1)*(sig(i-1,j ,k )+sig(i,j ,k )))
219 + f2xmy2z*(x(i-1,j ,k-1)*(sig(i-1,j-1,k-1)+sig(i-1,j,k-1))
220 + x(i+1,j ,k-1)*(sig(i ,j-1,k-1)+sig(i ,j,k-1))
221 + x(i-1,j ,k+1)*(sig(i-1,j-1,k )+sig(i-1,j,k ))
222 + x(i+1,j ,k+1)*(sig(i ,j-1,k )+sig(i ,j,k )))
223 + f2x2ymz*(x(i-1,j-1,k )*(sig(i-1,j-1,k-1)+sig(i-1,j-1,k))
224 + x(i+1,j-1,k )*(sig(i ,j-1,k-1)+sig(i ,j-1,k))
225 + x(i-1,j+1,k )*(sig(i-1,j ,k-1)+sig(i-1,j ,k))
226 + x(i+1,j+1,k )*(sig(i ,j ,k-1)+sig(i ,j ,k)))
227 + f4xm2ym2z*(x(i-1,j,k)*(sig(i-1,j-1,k-1)+sig(i-1,j,k-1)+sig(i-1,j-1,k)+sig(i-1,j,k))
228 + x(i+1,j,k)*(sig(i ,j-1,k-1)+sig(i ,j,k-1)+sig(i ,j-1,k)+sig(i ,j,k)))
229 + fm2x4ym2z*(x(i,j-1,k)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j-1,k)+sig(i,j-1,k))
230 + x(i,j+1,k)*(sig(i-1,j ,k-1)+sig(i,j ,k-1)+sig(i-1,j ,k)+sig(i,j ,k)))
231 + fm2xm2y4z*(x(i,j,k-1)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1))
232 + x(i,j,k+1)*(sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k )));
233 }
234}
235
237Real mlndlap_adotx_c (int i, int j, int k, Array4<Real const> const& x,
238 Real sig, Array4<int const> const& msk,
239 GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
240{
241 if (msk(i,j,k)) {
242 return Real(0.0);
243 } else {
244 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
245 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
246 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
247 Real fxyz = facx + facy + facz;
248 Real fmx2y2z = -facx + Real(2.0)*facy + Real(2.0)*facz;
249 Real f2xmy2z = Real(2.0)*facx - facy + Real(2.0)*facz;
250 Real f2x2ymz = Real(2.0)*facx + Real(2.0)*facy - facz;
251 Real f4xm2ym2z = Real(4.0)*facx - Real(2.0)*facy - Real(2.0)*facz;
252 Real fm2x4ym2z = -Real(2.0)*facx + Real(4.0)*facy - Real(2.0)*facz;
253 Real fm2xm2y4z = -Real(2.0)*facx - Real(2.0)*facy + Real(4.0)*facz;
254 return sig * (x(i,j,k)*Real(-4.0)*fxyz*Real(8.)
255 + fxyz*(x(i-1,j-1,k-1)
256 + x(i+1,j-1,k-1)
257 + x(i-1,j+1,k-1)
258 + x(i+1,j+1,k-1)
259 + x(i-1,j-1,k+1)
260 + x(i+1,j-1,k+1)
261 + x(i-1,j+1,k+1)
262 + x(i+1,j+1,k+1))
263 + fmx2y2z*(x(i ,j-1,k-1)*Real(2.)
264 + x(i ,j+1,k-1)*Real(2.)
265 + x(i ,j-1,k+1)*Real(2.)
266 + x(i ,j+1,k+1)*Real(2.))
267 + f2xmy2z*(x(i-1,j ,k-1)*Real(2.)
268 + x(i+1,j ,k-1)*Real(2.)
269 + x(i-1,j ,k+1)*Real(2.)
270 + x(i+1,j ,k+1)*Real(2.))
271 + f2x2ymz*(x(i-1,j-1,k )*Real(2.)
272 + x(i+1,j-1,k )*Real(2.)
273 + x(i-1,j+1,k )*Real(2.)
274 + x(i+1,j+1,k )*Real(2.))
275 + f4xm2ym2z*(x(i-1,j,k)*Real(4.)
276 + x(i+1,j,k)*Real(4.))
277 + fm2x4ym2z*(x(i,j-1,k)*Real(4.)
278 + x(i,j+1,k)*Real(4.))
279 + fm2xm2y4z*(x(i,j,k-1)*Real(4.)
280 + x(i,j,k+1)*Real(4.)));
281 }
282}
283
285void mlndlap_normalize_ha (int i, int j, int k, Array4<Real> const& x, Array4<Real const> const& sx,
286 Array4<Real const> const& sy, Array4<Real const> const& sz,
287 Array4<int const> const& msk, GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
288{
289 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
290 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
291 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
292
293 if (!msk(i,j,k)) {
294 x(i,j,k) = x(i,j,k)/(Real(-4.0)*(facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1)+sx(i-1,j,k-1)+sx(i,j,k-1)
295 +sx(i-1,j-1,k )+sx(i,j-1,k )+sx(i-1,j,k )+sx(i,j,k ))
296 +facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1)+sy(i-1,j,k-1)+sy(i,j,k-1)
297 +sy(i-1,j-1,k )+sy(i,j-1,k )+sy(i-1,j,k )+sy(i,j,k ))
298 +facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)+sz(i-1,j,k-1)+sz(i,j,k-1)
299 +sz(i-1,j-1,k )+sz(i,j-1,k )+sz(i-1,j,k )+sz(i,j,k ))));
300 }
301}
302
304void mlndlap_normalize_aa (int i, int j, int k, Array4<Real> const& x, Array4<Real const> const& sig,
305 Array4<int const> const& msk, GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
306{
307 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
308 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
309 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
310 Real fxyz = facx + facy + facz;
311
312 if (!msk(i,j,k)) {
313 x(i,j,k) = x(i,j,k) /
314 (Real(-4.0)*fxyz*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1)
315 +sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k )));
316 }
317}
318
320void mlndlap_jacobi_ha (int i, int j, int k, Array4<Real> const& sol, Real Ax,
321 Array4<Real const> const& rhs, Array4<Real const> const& sx,
322 Array4<Real const> const& sy, Array4<Real const> const& sz,
323 Array4<int const> const& msk, GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
324{
325 Real facx = Real(-4.0 / 36.0)*dxinv[0]*dxinv[0];
326 Real facy = Real(-4.0 / 36.0)*dxinv[1]*dxinv[1];
327 Real facz = Real(-4.0 / 36.0)*dxinv[2]*dxinv[2];
328
329 if (msk(i,j,k)) {
330 sol(i,j,k) = Real(0.0);
331 } else {
332 sol(i,j,k) += Real(2.0/3.0) * (rhs(i,j,k) - Ax)
333 / (facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1)+sx(i-1,j,k-1)+sx(i,j,k-1)
334 +sx(i-1,j-1,k )+sx(i,j-1,k )+sx(i-1,j,k )+sx(i,j,k ))
335 +facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1)+sy(i-1,j,k-1)+sy(i,j,k-1)
336 +sy(i-1,j-1,k )+sy(i,j-1,k )+sy(i-1,j,k )+sy(i,j,k ))
337 +facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)+sz(i-1,j,k-1)+sz(i,j,k-1)
338 +sz(i-1,j-1,k )+sz(i,j-1,k )+sz(i-1,j,k )+sz(i,j,k )));
339 }
340}
341
342inline
343void mlndlap_jacobi_ha (Box const& bx, Array4<Real> const& sol, Array4<Real const> const& Ax,
344 Array4<Real const> const& rhs, Array4<Real const> const& sx,
345 Array4<Real const> const& sy, Array4<Real const> const& sz,
346 Array4<int const> const& msk, GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
347{
348 Real facx = Real(-4.0 / 36.0)*dxinv[0]*dxinv[0];
349 Real facy = Real(-4.0 / 36.0)*dxinv[1]*dxinv[1];
350 Real facz = Real(-4.0 / 36.0)*dxinv[2]*dxinv[2];
351
352 amrex::LoopConcurrentOnCpu(bx, [&] (int i, int j, int k) noexcept
353 {
354 if (msk(i,j,k)) {
355 sol(i,j,k) = Real(0.0);
356 } else {
357 sol(i,j,k) += Real(2.0/3.0) * (rhs(i,j,k) - Ax(i,j,k))
358 / (facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1)+sx(i-1,j,k-1)+sx(i,j,k-1)
359 +sx(i-1,j-1,k )+sx(i,j-1,k )+sx(i-1,j,k )+sx(i,j,k ))
360 +facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1)+sy(i-1,j,k-1)+sy(i,j,k-1)
361 +sy(i-1,j-1,k )+sy(i,j-1,k )+sy(i-1,j,k )+sy(i,j,k ))
362 +facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)+sz(i-1,j,k-1)+sz(i,j,k-1)
363 +sz(i-1,j-1,k )+sz(i,j-1,k )+sz(i-1,j,k )+sz(i,j,k )));
364 }
365 });
366}
367
369void mlndlap_jacobi_aa (int i, int j, int k, Array4<Real> const& sol, Real Ax,
370 Array4<Real const> const& rhs, Array4<Real const> const& sig,
371 Array4<int const> const& msk, GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
372{
373 Real fxyz = Real(-4.0 / 36.0)*(dxinv[0]*dxinv[0] +
374 dxinv[1]*dxinv[1] +
375 dxinv[2]*dxinv[2]);
376
377 if (msk(i,j,k)) {
378 sol(i,j,k) = Real(0.0);
379 } else {
380 sol(i,j,k) += Real(2.0/3.0) * (rhs(i,j,k) - Ax)
381 / (fxyz*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1)
382 +sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k )));
383 }
384}
385
387void mlndlap_jacobi_c (int i, int j, int k, Array4<Real> const& sol, Real Ax,
388 Array4<Real const> const& rhs, Real sig,
389 Array4<int const> const& msk, GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
390{
391 Real fxyz = Real(-4.0 / 36.0)*(dxinv[0]*dxinv[0] +
392 dxinv[1]*dxinv[1] +
393 dxinv[2]*dxinv[2]);
394
395 if (msk(i,j,k)) {
396 sol(i,j,k) = Real(0.0);
397 } else {
398 sol(i,j,k) += Real(2.0/3.0) * (rhs(i,j,k) - Ax)
399 / (fxyz*Real(8.)*sig);
400 }
401}
402
403inline
404void mlndlap_jacobi_aa (Box const& bx, Array4<Real> const& sol, Array4<Real const> const& Ax,
405 Array4<Real const> const& rhs, Array4<Real const> const& sig,
406 Array4<int const> const& msk, GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
407{
408 Real fxyz = Real(-4.0 / 36.0)*(dxinv[0]*dxinv[0] +
409 dxinv[1]*dxinv[1] +
410 dxinv[2]*dxinv[2]);
411
412 amrex::LoopConcurrentOnCpu(bx, [&] (int i, int j, int k) noexcept
413 {
414 if (msk(i,j,k)) {
415 sol(i,j,k) = Real(0.0);
416 } else {
417 sol(i,j,k) += Real(2.0/3.0) * (rhs(i,j,k) - Ax(i,j,k))
418 / (fxyz*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1)
419 +sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k )));
420 }
421 });
422}
423
424inline
425void mlndlap_jacobi_c (Box const& bx, Array4<Real> const& sol, Array4<Real const> const& Ax,
426 Array4<Real const> const& rhs, Real sig,
427 Array4<int const> const& msk, GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
428{
429 Real fxyz = Real(-4.0 / 36.0)*(dxinv[0]*dxinv[0] +
430 dxinv[1]*dxinv[1] +
431 dxinv[2]*dxinv[2]);
432
433 amrex::LoopConcurrentOnCpu(bx, [&] (int i, int j, int k) noexcept
434 {
435 if (msk(i,j,k)) {
436 sol(i,j,k) = Real(0.0);
437 } else {
438 sol(i,j,k) += Real(2.0/3.0) * (rhs(i,j,k) - Ax(i,j,k))
439 / (fxyz*Real(8.)*sig);
440 }
441 });
442}
443
444inline
445void mlndlap_gauss_seidel_ha (Box const& bx, Array4<Real> const& sol,
446 Array4<Real const> const& rhs, Array4<Real const> const& sx,
447 Array4<Real const> const& sy, Array4<Real const> const& sz,
448 Array4<int const> const& msk,
449 GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
450{
451 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
452 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
453 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
454
455 amrex::LoopOnCpu(bx, [&] (int i, int j, int k) noexcept
456 {
457 if (msk(i,j,k)) {
458 sol(i,j,k) = Real(0.0);
459 } else {
460 Real s0 = Real(-4.0)*(facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1)+sx(i-1,j,k-1)+sx(i,j,k-1)
461 +sx(i-1,j-1,k )+sx(i,j-1,k )+sx(i-1,j,k )+sx(i,j,k ))
462 +facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1)+sy(i-1,j,k-1)+sy(i,j,k-1)
463 +sy(i-1,j-1,k )+sy(i,j-1,k )+sy(i-1,j,k )+sy(i,j,k ))
464 +facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)+sz(i-1,j,k-1)+sz(i,j,k-1)
465 +sz(i-1,j-1,k )+sz(i,j-1,k )+sz(i-1,j,k )+sz(i,j,k )));
466 Real Ax = sol(i,j,k)*s0
467 + sol(i-1,j-1,k-1)*(facx*sx(i-1,j-1,k-1)
468 +facy*sy(i-1,j-1,k-1)
469 +facz*sz(i-1,j-1,k-1))
470 + sol(i+1,j-1,k-1)*(facx*sx(i ,j-1,k-1)
471 +facy*sy(i ,j-1,k-1)
472 +facz*sz(i ,j-1,k-1))
473 + sol(i-1,j+1,k-1)*(facx*sx(i-1,j ,k-1)
474 +facy*sy(i-1,j ,k-1)
475 +facz*sz(i-1,j ,k-1))
476 + sol(i+1,j+1,k-1)*(facx*sx(i ,j ,k-1)
477 +facy*sy(i ,j ,k-1)
478 +facz*sz(i ,j ,k-1))
479 + sol(i-1,j-1,k+1)*(facx*sx(i-1,j-1,k )
480 +facy*sy(i-1,j-1,k )
481 +facz*sz(i-1,j-1,k ))
482 + sol(i+1,j-1,k+1)*(facx*sx(i ,j-1,k )
483 +facy*sy(i ,j-1,k )
484 +facz*sz(i ,j-1,k ))
485 + sol(i-1,j+1,k+1)*(facx*sx(i-1,j ,k )
486 +facy*sy(i-1,j ,k )
487 +facz*sz(i-1,j ,k ))
488 + sol(i+1,j+1,k+1)*(facx*sx(i ,j ,k )
489 +facy*sy(i ,j ,k )
490 +facz*sz(i ,j ,k ))
491 +sol(i ,j-1,k-1)*( -facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1))
492 +Real(2.0)*facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1))
493 +Real(2.0)*facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)))
494 +sol(i ,j+1,k-1)*( -facx*(sx(i-1,j ,k-1)+sx(i,j ,k-1))
495 +Real(2.0)*facy*(sy(i-1,j ,k-1)+sy(i,j ,k-1))
496 +Real(2.0)*facz*(sz(i-1,j ,k-1)+sz(i,j ,k-1)))
497 +sol(i ,j-1,k+1)*( -facx*(sx(i-1,j-1,k )+sx(i,j-1,k ))
498 +Real(2.0)*facy*(sy(i-1,j-1,k )+sy(i,j-1,k ))
499 +Real(2.0)*facz*(sz(i-1,j-1,k )+sz(i,j-1,k )))
500 +sol(i ,j+1,k+1)*( -facx*(sx(i-1,j ,k )+sx(i,j ,k ))
501 +Real(2.0)*facy*(sy(i-1,j ,k )+sy(i,j ,k ))
502 +Real(2.0)*facz*(sz(i-1,j ,k )+sz(i,j ,k )))
503 +sol(i-1,j ,k-1)*( Real(2.0)*facx*(sx(i-1,j-1,k-1)+sx(i-1,j,k-1))
504 -facy*(sy(i-1,j-1,k-1)+sy(i-1,j,k-1))
505 +Real(2.0)*facz*(sz(i-1,j-1,k-1)+sz(i-1,j,k-1)))
506 +sol(i+1,j ,k-1)*( Real(2.0)*facx*(sx(i ,j-1,k-1)+sx(i ,j,k-1))
507 -facy*(sy(i ,j-1,k-1)+sy(i ,j,k-1))
508 +Real(2.0)*facz*(sz(i ,j-1,k-1)+sz(i ,j,k-1)))
509 +sol(i-1,j ,k+1)*( Real(2.0)*facx*(sx(i-1,j-1,k )+sx(i-1,j,k ))
510 -facy*(sy(i-1,j-1,k )+sy(i-1,j,k ))
511 +Real(2.0)*facz*(sz(i-1,j-1,k )+sz(i-1,j,k )))
512 +sol(i+1,j ,k+1)*( Real(2.0)*facx*(sx(i ,j-1,k )+sx(i ,j,k ))
513 -facy*(sy(i ,j-1,k )+sy(i ,j,k ))
514 +Real(2.0)*facz*(sz(i ,j-1,k )+sz(i ,j,k )))
515 +sol(i-1,j-1,k )*( Real(2.0)*facx*(sx(i-1,j-1,k-1)+sx(i-1,j-1,k))
516 +Real(2.0)*facy*(sy(i-1,j-1,k-1)+sy(i-1,j-1,k))
517 -facz*(sz(i-1,j-1,k-1)+sz(i-1,j-1,k)))
518 +sol(i+1,j-1,k )*( Real(2.0)*facx*(sx(i ,j-1,k-1)+sx(i ,j-1,k))
519 +Real(2.0)*facy*(sy(i ,j-1,k-1)+sy(i ,j-1,k))
520 -facz*(sz(i ,j-1,k-1)+sz(i ,j-1,k)))
521 +sol(i-1,j+1,k )*( Real(2.0)*facx*(sx(i-1,j ,k-1)+sx(i-1,j ,k))
522 +Real(2.0)*facy*(sy(i-1,j ,k-1)+sy(i-1,j ,k))
523 -facz*(sz(i-1,j ,k-1)+sz(i-1,j ,k)))
524 +sol(i+1,j+1,k )*( Real(2.0)*facx*(sx(i ,j ,k-1)+sx(i ,j ,k))
525 +Real(2.0)*facy*(sy(i ,j ,k-1)+sy(i ,j ,k))
526 -facz*(sz(i ,j ,k-1)+sz(i ,j ,k)))
527 + Real(2.0)*sol(i-1,j,k)*(Real(2.0)*facx*(sx(i-1,j-1,k-1)+sx(i-1,j,k-1)+sx(i-1,j-1,k)+sx(i-1,j,k))
528 -facy*(sy(i-1,j-1,k-1)+sy(i-1,j,k-1)+sy(i-1,j-1,k)+sy(i-1,j,k))
529 -facz*(sz(i-1,j-1,k-1)+sz(i-1,j,k-1)+sz(i-1,j-1,k)+sz(i-1,j,k)))
530 + Real(2.0)*sol(i+1,j,k)*(Real(2.0)*facx*(sx(i ,j-1,k-1)+sx(i ,j,k-1)+sx(i ,j-1,k)+sx(i ,j,k))
531 -facy*(sy(i ,j-1,k-1)+sy(i ,j,k-1)+sy(i ,j-1,k)+sy(i ,j,k))
532 -facz*(sz(i ,j-1,k-1)+sz(i ,j,k-1)+sz(i ,j-1,k)+sz(i ,j,k)))
533 + Real(2.0)*sol(i,j-1,k)*( -facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1)+sx(i-1,j-1,k)+sx(i,j-1,k))
534 +Real(2.0)*facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1)+sy(i-1,j-1,k)+sy(i,j-1,k))
535 -facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)+sz(i-1,j-1,k)+sz(i,j-1,k)))
536 + Real(2.0)*sol(i,j+1,k)*( -facx*(sx(i-1,j ,k-1)+sx(i,j ,k-1)+sx(i-1,j ,k)+sx(i,j ,k))
537 +Real(2.0)*facy*(sy(i-1,j ,k-1)+sy(i,j ,k-1)+sy(i-1,j ,k)+sy(i,j ,k))
538 -facz*(sz(i-1,j ,k-1)+sz(i,j ,k-1)+sz(i-1,j ,k)+sz(i,j ,k)))
539 + Real(2.0)*sol(i,j,k-1)*( -facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1)+sx(i-1,j,k-1)+sx(i,j,k-1))
540 -facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1)+sy(i-1,j,k-1)+sy(i,j,k-1))
541 +Real(2.0)*facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)+sz(i-1,j,k-1)+sz(i,j,k-1)))
542 + Real(2.0)*sol(i,j,k+1)*( -facx*(sx(i-1,j-1,k )+sx(i,j-1,k )+sx(i-1,j,k )+sx(i,j,k ))
543 -facy*(sy(i-1,j-1,k )+sy(i,j-1,k )+sy(i-1,j,k )+sy(i,j,k ))
544 +Real(2.0)*facz*(sz(i-1,j-1,k )+sz(i,j-1,k )+sz(i-1,j,k )+sz(i,j,k )));
545
546 sol(i,j,k) += (rhs(i,j,k) - Ax) / s0;
547 }
548 });
549}
550
551inline
552void mlndlap_gauss_seidel_aa (Box const& bx, Array4<Real> const& sol,
553 Array4<Real const> const& rhs, Array4<Real const> const& sig,
554 Array4<int const> const& msk,
555 GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
556{
557 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
558 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
559 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
560 Real fxyz = facx + facy + facz;
561 Real fmx2y2z = -facx + Real(2.0)*facy + Real(2.0)*facz;
562 Real f2xmy2z = Real(2.0)*facx - facy + Real(2.0)*facz;
563 Real f2x2ymz = Real(2.0)*facx + Real(2.0)*facy - facz;
564 Real f4xm2ym2z = Real(4.0)*facx - Real(2.0)*facy - Real(2.0)*facz;
565 Real fm2x4ym2z = -Real(2.0)*facx + Real(4.0)*facy - Real(2.0)*facz;
566 Real fm2xm2y4z = -Real(2.0)*facx - Real(2.0)*facy + Real(4.0)*facz;
567
568 amrex::LoopOnCpu(bx, [&] (int i, int j, int k) noexcept
569 {
570 if (msk(i,j,k)) {
571 sol(i,j,k) = Real(0.0);
572 } else {
573 Real s0 = Real(-4.0)*fxyz*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1)
574 +sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k ));
575 Real Ax = sol(i,j,k)*s0
576 + fxyz*(sol(i-1,j-1,k-1)*sig(i-1,j-1,k-1)
577 + sol(i+1,j-1,k-1)*sig(i ,j-1,k-1)
578 + sol(i-1,j+1,k-1)*sig(i-1,j ,k-1)
579 + sol(i+1,j+1,k-1)*sig(i ,j ,k-1)
580 + sol(i-1,j-1,k+1)*sig(i-1,j-1,k )
581 + sol(i+1,j-1,k+1)*sig(i ,j-1,k )
582 + sol(i-1,j+1,k+1)*sig(i-1,j ,k )
583 + sol(i+1,j+1,k+1)*sig(i ,j ,k ))
584 + fmx2y2z*(sol(i ,j-1,k-1)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1))
585 + sol(i ,j+1,k-1)*(sig(i-1,j ,k-1)+sig(i,j ,k-1))
586 + sol(i ,j-1,k+1)*(sig(i-1,j-1,k )+sig(i,j-1,k ))
587 + sol(i ,j+1,k+1)*(sig(i-1,j ,k )+sig(i,j ,k )))
588 + f2xmy2z*(sol(i-1,j ,k-1)*(sig(i-1,j-1,k-1)+sig(i-1,j,k-1))
589 + sol(i+1,j ,k-1)*(sig(i ,j-1,k-1)+sig(i ,j,k-1))
590 + sol(i-1,j ,k+1)*(sig(i-1,j-1,k )+sig(i-1,j,k ))
591 + sol(i+1,j ,k+1)*(sig(i ,j-1,k )+sig(i ,j,k )))
592 + f2x2ymz*(sol(i-1,j-1,k )*(sig(i-1,j-1,k-1)+sig(i-1,j-1,k))
593 + sol(i+1,j-1,k )*(sig(i ,j-1,k-1)+sig(i ,j-1,k))
594 + sol(i-1,j+1,k )*(sig(i-1,j ,k-1)+sig(i-1,j ,k))
595 + sol(i+1,j+1,k )*(sig(i ,j ,k-1)+sig(i ,j ,k)))
596 + f4xm2ym2z*(sol(i-1,j,k)*(sig(i-1,j-1,k-1)+sig(i-1,j,k-1)+sig(i-1,j-1,k)+sig(i-1,j,k))
597 + sol(i+1,j,k)*(sig(i ,j-1,k-1)+sig(i ,j,k-1)+sig(i ,j-1,k)+sig(i ,j,k)))
598 + fm2x4ym2z*(sol(i,j-1,k)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j-1,k)+sig(i,j-1,k))
599 + sol(i,j+1,k)*(sig(i-1,j ,k-1)+sig(i,j ,k-1)+sig(i-1,j ,k)+sig(i,j ,k)))
600 + fm2xm2y4z*(sol(i,j,k-1)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1))
601 + sol(i,j,k+1)*(sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k )));
602
603 sol(i,j,k) += (rhs(i,j,k) - Ax) / s0;
604 }
605 });
606}
607
608inline
609void mlndlap_gauss_seidel_c (Box const& bx, Array4<Real> const& sol,
610 Array4<Real const> const& rhs, Real sig,
611 Array4<int const> const& msk,
612 GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
613{
614 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
615 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
616 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
617 Real fxyz = facx + facy + facz;
618 Real fmx2y2z = -facx + Real(2.0)*facy + Real(2.0)*facz;
619 Real f2xmy2z = Real(2.0)*facx - facy + Real(2.0)*facz;
620 Real f2x2ymz = Real(2.0)*facx + Real(2.0)*facy - facz;
621 Real f4xm2ym2z = Real(4.0)*facx - Real(2.0)*facy - Real(2.0)*facz;
622 Real fm2x4ym2z = -Real(2.0)*facx + Real(4.0)*facy - Real(2.0)*facz;
623 Real fm2xm2y4z = -Real(2.0)*facx - Real(2.0)*facy + Real(4.0)*facz;
624
625 amrex::LoopOnCpu(bx, [&] (int i, int j, int k) noexcept
626 {
627 if (msk(i,j,k)) {
628 sol(i,j,k) = Real(0.0);
629 } else {
630 Real s0 = Real(-4.0)*fxyz*Real(8.);
631 Real Ax = sol(i,j,k)*s0
632 + fxyz*(sol(i-1,j-1,k-1)
633 + sol(i+1,j-1,k-1)
634 + sol(i-1,j+1,k-1)
635 + sol(i+1,j+1,k-1)
636 + sol(i-1,j-1,k+1)
637 + sol(i+1,j-1,k+1)
638 + sol(i-1,j+1,k+1)
639 + sol(i+1,j+1,k+1))
640 + fmx2y2z*(sol(i ,j-1,k-1)*Real(2.)
641 + sol(i ,j+1,k-1)*Real(2.)
642 + sol(i ,j-1,k+1)*Real(2.)
643 + sol(i ,j+1,k+1)*Real(2.))
644 + f2xmy2z*(sol(i-1,j ,k-1)*Real(2.)
645 + sol(i+1,j ,k-1)*Real(2.)
646 + sol(i-1,j ,k+1)*Real(2.)
647 + sol(i+1,j ,k+1)*Real(2.))
648 + f2x2ymz*(sol(i-1,j-1,k )*Real(2.)
649 + sol(i+1,j-1,k )*Real(2.)
650 + sol(i-1,j+1,k )*Real(2.)
651 + sol(i+1,j+1,k )*Real(2.))
652 + f4xm2ym2z*(sol(i-1,j,k)*Real(4.)
653 + sol(i+1,j,k)*Real(4.))
654 + fm2x4ym2z*(sol(i,j-1,k)*Real(4.)
655 + sol(i,j+1,k)*Real(4.))
656 + fm2xm2y4z*(sol(i,j,k-1)*Real(4.)
657 + sol(i,j,k+1)*Real(4.));
658
659 sol(i,j,k) += (rhs(i,j,k) - Ax*sig) / (s0*sig);
660 }
661 });
662}
663
665void tridiagonal_solve (Array1D<Real,0,31>& a_ls, Array1D<Real,0,31>& b_ls, Array1D<Real,0,31>& c_ls,
666 Array1D<Real,0,31>& r_ls, Array1D<Real,0,31>& u_ls, Array1D<Real,0,31>& gam,
667 int ilen ) noexcept
668{
669 Real bet = b_ls(0);
670 u_ls(0) = r_ls(0) / bet;
671
672 for (int i = 1; i <= ilen - 1; i++) {
673 gam(i) = c_ls(i-1) / bet;
674 bet = b_ls(i) - a_ls(i)*gam(i);
675 if (bet == 0) { amrex::Abort(">>>TRIDIAG FAILED"); }
676 u_ls(i) = (r_ls(i)-a_ls(i)*u_ls(i-1)) / bet;
677 }
678 for (int i = ilen-2; i >= 0; i--) {
679 u_ls(i) = u_ls(i) - gam(i+1)*u_ls(i+1);
680 }
681}
682
683inline
684void mlndlap_gauss_seidel_with_line_solve_aa (Box const& bx, Array4<Real> const& sol,
685 Array4<Real const> const& rhs, Array4<Real const> const& sig,
686 Array4<int const> const& msk,
687 GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
688{
689 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
690 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
691 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
692 Real fxyz = facx + facy + facz;
693 Real fmx2y2z = -facx + Real(2.0)*facy + Real(2.0)*facz;
694 Real f2xmy2z = Real(2.0)*facx - facy + Real(2.0)*facz;
695 Real f2x2ymz = Real(2.0)*facx + Real(2.0)*facy - facz;
696 Real f4xm2ym2z = Real(4.0)*facx - Real(2.0)*facy - Real(2.0)*facz;
697 Real fm2x4ym2z = -Real(2.0)*facx + Real(4.0)*facy - Real(2.0)*facz;
698 Real fm2xm2y4z = -Real(2.0)*facx - Real(2.0)*facy + Real(4.0)*facz;
699
700 const auto lo = amrex::lbound(bx);
701 const auto hi = amrex::ubound(bx);
702
703 int idir = -1;
704 int ilen = 33;
705
706 if ( (dxinv[0] <= dxinv[2]) && (dxinv[1] <= dxinv[2]) ) {
707 idir = 2;
708 ilen = hi.z - lo.z + 1;
709 }
710 if ( (dxinv[0] <= dxinv[1]) && (dxinv[2] <= dxinv[1]) ) {
711 idir = 1;
712 ilen = hi.y - lo.y + 1;
713 }
714 if ( (dxinv[1] <= dxinv[0]) && (dxinv[2] <= dxinv[0]) ) {
715 idir = 0;
716 ilen = hi.x - lo.x + 1;
717 }
718
719 if (ilen > 32) {
720 amrex::Abort("mlndlap_gauss_seidel_with_line_solve_aa is hard-wired to be no longer than 32");
721 }
722
723 Array1D<Real,0,31> a_ls,b_ls,c_ls,u_ls,r_ls,gam;
724
725
726 if ( idir == 2 )
727 {
728 for (int j = lo.y; j <= hi.y; ++j)
729 {
730 for (int i = lo.x; i <= hi.x; ++i)
731 {
732 for (int k = lo.z; k <= hi.z; ++k)
733 {
734 if (msk(i,j,k))
735 {
736 a_ls(k-lo.z) = Real(0.);
737 b_ls(k-lo.z) = Real(1.);
738 c_ls(k-lo.z) = Real(0.);
739 u_ls(k-lo.z) = Real(0.);
740 r_ls(k-lo.z) = Real(0.);
741 }
742 else
743 {
744 Real s0 = Real(-4.0)*fxyz*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1)
745 + sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k ));
746
747 Real Ax = fxyz*(sol(i-1,j-1,k-1)*sig(i-1,j-1,k-1)
748 + sol(i+1,j-1,k-1)*sig(i ,j-1,k-1)
749 + sol(i-1,j+1,k-1)*sig(i-1,j ,k-1)
750 + sol(i+1,j+1,k-1)*sig(i ,j ,k-1)
751 + sol(i-1,j-1,k+1)*sig(i-1,j-1,k )
752 + sol(i+1,j-1,k+1)*sig(i ,j-1,k )
753 + sol(i-1,j+1,k+1)*sig(i-1,j ,k )
754 + sol(i+1,j+1,k+1)*sig(i ,j ,k ))
755 + fmx2y2z*(sol(i ,j-1,k-1)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1))
756 + sol(i ,j+1,k-1)*(sig(i-1,j ,k-1)+sig(i,j ,k-1))
757 + sol(i ,j-1,k+1)*(sig(i-1,j-1,k )+sig(i,j-1,k ))
758 + sol(i ,j+1,k+1)*(sig(i-1,j ,k )+sig(i,j ,k )))
759 + f2xmy2z*(sol(i-1,j ,k-1)*(sig(i-1,j-1,k-1)+sig(i-1,j,k-1))
760 + sol(i+1,j ,k-1)*(sig(i ,j-1,k-1)+sig(i ,j,k-1))
761 + sol(i-1,j ,k+1)*(sig(i-1,j-1,k )+sig(i-1,j,k ))
762 + sol(i+1,j ,k+1)*(sig(i ,j-1,k )+sig(i ,j,k )))
763 + f2x2ymz*(sol(i-1,j-1,k )*(sig(i-1,j-1,k-1)+sig(i-1,j-1,k))
764 + sol(i+1,j-1,k )*(sig(i ,j-1,k-1)+sig(i ,j-1,k))
765 + sol(i-1,j+1,k )*(sig(i-1,j ,k-1)+sig(i-1,j ,k))
766 + sol(i+1,j+1,k )*(sig(i ,j ,k-1)+sig(i ,j ,k)))
767 + f4xm2ym2z*(sol(i-1,j,k)*(sig(i-1,j-1,k-1)+sig(i-1,j,k-1)+sig(i-1,j-1,k)+sig(i-1,j,k))
768 + sol(i+1,j,k)*(sig(i ,j-1,k-1)+sig(i ,j,k-1)+sig(i ,j-1,k)+sig(i ,j,k)))
769 + fm2x4ym2z*(sol(i,j-1,k)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j-1,k)+sig(i,j-1,k))
770 + sol(i,j+1,k)*(sig(i-1,j ,k-1)+sig(i,j ,k-1)+sig(i-1,j ,k)+sig(i,j ,k)));
771
772 a_ls(k-lo.z) = fm2xm2y4z*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1));
773 b_ls(k-lo.z) = s0;
774 c_ls(k-lo.z) = fm2xm2y4z*(sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k ));
775 u_ls(k-lo.z) = Real(0.);
776 r_ls(k-lo.z) = rhs(i,j,k) - Ax;
777 }
778 }
779 tridiagonal_solve(a_ls, b_ls, c_ls, r_ls, u_ls, gam, ilen);
780
781 for (int k = lo.z; k <= hi.z; ++k)
782 {
783 sol(i,j,k) = u_ls(k-lo.z);
784 }
785 }
786 }
787 }
788 else if (idir == 1)
789 {
790 for (int k = lo.z; k <= hi.z; ++k)
791 {
792 for (int i = lo.x; i <= hi.x; ++i)
793 {
794 for (int j = lo.y; j <= hi.y; ++j)
795 {
796 if (msk(i,j,k)) {
797 a_ls(j-lo.y) = Real(0.);
798 b_ls(j-lo.y) = Real(1.);
799 c_ls(j-lo.y) = Real(0.);
800 u_ls(j-lo.y) = Real(0.);
801 r_ls(j-lo.y) = Real(0.);
802 }
803 else
804 {
805 Real s0 = Real(-4.0)*fxyz*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1)
806 + sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k ));
807
808 Real Ax = fxyz*(sol(i-1,j-1,k-1)*sig(i-1,j-1,k-1)
809 + sol(i+1,j-1,k-1)*sig(i ,j-1,k-1)
810 + sol(i-1,j+1,k-1)*sig(i-1,j ,k-1)
811 + sol(i+1,j+1,k-1)*sig(i ,j ,k-1)
812 + sol(i-1,j-1,k+1)*sig(i-1,j-1,k )
813 + sol(i+1,j-1,k+1)*sig(i ,j-1,k )
814 + sol(i-1,j+1,k+1)*sig(i-1,j ,k )
815 + sol(i+1,j+1,k+1)*sig(i ,j ,k ))
816 + fmx2y2z*(sol(i ,j-1,k-1)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1))
817 + sol(i ,j+1,k-1)*(sig(i-1,j ,k-1)+sig(i,j ,k-1))
818 + sol(i ,j-1,k+1)*(sig(i-1,j-1,k )+sig(i,j-1,k ))
819 + sol(i ,j+1,k+1)*(sig(i-1,j ,k )+sig(i,j ,k )))
820 + f2xmy2z*(sol(i-1,j ,k-1)*(sig(i-1,j-1,k-1)+sig(i-1,j,k-1))
821 + sol(i+1,j ,k-1)*(sig(i ,j-1,k-1)+sig(i ,j,k-1))
822 + sol(i-1,j ,k+1)*(sig(i-1,j-1,k )+sig(i-1,j,k ))
823 + sol(i+1,j ,k+1)*(sig(i ,j-1,k )+sig(i ,j,k )))
824 + f2x2ymz*(sol(i-1,j-1,k )*(sig(i-1,j-1,k-1)+sig(i-1,j-1,k))
825 + sol(i+1,j-1,k )*(sig(i ,j-1,k-1)+sig(i ,j-1,k))
826 + sol(i-1,j+1,k )*(sig(i-1,j ,k-1)+sig(i-1,j ,k))
827 + sol(i+1,j+1,k )*(sig(i ,j ,k-1)+sig(i ,j ,k)))
828 + f4xm2ym2z*(sol(i-1,j,k)*(sig(i-1,j-1,k-1)+sig(i-1,j,k-1)+sig(i-1,j-1,k)+sig(i-1,j,k))
829 + sol(i+1,j,k)*(sig(i ,j-1,k-1)+sig(i ,j,k-1)+sig(i ,j-1,k)+sig(i ,j,k)))
830 + fm2xm2y4z*(sol(i,j,k-1)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1))
831 + sol(i,j,k+1)*(sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k )));
832
833 a_ls(j-lo.y) = fm2x4ym2z*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j-1,k)+sig(i,j-1,k));
834 b_ls(j-lo.y) = s0;
835 c_ls(j-lo.y) = fm2x4ym2z*(sig(i-1,j ,k-1)+sig(i,j ,k-1)+sig(i-1,j ,k)+sig(i,j ,k));
836 u_ls(j-lo.y) = Real(0.);
837 r_ls(j-lo.y) = rhs(i,j,k) - Ax;
838
839 }
840 }
841 tridiagonal_solve(a_ls, b_ls, c_ls, r_ls, u_ls, gam, ilen);
842
843 for (int j = lo.y; j <= hi.y; ++j)
844 {
845 sol(i,j,k) = u_ls(j-lo.y);
846 }
847 }
848 }
849 }
850 else if (idir == 0)
851 {
852 for (int j = lo.y; j <= hi.y; ++j)
853 {
854 for (int k = lo.z; k <= hi.z; ++k)
855 {
856 for (int i = lo.x; i <= hi.x; ++i)
857 {
858 if (msk(i,j,k))
859 {
860 a_ls(i-lo.x) = Real(0.);
861 b_ls(i-lo.x) = Real(1.);
862 c_ls(i-lo.x) = Real(0.);
863 u_ls(i-lo.x) = Real(0.);
864 r_ls(i-lo.x) = Real(0.);
865 }
866 else
867 {
868 Real s0 = Real(-4.0)*fxyz*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1)
869 + sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k ));
870
871 Real Ax = fxyz*(sol(i-1,j-1,k-1)*sig(i-1,j-1,k-1)
872 + sol(i+1,j-1,k-1)*sig(i ,j-1,k-1)
873 + sol(i-1,j+1,k-1)*sig(i-1,j ,k-1)
874 + sol(i+1,j+1,k-1)*sig(i ,j ,k-1)
875 + sol(i-1,j-1,k+1)*sig(i-1,j-1,k )
876 + sol(i+1,j-1,k+1)*sig(i ,j-1,k )
877 + sol(i-1,j+1,k+1)*sig(i-1,j ,k )
878 + sol(i+1,j+1,k+1)*sig(i ,j ,k ))
879 + fmx2y2z*(sol(i ,j-1,k-1)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1))
880 + sol(i ,j+1,k-1)*(sig(i-1,j ,k-1)+sig(i,j ,k-1))
881 + sol(i ,j-1,k+1)*(sig(i-1,j-1,k )+sig(i,j-1,k ))
882 + sol(i ,j+1,k+1)*(sig(i-1,j ,k )+sig(i,j ,k )))
883 + f2xmy2z*(sol(i-1,j ,k-1)*(sig(i-1,j-1,k-1)+sig(i-1,j,k-1))
884 + sol(i+1,j ,k-1)*(sig(i ,j-1,k-1)+sig(i ,j,k-1))
885 + sol(i-1,j ,k+1)*(sig(i-1,j-1,k )+sig(i-1,j,k ))
886 + sol(i+1,j ,k+1)*(sig(i ,j-1,k )+sig(i ,j,k )))
887 + f2x2ymz*(sol(i-1,j-1,k )*(sig(i-1,j-1,k-1)+sig(i-1,j-1,k))
888 + sol(i+1,j-1,k )*(sig(i ,j-1,k-1)+sig(i ,j-1,k))
889 + sol(i-1,j+1,k )*(sig(i-1,j ,k-1)+sig(i-1,j ,k))
890 + sol(i+1,j+1,k )*(sig(i ,j ,k-1)+sig(i ,j ,k)))
891 + fm2x4ym2z*(sol(i,j-1,k)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j-1,k)+sig(i,j-1,k))
892 + sol(i,j+1,k)*(sig(i-1,j ,k-1)+sig(i,j ,k-1)+sig(i-1,j ,k)+sig(i,j ,k)))
893 + fm2xm2y4z*(sol(i,j,k-1)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1))
894 + sol(i,j,k+1)*(sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k )));
895
896 a_ls(i-lo.x) = f4xm2ym2z*(sig(i-1,j-1,k-1)+sig(i-1,j,k-1)+sig(i-1,j-1,k)+sig(i-1,j,k));
897 b_ls(i-lo.x) = s0;
898 c_ls(i-lo.x) = f4xm2ym2z*(sig(i ,j-1,k-1)+sig(i ,j,k-1)+sig(i ,j-1,k)+sig(i ,j,k));
899 u_ls(i-lo.x) = Real(0.);
900 r_ls(i-lo.x) = rhs(i,j,k) - Ax;
901 }
902 }
903 tridiagonal_solve(a_ls, b_ls, c_ls, r_ls, u_ls, gam, ilen);
904
905 for (int i = lo.x; i <= hi.x; ++i)
906 {
907 sol(i,j,k) = u_ls(i-lo.x);
908 }
909 }
910 }
911 }
912 else
913 {
914 amrex::Abort("mlndlap_gauss_seidel_with_line_solve_aa is wrong direction.");
915 }
916}
917
918//
919// interpolation
920//
921
924 int i, int j, int k, int ic, int jc, int kc) noexcept
925 {
926 Real w1 = sig(i-1,j-1,k-1) + sig(i-1,j,k-1) + sig(i-1,j-1,k) + sig(i-1,j,k);
927 Real w2 = sig(i ,j-1,k-1) + sig(i ,j,k-1) + sig(i ,j-1,k) + sig(i ,j,k);
928 return (w1*crse(ic,jc,kc)+w2*crse(ic+1,jc,kc))/(w1+w2);
929 }
930
933 int i, int j, int k, int ic, int jc, int kc) noexcept
934 {
935 Real w1 = sig(i-1,j-1,k-1) + sig(i,j-1,k-1) + sig(i-1,j-1,k) + sig(i,j-1,k);
936 Real w2 = sig(i-1,j ,k-1) + sig(i,j ,k-1) + sig(i-1,j ,k) + sig(i,j ,k);
937 return (w1*crse(ic,jc,kc)+w2*crse(ic,jc+1,kc))/(w1+w2);
938 }
939
942 int i, int j, int k, int ic, int jc, int kc) noexcept
943 {
944 Real w1 = sig(i-1,j-1,k-1) + sig(i,j-1,k-1) + sig(i-1,j,k-1) + sig(i,j,k-1);
945 Real w2 = sig(i-1,j-1,k ) + sig(i,j-1,k ) + sig(i-1,j,k ) + sig(i,j,k );
946 return (w1*crse(ic,jc,kc)+w2*crse(ic,jc,kc+1))/(w1+w2);
947 }
948
951 int i, int j, int k, int ic, int jc, int kc) noexcept
952 {
953 Real w1 = sig(i-1,j-1,k-1) + sig(i-1,j,k-1) + sig(i-1,j-1,k) + sig(i-1,j,k);
954 Real w2 = sig(i ,j-1,k-1) + sig(i ,j,k-1) + sig(i ,j-1,k) + sig(i ,j,k);
955 Real w3 = sig(i-1,j-1,k-1) + sig(i,j-1,k-1) + sig(i-1,j-1,k) + sig(i,j-1,k);
956 Real w4 = sig(i-1,j ,k-1) + sig(i,j ,k-1) + sig(i-1,j ,k) + sig(i,j ,k);
957 return (w1 * aa_interp_line_y(crse,sig,i-1,j ,k,ic ,jc ,kc) +
958 w2 * aa_interp_line_y(crse,sig,i+1,j ,k,ic+1,jc ,kc) +
959 w3 * aa_interp_line_x(crse,sig,i ,j-1,k,ic ,jc ,kc) +
960 w4 * aa_interp_line_x(crse,sig,i ,j+1,k,ic ,jc+1,kc)) / (w1+w2+w3+w4);
961 }
962
965 int i, int j, int k, int ic, int jc, int kc) noexcept
966 {
967 Real w1 = sig(i-1,j-1,k-1) + sig(i-1,j,k-1) + sig(i-1,j-1,k) + sig(i-1,j,k);
968 Real w2 = sig(i ,j-1,k-1) + sig(i ,j,k-1) + sig(i ,j-1,k) + sig(i ,j,k);
969 Real w3 = sig(i-1,j-1,k-1) + sig(i,j-1,k-1) + sig(i-1,j,k-1) + sig(i,j,k-1);
970 Real w4 = sig(i-1,j-1,k ) + sig(i,j-1,k ) + sig(i-1,j,k ) + sig(i,j,k );
971 return (w1 * aa_interp_line_z(crse,sig,i-1,j,k ,ic ,jc,kc ) +
972 w2 * aa_interp_line_z(crse,sig,i+1,j,k ,ic+1,jc,kc ) +
973 w3 * aa_interp_line_x(crse,sig,i ,j,k-1,ic ,jc,kc ) +
974 w4 * aa_interp_line_x(crse,sig,i ,j,k+1,ic ,jc,kc+1)) / (w1+w2+w3+w4);
975 }
976
979 int i, int j, int k, int ic, int jc, int kc) noexcept
980 {
981 Real w1 = sig(i-1,j-1,k-1) + sig(i,j-1,k-1) + sig(i-1,j-1,k) + sig(i,j-1,k);
982 Real w2 = sig(i-1,j ,k-1) + sig(i,j ,k-1) + sig(i-1,j ,k) + sig(i,j ,k);
983 Real w3 = sig(i-1,j-1,k-1) + sig(i,j-1,k-1) + sig(i-1,j,k-1) + sig(i,j,k-1);
984 Real w4 = sig(i-1,j-1,k ) + sig(i,j-1,k ) + sig(i-1,j,k ) + sig(i,j,k );
985 return (w1 * aa_interp_line_z(crse,sig,i,j-1,k ,ic,jc ,kc ) +
986 w2 * aa_interp_line_z(crse,sig,i,j+1,k ,ic,jc+1,kc ) +
987 w3 * aa_interp_line_y(crse,sig,i,j ,k-1,ic,jc ,kc ) +
988 w4 * aa_interp_line_y(crse,sig,i,j ,k+1,ic,jc ,kc+1)) / (w1+w2+w3+w4);
989 }
990
992void mlndlap_interpadd_c (int i, int j, int k, Array4<Real> const& fine,
993 Array4<Real const> const& crse,
994 Array4<int const> const& msk) noexcept
995{
996 if (!msk(i,j,k)) {
997 int ic = amrex::coarsen(i,2);
998 int jc = amrex::coarsen(j,2);
999 int kc = amrex::coarsen(k,2);
1000 bool i_is_odd = (ic*2 != i);
1001 bool j_is_odd = (jc*2 != j);
1002 bool k_is_odd = (kc*2 != k);
1003 if (i_is_odd && j_is_odd && k_is_odd) {
1004 // Fine node at center of cell
1005 fine(i,j,k) += Real(0.125) *
1006 (crse(ic,jc ,kc ) + crse(ic+1,jc ,kc ) +
1007 crse(ic,jc+1,kc ) + crse(ic+1,jc+1,kc ) +
1008 crse(ic,jc ,kc+1) + crse(ic+1,jc ,kc+1) +
1009 crse(ic,jc+1,kc+1) + crse(ic+1,jc+1,kc+1));
1010 } else if (j_is_odd && k_is_odd) {
1011 // Node on a Y-Z face
1012 fine(i,j,k) += Real(0.25) *
1013 (crse(ic,jc,kc ) + crse(ic,jc+1,kc ) +
1014 crse(ic,jc,kc+1) + crse(ic,jc+1,kc+1));
1015 } else if (i_is_odd && k_is_odd) {
1016 // Node on a Z-X face
1017 fine(i,j,k) += Real(0.25) *
1018 (crse(ic,jc,kc ) + crse(ic+1,jc,kc ) +
1019 crse(ic,jc,kc+1) + crse(ic+1,jc,kc+1));
1020 } else if (i_is_odd && j_is_odd) {
1021 // Node on a X-Y face
1022 fine(i,j,k) += Real(0.25) *
1023 (crse(ic,jc ,kc) + crse(ic+1,jc ,kc) +
1024 crse(ic,jc+1,kc) + crse(ic+1,jc+1,kc));
1025 } else if (i_is_odd) {
1026 // Node on X line
1027 fine(i,j,k) += Real(0.5)*(crse(ic,jc,kc)+crse(ic+1,jc,kc));
1028 } else if (j_is_odd) {
1029 // Node on Y line
1030 fine(i,j,k) += Real(0.5)*(crse(ic,jc,kc)+crse(ic,jc+1,kc));
1031 } else if (k_is_odd) {
1032 // Node on Z line
1033 fine(i,j,k) += Real(0.5)*(crse(ic,jc,kc)+crse(ic,jc,kc+1));
1034 } else {
1035 // Node coincident with coarse node
1036 fine(i,j,k) += crse(ic,jc,kc);
1037 }
1038 }
1039}
1040
1042void mlndlap_interpadd_aa (int i, int j, int k, Array4<Real> const& fine,
1043 Array4<Real const> const& crse, Array4<Real const> const& sig,
1044 Array4<int const> const& msk) noexcept
1045{
1046 if (!msk(i,j,k)) {
1047 int ic = amrex::coarsen(i,2);
1048 int jc = amrex::coarsen(j,2);
1049 int kc = amrex::coarsen(k,2);
1050 bool i_is_odd = (ic*2 != i);
1051 bool j_is_odd = (jc*2 != j);
1052 bool k_is_odd = (kc*2 != k);
1053 if (i_is_odd && j_is_odd && k_is_odd) {
1054 // Fine node at center of cell
1055 Real w1 = sig(i-1,j-1,k-1) + sig(i-1,j,k-1) + sig(i-1,j-1,k) + sig(i-1,j,k);
1056 Real w2 = sig(i ,j-1,k-1) + sig(i ,j,k-1) + sig(i ,j-1,k) + sig(i ,j,k);
1057 Real w3 = sig(i-1,j-1,k-1) + sig(i,j-1,k-1) + sig(i-1,j-1,k) + sig(i,j-1,k);
1058 Real w4 = sig(i-1,j ,k-1) + sig(i,j ,k-1) + sig(i-1,j ,k) + sig(i,j ,k);
1059 Real w5 = sig(i-1,j-1,k-1) + sig(i,j-1,k-1) + sig(i-1,j,k-1) + sig(i,j,k-1);
1060 Real w6 = sig(i-1,j-1,k ) + sig(i,j-1,k ) + sig(i-1,j,k ) + sig(i,j,k );
1061 fine(i,j,k) += (w1 * aa_interp_face_yz(crse,sig,i-1,j ,k ,ic ,jc ,kc ) +
1062 w2 * aa_interp_face_yz(crse,sig,i+1,j ,k ,ic+1,jc ,kc ) +
1063 w3 * aa_interp_face_xz(crse,sig,i ,j-1,k ,ic ,jc ,kc ) +
1064 w4 * aa_interp_face_xz(crse,sig,i ,j+1,k ,ic ,jc+1,kc ) +
1065 w5 * aa_interp_face_xy(crse,sig,i ,j ,k-1,ic ,jc ,kc ) +
1066 w6 * aa_interp_face_xy(crse,sig,i ,j ,k+1,ic ,jc ,kc+1))
1067 / (w1+w2+w3+w4+w5+w6);
1068 } else if (j_is_odd && k_is_odd) {
1069 // Node on a Y-Z face
1070 fine(i,j,k) += aa_interp_face_yz(crse,sig,i,j,k,ic,jc,kc);
1071 } else if (i_is_odd && k_is_odd) {
1072 // Node on a Z-X face
1073 fine(i,j,k) += aa_interp_face_xz(crse,sig,i,j,k,ic,jc,kc);
1074 } else if (i_is_odd && j_is_odd) {
1075 // Node on a X-Y face
1076 fine(i,j,k) += aa_interp_face_xy(crse,sig,i,j,k,ic,jc,kc);
1077 } else if (i_is_odd) {
1078 // Node on X line
1079 fine(i,j,k) += aa_interp_line_x(crse,sig,i,j,k,ic,jc,kc);
1080 } else if (j_is_odd) {
1081 // Node on Y line
1082 fine(i,j,k) += aa_interp_line_y(crse,sig,i,j,k,ic,jc,kc);
1083 } else if (k_is_odd) {
1084 // Node on Z line
1085 fine(i,j,k) += aa_interp_line_z(crse,sig,i,j,k,ic,jc,kc);
1086 } else {
1087 // Node coincident with coarse node
1088 fine(i,j,k) += crse(ic,jc,kc);
1089 }
1090 }
1091}
1092
1094void mlndlap_semi_interpadd_aa (int i, int j, int k, Array4<Real> const& fine,
1095 Array4<Real const> const& crse, Array4<Real const> const& sig,
1096 Array4<int const> const& msk, int idir) noexcept
1097{
1098 if (idir == 2 )
1099 {
1100 if (!msk(i,j,k)) {
1101 int ic = amrex::coarsen(i,2);
1102 int jc = amrex::coarsen(j,2);
1103 int kc = k;
1104 bool i_is_odd = (ic*2 != i);
1105 bool j_is_odd = (jc*2 != j);
1106
1107 if (i_is_odd && j_is_odd) {
1108 // Node on a X-Y face
1109 fine(i,j,k) += aa_interp_face_xy(crse,sig,i,j,k,ic,jc,kc);
1110 } else if (i_is_odd) {
1111 // Node on X line
1112 fine(i,j,k) += aa_interp_line_x(crse,sig,i,j,k,ic,jc,kc);
1113 } else if (j_is_odd) {
1114 // Node on Y line
1115 fine(i,j,k) += aa_interp_line_y(crse,sig,i,j,k,ic,jc,kc);
1116 } else {
1117 // Node coincident with coarse node
1118 fine(i,j,k) += crse(ic,jc,kc);
1119 }
1120 }
1121 } else if (idir ==1 ){
1122 if (!msk(i,j,k)) {
1123 int ic = amrex::coarsen(i,2);
1124 int jc = j;
1125 int kc = amrex::coarsen(k,2);
1126 bool i_is_odd = (ic*2 != i);
1127 bool k_is_odd = (kc*2 != k);
1128
1129 if (i_is_odd && k_is_odd) {
1130 // Node on a X-Z face
1131 fine(i,j,k) += aa_interp_face_xz(crse,sig,i,j,k,ic,jc,kc);
1132 } else if (i_is_odd) {
1133 // Node on X line
1134 fine(i,j,k) += aa_interp_line_x(crse,sig,i,j,k,ic,jc,kc);
1135 } else if (k_is_odd) {
1136 // Node on Z line
1137 fine(i,j,k) += aa_interp_line_z(crse,sig,i,j,k,ic,jc,kc);
1138 } else {
1139 // Node coincident with coarse node
1140 fine(i,j,k) += crse(ic,jc,kc);
1141 }
1142 }
1143 } else if (idir == 0 ) {
1144 if (!msk(i,j,k)) {
1145 int ic = i;
1146 int jc = amrex::coarsen(j,2);
1147 int kc = amrex::coarsen(k,2);
1148 bool j_is_odd = (jc*2 != j);
1149 bool k_is_odd = (kc*2 != k);
1150
1151 if (j_is_odd && k_is_odd) {
1152 // Node on a Y-Z face
1153 fine(i,j,k) += aa_interp_face_yz(crse,sig,i,j,k,ic,jc,kc);
1154 } else if (j_is_odd) {
1155 // Node on Y line
1156 fine(i,j,k) += aa_interp_line_y(crse,sig,i,j,k,ic,jc,kc);
1157 } else if (k_is_odd) {
1158 // Node on Z line
1159 fine(i,j,k) += aa_interp_line_z(crse,sig,i,j,k,ic,jc,kc);
1160 } else {
1161 // Node coincident with coarse node
1162 fine(i,j,k) += crse(ic,jc,kc);
1163 }
1164 }
1165 } else {
1166 amrex::Abort("mlndlap_semi_interpolation semi direction wrong semi-direction. ");
1167 }
1168}
1169
1170
1173 Array4<Real const> const& sigx, Array4<Real const> const& sigy,
1174 int i, int j, int k, int ic, int jc, int kc) noexcept
1175 {
1176 Real w1 = sigx(i-1,j-1,k-1) + sigx(i-1,j,k-1) + sigx(i-1,j-1,k) + sigx(i-1,j,k);
1177 Real w2 = sigx(i ,j-1,k-1) + sigx(i ,j,k-1) + sigx(i ,j-1,k) + sigx(i ,j,k);
1178 Real w3 = sigy(i-1,j-1,k-1) + sigy(i,j-1,k-1) + sigy(i-1,j-1,k) + sigy(i,j-1,k);
1179 Real w4 = sigy(i-1,j ,k-1) + sigy(i,j ,k-1) + sigy(i-1,j ,k) + sigy(i,j ,k);
1180 return (w1 * aa_interp_line_y(crse,sigy,i-1,j ,k,ic ,jc ,kc) +
1181 w2 * aa_interp_line_y(crse,sigy,i+1,j ,k,ic+1,jc ,kc) +
1182 w3 * aa_interp_line_x(crse,sigx,i ,j-1,k,ic ,jc ,kc) +
1183 w4 * aa_interp_line_x(crse,sigx,i ,j+1,k,ic ,jc+1,kc)) / (w1+w2+w3+w4);
1184 }
1185
1188 Array4<Real const> const& sigx, Array4<Real const> const& sigz,
1189 int i, int j, int k, int ic, int jc, int kc) noexcept
1190 {
1191 Real w1 = sigx(i-1,j-1,k-1) + sigx(i-1,j,k-1) + sigx(i-1,j-1,k) + sigx(i-1,j,k);
1192 Real w2 = sigx(i ,j-1,k-1) + sigx(i ,j,k-1) + sigx(i ,j-1,k) + sigx(i ,j,k);
1193 Real w3 = sigz(i-1,j-1,k-1) + sigz(i,j-1,k-1) + sigz(i-1,j,k-1) + sigz(i,j,k-1);
1194 Real w4 = sigz(i-1,j-1,k ) + sigz(i,j-1,k ) + sigz(i-1,j,k ) + sigz(i,j,k );
1195 return (w1 * aa_interp_line_z(crse,sigz,i-1,j,k ,ic ,jc,kc ) +
1196 w2 * aa_interp_line_z(crse,sigz,i+1,j,k ,ic+1,jc,kc ) +
1197 w3 * aa_interp_line_x(crse,sigx,i ,j,k-1,ic ,jc,kc ) +
1198 w4 * aa_interp_line_x(crse,sigx,i ,j,k+1,ic ,jc,kc+1)) / (w1+w2+w3+w4);
1199 }
1200
1203 Array4<Real const> const& sigy, Array4<Real const> const& sigz,
1204 int i, int j, int k, int ic, int jc, int kc) noexcept
1205 {
1206 Real w1 = sigy(i-1,j-1,k-1) + sigy(i,j-1,k-1) + sigy(i-1,j-1,k) + sigy(i,j-1,k);
1207 Real w2 = sigy(i-1,j ,k-1) + sigy(i,j ,k-1) + sigy(i-1,j ,k) + sigy(i,j ,k);
1208 Real w3 = sigz(i-1,j-1,k-1) + sigz(i,j-1,k-1) + sigz(i-1,j,k-1) + sigz(i,j,k-1);
1209 Real w4 = sigz(i-1,j-1,k ) + sigz(i,j-1,k ) + sigz(i-1,j,k ) + sigz(i,j,k );
1210 return (w1 * aa_interp_line_z(crse,sigz,i,j-1,k ,ic,jc ,kc ) +
1211 w2 * aa_interp_line_z(crse,sigz,i,j+1,k ,ic,jc+1,kc ) +
1212 w3 * aa_interp_line_y(crse,sigy,i,j ,k-1,ic,jc ,kc ) +
1213 w4 * aa_interp_line_y(crse,sigy,i,j ,k+1,ic,jc ,kc+1)) / (w1+w2+w3+w4);
1214 }
1215
1217void mlndlap_interpadd_ha (int i, int j, int k, Array4<Real> const& fine,
1218 Array4<Real const> const& crse, Array4<Real const> const& sigx,
1219 Array4<Real const> const& sigy, Array4<Real const> const& sigz,
1220 Array4<int const> const& msk) noexcept
1221{
1222 if (!msk(i,j,k)) {
1223 int ic = amrex::coarsen(i,2);
1224 int jc = amrex::coarsen(j,2);
1225 int kc = amrex::coarsen(k,2);
1226 bool i_is_odd = (ic*2 != i);
1227 bool j_is_odd = (jc*2 != j);
1228 bool k_is_odd = (kc*2 != k);
1229 if (i_is_odd && j_is_odd && k_is_odd) {
1230 // Fine node at center of cell
1231 Real w1 = sigx(i-1,j-1,k-1) + sigx(i-1,j,k-1) + sigx(i-1,j-1,k) + sigx(i-1,j,k);
1232 Real w2 = sigx(i ,j-1,k-1) + sigx(i ,j,k-1) + sigx(i ,j-1,k) + sigx(i ,j,k);
1233 Real w3 = sigy(i-1,j-1,k-1) + sigy(i,j-1,k-1) + sigy(i-1,j-1,k) + sigy(i,j-1,k);
1234 Real w4 = sigy(i-1,j ,k-1) + sigy(i,j ,k-1) + sigy(i-1,j ,k) + sigy(i,j ,k);
1235 Real w5 = sigz(i-1,j-1,k-1) + sigz(i,j-1,k-1) + sigz(i-1,j,k-1) + sigz(i,j,k-1);
1236 Real w6 = sigz(i-1,j-1,k ) + sigz(i,j-1,k ) + sigz(i-1,j,k ) + sigz(i,j,k );
1237 fine(i,j,k) += (w1 * ha_interp_face_yz(crse,sigy,sigz,i-1,j ,k ,ic ,jc ,kc ) +
1238 w2 * ha_interp_face_yz(crse,sigy,sigz,i+1,j ,k ,ic+1,jc ,kc ) +
1239 w3 * ha_interp_face_xz(crse,sigx,sigz,i ,j-1,k ,ic ,jc ,kc ) +
1240 w4 * ha_interp_face_xz(crse,sigx,sigz,i ,j+1,k ,ic ,jc+1,kc ) +
1241 w5 * ha_interp_face_xy(crse,sigx,sigy,i ,j ,k-1,ic ,jc ,kc ) +
1242 w6 * ha_interp_face_xy(crse,sigx,sigy,i ,j ,k+1,ic ,jc ,kc+1))
1243 / (w1+w2+w3+w4+w5+w6);
1244 } else if (j_is_odd && k_is_odd) {
1245 // Node on a Y-Z face
1246 fine(i,j,k) += ha_interp_face_yz(crse,sigy,sigz,i,j,k,ic,jc,kc);
1247 } else if (i_is_odd && k_is_odd) {
1248 // Node on a Z-X face
1249 fine(i,j,k) += ha_interp_face_xz(crse,sigx,sigz,i,j,k,ic,jc,kc);
1250 } else if (i_is_odd && j_is_odd) {
1251 // Node on a X-Y face
1252 fine(i,j,k) += ha_interp_face_xy(crse,sigx,sigy,i,j,k,ic,jc,kc);
1253 } else if (i_is_odd) {
1254 // Node on X line
1255 fine(i,j,k) += aa_interp_line_x(crse,sigx,i,j,k,ic,jc,kc);
1256 } else if (j_is_odd) {
1257 // Node on Y line
1258 fine(i,j,k) += aa_interp_line_y(crse,sigy,i,j,k,ic,jc,kc);
1259 } else if (k_is_odd) {
1260 // Node on Z line
1261 fine(i,j,k) += aa_interp_line_z(crse,sigz,i,j,k,ic,jc,kc);
1262 } else {
1263 // Node coincident with coarse node
1264 fine(i,j,k) += crse(ic,jc,kc);
1265 }
1266 }
1267}
1268
1269//
1270// rhs & u
1271//
1272
1274void mlndlap_divu (int i, int j, int k, Array4<Real> const& rhs, Array4<Real const> const& vel,
1275 Array4<int const> const& msk,
1276 GpuArray<Real,AMREX_SPACEDIM> const& dxinv,
1277 Box const& nodal_domain,
1278 GpuArray<LinOpBCType, AMREX_SPACEDIM> const& bclo,
1279 GpuArray<LinOpBCType, AMREX_SPACEDIM> const& bchi) noexcept
1280{
1281 Real facx = Real(0.25)*dxinv[0];
1282 Real facy = Real(0.25)*dxinv[1];
1283 Real facz = Real(0.25)*dxinv[2];
1284
1285 const auto domlo = amrex::lbound(nodal_domain);
1286 const auto domhi = amrex::ubound(nodal_domain);
1287
1288 if (msk(i,j,k)) {
1289 rhs(i,j,k) = Real(0.0);
1290 } else {
1291
1292 Real zero_ilo = Real(1.0);
1293 Real zero_ihi = Real(1.0);
1294 Real zero_jlo = Real(1.0);
1295 Real zero_jhi = Real(1.0);
1296 Real zero_klo = Real(1.0);
1297 Real zero_khi = Real(1.0);
1298
1299 // The nodal divergence operator should not see the tangential velocity
1300 // at an inflow face
1301 if ((bclo[0] == LinOpBCType::Neumann || bclo[0] == LinOpBCType::inflow)
1302 && i == domlo.x)
1303 {
1304 zero_ilo = Real(0.0);
1305 }
1306 if ((bchi[0] == LinOpBCType::Neumann || bchi[0] == LinOpBCType::inflow)
1307 && i == domhi.x)
1308 {
1309 zero_ihi = Real(0.0);
1310 }
1311 if ((bclo[1] == LinOpBCType::Neumann || bclo[1] == LinOpBCType::inflow)
1312 && j == domlo.y)
1313 {
1314 zero_jlo = Real(0.0);
1315 }
1316 if ((bchi[1] == LinOpBCType::Neumann || bchi[1] == LinOpBCType::inflow)
1317 && j == domhi.y)
1318 {
1319 zero_jhi = Real(0.0);
1320 }
1321 if ((bclo[2] == LinOpBCType::Neumann || bclo[2] == LinOpBCType::inflow)
1322 && k == domlo.z)
1323 {
1324 zero_klo = Real(0.0);
1325 }
1326 if ((bchi[2] == LinOpBCType::Neumann || bchi[2] == LinOpBCType::inflow)
1327 && k == domhi.z)
1328 {
1329 zero_khi = Real(0.0);
1330 }
1331
1332 rhs(i,j,k) = facx*(-vel(i-1,j-1,k-1,0)*zero_jlo*zero_klo+vel(i,j-1,k-1,0)*zero_jlo*zero_klo
1333 -vel(i-1,j ,k-1,0)*zero_jhi*zero_klo+vel(i,j ,k-1,0)*zero_jhi*zero_klo
1334 -vel(i-1,j-1,k ,0)*zero_jlo*zero_khi+vel(i,j-1,k ,0)*zero_jlo*zero_khi
1335 -vel(i-1,j ,k ,0)*zero_jhi*zero_khi+vel(i,j ,k ,0)*zero_jhi*zero_khi)
1336
1337 + facy*(-vel(i-1,j-1,k-1,1)*zero_ilo*zero_klo-vel(i,j-1,k-1,1)*zero_ihi*zero_klo
1338 +vel(i-1,j ,k-1,1)*zero_ilo*zero_klo+vel(i,j ,k-1,1)*zero_ihi*zero_klo
1339 -vel(i-1,j-1,k ,1)*zero_ilo*zero_khi-vel(i,j-1,k ,1)*zero_ihi*zero_khi
1340 +vel(i-1,j ,k ,1)*zero_ilo*zero_khi+vel(i,j ,k ,1)*zero_ihi*zero_khi)
1341
1342 + facz*(-vel(i-1,j-1,k-1,2)*zero_ilo*zero_jlo-vel(i,j-1,k-1,2)*zero_ihi*zero_jlo
1343 -vel(i-1,j ,k-1,2)*zero_ilo*zero_jhi-vel(i,j ,k-1,2)*zero_ihi*zero_jhi
1344 +vel(i-1,j-1,k ,2)*zero_ilo*zero_jlo+vel(i,j-1,k ,2)*zero_ihi*zero_jlo
1345 +vel(i-1,j ,k ,2)*zero_ilo*zero_jhi+vel(i,j ,k ,2)*zero_ihi*zero_jhi);
1346 }
1347}
1348
1350Real mlndlap_rhcc (int i, int j, int k, Array4<Real const> const& rhcc,
1351 Array4<int const> const& msk) noexcept
1352{
1353 Real r;
1354 if (msk(i,j,k)) {
1355 r = Real(0.0);
1356 } else {
1357 r = Real(0.125) * (rhcc(i-1,j-1,k-1)+rhcc(i,j-1,k-1)+rhcc(i-1,j,k-1)+rhcc(i,j,k-1) +
1358 rhcc(i-1,j-1,k )+rhcc(i,j-1,k )+rhcc(i-1,j,k )+rhcc(i,j,k ));
1359 }
1360 return r;
1361}
1362
1364void mlndlap_mknewu (int i, int j, int k, Array4<Real> const& u, Array4<Real const> const& p,
1365 Array4<Real const> const& sig, GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
1366{
1367 Real facx = Real(0.25)*dxinv[0];
1368 Real facy = Real(0.25)*dxinv[1];
1369 Real facz = Real(0.25)*dxinv[2];
1370 u(i,j,k,0) -= sig(i,j,k)*facx
1371 * (-p(i,j,k )+p(i+1,j,k )-p(i,j+1,k )+p(i+1,j+1,k )
1372 -p(i,j,k+1)+p(i+1,j,k+1)-p(i,j+1,k+1)+p(i+1,j+1,k+1));
1373 u(i,j,k,1) -= sig(i,j,k)*facy
1374 * (-p(i,j,k )-p(i+1,j,k )+p(i,j+1,k )+p(i+1,j+1,k )
1375 -p(i,j,k+1)-p(i+1,j,k+1)+p(i,j+1,k+1)+p(i+1,j+1,k+1));
1376 u(i,j,k,2) -= sig(i,j,k)*facz
1377 * (-p(i,j,k )-p(i+1,j,k )-p(i,j+1,k )-p(i+1,j+1,k )
1378 +p(i,j,k+1)+p(i+1,j,k+1)+p(i,j+1,k+1)+p(i+1,j+1,k+1));
1379}
1380
1382void mlndlap_mknewu_c (int i, int j, int k, Array4<Real> const& u, Array4<Real const> const& p,
1383 Real sig, GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
1384{
1385 Real facx = Real(0.25)*dxinv[0];
1386 Real facy = Real(0.25)*dxinv[1];
1387 Real facz = Real(0.25)*dxinv[2];
1388 u(i,j,k,0) -= sig*facx
1389 * (-p(i,j,k )+p(i+1,j,k )-p(i,j+1,k )+p(i+1,j+1,k )
1390 -p(i,j,k+1)+p(i+1,j,k+1)-p(i,j+1,k+1)+p(i+1,j+1,k+1));
1391 u(i,j,k,1) -= sig*facy
1392 * (-p(i,j,k )-p(i+1,j,k )+p(i,j+1,k )+p(i+1,j+1,k )
1393 -p(i,j,k+1)-p(i+1,j,k+1)+p(i,j+1,k+1)+p(i+1,j+1,k+1));
1394 u(i,j,k,2) -= sig*facz
1395 * (-p(i,j,k )-p(i+1,j,k )-p(i,j+1,k )-p(i+1,j+1,k )
1396 +p(i,j,k+1)+p(i+1,j,k+1)+p(i,j+1,k+1)+p(i+1,j+1,k+1));
1397}
1398
1400 Real mlndlap_sum_Df (int ii, int jj, int kk, Real facx, Real facy, Real facz,
1401 Array4<Real const> const& vel, Box const& velbx) noexcept
1402 {
1403 Real Df = Real(0.0);
1404 if (velbx.contains(ii-1,jj-1,kk-1)) {
1405 Df += -facx*vel(ii-1,jj-1,kk-1,0) - facy*vel(ii-1,jj-1,kk-1,1) - facz*vel(ii-1,jj-1,kk-1,2);
1406 }
1407 if (velbx.contains(ii,jj-1,kk-1)) {
1408 Df += facx*vel(ii,jj-1,kk-1,0) - facy*vel(ii,jj-1,kk-1,1) - facz*vel(ii,jj-1,kk-1,2);
1409 }
1410 if (velbx.contains(ii-1,jj,kk-1)) {
1411 Df += -facx*vel(ii-1,jj,kk-1,0) + facy*vel(ii-1,jj,kk-1,1) - facz*vel(ii-1,jj,kk-1,2);
1412 }
1413 if (velbx.contains(ii,jj,kk-1)) {
1414 Df += facx*vel(ii,jj,kk-1,0) + facy*vel(ii,jj,kk-1,1) - facz*vel(ii,jj,kk-1,2);
1415 }
1416 if (velbx.contains(ii-1,jj-1,kk)) {
1417 Df += -facx*vel(ii-1,jj-1,kk,0) - facy*vel(ii-1,jj-1,kk,1) + facz*vel(ii-1,jj-1,kk,2);
1418 }
1419 if (velbx.contains(ii,jj-1,kk)) {
1420 Df += facx*vel(ii,jj-1,kk,0) - facy*vel(ii,jj-1,kk,1) + facz*vel(ii,jj-1,kk,2);
1421 }
1422 if (velbx.contains(ii-1,jj,kk)) {
1423 Df += -facx*vel(ii-1,jj,kk,0) + facy*vel(ii-1,jj,kk,1) + facz*vel(ii-1,jj,kk,2);
1424 }
1425 if (velbx.contains(ii,jj,kk)) {
1426 Df += facx*vel(ii,jj,kk,0) + facy*vel(ii,jj,kk,1) + facz*vel(ii,jj,kk,2);
1427 }
1428 return Df;
1429 }
1430
1431template <int rr>
1433void mlndlap_divu_fine_contrib (int i, int j, int k, Box const& fvbx, Box const& velbx,
1434 Array4<Real> const& rhs, Array4<Real const> const& vel,
1435 Array4<Real const> const& frhs, Array4<int const> const& msk,
1436 GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
1437{
1438 const int ii = rr*i;
1439 const int jj = rr*j;
1440 const int kk = rr*k;
1441 if (msk(ii,jj,kk)) {
1442 const Real facx = Real(0.25)*dxinv[0];
1443 const Real facy = Real(0.25)*dxinv[1];
1444 const Real facz = Real(0.25)*dxinv[2];
1445
1446 Real Df = Real(0.0);
1447
1448 const int ilo = amrex::max(ii-rr+1, fvbx.smallEnd(0));
1449 const int ihi = amrex::min(ii+rr-1, fvbx.bigEnd (0));
1450 const int jlo = amrex::max(jj-rr+1, fvbx.smallEnd(1));
1451 const int jhi = amrex::min(jj+rr-1, fvbx.bigEnd (1));
1452 const int klo = amrex::max(kk-rr+1, fvbx.smallEnd(2));
1453 const int khi = amrex::min(kk+rr-1, fvbx.bigEnd (2));
1454
1455 for (int koff = klo; koff <= khi; ++koff) {
1456 for (int joff = jlo; joff <= jhi; ++joff) {
1457 for (int ioff = ilo; ioff <= ihi; ++ioff) {
1458 Real scale = static_cast<Real>((rr-std::abs(ii-ioff)) *
1459 (rr-std::abs(jj-joff)) *
1460 (rr-std::abs(kk-koff)));
1461 if (fvbx.strictly_contains(ioff,joff,koff)) {
1462 Df += scale * frhs(ioff,joff,koff);
1463 } else {
1464 Df += scale * mlndlap_sum_Df(ioff, joff, koff, facx, facy, facz, vel, velbx);
1465 }
1466 }}}
1467
1468 rhs(i,j,k) = Df * (Real(1.0)/static_cast<Real>(rr*rr*rr*rr*rr*rr));
1469 } else {
1470 rhs(i,j,k) = Real(0.0);
1471 }
1472}
1473
1474template<int rr>
1476void mlndlap_rhcc_fine_contrib (int i, int j, int k, Box const& ccbx,
1477 Array4<Real> const& rhs, Array4<Real const> const& cc,
1478 Array4<int const> const& msk) noexcept
1479{
1480 const int ii = rr*i;
1481 const int jj = rr*j;
1482 const int kk = rr*k;
1483 if (msk(ii,jj,kk)) {
1484 Real tmp = Real(0.0);
1485
1486 const int ilo = amrex::max(ii-rr , ccbx.smallEnd(0));
1487 const int ihi = amrex::min(ii+rr-1, ccbx.bigEnd (0));
1488 const int jlo = amrex::max(jj-rr , ccbx.smallEnd(1));
1489 const int jhi = amrex::min(jj+rr-1, ccbx.bigEnd (1));
1490 const int klo = amrex::max(kk-rr , ccbx.smallEnd(2));
1491 const int khi = amrex::min(kk+rr-1, ccbx.bigEnd (2));
1492
1493 for (int koff = klo; koff <= khi; ++koff) {
1494 for (int joff = jlo; joff <= jhi; ++joff) {
1495 for (int ioff = ilo; ioff <= ihi; ++ioff) {
1496 Real scale = (static_cast<Real>(rr)-std::abs(static_cast<Real>(ioff-ii)+Real(0.5)))
1497 * (static_cast<Real>(rr)-std::abs(static_cast<Real>(joff-jj)+Real(0.5)))
1498 * (static_cast<Real>(rr)-std::abs(static_cast<Real>(koff-kk)+Real(0.5)));
1499 tmp += cc(ioff,joff,koff) * scale;
1500 }}}
1501
1502 rhs(i,j,k) += tmp * (Real(1.0)/Real(rr*rr*rr*rr*rr*rr));
1503 }
1504}
1505
1507 Real neumann_scale (int i, int j, int k, Box const& nddom,
1509 GpuArray<LinOpBCType,AMREX_SPACEDIM> const& bchi) noexcept
1510 {
1511 Real val = Real(1.0);
1512
1513 const auto ndlo = amrex::lbound(nddom);
1514 const auto ndhi = amrex::ubound(nddom);
1515
1516 if ((i == ndlo.x && ( bclo[0] == LinOpBCType::Neumann ||
1517 bclo[0] == LinOpBCType::inflow)) ||
1518 (i == ndhi.x && ( bchi[0] == LinOpBCType::Neumann ||
1519 bchi[0] == LinOpBCType::inflow))) {
1520 val *= Real(2.);
1521 }
1522
1523 if ((j == ndlo.y && ( bclo[1] == LinOpBCType::Neumann ||
1524 bclo[1] == LinOpBCType::inflow)) ||
1525 (j == ndhi.y && ( bchi[1] == LinOpBCType::Neumann ||
1526 bchi[1] == LinOpBCType::inflow))) {
1527 val *= Real(2.);
1528 }
1529
1530 if ((k == ndlo.z && ( bclo[2] == LinOpBCType::Neumann ||
1531 bclo[2] == LinOpBCType::inflow)) ||
1532 (k == ndhi.z && ( bchi[2] == LinOpBCType::Neumann ||
1533 bchi[2] == LinOpBCType::inflow))) {
1534 val *= Real(2.);
1535 }
1536
1537 return val;
1538 }
1539
1541void mlndlap_divu_cf_contrib (int i, int j, int k, Array4<Real> const& rhs,
1542 Array4<Real const> const& vel, Array4<Real const> const& fc,
1543 Array4<Real const> const& rhcc, Array4<int const> const& dmsk,
1544 Array4<int const> const& ndmsk, Array4<int const> const& ccmsk,
1545 GpuArray<Real,AMREX_SPACEDIM> const& dxinv,
1546 Box const& ccdom_p, Box const& veldom, Box const& nddom,
1548 GpuArray<LinOpBCType,AMREX_SPACEDIM> const& bchi) noexcept
1549{
1550 using namespace nodelap_detail;
1551
1552 if (!dmsk(i,j,k) && ndmsk(i,j,k) == crse_fine_node) {
1553 Real facx = Real(0.25) * dxinv[0];
1554 Real facy = Real(0.25) * dxinv[1];
1555 Real facz = Real(0.25) * dxinv[2];
1556 Real tmp = fc(i,j,k);
1557
1558 // Where there is inflow, veldom there is bigger than ccdom_p by one cell.
1559 // ccdom_p is cc domain grown at periodic boundaries.
1560
1561 if (ccmsk(i-1,j-1,k-1) == crse_cell && veldom.contains(i-1,j-1,k-1)) {
1562 tmp += -facx*vel(i-1,j-1,k-1,0) - facy*vel(i-1,j-1,k-1,1) - facz*vel(i-1,j-1,k-1,2);
1563 if (rhcc && ccdom_p.contains(i-1,j-1,k-1)) {
1564 tmp += Real(0.125) * rhcc(i-1,j-1,k-1);
1565 }
1566 }
1567
1568 if (ccmsk(i,j-1,k-1) == crse_cell && veldom.contains(i,j-1,k-1)) {
1569 tmp += facx*vel(i,j-1,k-1,0) - facy*vel(i,j-1,k-1,1) - facz*vel(i,j-1,k-1,2);
1570 if (rhcc && ccdom_p.contains(i,j-1,k-1)) {
1571 tmp += Real(0.125) * rhcc(i,j-1,k-1);
1572 }
1573 }
1574
1575 if (ccmsk(i-1,j,k-1) == crse_cell && veldom.contains(i-1,j,k-1)) {
1576 tmp += -facx*vel(i-1,j,k-1,0) + facy*vel(i-1,j,k-1,1) - facz*vel(i-1,j,k-1,2);
1577 if (rhcc && ccdom_p.contains(i-1,j,k-1)) {
1578 tmp += Real(0.125) * rhcc(i-1,j,k-1);
1579 }
1580 }
1581
1582 if (ccmsk(i,j,k-1) == crse_cell && veldom.contains(i,j,k-1)) {
1583 tmp += facx*vel(i,j,k-1,0) + facy*vel(i,j,k-1,1) - facz*vel(i,j,k-1,2);
1584 if (rhcc && ccdom_p.contains(i,j,k-1)) {
1585 tmp += Real(0.125) * rhcc(i,j,k-1);
1586 }
1587 }
1588
1589 if (ccmsk(i-1,j-1,k) == crse_cell && veldom.contains(i-1,j-1,k)) {
1590 tmp += -facx*vel(i-1,j-1,k,0) - facy*vel(i-1,j-1,k,1) + facz*vel(i-1,j-1,k,2);
1591 if (rhcc && ccdom_p.contains(i-1,j-1,k)) {
1592 tmp += Real(0.125) * rhcc(i-1,j-1,k);
1593 }
1594 }
1595
1596 if (ccmsk(i,j-1,k) == crse_cell && veldom.contains(i,j-1,k)) {
1597 tmp += facx*vel(i,j-1,k,0) - facy*vel(i,j-1,k,1) + facz*vel(i,j-1,k,2);
1598 if (rhcc && ccdom_p.contains(i,j-1,k)) {
1599 tmp += Real(0.125) * rhcc(i,j-1,k);
1600 }
1601 }
1602
1603 if (ccmsk(i-1,j,k) == crse_cell && veldom.contains(i-1,j,k)) {
1604 tmp += -facx*vel(i-1,j,k,0) + facy*vel(i-1,j,k,1) + facz*vel(i-1,j,k,2);
1605 if (rhcc && ccdom_p.contains(i-1,j,k)) {
1606 tmp += Real(0.125) * rhcc(i-1,j,k);
1607 }
1608 }
1609
1610 if (ccmsk(i,j,k) == crse_cell && veldom.contains(i,j,k)) {
1611 tmp += facx*vel(i,j,k,0) + facy*vel(i,j,k,1) + facz*vel(i,j,k,2);
1612 if (rhcc && ccdom_p.contains(i,j,k)) {
1613 tmp += Real(0.125) * rhcc(i,j,k);
1614 }
1615 }
1616
1617 rhs(i,j,k) = tmp * neumann_scale(i, j, k, nddom, bclo, bchi);
1618 }
1619}
1620
1621//
1622// residual
1623//
1624
1626void mlndlap_crse_resid (int i, int j, int k, Array4<Real> const& resid,
1627 Array4<Real const> const& rhs, Array4<int const> const& msk,
1628 Box const& nddom, GpuArray<LinOpBCType,AMREX_SPACEDIM> const& bclo,
1629 GpuArray<LinOpBCType,AMREX_SPACEDIM> const& bchi,
1630 bool neumann_doubling) noexcept
1631{
1632 if ( msk(i-1,j-1,k-1) == 0 ||
1633 msk(i ,j-1,k-1) == 0 ||
1634 msk(i-1,j ,k-1) == 0 ||
1635 msk(i ,j ,k-1) == 0 ||
1636 msk(i-1,j-1,k ) == 0 ||
1637 msk(i ,j-1,k ) == 0 ||
1638 msk(i-1,j ,k ) == 0 ||
1639 msk(i ,j ,k ) == 0 )
1640 {
1641 Real fac = Real(1.0);
1642 if (neumann_doubling) {
1643 const auto ndlo = amrex::lbound(nddom);
1644 const auto ndhi = amrex::ubound(nddom);
1645 if ((i == ndlo.x && ( bclo[0] == LinOpBCType::Neumann ||
1646 bclo[0] == LinOpBCType::inflow)) ||
1647 (i == ndhi.x && ( bchi[0] == LinOpBCType::Neumann ||
1648 bchi[0] == LinOpBCType::inflow))) {
1649 fac *= Real(2.);
1650 }
1651 if ((j == ndlo.y && ( bclo[1] == LinOpBCType::Neumann ||
1652 bclo[1] == LinOpBCType::inflow)) ||
1653 (j == ndhi.y && ( bchi[1] == LinOpBCType::Neumann ||
1654 bchi[1] == LinOpBCType::inflow))) {
1655 fac *= Real(2.);
1656 }
1657 if ((k == ndlo.z && ( bclo[2] == LinOpBCType::Neumann ||
1658 bclo[2] == LinOpBCType::inflow)) ||
1659 (k == ndhi.z && ( bchi[2] == LinOpBCType::Neumann ||
1660 bchi[2] == LinOpBCType::inflow))) {
1661 fac *= Real(2.);
1662 }
1663 }
1664 resid(i,j,k) = (rhs(i,j,k) - resid(i,j,k)) * fac;
1665 } else {
1666 resid(i,j,k) = Real(0.);
1667 }
1668}
1669
1670//
1671// sync residual
1672//
1673
1674 template <typename P, typename S>
1676 Real mlndlap_sum_Ax (P const& pred, S const& sig,
1677 int i, int j, int k, Real facx, Real facy, Real facz,
1678 Array4<Real const> const& phi) noexcept
1679 {
1680 Real Ax = Real(0.0);
1681 if (pred(i-1,j-1,k-1)) {
1682 Ax += sig(i-1,j-1,k-1)*(facx*(Real(4.)*(phi(i-1,j ,k )-phi(i ,j ,k ))
1683 +Real(2.)*(phi(i-1,j-1,k )-phi(i ,j-1,k ))
1684 +Real(2.)*(phi(i-1,j ,k-1)-phi(i ,j ,k-1))
1685 + (phi(i-1,j-1,k-1)-phi(i ,j-1,k-1)))
1686 + facy*(Real(4.)*(phi(i ,j-1,k )-phi(i ,j ,k ))
1687 +Real(2.)*(phi(i-1,j-1,k )-phi(i-1,j ,k ))
1688 +Real(2.)*(phi(i ,j-1,k-1)-phi(i ,j ,k-1))
1689 + (phi(i-1,j-1,k-1)-phi(i-1,j ,k-1)))
1690 + facz*(Real(4.)*(phi(i ,j ,k-1)-phi(i ,j ,k ))
1691 +Real(2.)*(phi(i-1,j ,k-1)-phi(i-1,j ,k ))
1692 +Real(2.)*(phi(i ,j-1,k-1)-phi(i ,j-1,k ))
1693 + (phi(i-1,j-1,k-1)-phi(i-1,j-1,k ))));
1694 }
1695 if (pred(i,j-1,k-1)) {
1696 Ax += sig(i,j-1,k-1)*(facx*(Real(4.)*(phi(i+1,j ,k )-phi(i ,j ,k ))
1697 +Real(2.)*(phi(i+1,j-1,k )-phi(i ,j-1,k ))
1698 +Real(2.)*(phi(i+1,j ,k-1)-phi(i ,j ,k-1))
1699 + (phi(i+1,j-1,k-1)-phi(i ,j-1,k-1)))
1700 + facy*(Real(4.)*(phi(i ,j-1,k )-phi(i ,j ,k ))
1701 +Real(2.)*(phi(i+1,j-1,k )-phi(i+1,j ,k ))
1702 +Real(2.)*(phi(i ,j-1,k-1)-phi(i ,j ,k-1))
1703 + (phi(i+1,j-1,k-1)-phi(i+1,j ,k-1)))
1704 + facz*(Real(4.)*(phi(i ,j ,k-1)-phi(i ,j ,k ))
1705 +Real(2.)*(phi(i+1,j ,k-1)-phi(i+1,j ,k ))
1706 +Real(2.)*(phi(i ,j-1,k-1)-phi(i ,j-1,k ))
1707 + (phi(i+1,j-1,k-1)-phi(i+1,j-1,k ))));
1708 }
1709 if (pred(i-1,j,k-1)) {
1710 Ax += sig(i-1,j,k-1)*(facx*(Real(4.)*(phi(i-1,j ,k )-phi(i ,j ,k ))
1711 +Real(2.)*(phi(i-1,j+1,k )-phi(i ,j+1,k ))
1712 +Real(2.)*(phi(i-1,j ,k-1)-phi(i ,j ,k-1))
1713 + (phi(i-1,j+1,k-1)-phi(i ,j+1,k-1)))
1714 + facy*(Real(4.)*(phi(i ,j+1,k )-phi(i ,j ,k ))
1715 +Real(2.)*(phi(i-1,j+1,k )-phi(i-1,j ,k ))
1716 +Real(2.)*(phi(i ,j+1,k-1)-phi(i ,j ,k-1))
1717 + (phi(i-1,j+1,k-1)-phi(i-1,j ,k-1)))
1718 + facz*(Real(4.)*(phi(i ,j ,k-1)-phi(i ,j ,k ))
1719 +Real(2.)*(phi(i-1,j ,k-1)-phi(i-1,j ,k ))
1720 +Real(2.)*(phi(i ,j+1,k-1)-phi(i ,j+1,k ))
1721 + (phi(i-1,j+1,k-1)-phi(i-1,j+1,k ))));
1722 }
1723 if (pred(i,j,k-1)) {
1724 Ax += sig(i,j,k-1)*(facx*(Real(4.)*(phi(i+1,j ,k )-phi(i ,j ,k ))
1725 +Real(2.)*(phi(i+1,j+1,k )-phi(i ,j+1,k ))
1726 +Real(2.)*(phi(i+1,j ,k-1)-phi(i ,j ,k-1))
1727 + (phi(i+1,j+1,k-1)-phi(i ,j+1,k-1)))
1728 + facy*(Real(4.)*(phi(i ,j+1,k )-phi(i ,j ,k ))
1729 +Real(2.)*(phi(i+1,j+1,k )-phi(i+1,j ,k ))
1730 +Real(2.)*(phi(i ,j+1,k-1)-phi(i ,j ,k-1))
1731 + (phi(i+1,j+1,k-1)-phi(i+1,j ,k-1)))
1732 + facz*(Real(4.)*(phi(i ,j ,k-1)-phi(i ,j ,k ))
1733 +Real(2.)*(phi(i+1,j ,k-1)-phi(i+1,j ,k ))
1734 +Real(2.)*(phi(i ,j+1,k-1)-phi(i ,j+1,k ))
1735 + (phi(i+1,j+1,k-1)-phi(i+1,j+1,k ))));
1736 }
1737 if (pred(i-1,j-1,k)) {
1738 Ax += sig(i-1,j-1,k)*(facx*(Real(4.)*(phi(i-1,j ,k )-phi(i ,j ,k ))
1739 +Real(2.)*(phi(i-1,j-1,k )-phi(i ,j-1,k ))
1740 +Real(2.)*(phi(i-1,j ,k+1)-phi(i ,j ,k+1))
1741 + (phi(i-1,j-1,k+1)-phi(i ,j-1,k+1)))
1742 + facy*(Real(4.)*(phi(i ,j-1,k )-phi(i ,j ,k ))
1743 +Real(2.)*(phi(i-1,j-1,k )-phi(i-1,j ,k ))
1744 +Real(2.)*(phi(i ,j-1,k+1)-phi(i ,j ,k+1))
1745 + (phi(i-1,j-1,k+1)-phi(i-1,j ,k+1)))
1746 + facz*(Real(4.)*(phi(i ,j ,k+1)-phi(i ,j ,k ))
1747 +Real(2.)*(phi(i-1,j ,k+1)-phi(i-1,j ,k ))
1748 +Real(2.)*(phi(i ,j-1,k+1)-phi(i ,j-1,k ))
1749 + (phi(i-1,j-1,k+1)-phi(i-1,j-1,k ))));
1750 }
1751 if (pred(i,j-1,k)) {
1752 Ax += sig(i,j-1,k)*(facx*(Real(4.)*(phi(i+1,j ,k )-phi(i ,j ,k ))
1753 +Real(2.)*(phi(i+1,j-1,k )-phi(i ,j-1,k ))
1754 +Real(2.)*(phi(i+1,j ,k+1)-phi(i ,j ,k+1))
1755 + (phi(i+1,j-1,k+1)-phi(i ,j-1,k+1)))
1756 + facy*(Real(4.)*(phi(i ,j-1,k )-phi(i ,j ,k ))
1757 +Real(2.)*(phi(i+1,j-1,k )-phi(i+1,j ,k ))
1758 +Real(2.)*(phi(i ,j-1,k+1)-phi(i ,j ,k+1))
1759 + (phi(i+1,j-1,k+1)-phi(i+1,j ,k+1)))
1760 + facz*(Real(4.)*(phi(i ,j ,k+1)-phi(i ,j ,k ))
1761 +Real(2.)*(phi(i+1,j ,k+1)-phi(i+1,j ,k ))
1762 +Real(2.)*(phi(i ,j-1,k+1)-phi(i ,j-1,k ))
1763 + (phi(i+1,j-1,k+1)-phi(i+1,j-1,k ))));
1764 }
1765 if (pred(i-1,j,k)) {
1766 Ax += sig(i-1,j,k)*(facx*(Real(4.)*(phi(i-1,j ,k )-phi(i ,j ,k ))
1767 +Real(2.)*(phi(i-1,j+1,k )-phi(i ,j+1,k ))
1768 +Real(2.)*(phi(i-1,j ,k+1)-phi(i ,j ,k+1))
1769 + (phi(i-1,j+1,k+1)-phi(i ,j+1,k+1)))
1770 + facy*(Real(4.)*(phi(i ,j+1,k )-phi(i ,j ,k ))
1771 +Real(2.)*(phi(i-1,j+1,k )-phi(i-1,j ,k ))
1772 +Real(2.)*(phi(i ,j+1,k+1)-phi(i ,j ,k+1))
1773 + (phi(i-1,j+1,k+1)-phi(i-1,j ,k+1)))
1774 + facz*(Real(4.)*(phi(i ,j ,k+1)-phi(i ,j ,k ))
1775 +Real(2.)*(phi(i-1,j ,k+1)-phi(i-1,j ,k ))
1776 +Real(2.)*(phi(i ,j+1,k+1)-phi(i ,j+1,k ))
1777 + (phi(i-1,j+1,k+1)-phi(i-1,j+1,k ))));
1778 }
1779 if (pred(i,j,k)) {
1780 Ax += sig(i,j,k)*(facx*(Real(4.)*(phi(i+1,j ,k )-phi(i ,j ,k ))
1781 +Real(2.)*(phi(i+1,j+1,k )-phi(i ,j+1,k ))
1782 +Real(2.)*(phi(i+1,j ,k+1)-phi(i ,j ,k+1))
1783 + (phi(i+1,j+1,k+1)-phi(i ,j+1,k+1)))
1784 + facy*(Real(4.)*(phi(i ,j+1,k )-phi(i ,j ,k ))
1785 +Real(2.)*(phi(i+1,j+1,k )-phi(i+1,j ,k ))
1786 +Real(2.)*(phi(i ,j+1,k+1)-phi(i ,j ,k+1))
1787 + (phi(i+1,j+1,k+1)-phi(i+1,j ,k+1)))
1788 + facz*(Real(4.)*(phi(i ,j ,k+1)-phi(i ,j ,k ))
1789 +Real(2.)*(phi(i+1,j ,k+1)-phi(i+1,j ,k ))
1790 +Real(2.)*(phi(i ,j+1,k+1)-phi(i ,j+1,k ))
1791 + (phi(i+1,j+1,k+1)-phi(i+1,j+1,k ))));
1792 }
1793 return Ax;
1794 }
1795
1796 template <int rr, typename S>
1799 int i, int j, int k, Box const& ndbx, Box const& ccbx,
1800 Array4<Real> const& f, Array4<Real const> const& res,
1801 Array4<Real const> const& rhs,
1802 Array4<Real const> const& phi,
1803 Array4<int const> const& msk,
1804 GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
1805 {
1806 const int ii = rr*i;
1807 const int jj = rr*j;
1808 const int kk = rr*k;
1809 if (msk(ii,jj,kk)) {
1810 Real facx = Real(1./36.)*dxinv[0]*dxinv[0];
1811 Real facy = Real(1./36.)*dxinv[1]*dxinv[1];
1812 Real facz = Real(1./36.)*dxinv[2]*dxinv[2];
1813
1814 auto is_fine = [&ccbx] (int ix, int iy, int iz) -> bool {
1815 return ccbx.contains(ix,iy,iz);
1816 };
1817
1818 Real Df = Real(0.0);
1819
1820 const int ilo = amrex::max(ii-rr+1, ndbx.smallEnd(0));
1821 const int ihi = amrex::min(ii+rr-1, ndbx.bigEnd (0));
1822 const int jlo = amrex::max(jj-rr+1, ndbx.smallEnd(1));
1823 const int jhi = amrex::min(jj+rr-1, ndbx.bigEnd (1));
1824 const int klo = amrex::max(kk-rr+1, ndbx.smallEnd(2));
1825 const int khi = amrex::min(kk+rr-1, ndbx.bigEnd (2));
1826
1827 for (int koff = klo; koff <= khi; ++koff) {
1828 for (int joff = jlo; joff <= jhi; ++joff) {
1829 for (int ioff = ilo; ioff <= ihi; ++ioff) {
1830 Real scale = static_cast<Real>((rr-std::abs(ii-ioff)) *
1831 (rr-std::abs(jj-joff)) *
1832 (rr-std::abs(kk-koff)));
1833 if (ndbx.strictly_contains(ioff,joff,koff)) {
1834 Df += scale * (rhs(ioff,joff,koff)-res(ioff,joff,koff));
1835 } else {
1836 Df += scale * mlndlap_sum_Ax
1837 (is_fine, sig, ioff, joff, koff, facx, facy, facz, phi);
1838 }
1839 }}}
1840
1841 f(i,j,k) = Df * (Real(1.0)/static_cast<Real>(rr*rr*rr*rr*rr*rr));
1842 } else {
1843 f(i,j,k) = Real(0.0);
1844 }
1845 }
1846
1847template <int rr>
1849void mlndlap_Ax_fine_contrib (int i, int j, int k, Box const& ndbx, Box const& ccbx,
1850 Array4<Real> const& f, Array4<Real const> const& res,
1851 Array4<Real const> const& rhs, Array4<Real const> const& phi,
1852 Array4<Real const> const& sig, Array4<int const> const& msk,
1853 GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
1854{
1855 mlndlap_Ax_fine_contrib_doit<rr>
1856 ([&sig] (int ix, int iy, int iz) -> Real const& { return sig(ix,iy,iz); },
1857 i,j,k,ndbx,ccbx,f,res,rhs,phi,msk,dxinv);
1858}
1859
1860template <int rr>
1862void mlndlap_Ax_fine_contrib_cs (int i, int j, int k, Box const& ndbx, Box const& ccbx,
1863 Array4<Real> const& f, Array4<Real const> const& res,
1864 Array4<Real const> const& rhs, Array4<Real const> const& phi,
1865 Real const sig, Array4<int const> const& msk,
1866 GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
1867{
1868 mlndlap_Ax_fine_contrib_doit<rr>
1869 ([=] (int, int, int) -> Real { return sig; },
1870 i,j,k,ndbx,ccbx,f,res,rhs,phi,msk,dxinv);
1871}
1872
1874void mlndlap_res_cf_contrib (int i, int j, int k, Array4<Real> const& res,
1875 Array4<Real const> const& phi, Array4<Real const> const& rhs,
1876 Array4<Real const> const& sig, Array4<int const> const& dmsk,
1877 Array4<int const> const& ndmsk, Array4<int const> const& ccmsk,
1878 Array4<Real const> const& fc,
1879 GpuArray<Real,AMREX_SPACEDIM> const& dxinv,
1880 Box const& ccdom_p, Box const& nddom,
1883 bool neumann_doubling) noexcept
1884{
1885 using namespace nodelap_detail;
1886
1887 if (!dmsk(i,j,k) && ndmsk(i,j,k) == crse_fine_node) {
1888 Real facx = Real(1./36.)*dxinv[0]*dxinv[0];
1889 Real facy = Real(1./36.)*dxinv[1]*dxinv[1];
1890 Real facz = Real(1./36.)*dxinv[2]*dxinv[2];
1891
1892 Real Ax = mlndlap_sum_Ax([&ccmsk, &ccdom_p] (int ix, int iy, int iz) -> bool
1893 {
1894 return ccdom_p.contains(ix,iy,iz)
1895 && (ccmsk(ix,iy,iz) == crse_cell);
1896 },
1897 [&sig] (int ix, int iy, int iz) -> Real const&
1898 {
1899 return sig(ix,iy,iz);
1900 },
1901 i, j, k, facx, facy, facz, phi);
1902 Ax += fc(i,j,k);
1903 Real const ns = (neumann_doubling) ? neumann_scale(i,j,k,nddom,bclo,bchi) : Real(1.0);
1904 res(i,j,k) = rhs(i,j,k) - Ax*ns;
1905 }
1906}
1907
1909void mlndlap_res_cf_contrib_cs (int i, int j, int k, Array4<Real> const& res,
1910 Array4<Real const> const& phi, Array4<Real const> const& rhs,
1911 Real const sig, Array4<int const> const& dmsk,
1912 Array4<int const> const& ndmsk, Array4<int const> const& ccmsk,
1913 Array4<Real const> const& fc,
1914 GpuArray<Real,AMREX_SPACEDIM> const& dxinv,
1915 Box const& ccdom_p, Box const& nddom,
1918 bool neumann_doubling) noexcept
1919{
1920 using namespace nodelap_detail;
1921
1922 if (!dmsk(i,j,k) && ndmsk(i,j,k) == crse_fine_node) {
1923 Real facx = Real(1./36.)*dxinv[0]*dxinv[0];
1924 Real facy = Real(1./36.)*dxinv[1]*dxinv[1];
1925 Real facz = Real(1./36.)*dxinv[2]*dxinv[2];
1926
1927 Real Ax = mlndlap_sum_Ax([&ccmsk, &ccdom_p] (int ix, int iy, int iz) -> bool
1928 {
1929 return ccdom_p.contains(ix,iy,iz)
1930 && (ccmsk(ix,iy,iz) == crse_cell);
1931 },
1932 [=] (int, int, int) -> Real
1933 {
1934 return sig;
1935 },
1936 i, j, k, facx, facy, facz, phi);
1937 Ax += fc(i,j,k);
1938 Real const ns = (neumann_doubling) ? neumann_scale(i,j,k,nddom,bclo,bchi) : Real(1.0);
1939 res(i,j,k) = rhs(i,j,k) - Ax*ns;
1940 }
1941}
1942
1943//
1944// RAP
1945//
1946
1948namespace nodelap_detail {
1949
1950 constexpr int ist_000 = 0;
1951 constexpr int ist_p00 = 1;
1952 constexpr int ist_0p0 = 2;
1953 constexpr int ist_00p = 3;
1954 constexpr int ist_pp0 = 4;
1955 constexpr int ist_p0p = 5;
1956 constexpr int ist_0pp = 6;
1957 constexpr int ist_ppp = 7;
1958 constexpr int ist_inv = 8;
1959 constexpr int n_sten = 9;
1960}
1962
1964void mlndlap_set_stencil (Box const& bx, Array4<Real> const& sten,
1965 Array4<Real const> const& sig,
1966 GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
1967{
1968 using namespace nodelap_detail;
1969
1970 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
1971 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
1972 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
1973 Real fxyz = facx + facy + facz;
1974 Real fmx2y2z = -facx + Real(2.0)*facy + Real(2.0)*facz;
1975 Real f2xmy2z = Real(2.0)*facx - facy + Real(2.0)*facz;
1976 Real f2x2ymz = Real(2.0)*facx + Real(2.0)*facy - facz;
1977 Real f4xm2ym2z = Real(4.0)*facx - Real(2.0)*facy - Real(2.0)*facz;
1978 Real fm2x4ym2z = -Real(2.0)*facx + Real(4.0)*facy - Real(2.0)*facz;
1979 Real fm2xm2y4z = -Real(2.0)*facx - Real(2.0)*facy + Real(4.0)*facz;
1980
1981 amrex::LoopConcurrent(bx, [=] (int i, int j, int k) noexcept
1982 {
1983 // i+1,j,k
1984 sten(i,j,k,ist_p00) = f4xm2ym2z * (sig(i,j-1,k-1)+sig(i,j,k-1)+sig(i,j-1,k)+sig(i,j,k));
1985 // i-1,j,k: sten(i-1,j,k,ist_p00)
1986
1987 // i,j+1,k
1988 sten(i,j,k,ist_0p0) = fm2x4ym2z * (sig(i-1,j,k-1)+sig(i,j,k-1)+sig(i-1,j,k)+sig(i,j,k));
1989 // i,j-1,k: sten(i,j-1,k,ist_0p0)
1990
1991 // i,j,k+1
1992 sten(i,j,k,ist_00p) = fm2xm2y4z * (sig(i-1,j-1,k)+sig(i,j-1,k)+sig(i-1,j,k)+sig(i,j,k));
1993 // i,j,k-1: sten(i,j,k-1,ist_00p)
1994
1995 // i+1,j+1,k
1996 sten(i,j,k,ist_pp0) = f2x2ymz * (sig(i,j,k-1)+sig(i,j,k));
1997 // i-1,j-1,k: sten(i-1,j-1,k,ist_pp0)
1998 // i+1,j-1,k: sten(i ,j-1,k,ist_pp0)
1999 // i-1,j+1,k: sten(i-1,j ,k,ist_pp0)
2000
2001 // i+1,j,k+1
2002 sten(i,j,k,ist_p0p) = f2xmy2z * (sig(i,j-1,k)+sig(i,j,k));
2003 // i-1,j,k-1: sten(i-1,j,k-1,ist_p0p)
2004 // i+1,j,k-1: sten(i ,j,k-1,ist_p0p)
2005 // i-1,j,k+1: sten(i-1,j,k ,ist_p0p)
2006
2007 // i,j+1,k+1
2008 sten(i,j,k,ist_0pp) = fmx2y2z * (sig(i-1,j,k)+sig(i,j,k));
2009 // i,j-1,k-1: sten(i,j-1,k-1,ist_0pp)
2010 // i,j+1,k-1: sten(i,j ,k-1,ist_0pp)
2011 // i,j-1,k+1: sten(i,j-1,k ,ist_0pp)
2012
2013 // i+1,j+1,k+1
2014 sten(i,j,k,ist_ppp) = fxyz * sig(i,j,k);
2015 // i-1,j-1,k-1: sten(i-1,j-1,k-1,ist_ppp)
2016 // i+1,j-1,k-1: sten(i ,j-1,k-1,ist_ppp)
2017 // i-1,j+1,k-1: sten(i-1,j ,k-1,ist_ppp)
2018 // i+1,j+1,k-1: sten(i ,j ,k-1,ist_ppp)
2019 // i-1,j-1,k+1: sten(i-1,j-1,k ,ist_ppp)
2020 // i+1,j-1,k+1: sten(i ,j-1,k ,ist_ppp)
2021 // i-1,j+1,k+1: sten(i-1,j ,k ,ist_ppp)
2022 });
2023}
2024
2026void mlndlap_set_stencil_s0 (int i, int j, int k, Array4<Real> const& sten) noexcept
2027{
2028 using namespace nodelap_detail;
2029
2030 sten(i,j,k,ist_000) = -(sten(i-1,j,k,ist_p00) + sten(i,j,k,ist_p00)
2031 + sten(i,j-1,k,ist_0p0) + sten(i,j,k,ist_0p0)
2032 + sten(i,j,k-1,ist_00p) + sten(i,j,k,ist_00p)
2033 + sten(i-1,j-1,k,ist_pp0) + sten(i,j-1,k,ist_pp0)
2034 + sten(i-1,j,k,ist_pp0) + sten(i,j,k,ist_pp0)
2035 + sten(i-1,j,k-1,ist_p0p) + sten(i,j,k-1,ist_p0p)
2036 + sten(i-1,j,k,ist_p0p) + sten(i,j,k,ist_p0p)
2037 + sten(i,j-1,k-1,ist_0pp) + sten(i,j,k-1,ist_0pp)
2038 + sten(i,j-1,k,ist_0pp) + sten(i,j,k,ist_0pp)
2039 + sten(i-1,j-1,k-1,ist_ppp) + sten(i,j-1,k-1,ist_ppp)
2040 + sten(i-1,j,k-1,ist_ppp) + sten(i,j,k-1,ist_ppp)
2041 + sten(i-1,j-1,k,ist_ppp) + sten(i,j-1,k,ist_ppp)
2042 + sten(i-1,j,k,ist_ppp) + sten(i,j,k,ist_ppp));
2043 sten(i,j,k,ist_inv) = Real(1.0) /
2044 ( std::abs(sten(i-1,j,k,ist_p00)) + std::abs(sten(i,j,k,ist_p00))
2045 + std::abs(sten(i,j-1,k,ist_0p0)) + std::abs(sten(i,j,k,ist_0p0))
2046 + std::abs(sten(i,j,k-1,ist_00p)) + std::abs(sten(i,j,k,ist_00p))
2047 + std::abs(sten(i-1,j-1,k,ist_pp0)) + std::abs(sten(i,j-1,k,ist_pp0))
2048 + std::abs(sten(i-1,j,k,ist_pp0)) + std::abs(sten(i,j,k,ist_pp0))
2049 + std::abs(sten(i-1,j,k-1,ist_p0p)) + std::abs(sten(i,j,k-1,ist_p0p))
2050 + std::abs(sten(i-1,j,k,ist_p0p)) + std::abs(sten(i,j,k,ist_p0p))
2051 + std::abs(sten(i,j-1,k-1,ist_0pp)) + std::abs(sten(i,j,k-1,ist_0pp))
2052 + std::abs(sten(i,j-1,k,ist_0pp)) + std::abs(sten(i,j,k,ist_0pp))
2053 + std::abs(sten(i-1,j-1,k-1,ist_ppp)) + std::abs(sten(i,j-1,k-1,ist_ppp))
2054 + std::abs(sten(i-1,j,k-1,ist_ppp)) + std::abs(sten(i,j,k-1,ist_ppp))
2055 + std::abs(sten(i-1,j-1,k,ist_ppp)) + std::abs(sten(i,j-1,k,ist_ppp))
2056 + std::abs(sten(i-1,j,k,ist_ppp)) + std::abs(sten(i,j,k,ist_ppp)) + eps);
2057}
2058
2060void mlndlap_stencil_rap (int i, int j, int k, Array4<Real> const& csten,
2061 Array4<Real const> const& fsten) noexcept
2062{
2063 using namespace nodelap_detail;
2064
2065 auto interp_from_mmm_to = [&fsten] (int i_, int j_, int k_) -> Real {
2066 Real p = Real(1.);
2067 p += std::abs(fsten(i_-1,j_ ,k_ ,ist_p00)) /
2068 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2069 + std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2070 + std::abs(fsten(i_-1,j_-1,k_ ,ist_ppp))
2071 + std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp)) + eps);
2072 p += std::abs(fsten(i_ ,j_-1,k_ ,ist_0p0)) /
2073 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2074 + std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2075 + std::abs(fsten(i_-1,j_-1,k_ ,ist_ppp))
2076 + std::abs(fsten(i_ ,j_-1,k_ ,ist_ppp)) + eps);
2077 p += std::abs(fsten(i_ ,j_ ,k_-1,ist_00p)) /
2078 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2079 + std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2080 + std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2081 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp)) + eps);
2082 p += std::abs(fsten(i_-1,j_-1,k_ ,ist_pp0)) /
2083 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2084 + std::abs(fsten(i_-1,j_-1,k_ ,ist_ppp)) + eps);
2085 p += std::abs(fsten(i_-1,j_ ,k_-1,ist_p0p)) /
2086 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2087 + std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp)) + eps);
2088 p += std::abs(fsten(i_ ,j_-1,k_-1,ist_0pp)) /
2089 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2090 + std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp)) + eps);
2091 p *= std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp)) * fsten(i_,j_,k_,ist_inv);
2092 return p;
2093 };
2094 amrex::ignore_unused(interp_from_mmm_to);
2095
2096 auto interp_from_pmm_to = [&fsten] (int i_, int j_, int k_) -> Real {
2097 Real p = Real(1.);
2098 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_p00)) /
2099 ( std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2100 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp))
2101 + std::abs(fsten(i_ ,j_-1,k_ ,ist_ppp))
2102 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2103 p += std::abs(fsten(i_ ,j_-1,k_ ,ist_0p0)) /
2104 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2105 + std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2106 + std::abs(fsten(i_-1,j_-1,k_ ,ist_ppp))
2107 + std::abs(fsten(i_ ,j_-1,k_ ,ist_ppp)) + eps);
2108 p += std::abs(fsten(i_ ,j_ ,k_-1,ist_00p)) /
2109 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2110 + std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2111 + std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2112 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp)) + eps);
2113 p += std::abs(fsten(i_ ,j_-1,k_ ,ist_pp0)) /
2114 ( std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2115 + std::abs(fsten(i_ ,j_-1,k_ ,ist_ppp)) + eps);
2116 p += std::abs(fsten(i_ ,j_ ,k_-1,ist_p0p)) /
2117 ( std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2118 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp)) + eps);
2119 p += std::abs(fsten(i_ ,j_-1,k_-1,ist_0pp)) /
2120 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2121 + std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp)) + eps);
2122 p *= std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp)) * fsten(i_,j_,k_,ist_inv);
2123 return p;
2124 };
2125
2126 auto interp_from_mpm_to = [&fsten] (int i_, int j_, int k_) -> Real {
2127 Real p = Real(1.);
2128 p += std::abs(fsten(i_-1,j_ ,k_ ,ist_p00)) /
2129 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2130 + std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2131 + std::abs(fsten(i_-1,j_-1,k_ ,ist_ppp))
2132 + std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp)) + eps);
2133 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_0p0)) /
2134 ( std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2135 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp))
2136 + std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp))
2137 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2138 p += std::abs(fsten(i_ ,j_ ,k_-1,ist_00p)) /
2139 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2140 + std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2141 + std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2142 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp)) + eps);
2143 p += std::abs(fsten(i_-1,j_ ,k_ ,ist_pp0)) /
2144 ( std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2145 + std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp)) + eps);
2146 p += std::abs(fsten(i_-1,j_ ,k_-1,ist_p0p)) /
2147 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2148 + std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp)) + eps);
2149 p += std::abs(fsten(i_ ,j_ ,k_-1,ist_0pp)) /
2150 ( std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2151 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp)) + eps);
2152 p *= std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp)) * fsten(i_,j_,k_,ist_inv);
2153 return p;
2154 };
2155
2156 auto interp_from_ppm_to = [&fsten] (int i_, int j_, int k_) -> Real {
2157 Real p = Real(1.);
2158 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_p00)) /
2159 ( std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2160 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp))
2161 + std::abs(fsten(i_ ,j_-1,k_ ,ist_ppp))
2162 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2163 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_0p0)) /
2164 ( std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2165 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp))
2166 + std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp))
2167 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2168 p += std::abs(fsten(i_ ,j_ ,k_-1,ist_00p)) /
2169 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2170 + std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2171 + std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2172 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp)) + eps);
2173 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_pp0)) /
2174 ( std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp))
2175 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2176 p += std::abs(fsten(i_ ,j_ ,k_-1,ist_p0p)) /
2177 ( std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2178 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp)) + eps);
2179 p += std::abs(fsten(i_ ,j_ ,k_-1,ist_0pp)) /
2180 ( std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2181 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp)) + eps);
2182 p *= std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp)) * fsten(i_,j_,k_,ist_inv);
2183 return p;
2184 };
2185
2186 auto interp_from_mmp_to = [&fsten] (int i_, int j_, int k_) -> Real {
2187 Real p = Real(1.);
2188 p += std::abs(fsten(i_-1,j_ ,k_ ,ist_p00)) /
2189 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2190 + std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2191 + std::abs(fsten(i_-1,j_-1,k_ ,ist_ppp))
2192 + std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp)) + eps);
2193 p += std::abs(fsten(i_ ,j_-1,k_ ,ist_0p0)) /
2194 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2195 + std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2196 + std::abs(fsten(i_-1,j_-1,k_ ,ist_ppp))
2197 + std::abs(fsten(i_ ,j_-1,k_ ,ist_ppp)) + eps);
2198 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_00p)) /
2199 ( std::abs(fsten(i_-1,j_-1,k_,ist_ppp))
2200 + std::abs(fsten(i_ ,j_-1,k_,ist_ppp))
2201 + std::abs(fsten(i_-1,j_ ,k_,ist_ppp))
2202 + std::abs(fsten(i_ ,j_ ,k_,ist_ppp)) + eps);
2203 p += std::abs(fsten(i_-1,j_-1,k_,ist_pp0)) /
2204 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2205 + std::abs(fsten(i_-1,j_-1,k_ ,ist_ppp)) + eps);
2206 p += std::abs(fsten(i_-1,j_ ,k_,ist_p0p)) /
2207 ( std::abs(fsten(i_-1,j_-1,k_,ist_ppp))
2208 + std::abs(fsten(i_-1,j_ ,k_,ist_ppp)) + eps);
2209 p += std::abs(fsten(i_ ,j_-1,k_,ist_0pp)) /
2210 ( std::abs(fsten(i_-1,j_-1,k_,ist_ppp))
2211 + std::abs(fsten(i_ ,j_-1,k_,ist_ppp)) + eps);
2212 p *= std::abs(fsten(i_-1,j_-1,k_ ,ist_ppp)) * fsten(i_,j_,k_,ist_inv);
2213 return p;
2214 };
2215
2216 auto interp_from_pmp_to = [&fsten] (int i_, int j_, int k_) -> Real {
2217 Real p = Real(1.);
2218 p += std::abs(fsten(i_ ,j_ ,k_,ist_p00)) /
2219 ( std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2220 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp))
2221 + std::abs(fsten(i_ ,j_-1,k_ ,ist_ppp))
2222 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2223 p += std::abs(fsten(i_ ,j_-1,k_,ist_0p0)) /
2224 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2225 + std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2226 + std::abs(fsten(i_-1,j_-1,k_ ,ist_ppp))
2227 + std::abs(fsten(i_ ,j_-1,k_ ,ist_ppp)) + eps);
2228 p += std::abs(fsten(i_ ,j_ ,k_,ist_00p)) /
2229 ( std::abs(fsten(i_-1,j_-1,k_,ist_ppp))
2230 + std::abs(fsten(i_ ,j_-1,k_,ist_ppp))
2231 + std::abs(fsten(i_-1,j_ ,k_,ist_ppp))
2232 + std::abs(fsten(i_ ,j_ ,k_,ist_ppp)) + eps);
2233 p += std::abs(fsten(i_ ,j_-1,k_,ist_pp0)) /
2234 ( std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2235 + std::abs(fsten(i_ ,j_-1,k_ ,ist_ppp)) + eps);
2236 p += std::abs(fsten(i_ ,j_ ,k_,ist_p0p)) /
2237 ( std::abs(fsten(i_ ,j_-1,k_,ist_ppp))
2238 + std::abs(fsten(i_ ,j_ ,k_,ist_ppp)) + eps);
2239 p += std::abs(fsten(i_ ,j_-1,k_,ist_0pp)) /
2240 ( std::abs(fsten(i_-1,j_-1,k_,ist_ppp))
2241 + std::abs(fsten(i_ ,j_-1,k_,ist_ppp)) + eps);
2242 p *= std::abs(fsten(i_ ,j_-1,k_ ,ist_ppp)) * fsten(i_,j_ ,k_,ist_inv);
2243 return p;
2244 };
2245
2246 auto interp_from_mpp_to = [&fsten] (int i_, int j_, int k_) -> Real {
2247 Real p = Real(1.);
2248 p += std::abs(fsten(i_-1,j_ ,k_ ,ist_p00)) /
2249 ( std::abs(fsten(i_-1,j_-1,k_-1,ist_ppp))
2250 + std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2251 + std::abs(fsten(i_-1,j_-1,k_ ,ist_ppp))
2252 + std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp)) + eps);
2253 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_0p0)) /
2254 ( std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2255 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp))
2256 + std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp))
2257 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2258 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_00p)) /
2259 ( std::abs(fsten(i_-1,j_-1,k_ ,ist_ppp))
2260 + std::abs(fsten(i_ ,j_-1,k_ ,ist_ppp))
2261 + std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp))
2262 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2263 p += std::abs(fsten(i_-1,j_ ,k_ ,ist_pp0)) /
2264 ( std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2265 + std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp)) + eps);
2266 p += std::abs(fsten(i_-1,j_ ,k_ ,ist_p0p)) /
2267 ( std::abs(fsten(i_-1,j_-1,k_ ,ist_ppp))
2268 + std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp)) + eps);
2269 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_0pp)) /
2270 ( std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp))
2271 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2272 p *= std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp)) * fsten(i_,j_,k_,ist_inv);
2273 return p;
2274 };
2275
2276 auto interp_from_ppp_to = [&fsten] (int i_, int j_, int k_) -> Real {
2277 Real p = Real(1.);
2278 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_p00)) /
2279 ( std::abs(fsten(i_ ,j_-1,k_-1,ist_ppp))
2280 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp))
2281 + std::abs(fsten(i_ ,j_-1,k_ ,ist_ppp))
2282 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2283 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_0p0)) /
2284 ( std::abs(fsten(i_-1,j_ ,k_-1,ist_ppp))
2285 + std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp))
2286 + std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp))
2287 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2288 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_00p)) /
2289 ( std::abs(fsten(i_-1,j_-1,k_ ,ist_ppp))
2290 + std::abs(fsten(i_ ,j_-1,k_ ,ist_ppp))
2291 + std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp))
2292 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2293 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_pp0)) /
2294 ( std::abs(fsten(i_ ,j_ ,k_-1,ist_ppp))
2295 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2296 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_p0p)) /
2297 ( std::abs(fsten(i_ ,j_-1,k_ ,ist_ppp))
2298 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2299 p += std::abs(fsten(i_ ,j_ ,k_ ,ist_0pp)) /
2300 ( std::abs(fsten(i_-1,j_ ,k_ ,ist_ppp))
2301 + std::abs(fsten(i_ ,j_ ,k_ ,ist_ppp)) + eps);
2302 p *= std::abs(fsten(i_ ,j_ ,k_,ist_ppp)) * fsten(i_,j_,k_,ist_inv);
2303 return p;
2304 };
2305
2306 auto interp_from_0mm_to = [&fsten] (int i_, int j_, int k_) -> Real {
2307 Real w1m = std::abs(fsten(i_ ,j_-1,k_ ,ist_0p0)) / (std::abs(fsten(i_ ,j_-1,k_-1,ist_0pp))
2308 +std::abs(fsten(i_ ,j_-1,k_ ,ist_0pp)) + eps);
2309 Real w1p = std::abs(fsten(i_ ,j_ ,k_ ,ist_0p0)) / (std::abs(fsten(i_ ,j_ ,k_-1,ist_0pp))
2310 +std::abs(fsten(i_ ,j_ ,k_ ,ist_0pp)) + eps);
2311 Real w2m = std::abs(fsten(i_ ,j_ ,k_-1,ist_00p)) / (std::abs(fsten(i_ ,j_-1,k_-1,ist_0pp))
2312 +std::abs(fsten(i_ ,j_ ,k_-1,ist_0pp)) + eps);
2313 Real w2p = std::abs(fsten(i_ ,j_ ,k_ ,ist_00p)) / (std::abs(fsten(i_ ,j_-1,k_ ,ist_0pp))
2314 +std::abs(fsten(i_ ,j_ ,k_ ,ist_0pp)) + eps);
2315 Real wmm = std::abs(fsten(i_ ,j_-1,k_-1,ist_0pp)) * (Real(1.) + w1m + w2m);
2316 Real wpm = std::abs(fsten(i_ ,j_ ,k_-1,ist_0pp)) * (Real(1.) + w1p + w2m);
2317 Real wmp = std::abs(fsten(i_ ,j_-1,k_ ,ist_0pp)) * (Real(1.) + w1m + w2p);
2318 Real wpp = std::abs(fsten(i_ ,j_ ,k_ ,ist_0pp)) * (Real(1.) + w1p + w2p);
2319 return wmm / (wmm+wpm+wmp+wpp+eps);
2320 };
2321
2322 auto interp_from_0mp_to = [&fsten] (int i_, int j_, int k_) -> Real {
2323 Real w1m = std::abs(fsten(i_ ,j_-1,k_ ,ist_0p0)) / (std::abs(fsten(i_ ,j_-1,k_-1,ist_0pp))
2324 +std::abs(fsten(i_ ,j_-1,k_ ,ist_0pp)) + eps);
2325 Real w1p = std::abs(fsten(i_ ,j_ ,k_ ,ist_0p0)) / (std::abs(fsten(i_ ,j_ ,k_-1,ist_0pp))
2326 +std::abs(fsten(i_ ,j_ ,k_ ,ist_0pp)) + eps);
2327 Real w2m = std::abs(fsten(i_ ,j_ ,k_-1,ist_00p)) / (std::abs(fsten(i_ ,j_-1,k_-1,ist_0pp))
2328 +std::abs(fsten(i_ ,j_ ,k_-1,ist_0pp)) + eps);
2329 Real w2p = std::abs(fsten(i_ ,j_ ,k_ ,ist_00p)) / (std::abs(fsten(i_ ,j_-1,k_ ,ist_0pp))
2330 +std::abs(fsten(i_ ,j_ ,k_ ,ist_0pp)) + eps);
2331 Real wmm = std::abs(fsten(i_ ,j_-1,k_-1,ist_0pp)) * (Real(1.) + w1m + w2m);
2332 Real wpm = std::abs(fsten(i_ ,j_ ,k_-1,ist_0pp)) * (Real(1.) + w1p + w2m);
2333 Real wmp = std::abs(fsten(i_ ,j_-1,k_ ,ist_0pp)) * (Real(1.) + w1m + w2p);
2334 Real wpp = std::abs(fsten(i_ ,j_ ,k_ ,ist_0pp)) * (Real(1.) + w1p + w2p);
2335 return wmp / (wmm+wpm+wmp+wpp+eps);
2336 };
2337
2338 auto interp_from_0pm_to = [&fsten] (int i_, int j_, int k_) -> Real {
2339 Real w1m = std::abs(fsten(i_ ,j_-1,k_ ,ist_0p0)) / (std::abs(fsten(i_ ,j_-1,k_-1,ist_0pp))
2340 +std::abs(fsten(i_ ,j_-1,k_ ,ist_0pp)) + eps);
2341 Real w1p = std::abs(fsten(i_ ,j_ ,k_ ,ist_0p0)) / (std::abs(fsten(i_ ,j_ ,k_-1,ist_0pp))
2342 +std::abs(fsten(i_ ,j_ ,k_ ,ist_0pp)) + eps);
2343 Real w2m = std::abs(fsten(i_ ,j_ ,k_-1,ist_00p)) / (std::abs(fsten(i_ ,j_-1,k_-1,ist_0pp))
2344 +std::abs(fsten(i_ ,j_ ,k_-1,ist_0pp)) + eps);
2345 Real w2p = std::abs(fsten(i_ ,j_ ,k_ ,ist_00p)) / (std::abs(fsten(i_ ,j_-1,k_ ,ist_0pp))
2346 +std::abs(fsten(i_ ,j_ ,k_ ,ist_0pp)) + eps);
2347 Real wmm = std::abs(fsten(i_ ,j_-1,k_-1,ist_0pp)) * (Real(1.) + w1m + w2m);
2348 Real wpm = std::abs(fsten(i_ ,j_ ,k_-1,ist_0pp)) * (Real(1.) + w1p + w2m);
2349 Real wmp = std::abs(fsten(i_ ,j_-1,k_ ,ist_0pp)) * (Real(1.) + w1m + w2p);
2350 Real wpp = std::abs(fsten(i_ ,j_ ,k_ ,ist_0pp)) * (Real(1.) + w1p + w2p);
2351 return wpm / (wmm+wpm+wmp+wpp+eps);
2352 };
2353
2354 auto interp_from_0pp_to = [&fsten] (int i_, int j_, int k_) -> Real {
2355 Real w1m = std::abs(fsten(i_ ,j_-1,k_ ,ist_0p0)) / (std::abs(fsten(i_ ,j_-1,k_-1,ist_0pp))
2356 +std::abs(fsten(i_ ,j_-1,k_ ,ist_0pp)) + eps);
2357 Real w1p = std::abs(fsten(i_ ,j_ ,k_ ,ist_0p0)) / (std::abs(fsten(i_ ,j_ ,k_-1,ist_0pp))
2358 +std::abs(fsten(i_ ,j_ ,k_ ,ist_0pp)) + eps);
2359 Real w2m = std::abs(fsten(i_ ,j_ ,k_-1,ist_00p)) / (std::abs(fsten(i_ ,j_-1,k_-1,ist_0pp))
2360 +std::abs(fsten(i_ ,j_ ,k_-1,ist_0pp)) + eps);
2361 Real w2p = std::abs(fsten(i_ ,j_ ,k_ ,ist_00p)) / (std::abs(fsten(i_ ,j_-1,k_ ,ist_0pp))
2362 +std::abs(fsten(i_ ,j_ ,k_ ,ist_0pp)) + eps);
2363 Real wmm = std::abs(fsten(i_ ,j_-1,k_-1,ist_0pp)) * (Real(1.) + w1m + w2m);
2364 Real wpm = std::abs(fsten(i_ ,j_ ,k_-1,ist_0pp)) * (Real(1.) + w1p + w2m);
2365 Real wmp = std::abs(fsten(i_ ,j_-1,k_ ,ist_0pp)) * (Real(1.) + w1m + w2p);
2366 Real wpp = std::abs(fsten(i_ ,j_ ,k_ ,ist_0pp)) * (Real(1.) + w1p + w2p);
2367 return wpp / (wmm+wpm+wmp+wpp+eps);
2368 };
2369
2370 auto interp_from_m0m_to = [&fsten] (int i_, int j_, int k_) -> Real {
2371 Real w1m = std::abs(fsten(i_-1,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_-1,j_ ,k_-1,ist_p0p))
2372 +std::abs(fsten(i_-1,j_ ,k_ ,ist_p0p)) + eps);
2373 Real w1p = std::abs(fsten(i_ ,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_ ,j_ ,k_-1,ist_p0p))
2374 +std::abs(fsten(i_ ,j_ ,k_ ,ist_p0p)) + eps);
2375 Real w2m = std::abs(fsten(i_ ,j_ ,k_-1,ist_00p)) / (std::abs(fsten(i_-1,j_ ,k_-1,ist_p0p))
2376 +std::abs(fsten(i_ ,j_ ,k_-1,ist_p0p)) + eps);
2377 Real w2p = std::abs(fsten(i_ ,j_ ,k_ ,ist_00p)) / (std::abs(fsten(i_-1,j_ ,k_ ,ist_p0p))
2378 +std::abs(fsten(i_ ,j_ ,k_ ,ist_p0p)) + eps);
2379 Real wmm = std::abs(fsten(i_-1,j_ ,k_-1,ist_p0p)) * (Real(1.) + w1m + w2m);
2380 Real wpm = std::abs(fsten(i_ ,j_ ,k_-1,ist_p0p)) * (Real(1.) + w1p + w2m);
2381 Real wmp = std::abs(fsten(i_-1,j_ ,k_ ,ist_p0p)) * (Real(1.) + w1m + w2p);
2382 Real wpp = std::abs(fsten(i_ ,j_ ,k_ ,ist_p0p)) * (Real(1.) + w1p + w2p);
2383 return wmm / (wmm+wpm+wmp+wpp+eps);
2384 };
2385
2386 auto interp_from_p0m_to = [&fsten] (int i_, int j_, int k_) -> Real {
2387 Real w1m = std::abs(fsten(i_-1,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_-1,j_ ,k_-1,ist_p0p))
2388 +std::abs(fsten(i_-1,j_ ,k_ ,ist_p0p)) + eps);
2389 Real w1p = std::abs(fsten(i_ ,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_ ,j_ ,k_-1,ist_p0p))
2390 +std::abs(fsten(i_ ,j_ ,k_ ,ist_p0p)) + eps);
2391 Real w2m = std::abs(fsten(i_ ,j_ ,k_-1,ist_00p)) / (std::abs(fsten(i_-1,j_ ,k_-1,ist_p0p))
2392 +std::abs(fsten(i_ ,j_ ,k_-1,ist_p0p)) + eps);
2393 Real w2p = std::abs(fsten(i_ ,j_ ,k_ ,ist_00p)) / (std::abs(fsten(i_-1,j_ ,k_ ,ist_p0p))
2394 +std::abs(fsten(i_ ,j_ ,k_ ,ist_p0p)) + eps);
2395 Real wmm = std::abs(fsten(i_-1,j_ ,k_-1,ist_p0p)) * (Real(1.) + w1m + w2m);
2396 Real wpm = std::abs(fsten(i_ ,j_ ,k_-1,ist_p0p)) * (Real(1.) + w1p + w2m);
2397 Real wmp = std::abs(fsten(i_-1,j_ ,k_ ,ist_p0p)) * (Real(1.) + w1m + w2p);
2398 Real wpp = std::abs(fsten(i_ ,j_ ,k_ ,ist_p0p)) * (Real(1.) + w1p + w2p);
2399 return wpm / (wmm+wpm+wmp+wpp+eps);
2400 };
2401
2402 auto interp_from_m0p_to = [&fsten] (int i_, int j_, int k_) -> Real {
2403 Real w1m = std::abs(fsten(i_-1,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_-1,j_ ,k_-1,ist_p0p))
2404 +std::abs(fsten(i_-1,j_ ,k_ ,ist_p0p)) + eps);
2405 Real w1p = std::abs(fsten(i_ ,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_ ,j_ ,k_-1,ist_p0p))
2406 +std::abs(fsten(i_ ,j_ ,k_ ,ist_p0p)) + eps);
2407 Real w2m = std::abs(fsten(i_ ,j_ ,k_-1,ist_00p)) / (std::abs(fsten(i_-1,j_ ,k_-1,ist_p0p))
2408 +std::abs(fsten(i_ ,j_ ,k_-1,ist_p0p)) + eps);
2409 Real w2p = std::abs(fsten(i_ ,j_ ,k_ ,ist_00p)) / (std::abs(fsten(i_-1,j_ ,k_ ,ist_p0p))
2410 +std::abs(fsten(i_ ,j_ ,k_ ,ist_p0p)) + eps);
2411 Real wmm = std::abs(fsten(i_-1,j_ ,k_-1,ist_p0p)) * (Real(1.) + w1m + w2m);
2412 Real wpm = std::abs(fsten(i_ ,j_ ,k_-1,ist_p0p)) * (Real(1.) + w1p + w2m);
2413 Real wmp = std::abs(fsten(i_-1,j_ ,k_ ,ist_p0p)) * (Real(1.) + w1m + w2p);
2414 Real wpp = std::abs(fsten(i_ ,j_ ,k_ ,ist_p0p)) * (Real(1.) + w1p + w2p);
2415 return wmp / (wmm+wpm+wmp+wpp+eps);
2416 };
2417
2418 auto interp_from_p0p_to = [&fsten] (int i_, int j_, int k_) -> Real {
2419 Real w1m = std::abs(fsten(i_-1,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_-1,j_ ,k_-1,ist_p0p))
2420 +std::abs(fsten(i_-1,j_ ,k_ ,ist_p0p)) + eps);
2421 Real w1p = std::abs(fsten(i_ ,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_ ,j_ ,k_-1,ist_p0p))
2422 +std::abs(fsten(i_ ,j_ ,k_ ,ist_p0p)) + eps);
2423 Real w2m = std::abs(fsten(i_ ,j_ ,k_-1,ist_00p)) / (std::abs(fsten(i_-1,j_ ,k_-1,ist_p0p))
2424 +std::abs(fsten(i_ ,j_ ,k_-1,ist_p0p)) + eps);
2425 Real w2p = std::abs(fsten(i_ ,j_ ,k_ ,ist_00p)) / (std::abs(fsten(i_-1,j_ ,k_ ,ist_p0p))
2426 +std::abs(fsten(i_ ,j_ ,k_ ,ist_p0p)) + eps);
2427 Real wmm = std::abs(fsten(i_-1,j_ ,k_-1,ist_p0p)) * (Real(1.) + w1m + w2m);
2428 Real wpm = std::abs(fsten(i_ ,j_ ,k_-1,ist_p0p)) * (Real(1.) + w1p + w2m);
2429 Real wmp = std::abs(fsten(i_-1,j_ ,k_ ,ist_p0p)) * (Real(1.) + w1m + w2p);
2430 Real wpp = std::abs(fsten(i_ ,j_ ,k_ ,ist_p0p)) * (Real(1.) + w1p + w2p);
2431 return wpp / (wmm+wpm+wmp+wpp+eps);
2432 };
2433
2434 auto interp_from_mm0_to = [&fsten] (int i_, int j_, int k_) -> Real {
2435 Real w1m = std::abs(fsten(i_-1,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_-1,j_-1,k_ ,ist_pp0))
2436 +std::abs(fsten(i_-1,j_ ,k_ ,ist_pp0)) + eps);
2437 Real w1p = std::abs(fsten(i_ ,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_ ,j_-1,k_ ,ist_pp0))
2438 +std::abs(fsten(i_ ,j_ ,k_ ,ist_pp0)) + eps);
2439 Real w2m = std::abs(fsten(i_ ,j_-1,k_ ,ist_0p0)) / (std::abs(fsten(i_-1,j_-1,k_ ,ist_pp0))
2440 +std::abs(fsten(i_ ,j_-1,k_ ,ist_pp0)) + eps);
2441 Real w2p = std::abs(fsten(i_ ,j_ ,k_ ,ist_0p0)) / (std::abs(fsten(i_-1,j_ ,k_ ,ist_pp0))
2442 +std::abs(fsten(i_ ,j_ ,k_ ,ist_pp0)) + eps);
2443 Real wmm = std::abs(fsten(i_-1,j_-1,k_ ,ist_pp0)) * (Real(1.) + w1m + w2m);
2444 Real wpm = std::abs(fsten(i_ ,j_-1,k_ ,ist_pp0)) * (Real(1.) + w1p + w2m);
2445 Real wmp = std::abs(fsten(i_-1,j_ ,k_ ,ist_pp0)) * (Real(1.) + w1m + w2p);
2446 Real wpp = std::abs(fsten(i_ ,j_ ,k_ ,ist_pp0)) * (Real(1.) + w1p + w2p);
2447 return wmm / (wmm+wpm+wmp+wpp+eps);
2448 };
2449
2450 auto interp_from_mp0_to = [&fsten] (int i_, int j_, int k_) -> Real {
2451 Real w1m = std::abs(fsten(i_-1,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_-1,j_-1,k_ ,ist_pp0))
2452 +std::abs(fsten(i_-1,j_ ,k_ ,ist_pp0)) + eps);
2453 Real w1p = std::abs(fsten(i_ ,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_ ,j_-1,k_ ,ist_pp0))
2454 +std::abs(fsten(i_ ,j_ ,k_ ,ist_pp0)) + eps);
2455 Real w2m = std::abs(fsten(i_ ,j_-1,k_ ,ist_0p0)) / (std::abs(fsten(i_-1,j_-1,k_ ,ist_pp0))
2456 +std::abs(fsten(i_ ,j_-1,k_ ,ist_pp0)) + eps);
2457 Real w2p = std::abs(fsten(i_ ,j_ ,k_ ,ist_0p0)) / (std::abs(fsten(i_-1,j_ ,k_ ,ist_pp0))
2458 +std::abs(fsten(i_ ,j_ ,k_ ,ist_pp0)) + eps);
2459 Real wmm = std::abs(fsten(i_-1,j_-1,k_ ,ist_pp0)) * (Real(1.) + w1m + w2m);
2460 Real wpm = std::abs(fsten(i_ ,j_-1,k_ ,ist_pp0)) * (Real(1.) + w1p + w2m);
2461 Real wmp = std::abs(fsten(i_-1,j_ ,k_ ,ist_pp0)) * (Real(1.) + w1m + w2p);
2462 Real wpp = std::abs(fsten(i_ ,j_ ,k_ ,ist_pp0)) * (Real(1.) + w1p + w2p);
2463 return wmp / (wmm+wpm+wmp+wpp+eps);
2464 };
2465
2466 auto interp_from_pm0_to = [&fsten] (int i_, int j_, int k_) -> Real {
2467 Real w1m = std::abs(fsten(i_-1,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_-1,j_-1,k_ ,ist_pp0))
2468 +std::abs(fsten(i_-1,j_ ,k_ ,ist_pp0)) + eps);
2469 Real w1p = std::abs(fsten(i_ ,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_ ,j_-1,k_ ,ist_pp0))
2470 +std::abs(fsten(i_ ,j_ ,k_ ,ist_pp0)) + eps);
2471 Real w2m = std::abs(fsten(i_ ,j_-1,k_ ,ist_0p0)) / (std::abs(fsten(i_-1,j_-1,k_ ,ist_pp0))
2472 +std::abs(fsten(i_ ,j_-1,k_ ,ist_pp0)) + eps);
2473 Real w2p = std::abs(fsten(i_ ,j_ ,k_ ,ist_0p0)) / (std::abs(fsten(i_-1,j_ ,k_ ,ist_pp0))
2474 +std::abs(fsten(i_ ,j_ ,k_ ,ist_pp0)) + eps);
2475 Real wmm = std::abs(fsten(i_-1,j_-1,k_ ,ist_pp0)) * (Real(1.) + w1m + w2m);
2476 Real wpm = std::abs(fsten(i_ ,j_-1,k_ ,ist_pp0)) * (Real(1.) + w1p + w2m);
2477 Real wmp = std::abs(fsten(i_-1,j_ ,k_ ,ist_pp0)) * (Real(1.) + w1m + w2p);
2478 Real wpp = std::abs(fsten(i_ ,j_ ,k_ ,ist_pp0)) * (Real(1.) + w1p + w2p);
2479 return wpm / (wmm+wpm+wmp+wpp+eps);
2480 };
2481
2482 auto interp_from_pp0_to = [&fsten] (int i_, int j_, int k_) -> Real {
2483 Real w1m = std::abs(fsten(i_-1,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_-1,j_-1,k_ ,ist_pp0))
2484 +std::abs(fsten(i_-1,j_ ,k_ ,ist_pp0)) + eps);
2485 Real w1p = std::abs(fsten(i_ ,j_ ,k_ ,ist_p00)) / (std::abs(fsten(i_ ,j_-1,k_ ,ist_pp0))
2486 +std::abs(fsten(i_ ,j_ ,k_ ,ist_pp0)) + eps);
2487 Real w2m = std::abs(fsten(i_ ,j_-1,k_ ,ist_0p0)) / (std::abs(fsten(i_-1,j_-1,k_ ,ist_pp0))
2488 +std::abs(fsten(i_ ,j_-1,k_ ,ist_pp0)) + eps);
2489 Real w2p = std::abs(fsten(i_ ,j_ ,k_ ,ist_0p0)) / (std::abs(fsten(i_-1,j_ ,k_ ,ist_pp0))
2490 +std::abs(fsten(i_ ,j_ ,k_ ,ist_pp0)) + eps);
2491 Real wmm = std::abs(fsten(i_-1,j_-1,k_ ,ist_pp0)) * (Real(1.) + w1m + w2m);
2492 Real wpm = std::abs(fsten(i_ ,j_-1,k_ ,ist_pp0)) * (Real(1.) + w1p + w2m);
2493 Real wmp = std::abs(fsten(i_-1,j_ ,k_ ,ist_pp0)) * (Real(1.) + w1m + w2p);
2494 Real wpp = std::abs(fsten(i_ ,j_ ,k_ ,ist_pp0)) * (Real(1.) + w1p + w2p);
2495 return wpp / (wmm+wpm+wmp+wpp+eps);
2496 };
2497
2498 auto interp_from_00m_to = [&fsten] (int i_, int j_, int k_) -> Real {
2499 Real w1 = std::abs(fsten(i_ ,j_ ,k_-1,ist_00p));
2500 Real w2 = std::abs(fsten(i_ ,j_ ,k_ ,ist_00p));
2501 if (w1 == Real(0.) && w2 == Real(0.)) {
2502 return Real(0.5);
2503 } else {
2504 return w1 / (w1+w2);
2505 }
2506 };
2507
2508 auto interp_from_00p_to = [&fsten] (int i_, int j_, int k_) -> Real {
2509 Real w1 = std::abs(fsten(i_ ,j_ ,k_-1,ist_00p));
2510 Real w2 = std::abs(fsten(i_ ,j_ ,k_ ,ist_00p));
2511 if (w1 == Real(0.) && w2 == Real(0.)) {
2512 return Real(0.5);
2513 } else {
2514 return w2 / (w1+w2);
2515 }
2516 };
2517
2518 auto interp_from_0m0_to = [&fsten] (int i_, int j_, int k_) -> Real {
2519 Real w1 = std::abs(fsten(i_ ,j_-1,k_ ,ist_0p0));
2520 Real w2 = std::abs(fsten(i_ ,j_ ,k_ ,ist_0p0));
2521 if (w1 == Real(0.) && w2 == Real(0.)) {
2522 return Real(0.5);
2523 } else {
2524 return w1 / (w1+w2);
2525 }
2526 };
2527
2528 auto interp_from_0p0_to = [&fsten] (int i_, int j_, int k_) -> Real {
2529 Real w1 = std::abs(fsten(i_ ,j_-1,k_ ,ist_0p0));
2530 Real w2 = std::abs(fsten(i_ ,j_ ,k_ ,ist_0p0));
2531 if (w1 == Real(0.) && w2 == Real(0.)) {
2532 return Real(0.5);
2533 } else {
2534 return w2 / (w1+w2);
2535 }
2536 };
2537
2538 auto interp_from_m00_to = [&fsten] (int i_, int j_, int k_) -> Real {
2539 Real w1 = std::abs(fsten(i_-1,j_ ,k_ ,ist_p00));
2540 Real w2 = std::abs(fsten(i_ ,j_ ,k_ ,ist_p00));
2541 if (w1 == Real(0.) && w2 == Real(0.)) {
2542 return Real(0.5);
2543 } else {
2544 return w1 / (w1+w2);
2545 }
2546 };
2547
2548 auto interp_from_p00_to = [&fsten] (int i_, int j_, int k_) -> Real {
2549 Real w1 = std::abs(fsten(i_-1,j_ ,k_ ,ist_p00));
2550 Real w2 = std::abs(fsten(i_ ,j_ ,k_ ,ist_p00));
2551 if (w1 == Real(0.) && w2 == Real(0.)) {
2552 return Real(0.5);
2553 } else {
2554 return w2 / (w1+w2);
2555 }
2556 };
2557
2558 auto Ammm = [&fsten] (int i_, int j_, int k_) -> Real {
2559 return fsten(i_-1,j_-1,k_-1,ist_ppp);
2560 };
2562
2563 auto A0mm = [&fsten] (int i_, int j_, int k_) -> Real {
2564 return fsten(i_ ,j_-1,k_-1,ist_0pp);
2565 };
2566
2567 auto Apmm = [&fsten] (int i_, int j_, int k_) -> Real {
2568 return fsten(i_ ,j_-1,k_-1,ist_ppp);
2569 };
2570
2571 auto Am0m = [&fsten] (int i_, int j_, int k_) -> Real {
2572 return fsten(i_-1,j_ ,k_-1,ist_p0p);
2573 };
2574
2575 auto A00m = [&fsten] (int i_, int j_, int k_) -> Real {
2576 return fsten(i_ ,j_ ,k_-1,ist_00p);
2577 };
2578
2579 auto Ap0m = [&fsten] (int i_, int j_, int k_) -> Real {
2580 return fsten(i_ ,j_ ,k_-1,ist_p0p);
2581 };
2582
2583 auto Ampm = [&fsten] (int i_, int j_, int k_) -> Real {
2584 return fsten(i_-1,j_ ,k_-1,ist_ppp);
2585 };
2586
2587 auto A0pm = [&fsten] (int i_, int j_, int k_) -> Real {
2588 return fsten(i_ ,j_ ,k_-1,ist_0pp);
2589 };
2590
2591 auto Appm = [&fsten] (int i_, int j_, int k_) -> Real {
2592 return fsten(i_ ,j_ ,k_-1,ist_ppp);
2593 };
2594
2595 auto Amm0 = [&fsten] (int i_, int j_, int k_) -> Real {
2596 return fsten(i_-1,j_-1,k_ ,ist_pp0);
2597 };
2598
2599 auto A0m0 = [&fsten] (int i_, int j_, int k_) -> Real {
2600 return fsten(i_ ,j_-1,k_ ,ist_0p0);
2601 };
2602
2603 auto Apm0 = [&fsten] (int i_, int j_, int k_) -> Real {
2604 return fsten(i_ ,j_-1,k_ ,ist_pp0);
2605 };
2606
2607 auto Am00 = [&fsten] (int i_, int j_, int k_) -> Real {
2608 return fsten(i_-1,j_ ,k_ ,ist_p00);
2609 };
2610
2611 auto A000 = [&fsten] (int i_, int j_, int k_) -> Real {
2612 return fsten(i_ ,j_ ,k_ ,ist_000);
2613 };
2614
2615 auto Ap00 = [&fsten] (int i_, int j_, int k_) -> Real {
2616 return fsten(i_ ,j_ ,k_ ,ist_p00);
2617 };
2618
2619 auto Amp0 = [&fsten] (int i_, int j_, int k_) -> Real {
2620 return fsten(i_-1,j_ ,k_ ,ist_pp0);
2621 };
2622
2623 auto A0p0 = [&fsten] (int i_, int j_, int k_) -> Real {
2624 return fsten(i_ ,j_ ,k_ ,ist_0p0);
2625 };
2626
2627 auto App0 = [&fsten] (int i_, int j_, int k_) -> Real {
2628 return fsten(i_ ,j_ ,k_ ,ist_pp0);
2629 };
2630
2631 auto Ammp = [&fsten] (int i_, int j_, int k_) -> Real {
2632 return fsten(i_-1,j_-1,k_ ,ist_ppp);
2633 };
2634
2635 auto A0mp = [&fsten] (int i_, int j_, int k_) -> Real {
2636 return fsten(i_ ,j_-1,k_ ,ist_0pp);
2637 };
2638
2639 auto Apmp = [&fsten] (int i_, int j_, int k_) -> Real {
2640 return fsten(i_ ,j_-1,k_ ,ist_ppp);
2641 };
2642
2643 auto Am0p = [&fsten] (int i_, int j_, int k_) -> Real {
2644 return fsten(i_-1,j_ ,k_ ,ist_p0p);
2645 };
2646
2647 auto A00p = [&fsten] (int i_, int j_, int k_) -> Real {
2648 return fsten(i_ ,j_ ,k_ ,ist_00p);
2649 };
2650
2651 auto Ap0p = [&fsten] (int i_, int j_, int k_) -> Real {
2652 return fsten(i_ ,j_ ,k_ ,ist_p0p);
2653 };
2654
2655 auto Ampp = [&fsten] (int i_, int j_, int k_) -> Real {
2656 return fsten(i_-1,j_ ,k_ ,ist_ppp);
2657 };
2658
2659 auto A0pp = [&fsten] (int i_, int j_, int k_) -> Real {
2660 return fsten(i_ ,j_ ,k_ ,ist_0pp);
2661 };
2662
2663 auto Appp = [&fsten] (int i_, int j_, int k_) -> Real {
2664 return fsten(i_ ,j_ ,k_ ,ist_ppp);
2665 };
2666
2667 auto restrict_from_mmm_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2668 Real r = Real(1.);
2669 r += std::abs(fsten(ii_-1,jj_-1,kk_-1,ist_p00)) /
2670 ( std::abs(fsten(ii_-1,jj_-2,kk_-2,ist_ppp))
2671 + std::abs(fsten(ii_-1,jj_-1,kk_-2,ist_ppp))
2672 + std::abs(fsten(ii_-1,jj_-2,kk_-1,ist_ppp))
2673 + std::abs(fsten(ii_-1,jj_-1,kk_-1,ist_ppp)) + eps);
2674 r += std::abs(fsten(ii_-1,jj_-1,kk_-1,ist_0p0)) /
2675 ( std::abs(fsten(ii_-2,jj_-1,kk_-2,ist_ppp))
2676 + std::abs(fsten(ii_-1,jj_-1,kk_-2,ist_ppp))
2677 + std::abs(fsten(ii_-2,jj_-1,kk_-1,ist_ppp))
2678 + std::abs(fsten(ii_-1,jj_-1,kk_-1,ist_ppp)) + eps);
2679 r += std::abs(fsten(ii_-1,jj_-1,kk_-1,ist_00p)) /
2680 ( std::abs(fsten(ii_-2,jj_-2,kk_-1,ist_ppp))
2681 + std::abs(fsten(ii_-1,jj_-2,kk_-1,ist_ppp))
2682 + std::abs(fsten(ii_-2,jj_-1,kk_-1,ist_ppp))
2683 + std::abs(fsten(ii_-1,jj_-1,kk_-1,ist_ppp)) + eps);
2684 r += std::abs(fsten(ii_-1,jj_-1,kk_-1,ist_pp0)) /
2685 ( std::abs(fsten(ii_-1,jj_-1,kk_-2,ist_ppp))
2686 + std::abs(fsten(ii_-1,jj_-1,kk_-1,ist_ppp)) + eps);
2687 r += std::abs(fsten(ii_-1,jj_-1,kk_-1,ist_p0p)) /
2688 ( std::abs(fsten(ii_-1,jj_-2,kk_-1,ist_ppp))
2689 + std::abs(fsten(ii_-1,jj_-1,kk_-1,ist_ppp)) + eps);
2690 r += std::abs(fsten(ii_-1,jj_-1,kk_-1,ist_0pp)) /
2691 ( std::abs(fsten(ii_-2,jj_-1,kk_-1,ist_ppp))
2692 + std::abs(fsten(ii_-1,jj_-1,kk_-1,ist_ppp)) + eps);
2693 r *= std::abs(fsten(ii_-1,jj_-1,kk_-1,ist_ppp)) * fsten(ii_-1,jj_-1,kk_-1,ist_inv);
2694 return r;
2695 };
2696 amrex::ignore_unused(restrict_from_mmm_to);
2697
2698 auto restrict_from_0mm_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2699 Real w1m = std::abs(fsten(ii_,jj_-2,kk_-1,ist_0p0)) / (std::abs(fsten(ii_,jj_-2,kk_-2,ist_0pp))
2700 +std::abs(fsten(ii_,jj_-2,kk_-1,ist_0pp)) + eps);
2701 Real w1p = std::abs(fsten(ii_,jj_-1,kk_-1,ist_0p0)) / (std::abs(fsten(ii_,jj_-1,kk_-2,ist_0pp))
2702 +std::abs(fsten(ii_,jj_-1,kk_-1,ist_0pp)) + eps);
2703 Real w2m = std::abs(fsten(ii_,jj_-1,kk_-2,ist_00p)) / (std::abs(fsten(ii_,jj_-2,kk_-2,ist_0pp))
2704 +std::abs(fsten(ii_,jj_-1,kk_-2,ist_0pp)) + eps);
2705 Real w2p = std::abs(fsten(ii_,jj_-1,kk_-1,ist_00p)) / (std::abs(fsten(ii_,jj_-2,kk_-1,ist_0pp))
2706 +std::abs(fsten(ii_,jj_-1,kk_-1,ist_0pp)) + eps);
2707 Real wmm = std::abs(fsten(ii_,jj_-2,kk_-2,ist_0pp)) * (Real(1.) + w1m + w2m);
2708 Real wpm = std::abs(fsten(ii_,jj_-1,kk_-2,ist_0pp)) * (Real(1.) + w1p + w2m);
2709 Real wmp = std::abs(fsten(ii_,jj_-2,kk_-1,ist_0pp)) * (Real(1.) + w1m + w2p);
2710 Real wpp = std::abs(fsten(ii_,jj_-1,kk_-1,ist_0pp)) * (Real(1.) + w1p + w2p);
2711 return wpp / (wmm+wpm+wmp+wpp+eps);
2712 };
2713
2714 auto restrict_from_pmm_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2715 Real r = Real(1.);
2716 r += std::abs(fsten(ii_ ,jj_-1,kk_-1,ist_p00)) /
2717 ( std::abs(fsten(ii_ ,jj_-2,kk_-2,ist_ppp))
2718 + std::abs(fsten(ii_ ,jj_-1,kk_-2,ist_ppp))
2719 + std::abs(fsten(ii_ ,jj_-2,kk_-1,ist_ppp))
2720 + std::abs(fsten(ii_ ,jj_-1,kk_-1,ist_ppp)) + eps);
2721 r += std::abs(fsten(ii_+1,jj_-1,kk_-1,ist_0p0)) /
2722 ( std::abs(fsten(ii_ ,jj_-1,kk_-2,ist_ppp))
2723 + std::abs(fsten(ii_+1,jj_-1,kk_-2,ist_ppp))
2724 + std::abs(fsten(ii_ ,jj_-1,kk_-1,ist_ppp))
2725 + std::abs(fsten(ii_+1,jj_-1,kk_-1,ist_ppp)) + eps);
2726 r += std::abs(fsten(ii_+1,jj_-1,kk_-1,ist_00p)) /
2727 ( std::abs(fsten(ii_ ,jj_-2,kk_-1,ist_ppp))
2728 + std::abs(fsten(ii_+1,jj_-2,kk_-1,ist_ppp))
2729 + std::abs(fsten(ii_ ,jj_-1,kk_-1,ist_ppp))
2730 + std::abs(fsten(ii_+1,jj_-1,kk_-1,ist_ppp)) + eps);
2731 r += std::abs(fsten(ii_ ,jj_-1,kk_-1,ist_pp0)) /
2732 ( std::abs(fsten(ii_ ,jj_-1,kk_-2,ist_ppp))
2733 + std::abs(fsten(ii_ ,jj_-1,kk_-1,ist_ppp)) + eps);
2734 r += std::abs(fsten(ii_ ,jj_-1,kk_-1,ist_p0p)) /
2735 ( std::abs(fsten(ii_ ,jj_-2,kk_-1,ist_ppp))
2736 + std::abs(fsten(ii_ ,jj_-1,kk_-1,ist_ppp)) + eps);
2737 r += std::abs(fsten(ii_+1,jj_-1,kk_-1,ist_0pp)) /
2738 ( std::abs(fsten(ii_ ,jj_-1,kk_-1,ist_ppp))
2739 + std::abs(fsten(ii_+1,jj_-1,kk_-1,ist_ppp)) + eps);
2740 r *= std::abs(fsten(ii_ ,jj_-1,kk_-1,ist_ppp)) * fsten(ii_+1,jj_-1,kk_-1,ist_inv);
2741 return r;
2742 };
2743
2744 auto restrict_from_m0m_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2745 Real w1m = std::abs(fsten(ii_-2,jj_,kk_-1,ist_p00)) / (std::abs(fsten(ii_-2,jj_,kk_-2,ist_p0p))
2746 +std::abs(fsten(ii_-2,jj_,kk_-1,ist_p0p)) + eps);
2747 Real w1p = std::abs(fsten(ii_-1,jj_,kk_-1,ist_p00)) / (std::abs(fsten(ii_-1,jj_,kk_-2,ist_p0p))
2748 +std::abs(fsten(ii_-1,jj_,kk_-1,ist_p0p)) + eps);
2749 Real w2m = std::abs(fsten(ii_-1,jj_,kk_-2,ist_00p)) / (std::abs(fsten(ii_-2,jj_,kk_-2,ist_p0p))
2750 +std::abs(fsten(ii_-1,jj_,kk_-2,ist_p0p)) + eps);
2751 Real w2p = std::abs(fsten(ii_-1,jj_,kk_-1,ist_00p)) / (std::abs(fsten(ii_-2,jj_,kk_-1,ist_p0p))
2752 +std::abs(fsten(ii_-1,jj_,kk_-1,ist_p0p)) + eps);
2753 Real wmm = std::abs(fsten(ii_-2,jj_,kk_-2,ist_p0p)) * (Real(1.) + w1m + w2m);
2754 Real wpm = std::abs(fsten(ii_-1,jj_,kk_-2,ist_p0p)) * (Real(1.) + w1p + w2m);
2755 Real wmp = std::abs(fsten(ii_-2,jj_,kk_-1,ist_p0p)) * (Real(1.) + w1m + w2p);
2756 Real wpp = std::abs(fsten(ii_-1,jj_,kk_-1,ist_p0p)) * (Real(1.) + w1p + w2p);
2757 return wpp / (wmm+wpm+wmp+wpp+eps);
2758 };
2759
2760 auto restrict_from_00m_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2761 Real w1 = std::abs(fsten(ii_,jj_,kk_-2,ist_00p));
2762 Real w2 = std::abs(fsten(ii_,jj_,kk_-1,ist_00p));
2763 if (w1 == Real(0.) && w2 == Real(0.)) {
2764 return Real(0.5);
2765 } else {
2766 return w2 / (w1+w2);
2767 }
2768 };
2769
2770 auto restrict_from_p0m_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2771 Real w1m = std::abs(fsten(ii_ ,jj_,kk_-1,ist_p00)) / (std::abs(fsten(ii_ ,jj_,kk_-2,ist_p0p))
2772 +std::abs(fsten(ii_ ,jj_,kk_-1,ist_p0p)) + eps);
2773 Real w1p = std::abs(fsten(ii_+1,jj_,kk_-1,ist_p00)) / (std::abs(fsten(ii_+1,jj_,kk_-2,ist_p0p))
2774 +std::abs(fsten(ii_+1,jj_,kk_-1,ist_p0p)) + eps);
2775 Real w2m = std::abs(fsten(ii_+1,jj_,kk_-2,ist_00p)) / (std::abs(fsten(ii_ ,jj_,kk_-2,ist_p0p))
2776 +std::abs(fsten(ii_+1,jj_,kk_-2,ist_p0p)) + eps);
2777 Real w2p = std::abs(fsten(ii_+1,jj_,kk_-1,ist_00p)) / (std::abs(fsten(ii_ ,jj_,kk_-1,ist_p0p))
2778 +std::abs(fsten(ii_+1,jj_,kk_-1,ist_p0p)) + eps);
2779 Real wmm = std::abs(fsten(ii_ ,jj_,kk_-2,ist_p0p)) * (Real(1.) + w1m + w2m);
2780 Real wpm = std::abs(fsten(ii_+1,jj_,kk_-2,ist_p0p)) * (Real(1.) + w1p + w2m);
2781 Real wmp = std::abs(fsten(ii_ ,jj_,kk_-1,ist_p0p)) * (Real(1.) + w1m + w2p);
2782 Real wpp = std::abs(fsten(ii_+1,jj_,kk_-1,ist_p0p)) * (Real(1.) + w1p + w2p);
2783 return wmp / (wmm+wpm+wmp+wpp+eps);
2784 };
2785
2786 auto restrict_from_mpm_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2787 Real r = Real(1.);
2788 r += std::abs(fsten(ii_-1,jj_+1,kk_-1,ist_p00)) /
2789 ( std::abs(fsten(ii_-1,jj_ ,kk_-2,ist_ppp))
2790 + std::abs(fsten(ii_-1,jj_+1,kk_-2,ist_ppp))
2791 + std::abs(fsten(ii_-1,jj_ ,kk_-1,ist_ppp))
2792 + std::abs(fsten(ii_-1,jj_+1,kk_-1,ist_ppp)) + eps);
2793 r += std::abs(fsten(ii_-1,jj_ ,kk_-1,ist_0p0)) /
2794 ( std::abs(fsten(ii_-2,jj_ ,kk_-2,ist_ppp))
2795 + std::abs(fsten(ii_-1,jj_ ,kk_-2,ist_ppp))
2796 + std::abs(fsten(ii_-2,jj_ ,kk_-1,ist_ppp))
2797 + std::abs(fsten(ii_-1,jj_ ,kk_-1,ist_ppp)) + eps);
2798 r += std::abs(fsten(ii_-1,jj_+1,kk_-1,ist_00p)) /
2799 ( std::abs(fsten(ii_-2,jj_ ,kk_-1,ist_ppp))
2800 + std::abs(fsten(ii_-1,jj_ ,kk_-1,ist_ppp))
2801 + std::abs(fsten(ii_-2,jj_+1,kk_-1,ist_ppp))
2802 + std::abs(fsten(ii_-1,jj_+1,kk_-1,ist_ppp)) + eps);
2803 r += std::abs(fsten(ii_-1,jj_ ,kk_-1,ist_pp0)) /
2804 ( std::abs(fsten(ii_-1,jj_ ,kk_-2,ist_ppp))
2805 + std::abs(fsten(ii_-1,jj_ ,kk_-1,ist_ppp)) + eps);
2806 r += std::abs(fsten(ii_-1,jj_+1,kk_-1,ist_p0p)) /
2807 ( std::abs(fsten(ii_-1,jj_ ,kk_-1,ist_ppp))
2808 + std::abs(fsten(ii_-1,jj_+1,kk_-1,ist_ppp)) + eps);
2809 r += std::abs(fsten(ii_-1,jj_ ,kk_-1,ist_0pp)) /
2810 ( std::abs(fsten(ii_-2,jj_ ,kk_-1,ist_ppp))
2811 + std::abs(fsten(ii_-1,jj_ ,kk_-1,ist_ppp)) + eps);
2812 r *= std::abs(fsten(ii_-1,jj_ ,kk_-1,ist_ppp)) * fsten(ii_-1,jj_+1,kk_-1,ist_inv);
2813 return r;
2814 };
2815
2816 auto restrict_from_0pm_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2817 Real w1m = std::abs(fsten(ii_,jj_ ,kk_-1,ist_0p0)) / (std::abs(fsten(ii_,jj_ ,kk_-2,ist_0pp))
2818 +std::abs(fsten(ii_,jj_ ,kk_-1,ist_0pp)) + eps);
2819 Real w1p = std::abs(fsten(ii_,jj_+1,kk_-1,ist_0p0)) / (std::abs(fsten(ii_,jj_+1,kk_-2,ist_0pp))
2820 +std::abs(fsten(ii_,jj_+1,kk_-1,ist_0pp)) + eps);
2821 Real w2m = std::abs(fsten(ii_,jj_+1,kk_-2,ist_00p)) / (std::abs(fsten(ii_,jj_ ,kk_-2,ist_0pp))
2822 +std::abs(fsten(ii_,jj_+1,kk_-2,ist_0pp)) + eps);
2823 Real w2p = std::abs(fsten(ii_,jj_+1,kk_-1,ist_00p)) / (std::abs(fsten(ii_,jj_ ,kk_-1,ist_0pp))
2824 +std::abs(fsten(ii_,jj_+1,kk_-1,ist_0pp)) + eps);
2825 Real wmm = std::abs(fsten(ii_,jj_ ,kk_-2,ist_0pp)) * (Real(1.) + w1m + w2m);
2826 Real wpm = std::abs(fsten(ii_,jj_+1,kk_-2,ist_0pp)) * (Real(1.) + w1p + w2m);
2827 Real wmp = std::abs(fsten(ii_,jj_ ,kk_-1,ist_0pp)) * (Real(1.) + w1m + w2p);
2828 Real wpp = std::abs(fsten(ii_,jj_+1,kk_-1,ist_0pp)) * (Real(1.) + w1p + w2p);
2829 return wmp / (wmm+wpm+wmp+wpp+eps);
2830 };
2831
2832 auto restrict_from_ppm_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2833 Real r = Real(1.);
2834 r += std::abs(fsten(ii_ ,jj_+1,kk_-1,ist_p00)) /
2835 ( std::abs(fsten(ii_ ,jj_ ,kk_-2,ist_ppp))
2836 + std::abs(fsten(ii_ ,jj_+1,kk_-2,ist_ppp))
2837 + std::abs(fsten(ii_ ,jj_ ,kk_-1,ist_ppp))
2838 + std::abs(fsten(ii_ ,jj_+1,kk_-1,ist_ppp)) + eps);
2839 r += std::abs(fsten(ii_+1,jj_ ,kk_-1,ist_0p0)) /
2840 ( std::abs(fsten(ii_ ,jj_ ,kk_-2,ist_ppp))
2841 + std::abs(fsten(ii_+1,jj_ ,kk_-2,ist_ppp))
2842 + std::abs(fsten(ii_ ,jj_ ,kk_-1,ist_ppp))
2843 + std::abs(fsten(ii_+1,jj_ ,kk_-1,ist_ppp)) + eps);
2844 r += std::abs(fsten(ii_+1,jj_+1,kk_-1,ist_00p)) /
2845 ( std::abs(fsten(ii_ ,jj_ ,kk_-1,ist_ppp))
2846 + std::abs(fsten(ii_+1,jj_ ,kk_-1,ist_ppp))
2847 + std::abs(fsten(ii_ ,jj_+1,kk_-1,ist_ppp))
2848 + std::abs(fsten(ii_+1,jj_+1,kk_-1,ist_ppp)) + eps);
2849 r += std::abs(fsten(ii_ ,jj_ ,kk_-1,ist_pp0)) /
2850 ( std::abs(fsten(ii_ ,jj_ ,kk_-2,ist_ppp))
2851 + std::abs(fsten(ii_ ,jj_ ,kk_-1,ist_ppp)) + eps);
2852 r += std::abs(fsten(ii_ ,jj_+1,kk_-1,ist_p0p)) /
2853 ( std::abs(fsten(ii_ ,jj_ ,kk_-1,ist_ppp))
2854 + std::abs(fsten(ii_ ,jj_+1,kk_-1,ist_ppp)) + eps);
2855 r += std::abs(fsten(ii_+1,jj_ ,kk_-1,ist_0pp)) /
2856 ( std::abs(fsten(ii_ ,jj_ ,kk_-1,ist_ppp))
2857 + std::abs(fsten(ii_+1,jj_ ,kk_-1,ist_ppp)) + eps);
2858 r *= std::abs(fsten(ii_ ,jj_ ,kk_-1,ist_ppp)) * fsten(ii_+1,jj_+1,kk_-1,ist_inv);
2859 return r;
2860 };
2861
2862 auto restrict_from_mm0_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2863 Real w1m = std::abs(fsten(ii_-2,jj_-1,kk_,ist_p00)) / (std::abs(fsten(ii_-2,jj_-2,kk_,ist_pp0))
2864 +std::abs(fsten(ii_-2,jj_-1,kk_,ist_pp0)) + eps);
2865 Real w1p = std::abs(fsten(ii_-1,jj_-1,kk_,ist_p00)) / (std::abs(fsten(ii_-1,jj_-2,kk_,ist_pp0))
2866 +std::abs(fsten(ii_-1,jj_-1,kk_,ist_pp0)) + eps);
2867 Real w2m = std::abs(fsten(ii_-1,jj_-2,kk_,ist_0p0)) / (std::abs(fsten(ii_-2,jj_-2,kk_,ist_pp0))
2868 +std::abs(fsten(ii_-1,jj_-2,kk_,ist_pp0)) + eps);
2869 Real w2p = std::abs(fsten(ii_-1,jj_-1,kk_,ist_0p0)) / (std::abs(fsten(ii_-2,jj_-1,kk_,ist_pp0))
2870 +std::abs(fsten(ii_-1,jj_-1,kk_,ist_pp0)) + eps);
2871 Real wmm = std::abs(fsten(ii_-2,jj_-2,kk_,ist_pp0)) * (Real(1.) + w1m + w2m);
2872 Real wpm = std::abs(fsten(ii_-1,jj_-2,kk_,ist_pp0)) * (Real(1.) + w1p + w2m);
2873 Real wmp = std::abs(fsten(ii_-2,jj_-1,kk_,ist_pp0)) * (Real(1.) + w1m + w2p);
2874 Real wpp = std::abs(fsten(ii_-1,jj_-1,kk_,ist_pp0)) * (Real(1.) + w1p + w2p);
2875 return wpp / (wmm+wpm+wmp+wpp+eps);
2876 };
2877
2878 auto restrict_from_0m0_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2879 Real w1 = std::abs(fsten(ii_,jj_-2,kk_,ist_0p0));
2880 Real w2 = std::abs(fsten(ii_,jj_-1,kk_,ist_0p0));
2881 if (w1 == Real(0.) && w2 == Real(0.)) {
2882 return Real(0.5);
2883 } else {
2884 return w2 / (w1+w2);
2885 }
2886 };
2887
2888 auto restrict_from_pm0_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2889 Real w1m = std::abs(fsten(ii_ ,jj_-1,kk_,ist_p00)) / (std::abs(fsten(ii_ ,jj_-2,kk_,ist_pp0))
2890 +std::abs(fsten(ii_ ,jj_-1,kk_,ist_pp0)) + eps);
2891 Real w1p = std::abs(fsten(ii_+1,jj_-1,kk_,ist_p00)) / (std::abs(fsten(ii_+1,jj_-2,kk_,ist_pp0))
2892 +std::abs(fsten(ii_+1,jj_-1,kk_,ist_pp0)) + eps);
2893 Real w2m = std::abs(fsten(ii_+1,jj_-2,kk_,ist_0p0)) / (std::abs(fsten(ii_ ,jj_-2,kk_,ist_pp0))
2894 +std::abs(fsten(ii_+1,jj_-2,kk_,ist_pp0)) + eps);
2895 Real w2p = std::abs(fsten(ii_+1,jj_-1,kk_,ist_0p0)) / (std::abs(fsten(ii_ ,jj_-1,kk_,ist_pp0))
2896 +std::abs(fsten(ii_+1,jj_-1,kk_,ist_pp0)) + eps);
2897 Real wmm = std::abs(fsten(ii_ ,jj_-2,kk_,ist_pp0)) * (Real(1.) + w1m + w2m);
2898 Real wpm = std::abs(fsten(ii_+1,jj_-2,kk_,ist_pp0)) * (Real(1.) + w1p + w2m);
2899 Real wmp = std::abs(fsten(ii_ ,jj_-1,kk_,ist_pp0)) * (Real(1.) + w1m + w2p);
2900 Real wpp = std::abs(fsten(ii_+1,jj_-1,kk_,ist_pp0)) * (Real(1.) + w1p + w2p);
2901 return wmp / (wmm+wpm+wmp+wpp+eps);
2902 };
2903
2904 auto restrict_from_m00_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2905 Real w1 = std::abs(fsten(ii_-2,jj_,kk_,ist_p00));
2906 Real w2 = std::abs(fsten(ii_-1,jj_,kk_,ist_p00));
2907 if (w1 == Real(0.) && w2 == Real(0.)) {
2908 return Real(0.5);
2909 } else {
2910 return w2 / (w1+w2);
2911 }
2912 };
2913
2914 auto restrict_from_000_to = [] (int /*ii_*/, int /*jj_*/, int /*kk_*/) -> Real {
2915 return Real(1.);
2916 };
2917
2918 auto restrict_from_p00_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2919 Real w1 = std::abs(fsten(ii_ ,jj_,kk_,ist_p00));
2920 Real w2 = std::abs(fsten(ii_+1,jj_,kk_,ist_p00));
2921 if (w1 == Real(0.) && w2 == Real(0.)) {
2922 return Real(0.5);
2923 } else {
2924 return w1 / (w1+w2);
2925 }
2926 };
2927
2928 auto restrict_from_mp0_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2929 Real w1m = std::abs(fsten(ii_-2,jj_+1,kk_,ist_p00)) / (std::abs(fsten(ii_-2,jj_ ,kk_,ist_pp0))
2930 +std::abs(fsten(ii_-2,jj_+1,kk_,ist_pp0)) + eps);
2931 Real w1p = std::abs(fsten(ii_-1,jj_+1,kk_,ist_p00)) / (std::abs(fsten(ii_-1,jj_ ,kk_,ist_pp0))
2932 +std::abs(fsten(ii_-1,jj_+1,kk_,ist_pp0)) + eps);
2933 Real w2m = std::abs(fsten(ii_-1,jj_ ,kk_,ist_0p0)) / (std::abs(fsten(ii_-2,jj_ ,kk_,ist_pp0))
2934 +std::abs(fsten(ii_-1,jj_ ,kk_,ist_pp0)) + eps);
2935 Real w2p = std::abs(fsten(ii_-1,jj_+1,kk_,ist_0p0)) / (std::abs(fsten(ii_-2,jj_+1,kk_,ist_pp0))
2936 +std::abs(fsten(ii_-1,jj_+1,kk_,ist_pp0)) + eps);
2937 Real wmm = std::abs(fsten(ii_-2,jj_ ,kk_,ist_pp0)) * (Real(1.) + w1m + w2m);
2938 Real wpm = std::abs(fsten(ii_-1,jj_ ,kk_,ist_pp0)) * (Real(1.) + w1p + w2m);
2939 Real wmp = std::abs(fsten(ii_-2,jj_+1,kk_,ist_pp0)) * (Real(1.) + w1m + w2p);
2940 Real wpp = std::abs(fsten(ii_-1,jj_+1,kk_,ist_pp0)) * (Real(1.) + w1p + w2p);
2941 return wpm / (wmm+wpm+wmp+wpp+eps);
2942 };
2943
2944 auto restrict_from_0p0_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2945 Real w1 = std::abs(fsten(ii_,jj_ ,kk_,ist_0p0));
2946 Real w2 = std::abs(fsten(ii_,jj_+1,kk_,ist_0p0));
2947 if (w1 == Real(0.) && w2 == Real(0.)) {
2948 return Real(0.5);
2949 } else {
2950 return w1 / (w1+w2);
2951 }
2952 };
2953
2954 auto restrict_from_pp0_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2955 Real w1m = std::abs(fsten(ii_ ,jj_+1,kk_,ist_p00)) / (std::abs(fsten(ii_ ,jj_ ,kk_,ist_pp0))
2956 +std::abs(fsten(ii_ ,jj_+1,kk_,ist_pp0)) + eps);
2957 Real w1p = std::abs(fsten(ii_+1,jj_+1,kk_,ist_p00)) / (std::abs(fsten(ii_+1,jj_ ,kk_,ist_pp0))
2958 +std::abs(fsten(ii_+1,jj_+1,kk_,ist_pp0)) + eps);
2959 Real w2m = std::abs(fsten(ii_+1,jj_ ,kk_,ist_0p0)) / (std::abs(fsten(ii_ ,jj_ ,kk_,ist_pp0))
2960 +std::abs(fsten(ii_+1,jj_ ,kk_,ist_pp0)) + eps);
2961 Real w2p = std::abs(fsten(ii_+1,jj_+1,kk_,ist_0p0)) / (std::abs(fsten(ii_ ,jj_+1,kk_,ist_pp0))
2962 +std::abs(fsten(ii_+1,jj_+1,kk_,ist_pp0)) + eps);
2963 Real wmm = std::abs(fsten(ii_ ,jj_ ,kk_,ist_pp0)) * (Real(1.) + w1m + w2m);
2964 Real wpm = std::abs(fsten(ii_+1,jj_ ,kk_,ist_pp0)) * (Real(1.) + w1p + w2m);
2965 Real wmp = std::abs(fsten(ii_ ,jj_+1,kk_,ist_pp0)) * (Real(1.) + w1m + w2p);
2966 Real wpp = std::abs(fsten(ii_+1,jj_+1,kk_,ist_pp0)) * (Real(1.) + w1p + w2p);
2967 return wmm / (wmm+wpm+wmp+wpp+eps);
2968 };
2969
2970 auto restrict_from_mmp_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
2971 Real r = Real(1.);
2972 r += std::abs(fsten(ii_-1,jj_-1,kk_+1,ist_p00)) /
2973 ( std::abs(fsten(ii_-1,jj_-2,kk_ ,ist_ppp))
2974 + std::abs(fsten(ii_-1,jj_-1,kk_ ,ist_ppp))
2975 + std::abs(fsten(ii_-1,jj_-2,kk_+1,ist_ppp))
2976 + std::abs(fsten(ii_-1,jj_-1,kk_+1,ist_ppp)) + eps);
2977 r += std::abs(fsten(ii_-1,jj_-1,kk_+1,ist_0p0)) /
2978 ( std::abs(fsten(ii_-2,jj_-1,kk_ ,ist_ppp))
2979 + std::abs(fsten(ii_-1,jj_-1,kk_ ,ist_ppp))
2980 + std::abs(fsten(ii_-2,jj_-1,kk_+1,ist_ppp))
2981 + std::abs(fsten(ii_-1,jj_-1,kk_+1,ist_ppp)) + eps);
2982 r += std::abs(fsten(ii_-1,jj_-1,kk_ ,ist_00p)) /
2983 ( std::abs(fsten(ii_-2,jj_-2,kk_ ,ist_ppp))
2984 + std::abs(fsten(ii_-1,jj_-2,kk_ ,ist_ppp))
2985 + std::abs(fsten(ii_-2,jj_-1,kk_ ,ist_ppp))
2986 + std::abs(fsten(ii_-1,jj_-1,kk_ ,ist_ppp)) + eps);
2987 r += std::abs(fsten(ii_-1,jj_-1,kk_+1,ist_pp0)) /
2988 ( std::abs(fsten(ii_-1,jj_-1,kk_ ,ist_ppp))
2989 + std::abs(fsten(ii_-1,jj_-1,kk_+1,ist_ppp)) + eps);
2990 r += std::abs(fsten(ii_-1,jj_-1,kk_ ,ist_p0p)) /
2991 ( std::abs(fsten(ii_-1,jj_-2,kk_ ,ist_ppp))
2992 + std::abs(fsten(ii_-1,jj_-1,kk_ ,ist_ppp)) + eps);
2993 r += std::abs(fsten(ii_-1,jj_-1,kk_ ,ist_0pp)) /
2994 ( std::abs(fsten(ii_-2,jj_-1,kk_ ,ist_ppp))
2995 + std::abs(fsten(ii_-1,jj_-1,kk_ ,ist_ppp)) + eps);
2996 r *= std::abs(fsten(ii_-1,jj_-1,kk_ ,ist_ppp)) * fsten(ii_-1,jj_-1,kk_+1,ist_inv);
2997 return r;
2998 };
2999
3000 auto restrict_from_0mp_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
3001 Real w1m = std::abs(fsten(ii_,jj_-2,kk_+1,ist_0p0)) / (std::abs(fsten(ii_,jj_-2,kk_ ,ist_0pp))
3002 +std::abs(fsten(ii_,jj_-2,kk_+1,ist_0pp)) + eps);
3003 Real w1p = std::abs(fsten(ii_,jj_-1,kk_+1,ist_0p0)) / (std::abs(fsten(ii_,jj_-1,kk_ ,ist_0pp))
3004 +std::abs(fsten(ii_,jj_-1,kk_+1,ist_0pp)) + eps);
3005 Real w2m = std::abs(fsten(ii_,jj_-1,kk_ ,ist_00p)) / (std::abs(fsten(ii_,jj_-2,kk_ ,ist_0pp))
3006 +std::abs(fsten(ii_,jj_-1,kk_ ,ist_0pp)) + eps);
3007 Real w2p = std::abs(fsten(ii_,jj_-1,kk_+1,ist_00p)) / (std::abs(fsten(ii_,jj_-2,kk_+1,ist_0pp))
3008 +std::abs(fsten(ii_,jj_-1,kk_+1,ist_0pp)) + eps);
3009 Real wmm = std::abs(fsten(ii_,jj_-2,kk_ ,ist_0pp)) * (Real(1.) + w1m + w2m);
3010 Real wpm = std::abs(fsten(ii_,jj_-1,kk_ ,ist_0pp)) * (Real(1.) + w1p + w2m);
3011 Real wmp = std::abs(fsten(ii_,jj_-2,kk_+1,ist_0pp)) * (Real(1.) + w1m + w2p);
3012 Real wpp = std::abs(fsten(ii_,jj_-1,kk_+1,ist_0pp)) * (Real(1.) + w1p + w2p);
3013 return wpm / (wmm+wpm+wmp+wpp+eps);
3014 };
3015
3016 auto restrict_from_pmp_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
3017 Real r = Real(1.);
3018 r += std::abs(fsten(ii_ ,jj_-1,kk_+1,ist_p00)) /
3019 ( std::abs(fsten(ii_ ,jj_-2,kk_ ,ist_ppp))
3020 + std::abs(fsten(ii_ ,jj_-1,kk_ ,ist_ppp))
3021 + std::abs(fsten(ii_ ,jj_-2,kk_+1,ist_ppp))
3022 + std::abs(fsten(ii_ ,jj_-1,kk_+1,ist_ppp)) + eps);
3023 r += std::abs(fsten(ii_+1,jj_-1,kk_+1,ist_0p0)) /
3024 ( std::abs(fsten(ii_ ,jj_-1,kk_ ,ist_ppp))
3025 + std::abs(fsten(ii_+1,jj_-1,kk_ ,ist_ppp))
3026 + std::abs(fsten(ii_ ,jj_-1,kk_+1,ist_ppp))
3027 + std::abs(fsten(ii_+1,jj_-1,kk_+1,ist_ppp)) + eps);
3028 r += std::abs(fsten(ii_+1,jj_-1,kk_ ,ist_00p)) /
3029 ( std::abs(fsten(ii_ ,jj_-2,kk_ ,ist_ppp))
3030 + std::abs(fsten(ii_+1,jj_-2,kk_ ,ist_ppp))
3031 + std::abs(fsten(ii_ ,jj_-1,kk_ ,ist_ppp))
3032 + std::abs(fsten(ii_+1,jj_-1,kk_ ,ist_ppp)) + eps);
3033 r += std::abs(fsten(ii_ ,jj_-1,kk_+1,ist_pp0)) /
3034 ( std::abs(fsten(ii_ ,jj_-1,kk_ ,ist_ppp))
3035 + std::abs(fsten(ii_ ,jj_-1,kk_+1,ist_ppp)) + eps);
3036 r += std::abs(fsten(ii_ ,jj_-1,kk_ ,ist_p0p)) /
3037 ( std::abs(fsten(ii_ ,jj_-2,kk_ ,ist_ppp))
3038 + std::abs(fsten(ii_ ,jj_-1,kk_ ,ist_ppp)) + eps);
3039 r += std::abs(fsten(ii_+1,jj_-1,kk_ ,ist_0pp)) /
3040 ( std::abs(fsten(ii_ ,jj_-1,kk_ ,ist_ppp))
3041 + std::abs(fsten(ii_+1,jj_-1,kk_ ,ist_ppp)) + eps);
3042 r *= std::abs(fsten(ii_ ,jj_-1,kk_ ,ist_ppp)) * fsten(ii_+1,jj_-1,kk_+1,ist_inv);
3043 return r;
3044 };
3045
3046 auto restrict_from_m0p_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
3047 Real w1m = std::abs(fsten(ii_-2,jj_,kk_+1,ist_p00)) / (std::abs(fsten(ii_-2,jj_,kk_ ,ist_p0p))
3048 +std::abs(fsten(ii_-2,jj_,kk_+1,ist_p0p)) + eps);
3049 Real w1p = std::abs(fsten(ii_-1,jj_,kk_+1,ist_p00)) / (std::abs(fsten(ii_-1,jj_,kk_ ,ist_p0p))
3050 +std::abs(fsten(ii_-1,jj_,kk_+1,ist_p0p)) + eps);
3051 Real w2m = std::abs(fsten(ii_-1,jj_,kk_ ,ist_00p)) / (std::abs(fsten(ii_-2,jj_,kk_ ,ist_p0p))
3052 +std::abs(fsten(ii_-1,jj_,kk_ ,ist_p0p)) + eps);
3053 Real w2p = std::abs(fsten(ii_-1,jj_,kk_+1,ist_00p)) / (std::abs(fsten(ii_-2,jj_,kk_+1,ist_p0p))
3054 +std::abs(fsten(ii_-1,jj_,kk_+1,ist_p0p)) + eps);
3055 Real wmm = std::abs(fsten(ii_-2,jj_,kk_ ,ist_p0p)) * (Real(1.) + w1m + w2m);
3056 Real wpm = std::abs(fsten(ii_-1,jj_,kk_ ,ist_p0p)) * (Real(1.) + w1p + w2m);
3057 Real wmp = std::abs(fsten(ii_-2,jj_,kk_+1,ist_p0p)) * (Real(1.) + w1m + w2p);
3058 Real wpp = std::abs(fsten(ii_-1,jj_,kk_+1,ist_p0p)) * (Real(1.) + w1p + w2p);
3059 return wpm / (wmm+wpm+wmp+wpp+eps);
3060 };
3061
3062 auto restrict_from_00p_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
3063 Real w1 = std::abs(fsten(ii_,jj_,kk_ ,ist_00p));
3064 Real w2 = std::abs(fsten(ii_,jj_,kk_+1,ist_00p));
3065 if (w1 == Real(0.) && w2 == Real(0.)) {
3066 return Real(0.5);
3067 } else {
3068 return w1 / (w1+w2);
3069 }
3070 };
3071
3072 auto restrict_from_p0p_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
3073 Real w1m = std::abs(fsten(ii_ ,jj_,kk_+1,ist_p00)) / (std::abs(fsten(ii_ ,jj_,kk_ ,ist_p0p))
3074 +std::abs(fsten(ii_ ,jj_,kk_+1,ist_p0p)) + eps);
3075 Real w1p = std::abs(fsten(ii_+1,jj_,kk_+1,ist_p00)) / (std::abs(fsten(ii_+1,jj_,kk_ ,ist_p0p))
3076 +std::abs(fsten(ii_+1,jj_,kk_+1,ist_p0p)) + eps);
3077 Real w2m = std::abs(fsten(ii_+1,jj_,kk_ ,ist_00p)) / (std::abs(fsten(ii_ ,jj_,kk_ ,ist_p0p))
3078 +std::abs(fsten(ii_+1,jj_,kk_ ,ist_p0p)) + eps);
3079 Real w2p = std::abs(fsten(ii_+1,jj_,kk_+1,ist_00p)) / (std::abs(fsten(ii_ ,jj_,kk_+1,ist_p0p))
3080 +std::abs(fsten(ii_+1,jj_,kk_+1,ist_p0p)) + eps);
3081 Real wmm = std::abs(fsten(ii_ ,jj_,kk_ ,ist_p0p)) * (Real(1.) + w1m + w2m);
3082 Real wpm = std::abs(fsten(ii_+1,jj_,kk_ ,ist_p0p)) * (Real(1.) + w1p + w2m);
3083 Real wmp = std::abs(fsten(ii_ ,jj_,kk_+1,ist_p0p)) * (Real(1.) + w1m + w2p);
3084 Real wpp = std::abs(fsten(ii_+1,jj_,kk_+1,ist_p0p)) * (Real(1.) + w1p + w2p);
3085 return wmm / (wmm+wpm+wmp+wpp+eps);
3086 };
3087
3088 auto restrict_from_mpp_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
3089 Real r = Real(1.);
3090 r += std::abs(fsten(ii_-1,jj_+1,kk_+1,ist_p00)) /
3091 ( std::abs(fsten(ii_-1,jj_ ,kk_ ,ist_ppp))
3092 + std::abs(fsten(ii_-1,jj_+1,kk_ ,ist_ppp))
3093 + std::abs(fsten(ii_-1,jj_ ,kk_+1,ist_ppp))
3094 + std::abs(fsten(ii_-1,jj_+1,kk_+1,ist_ppp)) + eps);
3095 r += std::abs(fsten(ii_-1,jj_ ,kk_+1,ist_0p0)) /
3096 ( std::abs(fsten(ii_-2,jj_ ,kk_ ,ist_ppp))
3097 + std::abs(fsten(ii_-1,jj_ ,kk_ ,ist_ppp))
3098 + std::abs(fsten(ii_-2,jj_ ,kk_+1,ist_ppp))
3099 + std::abs(fsten(ii_-1,jj_ ,kk_+1,ist_ppp)) + eps);
3100 r += std::abs(fsten(ii_-1,jj_+1,kk_ ,ist_00p)) /
3101 ( std::abs(fsten(ii_-2,jj_ ,kk_ ,ist_ppp))
3102 + std::abs(fsten(ii_-1,jj_ ,kk_ ,ist_ppp))
3103 + std::abs(fsten(ii_-2,jj_+1,kk_ ,ist_ppp))
3104 + std::abs(fsten(ii_-1,jj_+1,kk_ ,ist_ppp)) + eps);
3105 r += std::abs(fsten(ii_-1,jj_ ,kk_+1,ist_pp0)) /
3106 ( std::abs(fsten(ii_-1,jj_ ,kk_ ,ist_ppp))
3107 + std::abs(fsten(ii_-1,jj_ ,kk_+1,ist_ppp)) + eps);
3108 r += std::abs(fsten(ii_-1,jj_+1,kk_ ,ist_p0p)) /
3109 ( std::abs(fsten(ii_-1,jj_ ,kk_ ,ist_ppp))
3110 + std::abs(fsten(ii_-1,jj_+1,kk_ ,ist_ppp)) + eps);
3111 r += std::abs(fsten(ii_-1,jj_ ,kk_ ,ist_0pp)) /
3112 ( std::abs(fsten(ii_-2,jj_ ,kk_ ,ist_ppp))
3113 + std::abs(fsten(ii_-1,jj_ ,kk_ ,ist_ppp)) + eps);
3114 r *= std::abs(fsten(ii_-1,jj_ ,kk_ ,ist_ppp)) * fsten(ii_-1,jj_+1,kk_+1,ist_inv);
3115 return r;
3116 };
3117
3118 auto restrict_from_0pp_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
3119 Real w1m = std::abs(fsten(ii_,jj_ ,kk_+1,ist_0p0)) / (std::abs(fsten(ii_,jj_ ,kk_ ,ist_0pp))
3120 +std::abs(fsten(ii_,jj_ ,kk_+1,ist_0pp)) + eps);
3121 Real w1p = std::abs(fsten(ii_,jj_+1,kk_+1,ist_0p0)) / (std::abs(fsten(ii_,jj_+1,kk_ ,ist_0pp))
3122 +std::abs(fsten(ii_,jj_+1,kk_+1,ist_0pp)) + eps);
3123 Real w2m = std::abs(fsten(ii_,jj_+1,kk_ ,ist_00p)) / (std::abs(fsten(ii_,jj_ ,kk_ ,ist_0pp))
3124 +std::abs(fsten(ii_,jj_+1,kk_ ,ist_0pp)) + eps);
3125 Real w2p = std::abs(fsten(ii_,jj_+1,kk_+1,ist_00p)) / (std::abs(fsten(ii_,jj_ ,kk_+1,ist_0pp))
3126 +std::abs(fsten(ii_,jj_+1,kk_+1,ist_0pp)) + eps);
3127 Real wmm = std::abs(fsten(ii_,jj_ ,kk_ ,ist_0pp)) * (Real(1.) + w1m + w2m);
3128 Real wpm = std::abs(fsten(ii_,jj_+1,kk_ ,ist_0pp)) * (Real(1.) + w1p + w2m);
3129 Real wmp = std::abs(fsten(ii_,jj_ ,kk_+1,ist_0pp)) * (Real(1.) + w1m + w2p);
3130 Real wpp = std::abs(fsten(ii_,jj_+1,kk_+1,ist_0pp)) * (Real(1.) + w1p + w2p);
3131 return wmm / (wmm+wpm+wmp+wpp+eps);
3132 };
3133
3134 auto restrict_from_ppp_to = [&fsten] (int ii_, int jj_, int kk_) -> Real {
3135 Real r = Real(1.);
3136 r += std::abs(fsten(ii_ ,jj_+1,kk_+1,ist_p00)) /
3137 ( std::abs(fsten(ii_ ,jj_ ,kk_ ,ist_ppp))
3138 + std::abs(fsten(ii_ ,jj_+1,kk_ ,ist_ppp))
3139 + std::abs(fsten(ii_ ,jj_ ,kk_+1,ist_ppp))
3140 + std::abs(fsten(ii_ ,jj_+1,kk_+1,ist_ppp)) + eps);
3141 r += std::abs(fsten(ii_+1,jj_ ,kk_+1,ist_0p0)) /
3142 ( std::abs(fsten(ii_ ,jj_ ,kk_ ,ist_ppp))
3143 + std::abs(fsten(ii_+1,jj_ ,kk_ ,ist_ppp))
3144 + std::abs(fsten(ii_ ,jj_ ,kk_+1,ist_ppp))
3145 + std::abs(fsten(ii_+1,jj_ ,kk_+1,ist_ppp)) + eps);
3146 r += std::abs(fsten(ii_+1,jj_+1,kk_ ,ist_00p)) /
3147 ( std::abs(fsten(ii_ ,jj_ ,kk_ ,ist_ppp))
3148 + std::abs(fsten(ii_+1,jj_ ,kk_ ,ist_ppp))
3149 + std::abs(fsten(ii_ ,jj_+1,kk_ ,ist_ppp))
3150 + std::abs(fsten(ii_+1,jj_+1,kk_ ,ist_ppp)) + eps);
3151 r += std::abs(fsten(ii_ ,jj_ ,kk_+1,ist_pp0)) /
3152 ( std::abs(fsten(ii_ ,jj_ ,kk_ ,ist_ppp))
3153 + std::abs(fsten(ii_ ,jj_ ,kk_+1,ist_ppp)) + eps);
3154 r += std::abs(fsten(ii_ ,jj_+1,kk_ ,ist_p0p)) /
3155 ( std::abs(fsten(ii_ ,jj_ ,kk_ ,ist_ppp))
3156 + std::abs(fsten(ii_ ,jj_+1,kk_ ,ist_ppp)) + eps);
3157 r += std::abs(fsten(ii_+1,jj_ ,kk_ ,ist_0pp)) /
3158 ( std::abs(fsten(ii_ ,jj_ ,kk_ ,ist_ppp))
3159 + std::abs(fsten(ii_+1,jj_ ,kk_ ,ist_ppp)) + eps);
3160 r *= std::abs(fsten(ii_ ,jj_ ,kk_ ,ist_ppp)) * fsten(ii_+1,jj_+1,kk_+1,ist_inv);
3161 return r;
3162 };
3163
3164 int ii = 2*i;
3165 int jj = 2*j;
3166 int kk = 2*k;
3167 Array3D<Real,-1,1,-1,1,-1,1> p;
3168 Array3D<Real,-1,1,-1,1,-1,1> ap;
3169 Real cs1, cs2, cs3, cs4;
3170
3171 // csten(i,j,k,ist_p00)
3172 int iii = ii;
3173 int jjj = jj;
3174 int kkk = kk;;
3175 p(-1,-1,-1) = interp_from_ppp_to(iii+1,jjj-1,kkk-1);
3176 p( 0,-1,-1) = interp_from_0pp_to(iii+2,jjj-1,kkk-1);
3177 p(-1, 0,-1) = interp_from_p0p_to(iii+1,jjj ,kkk-1);
3178 p( 0, 0,-1) = interp_from_00p_to(iii+2,jjj ,kkk-1);
3179 p(-1,+1,-1) = interp_from_pmp_to(iii+1,jjj+1,kkk-1);
3180 p( 0,+1,-1) = interp_from_0mp_to(iii+2,jjj+1,kkk-1);
3181 p(-1,-1, 0) = interp_from_pp0_to(iii+1,jjj-1,kkk );
3182 p( 0,-1, 0) = interp_from_0p0_to(iii+2,jjj-1,kkk );
3183 p(-1, 0, 0) = interp_from_p00_to(iii+1,jjj ,kkk );
3184 p( 0, 0, 0) = Real(1.);
3185 p(-1,+1, 0) = interp_from_pm0_to(iii+1,jjj+1,kkk );
3186 p( 0,+1, 0) = interp_from_0m0_to(iii+2,jjj+1,kkk );
3187 p(-1,-1,+1) = interp_from_ppm_to(iii+1,jjj-1,kkk+1);
3188 p( 0,-1,+1) = interp_from_0pm_to(iii+2,jjj-1,kkk+1);
3189 p(-1, 0,+1) = interp_from_p0m_to(iii+1,jjj ,kkk+1);
3190 p( 0, 0,+1) = interp_from_00m_to(iii+2,jjj ,kkk+1);
3191 p(-1,+1,+1) = interp_from_pmm_to(iii+1,jjj+1,kkk+1);
3192 p( 0,+1,+1) = interp_from_0mm_to(iii+2,jjj+1,kkk+1);
3193 ap(0,-1,-1) =
3194 Ap00(iii,jjj-1,kkk-1) * p(-1,-1,-1)
3195 + App0(iii,jjj-1,kkk-1) * p(-1, 0,-1)
3196 + Ap0p(iii,jjj-1,kkk-1) * p(-1,-1, 0)
3197 + Appp(iii,jjj-1,kkk-1) * p(-1, 0, 0);
3198 ap(1,-1,-1) =
3199 A000(iii+1,jjj-1,kkk-1) * p(-1,-1,-1)
3200 + Ap00(iii+1,jjj-1,kkk-1) * p( 0,-1,-1)
3201 + A0p0(iii+1,jjj-1,kkk-1) * p(-1, 0,-1)
3202 + App0(iii+1,jjj-1,kkk-1) * p( 0, 0,-1)
3203 + A00p(iii+1,jjj-1,kkk-1) * p(-1,-1, 0)
3204 + Ap0p(iii+1,jjj-1,kkk-1) * p( 0,-1, 0)
3205 + A0pp(iii+1,jjj-1,kkk-1) * p(-1, 0, 0)
3206 + Appp(iii+1,jjj-1,kkk-1) * p( 0, 0, 0);
3207 ap(0,0,-1) =
3208 Apm0(iii,jjj,kkk-1) * p(-1,-1,-1)
3209 + Ap00(iii,jjj,kkk-1) * p(-1, 0,-1)
3210 + App0(iii,jjj,kkk-1) * p(-1,+1,-1)
3211 + Apmp(iii,jjj,kkk-1) * p(-1,-1, 0)
3212 + Ap0p(iii,jjj,kkk-1) * p(-1, 0, 0)
3213 + Appp(iii,jjj,kkk-1) * p(-1,+1, 0);
3214 ap(1,0,-1) =
3215 A0m0(iii+1,jjj,kkk-1) * p(-1,-1,-1)
3216 + Apm0(iii+1,jjj,kkk-1) * p( 0,-1,-1)
3217 + A000(iii+1,jjj,kkk-1) * p(-1, 0,-1)
3218 + Ap00(iii+1,jjj,kkk-1) * p( 0, 0,-1)
3219 + A0p0(iii+1,jjj,kkk-1) * p(-1,+1,-1)
3220 + App0(iii+1,jjj,kkk-1) * p( 0,+1,-1)
3221 + A0mp(iii+1,jjj,kkk-1) * p(-1,-1, 0)
3222 + Apmp(iii+1,jjj,kkk-1) * p( 0,-1, 0)
3223 + A00p(iii+1,jjj,kkk-1) * p(-1, 0, 0)
3224 + Ap0p(iii+1,jjj,kkk-1) * p( 0, 0, 0)
3225 + A0pp(iii+1,jjj,kkk-1) * p(-1,+1, 0)
3226 + Appp(iii+1,jjj,kkk-1) * p( 0,+1, 0);
3227 ap(0,1,-1) =
3228 Apm0(iii,jjj+1,kkk-1) * p(-1, 0,-1)
3229 + Ap00(iii,jjj+1,kkk-1) * p(-1,+1,-1)
3230 + Apmp(iii,jjj+1,kkk-1) * p(-1, 0, 0)
3231 + Ap0p(iii,jjj+1,kkk-1) * p(-1,+1, 0);
3232 ap(1,1,-1) =
3233 A0m0(iii+1,jjj+1,kkk-1) * p(-1, 0,-1)
3234 + Apm0(iii+1,jjj+1,kkk-1) * p( 0, 0,-1)
3235 + A000(iii+1,jjj+1,kkk-1) * p(-1,+1,-1)
3236 + Ap00(iii+1,jjj+1,kkk-1) * p( 0,+1,-1)
3237 + A0mp(iii+1,jjj+1,kkk-1) * p(-1, 0, 0)
3238 + Apmp(iii+1,jjj+1,kkk-1) * p( 0, 0, 0)
3239 + A00p(iii+1,jjj+1,kkk-1) * p(-1,+1, 0)
3240 + Ap0p(iii+1,jjj+1,kkk-1) * p( 0,+1, 0);
3241 ap(0,-1,0) =
3242 Ap0m(iii,jjj-1,kkk) * p(-1,-1,-1)
3243 + Appm(iii,jjj-1,kkk) * p(-1, 0,-1)
3244 + Ap00(iii,jjj-1,kkk) * p(-1,-1, 0)
3245 + App0(iii,jjj-1,kkk) * p(-1, 0, 0)
3246 + Ap0p(iii,jjj-1,kkk) * p(-1,-1,+1)
3247 + Appp(iii,jjj-1,kkk) * p(-1, 0,+1);
3248 ap(1,-1,0) =
3249 A00m(iii+1,jjj-1,kkk) * p(-1,-1,-1)
3250 + Ap0m(iii+1,jjj-1,kkk) * p( 0,-1,-1)
3251 + A0pm(iii+1,jjj-1,kkk) * p(-1, 0,-1)
3252 + Appm(iii+1,jjj-1,kkk) * p( 0, 0,-1)
3253 + A000(iii+1,jjj-1,kkk) * p(-1,-1, 0)
3254 + Ap00(iii+1,jjj-1,kkk) * p( 0,-1, 0)
3255 + A0p0(iii+1,jjj-1,kkk) * p(-1, 0, 0)
3256 + App0(iii+1,jjj-1,kkk) * p( 0, 0, 0)
3257 + A00p(iii+1,jjj-1,kkk) * p(-1,-1,+1)
3258 + Ap0p(iii+1,jjj-1,kkk) * p( 0,-1,+1)
3259 + A0pp(iii+1,jjj-1,kkk) * p(-1, 0,+1)
3260 + Appp(iii+1,jjj-1,kkk) * p( 0, 0,+1);
3261 ap(0,0,0) =
3262 Apmm(iii,jjj,kkk) * p(-1,-1,-1)
3263 + Ap0m(iii,jjj,kkk) * p(-1, 0,-1)
3264 + Appm(iii,jjj,kkk) * p(-1,+1,-1)
3265 + Apm0(iii,jjj,kkk) * p(-1,-1, 0)
3266 + Ap00(iii,jjj,kkk) * p(-1, 0, 0)
3267 + App0(iii,jjj,kkk) * p(-1,+1, 0)
3268 + Apmp(iii,jjj,kkk) * p(-1,-1,+1)
3269 + Ap0p(iii,jjj,kkk) * p(-1, 0,+1)
3270 + Appp(iii,jjj,kkk) * p(-1,+1,+1);
3271 ap(1,0,0) =
3272 A0mm(iii+1,jjj,kkk) * p(-1,-1,-1)
3273 + Apmm(iii+1,jjj,kkk) * p( 0,-1,-1)
3274 + A00m(iii+1,jjj,kkk) * p(-1, 0,-1)
3275 + Ap0m(iii+1,jjj,kkk) * p( 0, 0,-1)
3276 + A0pm(iii+1,jjj,kkk) * p(-1,+1,-1)
3277 + Appm(iii+1,jjj,kkk) * p( 0,+1,-1)
3278 + A0m0(iii+1,jjj,kkk) * p(-1,-1, 0)
3279 + Apm0(iii+1,jjj,kkk) * p( 0,-1, 0)
3280 + A000(iii+1,jjj,kkk) * p(-1, 0, 0)
3281 + Ap00(iii+1,jjj,kkk) * p( 0, 0, 0)
3282 + A0p0(iii+1,jjj,kkk) * p(-1,+1, 0)
3283 + App0(iii+1,jjj,kkk) * p( 0,+1, 0)
3284 + A0mp(iii+1,jjj,kkk) * p(-1,-1,+1)
3285 + Apmp(iii+1,jjj,kkk) * p( 0,-1,+1)
3286 + A00p(iii+1,jjj,kkk) * p(-1, 0,+1)
3287 + Ap0p(iii+1,jjj,kkk) * p( 0, 0,+1)
3288 + A0pp(iii+1,jjj,kkk) * p(-1,+1,+1)
3289 + Appp(iii+1,jjj,kkk) * p( 0,+1,+1);
3290 ap(0,1,0) =
3291 Apmm(iii,jjj+1,kkk) * p(-1, 0,-1)
3292 + Ap0m(iii,jjj+1,kkk) * p(-1,+1,-1)
3293 + Apm0(iii,jjj+1,kkk) * p(-1, 0, 0)
3294 + Ap00(iii,jjj+1,kkk) * p(-1,+1, 0)
3295 + Apmp(iii,jjj+1,kkk) * p(-1, 0,+1)
3296 + Ap0p(iii,jjj+1,kkk) * p(-1,+1,+1);
3297 ap(1,1,0) =
3298 A0mm(iii+1,jjj+1,kkk) * p(-1, 0,-1)
3299 + Apmm(iii+1,jjj+1,kkk) * p( 0, 0,-1)
3300 + A00m(iii+1,jjj+1,kkk) * p(-1,+1,-1)
3301 + Ap0m(iii+1,jjj+1,kkk) * p( 0,+1,-1)
3302 + A0m0(iii+1,jjj+1,kkk) * p(-1, 0, 0)
3303 + Apm0(iii+1,jjj+1,kkk) * p( 0, 0, 0)
3304 + A000(iii+1,jjj+1,kkk) * p(-1,+1, 0)
3305 + Ap00(iii+1,jjj+1,kkk) * p( 0,+1, 0)
3306 + A0mp(iii+1,jjj+1,kkk) * p(-1, 0,+1)
3307 + Apmp(iii+1,jjj+1,kkk) * p( 0, 0,+1)
3308 + A00p(iii+1,jjj+1,kkk) * p(-1,+1,+1)
3309 + Ap0p(iii+1,jjj+1,kkk) * p( 0,+1,+1);
3310 ap(0,-1,1) =
3311 Ap0m(iii,jjj-1,kkk+1) * p(-1,-1, 0)
3312 + Appm(iii,jjj-1,kkk+1) * p(-1, 0, 0)
3313 + Ap00(iii,jjj-1,kkk+1) * p(-1,-1,+1)
3314 + App0(iii,jjj-1,kkk+1) * p(-1, 0,+1);
3315 ap(1,-1,1) =
3316 A00m(iii+1,jjj-1,kkk+1) * p(-1,-1, 0)
3317 + Ap0m(iii+1,jjj-1,kkk+1) * p( 0,-1, 0)
3318 + A0pm(iii+1,jjj-1,kkk+1) * p(-1, 0, 0)
3319 + Appm(iii+1,jjj-1,kkk+1) * p( 0, 0, 0)
3320 + A000(iii+1,jjj-1,kkk+1) * p(-1,-1,+1)
3321 + Ap00(iii+1,jjj-1,kkk+1) * p( 0,-1,+1)
3322 + A0p0(iii+1,jjj-1,kkk+1) * p(-1, 0,+1)
3323 + App0(iii+1,jjj-1,kkk+1) * p( 0, 0,+1);
3324 ap(0,0,1) =
3325 Apmm(iii,jjj,kkk+1) * p(-1,-1, 0)
3326 + Ap0m(iii,jjj,kkk+1) * p(-1, 0, 0)
3327 + Appm(iii,jjj,kkk+1) * p(-1,+1, 0)
3328 + Apm0(iii,jjj,kkk+1) * p(-1,-1,+1)
3329 + Ap00(iii,jjj,kkk+1) * p(-1, 0,+1)
3330 + App0(iii,jjj,kkk+1) * p(-1,+1,+1);
3331 ap(1,0,1) =
3332 A0mm(iii+1,jjj,kkk+1) * p(-1,-1, 0)
3333 + Apmm(iii+1,jjj,kkk+1) * p( 0,-1, 0)
3334 + A00m(iii+1,jjj,kkk+1) * p(-1, 0, 0)
3335 + Ap0m(iii+1,jjj,kkk+1) * p( 0, 0, 0)
3336 + A0pm(iii+1,jjj,kkk+1) * p(-1,+1, 0)
3337 + Appm(iii+1,jjj,kkk+1) * p( 0,+1, 0)
3338 + A0m0(iii+1,jjj,kkk+1) * p(-1,-1,+1)
3339 + Apm0(iii+1,jjj,kkk+1) * p( 0,-1,+1)
3340 + A000(iii+1,jjj,kkk+1) * p(-1, 0,+1)
3341 + Ap00(iii+1,jjj,kkk+1) * p( 0, 0,+1)
3342 + A0p0(iii+1,jjj,kkk+1) * p(-1,+1,+1)
3343 + App0(iii+1,jjj,kkk+1) * p( 0,+1,+1);
3344 ap(0,1,1) =
3345 Apmm(iii,jjj+1,kkk+1) * p(-1, 0, 0)
3346 + Ap0m(iii,jjj+1,kkk+1) * p(-1,+1, 0)
3347 + Apm0(iii,jjj+1,kkk+1) * p(-1, 0,+1)
3348 + Ap00(iii,jjj+1,kkk+1) * p(-1,+1,+1);
3349 ap(1,1,1) =
3350 A0mm(iii+1,jjj+1,kkk+1) * p(-1, 0, 0)
3351 + Apmm(iii+1,jjj+1,kkk+1) * p( 0, 0, 0)
3352 + A00m(iii+1,jjj+1,kkk+1) * p(-1,+1, 0)
3353 + Ap0m(iii+1,jjj+1,kkk+1) * p( 0,+1, 0)
3354 + A0m0(iii+1,jjj+1,kkk+1) * p(-1, 0,+1)
3355 + Apm0(iii+1,jjj+1,kkk+1) * p( 0, 0,+1)
3356 + A000(iii+1,jjj+1,kkk+1) * p(-1,+1,+1)
3357 + Ap00(iii+1,jjj+1,kkk+1) * p( 0,+1,+1);
3358 csten(i,j,k,ist_p00) = Real(0.125) *
3359 ( restrict_from_0mm_to(iii,jjj,kkk) * ap( 0,-1,-1)
3360 + restrict_from_pmm_to(iii,jjj,kkk) * ap(+1,-1,-1)
3361 + restrict_from_00m_to(iii,jjj,kkk) * ap( 0, 0,-1)
3362 + restrict_from_p0m_to(iii,jjj,kkk) * ap(+1, 0,-1)
3363 + restrict_from_0pm_to(iii,jjj,kkk) * ap( 0,+1,-1)
3364 + restrict_from_ppm_to(iii,jjj,kkk) * ap(+1,+1,-1)
3365 + restrict_from_0m0_to(iii,jjj,kkk) * ap( 0,-1, 0)
3366 + restrict_from_pm0_to(iii,jjj,kkk) * ap(+1,-1, 0)
3367 + restrict_from_000_to(iii,jjj,kkk) * ap( 0, 0, 0)
3368 + restrict_from_p00_to(iii,jjj,kkk) * ap(+1, 0, 0)
3369 + restrict_from_0p0_to(iii,jjj,kkk) * ap( 0,+1, 0)
3370 + restrict_from_pp0_to(iii,jjj,kkk) * ap(+1,+1, 0)
3371 + restrict_from_0mp_to(iii,jjj,kkk) * ap( 0,-1,+1)
3372 + restrict_from_pmp_to(iii,jjj,kkk) * ap(+1,-1,+1)
3373 + restrict_from_00p_to(iii,jjj,kkk) * ap( 0, 0,+1)
3374 + restrict_from_p0p_to(iii,jjj,kkk) * ap(+1, 0,+1)
3375 + restrict_from_0pp_to(iii,jjj,kkk) * ap( 0,+1,+1)
3376 + restrict_from_ppp_to(iii,jjj,kkk) * ap(+1,+1,+1));
3377
3378 // csten(i,j,k,ist_0p0)
3379 iii = ii;
3380 jjj = jj;
3381 kkk = kk;
3382 p(-1,-1,-1) = interp_from_ppp_to(iii-1,jjj+1,kkk-1);
3383 p( 0,-1,-1) = interp_from_0pp_to(iii ,jjj+1,kkk-1);
3384 p(+1,-1,-1) = interp_from_mpp_to(iii+1,jjj+1,kkk-1);
3385 p(-1, 0,-1) = interp_from_p0p_to(iii-1,jjj+2,kkk-1);
3386 p( 0, 0,-1) = interp_from_00p_to(iii ,jjj+2,kkk-1);
3387 p(+1, 0,-1) = interp_from_m0p_to(iii+1,jjj+2,kkk-1);
3388 p(-1,-1, 0) = interp_from_pp0_to(iii-1,jjj+1,kkk );
3389 p( 0,-1, 0) = interp_from_0p0_to(iii ,jjj+1,kkk );
3390 p(+1,-1, 0) = interp_from_mp0_to(iii+1,jjj+1,kkk );
3391 p(-1, 0, 0) = interp_from_p00_to(iii-1,jjj+2,kkk );
3392 p( 0, 0, 0) = Real(1.);
3393 p(+1, 0, 0) = interp_from_m00_to(iii+1,jjj+2,kkk );
3394 p(-1,-1,+1) = interp_from_ppm_to(iii-1,jjj+1,kkk+1);
3395 p( 0,-1,+1) = interp_from_0pm_to(iii ,jjj+1,kkk+1);
3396 p(+1,-1,+1) = interp_from_mpm_to(iii+1,jjj+1,kkk+1);
3397 p(-1, 0,+1) = interp_from_p0m_to(iii-1,jjj+2,kkk+1);
3398 p( 0, 0,+1) = interp_from_00m_to(iii ,jjj+2,kkk+1);
3399 p(+1, 0,+1) = interp_from_m0m_to(iii+1,jjj+2,kkk+1);
3400 ap(-1,0,-1) =
3401 A0p0(iii-1,jjj,kkk-1) * p(-1,-1,-1)
3402 + App0(iii-1,jjj,kkk-1) * p( 0,-1,-1)
3403 + A0pp(iii-1,jjj,kkk-1) * p(-1,-1, 0)
3404 + Appp(iii-1,jjj,kkk-1) * p( 0,-1, 0);
3405 ap(0,0,-1) =
3406 Amp0(iii,jjj,kkk-1) * p(-1,-1,-1)
3407 + A0p0(iii,jjj,kkk-1) * p( 0,-1,-1)
3408 + App0(iii,jjj,kkk-1) * p(+1,-1,-1)
3409 + Ampp(iii,jjj,kkk-1) * p(-1,-1, 0)
3410 + A0pp(iii,jjj,kkk-1) * p( 0,-1, 0)
3411 + Appp(iii,jjj,kkk-1) * p(+1,-1, 0);
3412 ap(1,0,-1) =
3413 Amp0(iii+1,jjj,kkk-1) * p( 0,-1,-1)
3414 + A0p0(iii+1,jjj,kkk-1) * p(+1,-1,-1)
3415 + Ampp(iii+1,jjj,kkk-1) * p( 0,-1, 0)
3416 + A0pp(iii+1,jjj,kkk-1) * p(+1,-1, 0);
3417 ap(-1,1,-1) =
3418 A000(iii-1,jjj+1,kkk-1) * p(-1,-1,-1)
3419 + Ap00(iii-1,jjj+1,kkk-1) * p( 0,-1,-1)
3420 + A0p0(iii-1,jjj+1,kkk-1) * p(-1, 0,-1)
3421 + App0(iii-1,jjj+1,kkk-1) * p( 0, 0,-1)
3422 + A00p(iii-1,jjj+1,kkk-1) * p(-1,-1, 0)
3423 + Ap0p(iii-1,jjj+1,kkk-1) * p( 0,-1, 0)
3424 + A0pp(iii-1,jjj+1,kkk-1) * p(-1, 0, 0)
3425 + Appp(iii-1,jjj+1,kkk-1) * p( 0, 0, 0);
3426 ap(0,1,-1) =
3427 Am00(iii,jjj+1,kkk-1) * p(-1,-1,-1)
3428 + A000(iii,jjj+1,kkk-1) * p( 0,-1,-1)
3429 + Ap00(iii,jjj+1,kkk-1) * p(+1,-1,-1)
3430 + Amp0(iii,jjj+1,kkk-1) * p(-1, 0,-1)
3431 + A0p0(iii,jjj+1,kkk-1) * p( 0, 0,-1)
3432 + App0(iii,jjj+1,kkk-1) * p(+1, 0,-1)
3433 + Am0p(iii,jjj+1,kkk-1) * p(-1,-1, 0)
3434 + A00p(iii,jjj+1,kkk-1) * p( 0,-1, 0)
3435 + Ap0p(iii,jjj+1,kkk-1) * p(+1,-1, 0)
3436 + Ampp(iii,jjj+1,kkk-1) * p(-1, 0, 0)
3437 + A0pp(iii,jjj+1,kkk-1) * p( 0, 0, 0)
3438 + Appp(iii,jjj+1,kkk-1) * p(+1, 0, 0);
3439 ap(1,1,-1) =
3440 Am00(iii+1,jjj+1,kkk-1) * p( 0,-1,-1)
3441 + A000(iii+1,jjj+1,kkk-1) * p(+1,-1,-1)
3442 + Amp0(iii+1,jjj+1,kkk-1) * p( 0, 0,-1)
3443 + A0p0(iii+1,jjj+1,kkk-1) * p(+1, 0,-1)
3444 + Am0p(iii+1,jjj+1,kkk-1) * p( 0,-1, 0)
3445 + A00p(iii+1,jjj+1,kkk-1) * p(+1,-1, 0)
3446 + Ampp(iii+1,jjj+1,kkk-1) * p( 0, 0, 0)
3447 + A0pp(iii+1,jjj+1,kkk-1) * p(+1, 0, 0);
3448 ap(-1,0,0) =
3449 A0pm(iii-1,jjj,kkk) * p(-1,-1,-1)
3450 + Appm(iii-1,jjj,kkk) * p( 0,-1,-1)
3451 + A0p0(iii-1,jjj,kkk) * p(-1,-1, 0)
3452 + App0(iii-1,jjj,kkk) * p( 0,-1, 0)
3453 + A0pp(iii-1,jjj,kkk) * p(-1,-1,+1)
3454 + Appp(iii-1,jjj,kkk) * p( 0,-1,+1);
3455 ap(0,0,0) =
3456 Ampm(iii,jjj,kkk) * p(-1,-1,-1)
3457 + A0pm(iii,jjj,kkk) * p( 0,-1,-1)
3458 + Appm(iii,jjj,kkk) * p(+1,-1,-1)
3459 + Amp0(iii,jjj,kkk) * p(-1,-1, 0)
3460 + A0p0(iii,jjj,kkk) * p( 0,-1, 0)
3461 + App0(iii,jjj,kkk) * p(+1,-1, 0)
3462 + Ampp(iii,jjj,kkk) * p(-1,-1,+1)
3463 + A0pp(iii,jjj,kkk) * p( 0,-1,+1)
3464 + Appp(iii,jjj,kkk) * p(+1,-1,+1);
3465 ap(1,0,0) =
3466 Ampm(iii+1,jjj,kkk) * p( 0,-1,-1)
3467 + A0pm(iii+1,jjj,kkk) * p(+1,-1,-1)
3468 + Amp0(iii+1,jjj,kkk) * p( 0,-1, 0)
3469 + A0p0(iii+1,jjj,kkk) * p(+1,-1, 0)
3470 + Ampp(iii+1,jjj,kkk) * p( 0,-1,+1)
3471 + A0pp(iii+1,jjj,kkk) * p(+1,-1,+1);
3472 ap(-1,1,0) =
3473 A00m(iii-1,jjj+1,kkk) * p(-1,-1,-1)
3474 + Ap0m(iii-1,jjj+1,kkk) * p( 0,-1,-1)
3475 + A0pm(iii-1,jjj+1,kkk) * p(-1, 0,-1)
3476 + Appm(iii-1,jjj+1,kkk) * p( 0, 0,-1)
3477 + A000(iii-1,jjj+1,kkk) * p(-1,-1, 0)
3478 + Ap00(iii-1,jjj+1,kkk) * p( 0,-1, 0)
3479 + A0p0(iii-1,jjj+1,kkk) * p(-1, 0, 0)
3480 + App0(iii-1,jjj+1,kkk) * p( 0, 0, 0)
3481 + A00p(iii-1,jjj+1,kkk) * p(-1,-1,+1)
3482 + Ap0p(iii-1,jjj+1,kkk) * p( 0,-1,+1)
3483 + A0pp(iii-1,jjj+1,kkk) * p(-1, 0,+1)
3484 + Appp(iii-1,jjj+1,kkk) * p( 0, 0,+1);
3485 ap(0,1,0) =
3486 Am0m(iii,jjj+1,kkk) * p(-1,-1,-1)
3487 + A00m(iii,jjj+1,kkk) * p( 0,-1,-1)
3488 + Ap0m(iii,jjj+1,kkk) * p(+1,-1,-1)
3489 + Ampm(iii,jjj+1,kkk) * p(-1, 0,-1)
3490 + A0pm(iii,jjj+1,kkk) * p( 0, 0,-1)
3491 + Appm(iii,jjj+1,kkk) * p(+1, 0,-1)
3492 + Am00(iii,jjj+1,kkk) * p(-1,-1, 0)
3493 + A000(iii,jjj+1,kkk) * p( 0,-1, 0)
3494 + Ap00(iii,jjj+1,kkk) * p(+1,-1, 0)
3495 + Amp0(iii,jjj+1,kkk) * p(-1, 0, 0)
3496 + A0p0(iii,jjj+1,kkk) * p( 0, 0, 0)
3497 + App0(iii,jjj+1,kkk) * p(+1, 0, 0)
3498 + Am0p(iii,jjj+1,kkk) * p(-1,-1,+1)
3499 + A00p(iii,jjj+1,kkk) * p( 0,-1,+1)
3500 + Ap0p(iii,jjj+1,kkk) * p(+1,-1,+1)
3501 + Ampp(iii,jjj+1,kkk) * p(-1, 0,+1)
3502 + A0pp(iii,jjj+1,kkk) * p( 0, 0,+1)
3503 + Appp(iii,jjj+1,kkk) * p(+1, 0,+1);
3504 ap(1,1,0) =
3505 Am0m(iii+1,jjj+1,kkk) * p( 0,-1,-1)
3506 + A00m(iii+1,jjj+1,kkk) * p(+1,-1,-1)
3507 + Ampm(iii+1,jjj+1,kkk) * p( 0, 0,-1)
3508 + A0pm(iii+1,jjj+1,kkk) * p(+1, 0,-1)
3509 + Am00(iii+1,jjj+1,kkk) * p( 0,-1, 0)
3510 + A000(iii+1,jjj+1,kkk) * p(+1,-1, 0)
3511 + Amp0(iii+1,jjj+1,kkk) * p( 0, 0, 0)
3512 + A0p0(iii+1,jjj+1,kkk) * p(+1, 0, 0)
3513 + Am0p(iii+1,jjj+1,kkk) * p( 0,-1,+1)
3514 + A00p(iii+1,jjj+1,kkk) * p(+1,-1,+1)
3515 + Ampp(iii+1,jjj+1,kkk) * p( 0, 0,+1)
3516 + A0pp(iii+1,jjj+1,kkk) * p(+1, 0,+1);
3517 ap(-1,0,1) =
3518 A0pm(iii-1,jjj,kkk+1) * p(-1,-1, 0)
3519 + Appm(iii-1,jjj,kkk+1) * p( 0,-1, 0)
3520 + A0p0(iii-1,jjj,kkk+1) * p(-1,-1,+1)
3521 + App0(iii-1,jjj,kkk+1) * p( 0,-1,+1);
3522 ap(0,0,1) =
3523 Ampm(iii,jjj,kkk+1) * p(-1,-1, 0)
3524 + A0pm(iii,jjj,kkk+1) * p( 0,-1, 0)
3525 + Appm(iii,jjj,kkk+1) * p(+1,-1, 0)
3526 + Amp0(iii,jjj,kkk+1) * p(-1,-1,+1)
3527 + A0p0(iii,jjj,kkk+1) * p( 0,-1,+1)
3528 + App0(iii,jjj,kkk+1) * p(+1,-1,+1);
3529 ap(1,0,1) =
3530 Ampm(iii+1,jjj,kkk+1) * p( 0,-1, 0)
3531 + A0pm(iii+1,jjj,kkk+1) * p(+1,-1, 0)
3532 + Amp0(iii+1,jjj,kkk+1) * p( 0,-1,+1)
3533 + A0p0(iii+1,jjj,kkk+1) * p(+1,-1,+1);
3534 ap(-1,1,1) =
3535 A00m(iii-1,jjj+1,kkk+1) * p(-1,-1, 0)
3536 + Ap0m(iii-1,jjj+1,kkk+1) * p( 0,-1, 0)
3537 + A0pm(iii-1,jjj+1,kkk+1) * p(-1, 0, 0)
3538 + Appm(iii-1,jjj+1,kkk+1) * p( 0, 0, 0)
3539 + A000(iii-1,jjj+1,kkk+1) * p(-1,-1,+1)
3540 + Ap00(iii-1,jjj+1,kkk+1) * p( 0,-1,+1)
3541 + A0p0(iii-1,jjj+1,kkk+1) * p(-1, 0,+1)
3542 + App0(iii-1,jjj+1,kkk+1) * p( 0, 0,+1);
3543 ap(0,1,1) =
3544 Am0m(iii,jjj+1,kkk+1) * p(-1,-1, 0)
3545 + A00m(iii,jjj+1,kkk+1) * p( 0,-1, 0)
3546 + Ap0m(iii,jjj+1,kkk+1) * p(+1,-1, 0)
3547 + Ampm(iii,jjj+1,kkk+1) * p(-1, 0, 0)
3548 + A0pm(iii,jjj+1,kkk+1) * p( 0, 0, 0)
3549 + Appm(iii,jjj+1,kkk+1) * p(+1, 0, 0)
3550 + Am00(iii,jjj+1,kkk+1) * p(-1,-1,+1)
3551 + A000(iii,jjj+1,kkk+1) * p( 0,-1,+1)
3552 + Ap00(iii,jjj+1,kkk+1) * p(+1,-1,+1)
3553 + Amp0(iii,jjj+1,kkk+1) * p(-1, 0,+1)
3554 + A0p0(iii,jjj+1,kkk+1) * p( 0, 0,+1)
3555 + App0(iii,jjj+1,kkk+1) * p(+1, 0,+1);
3556 ap(1,1,1) =
3557 Am0m(iii+1,jjj+1,kkk+1) * p( 0,-1, 0)
3558 + A00m(iii+1,jjj+1,kkk+1) * p(+1,-1, 0)
3559 + Ampm(iii+1,jjj+1,kkk+1) * p( 0, 0, 0)
3560 + A0pm(iii+1,jjj+1,kkk+1) * p(+1, 0, 0)
3561 + Am00(iii+1,jjj+1,kkk+1) * p( 0,-1,+1)
3562 + A000(iii+1,jjj+1,kkk+1) * p(+1,-1,+1)
3563 + Amp0(iii+1,jjj+1,kkk+1) * p( 0, 0,+1)
3564 + A0p0(iii+1,jjj+1,kkk+1) * p(+1, 0,+1);
3565 csten(i,j,k,ist_0p0) = Real(0.125) *
3566 ( restrict_from_m0m_to(iii,jjj,kkk) * ap(-1, 0,-1)
3567 + restrict_from_00m_to(iii,jjj,kkk) * ap( 0, 0,-1)
3568 + restrict_from_p0m_to(iii,jjj,kkk) * ap(+1, 0,-1)
3569 + restrict_from_mpm_to(iii,jjj,kkk) * ap(-1,+1,-1)
3570 + restrict_from_0pm_to(iii,jjj,kkk) * ap( 0,+1,-1)
3571 + restrict_from_ppm_to(iii,jjj,kkk) * ap(+1,+1,-1)
3572 + restrict_from_m00_to(iii,jjj,kkk) * ap(-1, 0, 0)
3573 + restrict_from_000_to(iii,jjj,kkk) * ap( 0, 0, 0)
3574 + restrict_from_p00_to(iii,jjj,kkk) * ap(+1, 0, 0)
3575 + restrict_from_mp0_to(iii,jjj,kkk) * ap(-1,+1, 0)
3576 + restrict_from_0p0_to(iii,jjj,kkk) * ap( 0,+1, 0)
3577 + restrict_from_pp0_to(iii,jjj,kkk) * ap(+1,+1, 0)
3578 + restrict_from_m0p_to(iii,jjj,kkk) * ap(-1, 0,+1)
3579 + restrict_from_00p_to(iii,jjj,kkk) * ap( 0, 0,+1)
3580 + restrict_from_p0p_to(iii,jjj,kkk) * ap(+1, 0,+1)
3581 + restrict_from_mpp_to(iii,jjj,kkk) * ap(-1,+1,+1)
3582 + restrict_from_0pp_to(iii,jjj,kkk) * ap( 0,+1,+1)
3583 + restrict_from_ppp_to(iii,jjj,kkk) * ap(+1,+1,+1));
3584
3585 // csten(i,j,k,ist_00p)
3586 iii = ii;
3587 jjj = jj;
3588 kkk = kk;
3589 p(-1,-1,-1) = interp_from_ppp_to(iii-1,jjj-1,kkk+1);
3590 p( 0,-1,-1) = interp_from_0pp_to(iii ,jjj-1,kkk+1);
3591 p(+1,-1,-1) = interp_from_mpp_to(iii+1,jjj-1,kkk+1);
3592 p(-1, 0,-1) = interp_from_p0p_to(iii-1,jjj ,kkk+1);
3593 p( 0, 0,-1) = interp_from_00p_to(iii ,jjj ,kkk+1);
3594 p(+1, 0,-1) = interp_from_m0p_to(iii+1,jjj ,kkk+1);
3595 p(-1,+1,-1) = interp_from_pmp_to(iii-1,jjj+1,kkk+1);
3596 p( 0,+1,-1) = interp_from_0mp_to(iii ,jjj+1,kkk+1);
3597 p(+1,+1,-1) = interp_from_mmp_to(iii+1,jjj+1,kkk+1);
3598 p(-1,-1, 0) = interp_from_pp0_to(iii-1,jjj-1,kkk+2);
3599 p( 0,-1, 0) = interp_from_0p0_to(iii ,jjj-1,kkk+2);
3600 p(+1,-1, 0) = interp_from_mp0_to(iii+1,jjj-1,kkk+2);
3601 p(-1, 0, 0) = interp_from_p00_to(iii-1,jjj ,kkk+2);
3602 p( 0, 0, 0) = Real(1.);
3603 p(+1, 0, 0) = interp_from_m00_to(iii+1,jjj ,kkk+2);
3604 p(-1,+1, 0) = interp_from_pm0_to(iii-1,jjj+1,kkk+2);
3605 p( 0,+1, 0) = interp_from_0m0_to(iii ,jjj+1,kkk+2);
3606 p(+1,+1, 0) = interp_from_mm0_to(iii+1,jjj+1,kkk+2);
3607 ap(-1,-1,0) =
3608 A00p(iii-1,jjj-1,kkk) * p(-1,-1,-1)
3609 + Ap0p(iii-1,jjj-1,kkk) * p( 0,-1,-1)
3610 + A0pp(iii-1,jjj-1,kkk) * p(-1, 0,-1)
3611 + Appp(iii-1,jjj-1,kkk) * p( 0, 0,-1);
3612 ap(0,-1,0) =
3613 Am0p(iii,jjj-1,kkk) * p(-1,-1,-1)
3614 + A00p(iii,jjj-1,kkk) * p( 0,-1,-1)
3615 + Ap0p(iii,jjj-1,kkk) * p(+1,-1,-1)
3616 + Ampp(iii,jjj-1,kkk) * p(-1, 0,-1)
3617 + A0pp(iii,jjj-1,kkk) * p( 0, 0,-1)
3618 + Appp(iii,jjj-1,kkk) * p(+1, 0,-1);
3619 ap(1,-1,0) =
3620 Am0p(iii+1,jjj-1,kkk) * p( 0,-1,-1)
3621 + A00p(iii+1,jjj-1,kkk) * p(+1,-1,-1)
3622 + Ampp(iii+1,jjj-1,kkk) * p( 0, 0,-1)
3623 + A0pp(iii+1,jjj-1,kkk) * p(+1, 0,-1);
3624 ap(-1,0,0) =
3625 A0mp(iii-1,jjj,kkk) * p(-1,-1,-1)
3626 + Apmp(iii-1,jjj,kkk) * p( 0,-1,-1)
3627 + A00p(iii-1,jjj,kkk) * p(-1, 0,-1)
3628 + Ap0p(iii-1,jjj,kkk) * p( 0, 0,-1)
3629 + A0pp(iii-1,jjj,kkk) * p(-1,+1,-1)
3630 + Appp(iii-1,jjj,kkk) * p( 0,+1,-1);
3631 ap(0,0,0) =
3632 Ammp(iii,jjj,kkk) * p(-1,-1,-1)
3633 + A0mp(iii,jjj,kkk) * p( 0,-1,-1)
3634 + Apmp(iii,jjj,kkk) * p(+1,-1,-1)
3635 + Am0p(iii,jjj,kkk) * p(-1, 0,-1)
3636 + A00p(iii,jjj,kkk) * p( 0, 0,-1)
3637 + Ap0p(iii,jjj,kkk) * p(+1, 0,-1)
3638 + Ampp(iii,jjj,kkk) * p(-1,+1,-1)
3639 + A0pp(iii,jjj,kkk) * p( 0,+1,-1)
3640 + Appp(iii,jjj,kkk) * p(+1,+1,-1);
3641 ap(1,0,0) =
3642 Ammp(iii+1,jjj,kkk) * p( 0,-1,-1)
3643 + A0mp(iii+1,jjj,kkk) * p(+1,-1,-1)
3644 + Am0p(iii+1,jjj,kkk) * p( 0, 0,-1)
3645 + A00p(iii+1,jjj,kkk) * p(+1, 0,-1)
3646 + Ampp(iii+1,jjj,kkk) * p( 0,+1,-1)
3647 + A0pp(iii+1,jjj,kkk) * p(+1,+1,-1);
3648 ap(-1,1,0) =
3649 A0mp(iii-1,jjj+1,kkk) * p(-1, 0,-1)
3650 + Apmp(iii-1,jjj+1,kkk) * p( 0, 0,-1)
3651 + A00p(iii-1,jjj+1,kkk) * p(-1,+1,-1)
3652 + Ap0p(iii-1,jjj+1,kkk) * p( 0,+1,-1);
3653 ap(0,1,0) =
3654 Ammp(iii,jjj+1,kkk) * p(-1, 0,-1)
3655 + A0mp(iii,jjj+1,kkk) * p( 0, 0,-1)
3656 + Apmp(iii,jjj+1,kkk) * p(+1, 0,-1)
3657 + Am0p(iii,jjj+1,kkk) * p(-1,+1,-1)
3658 + A00p(iii,jjj+1,kkk) * p( 0,+1,-1)
3659 + Ap0p(iii,jjj+1,kkk) * p(+1,+1,-1);
3660 ap(1,1,0) =
3661 Ammp(iii+1,jjj+1,kkk) * p( 0, 0,-1)
3662 + A0mp(iii+1,jjj+1,kkk) * p(+1, 0,-1)
3663 + Am0p(iii+1,jjj+1,kkk) * p( 0,+1,-1)
3664 + A00p(iii+1,jjj+1,kkk) * p(+1,+1,-1);
3665 ap(-1,-1,1) =
3666 A000(iii-1,jjj-1,kkk+1) * p(-1,-1,-1)
3667 + Ap00(iii-1,jjj-1,kkk+1) * p( 0,-1,-1)
3668 + A0p0(iii-1,jjj-1,kkk+1) * p(-1, 0,-1)
3669 + App0(iii-1,jjj-1,kkk+1) * p( 0, 0,-1)
3670 + A00p(iii-1,jjj-1,kkk+1) * p(-1,-1, 0)
3671 + Ap0p(iii-1,jjj-1,kkk+1) * p( 0,-1, 0)
3672 + A0pp(iii-1,jjj-1,kkk+1) * p(-1, 0, 0)
3673 + Appp(iii-1,jjj-1,kkk+1) * p( 0, 0, 0);
3674 ap(0,-1,1) =
3675 Am00(iii,jjj-1,kkk+1) * p(-1,-1,-1)
3676 + A000(iii,jjj-1,kkk+1) * p( 0,-1,-1)
3677 + Ap00(iii,jjj-1,kkk+1) * p(+1,-1,-1)
3678 + Amp0(iii,jjj-1,kkk+1) * p(-1, 0,-1)
3679 + A0p0(iii,jjj-1,kkk+1) * p( 0, 0,-1)
3680 + App0(iii,jjj-1,kkk+1) * p(+1, 0,-1)
3681 + Am0p(iii,jjj-1,kkk+1) * p(-1,-1, 0)
3682 + A00p(iii,jjj-1,kkk+1) * p( 0,-1, 0)
3683 + Ap0p(iii,jjj-1,kkk+1) * p(+1,-1, 0)
3684 + Ampp(iii,jjj-1,kkk+1) * p(-1, 0, 0)
3685 + A0pp(iii,jjj-1,kkk+1) * p( 0, 0, 0)
3686 + Appp(iii,jjj-1,kkk+1) * p(+1, 0, 0);
3687 ap(1,-1,1) =
3688 Am00(iii+1,jjj-1,kkk+1) * p( 0,-1,-1)
3689 + A000(iii+1,jjj-1,kkk+1) * p(+1,-1,-1)
3690 + Amp0(iii+1,jjj-1,kkk+1) * p( 0, 0,-1)
3691 + A0p0(iii+1,jjj-1,kkk+1) * p(+1, 0,-1)
3692 + Am0p(iii+1,jjj-1,kkk+1) * p( 0,-1, 0)
3693 + A00p(iii+1,jjj-1,kkk+1) * p(+1,-1, 0)
3694 + Ampp(iii+1,jjj-1,kkk+1) * p( 0, 0, 0)
3695 + A0pp(iii+1,jjj-1,kkk+1) * p(+1, 0, 0);
3696 ap(-1,0,1) =
3697 A0m0(iii-1,jjj,kkk+1) * p(-1,-1,-1)
3698 + Apm0(iii-1,jjj,kkk+1) * p( 0,-1,-1)
3699 + A000(iii-1,jjj,kkk+1) * p(-1, 0,-1)
3700 + Ap00(iii-1,jjj,kkk+1) * p( 0, 0,-1)
3701 + A0p0(iii-1,jjj,kkk+1) * p(-1,+1,-1)
3702 + App0(iii-1,jjj,kkk+1) * p( 0,+1,-1)
3703 + A0mp(iii-1,jjj,kkk+1) * p(-1,-1, 0)
3704 + Apmp(iii-1,jjj,kkk+1) * p( 0,-1, 0)
3705 + A00p(iii-1,jjj,kkk+1) * p(-1, 0, 0)
3706 + Ap0p(iii-1,jjj,kkk+1) * p( 0, 0, 0)
3707 + A0pp(iii-1,jjj,kkk+1) * p(-1,+1, 0)
3708 + Appp(iii-1,jjj,kkk+1) * p( 0,+1, 0);
3709 ap(0,0,1) =
3710 Amm0(iii,jjj,kkk+1) * p(-1,-1,-1)
3711 + A0m0(iii,jjj,kkk+1) * p( 0,-1,-1)
3712 + Apm0(iii,jjj,kkk+1) * p(+1,-1,-1)
3713 + Am00(iii,jjj,kkk+1) * p(-1, 0,-1)
3714 + A000(iii,jjj,kkk+1) * p( 0, 0,-1)
3715 + Ap00(iii,jjj,kkk+1) * p(+1, 0,-1)
3716 + Amp0(iii,jjj,kkk+1) * p(-1,+1,-1)
3717 + A0p0(iii,jjj,kkk+1) * p( 0,+1,-1)
3718 + App0(iii,jjj,kkk+1) * p(+1,+1,-1)
3719 + Ammp(iii,jjj,kkk+1) * p(-1,-1, 0)
3720 + A0mp(iii,jjj,kkk+1) * p( 0,-1, 0)
3721 + Apmp(iii,jjj,kkk+1) * p(+1,-1, 0)
3722 + Am0p(iii,jjj,kkk+1) * p(-1, 0, 0)
3723 + A00p(iii,jjj,kkk+1) * p( 0, 0, 0)
3724 + Ap0p(iii,jjj,kkk+1) * p(+1, 0, 0)
3725 + Ampp(iii,jjj,kkk+1) * p(-1,+1, 0)
3726 + A0pp(iii,jjj,kkk+1) * p( 0,+1, 0)
3727 + Appp(iii,jjj,kkk+1) * p(+1,+1, 0);
3728 ap(1,0,1) =
3729 Amm0(iii+1,jjj,kkk+1) * p( 0,-1,-1)
3730 + A0m0(iii+1,jjj,kkk+1) * p(+1,-1,-1)
3731 + Am00(iii+1,jjj,kkk+1) * p( 0, 0,-1)
3732 + A000(iii+1,jjj,kkk+1) * p(+1, 0,-1)
3733 + Amp0(iii+1,jjj,kkk+1) * p( 0,+1,-1)
3734 + A0p0(iii+1,jjj,kkk+1) * p(+1,+1,-1)
3735 + Ammp(iii+1,jjj,kkk+1) * p( 0,-1, 0)
3736 + A0mp(iii+1,jjj,kkk+1) * p(+1,-1, 0)
3737 + Am0p(iii+1,jjj,kkk+1) * p( 0, 0, 0)
3738 + A00p(iii+1,jjj,kkk+1) * p(+1, 0, 0)
3739 + Ampp(iii+1,jjj,kkk+1) * p( 0,+1, 0)
3740 + A0pp(iii+1,jjj,kkk+1) * p(+1,+1, 0);
3741 ap(-1,1,1) =
3742 A0m0(iii-1,jjj+1,kkk+1) * p(-1, 0,-1)
3743 + Apm0(iii-1,jjj+1,kkk+1) * p( 0, 0,-1)
3744 + A000(iii-1,jjj+1,kkk+1) * p(-1,+1,-1)
3745 + Ap00(iii-1,jjj+1,kkk+1) * p( 0,+1,-1)
3746 + A0mp(iii-1,jjj+1,kkk+1) * p(-1, 0, 0)
3747 + Apmp(iii-1,jjj+1,kkk+1) * p( 0, 0, 0)
3748 + A00p(iii-1,jjj+1,kkk+1) * p(-1,+1, 0)
3749 + Ap0p(iii-1,jjj+1,kkk+1) * p( 0,+1, 0);
3750 ap(0,1,1) =
3751 Amm0(iii,jjj+1,kkk+1) * p(-1, 0,-1)
3752 + A0m0(iii,jjj+1,kkk+1) * p( 0, 0,-1)
3753 + Apm0(iii,jjj+1,kkk+1) * p(+1, 0,-1)
3754 + Am00(iii,jjj+1,kkk+1) * p(-1,+1,-1)
3755 + A000(iii,jjj+1,kkk+1) * p( 0,+1,-1)
3756 + Ap00(iii,jjj+1,kkk+1) * p(+1,+1,-1)
3757 + Ammp(iii,jjj+1,kkk+1) * p(-1, 0, 0)
3758 + A0mp(iii,jjj+1,kkk+1) * p( 0, 0, 0)
3759 + Apmp(iii,jjj+1,kkk+1) * p(+1, 0, 0)
3760 + Am0p(iii,jjj+1,kkk+1) * p(-1,+1, 0)
3761 + A00p(iii,jjj+1,kkk+1) * p( 0,+1, 0)
3762 + Ap0p(iii,jjj+1,kkk+1) * p(+1,+1, 0);
3763 ap(1,1,1) =
3764 Amm0(iii+1,jjj+1,kkk+1) * p( 0, 0,-1)
3765 + A0m0(iii+1,jjj+1,kkk+1) * p(+1, 0,-1)
3766 + Am00(iii+1,jjj+1,kkk+1) * p( 0,+1,-1)
3767 + A000(iii+1,jjj+1,kkk+1) * p(+1,+1,-1)
3768 + Ammp(iii+1,jjj+1,kkk+1) * p( 0, 0, 0)
3769 + A0mp(iii+1,jjj+1,kkk+1) * p(+1, 0, 0)
3770 + Am0p(iii+1,jjj+1,kkk+1) * p( 0,+1, 0)
3771 + A00p(iii+1,jjj+1,kkk+1) * p(+1,+1, 0);
3772 csten(i,j,k,ist_00p) = Real(0.125) *
3773 ( restrict_from_mm0_to(iii,jjj,kkk) * ap(-1,-1, 0)
3774 + restrict_from_0m0_to(iii,jjj,kkk) * ap( 0,-1, 0)
3775 + restrict_from_pm0_to(iii,jjj,kkk) * ap(+1,-1, 0)
3776 + restrict_from_m00_to(iii,jjj,kkk) * ap(-1, 0, 0)
3777 + restrict_from_000_to(iii,jjj,kkk) * ap( 0, 0, 0)
3778 + restrict_from_p00_to(iii,jjj,kkk) * ap(+1, 0, 0)
3779 + restrict_from_mp0_to(iii,jjj,kkk) * ap(-1,+1, 0)
3780 + restrict_from_0p0_to(iii,jjj,kkk) * ap( 0,+1, 0)
3781 + restrict_from_pp0_to(iii,jjj,kkk) * ap(+1,+1, 0)
3782 + restrict_from_mmp_to(iii,jjj,kkk) * ap(-1,-1,+1)
3783 + restrict_from_0mp_to(iii,jjj,kkk) * ap( 0,-1,+1)
3784 + restrict_from_pmp_to(iii,jjj,kkk) * ap(+1,-1,+1)
3785 + restrict_from_m0p_to(iii,jjj,kkk) * ap(-1, 0,+1)
3786 + restrict_from_00p_to(iii,jjj,kkk) * ap( 0, 0,+1)
3787 + restrict_from_p0p_to(iii,jjj,kkk) * ap(+1, 0,+1)
3788 + restrict_from_mpp_to(iii,jjj,kkk) * ap(-1,+1,+1)
3789 + restrict_from_0pp_to(iii,jjj,kkk) * ap( 0,+1,+1)
3790 + restrict_from_ppp_to(iii,jjj,kkk) * ap(+1,+1,+1));
3791
3792 // csten(i,j,k,ist_pp0)
3793 iii = ii;
3794 jjj = jj;
3795 kkk = kk;
3796 p(-1,-1,-1) = interp_from_ppp_to(iii+1,jjj+1,kkk-1);
3797 p( 0,-1,-1) = interp_from_0pp_to(iii+2,jjj+1,kkk-1);
3798 p(-1, 0,-1) = interp_from_p0p_to(iii+1,jjj+2,kkk-1);
3799 p( 0, 0,-1) = interp_from_00p_to(iii+2,jjj+2,kkk-1);
3800 p(-1,-1, 0) = interp_from_pp0_to(iii+1,jjj+1,kkk );
3801 p( 0,-1, 0) = interp_from_0p0_to(iii+2,jjj+1,kkk );
3802 p(-1, 0, 0) = interp_from_p00_to(iii+1,jjj+2,kkk );
3803 p( 0, 0, 0) = Real(1.);
3804 p(-1,-1,+1) = interp_from_ppm_to(iii+1,jjj+1,kkk+1);
3805 p( 0,-1,+1) = interp_from_0pm_to(iii+2,jjj+1,kkk+1);
3806 p(-1, 0,+1) = interp_from_p0m_to(iii+1,jjj+2,kkk+1);
3807 p( 0, 0,+1) = interp_from_00m_to(iii+2,jjj+2,kkk+1);
3808 ap(0,0,-1) =
3809 App0(iii,jjj,kkk-1) * p(-1,-1,-1)
3810 + Appp(iii,jjj,kkk-1) * p(-1,-1, 0);
3811 ap(1,0,-1) =
3812 A0p0(iii+1,jjj,kkk-1) * p(-1,-1,-1)
3813 + App0(iii+1,jjj,kkk-1) * p( 0,-1,-1)
3814 + A0pp(iii+1,jjj,kkk-1) * p(-1,-1, 0)
3815 + Appp(iii+1,jjj,kkk-1) * p( 0,-1, 0);
3816 ap(0,1,-1) =
3817 Ap00(iii,jjj+1,kkk-1) * p(-1,-1,-1)
3818 + App0(iii,jjj+1,kkk-1) * p(-1, 0,-1)
3819 + Ap0p(iii,jjj+1,kkk-1) * p(-1,-1, 0)
3820 + Appp(iii,jjj+1,kkk-1) * p(-1, 0, 0);
3821 ap(1,1,-1) =
3822 A000(iii+1,jjj+1,kkk-1) * p(-1,-1,-1)
3823 + Ap00(iii+1,jjj+1,kkk-1) * p( 0,-1,-1)
3824 + A0p0(iii+1,jjj+1,kkk-1) * p(-1, 0,-1)
3825 + App0(iii+1,jjj+1,kkk-1) * p( 0, 0,-1)
3826 + A00p(iii+1,jjj+1,kkk-1) * p(-1,-1, 0)
3827 + Ap0p(iii+1,jjj+1,kkk-1) * p( 0,-1, 0)
3828 + A0pp(iii+1,jjj+1,kkk-1) * p(-1, 0, 0)
3829 + Appp(iii+1,jjj+1,kkk-1) * p( 0, 0, 0);
3830 ap(0,0,0) =
3831 Appm(iii,jjj,kkk) * p(-1,-1,-1)
3832 + App0(iii,jjj,kkk) * p(-1,-1, 0)
3833 + Appp(iii,jjj,kkk) * p(-1,-1,+1);
3834 ap(1,0,0) =
3835 A0pm(iii+1,jjj,kkk) * p(-1,-1,-1)
3836 + Appm(iii+1,jjj,kkk) * p( 0,-1,-1)
3837 + A0p0(iii+1,jjj,kkk) * p(-1,-1, 0)
3838 + App0(iii+1,jjj,kkk) * p( 0,-1, 0)
3839 + A0pp(iii+1,jjj,kkk) * p(-1,-1,+1)
3840 + Appp(iii+1,jjj,kkk) * p( 0,-1,+1);
3841 ap(0,1,0) =
3842 Ap0m(iii,jjj+1,kkk) * p(-1,-1,-1)
3843 + Appm(iii,jjj+1,kkk) * p(-1, 0,-1)
3844 + Ap00(iii,jjj+1,kkk) * p(-1,-1, 0)
3845 + App0(iii,jjj+1,kkk) * p(-1, 0, 0)
3846 + Ap0p(iii,jjj+1,kkk) * p(-1,-1,+1)
3847 + Appp(iii,jjj+1,kkk) * p(-1, 0,+1);
3848 ap(1,1,0) =
3849 A00m(iii+1,jjj+1,kkk) * p(-1,-1,-1)
3850 + Ap0m(iii+1,jjj+1,kkk) * p( 0,-1,-1)
3851 + A0pm(iii+1,jjj+1,kkk) * p(-1, 0,-1)
3852 + Appm(iii+1,jjj+1,kkk) * p( 0, 0,-1)
3853 + A000(iii+1,jjj+1,kkk) * p(-1,-1, 0)
3854 + Ap00(iii+1,jjj+1,kkk) * p( 0,-1, 0)
3855 + A0p0(iii+1,jjj+1,kkk) * p(-1, 0, 0)
3856 + App0(iii+1,jjj+1,kkk) * p( 0, 0, 0)
3857 + A00p(iii+1,jjj+1,kkk) * p(-1,-1,+1)
3858 + Ap0p(iii+1,jjj+1,kkk) * p( 0,-1,+1)
3859 + A0pp(iii+1,jjj+1,kkk) * p(-1, 0,+1)
3860 + Appp(iii+1,jjj+1,kkk) * p( 0, 0,+1);
3861 ap(0,0,1) =
3862 Appm(iii,jjj,kkk+1) * p(-1,-1, 0)
3863 + App0(iii,jjj,kkk+1) * p(-1,-1,+1);
3864 ap(1,0,1) =
3865 A0pm(iii+1,jjj,kkk+1) * p(-1,-1, 0)
3866 + Appm(iii+1,jjj,kkk+1) * p( 0,-1, 0)
3867 + A0p0(iii+1,jjj,kkk+1) * p(-1,-1,+1)
3868 + App0(iii+1,jjj,kkk+1) * p( 0,-1,+1);
3869 ap(0,1,1) =
3870 Ap0m(iii,jjj+1,kkk+1) * p(-1,-1, 0)
3871 + Appm(iii,jjj+1,kkk+1) * p(-1, 0, 0)
3872 + Ap00(iii,jjj+1,kkk+1) * p(-1,-1,+1)
3873 + App0(iii,jjj+1,kkk+1) * p(-1, 0,+1);
3874 ap(1,1,1) =
3875 A00m(iii+1,jjj+1,kkk+1) * p(-1,-1, 0)
3876 + Ap0m(iii+1,jjj+1,kkk+1) * p( 0,-1, 0)
3877 + A0pm(iii+1,jjj+1,kkk+1) * p(-1, 0, 0)
3878 + Appm(iii+1,jjj+1,kkk+1) * p( 0, 0, 0)
3879 + A000(iii+1,jjj+1,kkk+1) * p(-1,-1,+1)
3880 + Ap00(iii+1,jjj+1,kkk+1) * p( 0,-1,+1)
3881 + A0p0(iii+1,jjj+1,kkk+1) * p(-1, 0,+1)
3882 + App0(iii+1,jjj+1,kkk+1) * p( 0, 0,+1);
3883 cs1 = Real(0.125) *
3884 ( restrict_from_00m_to(iii,jjj,kkk) * ap( 0, 0,-1)
3885 + restrict_from_p0m_to(iii,jjj,kkk) * ap(+1, 0,-1)
3886 + restrict_from_0pm_to(iii,jjj,kkk) * ap( 0,+1,-1)
3887 + restrict_from_ppm_to(iii,jjj,kkk) * ap(+1,+1,-1)
3888 + restrict_from_000_to(iii,jjj,kkk) * ap( 0, 0, 0)
3889 + restrict_from_p00_to(iii,jjj,kkk) * ap(+1, 0, 0)
3890 + restrict_from_0p0_to(iii,jjj,kkk) * ap( 0,+1, 0)
3891 + restrict_from_pp0_to(iii,jjj,kkk) * ap(+1,+1, 0)
3892 + restrict_from_00p_to(iii,jjj,kkk) * ap( 0, 0,+1)
3893 + restrict_from_p0p_to(iii,jjj,kkk) * ap(+1, 0,+1)
3894 + restrict_from_0pp_to(iii,jjj,kkk) * ap( 0,+1,+1)
3895 + restrict_from_ppp_to(iii,jjj,kkk) * ap(+1,+1,+1));
3896
3897 // alternative: csten(i+1,j,k,ist_mp0)
3898 iii = ii+2;
3899 jjj = jj;
3900 kkk = kk;
3901 p( 0,-1,-1) = interp_from_0pp_to(iii-2,jjj+1,kkk-1);
3902 p(+1,-1,-1) = interp_from_mpp_to(iii-1,jjj+1,kkk-1);
3903 p( 0, 0,-1) = interp_from_00p_to(iii-2,jjj+2,kkk-1);
3904 p(+1, 0,-1) = interp_from_m0p_to(iii-1,jjj+2,kkk-1);
3905 p( 0,-1, 0) = interp_from_0p0_to(iii-2,jjj+1,kkk );
3906 p(+1,-1, 0) = interp_from_mp0_to(iii-1,jjj+1,kkk );
3907 p( 0, 0, 0) = Real(1.);
3908 p(+1, 0, 0) = interp_from_m00_to(iii-1,jjj+2,kkk );
3909 p( 0,-1,+1) = interp_from_0pm_to(iii-2,jjj+1,kkk+1);
3910 p(+1,-1,+1) = interp_from_mpm_to(iii-1,jjj+1,kkk+1);
3911 p( 0, 0,+1) = interp_from_00m_to(iii-2,jjj+2,kkk+1);
3912 p(+1, 0,+1) = interp_from_m0m_to(iii-1,jjj+2,kkk+1);
3913 ap(-1,0,-1) =
3914 Amp0(iii-1,jjj,kkk-1) * p( 0,-1,-1)
3915 + A0p0(iii-1,jjj,kkk-1) * p(+1,-1,-1)
3916 + Ampp(iii-1,jjj,kkk-1) * p( 0,-1, 0)
3917 + A0pp(iii-1,jjj,kkk-1) * p(+1,-1, 0);
3918 ap(0,0,-1) =
3919 Amp0(iii,jjj,kkk-1) * p(+1,-1,-1)
3920 + Ampp(iii,jjj,kkk-1) * p(+1,-1, 0);
3921 ap(-1,1,-1) =
3922 Am00(iii-1,jjj+1,kkk-1) * p( 0,-1,-1)
3923 + A000(iii-1,jjj+1,kkk-1) * p(+1,-1,-1)
3924 + Amp0(iii-1,jjj+1,kkk-1) * p( 0, 0,-1)
3925 + A0p0(iii-1,jjj+1,kkk-1) * p(+1, 0,-1)
3926 + Am0p(iii-1,jjj+1,kkk-1) * p( 0,-1, 0)
3927 + A00p(iii-1,jjj+1,kkk-1) * p(+1,-1, 0)
3928 + Ampp(iii-1,jjj+1,kkk-1) * p( 0, 0, 0)
3929 + A0pp(iii-1,jjj+1,kkk-1) * p(+1, 0, 0);
3930 ap(0,1,-1) =
3931 Am00(iii,jjj+1,kkk-1) * p(+1,-1,-1)
3932 + Amp0(iii,jjj+1,kkk-1) * p(+1, 0,-1)
3933 + Am0p(iii,jjj+1,kkk-1) * p(+1,-1, 0)
3934 + Ampp(iii,jjj+1,kkk-1) * p(+1, 0, 0);
3935 ap(-1,0,0) =
3936 Ampm(iii-1,jjj,kkk) * p( 0,-1,-1)
3937 + A0pm(iii-1,jjj,kkk) * p(+1,-1,-1)
3938 + Amp0(iii-1,jjj,kkk) * p( 0,-1, 0)
3939 + A0p0(iii-1,jjj,kkk) * p(+1,-1, 0)
3940 + Ampp(iii-1,jjj,kkk) * p( 0,-1,+1)
3941 + A0pp(iii-1,jjj,kkk) * p(+1,-1,+1);
3942 ap(0,0,0) =
3943 Ampm(iii,jjj,kkk) * p(+1,-1,-1)
3944 + Amp0(iii,jjj,kkk) * p(+1,-1, 0)
3945 + Ampp(iii,jjj,kkk) * p(+1,-1,+1);
3946 ap(-1,1,0) =
3947 Am0m(iii-1,jjj+1,kkk) * p( 0,-1,-1)
3948 + A00m(iii-1,jjj+1,kkk) * p(+1,-1,-1)
3949 + Ampm(iii-1,jjj+1,kkk) * p( 0, 0,-1)
3950 + A0pm(iii-1,jjj+1,kkk) * p(+1, 0,-1)
3951 + Am00(iii-1,jjj+1,kkk) * p( 0,-1, 0)
3952 + A000(iii-1,jjj+1,kkk) * p(+1,-1, 0)
3953 + Amp0(iii-1,jjj+1,kkk) * p( 0, 0, 0)
3954 + A0p0(iii-1,jjj+1,kkk) * p(+1, 0, 0)
3955 + Am0p(iii-1,jjj+1,kkk) * p( 0,-1,+1)
3956 + A00p(iii-1,jjj+1,kkk) * p(+1,-1,+1)
3957 + Ampp(iii-1,jjj+1,kkk) * p( 0, 0,+1)
3958 + A0pp(iii-1,jjj+1,kkk) * p(+1, 0,+1);
3959 ap(0,1,0) =
3960 Am0m(iii,jjj+1,kkk) * p(+1,-1,-1)
3961 + Ampm(iii,jjj+1,kkk) * p(+1, 0,-1)
3962 + Am00(iii,jjj+1,kkk) * p(+1,-1, 0)
3963 + Amp0(iii,jjj+1,kkk) * p(+1, 0, 0)
3964 + Am0p(iii,jjj+1,kkk) * p(+1,-1,+1)
3965 + Ampp(iii,jjj+1,kkk) * p(+1, 0,+1);
3966 ap(-1,0,1) =
3967 Ampm(iii-1,jjj,kkk+1) * p( 0,-1, 0)
3968 + A0pm(iii-1,jjj,kkk+1) * p(+1,-1, 0)
3969 + Amp0(iii-1,jjj,kkk+1) * p( 0,-1,+1)
3970 + A0p0(iii-1,jjj,kkk+1) * p(+1,-1,+1);
3971 ap(0,0,1) =
3972 Ampm(iii,jjj,kkk+1) * p(+1,-1, 0)
3973 + Amp0(iii,jjj,kkk+1) * p(+1,-1,+1);
3974 ap(-1,1,1) =
3975 Am0m(iii-1,jjj+1,kkk+1) * p( 0,-1, 0)
3976 + A00m(iii-1,jjj+1,kkk+1) * p(+1,-1, 0)
3977 + Ampm(iii-1,jjj+1,kkk+1) * p( 0, 0, 0)
3978 + A0pm(iii-1,jjj+1,kkk+1) * p(+1, 0, 0)
3979 + Am00(iii-1,jjj+1,kkk+1) * p( 0,-1,+1)
3980 + A000(iii-1,jjj+1,kkk+1) * p(+1,-1,+1)
3981 + Amp0(iii-1,jjj+1,kkk+1) * p( 0, 0,+1)
3982 + A0p0(iii-1,jjj+1,kkk+1) * p(+1, 0,+1);
3983 ap(0,1,1) =
3984 Am0m(iii,jjj+1,kkk+1) * p(+1,-1, 0)
3985 + Ampm(iii,jjj+1,kkk+1) * p(+1, 0, 0)
3986 + Am00(iii,jjj+1,kkk+1) * p(+1,-1,+1)
3987 + Amp0(iii,jjj+1,kkk+1) * p(+1, 0,+1);
3988 cs2 = Real(0.125) *
3989 ( restrict_from_m0m_to(iii,jjj,kkk) * ap(-1, 0,-1)
3990 + restrict_from_00m_to(iii,jjj,kkk) * ap( 0, 0,-1)
3991 + restrict_from_mpm_to(iii,jjj,kkk) * ap(-1,+1,-1)
3992 + restrict_from_0pm_to(iii,jjj,kkk) * ap( 0,+1,-1)
3993 + restrict_from_m00_to(iii,jjj,kkk) * ap(-1, 0, 0)
3994 + restrict_from_000_to(iii,jjj,kkk) * ap( 0, 0, 0)
3995 + restrict_from_mp0_to(iii,jjj,kkk) * ap(-1,+1, 0)
3996 + restrict_from_0p0_to(iii,jjj,kkk) * ap( 0,+1, 0)
3997 + restrict_from_m0p_to(iii,jjj,kkk) * ap(-1, 0,+1)
3998 + restrict_from_00p_to(iii,jjj,kkk) * ap( 0, 0,+1)
3999 + restrict_from_mpp_to(iii,jjj,kkk) * ap(-1,+1,+1)
4000 + restrict_from_0pp_to(iii,jjj,kkk) * ap( 0,+1,+1));
4001
4002 csten(i,j,k,ist_pp0) = Real(0.5)*(cs1 + cs2);
4003
4004 // csten(i,j,k,ist_p0p)
4005 iii = ii;
4006 jjj = jj;
4007 kkk = kk;
4008 p(-1,-1,-1) = interp_from_ppp_to(iii+1,jjj-1,kkk+1);
4009 p( 0,-1,-1) = interp_from_0pp_to(iii+2,jjj-1,kkk+1);
4010 p(-1, 0,-1) = interp_from_p0p_to(iii+1,jjj ,kkk+1);
4011 p( 0, 0,-1) = interp_from_00p_to(iii+2,jjj ,kkk+1);
4012 p(-1,+1,-1) = interp_from_pmp_to(iii+1,jjj+1,kkk+1);
4013 p( 0,+1,-1) = interp_from_0mp_to(iii+2,jjj+1,kkk+1);
4014 p(-1,-1, 0) = interp_from_pp0_to(iii+1,jjj-1,kkk+2);
4015 p( 0,-1, 0) = interp_from_0p0_to(iii+2,jjj-1,kkk+2);
4016 p(-1, 0, 0) = interp_from_p00_to(iii+1,jjj ,kkk+2);
4017 p( 0, 0, 0) = Real(1.);
4018 p(-1,+1, 0) = interp_from_pm0_to(iii+1,jjj+1,kkk+2);
4019 p( 0,+1, 0) = interp_from_0m0_to(iii+2,jjj+1,kkk+2);
4020 ap(0,-1,0) =
4021 Ap0p(iii,jjj-1,kkk) * p(-1,-1,-1)
4022 + Appp(iii,jjj-1,kkk) * p(-1, 0,-1);
4023 ap(1,-1,0) =
4024 A00p(iii+1,jjj-1,kkk) * p(-1,-1,-1)
4025 + Ap0p(iii+1,jjj-1,kkk) * p( 0,-1,-1)
4026 + A0pp(iii+1,jjj-1,kkk) * p(-1, 0,-1)
4027 + Appp(iii+1,jjj-1,kkk) * p( 0, 0,-1);
4028 ap(0,0,0) =
4029 Apmp(iii,jjj,kkk) * p(-1,-1,-1)
4030 + Ap0p(iii,jjj,kkk) * p(-1, 0,-1)
4031 + Appp(iii,jjj,kkk) * p(-1,+1,-1);
4032 ap(1,0,0) =
4033 A0mp(iii+1,jjj,kkk) * p(-1,-1,-1)
4034 + Apmp(iii+1,jjj,kkk) * p( 0,-1,-1)
4035 + A00p(iii+1,jjj,kkk) * p(-1, 0,-1)
4036 + Ap0p(iii+1,jjj,kkk) * p( 0, 0,-1)
4037 + A0pp(iii+1,jjj,kkk) * p(-1,+1,-1)
4038 + Appp(iii+1,jjj,kkk) * p( 0,+1,-1);
4039 ap(0,1,0) =
4040 Apmp(iii,jjj+1,kkk) * p(-1, 0,-1)
4041 + Ap0p(iii,jjj+1,kkk) * p(-1,+1,-1);
4042 ap(1,1,0) =
4043 A0mp(iii+1,jjj+1,kkk) * p(-1, 0,-1)
4044 + Apmp(iii+1,jjj+1,kkk) * p( 0, 0,-1)
4045 + A00p(iii+1,jjj+1,kkk) * p(-1,+1,-1)
4046 + Ap0p(iii+1,jjj+1,kkk) * p( 0,+1,-1);
4047 ap(0,-1,1) =
4048 Ap00(iii,jjj-1,kkk+1) * p(-1,-1,-1)
4049 + App0(iii,jjj-1,kkk+1) * p(-1, 0,-1)
4050 + Ap0p(iii,jjj-1,kkk+1) * p(-1,-1, 0)
4051 + Appp(iii,jjj-1,kkk+1) * p(-1, 0, 0);
4052 ap(1,-1,1) =
4053 A000(iii+1,jjj-1,kkk+1) * p(-1,-1,-1)
4054 + Ap00(iii+1,jjj-1,kkk+1) * p( 0,-1,-1)
4055 + A0p0(iii+1,jjj-1,kkk+1) * p(-1, 0,-1)
4056 + App0(iii+1,jjj-1,kkk+1) * p( 0, 0,-1)
4057 + A00p(iii+1,jjj-1,kkk+1) * p(-1,-1, 0)
4058 + Ap0p(iii+1,jjj-1,kkk+1) * p( 0,-1, 0)
4059 + A0pp(iii+1,jjj-1,kkk+1) * p(-1, 0, 0)
4060 + Appp(iii+1,jjj-1,kkk+1) * p( 0, 0, 0);
4061 ap(0,0,1) =
4062 Apm0(iii,jjj,kkk+1) * p(-1,-1,-1)
4063 + Ap00(iii,jjj,kkk+1) * p(-1, 0,-1)
4064 + App0(iii,jjj,kkk+1) * p(-1,+1,-1)
4065 + Apmp(iii,jjj,kkk+1) * p(-1,-1, 0)
4066 + Ap0p(iii,jjj,kkk+1) * p(-1, 0, 0)
4067 + Appp(iii,jjj,kkk+1) * p(-1,+1, 0);
4068 ap(1,0,1) =
4069 A0m0(iii+1,jjj,kkk+1) * p(-1,-1,-1)
4070 + Apm0(iii+1,jjj,kkk+1) * p( 0,-1,-1)
4071 + A000(iii+1,jjj,kkk+1) * p(-1, 0,-1)
4072 + Ap00(iii+1,jjj,kkk+1) * p( 0, 0,-1)
4073 + A0p0(iii+1,jjj,kkk+1) * p(-1,+1,-1)
4074 + App0(iii+1,jjj,kkk+1) * p( 0,+1,-1)
4075 + A0mp(iii+1,jjj,kkk+1) * p(-1,-1, 0)
4076 + Apmp(iii+1,jjj,kkk+1) * p( 0,-1, 0)
4077 + A00p(iii+1,jjj,kkk+1) * p(-1, 0, 0)
4078 + Ap0p(iii+1,jjj,kkk+1) * p( 0, 0, 0)
4079 + A0pp(iii+1,jjj,kkk+1) * p(-1,+1, 0)
4080 + Appp(iii+1,jjj,kkk+1) * p( 0,+1, 0);
4081 ap(0,1,1) =
4082 Apm0(iii,jjj+1,kkk+1) * p(-1, 0,-1)
4083 + Ap00(iii,jjj+1,kkk+1) * p(-1,+1,-1)
4084 + Apmp(iii,jjj+1,kkk+1) * p(-1, 0, 0)
4085 + Ap0p(iii,jjj+1,kkk+1) * p(-1,+1, 0);
4086 ap(1,1,1) =
4087 A0m0(iii+1,jjj+1,kkk+1) * p(-1, 0,-1)
4088 + Apm0(iii+1,jjj+1,kkk+1) * p( 0, 0,-1)
4089 + A000(iii+1,jjj+1,kkk+1) * p(-1,+1,-1)
4090 + Ap00(iii+1,jjj+1,kkk+1) * p( 0,+1,-1)
4091 + A0mp(iii+1,jjj+1,kkk+1) * p(-1, 0, 0)
4092 + Apmp(iii+1,jjj+1,kkk+1) * p( 0, 0, 0)
4093 + A00p(iii+1,jjj+1,kkk+1) * p(-1,+1, 0)
4094 + Ap0p(iii+1,jjj+1,kkk+1) * p( 0,+1, 0);
4095 cs1 = Real(0.125) *
4096 ( restrict_from_0m0_to(iii,jjj,kkk) * ap( 0,-1, 0)
4097 + restrict_from_pm0_to(iii,jjj,kkk) * ap(+1,-1, 0)
4098 + restrict_from_000_to(iii,jjj,kkk) * ap( 0, 0, 0)
4099 + restrict_from_p00_to(iii,jjj,kkk) * ap(+1, 0, 0)
4100 + restrict_from_0p0_to(iii,jjj,kkk) * ap( 0,+1, 0)
4101 + restrict_from_pp0_to(iii,jjj,kkk) * ap(+1,+1, 0)
4102 + restrict_from_0mp_to(iii,jjj,kkk) * ap( 0,-1,+1)
4103 + restrict_from_pmp_to(iii,jjj,kkk) * ap(+1,-1,+1)
4104 + restrict_from_00p_to(iii,jjj,kkk) * ap( 0, 0,+1)
4105 + restrict_from_p0p_to(iii,jjj,kkk) * ap(+1, 0,+1)
4106 + restrict_from_0pp_to(iii,jjj,kkk) * ap( 0,+1,+1)
4107 + restrict_from_ppp_to(iii,jjj,kkk) * ap(+1,+1,+1));
4108
4109 // alternative: csten(i+1,j,k,ist_m0p)
4110 iii = ii+2;
4111 jjj = jj;
4112 kkk = kk;
4113 p( 0,-1,-1) = interp_from_0pp_to(iii-2,jjj-1,kkk+1);
4114 p(+1,-1,-1) = interp_from_mpp_to(iii-1,jjj-1,kkk+1);
4115 p( 0, 0,-1) = interp_from_00p_to(iii-2,jjj ,kkk+1);
4116 p(+1, 0,-1) = interp_from_m0p_to(iii-1,jjj ,kkk+1);
4117 p( 0,+1,-1) = interp_from_0mp_to(iii-2,jjj+1,kkk+1);
4118 p(+1,+1,-1) = interp_from_mmp_to(iii-1,jjj+1,kkk+1);
4119 p( 0,-1, 0) = interp_from_0p0_to(iii-2,jjj-1,kkk+2);
4120 p(+1,-1, 0) = interp_from_mp0_to(iii-1,jjj-1,kkk+2);
4121 p( 0, 0, 0) = Real(1.);
4122 p(+1, 0, 0) = interp_from_m00_to(iii-1,jjj ,kkk+2);
4123 p( 0,+1, 0) = interp_from_0m0_to(iii-2,jjj+1,kkk+2);
4124 p(+1,+1, 0) = interp_from_mm0_to(iii-1,jjj+1,kkk+2);
4125
4126 ap(-1,-1,0) =
4127 Am0p(iii-1,jjj-1,kkk) * p( 0,-1,-1)
4128 + A00p(iii-1,jjj-1,kkk) * p(+1,-1,-1)
4129 + Ampp(iii-1,jjj-1,kkk) * p( 0, 0,-1)
4130 + A0pp(iii-1,jjj-1,kkk) * p(+1, 0,-1);
4131 ap(0,-1,0) =
4132 Am0p(iii,jjj-1,kkk) * p(+1,-1,-1)
4133 + Ampp(iii,jjj-1,kkk) * p(+1, 0,-1);
4134 ap(-1,0,0) =
4135 Ammp(iii-1,jjj,kkk) * p( 0,-1,-1)
4136 + A0mp(iii-1,jjj,kkk) * p(+1,-1,-1)
4137 + Am0p(iii-1,jjj,kkk) * p( 0, 0,-1)
4138 + A00p(iii-1,jjj,kkk) * p(+1, 0,-1)
4139 + Ampp(iii-1,jjj,kkk) * p( 0,+1,-1)
4140 + A0pp(iii-1,jjj,kkk) * p(+1,+1,-1);
4141 ap(0,0,0) =
4142 Ammp(iii,jjj,kkk) * p(+1,-1,-1)
4143 + Am0p(iii,jjj,kkk) * p(+1, 0,-1)
4144 + Ampp(iii,jjj,kkk) * p(+1,+1,-1);
4145 ap(-1,1,0) =
4146 Ammp(iii-1,jjj+1,kkk) * p( 0, 0,-1)
4147 + A0mp(iii-1,jjj+1,kkk) * p(+1, 0,-1)
4148 + Am0p(iii-1,jjj+1,kkk) * p( 0,+1,-1)
4149 + A00p(iii-1,jjj+1,kkk) * p(+1,+1,-1);
4150 ap(0,1,0) =
4151 Ammp(iii,jjj+1,kkk) * p(+1, 0,-1)
4152 + Am0p(iii,jjj+1,kkk) * p(+1,+1,-1);
4153 ap(-1,-1,1) =
4154 Am00(iii-1,jjj-1,kkk+1) * p( 0,-1,-1)
4155 + A000(iii-1,jjj-1,kkk+1) * p(+1,-1,-1)
4156 + Amp0(iii-1,jjj-1,kkk+1) * p( 0, 0,-1)
4157 + A0p0(iii-1,jjj-1,kkk+1) * p(+1, 0,-1)
4158 + Am0p(iii-1,jjj-1,kkk+1) * p( 0,-1, 0)
4159 + A00p(iii-1,jjj-1,kkk+1) * p(+1,-1, 0)
4160 + Ampp(iii-1,jjj-1,kkk+1) * p( 0, 0, 0)
4161 + A0pp(iii-1,jjj-1,kkk+1) * p(+1, 0, 0);
4162 ap(0,-1,1) =
4163 Am00(iii,jjj-1,kkk+1) * p(+1,-1,-1)
4164 + Amp0(iii,jjj-1,kkk+1) * p(+1, 0,-1)
4165 + Am0p(iii,jjj-1,kkk+1) * p(+1,-1, 0)
4166 + Ampp(iii,jjj-1,kkk+1) * p(+1, 0, 0);
4167 ap(-1,0,1) =
4168 Amm0(iii-1,jjj,kkk+1) * p( 0,-1,-1)
4169 + A0m0(iii-1,jjj,kkk+1) * p(+1,-1,-1)
4170 + Am00(iii-1,jjj,kkk+1) * p( 0, 0,-1)
4171 + A000(iii-1,jjj,kkk+1) * p(+1, 0,-1)
4172 + Amp0(iii-1,jjj,kkk+1) * p( 0,+1,-1)
4173 + A0p0(iii-1,jjj,kkk+1) * p(+1,+1,-1)
4174 + Ammp(iii-1,jjj,kkk+1) * p( 0,-1, 0)
4175 + A0mp(iii-1,jjj,kkk+1) * p(+1,-1, 0)
4176 + Am0p(iii-1,jjj,kkk+1) * p( 0, 0, 0)
4177 + A00p(iii-1,jjj,kkk+1) * p(+1, 0, 0)
4178 + Ampp(iii-1,jjj,kkk+1) * p( 0,+1, 0)
4179 + A0pp(iii-1,jjj,kkk+1) * p(+1,+1, 0);
4180 ap(0,0,1) =
4181 Amm0(iii,jjj,kkk+1) * p(+1,-1,-1)
4182 + Am00(iii,jjj,kkk+1) * p(+1, 0,-1)
4183 + Amp0(iii,jjj,kkk+1) * p(+1,+1,-1)
4184 + Ammp(iii,jjj,kkk+1) * p(+1,-1, 0)
4185 + Am0p(iii,jjj,kkk+1) * p(+1, 0, 0)
4186 + Ampp(iii,jjj,kkk+1) * p(+1,+1, 0);
4187 ap(-1,1,1) =
4188 Amm0(iii-1,jjj+1,kkk+1) * p( 0, 0,-1)
4189 + A0m0(iii-1,jjj+1,kkk+1) * p(+1, 0,-1)
4190 + Am00(iii-1,jjj+1,kkk+1) * p( 0,+1,-1)
4191 + A000(iii-1,jjj+1,kkk+1) * p(+1,+1,-1)
4192 + Ammp(iii-1,jjj+1,kkk+1) * p( 0, 0, 0)
4193 + A0mp(iii-1,jjj+1,kkk+1) * p(+1, 0, 0)
4194 + Am0p(iii-1,jjj+1,kkk+1) * p( 0,+1, 0)
4195 + A00p(iii-1,jjj+1,kkk+1) * p(+1,+1, 0);
4196 ap(0,1,1) =
4197 Amm0(iii,jjj+1,kkk+1) * p(+1, 0,-1)
4198 + Am00(iii,jjj+1,kkk+1) * p(+1,+1,-1)
4199 + Ammp(iii,jjj+1,kkk+1) * p(+1, 0, 0)
4200 + Am0p(iii,jjj+1,kkk+1) * p(+1,+1, 0);
4201 cs2 = Real(0.125) *
4202 ( restrict_from_mm0_to(iii,jjj,kkk) * ap(-1,-1, 0)
4203 + restrict_from_0m0_to(iii,jjj,kkk) * ap( 0,-1, 0)
4204 + restrict_from_m00_to(iii,jjj,kkk) * ap(-1, 0, 0)
4205 + restrict_from_000_to(iii,jjj,kkk) * ap( 0, 0, 0)
4206 + restrict_from_mp0_to(iii,jjj,kkk) * ap(-1,+1, 0)
4207 + restrict_from_0p0_to(iii,jjj,kkk) * ap( 0,+1, 0)
4208 + restrict_from_mmp_to(iii,jjj,kkk) * ap(-1,-1,+1)
4209 + restrict_from_0mp_to(iii,jjj,kkk) * ap( 0,-1,+1)
4210 + restrict_from_m0p_to(iii,jjj,kkk) * ap(-1, 0,+1)
4211 + restrict_from_00p_to(iii,jjj,kkk) * ap( 0, 0,+1)
4212 + restrict_from_mpp_to(iii,jjj,kkk) * ap(-1,+1,+1)
4213 + restrict_from_0pp_to(iii,jjj,kkk) * ap( 0,+1,+1));
4214
4215 csten(i,j,k,ist_p0p) = Real(0.5)*(cs1+cs2);
4216
4217 // csten(i,j,k,ist_0pp)
4218 iii = ii;
4219 jjj = jj;
4220 kkk = kk;
4221 p(-1,-1,-1) = interp_from_ppp_to(iii-1,jjj+1,kkk+1);
4222 p( 0,-1,-1) = interp_from_0pp_to(iii ,jjj+1,kkk+1);
4223 p(+1,-1,-1) = interp_from_mpp_to(iii+1,jjj+1,kkk+1);
4224 p(-1, 0,-1) = interp_from_p0p_to(iii-1,jjj+2,kkk+1);
4225 p( 0, 0,-1) = interp_from_00p_to(iii ,jjj+2,kkk+1);
4226 p(+1, 0,-1) = interp_from_m0p_to(iii+1,jjj+2,kkk+1);
4227 p(-1,-1, 0) = interp_from_pp0_to(iii-1,jjj+1,kkk+2);
4228 p( 0,-1, 0) = interp_from_0p0_to(iii ,jjj+1,kkk+2);
4229 p(+1,-1, 0) = interp_from_mp0_to(iii+1,jjj+1,kkk+2);
4230 p(-1, 0, 0) = interp_from_p00_to(iii-1,jjj+2,kkk+2);
4231 p( 0, 0, 0) = Real(1.);
4232 p(+1, 0, 0) = interp_from_m00_to(iii+1,jjj+2,kkk+2);
4233 ap(-1,0,0) =
4234 A0pp(iii-1,jjj,kkk) * p(-1,-1,-1)
4235 + Appp(iii-1,jjj,kkk) * p( 0,-1,-1);
4236 ap(0,0,0) =
4237 Ampp(iii,jjj,kkk) * p(-1,-1,-1)
4238 + A0pp(iii,jjj,kkk) * p( 0,-1,-1)
4239 + Appp(iii,jjj,kkk) * p(+1,-1,-1);
4240 ap(1,0,0) =
4241 Ampp(iii+1,jjj,kkk) * p( 0,-1,-1)
4242 + A0pp(iii+1,jjj,kkk) * p(+1,-1,-1);
4243 ap(-1,1,0) =
4244 A00p(iii-1,jjj+1,kkk) * p(-1,-1,-1)
4245 + Ap0p(iii-1,jjj+1,kkk) * p( 0,-1,-1)
4246 + A0pp(iii-1,jjj+1,kkk) * p(-1, 0,-1)
4247 + Appp(iii-1,jjj+1,kkk) * p( 0, 0,-1);
4248 ap(0,1,0) =
4249 Am0p(iii,jjj+1,kkk) * p(-1,-1,-1)
4250 + A00p(iii,jjj+1,kkk) * p( 0,-1,-1)
4251 + Ap0p(iii,jjj+1,kkk) * p(+1,-1,-1)
4252 + Ampp(iii,jjj+1,kkk) * p(-1, 0,-1)
4253 + A0pp(iii,jjj+1,kkk) * p( 0, 0,-1)
4254 + Appp(iii,jjj+1,kkk) * p(+1, 0,-1);
4255 ap(1,1,0) =
4256 Am0p(iii+1,jjj+1,kkk) * p( 0,-1,-1)
4257 + A00p(iii+1,jjj+1,kkk) * p(+1,-1,-1)
4258 + Ampp(iii+1,jjj+1,kkk) * p( 0, 0,-1)
4259 + A0pp(iii+1,jjj+1,kkk) * p(+1, 0,-1);
4260 ap(-1,0,1) =
4261 A0p0(iii-1,jjj,kkk+1) * p(-1,-1,-1)
4262 + App0(iii-1,jjj,kkk+1) * p( 0,-1,-1)
4263 + A0pp(iii-1,jjj,kkk+1) * p(-1,-1, 0)
4264 + Appp(iii-1,jjj,kkk+1) * p( 0,-1, 0);
4265 ap(0,0,1) =
4266 Amp0(iii,jjj,kkk+1) * p(-1,-1,-1)
4267 + A0p0(iii,jjj,kkk+1) * p( 0,-1,-1)
4268 + App0(iii,jjj,kkk+1) * p(+1,-1,-1)
4269 + Ampp(iii,jjj,kkk+1) * p(-1,-1, 0)
4270 + A0pp(iii,jjj,kkk+1) * p( 0,-1, 0)
4271 + Appp(iii,jjj,kkk+1) * p(+1,-1, 0);
4272 ap(1,0,1) =
4273 Amp0(iii+1,jjj,kkk+1) * p( 0,-1,-1)
4274 + A0p0(iii+1,jjj,kkk+1) * p(+1,-1,-1)
4275 + Ampp(iii+1,jjj,kkk+1) * p( 0,-1, 0)
4276 + A0pp(iii+1,jjj,kkk+1) * p(+1,-1, 0);
4277 ap(-1,1,1) =
4278 A000(iii-1,jjj+1,kkk+1) * p(-1,-1,-1)
4279 + Ap00(iii-1,jjj+1,kkk+1) * p( 0,-1,-1)
4280 + A0p0(iii-1,jjj+1,kkk+1) * p(-1, 0,-1)
4281 + App0(iii-1,jjj+1,kkk+1) * p( 0, 0,-1)
4282 + A00p(iii-1,jjj+1,kkk+1) * p(-1,-1, 0)
4283 + Ap0p(iii-1,jjj+1,kkk+1) * p( 0,-1, 0)
4284 + A0pp(iii-1,jjj+1,kkk+1) * p(-1, 0, 0)
4285 + Appp(iii-1,jjj+1,kkk+1) * p( 0, 0, 0);
4286 ap(0,1,1) =
4287 Am00(iii,jjj+1,kkk+1) * p(-1,-1,-1)
4288 + A000(iii,jjj+1,kkk+1) * p( 0,-1,-1)
4289 + Ap00(iii,jjj+1,kkk+1) * p(+1,-1,-1)
4290 + Amp0(iii,jjj+1,kkk+1) * p(-1, 0,-1)
4291 + A0p0(iii,jjj+1,kkk+1) * p( 0, 0,-1)
4292 + App0(iii,jjj+1,kkk+1) * p(+1, 0,-1)
4293 + Am0p(iii,jjj+1,kkk+1) * p(-1,-1, 0)
4294 + A00p(iii,jjj+1,kkk+1) * p( 0,-1, 0)
4295 + Ap0p(iii,jjj+1,kkk+1) * p(+1,-1, 0)
4296 + Ampp(iii,jjj+1,kkk+1) * p(-1, 0, 0)
4297 + A0pp(iii,jjj+1,kkk+1) * p( 0, 0, 0)
4298 + Appp(iii,jjj+1,kkk+1) * p(+1, 0, 0);
4299 ap(1,1,1) =
4300 Am00(iii+1,jjj+1,kkk+1) * p( 0,-1,-1)
4301 + A000(iii+1,jjj+1,kkk+1) * p(+1,-1,-1)
4302 + Amp0(iii+1,jjj+1,kkk+1) * p( 0, 0,-1)
4303 + A0p0(iii+1,jjj+1,kkk+1) * p(+1, 0,-1)
4304 + Am0p(iii+1,jjj+1,kkk+1) * p( 0,-1, 0)
4305 + A00p(iii+1,jjj+1,kkk+1) * p(+1,-1, 0)
4306 + Ampp(iii+1,jjj+1,kkk+1) * p( 0, 0, 0)
4307 + A0pp(iii+1,jjj+1,kkk+1) * p(+1, 0, 0);
4308 cs1 = Real(0.125) *
4309 ( restrict_from_m00_to(iii,jjj,kkk) * ap(-1, 0, 0)
4310 + restrict_from_000_to(iii,jjj,kkk) * ap( 0, 0, 0)
4311 + restrict_from_p00_to(iii,jjj,kkk) * ap(+1, 0, 0)
4312 + restrict_from_mp0_to(iii,jjj,kkk) * ap(-1,+1, 0)
4313 + restrict_from_0p0_to(iii,jjj,kkk) * ap( 0,+1, 0)
4314 + restrict_from_pp0_to(iii,jjj,kkk) * ap(+1,+1, 0)
4315 + restrict_from_m0p_to(iii,jjj,kkk) * ap(-1, 0,+1)
4316 + restrict_from_00p_to(iii,jjj,kkk) * ap( 0, 0,+1)
4317 + restrict_from_p0p_to(iii,jjj,kkk) * ap(+1, 0,+1)
4318 + restrict_from_mpp_to(iii,jjj,kkk) * ap(-1,+1,+1)
4319 + restrict_from_0pp_to(iii,jjj,kkk) * ap( 0,+1,+1)
4320 + restrict_from_ppp_to(iii,jjj,kkk) * ap(+1,+1,+1));
4321
4322 // alternative: csten(i,j+1,k,ist_0mp)
4323 iii = ii;
4324 jjj = jj+2;
4325 kkk = kk;
4326 p(-1, 0,-1) = interp_from_p0p_to(iii-1,jjj-2,kkk+1);
4327 p( 0, 0,-1) = interp_from_00p_to(iii ,jjj-2,kkk+1);
4328 p(+1, 0,-1) = interp_from_m0p_to(iii+1,jjj-2,kkk+1);
4329 p(-1,+1,-1) = interp_from_pmp_to(iii-1,jjj-1,kkk+1);
4330 p( 0,+1,-1) = interp_from_0mp_to(iii ,jjj-1,kkk+1);
4331 p(+1,+1,-1) = interp_from_mmp_to(iii+1,jjj-1,kkk+1);
4332 p(-1, 0, 0) = interp_from_p00_to(iii-1,jjj-2,kkk+2);
4333 p( 0, 0, 0) = Real(1.);
4334 p(+1, 0, 0) = interp_from_m00_to(iii+1,jjj-2,kkk+2);
4335 p(-1,+1, 0) = interp_from_pm0_to(iii-1,jjj-1,kkk+2);
4336 p( 0,+1, 0) = interp_from_0m0_to(iii ,jjj-1,kkk+2);
4337 p(+1,+1, 0) = interp_from_mm0_to(iii+1,jjj-1,kkk+2);
4338 ap(-1,-1,0) =
4339 A0mp(iii-1,jjj-1,kkk) * p(-1, 0,-1)
4340 + Apmp(iii-1,jjj-1,kkk) * p( 0, 0,-1)
4341 + A00p(iii-1,jjj-1,kkk) * p(-1,+1,-1)
4342 + Ap0p(iii-1,jjj-1,kkk) * p( 0,+1,-1);
4343 ap(0,-1,0) =
4344 Ammp(iii,jjj-1,kkk) * p(-1, 0,-1)
4345 + A0mp(iii,jjj-1,kkk) * p( 0, 0,-1)
4346 + Apmp(iii,jjj-1,kkk) * p(+1, 0,-1)
4347 + Am0p(iii,jjj-1,kkk) * p(-1,+1,-1)
4348 + A00p(iii,jjj-1,kkk) * p( 0,+1,-1)
4349 + Ap0p(iii,jjj-1,kkk) * p(+1,+1,-1);
4350 ap(1,-1,0) =
4351 Ammp(iii+1,jjj-1,kkk) * p( 0, 0,-1)
4352 + A0mp(iii+1,jjj-1,kkk) * p(+1, 0,-1)
4353 + Am0p(iii+1,jjj-1,kkk) * p( 0,+1,-1)
4354 + A00p(iii+1,jjj-1,kkk) * p(+1,+1,-1);
4355 ap(-1,0,0) =
4356 A0mp(iii-1,jjj,kkk) * p(-1,+1,-1)
4357 + Apmp(iii-1,jjj,kkk) * p( 0,+1,-1);
4358 ap(0,0,0) =
4359 Ammp(iii,jjj,kkk) * p(-1,+1,-1)
4360 + A0mp(iii,jjj,kkk) * p( 0,+1,-1)
4361 + Apmp(iii,jjj,kkk) * p(+1,+1,-1);
4362 ap(1,0,0) =
4363 Ammp(iii+1,jjj,kkk) * p( 0,+1,-1)
4364 + A0mp(iii+1,jjj,kkk) * p(+1,+1,-1);
4365 ap(-1,-1,1) =
4366 A0m0(iii-1,jjj-1,kkk+1) * p(-1, 0,-1)
4367 + Apm0(iii-1,jjj-1,kkk+1) * p( 0, 0,-1)
4368 + A000(iii-1,jjj-1,kkk+1) * p(-1,+1,-1)
4369 + Ap00(iii-1,jjj-1,kkk+1) * p( 0,+1,-1)
4370 + A0mp(iii-1,jjj-1,kkk+1) * p(-1, 0, 0)
4371 + Apmp(iii-1,jjj-1,kkk+1) * p( 0, 0, 0)
4372 + A00p(iii-1,jjj-1,kkk+1) * p(-1,+1, 0)
4373 + Ap0p(iii-1,jjj-1,kkk+1) * p( 0,+1, 0);
4374 ap(0,-1,1) =
4375 Amm0(iii,jjj-1,kkk+1) * p(-1, 0,-1)
4376 + A0m0(iii,jjj-1,kkk+1) * p( 0, 0,-1)
4377 + Apm0(iii,jjj-1,kkk+1) * p(+1, 0,-1)
4378 + Am00(iii,jjj-1,kkk+1) * p(-1,+1,-1)
4379 + A000(iii,jjj-1,kkk+1) * p( 0,+1,-1)
4380 + Ap00(iii,jjj-1,kkk+1) * p(+1,+1,-1)
4381 + Ammp(iii,jjj-1,kkk+1) * p(-1, 0, 0)
4382 + A0mp(iii,jjj-1,kkk+1) * p( 0, 0, 0)
4383 + Apmp(iii,jjj-1,kkk+1) * p(+1, 0, 0)
4384 + Am0p(iii,jjj-1,kkk+1) * p(-1,+1, 0)
4385 + A00p(iii,jjj-1,kkk+1) * p( 0,+1, 0)
4386 + Ap0p(iii,jjj-1,kkk+1) * p(+1,+1, 0);
4387 ap(1,-1,1) =
4388 Amm0(iii+1,jjj-1,kkk+1) * p( 0, 0,-1)
4389 + A0m0(iii+1,jjj-1,kkk+1) * p(+1, 0,-1)
4390 + Am00(iii+1,jjj-1,kkk+1) * p( 0,+1,-1)
4391 + A000(iii+1,jjj-1,kkk+1) * p(+1,+1,-1)
4392 + Ammp(iii+1,jjj-1,kkk+1) * p( 0, 0, 0)
4393 + A0mp(iii+1,jjj-1,kkk+1) * p(+1, 0, 0)
4394 + Am0p(iii+1,jjj-1,kkk+1) * p( 0,+1, 0)
4395 + A00p(iii+1,jjj-1,kkk+1) * p(+1,+1, 0);
4396 ap(-1,0,1) =
4397 A0m0(iii-1,jjj,kkk+1) * p(-1,+1,-1)
4398 + Apm0(iii-1,jjj,kkk+1) * p( 0,+1,-1)
4399 + A0mp(iii-1,jjj,kkk+1) * p(-1,+1, 0)
4400 + Apmp(iii-1,jjj,kkk+1) * p( 0,+1, 0);
4401 ap(0,0,1) =
4402 Amm0(iii,jjj,kkk+1) * p(-1,+1,-1)
4403 + A0m0(iii,jjj,kkk+1) * p( 0,+1,-1)
4404 + Apm0(iii,jjj,kkk+1) * p(+1,+1,-1)
4405 + Ammp(iii,jjj,kkk+1) * p(-1,+1, 0)
4406 + A0mp(iii,jjj,kkk+1) * p( 0,+1, 0)
4407 + Apmp(iii,jjj,kkk+1) * p(+1,+1, 0);
4408 ap(1,0,1) =
4409 Amm0(iii+1,jjj,kkk+1) * p( 0,+1,-1)
4410 + A0m0(iii+1,jjj,kkk+1) * p(+1,+1,-1)
4411 + Ammp(iii+1,jjj,kkk+1) * p( 0,+1, 0)
4412 + A0mp(iii+1,jjj,kkk+1) * p(+1,+1, 0);
4413 cs2 = Real(0.125) *
4414 ( restrict_from_mm0_to(iii,jjj,kkk) * ap(-1,-1, 0)
4415 + restrict_from_0m0_to(iii,jjj,kkk) * ap( 0,-1, 0)
4416 + restrict_from_pm0_to(iii,jjj,kkk) * ap(+1,-1, 0)
4417 + restrict_from_m00_to(iii,jjj,kkk) * ap(-1, 0, 0)
4418 + restrict_from_000_to(iii,jjj,kkk) * ap( 0, 0, 0)
4419 + restrict_from_p00_to(iii,jjj,kkk) * ap(+1, 0, 0)
4420 + restrict_from_mmp_to(iii,jjj,kkk) * ap(-1,-1,+1)
4421 + restrict_from_0mp_to(iii,jjj,kkk) * ap( 0,-1,+1)
4422 + restrict_from_pmp_to(iii,jjj,kkk) * ap(+1,-1,+1)
4423 + restrict_from_m0p_to(iii,jjj,kkk) * ap(-1, 0,+1)
4424 + restrict_from_00p_to(iii,jjj,kkk) * ap( 0, 0,+1)
4425 + restrict_from_p0p_to(iii,jjj,kkk) * ap(+1, 0,+1));
4426
4427 csten(i,j,k,ist_0pp) = Real(0.5)*(cs1+cs2);
4428
4429 // csten(i,j,k,ist_ppp)
4430 iii = ii;
4431 jjj = jj;
4432 kkk = kk;
4433 p(-1,-1,-1) = interp_from_ppp_to(iii+1,jjj+1,kkk+1);
4434 p( 0,-1,-1) = interp_from_0pp_to(iii+2,jjj+1,kkk+1);
4435 p(-1, 0,-1) = interp_from_p0p_to(iii+1,jjj+2,kkk+1);
4436 p( 0, 0,-1) = interp_from_00p_to(iii+2,jjj+2,kkk+1);
4437 p(-1,-1, 0) = interp_from_pp0_to(iii+1,jjj+1,kkk+2);
4438 p( 0,-1, 0) = interp_from_0p0_to(iii+2,jjj+1,kkk+2);
4439 p(-1, 0, 0) = interp_from_p00_to(iii+1,jjj+2,kkk+2);
4440 p( 0, 0, 0) = Real(1.);
4441 ap(0,0,0) =
4442 Appp(iii,jjj,kkk) * p(-1,-1,-1);
4443 ap(1,0,0) =
4444 A0pp(iii+1,jjj,kkk) * p(-1,-1,-1)
4445 + Appp(iii+1,jjj,kkk) * p( 0,-1,-1);
4446 ap(0,1,0) =
4447 Ap0p(iii,jjj+1,kkk) * p(-1,-1,-1)
4448 + Appp(iii,jjj+1,kkk) * p(-1, 0,-1);
4449 ap(1,1,0) =
4450 A00p(iii+1,jjj+1,kkk) * p(-1,-1,-1)
4451 + Ap0p(iii+1,jjj+1,kkk) * p( 0,-1,-1)
4452 + A0pp(iii+1,jjj+1,kkk) * p(-1, 0,-1)
4453 + Appp(iii+1,jjj+1,kkk) * p( 0, 0,-1);
4454 ap(0,0,1) =
4455 App0(iii,jjj,kkk+1) * p(-1,-1,-1)
4456 + Appp(iii,jjj,kkk+1) * p(-1,-1, 0);
4457 ap(1,0,1) =
4458 A0p0(iii+1,jjj,kkk+1) * p(-1,-1,-1)
4459 + App0(iii+1,jjj,kkk+1) * p( 0,-1,-1)
4460 + A0pp(iii+1,jjj,kkk+1) * p(-1,-1, 0)
4461 + Appp(iii+1,jjj,kkk+1) * p( 0,-1, 0);
4462 ap(0,1,1) =
4463 Ap00(iii,jjj+1,kkk+1) * p(-1,-1,-1)
4464 + App0(iii,jjj+1,kkk+1) * p(-1, 0,-1)
4465 + Ap0p(iii,jjj+1,kkk+1) * p(-1,-1, 0)
4466 + Appp(iii,jjj+1,kkk+1) * p(-1, 0, 0);
4467 ap(1,1,1) =
4468 A000(iii+1,jjj+1,kkk+1) * p(-1,-1,-1)
4469 + Ap00(iii+1,jjj+1,kkk+1) * p( 0,-1,-1)
4470 + A0p0(iii+1,jjj+1,kkk+1) * p(-1, 0,-1)
4471 + App0(iii+1,jjj+1,kkk+1) * p( 0, 0,-1)
4472 + A00p(iii+1,jjj+1,kkk+1) * p(-1,-1, 0)
4473 + Ap0p(iii+1,jjj+1,kkk+1) * p( 0,-1, 0)
4474 + A0pp(iii+1,jjj+1,kkk+1) * p(-1, 0, 0)
4475 + Appp(iii+1,jjj+1,kkk+1) * p( 0, 0, 0);
4476 cs1 = Real(0.125) *
4477 ( restrict_from_000_to(iii,jjj,kkk) * ap( 0, 0, 0)
4478 + restrict_from_p00_to(iii,jjj,kkk) * ap(+1, 0, 0)
4479 + restrict_from_0p0_to(iii,jjj,kkk) * ap( 0,+1, 0)
4480 + restrict_from_pp0_to(iii,jjj,kkk) * ap(+1,+1, 0)
4481 + restrict_from_00p_to(iii,jjj,kkk) * ap( 0, 0,+1)
4482 + restrict_from_p0p_to(iii,jjj,kkk) * ap(+1, 0,+1)
4483 + restrict_from_0pp_to(iii,jjj,kkk) * ap( 0,+1,+1)
4484 + restrict_from_ppp_to(iii,jjj,kkk) * ap(+1,+1,+1));
4485
4486 // alternative: csten(i+1,j,k,ist_mpp)
4487 iii = ii+2;
4488 jjj = jj;
4489 kkk = kk;
4490 p( 0,-1,-1) = interp_from_0pp_to(iii-2,jjj+1,kkk+1);
4491 p(+1,-1,-1) = interp_from_mpp_to(iii-1,jjj+1,kkk+1);
4492 p( 0, 0,-1) = interp_from_00p_to(iii-2,jjj+2,kkk+1);
4493 p(+1, 0,-1) = interp_from_m0p_to(iii-1,jjj+2,kkk+1);
4494 p( 0,-1, 0) = interp_from_0p0_to(iii-2,jjj+1,kkk+2);
4495 p(+1,-1, 0) = interp_from_mp0_to(iii-1,jjj+1,kkk+2);
4496 p( 0, 0, 0) = Real(1.);
4497 p(+1, 0, 0) = interp_from_m00_to(iii-1,jjj+2,kkk+2);
4498 ap(-1,0,0) =
4499 Ampp(iii-1,jjj,kkk) * p( 0,-1,-1)
4500 + A0pp(iii-1,jjj,kkk) * p(+1,-1,-1);
4501 ap(0,0,0) =
4502 Ampp(iii,jjj,kkk) * p(+1,-1,-1);
4503 ap(-1,1,0) =
4504 Am0p(iii-1,jjj+1,kkk) * p( 0,-1,-1)
4505 + A00p(iii-1,jjj+1,kkk) * p(+1,-1,-1)
4506 + Ampp(iii-1,jjj+1,kkk) * p( 0, 0,-1)
4507 + A0pp(iii-1,jjj+1,kkk) * p(+1, 0,-1);
4508 ap(0,1,0) =
4509 Am0p(iii,jjj+1,kkk) * p(+1,-1,-1)
4510 + Ampp(iii,jjj+1,kkk) * p(+1, 0,-1);
4511 ap(-1,0,1) =
4512 Amp0(iii-1,jjj,kkk+1) * p( 0,-1,-1)
4513 + A0p0(iii-1,jjj,kkk+1) * p(+1,-1,-1)
4514 + Ampp(iii-1,jjj,kkk+1) * p( 0,-1, 0)
4515 + A0pp(iii-1,jjj,kkk+1) * p(+1,-1, 0);
4516 ap(0,0,1) =
4517 Amp0(iii,jjj,kkk+1) * p(+1,-1,-1)
4518 + Ampp(iii,jjj,kkk+1) * p(+1,-1, 0);
4519 ap(-1,1,1) =
4520 Am00(iii-1,jjj+1,kkk+1) * p( 0,-1,-1)
4521 + A000(iii-1,jjj+1,kkk+1) * p(+1,-1,-1)
4522 + Amp0(iii-1,jjj+1,kkk+1) * p( 0, 0,-1)
4523 + A0p0(iii-1,jjj+1,kkk+1) * p(+1, 0,-1)
4524 + Am0p(iii-1,jjj+1,kkk+1) * p( 0,-1, 0)
4525 + A00p(iii-1,jjj+1,kkk+1) * p(+1,-1, 0)
4526 + Ampp(iii-1,jjj+1,kkk+1) * p( 0, 0, 0)
4527 + A0pp(iii-1,jjj+1,kkk+1) * p(+1, 0, 0);
4528 ap(0,1,1) =
4529 Am00(iii,jjj+1,kkk+1) * p(+1,-1,-1)
4530 + Amp0(iii,jjj+1,kkk+1) * p(+1, 0,-1)
4531 + Am0p(iii,jjj+1,kkk+1) * p(+1,-1, 0)
4532 + Ampp(iii,jjj+1,kkk+1) * p(+1, 0, 0);
4533 cs2 = Real(0.125) *
4534 ( restrict_from_m00_to(iii,jjj,kkk) * ap(-1, 0, 0)
4535 + restrict_from_000_to(iii,jjj,kkk) * ap( 0, 0, 0)
4536 + restrict_from_mp0_to(iii,jjj,kkk) * ap(-1,+1, 0)
4537 + restrict_from_0p0_to(iii,jjj,kkk) * ap( 0,+1, 0)
4538 + restrict_from_m0p_to(iii,jjj,kkk) * ap(-1, 0,+1)
4539 + restrict_from_00p_to(iii,jjj,kkk) * ap( 0, 0,+1)
4540 + restrict_from_mpp_to(iii,jjj,kkk) * ap(-1,+1,+1)
4541 + restrict_from_0pp_to(iii,jjj,kkk) * ap( 0,+1,+1));
4542
4543 // alternative: csten(i,j+1,k,ist_pmp)
4544 iii = ii;
4545 jjj = jj+2;
4546 kkk = kk;
4547 p(-1, 0,-1) = interp_from_p0p_to(iii+1,jjj-2,kkk+1);
4548 p( 0, 0,-1) = interp_from_00p_to(iii+2,jjj-2,kkk+1);
4549 p(-1,+1,-1) = interp_from_pmp_to(iii+1,jjj-1,kkk+1);
4550 p( 0,+1,-1) = interp_from_0mp_to(iii+2,jjj-1,kkk+1);
4551 p(-1, 0, 0) = interp_from_p00_to(iii+1,jjj-2,kkk+2);
4552 p( 0, 0, 0) = Real(1.);
4553 p(-1,+1, 0) = interp_from_pm0_to(iii+1,jjj-1,kkk+2);
4554 p( 0,+1, 0) = interp_from_0m0_to(iii+2,jjj-1,kkk+2);
4555 ap(0,-1,0) =
4556 Apmp(iii,jjj-1,kkk) * p(-1, 0,-1)
4557 + Ap0p(iii,jjj-1,kkk) * p(-1,+1,-1);
4558 ap(1,-1,0) =
4559 A0mp(iii+1,jjj-1,kkk) * p(-1, 0,-1)
4560 + Apmp(iii+1,jjj-1,kkk) * p( 0, 0,-1)
4561 + A00p(iii+1,jjj-1,kkk) * p(-1,+1,-1)
4562 + Ap0p(iii+1,jjj-1,kkk) * p( 0,+1,-1);
4563 ap(0,0,0) =
4564 Apmp(iii,jjj,kkk) * p(-1,+1,-1);
4565 ap(1,0,0) =
4566 A0mp(iii+1,jjj,kkk) * p(-1,+1,-1)
4567 + Apmp(iii+1,jjj,kkk) * p( 0,+1,-1);
4568 ap(0,-1,1) =
4569 Apm0(iii,jjj-1,kkk+1) * p(-1, 0,-1)
4570 + Ap00(iii,jjj-1,kkk+1) * p(-1,+1,-1)
4571 + Apmp(iii,jjj-1,kkk+1) * p(-1, 0, 0)
4572 + Ap0p(iii,jjj-1,kkk+1) * p(-1,+1, 0);
4573 ap(1,-1,1) =
4574 A0m0(iii+1,jjj-1,kkk+1) * p(-1, 0,-1)
4575 + Apm0(iii+1,jjj-1,kkk+1) * p( 0, 0,-1)
4576 + A000(iii+1,jjj-1,kkk+1) * p(-1,+1,-1)
4577 + Ap00(iii+1,jjj-1,kkk+1) * p( 0,+1,-1)
4578 + A0mp(iii+1,jjj-1,kkk+1) * p(-1, 0, 0)
4579 + Apmp(iii+1,jjj-1,kkk+1) * p( 0, 0, 0)
4580 + A00p(iii+1,jjj-1,kkk+1) * p(-1,+1, 0)
4581 + Ap0p(iii+1,jjj-1,kkk+1) * p( 0,+1, 0);
4582 ap(0,0,1) =
4583 Apm0(iii,jjj,kkk+1) * p(-1,+1,-1)
4584 + Apmp(iii,jjj,kkk+1) * p(-1,+1, 0);
4585 ap(1,0,1) =
4586 A0m0(iii+1,jjj,kkk+1) * p(-1,+1,-1)
4587 + Apm0(iii+1,jjj,kkk+1) * p( 0,+1,-1)
4588 + A0mp(iii+1,jjj,kkk+1) * p(-1,+1, 0)
4589 + Apmp(iii+1,jjj,kkk+1) * p( 0,+1, 0);
4590 cs3 = Real(0.125) *
4591 ( restrict_from_0m0_to(iii,jjj,kkk) * ap( 0,-1, 0)
4592 + restrict_from_pm0_to(iii,jjj,kkk) * ap(+1,-1, 0)
4593 + restrict_from_000_to(iii,jjj,kkk) * ap( 0, 0, 0)
4594 + restrict_from_p00_to(iii,jjj,kkk) * ap(+1, 0, 0)
4595 + restrict_from_0mp_to(iii,jjj,kkk) * ap( 0,-1,+1)
4596 + restrict_from_pmp_to(iii,jjj,kkk) * ap(+1,-1,+1)
4597 + restrict_from_00p_to(iii,jjj,kkk) * ap( 0, 0,+1)
4598 + restrict_from_p0p_to(iii,jjj,kkk) * ap(+1, 0,+1));
4599
4600 // alternative: csten(i+1,j+1,k,ist_mmp)
4601 iii = ii+2;
4602 jjj = jj+2;
4603 kkk = kk;
4604 p( 0, 0,-1) = interp_from_00p_to(iii-2,jjj-2,kkk+1);
4605 p(+1, 0,-1) = interp_from_m0p_to(iii-1,jjj-2,kkk+1);
4606 p( 0,+1,-1) = interp_from_0mp_to(iii-2,jjj-1,kkk+1);
4607 p(+1,+1,-1) = interp_from_mmp_to(iii-1,jjj-1,kkk+1);
4608 p( 0, 0, 0) = Real(1.);
4609 p(+1, 0, 0) = interp_from_m00_to(iii-1,jjj-2,kkk+2);
4610 p( 0,+1, 0) = interp_from_0m0_to(iii-2,jjj-1,kkk+2);
4611 p(+1,+1, 0) = interp_from_mm0_to(iii-1,jjj-1,kkk+2);
4612 ap(-1,-1,0) =
4613 Ammp(iii-1,jjj-1,kkk) * p( 0, 0,-1)
4614 + A0mp(iii-1,jjj-1,kkk) * p(+1, 0,-1)
4615 + Am0p(iii-1,jjj-1,kkk) * p( 0,+1,-1)
4616 + A00p(iii-1,jjj-1,kkk) * p(+1,+1,-1);
4617 ap(0,-1,0) =
4618 Ammp(iii,jjj-1,kkk) * p(+1, 0,-1)
4619 + Am0p(iii,jjj-1,kkk) * p(+1,+1,-1);
4620 ap(-1,0,0) =
4621 Ammp(iii-1,jjj,kkk) * p( 0,+1,-1)
4622 + A0mp(iii-1,jjj,kkk) * p(+1,+1,-1);
4623 ap(0,0,0) =
4624 Ammp(iii,jjj,kkk) * p(+1,+1,-1);
4625 ap(-1,-1,1) =
4626 Amm0(iii-1,jjj-1,kkk+1) * p( 0, 0,-1)
4627 + A0m0(iii-1,jjj-1,kkk+1) * p(+1, 0,-1)
4628 + Am00(iii-1,jjj-1,kkk+1) * p( 0,+1,-1)
4629 + A000(iii-1,jjj-1,kkk+1) * p(+1,+1,-1)
4630 + Ammp(iii-1,jjj-1,kkk+1) * p( 0, 0, 0)
4631 + A0mp(iii-1,jjj-1,kkk+1) * p(+1, 0, 0)
4632 + Am0p(iii-1,jjj-1,kkk+1) * p( 0,+1, 0)
4633 + A00p(iii-1,jjj-1,kkk+1) * p(+1,+1, 0);
4634 ap(0,-1,1) =
4635 Amm0(iii,jjj-1,kkk+1) * p(+1, 0,-1)
4636 + Am00(iii,jjj-1,kkk+1) * p(+1,+1,-1)
4637 + Ammp(iii,jjj-1,kkk+1) * p(+1, 0, 0)
4638 + Am0p(iii,jjj-1,kkk+1) * p(+1,+1, 0);
4639 ap(-1,0,1) =
4640 Amm0(iii-1,jjj,kkk+1) * p( 0,+1,-1)
4641 + A0m0(iii-1,jjj,kkk+1) * p(+1,+1,-1)
4642 + Ammp(iii-1,jjj,kkk+1) * p( 0,+1, 0)
4643 + A0mp(iii-1,jjj,kkk+1) * p(+1,+1, 0);
4644 ap(0,0,1) =
4645 Amm0(iii,jjj,kkk+1) * p(+1,+1,-1)
4646 + Ammp(iii,jjj,kkk+1) * p(+1,+1, 0);
4647 cs4 = Real(0.125) *
4648 ( restrict_from_mm0_to(iii,jjj,kkk) * ap(-1,-1, 0)
4649 + restrict_from_0m0_to(iii,jjj,kkk) * ap( 0,-1, 0)
4650 + restrict_from_m00_to(iii,jjj,kkk) * ap(-1, 0, 0)
4651 + restrict_from_000_to(iii,jjj,kkk) * ap( 0, 0, 0)
4652 + restrict_from_mmp_to(iii,jjj,kkk) * ap(-1,-1,+1)
4653 + restrict_from_0mp_to(iii,jjj,kkk) * ap( 0,-1,+1)
4654 + restrict_from_m0p_to(iii,jjj,kkk) * ap(-1, 0,+1)
4655 + restrict_from_00p_to(iii,jjj,kkk) * ap( 0, 0,+1));
4656
4657 csten(i,j,k,ist_ppp) = Real(0.25)*(cs1+cs2+cs3+cs4);
4658}
4659
4661Real mlndlap_adotx_sten_doit (int i, int j, int k, Array4<Real const> const& x,
4662 Array4<Real const> const& sten) noexcept
4663{
4664 using namespace nodelap_detail;
4665
4666 return x(i ,j ,k ) * sten(i ,j ,k ,ist_000)
4667 //
4668 + x(i-1,j ,k ) * sten(i-1,j ,k ,ist_p00)
4669 + x(i+1,j ,k ) * sten(i ,j ,k ,ist_p00)
4670 //
4671 + x(i ,j-1,k ) * sten(i ,j-1,k ,ist_0p0)
4672 + x(i ,j+1,k ) * sten(i ,j ,k ,ist_0p0)
4673 //
4674 + x(i ,j ,k-1) * sten(i ,j ,k-1,ist_00p)
4675 + x(i ,j ,k+1) * sten(i ,j ,k ,ist_00p)
4676 //
4677 + x(i-1,j-1,k ) * sten(i-1,j-1,k ,ist_pp0)
4678 + x(i+1,j-1,k ) * sten(i ,j-1,k ,ist_pp0)
4679 + x(i-1,j+1,k ) * sten(i-1,j ,k ,ist_pp0)
4680 + x(i+1,j+1,k ) * sten(i ,j ,k ,ist_pp0)
4681 //
4682 + x(i-1,j ,k-1) * sten(i-1,j ,k-1,ist_p0p)
4683 + x(i+1,j ,k-1) * sten(i ,j ,k-1,ist_p0p)
4684 + x(i-1,j ,k+1) * sten(i-1,j ,k ,ist_p0p)
4685 + x(i+1,j ,k+1) * sten(i ,j ,k ,ist_p0p)
4686 //
4687 + x(i ,j-1,k-1) * sten(i ,j-1,k-1,ist_0pp)
4688 + x(i ,j+1,k-1) * sten(i ,j ,k-1,ist_0pp)
4689 + x(i ,j-1,k+1) * sten(i ,j-1,k ,ist_0pp)
4690 + x(i ,j+1,k+1) * sten(i ,j ,k ,ist_0pp)
4691 //
4692 + x(i-1,j-1,k-1) * sten(i-1,j-1,k-1,ist_ppp)
4693 + x(i+1,j-1,k-1) * sten(i ,j-1,k-1,ist_ppp)
4694 + x(i-1,j+1,k-1) * sten(i-1,j ,k-1,ist_ppp)
4695 + x(i+1,j+1,k-1) * sten(i ,j ,k-1,ist_ppp)
4696 + x(i-1,j-1,k+1) * sten(i-1,j-1,k ,ist_ppp)
4697 + x(i+1,j-1,k+1) * sten(i ,j-1,k ,ist_ppp)
4698 + x(i-1,j+1,k+1) * sten(i-1,j ,k ,ist_ppp)
4699 + x(i+1,j+1,k+1) * sten(i ,j ,k ,ist_ppp);
4700}
4701
4703Real mlndlap_adotx_sten (int i, int j, int k, Array4<Real const> const& x,
4704 Array4<Real const> const& sten, Array4<int const> const& msk) noexcept
4705{
4706 if (msk(i,j,k)) {
4707 return Real(0.0);
4708 } else {
4709 return mlndlap_adotx_sten_doit(i,j,k,x,sten);
4710 }
4711}
4712
4714void mlndlap_gauss_seidel_sten (int i, int j, int k, Array4<Real> const& sol,
4715 Array4<Real const> const& rhs,
4716 Array4<Real const> const& sten,
4717 Array4<int const> const& msk) noexcept
4718{
4719 using namespace nodelap_detail;
4720
4721 if (msk(i,j,k)) {
4722 sol(i,j,k) = Real(0.0);
4723 } else if (sten(i,j,k,ist_000) != Real(0.0)) {
4724 Real Ax = mlndlap_adotx_sten_doit(i,j,k,sol,sten);
4725 sol(i,j,k) += (rhs(i,j,k) - Ax) / sten(i,j,k,ist_000);
4726 }
4727}
4728
4729inline
4730void mlndlap_gauss_seidel_sten (Box const& bx, Array4<Real> const& sol,
4731 Array4<Real const> const& rhs,
4732 Array4<Real const> const& sten,
4733 Array4<int const> const& msk) noexcept
4734{
4735 AMREX_LOOP_3D(bx, i, j, k,
4736 {
4737 mlndlap_gauss_seidel_sten(i,j,k,sol,rhs,sten,msk);
4738 });
4739}
4740
4742void mlndlap_interpadd_rap (int i, int j, int k, Array4<Real> const& fine,
4743 Array4<Real const> const& crse, Array4<Real const> const& sten,
4744 Array4<int const> const& msk) noexcept
4745{
4746 using namespace nodelap_detail;
4747
4748 if (!msk(i,j,k) && sten(i,j,k,ist_000) != Real(0.0)) {
4749 int ic = amrex::coarsen(i,2);
4750 int jc = amrex::coarsen(j,2);
4751 int kc = amrex::coarsen(k,2);
4752 bool ieven = ic*2 == i;
4753 bool jeven = jc*2 == j;
4754 bool keven = kc*2 == k;
4755 Real fv;
4756 if (ieven && jeven && keven) {
4757 fv = crse(ic,jc,kc);
4758 } else if (ieven && jeven) {
4759 Real w1 = std::abs(sten(i,j,k-1,ist_00p));
4760 Real w2 = std::abs(sten(i,j,k ,ist_00p));
4761 if (w1 == Real(0.0) && w2 == Real(0.0)) {
4762 fv = Real(0.5)*(crse(ic,jc,kc)+crse(ic,jc,kc+1));
4763 } else {
4764 fv = (w1*crse(ic,jc,kc) + w2*crse(ic,jc,kc+1)) / (w1+w2);
4765 }
4766 } else if (ieven && keven) {
4767 Real w1 = std::abs(sten(i,j-1,k,ist_0p0));
4768 Real w2 = std::abs(sten(i,j ,k,ist_0p0));
4769 if (w1 == Real(0.0) && w2 == Real(0.0)) {
4770 fv = Real(0.5)*(crse(ic,jc,kc)+crse(ic,jc+1,kc));
4771 } else {
4772 fv = (w1*crse(ic,jc,kc) + w2*crse(ic,jc+1,kc)) / (w1+w2);
4773 }
4774 } else if (jeven && keven) {
4775 Real w1 = std::abs(sten(i-1,j,k,ist_p00));
4776 Real w2 = std::abs(sten(i ,j,k,ist_p00));
4777 if (w1 == Real(0.0) && w2 == Real(0.0)) {
4778 fv = Real(0.5)*(crse(ic,jc,kc)+crse(ic+1,jc,kc));
4779 } else {
4780 fv = (w1*crse(ic,jc,kc) + w2*crse(ic+1,jc,kc)) / (w1+w2);
4781 }
4782 } else if (ieven) {
4783 Real w1m = std::abs(sten(i,j-1,k,ist_0p0)) / (std::abs(sten(i,j-1,k-1,ist_0pp))
4784 +std::abs(sten(i,j-1,k ,ist_0pp)) + eps);
4785 Real w1p = std::abs(sten(i,j ,k,ist_0p0)) / (std::abs(sten(i,j ,k-1,ist_0pp))
4786 +std::abs(sten(i,j ,k ,ist_0pp)) + eps);
4787 Real w2m = std::abs(sten(i,j,k-1,ist_00p)) / (std::abs(sten(i,j-1,k-1,ist_0pp))
4788 +std::abs(sten(i,j ,k-1,ist_0pp)) + eps);
4789 Real w2p = std::abs(sten(i,j,k ,ist_00p)) / (std::abs(sten(i,j-1,k ,ist_0pp))
4790 +std::abs(sten(i,j ,k ,ist_0pp)) + eps);
4791 Real wmm = std::abs(sten(i,j-1,k-1,ist_0pp)) * (Real(1.0) + w1m + w2m);
4792 Real wpm = std::abs(sten(i,j ,k-1,ist_0pp)) * (Real(1.0) + w1p + w2m);
4793 Real wmp = std::abs(sten(i,j-1,k ,ist_0pp)) * (Real(1.0) + w1m + w2p);
4794 Real wpp = std::abs(sten(i,j ,k ,ist_0pp)) * (Real(1.0) + w1p + w2p);
4795 fv = (wmm*crse(ic,jc,kc) + wpm*crse(ic,jc+1,kc)
4796 + wmp*crse(ic,jc,kc+1) + wpp*crse(ic,jc+1,kc+1))
4797 / (wmm+wpm+wmp+wpp+eps);
4798 } else if (jeven) {
4799 Real w1m = std::abs(sten(i-1,j,k,ist_p00)) / (std::abs(sten(i-1,j,k-1,ist_p0p))
4800 +std::abs(sten(i-1,j,k ,ist_p0p)) + eps);
4801 Real w1p = std::abs(sten(i ,j,k,ist_p00)) / (std::abs(sten(i ,j,k-1,ist_p0p))
4802 +std::abs(sten(i ,j,k ,ist_p0p)) + eps);
4803 Real w2m = std::abs(sten(i,j,k-1,ist_00p)) / (std::abs(sten(i-1,j,k-1,ist_p0p))
4804 +std::abs(sten(i ,j,k-1,ist_p0p)) + eps);
4805 Real w2p = std::abs(sten(i,j,k ,ist_00p)) / (std::abs(sten(i-1,j,k ,ist_p0p))
4806 +std::abs(sten(i ,j,k ,ist_p0p)) + eps);
4807 Real wmm = std::abs(sten(i-1,j,k-1,ist_p0p)) * (Real(1.0) + w1m + w2m);
4808 Real wpm = std::abs(sten(i ,j,k-1,ist_p0p)) * (Real(1.0) + w1p + w2m);
4809 Real wmp = std::abs(sten(i-1,j,k ,ist_p0p)) * (Real(1.0) + w1m + w2p);
4810 Real wpp = std::abs(sten(i ,j,k ,ist_p0p)) * (Real(1.0) + w1p + w2p);
4811 fv = (wmm*crse(ic,jc,kc) + wpm*crse(ic+1,jc,kc)
4812 + wmp*crse(ic,jc,kc+1) + wpp*crse(ic+1,jc,kc+1))
4813 / (wmm+wpm+wmp+wpp+eps);
4814 } else if (keven) {
4815 Real w1m = std::abs(sten(i-1,j,k,ist_p00)) / (std::abs(sten(i-1,j-1,k,ist_pp0))
4816 +std::abs(sten(i-1,j ,k,ist_pp0)) + eps);
4817 Real w1p = std::abs(sten(i ,j,k,ist_p00)) / (std::abs(sten(i ,j-1,k,ist_pp0))
4818 +std::abs(sten(i ,j ,k,ist_pp0)) + eps);
4819 Real w2m = std::abs(sten(i,j-1,k,ist_0p0)) / (std::abs(sten(i-1,j-1,k,ist_pp0))
4820 +std::abs(sten(i ,j-1,k,ist_pp0)) + eps);
4821 Real w2p = std::abs(sten(i,j ,k,ist_0p0)) / (std::abs(sten(i-1,j ,k,ist_pp0))
4822 +std::abs(sten(i ,j ,k,ist_pp0)) + eps);
4823 Real wmm = std::abs(sten(i-1,j-1,k,ist_pp0)) * (Real(1.0) + w1m + w2m);
4824 Real wpm = std::abs(sten(i ,j-1,k,ist_pp0)) * (Real(1.0) + w1p + w2m);
4825 Real wmp = std::abs(sten(i-1,j ,k,ist_pp0)) * (Real(1.0) + w1m + w2p);
4826 Real wpp = std::abs(sten(i ,j ,k,ist_pp0)) * (Real(1.0) + w1p + w2p);
4827 fv = (wmm*crse(ic,jc,kc) + wpm*crse(ic+1,jc,kc)
4828 + wmp*crse(ic,jc+1,kc) + wpp*crse(ic+1,jc+1,kc))
4829 / (wmm+wpm+wmp+wpp+eps);
4830 } else {
4831 Real wmmm = Real(1.0);
4832 Real wpmm = Real(1.0);
4833 Real wmpm = Real(1.0);
4834 Real wppm = Real(1.0);
4835 Real wmmp = Real(1.0);
4836 Real wpmp = Real(1.0);
4837 Real wmpp = Real(1.0);
4838 Real wppp = Real(1.0);
4839
4840 Real wtmp = std::abs(sten(i-1,j,k,ist_p00)) /
4841 ( std::abs(sten(i-1,j-1,k-1,ist_ppp))
4842 + std::abs(sten(i-1,j ,k-1,ist_ppp))
4843 + std::abs(sten(i-1,j-1,k ,ist_ppp))
4844 + std::abs(sten(i-1,j ,k ,ist_ppp)) + eps);
4845 wmmm += wtmp;
4846 wmpm += wtmp;
4847 wmmp += wtmp;
4848 wmpp += wtmp;
4849
4850 wtmp = std::abs(sten(i,j,k,ist_p00)) /
4851 ( std::abs(sten(i,j-1,k-1,ist_ppp))
4852 + std::abs(sten(i,j ,k-1,ist_ppp))
4853 + std::abs(sten(i,j-1,k ,ist_ppp))
4854 + std::abs(sten(i,j ,k ,ist_ppp)) + eps);
4855 wpmm += wtmp;
4856 wppm += wtmp;
4857 wpmp += wtmp;
4858 wppp += wtmp;
4859
4860 wtmp = std::abs(sten(i,j-1,k,ist_0p0)) /
4861 ( std::abs(sten(i-1,j-1,k-1,ist_ppp))
4862 + std::abs(sten(i ,j-1,k-1,ist_ppp))
4863 + std::abs(sten(i-1,j-1,k ,ist_ppp))
4864 + std::abs(sten(i ,j-1,k ,ist_ppp)) + eps);
4865 wmmm += wtmp;
4866 wpmm += wtmp;
4867 wmmp += wtmp;
4868 wpmp += wtmp;
4869
4870 wtmp = std::abs(sten(i,j,k,ist_0p0)) /
4871 ( std::abs(sten(i-1,j,k-1,ist_ppp))
4872 + std::abs(sten(i ,j,k-1,ist_ppp))
4873 + std::abs(sten(i-1,j,k ,ist_ppp))
4874 + std::abs(sten(i ,j,k ,ist_ppp)) + eps);
4875 wmpm += wtmp;
4876 wppm += wtmp;
4877 wmpp += wtmp;
4878 wppp += wtmp;
4879
4880 wtmp = std::abs(sten(i,j,k-1,ist_00p)) /
4881 ( std::abs(sten(i-1,j-1,k-1,ist_ppp))
4882 + std::abs(sten(i ,j-1,k-1,ist_ppp))
4883 + std::abs(sten(i-1,j ,k-1,ist_ppp))
4884 + std::abs(sten(i ,j ,k-1,ist_ppp)) + eps);
4885 wmmm += wtmp;
4886 wpmm += wtmp;
4887 wmpm += wtmp;
4888 wppm += wtmp;
4889
4890 wtmp = std::abs(sten(i,j,k,ist_00p)) /
4891 ( std::abs(sten(i-1,j-1,k,ist_ppp))
4892 + std::abs(sten(i ,j-1,k,ist_ppp))
4893 + std::abs(sten(i-1,j ,k,ist_ppp))
4894 + std::abs(sten(i ,j ,k,ist_ppp)) + eps);
4895 wmmp += wtmp;
4896 wpmp += wtmp;
4897 wmpp += wtmp;
4898 wppp += wtmp;
4899
4900 wtmp = std::abs(sten(i-1,j-1,k,ist_pp0)) /
4901 ( std::abs(sten(i-1,j-1,k-1,ist_ppp))
4902 + std::abs(sten(i-1,j-1,k ,ist_ppp)) + eps);
4903 wmmm += wtmp;
4904 wmmp += wtmp;
4905
4906 wtmp = std::abs(sten(i,j-1,k,ist_pp0)) /
4907 ( std::abs(sten(i,j-1,k-1,ist_ppp))
4908 + std::abs(sten(i,j-1,k ,ist_ppp)) + eps);
4909 wpmm += wtmp;
4910 wpmp += wtmp;
4911
4912 wtmp = std::abs(sten(i-1,j,k,ist_pp0)) /
4913 ( std::abs(sten(i-1,j,k-1,ist_ppp))
4914 + std::abs(sten(i-1,j,k ,ist_ppp)) + eps);
4915 wmpm += wtmp;
4916 wmpp += wtmp;
4917
4918 wtmp = std::abs(sten(i,j,k,ist_pp0)) /
4919 ( std::abs(sten(i,j,k-1,ist_ppp))
4920 + std::abs(sten(i,j,k ,ist_ppp)) + eps);
4921 wppm += wtmp;
4922 wppp += wtmp;
4923
4924 wtmp = std::abs(sten(i-1,j,k-1,ist_p0p)) /
4925 ( std::abs(sten(i-1,j-1,k-1,ist_ppp))
4926 + std::abs(sten(i-1,j ,k-1,ist_ppp)) + eps);
4927 wmmm += wtmp;
4928 wmpm += wtmp;
4929
4930 wtmp = std::abs(sten(i,j,k-1,ist_p0p)) /
4931 ( std::abs(sten(i,j-1,k-1,ist_ppp))
4932 + std::abs(sten(i,j ,k-1,ist_ppp)) + eps);
4933 wpmm += wtmp;
4934 wppm += wtmp;
4935
4936 wtmp = std::abs(sten(i-1,j,k,ist_p0p)) /
4937 ( std::abs(sten(i-1,j-1,k,ist_ppp))
4938 + std::abs(sten(i-1,j ,k,ist_ppp)) + eps);
4939 wmmp += wtmp;
4940 wmpp += wtmp;
4941
4942 wtmp = std::abs(sten(i,j,k,ist_p0p)) /
4943 ( std::abs(sten(i,j-1,k,ist_ppp))
4944 + std::abs(sten(i,j ,k,ist_ppp)) + eps);
4945 wpmp += wtmp;
4946 wppp += wtmp;
4947
4948 wtmp = std::abs(sten(i,j-1,k-1,ist_0pp)) /
4949 ( std::abs(sten(i-1,j-1,k-1,ist_ppp))
4950 + std::abs(sten(i ,j-1,k-1,ist_ppp)) + eps);
4951 wmmm += wtmp;
4952 wpmm += wtmp;
4953
4954 wtmp = std::abs(sten(i,j,k-1,ist_0pp)) /
4955 ( std::abs(sten(i-1,j,k-1,ist_ppp))
4956 + std::abs(sten(i ,j,k-1,ist_ppp)) + eps);
4957 wmpm += wtmp;
4958 wppm += wtmp;
4959
4960 wtmp = std::abs(sten(i,j-1,k,ist_0pp)) /
4961 ( std::abs(sten(i-1,j-1,k,ist_ppp))
4962 + std::abs(sten(i ,j-1,k,ist_ppp)) + eps);
4963 wmmp += wtmp;
4964 wpmp += wtmp;
4965
4966 wtmp = std::abs(sten(i,j,k,ist_0pp)) /
4967 ( std::abs(sten(i-1,j,k,ist_ppp))
4968 + std::abs(sten(i ,j,k,ist_ppp)) + eps);
4969 wmpp += wtmp;
4970 wppp += wtmp;
4971
4972 wmmm *= std::abs(sten(i-1,j-1,k-1,ist_ppp));
4973 wpmm *= std::abs(sten(i ,j-1,k-1,ist_ppp));
4974 wmpm *= std::abs(sten(i-1,j ,k-1,ist_ppp));
4975 wppm *= std::abs(sten(i ,j ,k-1,ist_ppp));
4976 wmmp *= std::abs(sten(i-1,j-1,k ,ist_ppp));
4977 wpmp *= std::abs(sten(i ,j-1,k ,ist_ppp));
4978 wmpp *= std::abs(sten(i-1,j ,k ,ist_ppp));
4979 wppp *= std::abs(sten(i ,j ,k ,ist_ppp));
4980 fv = (wmmm*crse(ic,jc ,kc ) + wpmm*crse(ic+1,jc ,kc )
4981 + wmpm*crse(ic,jc+1,kc ) + wppm*crse(ic+1,jc+1,kc )
4982 + wmmp*crse(ic,jc ,kc+1) + wpmp*crse(ic+1,jc ,kc+1)
4983 + wmpp*crse(ic,jc+1,kc+1) + wppp*crse(ic+1,jc+1,kc+1))
4984 / (wmmm + wpmm + wmpm + wppm + wmmp + wpmp + wmpp + wppp + eps);
4985 }
4986
4987 fine(i,j,k) += fv;
4988 }
4989}
4990
4992void mlndlap_restriction_rap (int i, int j, int k, Array4<Real> const& crse,
4993 Array4<Real const> const& fine, Array4<Real const> const& sten,
4994 Array4<int const> const& msk) noexcept
4995{
4996 using namespace nodelap_detail;
4997
4998 int ii = i*2;
4999 int jj = j*2;
5000 int kk = k*2;
5001 if (msk(ii,jj,kk)) {
5002 crse(i,j,k) = Real(0.0);
5003 } else {
5004
5005 Real cv = fine(ii,jj,kk);
5006
5007 // ************************************
5008 // Adding fine(ii-1,jj,kk)
5009 // ************************************
5010
5011 Real sten_lo = std::abs(sten(ii-2,jj,kk,ist_p00));
5012 Real sten_hi = std::abs(sten(ii-1,jj,kk,ist_p00));
5013
5014 if (sten_lo == Real(0.0) && sten_hi == Real(0.0)) {
5015 cv += Real(0.5)*fine(ii-1,jj,kk);
5016 } else {
5017 cv += fine(ii-1,jj,kk) * sten_hi / (sten_lo + sten_hi);
5018 }
5019
5020 // ************************************
5021 // Adding fine(ii+1,jj,kk)
5022 // ************************************
5023
5024 sten_lo = std::abs(sten(ii ,jj,kk,ist_p00));
5025 sten_hi = std::abs(sten(ii+1,jj,kk,ist_p00));
5026
5027 if (sten_lo == Real(0.0) && sten_hi == Real(0.0)) {
5028 cv += Real(0.5)*fine(ii+1,jj,kk);
5029 } else {
5030 cv += fine(ii+1,jj,kk) * sten_lo / (sten_lo + sten_hi);
5031 }
5032
5033 // ************************************
5034 // Adding fine(ii,jj-1,kk)
5035 // ************************************
5036
5037 sten_lo = std::abs(sten(ii,jj-2,kk,ist_0p0));
5038 sten_hi = std::abs(sten(ii,jj-1,kk,ist_0p0));
5039
5040 if (sten_lo == Real(0.0) && sten_hi == Real(0.0)) {
5041 cv += Real(0.5)*fine(ii,jj-1,kk);
5042 } else {
5043 cv += fine(ii,jj-1,kk) * sten_hi / (sten_lo + sten_hi);
5044 }
5045
5046 // ************************************
5047 // Adding fine(ii,jj+1,kk)
5048 // ************************************
5049
5050 sten_lo = std::abs(sten(ii,jj ,kk,ist_0p0));
5051 sten_hi = std::abs(sten(ii,jj+1,kk,ist_0p0));
5052
5053 if (sten_lo == Real(0.0) && sten_hi == Real(0.0)) {
5054 cv += Real(0.5)*fine(ii,jj+1,kk);
5055 } else {
5056 cv += fine(ii,jj+1,kk) * sten_lo / (sten_lo + sten_hi);
5057 }
5058
5059 // ************************************
5060 // Adding fine(ii,jj,kk-1)
5061 // ************************************
5062
5063 sten_lo = std::abs(sten(ii,jj,kk-2,ist_00p));
5064 sten_hi = std::abs(sten(ii,jj,kk-1,ist_00p));
5065
5066 if (sten_lo == Real(0.0) && sten_hi == Real(0.0)) {
5067 cv += Real(0.5)*fine(ii,jj,kk-1);
5068 } else {
5069 cv += fine(ii,jj,kk-1)*sten_hi / (sten_lo + sten_hi);
5070 }
5071
5072 // ************************************
5073 // Adding fine(ii,jj,kk+1)
5074 // ************************************
5075
5076 sten_lo = std::abs(sten(ii,jj,kk ,ist_00p));
5077 sten_hi = std::abs(sten(ii,jj,kk+1,ist_00p));
5078
5079 if (sten_lo == Real(0.0) && sten_hi == Real(0.0)) {
5080 cv += Real(0.5)*fine(ii,jj,kk+1);
5081 } else {
5082 cv += fine(ii,jj,kk+1)*sten_lo / (sten_lo + sten_hi);
5083 }
5084
5085 // ************************************
5086 // Adding fine(ii-1,jj-1,kk)
5087 // ************************************
5088
5089 // keven
5090 Real w1m = std::abs(sten(ii-2,jj-1,kk,ist_p00))
5091 / ( std::abs(sten(ii-2,jj-2,kk,ist_pp0))
5092 +std::abs(sten(ii-2,jj-1,kk,ist_pp0)) + eps);
5093 Real w1p = std::abs(sten(ii-1,jj-1,kk,ist_p00))
5094 / ( std::abs(sten(ii-1,jj-2,kk,ist_pp0))
5095 +std::abs(sten(ii-1,jj-1,kk,ist_pp0)) + eps);
5096 Real w2m = std::abs(sten(ii-1,jj-2,kk,ist_0p0))
5097 / ( std::abs(sten(ii-2,jj-2,kk,ist_pp0))
5098 +std::abs(sten(ii-1,jj-2,kk,ist_pp0)) + eps);
5099 Real w2p = std::abs(sten(ii-1,jj-1,kk,ist_0p0))
5100 / ( std::abs(sten(ii-2,jj-1,kk,ist_pp0))
5101 +std::abs(sten(ii-1,jj-1,kk,ist_pp0)) + eps);
5102 Real wmm = std::abs(sten(ii-2,jj-2,kk,ist_pp0)) * (Real(1.0) + w1m + w2m);
5103 Real wpm = std::abs(sten(ii-1,jj-2,kk,ist_pp0)) * (Real(1.0) + w1p + w2m);
5104 Real wmp = std::abs(sten(ii-2,jj-1,kk,ist_pp0)) * (Real(1.0) + w1m + w2p);
5105 Real wpp = std::abs(sten(ii-1,jj-1,kk,ist_pp0)) * (Real(1.0) + w1p + w2p);
5106 cv += fine(ii-1,jj-1,kk)*wpp/(wmm+wpm+wmp+wpp+eps);
5107
5108 // ************************************
5109 // Adding fine(ii+1,jj-1,kk)
5110 // ************************************
5111
5112 w1m = std::abs(sten(ii ,jj-1,kk,ist_p00))
5113 / (std::abs(sten(ii ,jj-2,kk,ist_pp0))
5114 +std::abs(sten(ii ,jj-1,kk,ist_pp0)) + eps);
5115 w1p = std::abs(sten(ii+1,jj-1,kk,ist_p00))
5116 / (std::abs(sten(ii+1,jj-2,kk,ist_pp0))
5117 +std::abs(sten(ii+1,jj-1,kk,ist_pp0)) + eps);
5118 w2m = std::abs(sten(ii+1,jj-2,kk,ist_0p0))
5119 / (std::abs(sten(ii ,jj-2,kk,ist_pp0))
5120 +std::abs(sten(ii+1,jj-2,kk,ist_pp0)) + eps);
5121 w2p = std::abs(sten(ii+1,jj-1,kk,ist_0p0))
5122 / (std::abs(sten(ii ,jj-1,kk,ist_pp0))
5123 +std::abs(sten(ii+1,jj-1,kk,ist_pp0)) + eps);
5124 wmm = std::abs(sten(ii ,jj-2,kk,ist_pp0)) * (Real(1.0) + w1m + w2m);
5125 wpm = std::abs(sten(ii+1,jj-2,kk,ist_pp0)) * (Real(1.0) + w1p + w2m);
5126 wmp = std::abs(sten(ii ,jj-1,kk,ist_pp0)) * (Real(1.0) + w1m + w2p);
5127 wpp = std::abs(sten(ii+1,jj-1,kk,ist_pp0)) * (Real(1.0) + w1p + w2p);
5128 cv += fine(ii+1,jj-1,kk)*wmp/(wmm+wpm+wmp+wpp+eps);
5129
5130 // ************************************
5131 // Adding fine(ii-1,jj+1,kk)
5132 // ************************************
5133
5134 w1m = std::abs(sten(ii-2,jj+1,kk,ist_p00))
5135 / (std::abs(sten(ii-2,jj ,kk,ist_pp0))
5136 +std::abs(sten(ii-2,jj+1,kk,ist_pp0)) + eps);
5137 w1p = std::abs(sten(ii-1,jj+1,kk,ist_p00))
5138 / (std::abs(sten(ii-1,jj ,kk,ist_pp0))
5139 +std::abs(sten(ii-1,jj+1,kk,ist_pp0)) + eps);
5140 w2m = std::abs(sten(ii-1,jj ,kk,ist_0p0))
5141 / (std::abs(sten(ii-2,jj ,kk,ist_pp0))
5142 +std::abs(sten(ii-1,jj ,kk,ist_pp0)) + eps);
5143 w2p = std::abs(sten(ii-1,jj+1,kk,ist_0p0))
5144 / (std::abs(sten(ii-2,jj+1,kk,ist_pp0))
5145 +std::abs(sten(ii-1,jj+1,kk,ist_pp0)) + eps);
5146 wmm = std::abs(sten(ii-2,jj ,kk,ist_pp0)) * (Real(1.0) + w1m + w2m);
5147 wpm = std::abs(sten(ii-1,jj ,kk,ist_pp0)) * (Real(1.0) + w1p + w2m);
5148 wmp = std::abs(sten(ii-2,jj+1,kk,ist_pp0)) * (Real(1.0) + w1m + w2p);
5149 wpp = std::abs(sten(ii-1,jj+1,kk,ist_pp0)) * (Real(1.0) + w1p + w2p);
5150 cv += fine(ii-1,jj+1,kk)*wpm/(wmm+wpm+wmp+wpp+eps);
5151
5152 // ************************************
5153 // Adding fine(ii+1,jj+1,kk)
5154 // ************************************
5155
5156 w1m = std::abs(sten(ii ,jj+1,kk,ist_p00))
5157 / (std::abs(sten(ii ,jj+1,kk,ist_pp0))
5158 +std::abs(sten(ii ,jj ,kk,ist_pp0)) + eps);
5159 w1p = std::abs(sten(ii+1,jj+1,kk,ist_p00))
5160 / (std::abs(sten(ii+1,jj+1,kk,ist_pp0))
5161 +std::abs(sten(ii+1,jj ,kk,ist_pp0)) + eps);
5162 w2m = std::abs(sten(ii+1,jj ,kk,ist_0p0))
5163 / (std::abs(sten(ii+1,jj ,kk,ist_pp0))
5164 +std::abs(sten(ii ,jj ,kk,ist_pp0)) + eps);
5165 w2p = std::abs(sten(ii+1,jj+1,kk,ist_0p0))
5166 / (std::abs(sten(ii+1,jj+1,kk,ist_pp0))
5167 +std::abs(sten(ii ,jj+1,kk,ist_pp0)) + eps);
5168 wmm = std::abs(sten(ii ,jj ,kk,ist_pp0)) * (Real(1.0) + w1m + w2m);
5169 wpm = std::abs(sten(ii+1,jj ,kk,ist_pp0)) * (Real(1.0) + w1p + w2m);
5170 wmp = std::abs(sten(ii ,jj+1,kk,ist_pp0)) * (Real(1.0) + w1m + w2p);
5171 wpp = std::abs(sten(ii+1,jj+1,kk,ist_pp0)) * (Real(1.0) + w1p + w2p);
5172 cv += fine(ii+1,jj+1,kk)*wmm/(wmm+wpm+wmp+wpp+eps);
5173
5174 // ************************************
5175 // Adding fine(ii-1,jj,kk-1)
5176 // ************************************
5177
5178 // jeven
5179 w1m = std::abs(sten(ii-2,jj,kk-1,ist_p00))
5180 / (std::abs(sten(ii-2,jj,kk-2,ist_p0p))
5181 +std::abs(sten(ii-2,jj,kk-1,ist_p0p)) + eps);
5182 w1p = std::abs(sten(ii-1,jj,kk-1,ist_p00))
5183 / (std::abs(sten(ii-1,jj,kk-2,ist_p0p))
5184 +std::abs(sten(ii-1,jj,kk-1,ist_p0p)) + eps);
5185 w2m = std::abs(sten(ii-1,jj,kk-2,ist_00p))
5186 / (std::abs(sten(ii-2,jj,kk-2,ist_p0p))
5187 +std::abs(sten(ii-1,jj,kk-2,ist_p0p)) + eps);
5188 w2p = std::abs(sten(ii-1,jj,kk-1,ist_00p))
5189 / (std::abs(sten(ii-2,jj,kk-1,ist_p0p))
5190 +std::abs(sten(ii-1,jj,kk-1,ist_p0p)) + eps);
5191 wmm = std::abs(sten(ii-2,jj,kk-2,ist_p0p)) * (Real(1.0) + w1m + w2m);
5192 wpm = std::abs(sten(ii-1,jj,kk-2,ist_p0p)) * (Real(1.0) + w1p + w2m);
5193 wmp = std::abs(sten(ii-2,jj,kk-1,ist_p0p)) * (Real(1.0) + w1m + w2p);
5194 wpp = std::abs(sten(ii-1,jj,kk-1,ist_p0p)) * (Real(1.0) + w1p + w2p);
5195 cv += fine(ii-1,jj,kk-1)*wpp/(wmm+wpm+wmp+wpp+eps);
5196
5197 // ************************************
5198 // Adding fine(ii+1,jj,kk-1)
5199 // ************************************
5200
5201 w1m = std::abs(sten(ii ,jj,kk-1,ist_p00))
5202 / (std::abs(sten(ii ,jj,kk-2,ist_p0p))
5203 +std::abs(sten(ii ,jj,kk-1,ist_p0p)) + eps);
5204 w1p = std::abs(sten(ii+1,jj,kk-1,ist_p00))
5205 / (std::abs(sten(ii+1,jj,kk-2,ist_p0p))
5206 +std::abs(sten(ii+1,jj,kk-1,ist_p0p)) + eps);
5207 w2m = std::abs(sten(ii+1,jj,kk-2,ist_00p))
5208 / (std::abs(sten(ii+1,jj,kk-2,ist_p0p))
5209 +std::abs(sten(ii ,jj,kk-2,ist_p0p)) + eps);
5210 w2p = std::abs(sten(ii+1,jj,kk-1,ist_00p))
5211 / (std::abs(sten(ii+1,jj,kk-1,ist_p0p))
5212 +std::abs(sten(ii ,jj,kk-1,ist_p0p)) + eps);
5213 wmm = std::abs(sten(ii ,jj,kk-2,ist_p0p)) * (Real(1.0) + w1m + w2m);
5214 wpm = std::abs(sten(ii+1,jj,kk-2,ist_p0p)) * (Real(1.0) + w1p + w2m);
5215 wmp = std::abs(sten(ii ,jj,kk-1,ist_p0p)) * (Real(1.0) + w1m + w2p);
5216 wpp = std::abs(sten(ii+1,jj,kk-1,ist_p0p)) * (Real(1.0) + w1p + w2p);
5217 cv += fine(ii+1,jj,kk-1)*wmp/(wmm+wpm+wmp+wpp+eps);
5218
5219 // ************************************
5220 // Adding fine(ii-1,jj,kk+1)
5221 // ************************************
5222
5223 w1m = std::abs(sten(ii-2,jj,kk+1,ist_p00))
5224 / (std::abs(sten(ii-2,jj,kk+1,ist_p0p))
5225 +std::abs(sten(ii-2,jj,kk ,ist_p0p)) + eps);
5226 w1p = std::abs(sten(ii-1,jj,kk+1,ist_p00))
5227 / (std::abs(sten(ii-1,jj,kk+1,ist_p0p))
5228 +std::abs(sten(ii-1,jj,kk ,ist_p0p)) + eps);
5229 w2m = std::abs(sten(ii-1,jj,kk ,ist_00p))
5230 / (std::abs(sten(ii-2,jj,kk ,ist_p0p))
5231 +std::abs(sten(ii-1,jj,kk ,ist_p0p)) + eps);
5232 w2p = std::abs(sten(ii-1,jj,kk+1,ist_00p))
5233 / (std::abs(sten(ii-2,jj,kk+1,ist_p0p))
5234 +std::abs(sten(ii-1,jj,kk+1,ist_p0p)) + eps);
5235 wmm = std::abs(sten(ii-2,jj,kk ,ist_p0p)) * (Real(1.0) + w1m + w2m);
5236 wpm = std::abs(sten(ii-1,jj,kk ,ist_p0p)) * (Real(1.0) + w1p + w2m);
5237 wmp = std::abs(sten(ii-2,jj,kk+1,ist_p0p)) * (Real(1.0) + w1m + w2p);
5238 wpp = std::abs(sten(ii-1,jj,kk+1,ist_p0p)) * (Real(1.0) + w1p + w2p);
5239 cv += fine(ii-1,jj,kk+1)*wpm/(wmm+wpm+wmp+wpp+eps);
5240
5241 // ************************************
5242 // Adding fine(ii+1,jj,kk+1)
5243 // ************************************
5244
5245 w1m = std::abs(sten(ii ,jj,kk+1,ist_p00))
5246 / (std::abs(sten(ii ,jj,kk+1,ist_p0p))
5247 +std::abs(sten(ii ,jj,kk ,ist_p0p)) + eps);
5248 w1p = std::abs(sten(ii+1,jj,kk+1,ist_p00))
5249 / (std::abs(sten(ii+1,jj,kk+1,ist_p0p))
5250 +std::abs(sten(ii+1,jj,kk ,ist_p0p)) + eps);
5251 w2m = std::abs(sten(ii+1,jj,kk ,ist_00p))
5252 / (std::abs(sten(ii+1,jj,kk ,ist_p0p))
5253 +std::abs(sten(ii ,jj,kk ,ist_p0p)) + eps);
5254 w2p = std::abs(sten(ii+1,jj,kk+1,ist_00p))
5255 / (std::abs(sten(ii+1,jj,kk+1,ist_p0p))
5256 +std::abs(sten(ii ,jj,kk+1,ist_p0p)) + eps);
5257 wmm = std::abs(sten(ii ,jj,kk ,ist_p0p)) * (Real(1.0) + w1m + w2m);
5258 wpm = std::abs(sten(ii+1,jj,kk ,ist_p0p)) * (Real(1.0) + w1p + w2m);
5259 wmp = std::abs(sten(ii ,jj,kk+1,ist_p0p)) * (Real(1.0) + w1m + w2p);
5260 wpp = std::abs(sten(ii+1,jj,kk+1,ist_p0p)) * (Real(1.0) + w1p + w2p);
5261 cv += fine(ii+1,jj,kk+1)*wmm/(wmm+wpm+wmp+wpp+eps);
5262
5263 // ************************************
5264 // Adding fine(ii,jj-1,kk-1)
5265 // ************************************
5266
5267 // ieven
5268 w1m = std::abs(sten(ii,jj-2,kk-1,ist_0p0))
5269 / (std::abs(sten(ii,jj-2,kk-2,ist_0pp))
5270 +std::abs(sten(ii,jj-2,kk-1,ist_0pp)) + eps);
5271 w2m = std::abs(sten(ii,jj-1,kk-2,ist_00p))
5272 / (std::abs(sten(ii,jj-2,kk-2,ist_0pp))
5273 +std::abs(sten(ii,jj-1,kk-2,ist_0pp)) + eps);
5274 w1p = std::abs(sten(ii,jj-1,kk-1,ist_0p0))
5275 / (std::abs(sten(ii,jj-1,kk-2,ist_0pp))
5276 +std::abs(sten(ii,jj-1,kk-1,ist_0pp)) + eps);
5277 w2p = std::abs(sten(ii,jj-1,kk-1,ist_00p))
5278 / (std::abs(sten(ii,jj-2,kk-1,ist_0pp))
5279 +std::abs(sten(ii,jj-1,kk-1,ist_0pp)) + eps);
5280 wmm = std::abs(sten(ii,jj-2,kk-2,ist_0pp)) * (Real(1.0) + w1m + w2m);
5281 wpm = std::abs(sten(ii,jj-1,kk-2,ist_0pp)) * (Real(1.0) + w1p + w2m);
5282 wmp = std::abs(sten(ii,jj-2,kk-1,ist_0pp)) * (Real(1.0) + w1m + w2p);
5283 wpp = std::abs(sten(ii,jj-1,kk-1,ist_0pp)) * (Real(1.0) + w1p + w2p);
5284 cv += fine(ii,jj-1,kk-1)*wpp/(wmm+wpm+wmp+wpp+eps);
5285
5286 // ************************************
5287 // Adding fine(ii,jj+1,kk-1)
5288 // ************************************
5289
5290 w1m = std::abs(sten(ii,jj ,kk-1,ist_0p0))
5291 / (std::abs(sten(ii,jj ,kk-2,ist_0pp))
5292 +std::abs(sten(ii,jj ,kk-1,ist_0pp)) + eps);
5293 w1p = std::abs(sten(ii,jj+1,kk-1,ist_0p0))
5294 / (std::abs(sten(ii,jj+1,kk-2,ist_0pp))
5295 +std::abs(sten(ii,jj+1,kk-1,ist_0pp)) + eps);
5296 w2m = std::abs(sten(ii,jj+1,kk-2,ist_00p))
5297 / (std::abs(sten(ii,jj+1,kk-2,ist_0pp))
5298 +std::abs(sten(ii,jj ,kk-2,ist_0pp)) + eps);
5299 w2p = std::abs(sten(ii,jj+1,kk-1,ist_00p))
5300 / (std::abs(sten(ii,jj+1,kk-1,ist_0pp))
5301 +std::abs(sten(ii,jj ,kk-1,ist_0pp)) + eps);
5302 wmm = std::abs(sten(ii,jj ,kk-2,ist_0pp)) * (Real(1.0) + w1m + w2m);
5303 wpm = std::abs(sten(ii,jj+1,kk-2,ist_0pp)) * (Real(1.0) + w1p + w2m);
5304 wmp = std::abs(sten(ii,jj ,kk-1,ist_0pp)) * (Real(1.0) + w1m + w2p);
5305 wpp = std::abs(sten(ii,jj+1,kk-1,ist_0pp)) * (Real(1.0) + w1p + w2p);
5306 cv += fine(ii,jj+1,kk-1)*wmp/(wmm+wpm+wmp+wpp+eps);
5307
5308 // ************************************
5309 // Adding fine(ii,jj-1,kk+1)
5310 // ************************************
5311
5312 w1m = std::abs(sten(ii,jj-2,kk+1,ist_0p0))
5313 / (std::abs(sten(ii,jj-2,kk+1,ist_0pp))
5314 +std::abs(sten(ii,jj-2,kk ,ist_0pp)) + eps);
5315 w1p = std::abs(sten(ii,jj-1,kk+1,ist_0p0))
5316 / (std::abs(sten(ii,jj-1,kk+1,ist_0pp))
5317 +std::abs(sten(ii,jj-1,kk ,ist_0pp)) + eps);
5318 w2m = std::abs(sten(ii,jj-1,kk ,ist_00p))
5319 / (std::abs(sten(ii,jj-2,kk ,ist_0pp))
5320 +std::abs(sten(ii,jj-1,kk ,ist_0pp)) + eps);
5321 w2p = std::abs(sten(ii,jj-1,kk+1,ist_00p))
5322 / (std::abs(sten(ii,jj-2,kk+1,ist_0pp))
5323 +std::abs(sten(ii,jj-1,kk+1,ist_0pp)) + eps);
5324 wmm = std::abs(sten(ii,jj-2,kk ,ist_0pp)) * (Real(1.0) + w1m + w2m);
5325 wpm = std::abs(sten(ii,jj-1,kk ,ist_0pp)) * (Real(1.0) + w1p + w2m);
5326 wmp = std::abs(sten(ii,jj-2,kk+1,ist_0pp)) * (Real(1.0) + w1m + w2p);
5327 wpp = std::abs(sten(ii,jj-1,kk+1,ist_0pp)) * (Real(1.0) + w1p + w2p);
5328 cv += fine(ii,jj-1,kk+1)*wpm/(wmm+wpm+wmp+wpp+eps);
5329
5330 // ************************************
5331 // Adding fine(ii,jj+1,kk+1)
5332 // ************************************
5333
5334 w1m = std::abs(sten(ii,jj ,kk+1,ist_0p0))
5335 / (std::abs(sten(ii,jj ,kk+1,ist_0pp))
5336 +std::abs(sten(ii,jj ,kk ,ist_0pp)) + eps);
5337 w1p = std::abs(sten(ii,jj+1,kk+1,ist_0p0))
5338 / (std::abs(sten(ii,jj+1,kk+1,ist_0pp))
5339 +std::abs(sten(ii,jj+1,kk ,ist_0pp)) + eps);
5340 w2m = std::abs(sten(ii,jj+1,kk ,ist_00p))
5341 / (std::abs(sten(ii,jj+1,kk ,ist_0pp))
5342 +std::abs(sten(ii,jj ,kk ,ist_0pp)) + eps);
5343 w2p = std::abs(sten(ii,jj+1,kk+1,ist_00p))
5344 / (std::abs(sten(ii,jj+1,kk+1,ist_0pp))
5345 +std::abs(sten(ii,jj ,kk+1,ist_0pp)) + eps);
5346 wmm = std::abs(sten(ii,jj ,kk ,ist_0pp)) * (Real(1.0) + w1m + w2m);
5347 wpm = std::abs(sten(ii,jj+1,kk ,ist_0pp)) * (Real(1.0) + w1p + w2m);
5348 wmp = std::abs(sten(ii,jj ,kk+1,ist_0pp)) * (Real(1.0) + w1m + w2p);
5349 wpp = std::abs(sten(ii,jj+1,kk+1,ist_0pp)) * (Real(1.0) + w1p + w2p);
5350 cv += fine(ii,jj+1,kk+1)*wmm/(wmm+wpm+wmp+wpp+eps);
5351
5352 // ************************************
5353 // Adding fine at corners
5354 // ************************************
5355
5356 Real wmmm = Real(1.0)
5357 + std::abs(sten(ii ,jj+1,kk+1,ist_p00)) /
5358 ( std::abs(sten(ii ,jj ,kk ,ist_ppp))
5359 + std::abs(sten(ii ,jj+1,kk ,ist_ppp))
5360 + std::abs(sten(ii ,jj ,kk+1,ist_ppp))
5361 + std::abs(sten(ii ,jj+1,kk+1,ist_ppp)) + eps)
5362 + std::abs(sten(ii+1,jj ,kk+1,ist_0p0)) /
5363 ( std::abs(sten(ii ,jj ,kk ,ist_ppp))
5364 + std::abs(sten(ii+1,jj ,kk ,ist_ppp))
5365 + std::abs(sten(ii ,jj ,kk+1,ist_ppp))
5366 + std::abs(sten(ii+1,jj ,kk+1,ist_ppp)) + eps)
5367 + std::abs(sten(ii+1,jj+1,kk ,ist_00p)) /
5368 ( std::abs(sten(ii ,jj ,kk ,ist_ppp))
5369 + std::abs(sten(ii+1,jj ,kk ,ist_ppp))
5370 + std::abs(sten(ii ,jj+1,kk ,ist_ppp))
5371 + std::abs(sten(ii+1,jj+1,kk ,ist_ppp)) + eps)
5372 + std::abs(sten(ii ,jj ,kk+1,ist_pp0)) /
5373 ( std::abs(sten(ii ,jj ,kk ,ist_ppp))
5374 + std::abs(sten(ii ,jj ,kk+1,ist_ppp)) + eps)
5375 + std::abs(sten(ii ,jj+1,kk ,ist_p0p)) /
5376 ( std::abs(sten(ii ,jj ,kk ,ist_ppp))
5377 + std::abs(sten(ii ,jj+1,kk ,ist_ppp)) + eps)
5378 + std::abs(sten(ii+1,jj ,kk ,ist_0pp)) /
5379 ( std::abs(sten(ii ,jj ,kk ,ist_ppp))
5380 + std::abs(sten(ii+1,jj ,kk ,ist_ppp)) + eps);
5381 wmmm *= std::abs(sten(ii,jj,kk,ist_ppp));
5382 cv += wmmm*fine(ii+1,jj+1,kk+1)*sten(ii+1,jj+1,kk+1,ist_inv);
5383
5384 Real wpmm = Real(1.0)
5385 + std::abs(sten(ii-1,jj+1,kk+1,ist_p00)) /
5386 ( std::abs(sten(ii-1,jj ,kk ,ist_ppp))
5387 + std::abs(sten(ii-1,jj+1,kk ,ist_ppp))
5388 + std::abs(sten(ii-1,jj ,kk+1,ist_ppp))
5389 + std::abs(sten(ii-1,jj+1,kk+1,ist_ppp)) + eps)
5390 + std::abs(sten(ii-1,jj ,kk+1,ist_0p0)) /
5391 ( std::abs(sten(ii-2,jj ,kk ,ist_ppp))
5392 + std::abs(sten(ii-1,jj ,kk ,ist_ppp))
5393 + std::abs(sten(ii-2,jj ,kk+1,ist_ppp))
5394 + std::abs(sten(ii-1,jj ,kk+1,ist_ppp)) + eps)
5395 + std::abs(sten(ii-1,jj+1,kk ,ist_00p)) /
5396 ( std::abs(sten(ii-2,jj ,kk ,ist_ppp))
5397 + std::abs(sten(ii-1,jj ,kk ,ist_ppp))
5398 + std::abs(sten(ii-2,jj+1,kk ,ist_ppp))
5399 + std::abs(sten(ii-1,jj+1,kk ,ist_ppp)) + eps)
5400 + std::abs(sten(ii-1,jj ,kk+1,ist_pp0)) /
5401 ( std::abs(sten(ii-1,jj ,kk ,ist_ppp))
5402 + std::abs(sten(ii-1,jj ,kk+1,ist_ppp)) + eps)
5403 + std::abs(sten(ii-1,jj+1,kk ,ist_p0p)) /
5404 ( std::abs(sten(ii-1,jj ,kk ,ist_ppp))
5405 + std::abs(sten(ii-1,jj+1,kk ,ist_ppp)) + eps)
5406 + std::abs(sten(ii-1,jj ,kk ,ist_0pp)) /
5407 ( std::abs(sten(ii-2,jj ,kk ,ist_ppp))
5408 + std::abs(sten(ii-1,jj ,kk ,ist_ppp)) + eps);
5409 wpmm *= std::abs(sten(ii-1,jj,kk,ist_ppp));
5410 cv += wpmm*fine(ii-1,jj+1,kk+1)*sten(ii-1,jj+1,kk+1,ist_inv);
5411
5412 Real wmpm = Real(1.0)
5413 + std::abs(sten(ii ,jj-1,kk+1,ist_p00)) /
5414 ( std::abs(sten(ii ,jj-2,kk ,ist_ppp))
5415 + std::abs(sten(ii ,jj-1,kk ,ist_ppp))
5416 + std::abs(sten(ii ,jj-2,kk+1,ist_ppp))
5417 + std::abs(sten(ii ,jj-1,kk+1,ist_ppp)) + eps)
5418 + std::abs(sten(ii+1,jj-1,kk+1,ist_0p0)) /
5419 ( std::abs(sten(ii ,jj-1,kk ,ist_ppp))
5420 + std::abs(sten(ii+1,jj-1,kk ,ist_ppp))
5421 + std::abs(sten(ii ,jj-1,kk+1,ist_ppp))
5422 + std::abs(sten(ii+1,jj-1,kk+1,ist_ppp)) + eps)
5423 + std::abs(sten(ii+1,jj-1,kk ,ist_00p)) /
5424 ( std::abs(sten(ii ,jj-2,kk ,ist_ppp))
5425 + std::abs(sten(ii+1,jj-2,kk ,ist_ppp))
5426 + std::abs(sten(ii ,jj-1,kk ,ist_ppp))
5427 + std::abs(sten(ii+1,jj-1,kk ,ist_ppp)) + eps)
5428 + std::abs(sten(ii ,jj-1,kk+1,ist_pp0)) /
5429 ( std::abs(sten(ii ,jj-1,kk ,ist_ppp))
5430 + std::abs(sten(ii ,jj-1,kk+1,ist_ppp)) + eps)
5431 + std::abs(sten(ii ,jj-1,kk ,ist_p0p)) /
5432 ( std::abs(sten(ii ,jj-2,kk ,ist_ppp))
5433 + std::abs(sten(ii ,jj-1,kk ,ist_ppp)) + eps)
5434 + std::abs(sten(ii+1,jj-1,kk ,ist_0pp)) /
5435 ( std::abs(sten(ii ,jj-1,kk ,ist_ppp))
5436 + std::abs(sten(ii+1,jj-1,kk ,ist_ppp)) + eps);
5437 wmpm *= std::abs(sten(ii ,jj-1,kk ,ist_ppp));
5438 cv += wmpm*fine(ii+1,jj-1,kk+1)*sten(ii+1,jj-1,kk+1,ist_inv);
5439
5440 Real wppm = Real(1.0)
5441 + std::abs(sten(ii-1,jj-1,kk+1,ist_p00)) /
5442 ( std::abs(sten(ii-1,jj-2,kk ,ist_ppp))
5443 + std::abs(sten(ii-1,jj-1,kk ,ist_ppp))
5444 + std::abs(sten(ii-1,jj-2,kk+1,ist_ppp))
5445 + std::abs(sten(ii-1,jj-1,kk+1,ist_ppp)) + eps)
5446 + std::abs(sten(ii-1,jj-1,kk+1,ist_0p0)) /
5447 ( std::abs(sten(ii-2,jj-1,kk ,ist_ppp))
5448 + std::abs(sten(ii-1,jj-1,kk ,ist_ppp))
5449 + std::abs(sten(ii-2,jj-1,kk+1,ist_ppp))
5450 + std::abs(sten(ii-1,jj-1,kk+1,ist_ppp)) + eps)
5451 + std::abs(sten(ii-1,jj-1,kk ,ist_00p)) /
5452 ( std::abs(sten(ii-2,jj-2,kk ,ist_ppp))
5453 + std::abs(sten(ii-1,jj-2,kk ,ist_ppp))
5454 + std::abs(sten(ii-2,jj-1,kk ,ist_ppp))
5455 + std::abs(sten(ii-1,jj-1,kk ,ist_ppp)) + eps)
5456 + std::abs(sten(ii-1,jj-1,kk+1,ist_pp0)) /
5457 ( std::abs(sten(ii-1,jj-1,kk ,ist_ppp))
5458 + std::abs(sten(ii-1,jj-1,kk+1,ist_ppp)) + eps)
5459 + std::abs(sten(ii-1,jj-1,kk ,ist_p0p)) /
5460 ( std::abs(sten(ii-1,jj-2,kk ,ist_ppp))
5461 + std::abs(sten(ii-1,jj-1,kk ,ist_ppp)) + eps)
5462 + std::abs(sten(ii-1,jj-1,kk ,ist_0pp)) /
5463 ( std::abs(sten(ii-2,jj-1,kk ,ist_ppp))
5464 + std::abs(sten(ii-1,jj-1,kk ,ist_ppp)) + eps);
5465 wppm *= std::abs(sten(ii-1,jj-1,kk ,ist_ppp));
5466 cv += wppm*fine(ii-1,jj-1,kk+1)*sten(ii-1,jj-1,kk+1,ist_inv);
5467
5468 Real wmmp = Real(1.0)
5469 + std::abs(sten(ii ,jj+1,kk-1,ist_p00)) /
5470 ( std::abs(sten(ii ,jj ,kk-2,ist_ppp))
5471 + std::abs(sten(ii ,jj+1,kk-2,ist_ppp))
5472 + std::abs(sten(ii ,jj ,kk-1,ist_ppp))
5473 + std::abs(sten(ii ,jj+1,kk-1,ist_ppp)) + eps)
5474 + std::abs(sten(ii+1,jj ,kk-1,ist_0p0)) /
5475 ( std::abs(sten(ii ,jj ,kk-2,ist_ppp))
5476 + std::abs(sten(ii+1,jj ,kk-2,ist_ppp))
5477 + std::abs(sten(ii ,jj ,kk-1,ist_ppp))
5478 + std::abs(sten(ii+1,jj ,kk-1,ist_ppp)) + eps)
5479 + std::abs(sten(ii+1,jj+1,kk-1,ist_00p)) /
5480 ( std::abs(sten(ii ,jj ,kk-1,ist_ppp))
5481 + std::abs(sten(ii+1,jj ,kk-1,ist_ppp))
5482 + std::abs(sten(ii ,jj+1,kk-1,ist_ppp))
5483 + std::abs(sten(ii+1,jj+1,kk-1,ist_ppp)) + eps)
5484 + std::abs(sten(ii ,jj ,kk-1,ist_pp0)) /
5485 ( std::abs(sten(ii ,jj ,kk-2,ist_ppp))
5486 + std::abs(sten(ii ,jj ,kk-1,ist_ppp)) + eps)
5487 + std::abs(sten(ii ,jj+1,kk-1,ist_p0p)) /
5488 ( std::abs(sten(ii ,jj ,kk-1,ist_ppp))
5489 + std::abs(sten(ii ,jj+1,kk-1,ist_ppp)) + eps)
5490 + std::abs(sten(ii+1,jj ,kk-1,ist_0pp)) /
5491 ( std::abs(sten(ii ,jj ,kk-1,ist_ppp))
5492 + std::abs(sten(ii+1,jj ,kk-1,ist_ppp)) + eps);
5493 wmmp *= std::abs(sten(ii ,jj ,kk-1,ist_ppp));
5494 cv += wmmp*fine(ii+1,jj+1,kk-1)*sten(ii+1,jj+1,kk-1,ist_inv);
5495
5496 Real wpmp = Real(1.0)
5497 + std::abs(sten(ii-1,jj+1,kk-1,ist_p00)) /
5498 ( std::abs(sten(ii-1,jj ,kk-2,ist_ppp))
5499 + std::abs(sten(ii-1,jj+1,kk-2,ist_ppp))
5500 + std::abs(sten(ii-1,jj ,kk-1,ist_ppp))
5501 + std::abs(sten(ii-1,jj+1,kk-1,ist_ppp)) + eps)
5502 + std::abs(sten(ii-1,jj ,kk-1,ist_0p0)) /
5503 ( std::abs(sten(ii-2,jj ,kk-2,ist_ppp))
5504 + std::abs(sten(ii-1,jj ,kk-2,ist_ppp))
5505 + std::abs(sten(ii-2,jj ,kk-1,ist_ppp))
5506 + std::abs(sten(ii-1,jj ,kk-1,ist_ppp)) + eps)
5507 + std::abs(sten(ii-1,jj+1,kk-1,ist_00p)) /
5508 ( std::abs(sten(ii-2,jj ,kk-1,ist_ppp))
5509 + std::abs(sten(ii-1,jj ,kk-1,ist_ppp))
5510 + std::abs(sten(ii-2,jj+1,kk-1,ist_ppp))
5511 + std::abs(sten(ii-1,jj+1,kk-1,ist_ppp)) + eps)
5512 + std::abs(sten(ii-1,jj ,kk-1,ist_pp0)) /
5513 ( std::abs(sten(ii-1,jj ,kk-2,ist_ppp))
5514 + std::abs(sten(ii-1,jj ,kk-1,ist_ppp)) + eps)
5515 + std::abs(sten(ii-1,jj+1,kk-1,ist_p0p)) /
5516 ( std::abs(sten(ii-1,jj ,kk-1,ist_ppp))
5517 + std::abs(sten(ii-1,jj+1,kk-1,ist_ppp)) + eps)
5518 + std::abs(sten(ii-1,jj ,kk-1,ist_0pp)) /
5519 ( std::abs(sten(ii-2,jj ,kk-1,ist_ppp))
5520 + std::abs(sten(ii-1,jj ,kk-1,ist_ppp)) + eps);
5521 wpmp *= std::abs(sten(ii-1,jj ,kk-1,ist_ppp));
5522 cv += wpmp*fine(ii-1,jj+1,kk-1)*sten(ii-1,jj+1,kk-1,ist_inv);
5523
5524 Real wmpp = Real(1.0)
5525 + std::abs(sten(ii ,jj-1,kk-1,ist_p00)) /
5526 ( std::abs(sten(ii ,jj-2,kk-2,ist_ppp))
5527 + std::abs(sten(ii ,jj-1,kk-2,ist_ppp))
5528 + std::abs(sten(ii ,jj-2,kk-1,ist_ppp))
5529 + std::abs(sten(ii ,jj-1,kk-1,ist_ppp)) + eps)
5530 + std::abs(sten(ii+1,jj-1,kk-1,ist_0p0)) /
5531 ( std::abs(sten(ii ,jj-1,kk-2,ist_ppp))
5532 + std::abs(sten(ii+1,jj-1,kk-2,ist_ppp))
5533 + std::abs(sten(ii ,jj-1,kk-1,ist_ppp))
5534 + std::abs(sten(ii+1,jj-1,kk-1,ist_ppp)) + eps)
5535 + std::abs(sten(ii+1,jj-1,kk-1,ist_00p)) /
5536 ( std::abs(sten(ii ,jj-2,kk-1,ist_ppp))
5537 + std::abs(sten(ii+1,jj-2,kk-1,ist_ppp))
5538 + std::abs(sten(ii ,jj-1,kk-1,ist_ppp))
5539 + std::abs(sten(ii+1,jj-1,kk-1,ist_ppp)) + eps)
5540 + std::abs(sten(ii ,jj-1,kk-1,ist_pp0)) /
5541 ( std::abs(sten(ii ,jj-1,kk-2,ist_ppp))
5542 + std::abs(sten(ii ,jj-1,kk-1,ist_ppp)) + eps)
5543 + std::abs(sten(ii ,jj-1,kk-1,ist_p0p)) /
5544 ( std::abs(sten(ii ,jj-2,kk-1,ist_ppp))
5545 + std::abs(sten(ii ,jj-1,kk-1,ist_ppp)) + eps)
5546 + std::abs(sten(ii+1,jj-1,kk-1,ist_0pp)) /
5547 ( std::abs(sten(ii ,jj-1,kk-1,ist_ppp))
5548 + std::abs(sten(ii+1,jj-1,kk-1,ist_ppp)) + eps);
5549 wmpp *= std::abs(sten(ii ,jj-1,kk-1,ist_ppp));
5550 cv += wmpp*fine(ii+1,jj-1,kk-1)*sten(ii+1,jj-1,kk-1,ist_inv);
5551
5552 Real wppp = Real(1.0)
5553 + std::abs(sten(ii-1,jj-1,kk-1,ist_p00)) /
5554 ( std::abs(sten(ii-1,jj-2,kk-2,ist_ppp))
5555 + std::abs(sten(ii-1,jj-1,kk-2,ist_ppp))
5556 + std::abs(sten(ii-1,jj-2,kk-1,ist_ppp))
5557 + std::abs(sten(ii-1,jj-1,kk-1,ist_ppp)) + eps)
5558 + std::abs(sten(ii-1,jj-1,kk-1,ist_0p0)) /
5559 ( std::abs(sten(ii-2,jj-1,kk-2,ist_ppp))
5560 + std::abs(sten(ii-1,jj-1,kk-2,ist_ppp))
5561 + std::abs(sten(ii-2,jj-1,kk-1,ist_ppp))
5562 + std::abs(sten(ii-1,jj-1,kk-1,ist_ppp)) + eps)
5563 + std::abs(sten(ii-1,jj-1,kk-1,ist_00p)) /
5564 ( std::abs(sten(ii-2,jj-2,kk-1,ist_ppp))
5565 + std::abs(sten(ii-1,jj-2,kk-1,ist_ppp))
5566 + std::abs(sten(ii-2,jj-1,kk-1,ist_ppp))
5567 + std::abs(sten(ii-1,jj-1,kk-1,ist_ppp)) + eps)
5568 + std::abs(sten(ii-1,jj-1,kk-1,ist_pp0)) /
5569 ( std::abs(sten(ii-1,jj-1,kk-2,ist_ppp))
5570 + std::abs(sten(ii-1,jj-1,kk-1,ist_ppp)) + eps)
5571 + std::abs(sten(ii-1,jj-1,kk-1,ist_p0p)) /
5572 ( std::abs(sten(ii-1,jj-2,kk-1,ist_ppp))
5573 + std::abs(sten(ii-1,jj-1,kk-1,ist_ppp)) + eps)
5574 + std::abs(sten(ii-1,jj-1,kk-1,ist_0pp)) /
5575 ( std::abs(sten(ii-2,jj-1,kk-1,ist_ppp))
5576 + std::abs(sten(ii-1,jj-1,kk-1,ist_ppp)) + eps);
5577 wppp *= std::abs(sten(ii-1,jj-1,kk-1,ist_ppp));
5578 cv += wppp*fine(ii-1,jj-1,kk-1)*sten(ii-1,jj-1,kk-1,ist_inv);
5579
5580 crse(i,j,k) = cv * Real(0.125);
5581 }
5582}
5583
5584#ifdef AMREX_USE_EB
5585
5587namespace nodelap_detail {
5588
5589 constexpr int i_S_x = 0;
5590 constexpr int i_S_y = 1;
5591 constexpr int i_S_z = 2;
5592 constexpr int i_S_x2 = 3;
5593 constexpr int i_S_y2 = 4;
5594 constexpr int i_S_z2 = 5;
5595 constexpr int i_S_x_y = 6;
5596 constexpr int i_S_x_z = 7;
5597 constexpr int i_S_y_z = 8;
5598 constexpr int i_S_x2_y = 9;
5599 constexpr int i_S_x2_z = 10;
5600 constexpr int i_S_x_y2 = 11;
5601 constexpr int i_S_y2_z = 12;
5602 constexpr int i_S_x_z2 = 13;
5603 constexpr int i_S_y_z2 = 14;
5604 constexpr int i_S_x2_y2 = 15;
5605 constexpr int i_S_x2_z2 = 16;
5606 constexpr int i_S_y2_z2 = 17;
5607 constexpr int i_S_xyz = 18;
5608 constexpr int n_Sintg = 19;
5609
5610 constexpr int i_c_xmym = 0;
5611 constexpr int i_c_xmyb = 1;
5612 constexpr int i_c_xmyp = 2;
5613 constexpr int i_c_xbym = 3;
5614 constexpr int i_c_xbyb = 4;
5615 constexpr int i_c_xbyp = 5;
5616 constexpr int i_c_xpym = 6;
5617 constexpr int i_c_xpyb = 7;
5618 constexpr int i_c_xpyp = 8;
5619 constexpr int i_c_xmzm = 9;
5620 constexpr int i_c_xmzb = 10;
5621 constexpr int i_c_xmzp = 11;
5622 constexpr int i_c_xbzm = 12;
5623 constexpr int i_c_xbzb = 13;
5624 constexpr int i_c_xbzp = 14;
5625 constexpr int i_c_xpzm = 15;
5626 constexpr int i_c_xpzb = 16;
5627 constexpr int i_c_xpzp = 17;
5628 constexpr int i_c_ymzm = 18;
5629 constexpr int i_c_ymzb = 19;
5630 constexpr int i_c_ymzp = 20;
5631 constexpr int i_c_ybzm = 21;
5632 constexpr int i_c_ybzb = 22;
5633 constexpr int i_c_ybzp = 23;
5634 constexpr int i_c_ypzm = 24;
5635 constexpr int i_c_ypzb = 25;
5636 constexpr int i_c_ypzp = 26;
5637 constexpr int n_conn = 27;
5638
5639 constexpr int i_B_x = 0;
5640 constexpr int i_B_y = 1;
5641 constexpr int i_B_z = 2;
5642 constexpr int i_B_x_y = 3;
5643 constexpr int i_B_x_z = 4;
5644 constexpr int i_B_y_z = 5;
5645 constexpr int i_B_xyz = 6;
5646 constexpr int numSurfIntgs = 7;
5647
5648}
5650
5652void mlndlap_set_connection (int i, int j, int k, Array4<Real> const& conn,
5653 Array4<Real const> const& intg, Array4<Real const> const& vol,
5654 Array4<EBCellFlag const> const& flag) noexcept
5655{
5656 using namespace nodelap_detail;
5657
5658 if (flag(i,j,k).isCovered()) {
5659 for (int n = 0; n < n_conn; ++n) { conn(i,j,k,n) = Real(0.); }
5660 } else if (flag(i,j,k).isRegular() || vol(i,j,k) >= almostone) {
5661 for (int n = 0; n < n_conn; ++n) { conn(i,j,k,n) = Real(1.); }
5662 } else {
5663 // Scaled by 9
5664 conn(i,j,k,i_c_xmym) = Real(0.5625)*vol(i,j,k)
5665 + Real(2.25)*(-intg(i,j,k,i_S_x ) - intg(i,j,k,i_S_y)
5666 +intg(i,j,k,i_S_x2) + intg(i,j,k,i_S_y2))
5667 + Real(9.)*( intg(i,j,k,i_S_x_y ) - intg(i,j,k,i_S_x2_y)
5668 -intg(i,j,k,i_S_x_y2) + intg(i,j,k,i_S_x2_y2));
5669
5670 // Scaled by 18
5671 conn(i,j,k,i_c_xmyb) = Real(1.125)*vol(i,j,k)
5672 + Real(4.5)*(-intg(i,j,k,i_S_x) + intg(i,j,k,i_S_x2) - intg(i,j,k,i_S_y2))
5673 + Real(18.)*( intg(i,j,k,i_S_x_y2) - intg(i,j,k,i_S_x2_y2));
5674
5675 // Scaled by 9
5676 conn(i,j,k,i_c_xmyp) = Real(0.5625)*vol(i,j,k)
5677 + Real(2.25)*(-intg(i,j,k,i_S_x ) + intg(i,j,k,i_S_y)
5678 +intg(i,j,k,i_S_x2) + intg(i,j,k,i_S_y2))
5679 + Real(9.)*(-intg(i,j,k,i_S_x_y ) + intg(i,j,k,i_S_x2_y)
5680 -intg(i,j,k,i_S_x_y2) + intg(i,j,k,i_S_x2_y2));
5681
5682 // Scaled by 18
5683 conn(i,j,k,i_c_xbym) = Real(1.125)*vol(i,j,k)
5684 + Real(4.5)*(-intg(i,j,k,i_S_y) - intg(i,j,k,i_S_x2) + intg(i,j,k,i_S_y2))
5685 + Real(18.)*(intg(i,j,k,i_S_x2_y) - intg(i,j,k,i_S_x2_y2));
5686
5687 // Scaled by 36
5688 conn(i,j,k,i_c_xbyb) = Real(2.25)*vol(i,j,k)
5689 + Real(9.)*(-intg(i,j,k,i_S_x2) - intg(i,j,k,i_S_y2))
5690 + Real(36.)*intg(i,j,k,i_S_x2_y2);
5691
5692 // Scaled by 18
5693 conn(i,j,k,i_c_xbyp) = Real(1.125)*vol(i,j,k)
5694 + Real(4.5)*( intg(i,j,k,i_S_y) - intg(i,j,k,i_S_x2) + intg(i,j,k,i_S_y2))
5695 + Real(18.)*(-intg(i,j,k,i_S_x2_y) - intg(i,j,k,i_S_x2_y2));
5696
5697 // Scaled by 9
5698 conn(i,j,k,i_c_xpym) = Real(0.5625)*vol(i,j,k)
5699 + Real(2.25)*( intg(i,j,k,i_S_x ) - intg(i,j,k,i_S_y)
5700 +intg(i,j,k,i_S_x2) + intg(i,j,k,i_S_y2))
5701 + Real(9.)*(-intg(i,j,k,i_S_x_y ) - intg(i,j,k,i_S_x2_y)
5702 +intg(i,j,k,i_S_x_y2) + intg(i,j,k,i_S_x2_y2));
5703
5704 // Scaled by 18
5705 conn(i,j,k,i_c_xpyb) = Real(1.125)*vol(i,j,k)
5706 + Real(4.5)*( intg(i,j,k,i_S_x) + intg(i,j,k,i_S_x2) - intg(i,j,k,i_S_y2))
5707 + Real(18.)*(-intg(i,j,k,i_S_x_y2) - intg(i,j,k,i_S_x2_y2));
5708
5709 // Scaled by 9
5710 conn(i,j,k,i_c_xpyp) = Real(0.5625)*vol(i,j,k)
5711 + Real(2.25)*( intg(i,j,k,i_S_x ) + intg(i,j,k,i_S_y)
5712 +intg(i,j,k,i_S_x2) + intg(i,j,k,i_S_y2))
5713 + Real(9.)*( intg(i,j,k,i_S_x_y ) + intg(i,j,k,i_S_x2_y)
5714 +intg(i,j,k,i_S_x_y2) + intg(i,j,k,i_S_x2_y2));
5715
5716 // Scaled by 9
5717 conn(i,j,k,i_c_xmzm) = Real(0.5625)*vol(i,j,k)
5718 + Real(2.25)*(-intg(i,j,k,i_S_x) - intg(i,j,k,i_S_z)
5719 +intg(i,j,k,i_S_x2) + intg(i,j,k,i_S_z2))
5720 + Real(9.)*(intg(i,j,k,i_S_x_z) - intg(i,j,k,i_S_x2_z)
5721 -intg(i,j,k,i_S_x_z2) + intg(i,j,k,i_S_x2_z2));
5722
5723 // Scaled by 18
5724 conn(i,j,k,i_c_xmzb) = Real(1.125)*vol(i,j,k)
5725 + Real(4.5)*(-intg(i,j,k,i_S_x) + intg(i,j,k,i_S_x2) - intg(i,j,k,i_S_z2))
5726 + Real(18.)*(intg(i,j,k,i_S_x_z2) - intg(i,j,k,i_S_x2_z2));
5727
5728 // Scaled by 9
5729 conn(i,j,k,i_c_xmzp) = Real(0.5625)*vol(i,j,k)
5730 + Real(2.25)*(-intg(i,j,k,i_S_x ) + intg(i,j,k,i_S_z)
5731 +intg(i,j,k,i_S_x2) + intg(i,j,k,i_S_z2))
5732 + Real(9.)*(-intg(i,j,k,i_S_x_z ) + intg(i,j,k,i_S_x2_z)
5733 -intg(i,j,k,i_S_x_z2) + intg(i,j,k,i_S_x2_z2));
5734
5735 // Scaled by 18
5736 conn(i,j,k,i_c_xbzm) = Real(1.125)*vol(i,j,k)
5737 + Real(4.5)*(-intg(i,j,k,i_S_z) - intg(i,j,k,i_S_x2) + intg(i,j,k,i_S_z2))
5738 + Real(18.)*(intg(i,j,k,i_S_x2_z) - intg(i,j,k,i_S_x2_z2));
5739
5740 // Scaled by 18
5741 conn(i,j,k,i_c_xbzb) = Real(2.25)*vol(i,j,k)
5742 + Real(9.)*(-intg(i,j,k,i_S_x2) - intg(i,j,k,i_S_z2))
5743 + Real(36.)*intg(i,j,k,i_S_x2_z2);
5744
5745 // Scaled by 18
5746 conn(i,j,k,i_c_xbzp) = Real(1.125)*vol(i,j,k)
5747 + Real(4.5)*( intg(i,j,k,i_S_z) - intg(i,j,k,i_S_x2) + intg(i,j,k,i_S_z2))
5748 + Real(18.)*(-intg(i,j,k,i_S_x2_z) - intg(i,j,k,i_S_x2_z2));
5749
5750 // Scaled by 9
5751 conn(i,j,k,i_c_xpzm) = Real(0.5625)*vol(i,j,k)
5752 + Real(2.25)*( intg(i,j,k,i_S_x ) - intg(i,j,k,i_S_z)
5753 +intg(i,j,k,i_S_x2) + intg(i,j,k,i_S_z2))
5754 + Real(9.)*(-intg(i,j,k,i_S_x_z ) - intg(i,j,k,i_S_x2_z)
5755 +intg(i,j,k,i_S_x_z2) + intg(i,j,k,i_S_x2_z2));
5756
5757 // Scaled by 18
5758 conn(i,j,k,i_c_xpzb) = Real(1.125)*vol(i,j,k)
5759 + Real(4.5)*( intg(i,j,k,i_S_x ) + intg(i,j,k,i_S_x2 ) - intg(i,j,k,i_S_z2))
5760 + Real(18.)*(-intg(i,j,k,i_S_x_z2) - intg(i,j,k,i_S_x2_z2));
5761
5762 // Scaled by 9
5763 conn(i,j,k,i_c_xpzp) = Real(0.5625)*vol(i,j,k)
5764 + Real(2.25)*( intg(i,j,k,i_S_x ) + intg(i,j,k,i_S_z)
5765 +intg(i,j,k,i_S_x2) + intg(i,j,k,i_S_z2))
5766 + Real(9.)*( intg(i,j,k,i_S_x_z ) + intg(i,j,k,i_S_x2_z)
5767 +intg(i,j,k,i_S_x_z2) + intg(i,j,k,i_S_x2_z2));
5768
5769 // Scaled by 9
5770 conn(i,j,k,i_c_ymzm) = Real(0.5625)*vol(i,j,k)
5771 + Real(2.25)*(-intg(i,j,k,i_S_y) - intg(i,j,k,i_S_z)
5772 +intg(i,j,k,i_S_y2) + intg(i,j,k,i_S_z2))
5773 + Real(9.)*(intg(i,j,k,i_S_y_z) - intg(i,j,k,i_S_y2_z)
5774 -intg(i,j,k,i_S_y_z2) + intg(i,j,k,i_S_y2_z2));
5775
5776 // Scaled by 18
5777 conn(i,j,k,i_c_ymzb) = Real(1.125)*vol(i,j,k)
5778 + Real(4.5)*(-intg(i,j,k,i_S_y) + intg(i,j,k,i_S_y2) - intg(i,j,k,i_S_z2))
5779 + Real(18.)*(intg(i,j,k,i_S_y_z2) - intg(i,j,k,i_S_y2_z2));
5780
5781 // Scaled by 9
5782 conn(i,j,k,i_c_ymzp) = Real(0.5625)*vol(i,j,k)
5783 + Real(2.25)*(-intg(i,j,k,i_S_y ) + intg(i,j,k,i_S_z)
5784 +intg(i,j,k,i_S_y2) + intg(i,j,k,i_S_z2))
5785 + Real(9.)*(-intg(i,j,k,i_S_y_z ) + intg(i,j,k,i_S_y2_z)
5786 -intg(i,j,k,i_S_y_z2) + intg(i,j,k,i_S_y2_z2));
5787
5788 // Scaled by 18
5789 conn(i,j,k,i_c_ybzm) = Real(1.125)*vol(i,j,k)
5790 + Real(4.5)*(-intg(i,j,k,i_S_z) - intg(i,j,k,i_S_y2) + intg(i,j,k,i_S_z2))
5791 + Real(18.)*(intg(i,j,k,i_S_y2_z) - intg(i,j,k,i_S_y2_z2));
5792
5793 // Scaled by 36
5794 conn(i,j,k,i_c_ybzb) = Real(2.25)*vol(i,j,k)
5795 + Real(9.)*(-intg(i,j,k,i_S_y2) - intg(i,j,k,i_S_z2))
5796 + Real(36.)*intg(i,j,k,i_S_y2_z2);
5797
5798 // Scaled by 18
5799 conn(i,j,k,i_c_ybzp) = Real(1.125)*vol(i,j,k)
5800 + Real(4.5)*( intg(i,j,k,i_S_z) - intg(i,j,k,i_S_y2) + intg(i,j,k,i_S_z2))
5801 + Real(18.)*(-intg(i,j,k,i_S_y2_z) - intg(i,j,k,i_S_y2_z2));
5802
5803 // Scaled by 9
5804 conn(i,j,k,i_c_ypzm) = Real(0.5625)*vol(i,j,k)
5805 + Real(2.25)*( intg(i,j,k,i_S_y ) - intg(i,j,k,i_S_z)
5806 +intg(i,j,k,i_S_y2) + intg(i,j,k,i_S_z2))
5807 + Real(9.)*(-intg(i,j,k,i_S_y_z ) - intg(i,j,k,i_S_y2_z)
5808 +intg(i,j,k,i_S_y_z2) + intg(i,j,k,i_S_y2_z2));
5809
5810 // Scaled by 18
5811 conn(i,j,k,i_c_ypzb) = Real(1.125)*vol(i,j,k)
5812 + Real(4.5)*( intg(i,j,k,i_S_y ) + intg(i,j,k,i_S_y2) - intg(i,j,k,i_S_z2))
5813 + Real(18.)*(-intg(i,j,k,i_S_y_z2) - intg(i,j,k,i_S_y2_z2));
5814
5815 // Scaled by 9
5816 conn(i,j,k,i_c_ypzp) = Real(0.5625)*vol(i,j,k)
5817 + Real(2.25)*( intg(i,j,k,i_S_y ) + intg(i,j,k,i_S_z)
5818 +intg(i,j,k,i_S_y2) + intg(i,j,k,i_S_z2))
5819 + Real(9.)*( intg(i,j,k,i_S_y_z ) + intg(i,j,k,i_S_y2_z)
5820 +intg(i,j,k,i_S_y_z2) + intg(i,j,k,i_S_y2_z2));
5821 }
5822}
5823
5825void mlndlap_set_stencil_eb (int i, int j, int k, Array4<Real> const& sten,
5826 Array4<Real const> const& sig, Array4<Real const> const& conn,
5827 GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
5828{
5829 using namespace nodelap_detail;
5830
5831 Real facx = Real(1./36.)*dxinv[0]*dxinv[0];
5832 Real facy = Real(1./36.)*dxinv[1]*dxinv[1];
5833 Real facz = Real(1./36.)*dxinv[2]*dxinv[2];
5834
5835 // i+1,j,k
5836 sten(i,j,k,ist_p00) = (
5837 sig(i,j ,k )*(Real(4.)*facx*conn(i,j ,k ,i_c_ymzm) - Real(2.)*facy*conn(i,j ,k ,i_c_xbzm) - Real(2.)*facz*conn(i,j ,k ,i_c_xbym) ) +
5838 sig(i,j-1,k )*(Real(4.)*facx*conn(i,j-1,k ,i_c_ypzm) - Real(2.)*facy*conn(i,j-1,k ,i_c_xbzm) - Real(2.)*facz*conn(i,j-1,k ,i_c_xbyp) ) +
5839 sig(i,j ,k-1)*(Real(4.)*facx*conn(i,j ,k-1,i_c_ymzp) - Real(2.)*facy*conn(i,j ,k-1,i_c_xbzp) - Real(2.)*facz*conn(i,j ,k-1,i_c_xbym) ) +
5840 sig(i,j-1,k-1)*(Real(4.)*facx*conn(i,j-1,k-1,i_c_ypzp) - Real(2.)*facy*conn(i,j-1,k-1,i_c_xbzp) - Real(2.)*facz*conn(i,j-1,k-1,i_c_xbyp) ) );
5841
5842 // i,j+1,k
5843 sten(i,j,k,ist_0p0) = (
5844 sig(i ,j,k )*(Real(-2.)*facx*conn(i ,j,k ,i_c_ybzm) + Real(4.)*facy*conn(i ,j,k ,i_c_xmzm) - Real(2.)*facz*conn(i ,j,k ,i_c_xmyb) ) +
5845 sig(i-1,j,k )*(Real(-2.)*facx*conn(i-1,j,k ,i_c_ybzm) + Real(4.)*facy*conn(i-1,j,k ,i_c_xpzm) - Real(2.)*facz*conn(i-1,j,k ,i_c_xpyb) ) +
5846 sig(i ,j,k-1)*(Real(-2.)*facx*conn(i ,j,k-1,i_c_ybzp) + Real(4.)*facy*conn(i ,j,k-1,i_c_xmzp) - Real(2.)*facz*conn(i ,j,k-1,i_c_xmyb) ) +
5847 sig(i-1,j,k-1)*(Real(-2.)*facx*conn(i-1,j,k-1,i_c_ybzp) + Real(4.)*facy*conn(i-1,j,k-1,i_c_xpzp) - Real(2.)*facz*conn(i-1,j,k-1,i_c_xpyb) ) );
5848
5849 // i,j,k+1
5850 sten(i,j,k,ist_00p) = (
5851 sig(i ,j ,k)*(Real(-2.)*facx*conn(i ,j ,k,i_c_ymzb) - Real(2.)*facy*conn(i ,j ,k,i_c_xmzb) + Real(4.)*facz*conn(i ,j ,k,i_c_xmym) ) +
5852 sig(i-1,j ,k)*(Real(-2.)*facx*conn(i-1,j ,k,i_c_ymzb) - Real(2.)*facy*conn(i-1,j ,k,i_c_xpzb) + Real(4.)*facz*conn(i-1,j ,k,i_c_xpym) ) +
5853 sig(i ,j-1,k)*(Real(-2.)*facx*conn(i ,j-1,k,i_c_ypzb) - Real(2.)*facy*conn(i ,j-1,k,i_c_xmzb) + Real(4.)*facz*conn(i ,j-1,k,i_c_xmyp) ) +
5854 sig(i-1,j-1,k)*(Real(-2.)*facx*conn(i-1,j-1,k,i_c_ypzb) - Real(2.)*facy*conn(i-1,j-1,k,i_c_xpzb) + Real(4.)*facz*conn(i-1,j-1,k,i_c_xpyp) ) );
5855
5856 // i+1,j+1,k
5857 sten(i,j,k,ist_pp0) = (
5858 sig(i,j,k )*(Real(2.)*facx*conn(i,j,k ,i_c_ybzm) + Real(2.)*facy*conn(i,j,k ,i_c_xbzm) - facz*conn(i,j,k ,i_c_xbyb) ) +
5859 sig(i,j,k-1)*(Real(2.)*facx*conn(i,j,k-1,i_c_ybzp) + Real(2.)*facy*conn(i,j,k-1,i_c_xbzp) - facz*conn(i,j,k-1,i_c_xbyb) ) );
5860
5861 // i+1,j,k+1
5862 sten(i,j,k,ist_p0p) = (
5863 sig(i,j,k )*(Real(2.)*facx*conn(i,j,k ,i_c_ymzb) - facy*conn(i,j,k ,i_c_xbzb) + Real(2.)*facz*conn(i,j,k ,i_c_xbym) ) +
5864 sig(i,j-1,k)*(Real(2.)*facx*conn(i,j-1,k,i_c_ypzb) - facy*conn(i,j-1,k,i_c_xbzb) + Real(2.)*facz*conn(i,j-1,k,i_c_xbyp) ) );
5865
5866 // i,j+1,k+1
5867 sten(i,j,k,ist_0pp) = (
5868 sig(i ,j,k)*(-facx*conn(i ,j,k,i_c_ybzb) + Real(2.)*facy*conn(i ,j,k,i_c_xmzb) + Real(2.)*facz*conn(i ,j,k,i_c_xmyb) ) +
5869 sig(i-1,j,k)*(-facx*conn(i-1,j,k,i_c_ybzb) + Real(2.)*facy*conn(i-1,j,k,i_c_xpzb) + Real(2.)*facz*conn(i-1,j,k,i_c_xpyb) ) );
5870
5871 // i+1,j+1,k+1
5872 sten(i,j,k,ist_ppp) = sig(i,j,k) * (facx*conn(i,j,k,i_c_ybzb) + facy*conn(i,j,k,i_c_xbzb) + facz*conn(i,j,k,i_c_xbyb) );
5873}
5874
5876void mlndlap_divu_eb (int i, int j, int k, Array4<Real> const& rhs, Array4<Real const> const& vel,
5877 Array4<Real const> const& vfrac, Array4<Real const> const& intg,
5878 Array4<int const> const& msk, GpuArray<Real,AMREX_SPACEDIM> const& dxinv,
5879 Box const& nodal_domain,
5880 GpuArray<LinOpBCType, AMREX_SPACEDIM> const& bclo,
5881 GpuArray<LinOpBCType, AMREX_SPACEDIM> const& bchi) noexcept
5882{
5883 using namespace nodelap_detail;
5884
5885 Real facx = Real(0.25)*dxinv[0];
5886 Real facy = Real(0.25)*dxinv[1];
5887 Real facz = Real(0.25)*dxinv[2];
5888
5889 const auto domlo = amrex::lbound(nodal_domain);
5890 const auto domhi = amrex::ubound(nodal_domain);
5891
5892 if (!msk(i,j,k)) {
5893
5894 Real zero_ilo = Real(1.0);
5895 Real zero_ihi = Real(1.0);
5896 Real zero_jlo = Real(1.0);
5897 Real zero_jhi = Real(1.0);
5898 Real zero_klo = Real(1.0);
5899 Real zero_khi = Real(1.0);
5900
5901 // The nodal divergence operator should not see the tangential velocity
5902 // at an inflow face
5903 if ((bclo[0] == LinOpBCType::Neumann || bclo[0] == LinOpBCType::inflow)
5904 && i == domlo.x)
5905 {
5906 zero_ilo = Real(0.0);
5907 }
5908 if ((bchi[0] == LinOpBCType::Neumann || bchi[0] == LinOpBCType::inflow)
5909 && i == domhi.x)
5910 {
5911 zero_ihi = Real(0.0);
5912 }
5913 if ((bclo[1] == LinOpBCType::Neumann || bclo[1] == LinOpBCType::inflow)
5914 && j == domlo.y)
5915 {
5916 zero_jlo = Real(0.0);
5917 }
5918 if ((bchi[1] == LinOpBCType::Neumann || bchi[1] == LinOpBCType::inflow)
5919 && j == domhi.y)
5920 {
5921 zero_jhi = Real(0.0);
5922 }
5923 if ((bclo[2] == LinOpBCType::Neumann || bclo[2] == LinOpBCType::inflow)
5924 && k == domlo.z)
5925 {
5926 zero_klo = Real(0.0);
5927 }
5928 if ((bchi[2] == LinOpBCType::Neumann || bchi[2] == LinOpBCType::inflow)
5929 && k == domhi.z)
5930 {
5931 zero_khi = Real(0.0);
5932 }
5933
5934 rhs(i,j,k) = facx*(
5935 vel(i-1,j-1,k ,0)*( -vfrac(i-1,j-1,k )
5936 -Real(2.)*intg(i-1,j-1,k ,i_S_y)
5937 +Real(2.)*intg(i-1,j-1,k ,i_S_z)
5938 +Real(4.)*intg(i-1,j-1,k ,i_S_y_z))*zero_jlo*zero_khi
5939 +vel(i ,j-1,k ,0)*( vfrac(i ,j-1,k )
5940 +Real(2.)*intg(i ,j-1,k ,i_S_y)
5941 -Real(2.)*intg(i ,j-1,k ,i_S_z)
5942 -Real(4.)*intg(i ,j-1,k ,i_S_y_z))*zero_jlo*zero_khi
5943 +vel(i-1,j ,k ,0)*( -vfrac(i-1,j ,k )
5944 +Real(2.)*intg(i-1,j ,k ,i_S_y)
5945 +Real(2.)*intg(i-1,j ,k ,i_S_z)
5946 -Real(4.)*intg(i-1,j ,k ,i_S_y_z))*zero_jhi*zero_khi
5947 +vel(i ,j ,k ,0)*( vfrac(i ,j ,k )
5948 -Real(2.)*intg(i ,j ,k ,i_S_y)
5949 -Real(2.)*intg(i ,j ,k ,i_S_z)
5950 +Real(4.)*intg(i ,j ,k ,i_S_y_z))*zero_jhi*zero_khi
5951 +vel(i-1,j-1,k-1,0)*( -vfrac(i-1,j-1,k-1)
5952 -Real(2.)*intg(i-1,j-1,k-1,i_S_y)
5953 -Real(2.)*intg(i-1,j-1,k-1,i_S_z)
5954 -Real(4.)*intg(i-1,j-1,k-1,i_S_y_z))*zero_jlo*zero_klo
5955 +vel(i ,j-1,k-1,0)*( vfrac(i ,j-1,k-1)
5956 +Real(2.)*intg(i ,j-1,k-1,i_S_y)
5957 +Real(2.)*intg(i ,j-1,k-1,i_S_z)
5958 +Real(4.)*intg(i ,j-1,k-1,i_S_y_z))*zero_jlo*zero_klo
5959 +vel(i-1,j ,k-1,0)*( -vfrac(i-1,j ,k-1)
5960 +Real(2.)*intg(i-1,j ,k-1,i_S_y)
5961 -Real(2.)*intg(i-1,j ,k-1,i_S_z)
5962 +Real(4.)*intg(i-1,j ,k-1,i_S_y_z))*zero_jhi*zero_klo
5963 +vel(i ,j ,k-1,0)*( vfrac(i ,j ,k-1)
5964 -Real(2.)*intg(i ,j ,k-1,i_S_y)
5965 +Real(2.)*intg(i ,j ,k-1,i_S_z)
5966 -Real(4.)*intg(i ,j ,k-1,i_S_y_z))*zero_jhi*zero_klo )
5967 + facy*(
5968 vel(i-1,j-1,k ,1)*( -vfrac(i-1,j-1,k )
5969 -Real(2.)*intg(i-1,j-1,k ,i_S_x)
5970 +Real(2.)*intg(i-1,j-1,k ,i_S_z)
5971 +Real(4.)*intg(i-1,j-1,k ,i_S_x_z))*zero_ilo*zero_khi
5972 +vel(i ,j-1,k ,1)*( -vfrac(i ,j-1,k )
5973 +Real(2.)*intg(i ,j-1,k ,i_S_x)
5974 +Real(2.)*intg(i ,j-1,k ,i_S_z)
5975 -Real(4.)*intg(i ,j-1,k ,i_S_x_z))*zero_ihi*zero_khi
5976 +vel(i-1,j ,k ,1)*( vfrac(i-1,j ,k )
5977 +Real(2.)*intg(i-1,j ,k ,i_S_x)
5978 -Real(2.)*intg(i-1,j ,k ,i_S_z)
5979 -Real(4.)*intg(i-1,j ,k ,i_S_x_z))*zero_ilo*zero_khi
5980 +vel(i ,j ,k ,1)*( vfrac(i ,j ,k )
5981 -Real(2.)*intg(i ,j ,k ,i_S_x)
5982 -Real(2.)*intg(i ,j ,k ,i_S_z)
5983 +Real(4.)*intg(i ,j ,k ,i_S_x_z))*zero_ihi*zero_khi
5984 +vel(i-1,j-1,k-1,1)*( -vfrac(i-1,j-1,k-1)
5985 -Real(2.)*intg(i-1,j-1,k-1,i_S_x)
5986 -Real(2.)*intg(i-1,j-1,k-1,i_S_z)
5987 -Real(4.)*intg(i-1,j-1,k-1,i_S_x_z))*zero_ilo*zero_klo
5988 +vel(i ,j-1,k-1,1)*( -vfrac(i ,j-1,k-1)
5989 +Real(2.)*intg(i ,j-1,k-1,i_S_x)
5990 -Real(2.)*intg(i ,j-1,k-1,i_S_z)
5991 +Real(4.)*intg(i ,j-1,k-1,i_S_x_z))*zero_ihi*zero_klo
5992 +vel(i-1,j ,k-1,1)*( vfrac(i-1,j ,k-1)
5993 +Real(2.)*intg(i-1,j ,k-1,i_S_x)
5994 +Real(2.)*intg(i-1,j ,k-1,i_S_z)
5995 +Real(4.)*intg(i-1,j ,k-1,i_S_x_z))*zero_ilo*zero_klo
5996 +vel(i ,j ,k-1,1)*( vfrac(i ,j ,k-1)
5997 -Real(2.)*intg(i ,j ,k-1,i_S_x)
5998 +Real(2.)*intg(i ,j ,k-1,i_S_z)
5999 -Real(4.)*intg(i ,j ,k-1,i_S_x_z))*zero_ihi*zero_klo )
6000 + facz*(
6001 vel(i-1,j-1,k ,2)*( vfrac(i-1,j-1,k )
6002 +Real(2.)*intg(i-1,j-1,k ,i_S_x)
6003 +Real(2.)*intg(i-1,j-1,k ,i_S_y)
6004 +Real(4.)*intg(i-1,j-1,k ,i_S_x_y))*zero_ilo*zero_jlo
6005 +vel(i ,j-1,k ,2)*( vfrac(i ,j-1,k )
6006 -Real(2.)*intg(i ,j-1,k ,i_S_x)
6007 +Real(2.)*intg(i ,j-1,k ,i_S_y)
6008 -Real(4.)*intg(i ,j-1,k ,i_S_x_y))*zero_ihi*zero_jlo
6009 +vel(i-1,j ,k ,2)*( vfrac(i-1,j ,k )
6010 +Real(2.)*intg(i-1,j ,k ,i_S_x)
6011 -Real(2.)*intg(i-1,j ,k ,i_S_y)
6012 -Real(4.)*intg(i-1,j ,k ,i_S_x_y))*zero_ilo*zero_jhi
6013 +vel(i ,j ,k ,2)*( vfrac(i ,j ,k )
6014 -Real(2.)*intg(i ,j ,k ,i_S_x)
6015 -Real(2.)*intg(i ,j ,k ,i_S_y)
6016 +Real(4.)*intg(i ,j ,k ,i_S_x_y))*zero_ihi*zero_jhi
6017 +vel(i-1,j-1,k-1,2)*( -vfrac(i-1,j-1,k-1)
6018 -Real(2.)*intg(i-1,j-1,k-1,i_S_x)
6019 -Real(2.)*intg(i-1,j-1,k-1,i_S_y)
6020 -Real(4.)*intg(i-1,j-1,k-1,i_S_x_y))*zero_ilo*zero_jlo
6021 +vel(i ,j-1,k-1,2)*( -vfrac(i ,j-1,k-1)
6022 +Real(2.)*intg(i ,j-1,k-1,i_S_x)
6023 -Real(2.)*intg(i ,j-1,k-1,i_S_y)
6024 +Real(4.)*intg(i ,j-1,k-1,i_S_x_y))*zero_ihi*zero_jlo
6025 +vel(i-1,j ,k-1,2)*( -vfrac(i-1,j ,k-1)
6026 -Real(2.)*intg(i-1,j ,k-1,i_S_x)
6027 +Real(2.)*intg(i-1,j ,k-1,i_S_y)
6028 +Real(4.)*intg(i-1,j ,k-1,i_S_x_y))*zero_ilo*zero_jhi
6029 +vel(i ,j ,k-1,2)*( -vfrac(i ,j ,k-1)
6030 +Real(2.)*intg(i ,j ,k-1,i_S_x)
6031 +Real(2.)*intg(i ,j ,k-1,i_S_y)
6032 -Real(4.)*intg(i ,j ,k-1,i_S_x_y))*zero_ihi*zero_jhi );
6033 } else {
6034 rhs(i,j,k) = Real(0.);
6035 }
6036}
6037
6039void add_eb_flow_contribution (int i, int j, int k, Array4<Real> const& rhs,
6040 Array4<int const> const& msk, GpuArray<Real,AMREX_SPACEDIM> const& dxinv,
6041 Array4<Real const> const& bareaarr,
6042 Array4<Real const> const& sintg,
6043 Array4<Real const> const& eb_vel_dot_n) noexcept
6044{
6045 using namespace nodelap_detail;
6046
6047 Real fac_eb = Real(0.125) * dxinv[0];
6048
6049 if (!msk(i,j,k)) {
6050 rhs(i,j,k) += fac_eb*(
6051 eb_vel_dot_n(i-1,j-1,k )*( bareaarr(i-1,j-1,k)
6052 +Real(2.)*sintg(i-1,j-1,k ,i_B_x)
6053 +Real(2.)*sintg(i-1,j-1,k ,i_B_y)
6054 +Real(4.)*sintg(i-1,j-1,k ,i_B_x_y)
6055 -Real(2.)*sintg(i-1,j-1,k ,i_B_z)
6056 -Real(4.)*sintg(i-1,j-1,k ,i_B_y_z)
6057 -Real(4.)*sintg(i-1,j-1,k ,i_B_x_z)
6058 -Real(8.)*sintg(i-1,j-1,k ,i_B_xyz))
6059 +eb_vel_dot_n(i ,j-1,k )*( bareaarr(i ,j-1,k)
6060 -Real(2.)*sintg(i ,j-1,k ,i_B_x)
6061 +Real(2.)*sintg(i ,j-1,k ,i_B_y)
6062 -Real(4.)*sintg(i ,j-1,k ,i_B_x_y)
6063 -Real(2.)*sintg(i ,j-1,k ,i_B_z)
6064 -Real(4.)*sintg(i ,j-1,k ,i_B_y_z)
6065 +Real(4.)*sintg(i ,j-1,k ,i_B_x_z)
6066 +Real(8.)*sintg(i ,j-1,k ,i_B_xyz))
6067 +eb_vel_dot_n(i-1,j ,k )*( bareaarr(i-1,j ,k)
6068 +Real(2.)*sintg(i-1,j ,k ,i_B_x)
6069 -Real(2.)*sintg(i-1,j ,k ,i_B_y)
6070 -Real(4.)*sintg(i-1,j ,k ,i_B_x_y)
6071 -Real(2.)*sintg(i-1,j ,k ,i_B_z)
6072 +Real(4.)*sintg(i-1,j ,k ,i_B_y_z)
6073 -Real(4.)*sintg(i-1,j ,k ,i_B_x_z)
6074 +Real(8.)*sintg(i-1,j ,k ,i_B_xyz))
6075 +eb_vel_dot_n(i ,j ,k )*( bareaarr(i ,j ,k)
6076 -Real(2.)*sintg(i ,j ,k ,i_B_x)
6077 -Real(2.)*sintg(i ,j ,k ,i_B_y)
6078 +Real(4.)*sintg(i ,j ,k ,i_B_x_y)
6079 -Real(2.)*sintg(i ,j ,k ,i_B_z)
6080 +Real(4.)*sintg(i ,j ,k ,i_B_y_z)
6081 +Real(4.)*sintg(i ,j ,k ,i_B_x_z)
6082 -Real(8.)*sintg(i ,j ,k ,i_B_xyz))
6083 +eb_vel_dot_n(i-1,j-1,k-1)*( bareaarr(i-1,j-1,k-1)
6084 +Real(2.)*sintg(i-1,j-1,k-1,i_B_x)
6085 +Real(2.)*sintg(i-1,j-1,k-1,i_B_y)
6086 +Real(4.)*sintg(i-1,j-1,k-1,i_B_x_y)
6087 +Real(2.)*sintg(i-1,j-1,k-1,i_B_z)
6088 +Real(4.)*sintg(i-1,j-1,k-1,i_B_y_z)
6089 +Real(4.)*sintg(i-1,j-1,k-1,i_B_x_z)
6090 +Real(8.)*sintg(i-1,j-1,k-1,i_B_xyz))
6091 +eb_vel_dot_n(i ,j-1,k-1)*( bareaarr(i ,j-1,k-1)
6092 -Real(2.)*sintg(i ,j-1,k-1,i_B_x)
6093 +Real(2.)*sintg(i ,j-1,k-1,i_B_y)
6094 -Real(4.)*sintg(i ,j-1,k-1,i_B_x_y)
6095 +Real(2.)*sintg(i ,j-1,k-1,i_B_z)
6096 +Real(4.)*sintg(i ,j-1,k-1,i_B_y_z)
6097 -Real(4.)*sintg(i ,j-1,k-1,i_B_x_z)
6098 -Real(8.)*sintg(i ,j-1,k-1,i_B_xyz))
6099 +eb_vel_dot_n(i-1,j ,k-1)*( bareaarr(i-1,j ,k-1)
6100 +Real(2.)*sintg(i-1,j ,k-1,i_B_x)
6101 -Real(2.)*sintg(i-1,j ,k-1,i_B_y)
6102 -Real(4.)*sintg(i-1,j ,k-1,i_B_x_y)
6103 +Real(2.)*sintg(i-1,j ,k-1,i_B_z)
6104 -Real(4.)*sintg(i-1,j ,k-1,i_B_y_z)
6105 +Real(4.)*sintg(i-1,j ,k-1,i_B_x_z)
6106 -Real(8.)*sintg(i-1,j ,k-1,i_B_xyz))
6107 +eb_vel_dot_n(i ,j ,k-1)*( bareaarr(i ,j ,k-1)
6108 -Real(2.)*sintg(i ,j ,k-1,i_B_x)
6109 -Real(2.)*sintg(i ,j ,k-1,i_B_y)
6110 +Real(4.)*sintg(i ,j ,k-1,i_B_x_y)
6111 +Real(2.)*sintg(i ,j ,k-1,i_B_z)
6112 -Real(4.)*sintg(i ,j ,k-1,i_B_y_z)
6113 -Real(4.)*sintg(i ,j ,k-1,i_B_x_z)
6114 +Real(8.)*sintg(i ,j ,k-1,i_B_xyz)));
6115 }
6116}
6117
6119void mlndlap_mknewu_eb (int i, int j, int k, Array4<Real> const& u, Array4<Real const> const& p,
6120 Array4<Real const> const& sig, Array4<Real const> const& vfrac,
6121 Array4<Real const> const& intg, GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
6122{
6123 using namespace nodelap_detail;
6124
6125 if (vfrac(i,j,k) == Real(0.)) {
6126 u(i,j,k,0) = u(i,j,k,1) = u(i,j,k,2) = Real(0.);
6127 } else {
6128 Real dpdx = Real(0.25)*(-p(i,j,k )+p(i+1,j,k )-p(i,j+1,k )+p(i+1,j+1,k )
6129 -p(i,j,k+1)+p(i+1,j,k+1)-p(i,j+1,k+1)+p(i+1,j+1,k+1));
6130 Real dpdy = Real(0.25)*(-p(i,j,k )-p(i+1,j,k )+p(i,j+1,k )+p(i+1,j+1,k )
6131 -p(i,j,k+1)-p(i+1,j,k+1)+p(i,j+1,k+1)+p(i+1,j+1,k+1));
6132 Real dpdz = Real(0.25)*(-p(i,j,k )-p(i+1,j,k )-p(i,j+1,k )-p(i+1,j+1,k )
6133 +p(i,j,k+1)+p(i+1,j,k+1)+p(i,j+1,k+1)+p(i+1,j+1,k+1));
6134
6135 Real dpp_xy = (p(i+1,j+1,k+1) - p(i,j+1,k+1) - p(i+1,j,k+1) + p(i,j,k+1)
6136 +p(i+1,j+1,k ) - p(i,j+1,k ) - p(i+1,j,k ) + p(i,j,k ) ) / vfrac(i,j,k);
6137
6138 Real dpp_xz = (p(i+1,j+1,k+1) - p(i,j+1,k+1) + p(i+1,j,k+1) - p(i,j,k+1)
6139 -p(i+1,j+1,k ) + p(i,j+1,k ) - p(i+1,j,k ) + p(i,j,k ) ) / vfrac(i,j,k);
6140
6141 Real dpp_yz = (p(i+1,j+1,k+1) + p(i,j+1,k+1) - p(i+1,j,k+1) - p(i,j,k+1)
6142 -p(i+1,j+1,k ) - p(i,j+1,k ) + p(i+1,j,k ) + p(i,j,k ) ) / vfrac(i,j,k);
6143
6144 Real dpp_xyz = (p(i+1,j+1,k+1) - p(i,j+1,k+1) - p(i+1,j,k+1) + p(i,j,k+1)
6145 -p(i+1,j+1,k ) + p(i,j+1,k ) + p(i+1,j,k ) - p(i,j,k ) ) / vfrac(i,j,k);
6146
6147 u(i,j,k,0) -= sig(i,j,k)*dxinv[0]*(dpdx + Real(0.5)*intg(i,j,k,i_S_y )*dpp_xy +
6148 Real(0.5)*intg(i,j,k,i_S_z )*dpp_xz +
6149 intg(i,j,k,i_S_y_z)*dpp_xyz );
6150 u(i,j,k,1) -= sig(i,j,k)*dxinv[1]*(dpdy + Real(0.5)*intg(i,j,k,i_S_x )*dpp_xy +
6151 Real(0.5)*intg(i,j,k,i_S_z )*dpp_yz +
6152 intg(i,j,k,i_S_x_z)*dpp_xyz );
6153 u(i,j,k,2) -= sig(i,j,k)*dxinv[2]*(dpdz + Real(0.5)*intg(i,j,k,i_S_x )*dpp_xz +
6154 Real(0.5)*intg(i,j,k,i_S_y )*dpp_yz +
6155 intg(i,j,k,i_S_x_y)*dpp_xyz );
6156 }
6157}
6158
6160void mlndlap_mknewu_eb_c (int i, int j, int k, Array4<Real> const& u, Array4<Real const> const& p,
6161 Real sig, Array4<Real const> const& vfrac,
6162 Array4<Real const> const& intg, GpuArray<Real,AMREX_SPACEDIM> const& dxinv) noexcept
6163{
6164 using namespace nodelap_detail;
6165
6166 if (vfrac(i,j,k) == Real(0.)) {
6167 u(i,j,k,0) = u(i,j,k,1) = u(i,j,k,2) = Real(0.);
6168 } else {
6169 Real dpdx = Real(0.25)*(-p(i,j,k )+p(i+1,j,k )-p(i,j+1,k )+p(i+1,j+1,k )
6170 -p(i,j,k+1)+p(i+1,j,k+1)-p(i,j+1,k+1)+p(i+1,j+1,k+1));
6171 Real dpdy = Real(0.25)*(-p(i,j,k )-p(i+1,j,k )+p(i,j+1,k )+p(i+1,j+1,k )
6172 -p(i,j,k+1)-p(i+1,j,k+1)+p(i,j+1,k+1)+p(i+1,j+1,k+1));
6173 Real dpdz = Real(0.25)*(-p(i,j,k )-p(i+1,j,k )-p(i,j+1,k )-p(i+1,j+1,k )
6174 +p(i,j,k+1)+p(i+1,j,k+1)+p(i,j+1,k+1)+p(i+1,j+1,k+1));
6175
6176 Real dpp_xy = (p(i+1,j+1,k+1) - p(i,j+1,k+1) - p(i+1,j,k+1) + p(i,j,k+1)
6177 +p(i+1,j+1,k ) - p(i,j+1,k ) - p(i+1,j,k ) + p(i,j,k ) ) / vfrac(i,j,k);
6178
6179 Real dpp_xz = (p(i+1,j+1,k+1) - p(i,j+1,k+1) + p(i+1,j,k+1) - p(i,j,k+1)
6180 -p(i+1,j+1,k ) + p(i,j+1,k ) - p(i+1,j,k ) + p(i,j,k ) ) / vfrac(i,j,k);
6181
6182 Real dpp_yz = (p(i+1,j+1,k+1) + p(i,j+1,k+1) - p(i+1,j,k+1) - p(i,j,k+1)
6183 -p(i+1,j+1,k ) - p(i,j+1,k ) + p(i+1,j,k ) + p(i,j,k ) ) / vfrac(i,j,k);
6184
6185 Real dpp_xyz = (p(i+1,j+1,k+1) - p(i,j+1,k+1) - p(i+1,j,k+1) + p(i,j,k+1)
6186 -p(i+1,j+1,k ) + p(i,j+1,k ) + p(i+1,j,k ) - p(i,j,k ) ) / vfrac(i,j,k);
6187
6188 u(i,j,k,0) -= sig*dxinv[0]*(dpdx + Real(0.5)*intg(i,j,k,i_S_y )*dpp_xy +
6189 Real(0.5)*intg(i,j,k,i_S_z )*dpp_xz +
6190 intg(i,j,k,i_S_y_z)*dpp_xyz );
6191 u(i,j,k,1) -= sig*dxinv[1]*(dpdy + Real(0.5)*intg(i,j,k,i_S_x )*dpp_xy +
6192 Real(0.5)*intg(i,j,k,i_S_z )*dpp_yz +
6193 intg(i,j,k,i_S_x_z)*dpp_xyz );
6194 u(i,j,k,2) -= sig*dxinv[2]*(dpdz + Real(0.5)*intg(i,j,k,i_S_x )*dpp_xz +
6195 Real(0.5)*intg(i,j,k,i_S_y )*dpp_yz +
6196 intg(i,j,k,i_S_x_y)*dpp_xyz );
6197 }
6198}
6199
6201Real mlndlap_rhcc_eb (int i, int j, int k, Array4<Real const> const& rhcc,
6202 Array4<Real const> const& vfrac, Array4<Real const> const& intg,
6203 Array4<int const> const& msk) noexcept
6204{
6205 using namespace nodelap_detail;
6206
6207 if (!msk(i,j,k)) {
6208 return
6209 rhcc(i ,j ,k ) *
6210 ( Real(0.125) * vfrac(i ,j ,k )
6211 + Real(0.25) * (-intg(i ,j ,k ,i_S_x)
6212 -intg(i ,j ,k ,i_S_y)
6213 -intg(i ,j ,k ,i_S_z))
6214 + Real(0.5) * ( intg(i ,j ,k ,i_S_x_y)
6215 +intg(i ,j ,k ,i_S_x_z)
6216 +intg(i ,j ,k ,i_S_y_z))
6217 + ( -intg(i ,j ,k ,i_S_xyz)))
6218 //
6219 + rhcc(i-1,j ,k ) *
6220 ( Real(0.125) * vfrac(i-1,j ,k )
6221 + Real(0.25) * ( intg(i-1,j ,k ,i_S_x)
6222 -intg(i-1,j ,k ,i_S_y)
6223 -intg(i-1,j ,k ,i_S_z))
6224 + Real(0.5) * ( -intg(i-1,j ,k ,i_S_x_y)
6225 -intg(i-1,j ,k ,i_S_x_z)
6226 +intg(i-1,j ,k ,i_S_y_z))
6227 + ( intg(i-1,j ,k ,i_S_xyz)))
6228 //
6229 + rhcc(i ,j-1,k ) *
6230 ( Real(0.125) * vfrac(i ,j-1,k )
6231 + Real(0.25) * (-intg(i ,j-1,k ,i_S_x)
6232 +intg(i ,j-1,k ,i_S_y)
6233 -intg(i ,j-1,k ,i_S_z))
6234 + Real(0.5) * ( -intg(i ,j-1,k ,i_S_x_y)
6235 +intg(i ,j-1,k ,i_S_x_z)
6236 -intg(i ,j-1,k ,i_S_y_z))
6237 + ( intg(i ,j-1,k ,i_S_xyz)))
6238 //
6239 + rhcc(i-1,j-1,k ) *
6240 ( Real(0.125) * vfrac(i-1,j-1,k )
6241 + Real(0.25) * ( intg(i-1,j-1,k ,i_S_x)
6242 +intg(i-1,j-1,k ,i_S_y)
6243 -intg(i-1,j-1,k ,i_S_z))
6244 + Real(0.5) * ( intg(i-1,j-1,k ,i_S_x_y)
6245 -intg(i-1,j-1,k ,i_S_x_z)
6246 -intg(i-1,j-1,k ,i_S_y_z))
6247 + ( -intg(i-1,j-1,k ,i_S_xyz)))
6248 //
6249 + rhcc(i ,j ,k-1) *
6250 ( Real(0.125) * vfrac(i ,j ,k-1)
6251 + Real(0.25) * (-intg(i ,j ,k-1,i_S_x)
6252 -intg(i ,j ,k-1,i_S_y)
6253 +intg(i ,j ,k-1,i_S_z))
6254 + Real(0.5) * ( intg(i ,j ,k-1,i_S_x_y)
6255 -intg(i ,j ,k-1,i_S_x_z)
6256 -intg(i ,j ,k-1,i_S_y_z))
6257 + ( intg(i ,j ,k-1,i_S_xyz)))
6258 //
6259 + rhcc(i-1,j ,k-1) *
6260 ( Real(0.125) * vfrac(i-1,j ,k-1)
6261 + Real(0.25) * ( intg(i-1,j ,k-1,i_S_x)
6262 -intg(i-1,j ,k-1,i_S_y)
6263 +intg(i-1,j ,k-1,i_S_z))
6264 + Real(0.5) * ( -intg(i-1,j ,k-1,i_S_x_y)
6265 +intg(i-1,j ,k-1,i_S_x_z)
6266 -intg(i-1,j ,k-1,i_S_y_z))
6267 + ( -intg(i-1,j ,k-1,i_S_xyz)))
6268 //
6269 + rhcc(i ,j-1,k-1) *
6270 ( Real(0.125) * vfrac(i ,j-1,k-1)
6271 + Real(0.25) * (-intg(i ,j-1,k-1,i_S_x)
6272 +intg(i ,j-1,k-1,i_S_y)
6273 +intg(i ,j-1,k-1,i_S_z))
6274 + Real(0.5) * ( -intg(i ,j-1,k-1,i_S_x_y)
6275 -intg(i ,j-1,k-1,i_S_x_z)
6276 +intg(i ,j-1,k-1,i_S_y_z))
6277 + ( -intg(i ,j-1,k-1,i_S_xyz)))
6278 //
6279 + rhcc(i-1,j-1,k-1) *
6280 ( Real(0.125) * vfrac(i-1,j-1,k-1)
6281 + Real(0.25) * ( intg(i-1,j-1,k-1,i_S_x)
6282 +intg(i-1,j-1,k-1,i_S_y)
6283 +intg(i-1,j-1,k-1,i_S_z))
6284 + Real(0.5) * ( intg(i-1,j-1,k-1,i_S_x_y)
6285 +intg(i-1,j-1,k-1,i_S_x_z)
6286 +intg(i-1,j-1,k-1,i_S_y_z))
6287 + ( intg(i-1,j-1,k-1,i_S_xyz)));
6288 } else {
6289 return Real(0.);
6290 }
6291}
6292
6293#endif
6294
6295#if defined(AMREX_USE_HYPRE)
6296
6297template <typename HypreInt, typename AtomicInt>
6298void mlndlap_fillijmat_sten_cpu (Box const& ndbx,
6299 Array4<AtomicInt const> const& gid,
6300 Array4<int const> const& lid,
6301 HypreInt* ncols, HypreInt* cols,
6302 Real* mat, // NOLINT(readability-non-const-parameter)
6303 Array4<Real const> const& sten) noexcept
6304{
6305 constexpr int ist_000 = 1-1;
6306 constexpr int ist_p00 = 2-1;
6307 constexpr int ist_0p0 = 3-1;
6308 constexpr int ist_00p = 4-1;
6309 constexpr int ist_pp0 = 5-1;
6310 constexpr int ist_p0p = 6-1;
6311 constexpr int ist_0pp = 7-1;
6312 constexpr int ist_ppp = 8-1;
6313
6314 constexpr auto gidmax = std::numeric_limits<AtomicInt>::max();
6315 HypreInt nelems = 0;
6316 amrex::LoopOnCpu(ndbx, [&] (int i, int j, int k) noexcept
6317 {
6318 if (lid(i,j,k) >= 0)
6319 {
6320 cols[nelems] = gid(i,j,k);
6321 mat[nelems] = sten(i,j,k,ist_000);
6322 HypreNodeLap::Int nelems_old = nelems;
6323 ++nelems;
6324
6325 if (gid(i-1,j-1,k-1) < gidmax) {
6326 cols[nelems] = gid(i-1,j-1,k-1);
6327 mat[nelems] = sten(i-1,j-1,k-1,ist_ppp);
6328 ++nelems;
6329 }
6330
6331 if (gid(i,j-1,k-1) < gidmax) {
6332 cols[nelems] = gid(i,j-1,k-1);
6333 mat[nelems] = sten(i,j-1,k-1,ist_0pp);
6334 ++nelems;
6335 }
6336
6337 if (gid(i+1,j-1,k-1) < gidmax) {
6338 cols[nelems] = gid(i+1,j-1,k-1);
6339 mat[nelems] = sten(i,j-1,k-1,ist_ppp);
6340 ++nelems;
6341 }
6342
6343 if (gid(i-1,j,k-1) < gidmax) {
6344 cols[nelems] = gid(i-1,j,k-1);
6345 mat[nelems] = sten(i-1,j,k-1,ist_p0p);
6346 ++nelems;
6347 }
6348
6349 if (gid(i,j,k-1) < gidmax) {
6350 cols[nelems] = gid(i,j,k-1);
6351 mat[nelems] = sten(i,j,k-1,ist_00p);
6352 ++nelems;
6353 }
6354
6355 if (gid(i+1,j,k-1) < gidmax) {
6356 cols[nelems] = gid(i+1,j,k-1);
6357 mat[nelems] = sten(i,j,k-1,ist_p0p);
6358 ++nelems;
6359 }
6360
6361 if (gid(i-1,j+1,k-1) < gidmax) {
6362 cols[nelems] = gid(i-1,j+1,k-1);
6363 mat[nelems] = sten(i-1,j,k-1,ist_ppp);
6364 ++nelems;
6365 }
6366
6367 if (gid(i,j+1,k-1) < gidmax) {
6368 cols[nelems] = gid(i,j+1,k-1);
6369 mat[nelems] = sten(i,j,k-1,ist_0pp);
6370 ++nelems;
6371 }
6372
6373 if (gid(i+1,j+1,k-1) < gidmax) {
6374 cols[nelems] = gid(i+1,j+1,k-1);
6375 mat[nelems] = sten(i,j,k-1,ist_ppp);
6376 ++nelems;
6377 }
6378
6379 if (gid(i-1,j-1,k) < gidmax) {
6380 cols[nelems] = gid(i-1,j-1,k);
6381 mat[nelems] = sten(i-1,j-1,k,ist_pp0);
6382 ++nelems;
6383 }
6384
6385 if (gid(i,j-1,k) < gidmax) {
6386 cols[nelems] = gid(i,j-1,k);
6387 mat[nelems] = sten(i,j-1,k,ist_0p0);
6388 ++nelems;
6389 }
6390
6391 if (gid(i+1,j-1,k) < gidmax) {
6392 cols[nelems] = gid(i+1,j-1,k);
6393 mat[nelems] = sten(i,j-1,k,ist_pp0);
6394 ++nelems;
6395 }
6396
6397 if (gid(i-1,j,k) < gidmax) {
6398 cols[nelems] = gid(i-1,j,k);
6399 mat[nelems] = sten(i-1,j,k,ist_p00);
6400 ++nelems;
6401 }
6402
6403 if (gid(i+1,j,k) < gidmax) {
6404 cols[nelems] = gid(i+1,j,k);
6405 mat[nelems] = sten(i,j,k,ist_p00);
6406 ++nelems;
6407 }
6408
6409 if (gid(i-1,j+1,k) < gidmax) {
6410 cols[nelems] = gid(i-1,j+1,k);
6411 mat[nelems] = sten(i-1,j,k,ist_pp0);
6412 ++nelems;
6413 }
6414
6415 if (gid(i,j+1,k) < gidmax) {
6416 cols[nelems] = gid(i,j+1,k);
6417 mat[nelems] = sten(i,j,k,ist_0p0);
6418 ++nelems;
6419 }
6420
6421 if (gid(i+1,j+1,k) < gidmax) {
6422 cols[nelems] = gid(i+1,j+1,k);
6423 mat[nelems] = sten(i,j,k,ist_pp0);
6424 ++nelems;
6425 }
6426
6427 if (gid(i-1,j-1,k+1) < gidmax) {
6428 cols[nelems] = gid(i-1,j-1,k+1);
6429 mat[nelems] = sten(i-1,j-1,k,ist_ppp);
6430 ++nelems;
6431 }
6432
6433 if (gid(i,j-1,k+1) < gidmax) {
6434 cols[nelems] = gid(i,j-1,k+1);
6435 mat[nelems] = sten(i,j-1,k,ist_0pp);
6436 ++nelems;
6437 }
6438
6439 if (gid(i+1,j-1,k+1) < gidmax) {
6440 cols[nelems] = gid(i+1,j-1,k+1);
6441 mat[nelems] = sten(i,j-1,k,ist_ppp);
6442 ++nelems;
6443 }
6444
6445 if (gid(i-1,j,k+1) < gidmax) {
6446 cols[nelems] = gid(i-1,j,k+1);
6447 mat[nelems] = sten(i-1,j,k,ist_p0p);
6448 ++nelems;
6449 }
6450
6451 if (gid(i,j,k+1) < gidmax) {
6452 cols[nelems] = gid(i,j,k+1);
6453 mat[nelems] = sten(i,j,k,ist_00p);
6454 ++nelems;
6455 }
6456
6457 if (gid(i+1,j,k+1) < gidmax) {
6458 cols[nelems] = gid(i+1,j,k+1);
6459 mat[nelems] = sten(i,j,k,ist_p0p);
6460 ++nelems;
6461 }
6462
6463 if (gid(i-1,j+1,k+1) < gidmax) {
6464 cols[nelems] = gid(i-1,j+1,k+1);
6465 mat[nelems] = sten(i-1,j,k,ist_ppp);
6466 ++nelems;
6467 }
6468
6469 if (gid(i,j+1,k+1) < gidmax) {
6470 cols[nelems] = gid(i,j+1,k+1);
6471 mat[nelems] = sten(i,j,k,ist_0pp);
6472 ++nelems;
6473 }
6474
6475 if (gid(i+1,j+1,k+1) < gidmax) {
6476 cols[nelems] = gid(i+1,j+1,k+1);
6477 mat[nelems] = sten(i,j,k,ist_ppp);
6478 ++nelems;
6479 }
6480
6481 ncols[lid(i,j,k)] = nelems - nelems_old;
6482 }
6483 });
6484}
6485
6486template <typename HypreInt, typename AtomicInt>
6487void mlndlap_fillijmat_aa_cpu (Box const& ndbx,
6488 Array4<AtomicInt const> const& gid,
6489 Array4<int const> const& lid,
6490 HypreInt* ncols, HypreInt* cols,
6491 Real* mat, // NOLINT(readability-non-const-parameter)
6492 Array4<Real const> const& sig,
6493 GpuArray<Real,AMREX_SPACEDIM> const& dxinv,
6494 Box const& ccdom) noexcept
6495{
6496 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
6497 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
6498 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
6499 Real fxyz = facx + facy + facz;
6500 Real fmx2y2z = -facx + Real(2.0)*facy + Real(2.0)*facz;
6501 Real f2xmy2z = Real(2.0)*facx - facy + Real(2.0)*facz;
6502 Real f2x2ymz = Real(2.0)*facx + Real(2.0)*facy - facz;
6503 Real f4xm2ym2z = Real(4.0)*facx - Real(2.0)*facy - Real(2.0)*facz;
6504 Real fm2x4ym2z = -Real(2.0)*facx + Real(4.0)*facy - Real(2.0)*facz;
6505 Real fm2xm2y4z = -Real(2.0)*facx - Real(2.0)*facy + Real(4.0)*facz;
6506
6507 const Box& nddom = amrex::surroundingNodes(ccdom);
6508
6509 constexpr auto gidmax = std::numeric_limits<AtomicInt>::max();
6510 HypreInt nelems = 0;
6511 amrex::LoopOnCpu(ndbx, [&] (int i, int j, int k) noexcept
6512 {
6513 if (lid(i,j,k) >= 0)
6514 {
6515 HypreInt nelems_old = nelems;
6516 cols[nelems_old] = gid(i,j,k);
6517 Real m0 = Real(0.);
6518 ++nelems;
6519
6520 if (nddom.contains(i-1,j-1,k-1)) {
6521 Real tmp = sig(i-1,j-1,k-1) * fxyz;
6522 m0 -= tmp;
6523 if ( gid(i-1,j-1,k-1) < gidmax) {
6524 cols[nelems] = gid(i-1,j-1,k-1);
6525 mat[nelems] = tmp;
6526 ++nelems;
6527 }
6528 }
6529
6530 if (nddom.contains(i,j-1,k-1)) {
6531 Real tmp = Real(0.);
6532 if (ccdom.contains(i-1,j-1,k-1)) {
6533 tmp += sig(i-1,j-1,k-1) * fmx2y2z;
6534 }
6535 if (ccdom.contains(i,j-1,k-1)) {
6536 tmp += sig(i,j-1,k-1) * fmx2y2z;
6537 }
6538 m0 -= tmp;
6539 if (gid(i,j-1,k-1) < gidmax) {
6540 cols[nelems] = gid(i,j-1,k-1);
6541 mat[nelems] = tmp;
6542 ++nelems;
6543 }
6544 }
6545
6546 if (nddom.contains(i+1,j-1,k-1)) {
6547 Real tmp = sig(i ,j-1,k-1) * fxyz;
6548 m0 -= tmp;
6549 if (gid(i+1,j-1,k-1) < gidmax) {
6550 cols[nelems] = gid(i+1,j-1,k-1);
6551 mat[nelems] = tmp;
6552 ++nelems;
6553 }
6554 }
6555
6556 if (nddom.contains(i-1,j,k-1)) {
6557 Real tmp = Real(0.);
6558 if (ccdom.contains(i-1,j-1,k-1)) {
6559 tmp += sig(i-1,j-1,k-1) * f2xmy2z;
6560 }
6561 if (ccdom.contains(i-1,j,k-1)) {
6562 tmp += sig(i-1,j,k-1) * f2xmy2z;
6563 }
6564 m0 -= tmp;
6565 if (gid(i-1,j,k-1) < gidmax) {
6566 cols[nelems] = gid(i-1,j,k-1);
6567 mat[nelems] = tmp;
6568 ++nelems;
6569 }
6570 }
6571
6572 if (nddom.contains(i,j,k-1) && fm2xm2y4z != Real(0.0)) {
6573 Real tmp = Real(0.);
6574 if (ccdom.contains(i-1,j-1,k-1)) {
6575 tmp += sig(i-1,j-1,k-1) * fm2xm2y4z;
6576 }
6577 if (ccdom.contains(i,j-1,k-1)) {
6578 tmp += sig(i,j-1,k-1) * fm2xm2y4z;
6579 }
6580 if (ccdom.contains(i-1,j,k-1)) {
6581 tmp += sig(i-1,j,k-1) * fm2xm2y4z;
6582 }
6583 if (ccdom.contains(i,j,k-1)) {
6584 tmp += sig(i,j,k-1) * fm2xm2y4z;
6585 }
6586 m0 -= tmp;
6587 if (gid(i,j,k-1) < gidmax) {
6588 cols[nelems] = gid(i,j,k-1);
6589 mat[nelems] = tmp;
6590 ++nelems;
6591 }
6592 }
6593
6594 if (nddom.contains(i+1,j,k-1)) {
6595 Real tmp = Real(0.);
6596 if (ccdom.contains(i ,j-1,k-1)) {
6597 tmp += sig(i ,j-1,k-1) * f2xmy2z;
6598 }
6599 if (ccdom.contains(i ,j,k-1)) {
6600 tmp += sig(i ,j,k-1) * f2xmy2z;
6601 }
6602 m0 -= tmp;
6603 if (gid(i+1,j,k-1) < gidmax) {
6604 cols[nelems] = gid(i+1,j,k-1);
6605 mat[nelems] = tmp;
6606 ++nelems;
6607 }
6608 }
6609
6610 if (nddom.contains(i-1,j+1,k-1)) {
6611 Real tmp = sig(i-1,j ,k-1) * fxyz;
6612 m0 -= tmp;
6613 if (gid(i-1,j+1,k-1) < gidmax) {
6614 cols[nelems] = gid(i-1,j+1,k-1);
6615 mat[nelems] = tmp;
6616 ++nelems;
6617 }
6618 }
6619
6620 if (nddom.contains(i,j+1,k-1)) {
6621 Real tmp = Real(0.);
6622 if (ccdom.contains(i-1,j ,k-1)) {
6623 tmp += sig(i-1,j ,k-1) * fmx2y2z;
6624 }
6625 if (ccdom.contains(i,j ,k-1)) {
6626 tmp += sig(i,j ,k-1) * fmx2y2z;
6627 }
6628 m0 -= tmp;
6629 if (gid(i,j+1,k-1) < gidmax) {
6630 cols[nelems] = gid(i,j+1,k-1);
6631 mat[nelems] = tmp;
6632 ++nelems;
6633 }
6634 }
6635
6636 if (nddom.contains(i+1,j+1,k-1)) {
6637 Real tmp = sig(i ,j ,k-1) * fxyz;
6638 m0 -= tmp;
6639 if (gid(i+1,j+1,k-1) < gidmax) {
6640 cols[nelems] = gid(i+1,j+1,k-1);
6641 mat[nelems] = tmp;
6642 ++nelems;
6643 }
6644 }
6645
6646 if (nddom.contains(i-1,j-1,k)) {
6647 Real tmp = Real(0.);
6648 if (ccdom.contains(i-1,j-1,k-1)) {
6649 tmp += sig(i-1,j-1,k-1) * f2x2ymz;
6650 }
6651 if (ccdom.contains(i-1,j-1,k)) {
6652 tmp += sig(i-1,j-1,k) * f2x2ymz;
6653 }
6654 m0 -= tmp;
6655 if (gid(i-1,j-1,k) < gidmax) {
6656 cols[nelems] = gid(i-1,j-1,k);
6657 mat[nelems] = tmp;
6658 ++nelems;
6659 }
6660 }
6661
6662 if (nddom.contains(i,j-1,k) && fm2x4ym2z != Real(0.0)) {
6663 Real tmp = Real(0.);
6664 if (ccdom.contains(i-1,j-1,k-1)) {
6665 tmp += sig(i-1,j-1,k-1) * fm2x4ym2z;
6666 }
6667 if (ccdom.contains(i,j-1,k-1)) {
6668 tmp += sig(i,j-1,k-1) * fm2x4ym2z;
6669 }
6670 if (ccdom.contains(i-1,j-1,k)) {
6671 tmp += sig(i-1,j-1,k) * fm2x4ym2z;
6672 }
6673 if (ccdom.contains(i,j-1,k)) {
6674 tmp += sig(i,j-1,k) * fm2x4ym2z;
6675 }
6676 m0 -= tmp;
6677 if (gid(i,j-1,k) < gidmax) {
6678 cols[nelems] = gid(i,j-1,k);
6679 mat[nelems] = tmp;
6680 ++nelems;
6681 }
6682 }
6683
6684 if (nddom.contains(i+1,j-1,k)) {
6685 Real tmp = Real(0.);
6686 if (ccdom.contains(i ,j-1,k-1)) {
6687 tmp += sig(i ,j-1,k-1) * f2x2ymz;
6688 }
6689 if (ccdom.contains(i ,j-1,k)) {
6690 tmp += sig(i ,j-1,k) * f2x2ymz;
6691 }
6692 m0 -= tmp;
6693 if (gid(i+1,j-1,k) < gidmax) {
6694 cols[nelems] = gid(i+1,j-1,k);
6695 mat[nelems] = tmp;
6696 ++nelems;
6697 }
6698 }
6699
6700 if (nddom.contains(i-1,j,k) && f4xm2ym2z != Real(0.0)) {
6701 Real tmp = Real(0.);
6702 if (ccdom.contains(i-1,j-1,k-1)) {
6703 tmp += sig(i-1,j-1,k-1) * f4xm2ym2z;
6704 }
6705 if (ccdom.contains(i-1,j,k-1)) {
6706 tmp += sig(i-1,j,k-1) * f4xm2ym2z;
6707 }
6708 if (ccdom.contains(i-1,j-1,k)) {
6709 tmp += sig(i-1,j-1,k) * f4xm2ym2z;
6710 }
6711 if (ccdom.contains(i-1,j,k)) {
6712 tmp += sig(i-1,j,k) * f4xm2ym2z;
6713 }
6714 m0 -= tmp;
6715 if (gid(i-1,j,k) < gidmax) {
6716 cols[nelems] = gid(i-1,j,k);
6717 mat[nelems] = tmp;
6718 ++nelems;
6719 }
6720 }
6721
6722 if (nddom.contains(i+1,j,k) && f4xm2ym2z != Real(0.0)) {
6723 Real tmp = Real(0.);
6724 if (ccdom.contains(i ,j-1,k-1)) {
6725 tmp += sig(i ,j-1,k-1) * f4xm2ym2z;
6726 }
6727 if (ccdom.contains(i ,j,k-1)) {
6728 tmp += sig(i ,j,k-1) * f4xm2ym2z;
6729 }
6730 if (ccdom.contains(i ,j-1,k)) {
6731 tmp += sig(i ,j-1,k) * f4xm2ym2z;
6732 }
6733 if (ccdom.contains(i ,j,k)) {
6734 tmp += sig(i ,j,k) * f4xm2ym2z;
6735 }
6736 m0 -= tmp;
6737 if (gid(i+1,j,k) < gidmax) {
6738 cols[nelems] = gid(i+1,j,k);
6739 mat[nelems] = tmp;
6740 ++nelems;
6741 }
6742 }
6743
6744 if (nddom.contains(i-1,j+1,k)) {
6745 Real tmp = Real(0.);
6746 if (ccdom.contains(i-1,j ,k-1)) {
6747 tmp += sig(i-1,j ,k-1) * f2x2ymz;
6748 }
6749 if (ccdom.contains(i-1,j ,k)) {
6750 tmp += sig(i-1,j ,k) * f2x2ymz;
6751 }
6752 m0 -= tmp;
6753 if (gid(i-1,j+1,k) < gidmax) {
6754 cols[nelems] = gid(i-1,j+1,k);
6755 mat[nelems] = tmp;
6756 ++nelems;
6757 }
6758 }
6759
6760 if (nddom.contains(i,j+1,k) && fm2x4ym2z != Real(0.0)) {
6761 Real tmp = Real(0.);
6762 if (ccdom.contains(i-1,j ,k-1)) {
6763 tmp += sig(i-1,j ,k-1) * fm2x4ym2z;
6764 }
6765 if (ccdom.contains(i,j ,k-1)) {
6766 tmp += sig(i,j ,k-1) * fm2x4ym2z;
6767 }
6768 if (ccdom.contains(i-1,j ,k)) {
6769 tmp += sig(i-1,j ,k) * fm2x4ym2z;
6770 }
6771 if (ccdom.contains(i,j ,k)) {
6772 tmp += sig(i,j ,k) * fm2x4ym2z;
6773 }
6774 m0 -= tmp;
6775 if (gid(i,j+1,k) < gidmax) {
6776 cols[nelems] = gid(i,j+1,k);
6777 mat[nelems] = tmp;
6778 ++nelems;
6779 }
6780 }
6781
6782 if (nddom.contains(i+1,j+1,k)) {
6783 Real tmp = Real(0.);
6784 if (ccdom.contains(i ,j ,k-1)) {
6785 tmp += sig(i ,j ,k-1) * f2x2ymz;
6786 }
6787 if (ccdom.contains(i ,j ,k)) {
6788 tmp += sig(i ,j ,k) * f2x2ymz;
6789 }
6790 m0 -= tmp;
6791 if (gid(i+1,j+1,k) < gidmax) {
6792 cols[nelems] = gid(i+1,j+1,k);
6793 mat[nelems] = tmp;
6794 ++nelems;
6795 }
6796 }
6797
6798 if (nddom.contains(i-1,j-1,k+1)) {
6799 Real tmp = sig(i-1,j-1,k ) * fxyz;
6800 m0 -= tmp;
6801 if (gid(i-1,j-1,k+1) < gidmax) {
6802 cols[nelems] = gid(i-1,j-1,k+1);
6803 mat[nelems] = tmp;
6804 ++nelems;
6805 }
6806 }
6807
6808 if (nddom.contains(i,j-1,k+1)) {
6809 Real tmp = Real(0.);
6810 if (ccdom.contains(i-1,j-1,k )) {
6811 tmp += sig(i-1,j-1,k ) * fmx2y2z;
6812 }
6813 if (ccdom.contains(i,j-1,k )) {
6814 tmp += sig(i,j-1,k ) * fmx2y2z;
6815 }
6816 m0 -= tmp;
6817 if (gid(i,j-1,k+1) < gidmax) {
6818 cols[nelems] = gid(i,j-1,k+1);
6819 mat[nelems] = tmp;
6820 ++nelems;
6821 }
6822 }
6823
6824 if (nddom.contains(i+1,j-1,k+1)) {
6825 Real tmp = sig(i ,j-1,k ) * fxyz;
6826 m0 -= tmp;
6827 if (gid(i+1,j-1,k+1) < gidmax) {
6828 cols[nelems] = gid(i+1,j-1,k+1);
6829 mat[nelems] = tmp;
6830 ++nelems;
6831 }
6832 }
6833
6834 if (nddom.contains(i-1,j,k+1)) {
6835 Real tmp = Real(0.);
6836 if (ccdom.contains(i-1,j-1,k )) {
6837 tmp += sig(i-1,j-1,k ) * f2xmy2z;
6838 }
6839 if (ccdom.contains(i-1,j,k )) {
6840 tmp += sig(i-1,j,k ) * f2xmy2z;
6841 }
6842 m0 -= tmp;
6843 if (gid(i-1,j,k+1) < gidmax) {
6844 cols[nelems] = gid(i-1,j,k+1);
6845 mat[nelems] = tmp;
6846 ++nelems;
6847 }
6848 }
6849
6850 if (nddom.contains(i,j,k+1) && fm2xm2y4z != Real(0.0)) {
6851 Real tmp = Real(0.);
6852 if (ccdom.contains(i-1,j-1,k )) {
6853 tmp += sig(i-1,j-1,k ) * fm2xm2y4z;
6854 }
6855 if (ccdom.contains(i,j-1,k )) {
6856 tmp += sig(i,j-1,k ) * fm2xm2y4z;
6857 }
6858 if (ccdom.contains(i-1,j,k )) {
6859 tmp += sig(i-1,j,k ) * fm2xm2y4z;
6860 }
6861 if (ccdom.contains(i,j,k )) {
6862 tmp += sig(i,j,k ) * fm2xm2y4z;
6863 }
6864 m0 -= tmp;
6865 if (gid(i,j,k+1) < gidmax) {
6866 cols[nelems] = gid(i,j,k+1);
6867 mat[nelems] = tmp;
6868 ++nelems;
6869 }
6870 }
6871
6872 if (nddom.contains(i+1,j,k+1)) {
6873 Real tmp = Real(0.);
6874 if (ccdom.contains(i ,j-1,k )) {
6875 tmp += sig(i ,j-1,k ) * f2xmy2z;
6876 }
6877 if (ccdom.contains(i ,j,k )) {
6878 tmp += sig(i ,j,k ) * f2xmy2z;
6879 }
6880 m0 -= tmp;
6881 if (gid(i+1,j,k+1) < gidmax) {
6882 cols[nelems] = gid(i+1,j,k+1);
6883 mat[nelems] = tmp;
6884 ++nelems;
6885 }
6886 }
6887
6888 if (nddom.contains(i-1,j+1,k+1)) {
6889 Real tmp = sig(i-1,j ,k ) * fxyz;
6890 m0 -= tmp;
6891 if (gid(i-1,j+1,k+1) < gidmax) {
6892 cols[nelems] = gid(i-1,j+1,k+1);
6893 mat[nelems] = tmp;
6894 ++nelems;
6895 }
6896 }
6897
6898 if (nddom.contains(i,j+1,k+1)) {
6899 Real tmp = Real(0.);
6900 if (ccdom.contains(i-1,j ,k )) {
6901 tmp += sig(i-1,j ,k ) * fmx2y2z;
6902 }
6903 if (ccdom.contains(i,j ,k )) {
6904 tmp += sig(i,j ,k ) * fmx2y2z;
6905 }
6906 m0 -= tmp;
6907 if (gid(i,j+1,k+1) < gidmax) {
6908 cols[nelems] = gid(i,j+1,k+1);
6909 mat[nelems] = tmp;
6910 ++nelems;
6911 }
6912 }
6913
6914 if (nddom.contains(i+1,j+1,k+1)) {
6915 Real tmp = sig(i ,j ,k ) * fxyz;
6916 m0 -= tmp;
6917 if (gid(i+1,j+1,k+1) < gidmax) {
6918 cols[nelems] = gid(i+1,j+1,k+1);
6919 mat[nelems] = tmp;
6920 ++nelems;
6921 }
6922 }
6923
6924 mat[nelems_old] = m0;
6925 ncols[lid(i,j,k)] = nelems - nelems_old;
6926 }
6927 });
6928}
6929
6930template <typename HypreInt, typename AtomicInt>
6931void mlndlap_fillijmat_ha_cpu (Box const& ndbx,
6932 Array4<AtomicInt const> const& gid,
6933 Array4<int const> const& lid,
6934 HypreInt* ncols, HypreInt* cols,
6935 Real* mat, // NOLINT(readability-non-const-parameter)
6936 Array4<Real const> const& sx,
6937 Array4<Real const> const& sy,
6938 Array4<Real const> const& sz,
6939 GpuArray<Real,AMREX_SPACEDIM> const& dxinv,
6940 Box const& ccdom) noexcept
6941{
6942 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
6943 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
6944 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
6945
6946 const Box& nddom = amrex::surroundingNodes(ccdom);
6947
6948 constexpr auto gidmax = std::numeric_limits<AtomicInt>::max();
6949 HypreInt nelems = 0;
6950 amrex::LoopOnCpu(ndbx, [&] (int i, int j, int k) noexcept
6951 {
6952 if (lid(i,j,k) >= 0)
6953 {
6954 HypreInt nelems_old = nelems;
6955 cols[nelems_old] = gid(i,j,k);
6956 Real m0 = Real(0.);
6957 ++nelems;
6958
6959 if (nddom.contains(i-1,j-1,k-1)) {
6960 Real tmp = sx(i-1,j-1,k-1) * facx
6961 + sy(i-1,j-1,k-1) * facy
6962 + sz(i-1,j-1,k-1) * facz;
6963 m0 -= tmp;
6964 if ( gid(i-1,j-1,k-1) < gidmax) {
6965 cols[nelems] = gid(i-1,j-1,k-1);
6966 mat[nelems] = tmp;
6967 ++nelems;
6968 }
6969 }
6970
6971 if (nddom.contains(i,j-1,k-1)) {
6972 Real tmp = Real(0.);
6973 if (ccdom.contains(i-1,j-1,k-1)) {
6974 tmp += - sx(i-1,j-1,k-1) * facx
6975 + sy(i-1,j-1,k-1) * facy * Real(2.0)
6976 + sz(i-1,j-1,k-1) * facz * Real(2.0);
6977 }
6978 if (ccdom.contains(i,j-1,k-1)) {
6979 tmp += - sx(i,j-1,k-1) * facx
6980 + sy(i,j-1,k-1) * facy * Real(2.0)
6981 + sz(i,j-1,k-1) * facz * Real(2.0);
6982 }
6983 m0 -= tmp;
6984 if (gid(i,j-1,k-1) < gidmax) {
6985 cols[nelems] = gid(i,j-1,k-1);
6986 mat[nelems] = tmp;
6987 ++nelems;
6988 }
6989 }
6990
6991 if (nddom.contains(i+1,j-1,k-1)) {
6992 Real tmp = sx(i ,j-1,k-1) * facx
6993 + sy(i ,j-1,k-1) * facy
6994 + sz(i ,j-1,k-1) * facz;
6995 m0 -= tmp;
6996 if (gid(i+1,j-1,k-1) < gidmax) {
6997 cols[nelems] = gid(i+1,j-1,k-1);
6998 mat[nelems] = tmp;
6999 ++nelems;
7000 }
7001 }
7002
7003 if (nddom.contains(i-1,j,k-1)) {
7004 Real tmp = Real(0.);
7005 if (ccdom.contains(i-1,j-1,k-1)) {
7006 tmp += sx(i-1,j-1,k-1) * facx * Real(2.0)
7007 - sy(i-1,j-1,k-1) * facy
7008 + sz(i-1,j-1,k-1) * facz * Real(2.0);
7009 }
7010 if (ccdom.contains(i-1,j,k-1)) {
7011 tmp += sx(i-1,j,k-1) * facx * Real(2.0)
7012 - sy(i-1,j,k-1) * facy
7013 + sz(i-1,j,k-1) * facz * Real(2.0);
7014 }
7015 m0 -= tmp;
7016 if (gid(i-1,j,k-1) < gidmax) {
7017 cols[nelems] = gid(i-1,j,k-1);
7018 mat[nelems] = tmp;
7019 ++nelems;
7020 }
7021 }
7022
7023 if (nddom.contains(i,j,k-1)) {
7024 Real tmp = Real(0.);
7025 if (ccdom.contains(i-1,j-1,k-1)) {
7026 tmp += - sx(i-1,j-1,k-1) * facx * Real(2.0)
7027 - sy(i-1,j-1,k-1) * facy * Real(2.0)
7028 + sz(i-1,j-1,k-1) * facz * Real(4.0);
7029 }
7030 if (ccdom.contains(i,j-1,k-1)) {
7031 tmp += - sx(i,j-1,k-1) * facx * Real(2.0)
7032 - sy(i,j-1,k-1) * facy * Real(2.0)
7033 + sz(i,j-1,k-1) * facz * Real(4.0);
7034
7035 }
7036 if (ccdom.contains(i-1,j,k-1)) {
7037 tmp += - sx(i-1,j,k-1) * facx * Real(2.0)
7038 - sy(i-1,j,k-1) * facy * Real(2.0)
7039 + sz(i-1,j,k-1) * facz * Real(4.0);
7040 }
7041 if (ccdom.contains(i,j,k-1)) {
7042 tmp += - sx(i,j,k-1) * facx * Real(2.0)
7043 - sy(i,j,k-1) * facy * Real(2.0)
7044 + sz(i,j,k-1) * facz * Real(4.0);
7045 }
7046 m0 -= tmp;
7047 if (gid(i,j,k-1) < gidmax && tmp != Real(0.0)) {
7048 cols[nelems] = gid(i,j,k-1);
7049 mat[nelems] = tmp;
7050 ++nelems;
7051 }
7052 }
7053
7054 if (nddom.contains(i+1,j,k-1)) {
7055 Real tmp = Real(0.);
7056 if (ccdom.contains(i ,j-1,k-1)) {
7057 tmp += sx(i ,j-1,k-1) * facx * Real(2.0)
7058 - sy(i ,j-1,k-1) * facy
7059 + sz(i ,j-1,k-1) * facz * Real(2.0);
7060 }
7061 if (ccdom.contains(i ,j,k-1)) {
7062 tmp += sx(i ,j,k-1) * facx * Real(2.0)
7063 - sy(i ,j,k-1) * facy
7064 + sz(i ,j,k-1) * facz * Real(2.0);
7065 }
7066 m0 -= tmp;
7067 if (gid(i+1,j,k-1) < gidmax) {
7068 cols[nelems] = gid(i+1,j,k-1);
7069 mat[nelems] = tmp;
7070 ++nelems;
7071 }
7072 }
7073
7074 if (nddom.contains(i-1,j+1,k-1)) {
7075 Real tmp = sx(i-1,j ,k-1) * facx
7076 + sy(i-1,j ,k-1) * facy
7077 + sz(i-1,j ,k-1) * facz;
7078 m0 -= tmp;
7079 if (gid(i-1,j+1,k-1) < gidmax) {
7080 cols[nelems] = gid(i-1,j+1,k-1);
7081 mat[nelems] = tmp;
7082 ++nelems;
7083 }
7084 }
7085
7086 if (nddom.contains(i,j+1,k-1)) {
7087 Real tmp = Real(0.);
7088 if (ccdom.contains(i-1,j ,k-1)) {
7089 tmp += - sx(i-1,j ,k-1) * facx
7090 + sy(i-1,j ,k-1) * facy * Real(2.0)
7091 + sz(i-1,j ,k-1) * facz * Real(2.0);
7092 }
7093 if (ccdom.contains(i,j ,k-1)) {
7094 tmp += - sx(i,j ,k-1) * facx
7095 + sy(i,j ,k-1) * facy * Real(2.0)
7096 + sz(i,j ,k-1) * facz * Real(2.0);
7097 }
7098 m0 -= tmp;
7099 if (gid(i,j+1,k-1) < gidmax) {
7100 cols[nelems] = gid(i,j+1,k-1);
7101 mat[nelems] = tmp;
7102 ++nelems;
7103 }
7104 }
7105
7106 if (nddom.contains(i+1,j+1,k-1)) {
7107 Real tmp = sx(i ,j ,k-1) * facx
7108 + sy(i ,j ,k-1) * facy
7109 + sz(i ,j ,k-1) * facz;
7110 m0 -= tmp;
7111 if (gid(i+1,j+1,k-1) < gidmax) {
7112 cols[nelems] = gid(i+1,j+1,k-1);
7113 mat[nelems] = tmp;
7114 ++nelems;
7115 }
7116 }
7117
7118 if (nddom.contains(i-1,j-1,k)) {
7119 Real tmp = Real(0.);
7120 if (ccdom.contains(i-1,j-1,k-1)) {
7121 tmp += sx(i-1,j-1,k-1) * facx * Real(2.0)
7122 + sy(i-1,j-1,k-1) * facy * Real(2.0)
7123 - sz(i-1,j-1,k-1) * facz;
7124 }
7125 if (ccdom.contains(i-1,j-1,k)) {
7126 tmp += sx(i-1,j-1,k) * facx * Real(2.0)
7127 + sy(i-1,j-1,k) * facy * Real(2.0)
7128 - sz(i-1,j-1,k) * facz;
7129 }
7130 m0 -= tmp;
7131 if (gid(i-1,j-1,k) < gidmax) {
7132 cols[nelems] = gid(i-1,j-1,k);
7133 mat[nelems] = tmp;
7134 ++nelems;
7135 }
7136 }
7137
7138 if (nddom.contains(i,j-1,k)) {
7139 Real tmp = Real(0.);
7140 if (ccdom.contains(i-1,j-1,k-1)) {
7141 tmp += - sx(i-1,j-1,k-1) * facx * Real(2.0)
7142 + sy(i-1,j-1,k-1) * facy * Real(4.0)
7143 - sz(i-1,j-1,k-1) * facz * Real(2.0);
7144 }
7145 if (ccdom.contains(i,j-1,k-1)) {
7146 tmp += - sx(i,j-1,k-1) * facx * Real(2.0)
7147 + sy(i,j-1,k-1) * facy * Real(4.0)
7148 - sz(i,j-1,k-1) * facz * Real(2.0);
7149 }
7150 if (ccdom.contains(i-1,j-1,k)) {
7151 tmp += - sx(i-1,j-1,k) * facx * Real(2.0)
7152 + sy(i-1,j-1,k) * facy * Real(4.0)
7153 - sz(i-1,j-1,k) * facz * Real(2.0);
7154 }
7155 if (ccdom.contains(i,j-1,k)) {
7156 tmp += - sx(i,j-1,k) * facx * Real(2.0)
7157 + sy(i,j-1,k) * facy * Real(4.0)
7158 - sz(i,j-1,k) * facz * Real(2.0);
7159 }
7160 m0 -= tmp;
7161 if (gid(i,j-1,k) < gidmax && tmp != Real(0.0)) {
7162 cols[nelems] = gid(i,j-1,k);
7163 mat[nelems] = tmp;
7164 ++nelems;
7165 }
7166 }
7167
7168 if (nddom.contains(i+1,j-1,k)) {
7169 Real tmp = Real(0.);
7170 if (ccdom.contains(i ,j-1,k-1)) {
7171 tmp += sx(i ,j-1,k-1) * facx * Real(2.0)
7172 + sy(i ,j-1,k-1) * facy * Real(2.0)
7173 - sz(i ,j-1,k-1) * facz;
7174 }
7175 if (ccdom.contains(i ,j-1,k)) {
7176 tmp += sx(i ,j-1,k) * facx * Real(2.0)
7177 + sy(i ,j-1,k) * facy * Real(2.0)
7178 - sz(i ,j-1,k) * facz;
7179 }
7180 m0 -= tmp;
7181 if (gid(i+1,j-1,k) < gidmax) {
7182 cols[nelems] = gid(i+1,j-1,k);
7183 mat[nelems] = tmp;
7184 ++nelems;
7185 }
7186 }
7187
7188 if (nddom.contains(i-1,j,k)) {
7189 Real tmp = Real(0.);
7190 if (ccdom.contains(i-1,j-1,k-1)) {
7191 tmp += sx(i-1,j-1,k-1) * facx * Real(4.0)
7192 - sy(i-1,j-1,k-1) * facy * Real(2.0)
7193 - sz(i-1,j-1,k-1) * facz * Real(2.0);
7194 }
7195 if (ccdom.contains(i-1,j,k-1)) {
7196 tmp += sx(i-1,j,k-1) * facx * Real(4.0)
7197 - sy(i-1,j,k-1) * facy * Real(2.0)
7198 - sz(i-1,j,k-1) * facz * Real(2.0);
7199 }
7200 if (ccdom.contains(i-1,j-1,k)) {
7201 tmp += sx(i-1,j-1,k) * facx * Real(4.0)
7202 - sy(i-1,j-1,k) * facy * Real(2.0)
7203 - sz(i-1,j-1,k) * facz * Real(2.0);
7204 }
7205 if (ccdom.contains(i-1,j,k)) {
7206 tmp += sx(i-1,j,k) * facx * Real(4.0)
7207 - sy(i-1,j,k) * facy * Real(2.0)
7208 - sz(i-1,j,k) * facz * Real(2.0);
7209 }
7210 m0 -= tmp;
7211 if (gid(i-1,j,k) < gidmax && tmp != Real(0.0)) {
7212 cols[nelems] = gid(i-1,j,k);
7213 mat[nelems] = tmp;
7214 ++nelems;
7215 }
7216 }
7217
7218 if (nddom.contains(i+1,j,k)) {
7219 Real tmp = Real(0.);
7220 if (ccdom.contains(i ,j-1,k-1)) {
7221 tmp += sx(i ,j-1,k-1) * facx * Real(4.0)
7222 - sy(i ,j-1,k-1) * facy * Real(2.0)
7223 - sz(i ,j-1,k-1) * facz * Real(2.0);
7224 }
7225 if (ccdom.contains(i ,j,k-1)) {
7226 tmp += sx(i ,j,k-1) * facx * Real(4.0)
7227 - sy(i ,j,k-1) * facy * Real(2.0)
7228 - sz(i ,j,k-1) * facz * Real(2.0);
7229 }
7230 if (ccdom.contains(i ,j-1,k)) {
7231 tmp += sx(i ,j-1,k) * facx * Real(4.0)
7232 - sy(i ,j-1,k) * facy * Real(2.0)
7233 - sz(i ,j-1,k) * facz * Real(2.0);
7234 }
7235 if (ccdom.contains(i ,j,k)) {
7236 tmp += sx(i ,j,k) * facx * Real(4.0)
7237 - sy(i ,j,k) * facy * Real(2.0)
7238 - sz(i ,j,k) * facz * Real(2.0);
7239 }
7240 m0 -= tmp;
7241 if (gid(i+1,j,k) < gidmax && tmp != Real(0.0)) {
7242 cols[nelems] = gid(i+1,j,k);
7243 mat[nelems] = tmp;
7244 ++nelems;
7245 }
7246 }
7247
7248 if (nddom.contains(i-1,j+1,k)) {
7249 Real tmp = Real(0.);
7250 if (ccdom.contains(i-1,j ,k-1)) {
7251 tmp += sx(i-1,j ,k-1) * facx * Real(2.0)
7252 + sy(i-1,j ,k-1) * facy * Real(2.0)
7253 - sz(i-1,j ,k-1) * facz;
7254 }
7255 if (ccdom.contains(i-1,j ,k)) {
7256 tmp += sx(i-1,j ,k) * facx * Real(2.0)
7257 + sy(i-1,j ,k) * facy * Real(2.0)
7258 - sz(i-1,j ,k) * facz;
7259 }
7260 m0 -= tmp;
7261 if (gid(i-1,j+1,k) < gidmax) {
7262 cols[nelems] = gid(i-1,j+1,k);
7263 mat[nelems] = tmp;
7264 ++nelems;
7265 }
7266 }
7267
7268 if (nddom.contains(i,j+1,k)) {
7269 Real tmp = Real(0.);
7270 if (ccdom.contains(i-1,j ,k-1)) {
7271 tmp += - sx(i-1,j ,k-1) * facx * Real(2.0)
7272 + sy(i-1,j ,k-1) * facy * Real(4.0)
7273 - sz(i-1,j ,k-1) * facz * Real(2.0);
7274 }
7275 if (ccdom.contains(i,j ,k-1)) {
7276 tmp += - sx(i,j ,k-1) * facx * Real(2.0)
7277 + sy(i,j ,k-1) * facy * Real(4.0)
7278 - sz(i,j ,k-1) * facz * Real(2.0);
7279 }
7280 if (ccdom.contains(i-1,j ,k)) {
7281 tmp += - sx(i-1,j ,k) * facx * Real(2.0)
7282 + sy(i-1,j ,k) * facy * Real(4.0)
7283 - sz(i-1,j ,k) * facz * Real(2.0);
7284 }
7285 if (ccdom.contains(i,j ,k)) {
7286 tmp += - sx(i,j ,k) * facx * Real(2.0)
7287 + sy(i,j ,k) * facy * Real(4.0)
7288 - sz(i,j ,k) * facz * Real(2.0);
7289 }
7290 m0 -= tmp;
7291 if (gid(i,j+1,k) < gidmax && tmp != Real(0.0)) {
7292 cols[nelems] = gid(i,j+1,k);
7293 mat[nelems] = tmp;
7294 ++nelems;
7295 }
7296 }
7297
7298 if (nddom.contains(i+1,j+1,k)) {
7299 Real tmp = Real(0.);
7300 if (ccdom.contains(i ,j ,k-1)) {
7301 tmp += sx(i ,j ,k-1) * facx * Real(2.0)
7302 + sy(i ,j ,k-1) * facy * Real(2.0)
7303 - sz(i ,j ,k-1) * facz;
7304 }
7305 if (ccdom.contains(i ,j ,k)) {
7306 tmp += sx(i ,j ,k) * facx * Real(2.0)
7307 + sy(i ,j ,k) * facy * Real(2.0)
7308 - sz(i ,j ,k) * facz;
7309 }
7310 m0 -= tmp;
7311 if (gid(i+1,j+1,k) < gidmax) {
7312 cols[nelems] = gid(i+1,j+1,k);
7313 mat[nelems] = tmp;
7314 ++nelems;
7315 }
7316 }
7317
7318 if (nddom.contains(i-1,j-1,k+1)) {
7319 Real tmp = sx(i-1,j-1,k ) * facx
7320 + sy(i-1,j-1,k ) * facy
7321 + sz(i-1,j-1,k ) * facz;
7322 m0 -= tmp;
7323 if (gid(i-1,j-1,k+1) < gidmax) {
7324 cols[nelems] = gid(i-1,j-1,k+1);
7325 mat[nelems] = tmp;
7326 ++nelems;
7327 }
7328 }
7329
7330 if (nddom.contains(i,j-1,k+1)) {
7331 Real tmp = Real(0.);
7332 if (ccdom.contains(i-1,j-1,k )) {
7333 tmp += - sx(i-1,j-1,k ) * facx
7334 + sy(i-1,j-1,k ) * facy * Real(2.0)
7335 + sz(i-1,j-1,k ) * facz * Real(2.0);
7336 }
7337 if (ccdom.contains(i,j-1,k )) {
7338 tmp += - sx(i,j-1,k ) * facx
7339 + sy(i,j-1,k ) * facy * Real(2.0)
7340 + sz(i,j-1,k ) * facz * Real(2.0);
7341 }
7342 m0 -= tmp;
7343 if (gid(i,j-1,k+1) < gidmax) {
7344 cols[nelems] = gid(i,j-1,k+1);
7345 mat[nelems] = tmp;
7346 ++nelems;
7347 }
7348 }
7349
7350 if (nddom.contains(i+1,j-1,k+1)) {
7351 Real tmp = sx(i ,j-1,k ) * facx
7352 + sy(i ,j-1,k ) * facy
7353 + sz(i ,j-1,k ) * facz;
7354 m0 -= tmp;
7355 if (gid(i+1,j-1,k+1) < gidmax) {
7356 cols[nelems] = gid(i+1,j-1,k+1);
7357 mat[nelems] = tmp;
7358 ++nelems;
7359 }
7360 }
7361
7362 if (nddom.contains(i-1,j,k+1)) {
7363 Real tmp = Real(0.);
7364 if (ccdom.contains(i-1,j-1,k )) {
7365 tmp += sx(i-1,j-1,k ) * facx * Real(2.0)
7366 - sy(i-1,j-1,k ) * facy
7367 + sz(i-1,j-1,k ) * facz * Real(2.0);
7368 }
7369 if (ccdom.contains(i-1,j,k )) {
7370 tmp += sx(i-1,j,k ) * facx * Real(2.0)
7371 - sy(i-1,j,k ) * facy
7372 + sz(i-1,j,k ) * facz * Real(2.0);
7373 }
7374 m0 -= tmp;
7375 if (gid(i-1,j,k+1) < gidmax) {
7376 cols[nelems] = gid(i-1,j,k+1);
7377 mat[nelems] = tmp;
7378 ++nelems;
7379 }
7380 }
7381
7382 if (nddom.contains(i,j,k+1)) {
7383 Real tmp = Real(0.);
7384 if (ccdom.contains(i-1,j-1,k )) {
7385 tmp += - sx(i-1,j-1,k ) * facx * Real(2.0)
7386 - sy(i-1,j-1,k ) * facy * Real(2.0)
7387 + sz(i-1,j-1,k ) * facz * Real(4.0);
7388 }
7389 if (ccdom.contains(i,j-1,k )) {
7390 tmp += - sx(i,j-1,k ) * facx * Real(2.0)
7391 - sy(i,j-1,k ) * facy * Real(2.0)
7392 + sz(i,j-1,k ) * facz * Real(4.0);
7393 }
7394 if (ccdom.contains(i-1,j,k )) {
7395 tmp += - sx(i-1,j,k ) * facx * Real(2.0)
7396 - sy(i-1,j,k ) * facy * Real(2.0)
7397 + sz(i-1,j,k ) * facz * Real(4.0);
7398 }
7399 if (ccdom.contains(i,j,k )) {
7400 tmp += - sx(i,j,k ) * facx * Real(2.0)
7401 - sy(i,j,k ) * facy * Real(2.0)
7402 + sz(i,j,k ) * facz * Real(4.0);
7403 }
7404 m0 -= tmp;
7405 if (gid(i,j,k+1) < gidmax && tmp != Real(0.0)) {
7406 cols[nelems] = gid(i,j,k+1);
7407 mat[nelems] = tmp;
7408 ++nelems;
7409 }
7410 }
7411
7412 if (nddom.contains(i+1,j,k+1)) {
7413 Real tmp = Real(0.);
7414 if (ccdom.contains(i ,j-1,k )) {
7415 tmp += sx(i ,j-1,k ) * facx * Real(2.0)
7416 - sy(i ,j-1,k ) * facy
7417 + sz(i ,j-1,k ) * facz * Real(2.0);
7418 }
7419 if (ccdom.contains(i ,j,k )) {
7420 tmp += sx(i ,j,k ) * facx * Real(2.0)
7421 - sy(i ,j,k ) * facy
7422 + sz(i ,j,k ) * facz * Real(2.0);
7423 }
7424 m0 -= tmp;
7425 if (gid(i+1,j,k+1) < gidmax) {
7426 cols[nelems] = gid(i+1,j,k+1);
7427 mat[nelems] = tmp;
7428 ++nelems;
7429 }
7430 }
7431
7432 if (nddom.contains(i-1,j+1,k+1)) {
7433 Real tmp = sx(i-1,j ,k ) * facx
7434 + sy(i-1,j ,k ) * facy
7435 + sz(i-1,j ,k ) * facz;
7436 m0 -= tmp;
7437 if (gid(i-1,j+1,k+1) < gidmax) {
7438 cols[nelems] = gid(i-1,j+1,k+1);
7439 mat[nelems] = tmp;
7440 ++nelems;
7441 }
7442 }
7443
7444 if (nddom.contains(i,j+1,k+1)) {
7445 Real tmp = Real(0.);
7446 if (ccdom.contains(i-1,j ,k )) {
7447 tmp += - sx(i-1,j ,k ) * facx
7448 + sy(i-1,j ,k ) * facy * Real(2.0)
7449 + sz(i-1,j ,k ) * facz * Real(2.0);
7450 }
7451 if (ccdom.contains(i,j ,k )) {
7452 tmp += - sx(i,j ,k ) * facx
7453 + sy(i,j ,k ) * facy * Real(2.0)
7454 + sz(i,j ,k ) * facz * Real(2.0);
7455 }
7456 m0 -= tmp;
7457 if (gid(i,j+1,k+1) < gidmax) {
7458 cols[nelems] = gid(i,j+1,k+1);
7459 mat[nelems] = tmp;
7460 ++nelems;
7461 }
7462 }
7463
7464 if (nddom.contains(i+1,j+1,k+1)) {
7465 Real tmp = sx(i ,j ,k ) * facx
7466 + sy(i ,j ,k ) * facy
7467 + sz(i ,j ,k ) * facz;
7468 m0 -= tmp;
7469 if (gid(i+1,j+1,k+1) < gidmax) {
7470 cols[nelems] = gid(i+1,j+1,k+1);
7471 mat[nelems] = tmp;
7472 ++nelems;
7473 }
7474 }
7475
7476 mat[nelems_old] = m0;
7477 ncols[lid(i,j,k)] = nelems - nelems_old;
7478 }
7479 });
7480}
7481
7482template <typename HypreInt, typename AtomicInt>
7483void mlndlap_fillijmat_cs_cpu (Box const& ndbx,
7484 Array4<AtomicInt const> const& gid,
7485 Array4<int const> const& lid,
7486 HypreInt* ncols, HypreInt* cols,
7487 Real* mat, // NOLINT(readability-non-const-parameter)
7488 Real sigma,
7489 GpuArray<Real,AMREX_SPACEDIM> const& dxinv,
7490 Box const& ccdom) noexcept
7491{
7492 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0] * sigma;
7493 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1] * sigma;
7494 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2] * sigma;
7495 Real fxyz = facx + facy + facz;
7496 Real fmx2y2z = -facx + Real(2.0)*facy + Real(2.0)*facz;
7497 Real f2xmy2z = Real(2.0)*facx - facy + Real(2.0)*facz;
7498 Real f2x2ymz = Real(2.0)*facx + Real(2.0)*facy - facz;
7499 Real f4xm2ym2z = Real(4.0)*facx - Real(2.0)*facy - Real(2.0)*facz;
7500 Real fm2x4ym2z = -Real(2.0)*facx + Real(4.0)*facy - Real(2.0)*facz;
7501 Real fm2xm2y4z = -Real(2.0)*facx - Real(2.0)*facy + Real(4.0)*facz;
7502
7503 const Box& nddom = amrex::surroundingNodes(ccdom);
7504
7505 constexpr auto gidmax = std::numeric_limits<AtomicInt>::max();
7506 HypreInt nelems = 0;
7507 amrex::LoopOnCpu(ndbx, [&] (int i, int j, int k) noexcept
7508 {
7509 if (lid(i,j,k) >= 0)
7510 {
7511 HypreInt nelems_old = nelems;
7512 cols[nelems_old] = gid(i,j,k);
7513 Real m0 = Real(0.);
7514 ++nelems;
7515
7516 if (nddom.contains(i-1,j-1,k-1)) {
7517 Real tmp = fxyz;
7518 m0 -= tmp;
7519 if ( gid(i-1,j-1,k-1) < gidmax) {
7520 cols[nelems] = gid(i-1,j-1,k-1);
7521 mat[nelems] = tmp;
7522 ++nelems;
7523 }
7524 }
7525
7526 if (nddom.contains(i,j-1,k-1)) {
7527 Real tmp = Real(0.);
7528 if (ccdom.contains(i-1,j-1,k-1)) {
7529 tmp += fmx2y2z;
7530 }
7531 if (ccdom.contains(i,j-1,k-1)) {
7532 tmp += fmx2y2z;
7533 }
7534 m0 -= tmp;
7535 if (gid(i,j-1,k-1) < gidmax) {
7536 cols[nelems] = gid(i,j-1,k-1);
7537 mat[nelems] = tmp;
7538 ++nelems;
7539 }
7540 }
7541
7542 if (nddom.contains(i+1,j-1,k-1)) {
7543 Real tmp = fxyz;
7544 m0 -= tmp;
7545 if (gid(i+1,j-1,k-1) < gidmax) {
7546 cols[nelems] = gid(i+1,j-1,k-1);
7547 mat[nelems] = tmp;
7548 ++nelems;
7549 }
7550 }
7551
7552 if (nddom.contains(i-1,j,k-1)) {
7553 Real tmp = Real(0.);
7554 if (ccdom.contains(i-1,j-1,k-1)) {
7555 tmp += f2xmy2z;
7556 }
7557 if (ccdom.contains(i-1,j,k-1)) {
7558 tmp += f2xmy2z;
7559 }
7560 m0 -= tmp;
7561 if (gid(i-1,j,k-1) < gidmax) {
7562 cols[nelems] = gid(i-1,j,k-1);
7563 mat[nelems] = tmp;
7564 ++nelems;
7565 }
7566 }
7567
7568 if (nddom.contains(i,j,k-1) && fm2xm2y4z != Real(0.0)) {
7569 Real tmp = Real(0.);
7570 if (ccdom.contains(i-1,j-1,k-1)) {
7571 tmp += fm2xm2y4z;
7572 }
7573 if (ccdom.contains(i,j-1,k-1)) {
7574 tmp += fm2xm2y4z;
7575 }
7576 if (ccdom.contains(i-1,j,k-1)) {
7577 tmp += fm2xm2y4z;
7578 }
7579 if (ccdom.contains(i,j,k-1)) {
7580 tmp += fm2xm2y4z;
7581 }
7582 m0 -= tmp;
7583 if (gid(i,j,k-1) < gidmax) {
7584 cols[nelems] = gid(i,j,k-1);
7585 mat[nelems] = tmp;
7586 ++nelems;
7587 }
7588 }
7589
7590 if (nddom.contains(i+1,j,k-1)) {
7591 Real tmp = Real(0.);
7592 if (ccdom.contains(i ,j-1,k-1)) {
7593 tmp += f2xmy2z;
7594 }
7595 if (ccdom.contains(i ,j,k-1)) {
7596 tmp += f2xmy2z;
7597 }
7598 m0 -= tmp;
7599 if (gid(i+1,j,k-1) < gidmax) {
7600 cols[nelems] = gid(i+1,j,k-1);
7601 mat[nelems] = tmp;
7602 ++nelems;
7603 }
7604 }
7605
7606 if (nddom.contains(i-1,j+1,k-1)) {
7607 Real tmp = fxyz;
7608 m0 -= tmp;
7609 if (gid(i-1,j+1,k-1) < gidmax) {
7610 cols[nelems] = gid(i-1,j+1,k-1);
7611 mat[nelems] = tmp;
7612 ++nelems;
7613 }
7614 }
7615
7616 if (nddom.contains(i,j+1,k-1)) {
7617 Real tmp = Real(0.);
7618 if (ccdom.contains(i-1,j ,k-1)) {
7619 tmp += fmx2y2z;
7620 }
7621 if (ccdom.contains(i,j ,k-1)) {
7622 tmp += fmx2y2z;
7623 }
7624 m0 -= tmp;
7625 if (gid(i,j+1,k-1) < gidmax) {
7626 cols[nelems] = gid(i,j+1,k-1);
7627 mat[nelems] = tmp;
7628 ++nelems;
7629 }
7630 }
7631
7632 if (nddom.contains(i+1,j+1,k-1)) {
7633 Real tmp = fxyz;
7634 m0 -= tmp;
7635 if (gid(i+1,j+1,k-1) < gidmax) {
7636 cols[nelems] = gid(i+1,j+1,k-1);
7637 mat[nelems] = tmp;
7638 ++nelems;
7639 }
7640 }
7641
7642 if (nddom.contains(i-1,j-1,k)) {
7643 Real tmp = Real(0.);
7644 if (ccdom.contains(i-1,j-1,k-1)) {
7645 tmp += f2x2ymz;
7646 }
7647 if (ccdom.contains(i-1,j-1,k)) {
7648 tmp += f2x2ymz;
7649 }
7650 m0 -= tmp;
7651 if (gid(i-1,j-1,k) < gidmax) {
7652 cols[nelems] = gid(i-1,j-1,k);
7653 mat[nelems] = tmp;
7654 ++nelems;
7655 }
7656 }
7657
7658 if (nddom.contains(i,j-1,k) && fm2x4ym2z != Real(0.0)) {
7659 Real tmp = Real(0.);
7660 if (ccdom.contains(i-1,j-1,k-1)) {
7661 tmp += fm2x4ym2z;
7662 }
7663 if (ccdom.contains(i,j-1,k-1)) {
7664 tmp += fm2x4ym2z;
7665 }
7666 if (ccdom.contains(i-1,j-1,k)) {
7667 tmp += fm2x4ym2z;
7668 }
7669 if (ccdom.contains(i,j-1,k)) {
7670 tmp += fm2x4ym2z;
7671 }
7672 m0 -= tmp;
7673 if (gid(i,j-1,k) < gidmax) {
7674 cols[nelems] = gid(i,j-1,k);
7675 mat[nelems] = tmp;
7676 ++nelems;
7677 }
7678 }
7679
7680 if (nddom.contains(i+1,j-1,k)) {
7681 Real tmp = Real(0.);
7682 if (ccdom.contains(i ,j-1,k-1)) {
7683 tmp += f2x2ymz;
7684 }
7685 if (ccdom.contains(i ,j-1,k)) {
7686 tmp += f2x2ymz;
7687 }
7688 m0 -= tmp;
7689 if (gid(i+1,j-1,k) < gidmax) {
7690 cols[nelems] = gid(i+1,j-1,k);
7691 mat[nelems] = tmp;
7692 ++nelems;
7693 }
7694 }
7695
7696 if (nddom.contains(i-1,j,k) && f4xm2ym2z != Real(0.0)) {
7697 Real tmp = Real(0.);
7698 if (ccdom.contains(i-1,j-1,k-1)) {
7699 tmp += f4xm2ym2z;
7700 }
7701 if (ccdom.contains(i-1,j,k-1)) {
7702 tmp += f4xm2ym2z;
7703 }
7704 if (ccdom.contains(i-1,j-1,k)) {
7705 tmp += f4xm2ym2z;
7706 }
7707 if (ccdom.contains(i-1,j,k)) {
7708 tmp += f4xm2ym2z;
7709 }
7710 m0 -= tmp;
7711 if (gid(i-1,j,k) < gidmax) {
7712 cols[nelems] = gid(i-1,j,k);
7713 mat[nelems] = tmp;
7714 ++nelems;
7715 }
7716 }
7717
7718 if (nddom.contains(i+1,j,k) && f4xm2ym2z != Real(0.0)) {
7719 Real tmp = Real(0.);
7720 if (ccdom.contains(i ,j-1,k-1)) {
7721 tmp += f4xm2ym2z;
7722 }
7723 if (ccdom.contains(i ,j,k-1)) {
7724 tmp += f4xm2ym2z;
7725 }
7726 if (ccdom.contains(i ,j-1,k)) {
7727 tmp += f4xm2ym2z;
7728 }
7729 if (ccdom.contains(i ,j,k)) {
7730 tmp += f4xm2ym2z;
7731 }
7732 m0 -= tmp;
7733 if (gid(i+1,j,k) < gidmax) {
7734 cols[nelems] = gid(i+1,j,k);
7735 mat[nelems] = tmp;
7736 ++nelems;
7737 }
7738 }
7739
7740 if (nddom.contains(i-1,j+1,k)) {
7741 Real tmp = Real(0.);
7742 if (ccdom.contains(i-1,j ,k-1)) {
7743 tmp += f2x2ymz;
7744 }
7745 if (ccdom.contains(i-1,j ,k)) {
7746 tmp += f2x2ymz;
7747 }
7748 m0 -= tmp;
7749 if (gid(i-1,j+1,k) < gidmax) {
7750 cols[nelems] = gid(i-1,j+1,k);
7751 mat[nelems] = tmp;
7752 ++nelems;
7753 }
7754 }
7755
7756 if (nddom.contains(i,j+1,k) && fm2x4ym2z != Real(0.0)) {
7757 Real tmp = Real(0.);
7758 if (ccdom.contains(i-1,j ,k-1)) {
7759 tmp += fm2x4ym2z;
7760 }
7761 if (ccdom.contains(i,j ,k-1)) {
7762 tmp += fm2x4ym2z;
7763 }
7764 if (ccdom.contains(i-1,j ,k)) {
7765 tmp += fm2x4ym2z;
7766 }
7767 if (ccdom.contains(i,j ,k)) {
7768 tmp += fm2x4ym2z;
7769 }
7770 m0 -= tmp;
7771 if (gid(i,j+1,k) < gidmax) {
7772 cols[nelems] = gid(i,j+1,k);
7773 mat[nelems] = tmp;
7774 ++nelems;
7775 }
7776 }
7777
7778 if (nddom.contains(i+1,j+1,k)) {
7779 Real tmp = Real(0.);
7780 if (ccdom.contains(i ,j ,k-1)) {
7781 tmp += f2x2ymz;
7782 }
7783 if (ccdom.contains(i ,j ,k)) {
7784 tmp += f2x2ymz;
7785 }
7786 m0 -= tmp;
7787 if (gid(i+1,j+1,k) < gidmax) {
7788 cols[nelems] = gid(i+1,j+1,k);
7789 mat[nelems] = tmp;
7790 ++nelems;
7791 }
7792 }
7793
7794 if (nddom.contains(i-1,j-1,k+1)) {
7795 Real tmp = fxyz;
7796 m0 -= tmp;
7797 if (gid(i-1,j-1,k+1) < gidmax) {
7798 cols[nelems] = gid(i-1,j-1,k+1);
7799 mat[nelems] = tmp;
7800 ++nelems;
7801 }
7802 }
7803
7804 if (nddom.contains(i,j-1,k+1)) {
7805 Real tmp = Real(0.);
7806 if (ccdom.contains(i-1,j-1,k )) {
7807 tmp += fmx2y2z;
7808 }
7809 if (ccdom.contains(i,j-1,k )) {
7810 tmp += fmx2y2z;
7811 }
7812 m0 -= tmp;
7813 if (gid(i,j-1,k+1) < gidmax) {
7814 cols[nelems] = gid(i,j-1,k+1);
7815 mat[nelems] = tmp;
7816 ++nelems;
7817 }
7818 }
7819
7820 if (nddom.contains(i+1,j-1,k+1)) {
7821 Real tmp = fxyz;
7822 m0 -= tmp;
7823 if (gid(i+1,j-1,k+1) < gidmax) {
7824 cols[nelems] = gid(i+1,j-1,k+1);
7825 mat[nelems] = tmp;
7826 ++nelems;
7827 }
7828 }
7829
7830 if (nddom.contains(i-1,j,k+1)) {
7831 Real tmp = Real(0.);
7832 if (ccdom.contains(i-1,j-1,k )) {
7833 tmp += f2xmy2z;
7834 }
7835 if (ccdom.contains(i-1,j,k )) {
7836 tmp += f2xmy2z;
7837 }
7838 m0 -= tmp;
7839 if (gid(i-1,j,k+1) < gidmax) {
7840 cols[nelems] = gid(i-1,j,k+1);
7841 mat[nelems] = tmp;
7842 ++nelems;
7843 }
7844 }
7845
7846 if (nddom.contains(i,j,k+1) && fm2xm2y4z != Real(0.0)) {
7847 Real tmp = Real(0.);
7848 if (ccdom.contains(i-1,j-1,k )) {
7849 tmp += fm2xm2y4z;
7850 }
7851 if (ccdom.contains(i,j-1,k )) {
7852 tmp += fm2xm2y4z;
7853 }
7854 if (ccdom.contains(i-1,j,k )) {
7855 tmp += fm2xm2y4z;
7856 }
7857 if (ccdom.contains(i,j,k )) {
7858 tmp += fm2xm2y4z;
7859 }
7860 m0 -= tmp;
7861 if (gid(i,j,k+1) < gidmax) {
7862 cols[nelems] = gid(i,j,k+1);
7863 mat[nelems] = tmp;
7864 ++nelems;
7865 }
7866 }
7867
7868 if (nddom.contains(i+1,j,k+1)) {
7869 Real tmp = Real(0.);
7870 if (ccdom.contains(i ,j-1,k )) {
7871 tmp += f2xmy2z;
7872 }
7873 if (ccdom.contains(i ,j,k )) {
7874 tmp += f2xmy2z;
7875 }
7876 m0 -= tmp;
7877 if (gid(i+1,j,k+1) < gidmax) {
7878 cols[nelems] = gid(i+1,j,k+1);
7879 mat[nelems] = tmp;
7880 ++nelems;
7881 }
7882 }
7883
7884 if (nddom.contains(i-1,j+1,k+1)) {
7885 Real tmp = fxyz;
7886 m0 -= tmp;
7887 if (gid(i-1,j+1,k+1) < gidmax) {
7888 cols[nelems] = gid(i-1,j+1,k+1);
7889 mat[nelems] = tmp;
7890 ++nelems;
7891 }
7892 }
7893
7894 if (nddom.contains(i,j+1,k+1)) {
7895 Real tmp = Real(0.);
7896 if (ccdom.contains(i-1,j ,k )) {
7897 tmp += fmx2y2z;
7898 }
7899 if (ccdom.contains(i,j ,k )) {
7900 tmp += fmx2y2z;
7901 }
7902 m0 -= tmp;
7903 if (gid(i,j+1,k+1) < gidmax) {
7904 cols[nelems] = gid(i,j+1,k+1);
7905 mat[nelems] = tmp;
7906 ++nelems;
7907 }
7908 }
7909
7910 if (nddom.contains(i+1,j+1,k+1)) {
7911 Real tmp = fxyz;
7912 m0 -= tmp;
7913 if (gid(i+1,j+1,k+1) < gidmax) {
7914 cols[nelems] = gid(i+1,j+1,k+1);
7915 mat[nelems] = tmp;
7916 ++nelems;
7917 }
7918 }
7919
7920 mat[nelems_old] = m0;
7921 ncols[lid(i,j,k)] = nelems - nelems_old;
7922 }
7923 });
7924}
7925
7926#ifdef AMREX_USE_GPU
7927
7928template <typename HypreInt, typename AtomicInt>
7930void mlndlap_fillijmat_sten_gpu (const int ps, const int i, const int j, const int k,
7931 const int offset,
7932 Array4<AtomicInt const> const& gid,
7933 Array4<int const> const& lid,
7934 HypreInt* ncols, HypreInt* cols,
7935 Real* mat, // NOLINT(readability-non-const-parameter)
7936 Array4<Real const> const& sten) noexcept
7937{
7938 if (lid(i,j,k) >= 0)
7939 {
7940 constexpr int ist_000 = 1-1;
7941 constexpr int ist_p00 = 2-1;
7942 constexpr int ist_0p0 = 3-1;
7943 constexpr int ist_00p = 4-1;
7944 constexpr int ist_pp0 = 5-1;
7945 constexpr int ist_p0p = 6-1;
7946 constexpr int ist_0pp = 7-1;
7947 constexpr int ist_ppp = 8-1;
7948
7949 constexpr auto gidmax = std::numeric_limits<AtomicInt>::max();
7950 int nelems = 0;
7951
7952 if (offset == 1 || offset == 0) {
7953 if (gid(i-1,j-1,k-1) < gidmax) {
7954 if (offset != 0) {
7955 cols[ps] = gid(i-1,j-1,k-1);
7956 mat[ps] = sten(i-1,j-1,k-1,ist_ppp);
7957 }
7958 ++nelems;
7959 }
7960 if (offset != 0) { return; }
7961 }
7962
7963 if (offset == 2 || offset == 0) {
7964 if (gid(i,j-1,k-1) < gidmax) {
7965 if (offset != 0) {
7966 cols[ps] = gid(i,j-1,k-1);
7967 mat[ps] = sten(i,j-1,k-1,ist_0pp);
7968 }
7969 ++nelems;
7970 }
7971 if (offset != 0) { return; }
7972 }
7973
7974 if (offset == 3 || offset == 0) {
7975 if (gid(i+1,j-1,k-1) < gidmax) {
7976 if (offset != 0) {
7977 cols[ps] = gid(i+1,j-1,k-1);
7978 mat[ps] = sten(i,j-1,k-1,ist_ppp);
7979 }
7980 ++nelems;
7981 }
7982 if (offset != 0) { return; }
7983 }
7984
7985 if (offset == 4 || offset == 0) {
7986 if (gid(i-1,j,k-1) < gidmax) {
7987 if (offset != 0) {
7988 cols[ps] = gid(i-1,j,k-1);
7989 mat[ps] = sten(i-1,j,k-1,ist_p0p);
7990 }
7991 ++nelems;
7992 }
7993 if (offset != 0) { return; }
7994 }
7995
7996 if (offset == 5 || offset == 0) {
7997 if (gid(i,j,k-1) < gidmax) {
7998 if (offset != 0) {
7999 cols[ps] = gid(i,j,k-1);
8000 mat[ps] = sten(i,j,k-1,ist_00p);
8001 }
8002 ++nelems;
8003 }
8004 if (offset != 0) { return; }
8005 }
8006
8007 if (offset == 6 || offset == 0) {
8008 if (gid(i+1,j,k-1) < gidmax) {
8009 if (offset != 0) {
8010 cols[ps] = gid(i+1,j,k-1);
8011 mat[ps] = sten(i,j,k-1,ist_p0p);
8012 }
8013 ++nelems;
8014 }
8015 if (offset != 0) { return; }
8016 }
8017
8018 if (offset == 7 || offset == 0) {
8019 if (gid(i-1,j+1,k-1) < gidmax) {
8020 if (offset != 0) {
8021 cols[ps] = gid(i-1,j+1,k-1);
8022 mat[ps] = sten(i-1,j,k-1,ist_ppp);
8023 }
8024 ++nelems;
8025 }
8026 if (offset != 0) { return; }
8027 }
8028
8029 if (offset == 8 || offset == 0) {
8030 if (gid(i,j+1,k-1) < gidmax) {
8031 if (offset != 0) {
8032 cols[ps] = gid(i,j+1,k-1);
8033 mat[ps] = sten(i,j,k-1,ist_0pp);
8034 }
8035 ++nelems;
8036 }
8037 if (offset != 0) { return; }
8038 }
8039
8040 if (offset == 9 || offset == 0) {
8041 if (gid(i+1,j+1,k-1) < gidmax) {
8042 if (offset != 0) {
8043 cols[ps] = gid(i+1,j+1,k-1);
8044 mat[ps] = sten(i,j,k-1,ist_ppp);
8045 }
8046 ++nelems;
8047 }
8048 if (offset != 0) { return; }
8049 }
8050
8051 if (offset == 10 || offset == 0) {
8052 if (gid(i-1,j-1,k) < gidmax) {
8053 if (offset != 0) {
8054 cols[ps] = gid(i-1,j-1,k);
8055 mat[ps] = sten(i-1,j-1,k,ist_pp0);
8056 }
8057 ++nelems;
8058 }
8059 if (offset != 0) { return; }
8060 }
8061
8062 if (offset == 11 || offset == 0) {
8063 if (gid(i,j-1,k) < gidmax) {
8064 if (offset != 0) {
8065 cols[ps] = gid(i,j-1,k);
8066 mat[ps] = sten(i,j-1,k,ist_0p0);
8067 }
8068 ++nelems;
8069 }
8070 if (offset != 0) { return; }
8071 }
8072
8073 if (offset == 12 || offset == 0) {
8074 if (gid(i+1,j-1,k) < gidmax) {
8075 if (offset != 0) {
8076 cols[ps] = gid(i+1,j-1,k);
8077 mat[ps] = sten(i,j-1,k,ist_pp0);
8078 }
8079 ++nelems;
8080 }
8081 if (offset != 0) { return; }
8082 }
8083
8084 if (offset == 13 || offset == 0) {
8085 if (gid(i-1,j,k) < gidmax) {
8086 if (offset != 0) {
8087 cols[ps] = gid(i-1,j,k);
8088 mat[ps] = sten(i-1,j,k,ist_p00);
8089 }
8090 ++nelems;
8091 }
8092 if (offset != 0) { return; }
8093 }
8094
8095 if (offset == 14 || offset == 0) {
8096 if (gid(i+1,j,k) < gidmax) {
8097 if (offset != 0) {
8098 cols[ps] = gid(i+1,j,k);
8099 mat[ps] = sten(i,j,k,ist_p00);
8100 }
8101 ++nelems;
8102 }
8103 if (offset != 0) { return; }
8104 }
8105
8106 if (offset == 15 || offset == 0) {
8107 if (gid(i-1,j+1,k) < gidmax) {
8108 if (offset != 0) {
8109 cols[ps] = gid(i-1,j+1,k);
8110 mat[ps] = sten(i-1,j,k,ist_pp0);
8111 }
8112 ++nelems;
8113 }
8114 if (offset != 0) { return; }
8115 }
8116
8117 if (offset == 16 || offset == 0) {
8118 if (gid(i,j+1,k) < gidmax) {
8119 if (offset != 0) {
8120 cols[ps] = gid(i,j+1,k);
8121 mat[ps] = sten(i,j,k,ist_0p0);
8122 }
8123 ++nelems;
8124 }
8125 if (offset != 0) { return; }
8126 }
8127
8128 if (offset == 17 || offset == 0) {
8129 if (gid(i+1,j+1,k) < gidmax) {
8130 if (offset != 0) {
8131 cols[ps] = gid(i+1,j+1,k);
8132 mat[ps] = sten(i,j,k,ist_pp0);
8133 }
8134 ++nelems;
8135 }
8136 if (offset != 0) { return; }
8137 }
8138
8139 if (offset == 18 || offset == 0) {
8140 if (gid(i-1,j-1,k+1) < gidmax) {
8141 if (offset != 0) {
8142 cols[ps] = gid(i-1,j-1,k+1);
8143 mat[ps] = sten(i-1,j-1,k,ist_ppp);
8144 }
8145 ++nelems;
8146 }
8147 if (offset != 0) { return; }
8148 }
8149
8150 if (offset == 19 || offset == 0) {
8151 if (gid(i,j-1,k+1) < gidmax) {
8152 if (offset != 0) {
8153 cols[ps] = gid(i,j-1,k+1);
8154 mat[ps] = sten(i,j-1,k,ist_0pp);
8155 }
8156 ++nelems;
8157 }
8158 if (offset != 0) { return; }
8159 }
8160
8161 if (offset == 20 || offset == 0) {
8162 if (gid(i+1,j-1,k+1) < gidmax) {
8163 if (offset != 0) {
8164 cols[ps] = gid(i+1,j-1,k+1);
8165 mat[ps] = sten(i,j-1,k,ist_ppp);
8166 }
8167 ++nelems;
8168 }
8169 if (offset != 0) { return; }
8170 }
8171
8172 if (offset == 21 || offset == 0) {
8173 if (gid(i-1,j,k+1) < gidmax) {
8174 if (offset != 0) {
8175 cols[ps] = gid(i-1,j,k+1);
8176 mat[ps] = sten(i-1,j,k,ist_p0p);
8177 }
8178 ++nelems;
8179 }
8180 if (offset != 0) { return; }
8181 }
8182
8183 if (offset == 22 || offset == 0) {
8184 if (gid(i,j,k+1) < gidmax) {
8185 if (offset != 0) {
8186 cols[ps] = gid(i,j,k+1);
8187 mat[ps] = sten(i,j,k,ist_00p);
8188 }
8189 ++nelems;
8190 }
8191 if (offset != 0) { return; }
8192 }
8193
8194 if (offset == 23 || offset == 0) {
8195 if (gid(i+1,j,k+1) < gidmax) {
8196 if (offset != 0) {
8197 cols[ps] = gid(i+1,j,k+1);
8198 mat[ps] = sten(i,j,k,ist_p0p);
8199 }
8200 ++nelems;
8201 }
8202 if (offset != 0) { return; }
8203 }
8204
8205 if (offset == 24 || offset == 0) {
8206 if (gid(i-1,j+1,k+1) < gidmax) {
8207 if (offset != 0) {
8208 cols[ps] = gid(i-1,j+1,k+1);
8209 mat[ps] = sten(i-1,j,k,ist_ppp);
8210 }
8211 ++nelems;
8212 }
8213 if (offset != 0) { return; }
8214 }
8215
8216 if (offset == 25 || offset == 0) {
8217 if (gid(i,j+1,k+1) < gidmax) {
8218 if (offset != 0) {
8219 cols[ps] = gid(i,j+1,k+1);
8220 mat[ps] = sten(i,j,k,ist_0pp);
8221 }
8222 ++nelems;
8223 }
8224 if (offset != 0) { return; }
8225 }
8226
8227 if (offset == 26 || offset == 0) {
8228 if (gid(i+1,j+1,k+1) < gidmax) {
8229 if (offset != 0) {
8230 cols[ps] = gid(i+1,j+1,k+1);
8231 mat[ps] = sten(i,j,k,ist_ppp);
8232 }
8233 ++nelems;
8234 }
8235 if (offset != 0) { return; }
8236 }
8237
8238 // Only offset == 0 could get this far.
8239 cols[ps] = gid(i,j,k);
8240 mat[ps] = sten(i,j,k,ist_000);
8241 ncols[lid(i,j,k)] = nelems+1;
8242 }
8243}
8244
8245template <typename HypreInt, typename AtomicInt>
8247void mlndlap_fillijmat_aa_gpu (const int ps, const int i, const int j, const int k,
8248 const int offset,
8249 Box const& ndbx, Array4<AtomicInt const> const& gid,
8250 Array4<int const> const& lid,
8251 HypreInt* ncols, HypreInt* cols,
8252 Real* mat, // NOLINT(readability-non-const-parameter)
8253 Array4<Real const> const& sig,
8254 GpuArray<Real,AMREX_SPACEDIM> const& dxinv,
8255 Box const& ccdom) noexcept
8256{
8257 if (lid(i,j,k) >= 0)
8258 {
8259 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
8260 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
8261 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
8262 Real fxyz = facx + facy + facz;
8263 Real fmx2y2z = -facx + Real(2.0)*facy + Real(2.0)*facz;
8264 Real f2xmy2z = Real(2.0)*facx - facy + Real(2.0)*facz;
8265 Real f2x2ymz = Real(2.0)*facx + Real(2.0)*facy - facz;
8266 Real f4xm2ym2z = Real(4.0)*facx - Real(2.0)*facy - Real(2.0)*facz;
8267 Real fm2x4ym2z = -Real(2.0)*facx + Real(4.0)*facy - Real(2.0)*facz;
8268 Real fm2xm2y4z = -Real(2.0)*facx - Real(2.0)*facy + Real(4.0)*facz;
8269
8270 const Box& nddom = amrex::surroundingNodes(ccdom);
8271
8272 constexpr auto gidmax = std::numeric_limits<AtomicInt>::max();
8273 int nelems = 0;
8274 Real m0 = Real(0.);
8275
8276 if (offset == 1 || offset == 0) {
8277 if (nddom.contains(i-1,j-1,k-1)) {
8278 Real tmp = sig(i-1,j-1,k-1) * fxyz;
8279 m0 -= tmp;
8280 if ( gid(i-1,j-1,k-1) < gidmax) {
8281 if (offset != 0) {
8282 cols[ps] = gid(i-1,j-1,k-1);
8283 mat[ps] = tmp;
8284 }
8285 ++nelems;
8286 }
8287 }
8288 if (offset != 0) { return; }
8289 }
8290
8291 if (offset == 2 || offset == 0) {
8292 if (nddom.contains(i,j-1,k-1)) {
8293 Real tmp = Real(0.);
8294 if (ccdom.contains(i-1,j-1,k-1)) {
8295 tmp += sig(i-1,j-1,k-1) * fmx2y2z;
8296 }
8297 if (ccdom.contains(i,j-1,k-1)) {
8298 tmp += sig(i,j-1,k-1) * fmx2y2z;
8299 }
8300 m0 -= tmp;
8301 if (gid(i,j-1,k-1) < gidmax) {
8302 if (offset != 0) {
8303 cols[ps] = gid(i,j-1,k-1);
8304 mat[ps] = tmp;
8305 }
8306 ++nelems;
8307 }
8308 }
8309 if (offset != 0) { return; }
8310 }
8311
8312 if (offset == 3 || offset == 0) {
8313 if (nddom.contains(i+1,j-1,k-1)) {
8314 Real tmp = sig(i ,j-1,k-1) * fxyz;
8315 m0 -= tmp;
8316 if (gid(i+1,j-1,k-1) < gidmax) {
8317 if (offset != 0) {
8318 cols[ps] = gid(i+1,j-1,k-1);
8319 mat[ps] = tmp;
8320 }
8321 ++nelems;
8322 }
8323 }
8324 if (offset != 0) { return; }
8325 }
8326
8327 if (offset == 4 || offset == 0) {
8328 if (nddom.contains(i-1,j,k-1)) {
8329 Real tmp = Real(0.);
8330 if (ccdom.contains(i-1,j-1,k-1)) {
8331 tmp += sig(i-1,j-1,k-1) * f2xmy2z;
8332 }
8333 if (ccdom.contains(i-1,j,k-1)) {
8334 tmp += sig(i-1,j,k-1) * f2xmy2z;
8335 }
8336 m0 -= tmp;
8337 if (gid(i-1,j,k-1) < gidmax) {
8338 if (offset != 0) {
8339 cols[ps] = gid(i-1,j,k-1);
8340 mat[ps] = tmp;
8341 }
8342 ++nelems;
8343 }
8344 }
8345 if (offset != 0) { return; }
8346 }
8347
8348 if (offset == 5 || offset == 0) {
8349 if (nddom.contains(i,j,k-1)) {
8350 Real tmp = Real(0.);
8351 if (ccdom.contains(i-1,j-1,k-1)) {
8352 tmp += sig(i-1,j-1,k-1) * fm2xm2y4z;
8353 }
8354 if (ccdom.contains(i,j-1,k-1)) {
8355 tmp += sig(i,j-1,k-1) * fm2xm2y4z;
8356 }
8357 if (ccdom.contains(i-1,j,k-1)) {
8358 tmp += sig(i-1,j,k-1) * fm2xm2y4z;
8359 }
8360 if (ccdom.contains(i,j,k-1)) {
8361 tmp += sig(i,j,k-1) * fm2xm2y4z;
8362 }
8363 m0 -= tmp;
8364 if (gid(i,j,k-1) < gidmax) {
8365 if (offset != 0) {
8366 cols[ps] = gid(i,j,k-1);
8367 mat[ps] = tmp;
8368 }
8369 ++nelems;
8370 }
8371 }
8372 if (offset != 0) { return; }
8373 }
8374
8375 if (offset == 6 || offset == 0) {
8376 if (nddom.contains(i+1,j,k-1)) {
8377 Real tmp = Real(0.);
8378 if (ccdom.contains(i ,j-1,k-1)) {
8379 tmp += sig(i ,j-1,k-1) * f2xmy2z;
8380 }
8381 if (ccdom.contains(i ,j,k-1)) {
8382 tmp += sig(i ,j,k-1) * f2xmy2z;
8383 }
8384 m0 -= tmp;
8385 if (gid(i+1,j,k-1) < gidmax) {
8386 if (offset != 0) {
8387 cols[ps] = gid(i+1,j,k-1);
8388 mat[ps] = tmp;
8389 }
8390 ++nelems;
8391 }
8392 }
8393 if (offset != 0) { return; }
8394 }
8395
8396 if (offset == 7 || offset == 0) {
8397 if (nddom.contains(i-1,j+1,k-1)) {
8398 Real tmp = sig(i-1,j ,k-1) * fxyz;
8399 m0 -= tmp;
8400 if (gid(i-1,j+1,k-1) < gidmax) {
8401 if (offset != 0) {
8402 cols[ps] = gid(i-1,j+1,k-1);
8403 mat[ps] = tmp;
8404 }
8405 ++nelems;
8406 }
8407 }
8408 if (offset != 0) { return; }
8409 }
8410
8411 if (offset == 8 || offset == 0) {
8412 if (nddom.contains(i,j+1,k-1)) {
8413 Real tmp = Real(0.);
8414 if (ccdom.contains(i-1,j ,k-1)) {
8415 tmp += sig(i-1,j ,k-1) * fmx2y2z;
8416 }
8417 if (ccdom.contains(i,j ,k-1)) {
8418 tmp += sig(i,j ,k-1) * fmx2y2z;
8419 }
8420 m0 -= tmp;
8421 if (gid(i,j+1,k-1) < gidmax) {
8422 if (offset != 0) {
8423 cols[ps] = gid(i,j+1,k-1);
8424 mat[ps] = tmp;
8425 }
8426 ++nelems;
8427 }
8428 }
8429 if (offset != 0) { return; }
8430 }
8431
8432 if (offset == 9 || offset == 0) {
8433 if (nddom.contains(i+1,j+1,k-1)) {
8434 Real tmp = sig(i ,j ,k-1) * fxyz;
8435 m0 -= tmp;
8436 if (gid(i+1,j+1,k-1) < gidmax) {
8437 if (offset != 0) {
8438 cols[ps] = gid(i+1,j+1,k-1);
8439 mat[ps] = tmp;
8440 }
8441 ++nelems;
8442 }
8443 }
8444 if (offset != 0) { return; }
8445 }
8446
8447 if (offset == 10 || offset == 0) {
8448 if (nddom.contains(i-1,j-1,k)) {
8449 Real tmp = Real(0.);
8450 if (ccdom.contains(i-1,j-1,k-1)) {
8451 tmp += sig(i-1,j-1,k-1) * f2x2ymz;
8452 }
8453 if (ccdom.contains(i-1,j-1,k)) {
8454 tmp += sig(i-1,j-1,k) * f2x2ymz;
8455 }
8456 m0 -= tmp;
8457 if (gid(i-1,j-1,k) < gidmax) {
8458 if (offset != 0) {
8459 cols[ps] = gid(i-1,j-1,k);
8460 mat[ps] = tmp;
8461 }
8462 ++nelems;
8463 }
8464 }
8465 if (offset != 0) { return; }
8466 }
8467
8468 if (offset == 11 || offset == 0) {
8469 if (nddom.contains(i,j-1,k)) {
8470 Real tmp = Real(0.);
8471 if (ccdom.contains(i-1,j-1,k-1)) {
8472 tmp += sig(i-1,j-1,k-1) * fm2x4ym2z;
8473 }
8474 if (ccdom.contains(i,j-1,k-1)) {
8475 tmp += sig(i,j-1,k-1) * fm2x4ym2z;
8476 }
8477 if (ccdom.contains(i-1,j-1,k)) {
8478 tmp += sig(i-1,j-1,k) * fm2x4ym2z;
8479 }
8480 if (ccdom.contains(i,j-1,k)) {
8481 tmp += sig(i,j-1,k) * fm2x4ym2z;
8482 }
8483 m0 -= tmp;
8484 if (gid(i,j-1,k) < gidmax) {
8485 if (offset != 0) {
8486 cols[ps] = gid(i,j-1,k);
8487 mat[ps] = tmp;
8488 }
8489 ++nelems;
8490 }
8491 }
8492 if (offset != 0) { return; }
8493 }
8494
8495 if (offset == 12 || offset == 0) {
8496 if (nddom.contains(i+1,j-1,k)) {
8497 Real tmp = Real(0.);
8498 if (ccdom.contains(i ,j-1,k-1)) {
8499 tmp += sig(i ,j-1,k-1) * f2x2ymz;
8500 }
8501 if (ccdom.contains(i ,j-1,k)) {
8502 tmp += sig(i ,j-1,k) * f2x2ymz;
8503 }
8504 m0 -= tmp;
8505 if (gid(i+1,j-1,k) < gidmax) {
8506 if (offset != 0) {
8507 cols[ps] = gid(i+1,j-1,k);
8508 mat[ps] = tmp;
8509 }
8510 ++nelems;
8511 }
8512 }
8513 if (offset != 0) { return; }
8514 }
8515
8516 if (offset == 13 || offset == 0) {
8517 if (nddom.contains(i-1,j,k)) {
8518 Real tmp = Real(0.);
8519 if (ccdom.contains(i-1,j-1,k-1)) {
8520 tmp += sig(i-1,j-1,k-1) * f4xm2ym2z;
8521 }
8522 if (ccdom.contains(i-1,j,k-1)) {
8523 tmp += sig(i-1,j,k-1) * f4xm2ym2z;
8524 }
8525 if (ccdom.contains(i-1,j-1,k)) {
8526 tmp += sig(i-1,j-1,k) * f4xm2ym2z;
8527 }
8528 if (ccdom.contains(i-1,j,k)) {
8529 tmp += sig(i-1,j,k) * f4xm2ym2z;
8530 }
8531 m0 -= tmp;
8532 if (gid(i-1,j,k) < gidmax) {
8533 if (offset != 0) {
8534 cols[ps] = gid(i-1,j,k);
8535 mat[ps] = tmp;
8536 }
8537 ++nelems;
8538 }
8539 }
8540 if (offset != 0) { return; }
8541 }
8542
8543 if (offset == 14 || offset == 0) {
8544 if (nddom.contains(i+1,j,k)) {
8545 Real tmp = Real(0.);
8546 if (ccdom.contains(i ,j-1,k-1)) {
8547 tmp += sig(i ,j-1,k-1) * f4xm2ym2z;
8548 }
8549 if (ccdom.contains(i ,j,k-1)) {
8550 tmp += sig(i ,j,k-1) * f4xm2ym2z;
8551 }
8552 if (ccdom.contains(i ,j-1,k)) {
8553 tmp += sig(i ,j-1,k) * f4xm2ym2z;
8554 }
8555 if (ccdom.contains(i ,j,k)) {
8556 tmp += sig(i ,j,k) * f4xm2ym2z;
8557 }
8558 m0 -= tmp;
8559 if (gid(i+1,j,k) < gidmax) {
8560 if (offset != 0) {
8561 cols[ps] = gid(i+1,j,k);
8562 mat[ps] = tmp;
8563 }
8564 ++nelems;
8565 }
8566 }
8567 if (offset != 0) { return; }
8568 }
8569
8570 if (offset == 15 || offset == 0) {
8571 if (nddom.contains(i-1,j+1,k)) {
8572 Real tmp = Real(0.);
8573 if (ccdom.contains(i-1,j ,k-1)) {
8574 tmp += sig(i-1,j ,k-1) * f2x2ymz;
8575 }
8576 if (ccdom.contains(i-1,j ,k)) {
8577 tmp += sig(i-1,j ,k) * f2x2ymz;
8578 }
8579 m0 -= tmp;
8580 if (gid(i-1,j+1,k) < gidmax) {
8581 if (offset != 0) {
8582 cols[ps] = gid(i-1,j+1,k);
8583 mat[ps] = tmp;
8584 }
8585 ++nelems;
8586 }
8587 }
8588 if (offset != 0) { return; }
8589 }
8590
8591 if (offset == 16 || offset == 0) {
8592 if (nddom.contains(i,j+1,k)) {
8593 Real tmp = Real(0.);
8594 if (ccdom.contains(i-1,j ,k-1)) {
8595 tmp += sig(i-1,j ,k-1) * fm2x4ym2z;
8596 }
8597 if (ccdom.contains(i,j ,k-1)) {
8598 tmp += sig(i,j ,k-1) * fm2x4ym2z;
8599 }
8600 if (ccdom.contains(i-1,j ,k)) {
8601 tmp += sig(i-1,j ,k) * fm2x4ym2z;
8602 }
8603 if (ccdom.contains(i,j ,k)) {
8604 tmp += sig(i,j ,k) * fm2x4ym2z;
8605 }
8606 m0 -= tmp;
8607 if (gid(i,j+1,k) < gidmax) {
8608 if (offset != 0) {
8609 cols[ps] = gid(i,j+1,k);
8610 mat[ps] = tmp;
8611 }
8612 ++nelems;
8613 }
8614 }
8615 if (offset != 0) { return; }
8616 }
8617
8618 if (offset == 17 || offset == 0) {
8619 if (nddom.contains(i+1,j+1,k)) {
8620 Real tmp = Real(0.);
8621 if (ccdom.contains(i ,j ,k-1)) {
8622 tmp += sig(i ,j ,k-1) * f2x2ymz;
8623 }
8624 if (ccdom.contains(i ,j ,k)) {
8625 tmp += sig(i ,j ,k) * f2x2ymz;
8626 }
8627 m0 -= tmp;
8628 if (gid(i+1,j+1,k) < gidmax) {
8629 if (offset != 0) {
8630 cols[ps] = gid(i+1,j+1,k);
8631 mat[ps] = tmp;
8632 }
8633 ++nelems;
8634 }
8635 }
8636 if (offset != 0) { return; }
8637 }
8638
8639 if (offset == 18 || offset == 0) {
8640 if (nddom.contains(i-1,j-1,k+1)) {
8641 Real tmp = sig(i-1,j-1,k ) * fxyz;
8642 m0 -= tmp;
8643 if (gid(i-1,j-1,k+1) < gidmax) {
8644 if (offset != 0) {
8645 cols[ps] = gid(i-1,j-1,k+1);
8646 mat[ps] = tmp;
8647 }
8648 ++nelems;
8649 }
8650 }
8651 if (offset != 0) { return; }
8652 }
8653
8654 if (offset == 19 || offset == 0) {
8655 if (nddom.contains(i,j-1,k+1)) {
8656 Real tmp = Real(0.);
8657 if (ccdom.contains(i-1,j-1,k )) {
8658 tmp += sig(i-1,j-1,k ) * fmx2y2z;
8659 }
8660 if (ccdom.contains(i,j-1,k )) {
8661 tmp += sig(i,j-1,k ) * fmx2y2z;
8662 }
8663 m0 -= tmp;
8664 if (gid(i,j-1,k+1) < gidmax) {
8665 if (offset != 0) {
8666 cols[ps] = gid(i,j-1,k+1);
8667 mat[ps] = tmp;
8668 }
8669 ++nelems;
8670 }
8671 }
8672 if (offset != 0) { return; }
8673 }
8674
8675 if (offset == 20 || offset == 0) {
8676 if (nddom.contains(i+1,j-1,k+1)) {
8677 Real tmp = sig(i ,j-1,k ) * fxyz;
8678 m0 -= tmp;
8679 if (gid(i+1,j-1,k+1) < gidmax) {
8680 if (offset != 0) {
8681 cols[ps] = gid(i+1,j-1,k+1);
8682 mat[ps] = tmp;
8683 }
8684 ++nelems;
8685 }
8686 }
8687 if (offset != 0) { return; }
8688 }
8689
8690 if (offset == 21 || offset == 0) {
8691 if (nddom.contains(i-1,j,k+1)) {
8692 Real tmp = Real(0.);
8693 if (ccdom.contains(i-1,j-1,k )) {
8694 tmp += sig(i-1,j-1,k ) * f2xmy2z;
8695 }
8696 if (ccdom.contains(i-1,j,k )) {
8697 tmp += sig(i-1,j,k ) * f2xmy2z;
8698 }
8699 m0 -= tmp;
8700 if (gid(i-1,j,k+1) < gidmax) {
8701 if (offset != 0) {
8702 cols[ps] = gid(i-1,j,k+1);
8703 mat[ps] = tmp;
8704 }
8705 ++nelems;
8706 }
8707 }
8708 if (offset != 0) { return; }
8709 }
8710
8711 if (offset == 22 || offset == 0) {
8712 if (nddom.contains(i,j,k+1)) {
8713 Real tmp = Real(0.);
8714 if (ccdom.contains(i-1,j-1,k )) {
8715 tmp += sig(i-1,j-1,k ) * fm2xm2y4z;
8716 }
8717 if (ccdom.contains(i,j-1,k )) {
8718 tmp += sig(i,j-1,k ) * fm2xm2y4z;
8719 }
8720 if (ccdom.contains(i-1,j,k )) {
8721 tmp += sig(i-1,j,k ) * fm2xm2y4z;
8722 }
8723 if (ccdom.contains(i,j,k )) {
8724 tmp += sig(i,j,k ) * fm2xm2y4z;
8725 }
8726 m0 -= tmp;
8727 if (gid(i,j,k+1) < gidmax) {
8728 if (offset != 0) {
8729 cols[ps] = gid(i,j,k+1);
8730 mat[ps] = tmp;
8731 }
8732 ++nelems;
8733 }
8734 }
8735 if (offset != 0) { return; }
8736 }
8737
8738 if (offset == 23 || offset == 0) {
8739 if (nddom.contains(i+1,j,k+1)) {
8740 Real tmp = Real(0.);
8741 if (ccdom.contains(i ,j-1,k )) {
8742 tmp += sig(i ,j-1,k ) * f2xmy2z;
8743 }
8744 if (ccdom.contains(i ,j,k )) {
8745 tmp += sig(i ,j,k ) * f2xmy2z;
8746 }
8747 m0 -= tmp;
8748 if (gid(i+1,j,k+1) < gidmax) {
8749 if (offset != 0) {
8750 cols[ps] = gid(i+1,j,k+1);
8751 mat[ps] = tmp;
8752 }
8753 ++nelems;
8754 }
8755 }
8756 if (offset != 0) { return; }
8757 }
8758
8759 if (offset == 24 || offset == 0) {
8760 if (nddom.contains(i-1,j+1,k+1)) {
8761 Real tmp = sig(i-1,j ,k ) * fxyz;
8762 m0 -= tmp;
8763 if (gid(i-1,j+1,k+1) < gidmax) {
8764 if (offset != 0) {
8765 cols[ps] = gid(i-1,j+1,k+1);
8766 mat[ps] = tmp;
8767 }
8768 ++nelems;
8769 }
8770 }
8771 if (offset != 0) { return; }
8772 }
8773
8774 if (offset == 25 || offset == 0) {
8775 if (nddom.contains(i,j+1,k+1)) {
8776 Real tmp = Real(0.);
8777 if (ccdom.contains(i-1,j ,k )) {
8778 tmp += sig(i-1,j ,k ) * fmx2y2z;
8779 }
8780 if (ccdom.contains(i,j ,k )) {
8781 tmp += sig(i,j ,k ) * fmx2y2z;
8782 }
8783 m0 -= tmp;
8784 if (gid(i,j+1,k+1) < gidmax) {
8785 if (offset != 0) {
8786 cols[ps] = gid(i,j+1,k+1);
8787 mat[ps] = tmp;
8788 }
8789 ++nelems;
8790 }
8791 }
8792 if (offset != 0) { return; }
8793 }
8794
8795 if (offset == 26 || offset == 0) {
8796 if (nddom.contains(i+1,j+1,k+1)) {
8797 Real tmp = sig(i ,j ,k ) * fxyz;
8798 m0 -= tmp;
8799 if (gid(i+1,j+1,k+1) < gidmax) {
8800 if (offset != 0) {
8801 cols[ps] = gid(i+1,j+1,k+1);
8802 mat[ps] = tmp;
8803 }
8804 ++nelems;
8805 }
8806 }
8807 if (offset != 0) { return; }
8808 }
8809
8810 // Only offset == 0 could get this far.
8811 cols[ps] = gid(i,j,k);
8812 mat[ps] = m0;
8813 ncols[lid(i,j,k)] = nelems+1;
8814 }
8815}
8816
8817template <typename HypreInt, typename AtomicInt>
8819void mlndlap_fillijmat_ha_gpu (const int ps, const int i, const int j, const int k,
8820 const int offset,
8821 Box const& ndbx, Array4<AtomicInt const> const& gid,
8822 Array4<int const> const& lid,
8823 HypreInt* ncols, HypreInt* cols,
8824 Real* mat, // NOLINT(readability-non-const-parameter)
8825 Array4<Real const> const& sx,
8826 Array4<Real const> const& sy,
8827 Array4<Real const> const& sz,
8828 GpuArray<Real,AMREX_SPACEDIM> const& dxinv,
8829 Box const& ccdom) noexcept
8830{
8831 if (lid(i,j,k) >= 0)
8832 {
8833 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
8834 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
8835 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
8836
8837 const Box& nddom = amrex::surroundingNodes(ccdom);
8838
8839 constexpr auto gidmax = std::numeric_limits<AtomicInt>::max();
8840 int nelems = 0;
8841 Real m0 = Real(0.);
8842
8843 if (offset == 1 || offset == 0) {
8844 if (nddom.contains(i-1,j-1,k-1)) {
8845 Real tmp = sx(i-1,j-1,k-1) * facx
8846 + sy(i-1,j-1,k-1) * facy
8847 + sz(i-1,j-1,k-1) * facz;
8848 m0 -= tmp;
8849 if ( gid(i-1,j-1,k-1) < gidmax) {
8850 if (offset != 0) {
8851 cols[ps] = gid(i-1,j-1,k-1);
8852 mat[ps] = tmp;
8853 }
8854 ++nelems;
8855 }
8856 }
8857 if (offset != 0) { return; }
8858 }
8859
8860 if (offset == 2 || offset == 0) {
8861 if (nddom.contains(i,j-1,k-1)) {
8862 Real tmp = Real(0.);
8863 if (ccdom.contains(i-1,j-1,k-1)) {
8864 tmp += - sx(i-1,j-1,k-1) * facx
8865 + sy(i-1,j-1,k-1) * facy * Real(2.0)
8866 + sz(i-1,j-1,k-1) * facz * Real(2.0);
8867 }
8868 if (ccdom.contains(i,j-1,k-1)) {
8869 tmp += - sx(i,j-1,k-1) * facx
8870 + sy(i,j-1,k-1) * facy * Real(2.0)
8871 + sz(i,j-1,k-1) * facz * Real(2.0);
8872 }
8873 m0 -= tmp;
8874 if (gid(i,j-1,k-1) < gidmax) {
8875 if (offset != 0) {
8876 cols[ps] = gid(i,j-1,k-1);
8877 mat[ps] = tmp;
8878 }
8879 ++nelems;
8880 }
8881 }
8882 if (offset != 0) { return; }
8883 }
8884
8885 if (offset == 3 || offset == 0) {
8886 if (nddom.contains(i+1,j-1,k-1)) {
8887 Real tmp = sx(i ,j-1,k-1) * facx
8888 + sy(i ,j-1,k-1) * facy
8889 + sz(i ,j-1,k-1) * facz;
8890 m0 -= tmp;
8891 if (gid(i+1,j-1,k-1) < gidmax) {
8892 if (offset != 0) {
8893 cols[ps] = gid(i+1,j-1,k-1);
8894 mat[ps] = tmp;
8895 }
8896 ++nelems;
8897 }
8898 }
8899 if (offset != 0) { return; }
8900 }
8901
8902 if (offset == 4 || offset == 0) {
8903 if (nddom.contains(i-1,j,k-1)) {
8904 Real tmp = Real(0.);
8905 if (ccdom.contains(i-1,j-1,k-1)) {
8906 tmp += sx(i-1,j-1,k-1) * facx * Real(2.0)
8907 - sy(i-1,j-1,k-1) * facy
8908 + sz(i-1,j-1,k-1) * facz * Real(2.0);
8909 }
8910 if (ccdom.contains(i-1,j,k-1)) {
8911 tmp += sx(i-1,j,k-1) * facx * Real(2.0)
8912 - sy(i-1,j,k-1) * facy
8913 + sz(i-1,j,k-1) * facz * Real(2.0);
8914 }
8915 m0 -= tmp;
8916 if (gid(i-1,j,k-1) < gidmax) {
8917 if (offset != 0) {
8918 cols[ps] = gid(i-1,j,k-1);
8919 mat[ps] = tmp;
8920 }
8921 ++nelems;
8922 }
8923 }
8924 if (offset != 0) { return; }
8925 }
8926
8927 if (offset == 5 || offset == 0) {
8928 if (nddom.contains(i,j,k-1)) {
8929 Real tmp = Real(0.);
8930 if (ccdom.contains(i-1,j-1,k-1)) {
8931 tmp += - sx(i-1,j-1,k-1) * facx * Real(2.0)
8932 - sy(i-1,j-1,k-1) * facy * Real(2.0)
8933 + sz(i-1,j-1,k-1) * facz * Real(4.0);
8934 }
8935 if (ccdom.contains(i,j-1,k-1)) {
8936 tmp += - sx(i,j-1,k-1) * facx * Real(2.0)
8937 - sy(i,j-1,k-1) * facy * Real(2.0)
8938 + sz(i,j-1,k-1) * facz * Real(4.0);
8939
8940 }
8941 if (ccdom.contains(i-1,j,k-1)) {
8942 tmp += - sx(i-1,j,k-1) * facx * Real(2.0)
8943 - sy(i-1,j,k-1) * facy * Real(2.0)
8944 + sz(i-1,j,k-1) * facz * Real(4.0);
8945 }
8946 if (ccdom.contains(i,j,k-1)) {
8947 tmp += - sx(i,j,k-1) * facx * Real(2.0)
8948 - sy(i,j,k-1) * facy * Real(2.0)
8949 + sz(i,j,k-1) * facz * Real(4.0);
8950 }
8951 m0 -= tmp;
8952 if (gid(i,j,k-1) < gidmax) {
8953 if (offset != 0) {
8954 cols[ps] = gid(i,j,k-1);
8955 mat[ps] = tmp;
8956 }
8957 ++nelems;
8958 }
8959 }
8960 if (offset != 0) { return; }
8961 }
8962
8963 if (offset == 6 || offset == 0) {
8964 if (nddom.contains(i+1,j,k-1)) {
8965 Real tmp = Real(0.);
8966 if (ccdom.contains(i ,j-1,k-1)) {
8967 tmp += sx(i ,j-1,k-1) * facx * Real(2.0)
8968 - sy(i ,j-1,k-1) * facy
8969 + sz(i ,j-1,k-1) * facz * Real(2.0);
8970 }
8971 if (ccdom.contains(i ,j,k-1)) {
8972 tmp += sx(i ,j,k-1) * facx * Real(2.0)
8973 - sy(i ,j,k-1) * facy
8974 + sz(i ,j,k-1) * facz * Real(2.0);
8975 }
8976 m0 -= tmp;
8977 if (gid(i+1,j,k-1) < gidmax) {
8978 if (offset != 0) {
8979 cols[ps] = gid(i+1,j,k-1);
8980 mat[ps] = tmp;
8981 }
8982 ++nelems;
8983 }
8984 }
8985 if (offset != 0) { return; }
8986 }
8987
8988 if (offset == 7 || offset == 0) {
8989 if (nddom.contains(i-1,j+1,k-1)) {
8990 Real tmp = sx(i-1,j ,k-1) * facx
8991 + sy(i-1,j ,k-1) * facy
8992 + sz(i-1,j ,k-1) * facz;
8993 m0 -= tmp;
8994 if (gid(i-1,j+1,k-1) < gidmax) {
8995 if (offset != 0) {
8996 cols[ps] = gid(i-1,j+1,k-1);
8997 mat[ps] = tmp;
8998 }
8999 ++nelems;
9000 }
9001 }
9002 if (offset != 0) { return; }
9003 }
9004
9005 if (offset == 8 || offset == 0) {
9006 if (nddom.contains(i,j+1,k-1)) {
9007 Real tmp = Real(0.);
9008 if (ccdom.contains(i-1,j ,k-1)) {
9009 tmp += - sx(i-1,j ,k-1) * facx
9010 + sy(i-1,j ,k-1) * facy * Real(2.0)
9011 + sz(i-1,j ,k-1) * facz * Real(2.0);
9012 }
9013 if (ccdom.contains(i,j ,k-1)) {
9014 tmp += - sx(i,j ,k-1) * facx
9015 + sy(i,j ,k-1) * facy * Real(2.0)
9016 + sz(i,j ,k-1) * facz * Real(2.0);
9017 }
9018 m0 -= tmp;
9019 if (gid(i,j+1,k-1) < gidmax) {
9020 if (offset != 0) {
9021 cols[ps] = gid(i,j+1,k-1);
9022 mat[ps] = tmp;
9023 }
9024 ++nelems;
9025 }
9026 }
9027 if (offset != 0) { return; }
9028 }
9029
9030 if (offset == 9 || offset == 0) {
9031 if (nddom.contains(i+1,j+1,k-1)) {
9032 Real tmp = sx(i ,j ,k-1) * facx
9033 + sy(i ,j ,k-1) * facy
9034 + sz(i ,j ,k-1) * facz;
9035 m0 -= tmp;
9036 if (gid(i+1,j+1,k-1) < gidmax) {
9037 if (offset != 0) {
9038 cols[ps] = gid(i+1,j+1,k-1);
9039 mat[ps] = tmp;
9040 }
9041 ++nelems;
9042 }
9043 }
9044 if (offset != 0) { return; }
9045 }
9046
9047 if (offset == 10 || offset == 0) {
9048 if (nddom.contains(i-1,j-1,k)) {
9049 Real tmp = Real(0.);
9050 if (ccdom.contains(i-1,j-1,k-1)) {
9051 tmp += sx(i-1,j-1,k-1) * facx * Real(2.0)
9052 + sy(i-1,j-1,k-1) * facy * Real(2.0)
9053 - sz(i-1,j-1,k-1) * facz;
9054 }
9055 if (ccdom.contains(i-1,j-1,k)) {
9056 tmp += sx(i-1,j-1,k) * facx * Real(2.0)
9057 + sy(i-1,j-1,k) * facy * Real(2.0)
9058 - sz(i-1,j-1,k) * facz;
9059 }
9060 m0 -= tmp;
9061 if (gid(i-1,j-1,k) < gidmax) {
9062 if (offset != 0) {
9063 cols[ps] = gid(i-1,j-1,k);
9064 mat[ps] = tmp;
9065 }
9066 ++nelems;
9067 }
9068 }
9069 if (offset != 0) { return; }
9070 }
9071
9072 if (offset == 11 || offset == 0) {
9073 if (nddom.contains(i,j-1,k)) {
9074 Real tmp = Real(0.);
9075 if (ccdom.contains(i-1,j-1,k-1)) {
9076 tmp += - sx(i-1,j-1,k-1) * facx * Real(2.0)
9077 + sy(i-1,j-1,k-1) * facy * Real(4.0)
9078 - sz(i-1,j-1,k-1) * facz * Real(2.0);
9079 }
9080 if (ccdom.contains(i,j-1,k-1)) {
9081 tmp += - sx(i,j-1,k-1) * facx * Real(2.0)
9082 + sy(i,j-1,k-1) * facy * Real(4.0)
9083 - sz(i,j-1,k-1) * facz * Real(2.0);
9084 }
9085 if (ccdom.contains(i-1,j-1,k)) {
9086 tmp += - sx(i-1,j-1,k) * facx * Real(2.0)
9087 + sy(i-1,j-1,k) * facy * Real(4.0)
9088 - sz(i-1,j-1,k) * facz * Real(2.0);
9089 }
9090 if (ccdom.contains(i,j-1,k)) {
9091 tmp += - sx(i,j-1,k) * facx * Real(2.0)
9092 + sy(i,j-1,k) * facy * Real(4.0)
9093 - sz(i,j-1,k) * facz * Real(2.0);
9094 }
9095 m0 -= tmp;
9096 if (gid(i,j-1,k) < gidmax) {
9097 if (offset != 0) {
9098 cols[ps] = gid(i,j-1,k);
9099 mat[ps] = tmp;
9100 }
9101 ++nelems;
9102 }
9103 }
9104 if (offset != 0) { return; }
9105 }
9106
9107 if (offset == 12 || offset == 0) {
9108 if (nddom.contains(i+1,j-1,k)) {
9109 Real tmp = Real(0.);
9110 if (ccdom.contains(i ,j-1,k-1)) {
9111 tmp += sx(i ,j-1,k-1) * facx * Real(2.0)
9112 + sy(i ,j-1,k-1) * facy * Real(2.0)
9113 - sz(i ,j-1,k-1) * facz;
9114 }
9115 if (ccdom.contains(i ,j-1,k)) {
9116 tmp += sx(i ,j-1,k) * facx * Real(2.0)
9117 + sy(i ,j-1,k) * facy * Real(2.0)
9118 - sz(i ,j-1,k) * facz;
9119 }
9120 m0 -= tmp;
9121 if (gid(i+1,j-1,k) < gidmax) {
9122 if (offset != 0) {
9123 cols[ps] = gid(i+1,j-1,k);
9124 mat[ps] = tmp;
9125 }
9126 ++nelems;
9127 }
9128 }
9129 if (offset != 0) { return; }
9130 }
9131
9132 if (offset == 13 || offset == 0) {
9133 if (nddom.contains(i-1,j,k)) {
9134 Real tmp = Real(0.);
9135 if (ccdom.contains(i-1,j-1,k-1)) {
9136 tmp += sx(i-1,j-1,k-1) * facx * Real(4.0)
9137 - sy(i-1,j-1,k-1) * facy * Real(2.0)
9138 - sz(i-1,j-1,k-1) * facz * Real(2.0);
9139 }
9140 if (ccdom.contains(i-1,j,k-1)) {
9141 tmp += sx(i-1,j,k-1) * facx * Real(4.0)
9142 - sy(i-1,j,k-1) * facy * Real(2.0)
9143 - sz(i-1,j,k-1) * facz * Real(2.0);
9144 }
9145 if (ccdom.contains(i-1,j-1,k)) {
9146 tmp += sx(i-1,j-1,k) * facx * Real(4.0)
9147 - sy(i-1,j-1,k) * facy * Real(2.0)
9148 - sz(i-1,j-1,k) * facz * Real(2.0);
9149 }
9150 if (ccdom.contains(i-1,j,k)) {
9151 tmp += sx(i-1,j,k) * facx * Real(4.0)
9152 - sy(i-1,j,k) * facy * Real(2.0)
9153 - sz(i-1,j,k) * facz * Real(2.0);
9154 }
9155 m0 -= tmp;
9156 if (gid(i-1,j,k) < gidmax) {
9157 if (offset != 0) {
9158 cols[ps] = gid(i-1,j,k);
9159 mat[ps] = tmp;
9160 }
9161 ++nelems;
9162 }
9163 }
9164 if (offset != 0) { return; }
9165 }
9166
9167 if (offset == 14 || offset == 0) {
9168 if (nddom.contains(i+1,j,k)) {
9169 Real tmp = Real(0.);
9170 if (ccdom.contains(i ,j-1,k-1)) {
9171 tmp += sx(i ,j-1,k-1) * facx * Real(4.0)
9172 - sy(i ,j-1,k-1) * facy * Real(2.0)
9173 - sz(i ,j-1,k-1) * facz * Real(2.0);
9174 }
9175 if (ccdom.contains(i ,j,k-1)) {
9176 tmp += sx(i ,j,k-1) * facx * Real(4.0)
9177 - sy(i ,j,k-1) * facy * Real(2.0)
9178 - sz(i ,j,k-1) * facz * Real(2.0);
9179 }
9180 if (ccdom.contains(i ,j-1,k)) {
9181 tmp += sx(i ,j-1,k) * facx * Real(4.0)
9182 - sy(i ,j-1,k) * facy * Real(2.0)
9183 - sz(i ,j-1,k) * facz * Real(2.0);
9184 }
9185 if (ccdom.contains(i ,j,k)) {
9186 tmp += sx(i ,j,k) * facx * Real(4.0)
9187 - sy(i ,j,k) * facy * Real(2.0)
9188 - sz(i ,j,k) * facz * Real(2.0);
9189 }
9190 m0 -= tmp;
9191 if (gid(i+1,j,k) < gidmax) {
9192 if (offset != 0) {
9193 cols[ps] = gid(i+1,j,k);
9194 mat[ps] = tmp;
9195 }
9196 ++nelems;
9197 }
9198 }
9199 if (offset != 0) { return; }
9200 }
9201
9202 if (offset == 15 || offset == 0) {
9203 if (nddom.contains(i-1,j+1,k)) {
9204 Real tmp = Real(0.);
9205 if (ccdom.contains(i-1,j ,k-1)) {
9206 tmp += sx(i-1,j ,k-1) * facx * Real(2.0)
9207 + sy(i-1,j ,k-1) * facy * Real(2.0)
9208 - sz(i-1,j ,k-1) * facz;
9209 }
9210 if (ccdom.contains(i-1,j ,k)) {
9211 tmp += sx(i-1,j ,k) * facx * Real(2.0)
9212 + sy(i-1,j ,k) * facy * Real(2.0)
9213 - sz(i-1,j ,k) * facz;
9214 }
9215 m0 -= tmp;
9216 if (gid(i-1,j+1,k) < gidmax) {
9217 if (offset != 0) {
9218 cols[ps] = gid(i-1,j+1,k);
9219 mat[ps] = tmp;
9220 }
9221 ++nelems;
9222 }
9223 }
9224 if (offset != 0) { return; }
9225 }
9226
9227 if (offset == 16 || offset == 0) {
9228 if (nddom.contains(i,j+1,k)) {
9229 Real tmp = Real(0.);
9230 if (ccdom.contains(i-1,j ,k-1)) {
9231 tmp += - sx(i-1,j ,k-1) * facx * Real(2.0)
9232 + sy(i-1,j ,k-1) * facy * Real(4.0)
9233 - sz(i-1,j ,k-1) * facz * Real(2.0);
9234 }
9235 if (ccdom.contains(i,j ,k-1)) {
9236 tmp += - sx(i,j ,k-1) * facx * Real(2.0)
9237 + sy(i,j ,k-1) * facy * Real(4.0)
9238 - sz(i,j ,k-1) * facz * Real(2.0);
9239 }
9240 if (ccdom.contains(i-1,j ,k)) {
9241 tmp += - sx(i-1,j ,k) * facx * Real(2.0)
9242 + sy(i-1,j ,k) * facy * Real(4.0)
9243 - sz(i-1,j ,k) * facz * Real(2.0);
9244 }
9245 if (ccdom.contains(i,j ,k)) {
9246 tmp += - sx(i,j ,k) * facx * Real(2.0)
9247 + sy(i,j ,k) * facy * Real(4.0)
9248 - sz(i,j ,k) * facz * Real(2.0);
9249 }
9250 m0 -= tmp;
9251 if (gid(i,j+1,k) < gidmax) {
9252 if (offset != 0) {
9253 cols[ps] = gid(i,j+1,k);
9254 mat[ps] = tmp;
9255 }
9256 ++nelems;
9257 }
9258 }
9259 if (offset != 0) { return; }
9260 }
9261
9262 if (offset == 17 || offset == 0) {
9263 if (nddom.contains(i+1,j+1,k)) {
9264 Real tmp = Real(0.);
9265 if (ccdom.contains(i ,j ,k-1)) {
9266 tmp += sx(i ,j ,k-1) * facx * Real(2.0)
9267 + sy(i ,j ,k-1) * facy * Real(2.0)
9268 - sz(i ,j ,k-1) * facz;
9269 }
9270 if (ccdom.contains(i ,j ,k)) {
9271 tmp += sx(i ,j ,k) * facx * Real(2.0)
9272 + sy(i ,j ,k) * facy * Real(2.0)
9273 - sz(i ,j ,k) * facz;
9274 }
9275 m0 -= tmp;
9276 if (gid(i+1,j+1,k) < gidmax) {
9277 if (offset != 0) {
9278 cols[ps] = gid(i+1,j+1,k);
9279 mat[ps] = tmp;
9280 }
9281 ++nelems;
9282 }
9283 }
9284 if (offset != 0) { return; }
9285 }
9286
9287 if (offset == 18 || offset == 0) {
9288 if (nddom.contains(i-1,j-1,k+1)) {
9289 Real tmp = sx(i-1,j-1,k ) * facx
9290 + sy(i-1,j-1,k ) * facy
9291 + sz(i-1,j-1,k ) * facz;
9292 m0 -= tmp;
9293 if (gid(i-1,j-1,k+1) < gidmax) {
9294 if (offset != 0) {
9295 cols[ps] = gid(i-1,j-1,k+1);
9296 mat[ps] = tmp;
9297 }
9298 ++nelems;
9299 }
9300 }
9301 if (offset != 0) { return; }
9302 }
9303
9304 if (offset == 19 || offset == 0) {
9305 if (nddom.contains(i,j-1,k+1)) {
9306 Real tmp = Real(0.);
9307 if (ccdom.contains(i-1,j-1,k )) {
9308 tmp += - sx(i-1,j-1,k ) * facx
9309 + sy(i-1,j-1,k ) * facy * Real(2.0)
9310 + sz(i-1,j-1,k ) * facz * Real(2.0);
9311 }
9312 if (ccdom.contains(i,j-1,k )) {
9313 tmp += - sx(i,j-1,k ) * facx
9314 + sy(i,j-1,k ) * facy * Real(2.0)
9315 + sz(i,j-1,k ) * facz * Real(2.0);
9316 }
9317 m0 -= tmp;
9318 if (gid(i,j-1,k+1) < gidmax) {
9319 if (offset != 0) {
9320 cols[ps] = gid(i,j-1,k+1);
9321 mat[ps] = tmp;
9322 }
9323 ++nelems;
9324 }
9325 }
9326 if (offset != 0) { return; }
9327 }
9328
9329 if (offset == 20 || offset == 0) {
9330 if (nddom.contains(i+1,j-1,k+1)) {
9331 Real tmp = sx(i ,j-1,k ) * facx
9332 + sy(i ,j-1,k ) * facy
9333 + sz(i ,j-1,k ) * facz;
9334 m0 -= tmp;
9335 if (gid(i+1,j-1,k+1) < gidmax) {
9336 if (offset != 0) {
9337 cols[ps] = gid(i+1,j-1,k+1);
9338 mat[ps] = tmp;
9339 }
9340 ++nelems;
9341 }
9342 }
9343 if (offset != 0) { return; }
9344 }
9345
9346 if (offset == 21 || offset == 0) {
9347 if (nddom.contains(i-1,j,k+1)) {
9348 Real tmp = Real(0.);
9349 if (ccdom.contains(i-1,j-1,k )) {
9350 tmp += sx(i-1,j-1,k ) * facx * Real(2.0)
9351 - sy(i-1,j-1,k ) * facy
9352 + sz(i-1,j-1,k ) * facz * Real(2.0);
9353 }
9354 if (ccdom.contains(i-1,j,k )) {
9355 tmp += sx(i-1,j,k ) * facx * Real(2.0)
9356 - sy(i-1,j,k ) * facy
9357 + sz(i-1,j,k ) * facz * Real(2.0);
9358 }
9359 m0 -= tmp;
9360 if (gid(i-1,j,k+1) < gidmax) {
9361 if (offset != 0) {
9362 cols[ps] = gid(i-1,j,k+1);
9363 mat[ps] = tmp;
9364 }
9365 ++nelems;
9366 }
9367 }
9368 if (offset != 0) { return; }
9369 }
9370
9371 if (offset == 22 || offset == 0) {
9372 if (nddom.contains(i,j,k+1)) {
9373 Real tmp = Real(0.);
9374 if (ccdom.contains(i-1,j-1,k )) {
9375 tmp += - sx(i-1,j-1,k ) * facx * Real(2.0)
9376 - sy(i-1,j-1,k ) * facy * Real(2.0)
9377 + sz(i-1,j-1,k ) * facz * Real(4.0);
9378 }
9379 if (ccdom.contains(i,j-1,k )) {
9380 tmp += - sx(i,j-1,k ) * facx * Real(2.0)
9381 - sy(i,j-1,k ) * facy * Real(2.0)
9382 + sz(i,j-1,k ) * facz * Real(4.0);
9383 }
9384 if (ccdom.contains(i-1,j,k )) {
9385 tmp += - sx(i-1,j,k ) * facx * Real(2.0)
9386 - sy(i-1,j,k ) * facy * Real(2.0)
9387 + sz(i-1,j,k ) * facz * Real(4.0);
9388 }
9389 if (ccdom.contains(i,j,k )) {
9390 tmp += - sx(i,j,k ) * facx * Real(2.0)
9391 - sy(i,j,k ) * facy * Real(2.0)
9392 + sz(i,j,k ) * facz * Real(4.0);
9393 }
9394 m0 -= tmp;
9395 if (gid(i,j,k+1) < gidmax) {
9396 if (offset != 0) {
9397 cols[ps] = gid(i,j,k+1);
9398 mat[ps] = tmp;
9399 }
9400 ++nelems;
9401 }
9402 }
9403 if (offset != 0) { return; }
9404 }
9405
9406 if (offset == 23 || offset == 0) {
9407 if (nddom.contains(i+1,j,k+1)) {
9408 Real tmp = Real(0.);
9409 if (ccdom.contains(i ,j-1,k )) {
9410 tmp += sx(i ,j-1,k ) * facx * Real(2.0)
9411 - sy(i ,j-1,k ) * facy
9412 + sz(i ,j-1,k ) * facz * Real(2.0);
9413 }
9414 if (ccdom.contains(i ,j,k )) {
9415 tmp += sx(i ,j,k ) * facx * Real(2.0)
9416 - sy(i ,j,k ) * facy
9417 + sz(i ,j,k ) * facz * Real(2.0);
9418 }
9419 m0 -= tmp;
9420 if (gid(i+1,j,k+1) < gidmax) {
9421 if (offset != 0) {
9422 cols[ps] = gid(i+1,j,k+1);
9423 mat[ps] = tmp;
9424 }
9425 ++nelems;
9426 }
9427 }
9428 if (offset != 0) { return; }
9429 }
9430
9431 if (offset == 24 || offset == 0) {
9432 if (nddom.contains(i-1,j+1,k+1)) {
9433 Real tmp = sx(i-1,j ,k ) * facx
9434 + sy(i-1,j ,k ) * facy
9435 + sz(i-1,j ,k ) * facz;
9436 m0 -= tmp;
9437 if (gid(i-1,j+1,k+1) < gidmax) {
9438 if (offset != 0) {
9439 cols[ps] = gid(i-1,j+1,k+1);
9440 mat[ps] = tmp;
9441 }
9442 ++nelems;
9443 }
9444 }
9445 if (offset != 0) { return; }
9446 }
9447
9448 if (offset == 25 || offset == 0) {
9449 if (nddom.contains(i,j+1,k+1)) {
9450 Real tmp = Real(0.);
9451 if (ccdom.contains(i-1,j ,k )) {
9452 tmp += - sx(i-1,j ,k ) * facx
9453 + sy(i-1,j ,k ) * facy * Real(2.0)
9454 + sz(i-1,j ,k ) * facz * Real(2.0);
9455 }
9456 if (ccdom.contains(i,j ,k )) {
9457 tmp += - sx(i,j ,k ) * facx
9458 + sy(i,j ,k ) * facy * Real(2.0)
9459 + sz(i,j ,k ) * facz * Real(2.0);
9460 }
9461 m0 -= tmp;
9462 if (gid(i,j+1,k+1) < gidmax) {
9463 if (offset != 0) {
9464 cols[ps] = gid(i,j+1,k+1);
9465 mat[ps] = tmp;
9466 }
9467 ++nelems;
9468 }
9469 }
9470 if (offset != 0) { return; }
9471 }
9472
9473 if (offset == 26 || offset == 0) {
9474 if (nddom.contains(i+1,j+1,k+1)) {
9475 Real tmp = sx(i ,j ,k ) * facx
9476 + sy(i ,j ,k ) * facy
9477 + sz(i ,j ,k ) * facz;
9478 m0 -= tmp;
9479 if (gid(i+1,j+1,k+1) < gidmax) {
9480 if (offset != 0) {
9481 cols[ps] = gid(i+1,j+1,k+1);
9482 mat[ps] = tmp;
9483 }
9484 ++nelems;
9485 }
9486 }
9487 if (offset != 0) { return; }
9488 }
9489
9490 // Only offset == 0 could get this far.
9491 cols[ps] = gid(i,j,k);
9492 mat[ps] = m0;
9493 ncols[lid(i,j,k)] = nelems+1;
9494 }
9495}
9496
9497template <typename HypreInt, typename AtomicInt>
9499void mlndlap_fillijmat_cs_gpu (const int ps, const int i, const int j, const int k,
9500 const int offset,
9501 Box const& ndbx, Array4<AtomicInt const> const& gid,
9502 Array4<int const> const& lid,
9503 HypreInt* ncols, HypreInt* cols,
9504 Real* mat, // NOLINT(readability-non-const-parameter)
9505 Real sigma, GpuArray<Real,AMREX_SPACEDIM> const& dxinv,
9506 Box const& ccdom) noexcept
9507{
9508 if (lid(i,j,k) >= 0)
9509 {
9510 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0] * sigma;
9511 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1] * sigma;
9512 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2] * sigma;
9513 Real fxyz = facx + facy + facz;
9514 Real fmx2y2z = -facx + Real(2.0)*facy + Real(2.0)*facz;
9515 Real f2xmy2z = Real(2.0)*facx - facy + Real(2.0)*facz;
9516 Real f2x2ymz = Real(2.0)*facx + Real(2.0)*facy - facz;
9517 Real f4xm2ym2z = Real(4.0)*facx - Real(2.0)*facy - Real(2.0)*facz;
9518 Real fm2x4ym2z = -Real(2.0)*facx + Real(4.0)*facy - Real(2.0)*facz;
9519 Real fm2xm2y4z = -Real(2.0)*facx - Real(2.0)*facy + Real(4.0)*facz;
9520
9521 const Box& nddom = amrex::surroundingNodes(ccdom);
9522
9523 constexpr auto gidmax = std::numeric_limits<AtomicInt>::max();
9524 int nelems = 0;
9525 Real m0 = Real(0.);
9526
9527 if (offset == 1 || offset == 0) {
9528 if (nddom.contains(i-1,j-1,k-1)) {
9529 Real tmp = fxyz;
9530 m0 -= tmp;
9531 if ( gid(i-1,j-1,k-1) < gidmax) {
9532 if (offset != 0) {
9533 cols[ps] = gid(i-1,j-1,k-1);
9534 mat[ps] = tmp;
9535 }
9536 ++nelems;
9537 }
9538 }
9539 if (offset != 0) { return; }
9540 }
9541
9542 if (offset == 2 || offset == 0) {
9543 if (nddom.contains(i,j-1,k-1)) {
9544 Real tmp = Real(0.);
9545 if (ccdom.contains(i-1,j-1,k-1)) {
9546 tmp += fmx2y2z;
9547 }
9548 if (ccdom.contains(i,j-1,k-1)) {
9549 tmp += fmx2y2z;
9550 }
9551 m0 -= tmp;
9552 if (gid(i,j-1,k-1) < gidmax) {
9553 if (offset != 0) {
9554 cols[ps] = gid(i,j-1,k-1);
9555 mat[ps] = tmp;
9556 }
9557 ++nelems;
9558 }
9559 }
9560 if (offset != 0) { return; }
9561 }
9562
9563 if (offset == 3 || offset == 0) {
9564 if (nddom.contains(i+1,j-1,k-1)) {
9565 Real tmp = fxyz;
9566 m0 -= tmp;
9567 if (gid(i+1,j-1,k-1) < gidmax) {
9568 if (offset != 0) {
9569 cols[ps] = gid(i+1,j-1,k-1);
9570 mat[ps] = tmp;
9571 }
9572 ++nelems;
9573 }
9574 }
9575 if (offset != 0) { return; }
9576 }
9577
9578 if (offset == 4 || offset == 0) {
9579 if (nddom.contains(i-1,j,k-1)) {
9580 Real tmp = Real(0.);
9581 if (ccdom.contains(i-1,j-1,k-1)) {
9582 tmp += f2xmy2z;
9583 }
9584 if (ccdom.contains(i-1,j,k-1)) {
9585 tmp += f2xmy2z;
9586 }
9587 m0 -= tmp;
9588 if (gid(i-1,j,k-1) < gidmax) {
9589 if (offset != 0) {
9590 cols[ps] = gid(i-1,j,k-1);
9591 mat[ps] = tmp;
9592 }
9593 ++nelems;
9594 }
9595 }
9596 if (offset != 0) { return; }
9597 }
9598
9599 if (offset == 5 || offset == 0) {
9600 if (nddom.contains(i,j,k-1)) {
9601 Real tmp = Real(0.);
9602 if (ccdom.contains(i-1,j-1,k-1)) {
9603 tmp += fm2xm2y4z;
9604 }
9605 if (ccdom.contains(i,j-1,k-1)) {
9606 tmp += fm2xm2y4z;
9607 }
9608 if (ccdom.contains(i-1,j,k-1)) {
9609 tmp += fm2xm2y4z;
9610 }
9611 if (ccdom.contains(i,j,k-1)) {
9612 tmp += fm2xm2y4z;
9613 }
9614 m0 -= tmp;
9615 if (gid(i,j,k-1) < gidmax) {
9616 if (offset != 0) {
9617 cols[ps] = gid(i,j,k-1);
9618 mat[ps] = tmp;
9619 }
9620 ++nelems;
9621 }
9622 }
9623 if (offset != 0) { return; }
9624 }
9625
9626 if (offset == 6 || offset == 0) {
9627 if (nddom.contains(i+1,j,k-1)) {
9628 Real tmp = Real(0.);
9629 if (ccdom.contains(i ,j-1,k-1)) {
9630 tmp += f2xmy2z;
9631 }
9632 if (ccdom.contains(i ,j,k-1)) {
9633 tmp += f2xmy2z;
9634 }
9635 m0 -= tmp;
9636 if (gid(i+1,j,k-1) < gidmax) {
9637 if (offset != 0) {
9638 cols[ps] = gid(i+1,j,k-1);
9639 mat[ps] = tmp;
9640 }
9641 ++nelems;
9642 }
9643 }
9644 if (offset != 0) { return; }
9645 }
9646
9647 if (offset == 7 || offset == 0) {
9648 if (nddom.contains(i-1,j+1,k-1)) {
9649 Real tmp = fxyz;
9650 m0 -= tmp;
9651 if (gid(i-1,j+1,k-1) < gidmax) {
9652 if (offset != 0) {
9653 cols[ps] = gid(i-1,j+1,k-1);
9654 mat[ps] = tmp;
9655 }
9656 ++nelems;
9657 }
9658 }
9659 if (offset != 0) { return; }
9660 }
9661
9662 if (offset == 8 || offset == 0) {
9663 if (nddom.contains(i,j+1,k-1)) {
9664 Real tmp = Real(0.);
9665 if (ccdom.contains(i-1,j ,k-1)) {
9666 tmp += fmx2y2z;
9667 }
9668 if (ccdom.contains(i,j ,k-1)) {
9669 tmp += fmx2y2z;
9670 }
9671 m0 -= tmp;
9672 if (gid(i,j+1,k-1) < gidmax) {
9673 if (offset != 0) {
9674 cols[ps] = gid(i,j+1,k-1);
9675 mat[ps] = tmp;
9676 }
9677 ++nelems;
9678 }
9679 }
9680 if (offset != 0) { return; }
9681 }
9682
9683 if (offset == 9 || offset == 0) {
9684 if (nddom.contains(i+1,j+1,k-1)) {
9685 Real tmp = fxyz;
9686 m0 -= tmp;
9687 if (gid(i+1,j+1,k-1) < gidmax) {
9688 if (offset != 0) {
9689 cols[ps] = gid(i+1,j+1,k-1);
9690 mat[ps] = tmp;
9691 }
9692 ++nelems;
9693 }
9694 }
9695 if (offset != 0) { return; }
9696 }
9697
9698 if (offset == 10 || offset == 0) {
9699 if (nddom.contains(i-1,j-1,k)) {
9700 Real tmp = Real(0.);
9701 if (ccdom.contains(i-1,j-1,k-1)) {
9702 tmp += f2x2ymz;
9703 }
9704 if (ccdom.contains(i-1,j-1,k)) {
9705 tmp += f2x2ymz;
9706 }
9707 m0 -= tmp;
9708 if (gid(i-1,j-1,k) < gidmax) {
9709 if (offset != 0) {
9710 cols[ps] = gid(i-1,j-1,k);
9711 mat[ps] = tmp;
9712 }
9713 ++nelems;
9714 }
9715 }
9716 if (offset != 0) { return; }
9717 }
9718
9719 if (offset == 11 || offset == 0) {
9720 if (nddom.contains(i,j-1,k)) {
9721 Real tmp = Real(0.);
9722 if (ccdom.contains(i-1,j-1,k-1)) {
9723 tmp += fm2x4ym2z;
9724 }
9725 if (ccdom.contains(i,j-1,k-1)) {
9726 tmp += fm2x4ym2z;
9727 }
9728 if (ccdom.contains(i-1,j-1,k)) {
9729 tmp += fm2x4ym2z;
9730 }
9731 if (ccdom.contains(i,j-1,k)) {
9732 tmp += fm2x4ym2z;
9733 }
9734 m0 -= tmp;
9735 if (gid(i,j-1,k) < gidmax) {
9736 if (offset != 0) {
9737 cols[ps] = gid(i,j-1,k);
9738 mat[ps] = tmp;
9739 }
9740 ++nelems;
9741 }
9742 }
9743 if (offset != 0) { return; }
9744 }
9745
9746 if (offset == 12 || offset == 0) {
9747 if (nddom.contains(i+1,j-1,k)) {
9748 Real tmp = Real(0.);
9749 if (ccdom.contains(i ,j-1,k-1)) {
9750 tmp += f2x2ymz;
9751 }
9752 if (ccdom.contains(i ,j-1,k)) {
9753 tmp += f2x2ymz;
9754 }
9755 m0 -= tmp;
9756 if (gid(i+1,j-1,k) < gidmax) {
9757 if (offset != 0) {
9758 cols[ps] = gid(i+1,j-1,k);
9759 mat[ps] = tmp;
9760 }
9761 ++nelems;
9762 }
9763 }
9764 if (offset != 0) { return; }
9765 }
9766
9767 if (offset == 13 || offset == 0) {
9768 if (nddom.contains(i-1,j,k)) {
9769 Real tmp = Real(0.);
9770 if (ccdom.contains(i-1,j-1,k-1)) {
9771 tmp += f4xm2ym2z;
9772 }
9773 if (ccdom.contains(i-1,j,k-1)) {
9774 tmp += f4xm2ym2z;
9775 }
9776 if (ccdom.contains(i-1,j-1,k)) {
9777 tmp += f4xm2ym2z;
9778 }
9779 if (ccdom.contains(i-1,j,k)) {
9780 tmp += f4xm2ym2z;
9781 }
9782 m0 -= tmp;
9783 if (gid(i-1,j,k) < gidmax) {
9784 if (offset != 0) {
9785 cols[ps] = gid(i-1,j,k);
9786 mat[ps] = tmp;
9787 }
9788 ++nelems;
9789 }
9790 }
9791 if (offset != 0) { return; }
9792 }
9793
9794 if (offset == 14 || offset == 0) {
9795 if (nddom.contains(i+1,j,k)) {
9796 Real tmp = Real(0.);
9797 if (ccdom.contains(i ,j-1,k-1)) {
9798 tmp += f4xm2ym2z;
9799 }
9800 if (ccdom.contains(i ,j,k-1)) {
9801 tmp += f4xm2ym2z;
9802 }
9803 if (ccdom.contains(i ,j-1,k)) {
9804 tmp += f4xm2ym2z;
9805 }
9806 if (ccdom.contains(i ,j,k)) {
9807 tmp += f4xm2ym2z;
9808 }
9809 m0 -= tmp;
9810 if (gid(i+1,j,k) < gidmax) {
9811 if (offset != 0) {
9812 cols[ps] = gid(i+1,j,k);
9813 mat[ps] = tmp;
9814 }
9815 ++nelems;
9816 }
9817 }
9818 if (offset != 0) { return; }
9819 }
9820
9821 if (offset == 15 || offset == 0) {
9822 if (nddom.contains(i-1,j+1,k)) {
9823 Real tmp = Real(0.);
9824 if (ccdom.contains(i-1,j ,k-1)) {
9825 tmp += f2x2ymz;
9826 }
9827 if (ccdom.contains(i-1,j ,k)) {
9828 tmp += f2x2ymz;
9829 }
9830 m0 -= tmp;
9831 if (gid(i-1,j+1,k) < gidmax) {
9832 if (offset != 0) {
9833 cols[ps] = gid(i-1,j+1,k);
9834 mat[ps] = tmp;
9835 }
9836 ++nelems;
9837 }
9838 }
9839 if (offset != 0) { return; }
9840 }
9841
9842 if (offset == 16 || offset == 0) {
9843 if (nddom.contains(i,j+1,k)) {
9844 Real tmp = Real(0.);
9845 if (ccdom.contains(i-1,j ,k-1)) {
9846 tmp += fm2x4ym2z;
9847 }
9848 if (ccdom.contains(i,j ,k-1)) {
9849 tmp += fm2x4ym2z;
9850 }
9851 if (ccdom.contains(i-1,j ,k)) {
9852 tmp += fm2x4ym2z;
9853 }
9854 if (ccdom.contains(i,j ,k)) {
9855 tmp += fm2x4ym2z;
9856 }
9857 m0 -= tmp;
9858 if (gid(i,j+1,k) < gidmax) {
9859 if (offset != 0) {
9860 cols[ps] = gid(i,j+1,k);
9861 mat[ps] = tmp;
9862 }
9863 ++nelems;
9864 }
9865 }
9866 if (offset != 0) { return; }
9867 }
9868
9869 if (offset == 17 || offset == 0) {
9870 if (nddom.contains(i+1,j+1,k)) {
9871 Real tmp = Real(0.);
9872 if (ccdom.contains(i ,j ,k-1)) {
9873 tmp += f2x2ymz;
9874 }
9875 if (ccdom.contains(i ,j ,k)) {
9876 tmp += f2x2ymz;
9877 }
9878 m0 -= tmp;
9879 if (gid(i+1,j+1,k) < gidmax) {
9880 if (offset != 0) {
9881 cols[ps] = gid(i+1,j+1,k);
9882 mat[ps] = tmp;
9883 }
9884 ++nelems;
9885 }
9886 }
9887 if (offset != 0) { return; }
9888 }
9889
9890 if (offset == 18 || offset == 0) {
9891 if (nddom.contains(i-1,j-1,k+1)) {
9892 Real tmp = fxyz;
9893 m0 -= tmp;
9894 if (gid(i-1,j-1,k+1) < gidmax) {
9895 if (offset != 0) {
9896 cols[ps] = gid(i-1,j-1,k+1);
9897 mat[ps] = tmp;
9898 }
9899 ++nelems;
9900 }
9901 }
9902 if (offset != 0) { return; }
9903 }
9904
9905 if (offset == 19 || offset == 0) {
9906 if (nddom.contains(i,j-1,k+1)) {
9907 Real tmp = Real(0.);
9908 if (ccdom.contains(i-1,j-1,k )) {
9909 tmp += fmx2y2z;
9910 }
9911 if (ccdom.contains(i,j-1,k )) {
9912 tmp += fmx2y2z;
9913 }
9914 m0 -= tmp;
9915 if (gid(i,j-1,k+1) < gidmax) {
9916 if (offset != 0) {
9917 cols[ps] = gid(i,j-1,k+1);
9918 mat[ps] = tmp;
9919 }
9920 ++nelems;
9921 }
9922 }
9923 if (offset != 0) { return; }
9924 }
9925
9926 if (offset == 20 || offset == 0) {
9927 if (nddom.contains(i+1,j-1,k+1)) {
9928 Real tmp = fxyz;
9929 m0 -= tmp;
9930 if (gid(i+1,j-1,k+1) < gidmax) {
9931 if (offset != 0) {
9932 cols[ps] = gid(i+1,j-1,k+1);
9933 mat[ps] = tmp;
9934 }
9935 ++nelems;
9936 }
9937 }
9938 if (offset != 0) { return; }
9939 }
9940
9941 if (offset == 21 || offset == 0) {
9942 if (nddom.contains(i-1,j,k+1)) {
9943 Real tmp = Real(0.);
9944 if (ccdom.contains(i-1,j-1,k )) {
9945 tmp += f2xmy2z;
9946 }
9947 if (ccdom.contains(i-1,j,k )) {
9948 tmp += f2xmy2z;
9949 }
9950 m0 -= tmp;
9951 if (gid(i-1,j,k+1) < gidmax) {
9952 if (offset != 0) {
9953 cols[ps] = gid(i-1,j,k+1);
9954 mat[ps] = tmp;
9955 }
9956 ++nelems;
9957 }
9958 }
9959 if (offset != 0) { return; }
9960 }
9961
9962 if (offset == 22 || offset == 0) {
9963 if (nddom.contains(i,j,k+1)) {
9964 Real tmp = Real(0.);
9965 if (ccdom.contains(i-1,j-1,k )) {
9966 tmp += fm2xm2y4z;
9967 }
9968 if (ccdom.contains(i,j-1,k )) {
9969 tmp += fm2xm2y4z;
9970 }
9971 if (ccdom.contains(i-1,j,k )) {
9972 tmp += fm2xm2y4z;
9973 }
9974 if (ccdom.contains(i,j,k )) {
9975 tmp += fm2xm2y4z;
9976 }
9977 m0 -= tmp;
9978 if (gid(i,j,k+1) < gidmax) {
9979 if (offset != 0) {
9980 cols[ps] = gid(i,j,k+1);
9981 mat[ps] = tmp;
9982 }
9983 ++nelems;
9984 }
9985 }
9986 if (offset != 0) { return; }
9987 }
9988
9989 if (offset == 23 || offset == 0) {
9990 if (nddom.contains(i+1,j,k+1)) {
9991 Real tmp = Real(0.);
9992 if (ccdom.contains(i ,j-1,k )) {
9993 tmp += f2xmy2z;
9994 }
9995 if (ccdom.contains(i ,j,k )) {
9996 tmp += f2xmy2z;
9997 }
9998 m0 -= tmp;
9999 if (gid(i+1,j,k+1) < gidmax) {
10000 if (offset != 0) {
10001 cols[ps] = gid(i+1,j,k+1);
10002 mat[ps] = tmp;
10003 }
10004 ++nelems;
10005 }
10006 }
10007 if (offset != 0) { return; }
10008 }
10009
10010 if (offset == 24 || offset == 0) {
10011 if (nddom.contains(i-1,j+1,k+1)) {
10012 Real tmp = fxyz;
10013 m0 -= tmp;
10014 if (gid(i-1,j+1,k+1) < gidmax) {
10015 if (offset != 0) {
10016 cols[ps] = gid(i-1,j+1,k+1);
10017 mat[ps] = tmp;
10018 }
10019 ++nelems;
10020 }
10021 }
10022 if (offset != 0) { return; }
10023 }
10024
10025 if (offset == 25 || offset == 0) {
10026 if (nddom.contains(i,j+1,k+1)) {
10027 Real tmp = Real(0.);
10028 if (ccdom.contains(i-1,j ,k )) {
10029 tmp += fmx2y2z;
10030 }
10031 if (ccdom.contains(i,j ,k )) {
10032 tmp += fmx2y2z;
10033 }
10034 m0 -= tmp;
10035 if (gid(i,j+1,k+1) < gidmax) {
10036 if (offset != 0) {
10037 cols[ps] = gid(i,j+1,k+1);
10038 mat[ps] = tmp;
10039 }
10040 ++nelems;
10041 }
10042 }
10043 if (offset != 0) { return; }
10044 }
10045
10046 if (offset == 26 || offset == 0) {
10047 if (nddom.contains(i+1,j+1,k+1)) {
10048 Real tmp = fxyz;
10049 m0 -= tmp;
10050 if (gid(i+1,j+1,k+1) < gidmax) {
10051 if (offset != 0) {
10052 cols[ps] = gid(i+1,j+1,k+1);
10053 mat[ps] = tmp;
10054 }
10055 ++nelems;
10056 }
10057 }
10058 if (offset != 0) { return; }
10059 }
10060
10061 // Only offset == 0 could get this far.
10062 cols[ps] = gid(i,j,k);
10063 mat[ps] = m0;
10064 ncols[lid(i,j,k)] = nelems+1;
10065 }
10066}
10067
10068#endif
10069
10070#endif
10071
10073int mlndlap_color (int i, int j, int k)
10074{
10075 return (i%2) + (j%2)*2 + (k%2)*4;
10076}
10077
10079void mlndlap_gscolor_ha (int i, int j, int k, Array4<Real> const& sol,
10080 Array4<Real const> const& rhs, Array4<Real const> const& sx,
10081 Array4<Real const> const& sy, Array4<Real const> const& sz,
10082 Array4<int const> const& msk,
10083 GpuArray<Real,AMREX_SPACEDIM> const& dxinv, int color) noexcept
10084{
10085 if (mlndlap_color(i,j,k) == color) {
10086 if (msk(i,j,k)) {
10087 sol(i,j,k) = Real(0.0);
10088 } else {
10089 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
10090 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
10091 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
10092
10093 Real s0 = Real(-4.0)*(facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1)+sx(i-1,j,k-1)+sx(i,j,k-1)
10094 +sx(i-1,j-1,k )+sx(i,j-1,k )+sx(i-1,j,k )+sx(i,j,k ))
10095 +facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1)+sy(i-1,j,k-1)+sy(i,j,k-1)
10096 +sy(i-1,j-1,k )+sy(i,j-1,k )+sy(i-1,j,k )+sy(i,j,k ))
10097 +facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)+sz(i-1,j,k-1)+sz(i,j,k-1)
10098 +sz(i-1,j-1,k )+sz(i,j-1,k )+sz(i-1,j,k )+sz(i,j,k )));
10099 Real Ax = sol(i,j,k)*s0
10100 + sol(i-1,j-1,k-1)*(facx*sx(i-1,j-1,k-1)
10101 +facy*sy(i-1,j-1,k-1)
10102 +facz*sz(i-1,j-1,k-1))
10103 + sol(i+1,j-1,k-1)*(facx*sx(i ,j-1,k-1)
10104 +facy*sy(i ,j-1,k-1)
10105 +facz*sz(i ,j-1,k-1))
10106 + sol(i-1,j+1,k-1)*(facx*sx(i-1,j ,k-1)
10107 +facy*sy(i-1,j ,k-1)
10108 +facz*sz(i-1,j ,k-1))
10109 + sol(i+1,j+1,k-1)*(facx*sx(i ,j ,k-1)
10110 +facy*sy(i ,j ,k-1)
10111 +facz*sz(i ,j ,k-1))
10112 + sol(i-1,j-1,k+1)*(facx*sx(i-1,j-1,k )
10113 +facy*sy(i-1,j-1,k )
10114 +facz*sz(i-1,j-1,k ))
10115 + sol(i+1,j-1,k+1)*(facx*sx(i ,j-1,k )
10116 +facy*sy(i ,j-1,k )
10117 +facz*sz(i ,j-1,k ))
10118 + sol(i-1,j+1,k+1)*(facx*sx(i-1,j ,k )
10119 +facy*sy(i-1,j ,k )
10120 +facz*sz(i-1,j ,k ))
10121 + sol(i+1,j+1,k+1)*(facx*sx(i ,j ,k )
10122 +facy*sy(i ,j ,k )
10123 +facz*sz(i ,j ,k ))
10124 +sol(i ,j-1,k-1)*( -facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1))
10125 +Real(2.0)*facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1))
10126 +Real(2.0)*facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)))
10127 +sol(i ,j+1,k-1)*( -facx*(sx(i-1,j ,k-1)+sx(i,j ,k-1))
10128 +Real(2.0)*facy*(sy(i-1,j ,k-1)+sy(i,j ,k-1))
10129 +Real(2.0)*facz*(sz(i-1,j ,k-1)+sz(i,j ,k-1)))
10130 +sol(i ,j-1,k+1)*( -facx*(sx(i-1,j-1,k )+sx(i,j-1,k ))
10131 +Real(2.0)*facy*(sy(i-1,j-1,k )+sy(i,j-1,k ))
10132 +Real(2.0)*facz*(sz(i-1,j-1,k )+sz(i,j-1,k )))
10133 +sol(i ,j+1,k+1)*( -facx*(sx(i-1,j ,k )+sx(i,j ,k ))
10134 +Real(2.0)*facy*(sy(i-1,j ,k )+sy(i,j ,k ))
10135 +Real(2.0)*facz*(sz(i-1,j ,k )+sz(i,j ,k )))
10136 +sol(i-1,j ,k-1)*( Real(2.0)*facx*(sx(i-1,j-1,k-1)+sx(i-1,j,k-1))
10137 -facy*(sy(i-1,j-1,k-1)+sy(i-1,j,k-1))
10138 +Real(2.0)*facz*(sz(i-1,j-1,k-1)+sz(i-1,j,k-1)))
10139 +sol(i+1,j ,k-1)*( Real(2.0)*facx*(sx(i ,j-1,k-1)+sx(i ,j,k-1))
10140 -facy*(sy(i ,j-1,k-1)+sy(i ,j,k-1))
10141 +Real(2.0)*facz*(sz(i ,j-1,k-1)+sz(i ,j,k-1)))
10142 +sol(i-1,j ,k+1)*( Real(2.0)*facx*(sx(i-1,j-1,k )+sx(i-1,j,k ))
10143 -facy*(sy(i-1,j-1,k )+sy(i-1,j,k ))
10144 +Real(2.0)*facz*(sz(i-1,j-1,k )+sz(i-1,j,k )))
10145 +sol(i+1,j ,k+1)*( Real(2.0)*facx*(sx(i ,j-1,k )+sx(i ,j,k ))
10146 -facy*(sy(i ,j-1,k )+sy(i ,j,k ))
10147 +Real(2.0)*facz*(sz(i ,j-1,k )+sz(i ,j,k )))
10148 +sol(i-1,j-1,k )*( Real(2.0)*facx*(sx(i-1,j-1,k-1)+sx(i-1,j-1,k))
10149 +Real(2.0)*facy*(sy(i-1,j-1,k-1)+sy(i-1,j-1,k))
10150 -facz*(sz(i-1,j-1,k-1)+sz(i-1,j-1,k)))
10151 +sol(i+1,j-1,k )*( Real(2.0)*facx*(sx(i ,j-1,k-1)+sx(i ,j-1,k))
10152 +Real(2.0)*facy*(sy(i ,j-1,k-1)+sy(i ,j-1,k))
10153 -facz*(sz(i ,j-1,k-1)+sz(i ,j-1,k)))
10154 +sol(i-1,j+1,k )*( Real(2.0)*facx*(sx(i-1,j ,k-1)+sx(i-1,j ,k))
10155 +Real(2.0)*facy*(sy(i-1,j ,k-1)+sy(i-1,j ,k))
10156 -facz*(sz(i-1,j ,k-1)+sz(i-1,j ,k)))
10157 +sol(i+1,j+1,k )*( Real(2.0)*facx*(sx(i ,j ,k-1)+sx(i ,j ,k))
10158 +Real(2.0)*facy*(sy(i ,j ,k-1)+sy(i ,j ,k))
10159 -facz*(sz(i ,j ,k-1)+sz(i ,j ,k)))
10160 + Real(2.0)*sol(i-1,j,k)*(Real(2.0)*facx*(sx(i-1,j-1,k-1)+sx(i-1,j,k-1)+sx(i-1,j-1,k)+sx(i-1,j,k))
10161 -facy*(sy(i-1,j-1,k-1)+sy(i-1,j,k-1)+sy(i-1,j-1,k)+sy(i-1,j,k))
10162 -facz*(sz(i-1,j-1,k-1)+sz(i-1,j,k-1)+sz(i-1,j-1,k)+sz(i-1,j,k)))
10163 + Real(2.0)*sol(i+1,j,k)*(Real(2.0)*facx*(sx(i ,j-1,k-1)+sx(i ,j,k-1)+sx(i ,j-1,k)+sx(i ,j,k))
10164 -facy*(sy(i ,j-1,k-1)+sy(i ,j,k-1)+sy(i ,j-1,k)+sy(i ,j,k))
10165 -facz*(sz(i ,j-1,k-1)+sz(i ,j,k-1)+sz(i ,j-1,k)+sz(i ,j,k)))
10166 + Real(2.0)*sol(i,j-1,k)*( -facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1)+sx(i-1,j-1,k)+sx(i,j-1,k))
10167 +Real(2.0)*facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1)+sy(i-1,j-1,k)+sy(i,j-1,k))
10168 -facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)+sz(i-1,j-1,k)+sz(i,j-1,k)))
10169 + Real(2.0)*sol(i,j+1,k)*( -facx*(sx(i-1,j ,k-1)+sx(i,j ,k-1)+sx(i-1,j ,k)+sx(i,j ,k))
10170 +Real(2.0)*facy*(sy(i-1,j ,k-1)+sy(i,j ,k-1)+sy(i-1,j ,k)+sy(i,j ,k))
10171 -facz*(sz(i-1,j ,k-1)+sz(i,j ,k-1)+sz(i-1,j ,k)+sz(i,j ,k)))
10172 + Real(2.0)*sol(i,j,k-1)*( -facx*(sx(i-1,j-1,k-1)+sx(i,j-1,k-1)+sx(i-1,j,k-1)+sx(i,j,k-1))
10173 -facy*(sy(i-1,j-1,k-1)+sy(i,j-1,k-1)+sy(i-1,j,k-1)+sy(i,j,k-1))
10174 +Real(2.0)*facz*(sz(i-1,j-1,k-1)+sz(i,j-1,k-1)+sz(i-1,j,k-1)+sz(i,j,k-1)))
10175 + Real(2.0)*sol(i,j,k+1)*( -facx*(sx(i-1,j-1,k )+sx(i,j-1,k )+sx(i-1,j,k )+sx(i,j,k ))
10176 -facy*(sy(i-1,j-1,k )+sy(i,j-1,k )+sy(i-1,j,k )+sy(i,j,k ))
10177 +Real(2.0)*facz*(sz(i-1,j-1,k )+sz(i,j-1,k )+sz(i-1,j,k )+sz(i,j,k )));
10178
10179 sol(i,j,k) += (rhs(i,j,k) - Ax) / s0;
10180 }
10181 }
10182}
10183
10185void mlndlap_gscolor_aa (int i, int j, int k, Array4<Real> const& sol,
10186 Array4<Real const> const& rhs, Array4<Real const> const& sig,
10187 Array4<int const> const& msk,
10188 GpuArray<Real,AMREX_SPACEDIM> const& dxinv, int color) noexcept
10189{
10190 if (mlndlap_color(i,j,k) == color) {
10191 if (msk(i,j,k)) {
10192 sol(i,j,k) = Real(0.0);
10193 } else {
10194 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
10195 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
10196 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
10197 Real fxyz = facx + facy + facz;
10198 Real fmx2y2z = -facx + Real(2.0)*facy + Real(2.0)*facz;
10199 Real f2xmy2z = Real(2.0)*facx - facy + Real(2.0)*facz;
10200 Real f2x2ymz = Real(2.0)*facx + Real(2.0)*facy - facz;
10201 Real f4xm2ym2z = Real(4.0)*facx - Real(2.0)*facy - Real(2.0)*facz;
10202 Real fm2x4ym2z = -Real(2.0)*facx + Real(4.0)*facy - Real(2.0)*facz;
10203 Real fm2xm2y4z = -Real(2.0)*facx - Real(2.0)*facy + Real(4.0)*facz;
10204
10205 Real s0 = Real(-4.0)*fxyz*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1)
10206 +sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k ));
10207 Real Ax = sol(i,j,k)*s0
10208 + fxyz*(sol(i-1,j-1,k-1)*sig(i-1,j-1,k-1)
10209 + sol(i+1,j-1,k-1)*sig(i ,j-1,k-1)
10210 + sol(i-1,j+1,k-1)*sig(i-1,j ,k-1)
10211 + sol(i+1,j+1,k-1)*sig(i ,j ,k-1)
10212 + sol(i-1,j-1,k+1)*sig(i-1,j-1,k )
10213 + sol(i+1,j-1,k+1)*sig(i ,j-1,k )
10214 + sol(i-1,j+1,k+1)*sig(i-1,j ,k )
10215 + sol(i+1,j+1,k+1)*sig(i ,j ,k ))
10216 + fmx2y2z*(sol(i ,j-1,k-1)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1))
10217 + sol(i ,j+1,k-1)*(sig(i-1,j ,k-1)+sig(i,j ,k-1))
10218 + sol(i ,j-1,k+1)*(sig(i-1,j-1,k )+sig(i,j-1,k ))
10219 + sol(i ,j+1,k+1)*(sig(i-1,j ,k )+sig(i,j ,k )))
10220 + f2xmy2z*(sol(i-1,j ,k-1)*(sig(i-1,j-1,k-1)+sig(i-1,j,k-1))
10221 + sol(i+1,j ,k-1)*(sig(i ,j-1,k-1)+sig(i ,j,k-1))
10222 + sol(i-1,j ,k+1)*(sig(i-1,j-1,k )+sig(i-1,j,k ))
10223 + sol(i+1,j ,k+1)*(sig(i ,j-1,k )+sig(i ,j,k )))
10224 + f2x2ymz*(sol(i-1,j-1,k )*(sig(i-1,j-1,k-1)+sig(i-1,j-1,k))
10225 + sol(i+1,j-1,k )*(sig(i ,j-1,k-1)+sig(i ,j-1,k))
10226 + sol(i-1,j+1,k )*(sig(i-1,j ,k-1)+sig(i-1,j ,k))
10227 + sol(i+1,j+1,k )*(sig(i ,j ,k-1)+sig(i ,j ,k)))
10228 + f4xm2ym2z*(sol(i-1,j,k)*(sig(i-1,j-1,k-1)+sig(i-1,j,k-1)+sig(i-1,j-1,k)+sig(i-1,j,k))
10229 + sol(i+1,j,k)*(sig(i ,j-1,k-1)+sig(i ,j,k-1)+sig(i ,j-1,k)+sig(i ,j,k)))
10230 + fm2x4ym2z*(sol(i,j-1,k)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j-1,k)+sig(i,j-1,k))
10231 + sol(i,j+1,k)*(sig(i-1,j ,k-1)+sig(i,j ,k-1)+sig(i-1,j ,k)+sig(i,j ,k)))
10232 + fm2xm2y4z*(sol(i,j,k-1)*(sig(i-1,j-1,k-1)+sig(i,j-1,k-1)+sig(i-1,j,k-1)+sig(i,j,k-1))
10233 + sol(i,j,k+1)*(sig(i-1,j-1,k )+sig(i,j-1,k )+sig(i-1,j,k )+sig(i,j,k )));
10234
10235 sol(i,j,k) += (rhs(i,j,k) - Ax) / s0;
10236 }
10237 }
10238}
10239
10241void mlndlap_gscolor_c (int i, int j, int k, Array4<Real> const& sol,
10242 Array4<Real const> const& rhs, Real sig,
10243 Array4<int const> const& msk,
10244 GpuArray<Real,AMREX_SPACEDIM> const& dxinv, int color) noexcept
10245{
10246 if (mlndlap_color(i,j,k) == color) {
10247 if (msk(i,j,k)) {
10248 sol(i,j,k) = Real(0.0);
10249 } else {
10250 Real facx = Real(1.0/36.0)*dxinv[0]*dxinv[0];
10251 Real facy = Real(1.0/36.0)*dxinv[1]*dxinv[1];
10252 Real facz = Real(1.0/36.0)*dxinv[2]*dxinv[2];
10253 Real fxyz = facx + facy + facz;
10254 Real fmx2y2z = -facx + Real(2.0)*facy + Real(2.0)*facz;
10255 Real f2xmy2z = Real(2.0)*facx - facy + Real(2.0)*facz;
10256 Real f2x2ymz = Real(2.0)*facx + Real(2.0)*facy - facz;
10257 Real f4xm2ym2z = Real(4.0)*facx - Real(2.0)*facy - Real(2.0)*facz;
10258 Real fm2x4ym2z = -Real(2.0)*facx + Real(4.0)*facy - Real(2.0)*facz;
10259 Real fm2xm2y4z = -Real(2.0)*facx - Real(2.0)*facy + Real(4.0)*facz;
10260
10261 Real s0 = Real(-4.0)*fxyz*Real(8.);
10262 Real Ax = sol(i,j,k)*s0
10263 + fxyz*(sol(i-1,j-1,k-1)
10264 + sol(i+1,j-1,k-1)
10265 + sol(i-1,j+1,k-1)
10266 + sol(i+1,j+1,k-1)
10267 + sol(i-1,j-1,k+1)
10268 + sol(i+1,j-1,k+1)
10269 + sol(i-1,j+1,k+1)
10270 + sol(i+1,j+1,k+1))
10271 + fmx2y2z*(sol(i ,j-1,k-1)*Real(2.)
10272 + sol(i ,j+1,k-1)*Real(2.)
10273 + sol(i ,j-1,k+1)*Real(2.)
10274 + sol(i ,j+1,k+1)*Real(2.))
10275 + f2xmy2z*(sol(i-1,j ,k-1)*Real(2.)
10276 + sol(i+1,j ,k-1)*Real(2.)
10277 + sol(i-1,j ,k+1)*Real(2.)
10278 + sol(i+1,j ,k+1)*Real(2.))
10279 + f2x2ymz*(sol(i-1,j-1,k )*Real(2.)
10280 + sol(i+1,j-1,k )*Real(2.)
10281 + sol(i-1,j+1,k )*Real(2.)
10282 + sol(i+1,j+1,k )*Real(2.))
10283 + f4xm2ym2z*(sol(i-1,j,k)*Real(4.)
10284 + sol(i+1,j,k)*Real(4.))
10285 + fm2x4ym2z*(sol(i,j-1,k)*Real(4.)
10286 + sol(i,j+1,k)*Real(4.))
10287 + fm2xm2y4z*(sol(i,j,k-1)*Real(4.)
10288 + sol(i,j,k+1)*Real(4.));
10289
10290 sol(i,j,k) += (rhs(i,j,k) - Ax*sig) / (s0*sig);
10291 }
10292 }
10293}
10294
10296void mlndlap_gscolor_sten (int i, int j, int k, Array4<Real> const& sol,
10297 Array4<Real const> const& rhs,
10298 Array4<Real const> const& sten,
10299 Array4<int const> const& msk, int color) noexcept
10300{
10301 if (mlndlap_color(i,j,k) == color) {
10302 mlndlap_gauss_seidel_sten(i,j,k,sol,rhs,sten,msk);
10303 }
10304}
10305
10306}
10307#endif
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:119
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
int idir
Definition AMReX_HypreMLABecLap.cpp:1093
Array4< int const > offset
Definition AMReX_HypreMLABecLap.cpp:1089
Array4< Real > fine
Definition AMReX_InterpFaceRegister.cpp:90
Array4< Real const > crse
Definition AMReX_InterpFaceRegister.cpp:92
#define AMREX_LOOP_3D(bx, i, j, k, block)
Definition AMReX_Loop.nolint.H:4
HYPRE_Int Int
Definition AMReX_HypreNodeLap.H:36
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
__host__ __device__ BoxND< dim > coarsen(const BoxND< dim > &b, int ref_ratio) noexcept
Coarsen BoxND by given (positive) coarsening ratio.
Definition AMReX_Box.H:1409
Definition AMReX_Amr.cpp:49
__host__ __device__ Dim3 ubound(Array4< T > const &a) noexcept
Definition AMReX_Array4.H:319
__host__ __device__ void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:138
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlndlap_jacobi_ha(int i, int, int, Array4< Real > const &sol, Real Ax, Array4< Real const > const &rhs, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_1D_K.H:92
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_set_connection(int i, int j, int, Array4< Real > const &conn, Array4< Real const > const &intg, Array4< Real const > const &vol, Array4< EBCellFlag const > const &flag) noexcept
Definition AMReX_MLNodeLap_2D_K.H:1689
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real ha_interp_face_xz(Array4< Real const > const &crse, Array4< Real const > const &sigx, Array4< Real const > const &sigz, int i, int j, int k, int ic, int jc, int kc) noexcept
Definition AMReX_MLNodeLap_3D_K.H:1187
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_adotx_aa(int i, int j, int k, Array4< Real const > const &x, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_1D_K.H:66
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_avgdown_coeff_z(int i, int j, int k, Array4< Real > const &crse, Array4< Real const > const &fine) noexcept
Definition AMReX_MLNodeLap_3D_K.H:53
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_mknewu_c(int i, int, int, Array4< Real > const &u, Array4< Real const > const &p, Real sig, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_1D_K.H:322
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlndlap_gscolor_ha(int i, int j, int k, Array4< Real > const &sol, Array4< Real const > const &rhs, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv, int color) noexcept
Definition AMReX_MLNodeLap_1D_K.H:426
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_divu_fine_contrib(int i, int j, int, Box const &fvbx, Box const &velbx, Array4< Real > const &rhs, Array4< Real const > const &vel, Array4< Real const > const &frhs, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv, bool is_rz) noexcept
Definition AMReX_MLNodeLap_2D_K.H:867
__host__ __device__ BoxND< dim > surroundingNodes(const BoxND< dim > &b, int dir) noexcept
Return a BoxND with NODE based coordinates in direction dir that encloses BoxND b....
Definition AMReX_Box.H:1522
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real aa_interp_line_z(Array4< Real const > const &crse, Array4< Real const > const &sig, int i, int j, int k, int ic, int jc, int kc) noexcept
Definition AMReX_MLNodeLap_3D_K.H:941
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_semi_avgdown_coeff(int i, int j, int k, Array4< Real > const &crse, Array4< Real const > const &fine, int) noexcept
Definition AMReX_MLNodeLap_1D_K.H:30
void mlndlap_gauss_seidel_aa(Box const &bx, Array4< Real > const &sol, Array4< Real const > const &rhs, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_1D_K.H:193
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real ha_interp_face_yz(Array4< Real const > const &crse, Array4< Real const > const &sigy, Array4< Real const > const &sigz, int i, int j, int k, int ic, int jc, int kc) noexcept
Definition AMReX_MLNodeLap_3D_K.H:1202
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_interpadd_rap(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &) noexcept
Definition AMReX_MLNodeLap_1D_K.H:408
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_avgdown_coeff_y(int i, int j, int k, Array4< Real > const &crse, Array4< Real const > const &fine) noexcept
Definition AMReX_MLNodeLap_2D_K.H:36
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlndlap_gscolor_aa(int i, int j, int k, Array4< Real > const &sol, Array4< Real const > const &rhs, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv, int color) noexcept
Definition AMReX_MLNodeLap_1D_K.H:448
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_normalize_ha(int i, int, int, Array4< Real > const &x, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_1D_K.H:74
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_adotx_sten(int, int, int, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &) noexcept
Definition AMReX_MLNodeLap_1D_K.H:396
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_interpadd_c(int i, int, int, Array4< Real > const &fine, Array4< Real const > const &crse, Array4< int const > const &msk) noexcept
Definition AMReX_MLNodeLap_1D_K.H:233
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_set_stencil_s0(int, int, int, Array4< Real > const &) noexcept
Definition AMReX_MLNodeLap_1D_K.H:387
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_crse_resid(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< int const > const &, Box const &, GpuArray< LinOpBCType, 3 > const &, GpuArray< LinOpBCType, 3 > const &, bool) noexcept
Definition AMReX_MLNodeLap_1D_K.H:349
void mlndlap_gauss_seidel_with_line_solve_aa(Box const &, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &, GpuArray< Real, 3 > const &) noexcept
Definition AMReX_MLNodeLap_1D_K.H:225
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlndlap_gscolor_c(int i, int j, int k, Array4< Real > const &sol, Array4< Real const > const &rhs, Real sig, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv, int color) noexcept
Definition AMReX_MLNodeLap_1D_K.H:458
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_mknewu_eb(int i, int j, int, Array4< Real > const &u, Array4< Real const > const &p, Array4< Real const > const &sig, Array4< Real const > const &vfrac, Array4< Real const > const &intg, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_2D_K.H:1818
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_Ax_fine_contrib_cs(int i, int j, int, Box const &ndbx, Box const &ccbx, Array4< Real > const &f, Array4< Real const > const &res, Array4< Real const > const &rhs, Array4< Real const > const &phi, Real const sig, Array4< int const > const &msk, bool is_rz, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_2D_K.H:1157
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_res_cf_contrib_cs(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Real, Array4< int const > const &, Array4< int const > const &, Array4< int const > const &, Array4< Real const > const &, GpuArray< Real, 3 > const &, Box const &, GpuArray< LinOpBCType, 3 > const &, GpuArray< LinOpBCType, 3 > const &, bool) noexcept
Definition AMReX_MLNodeLap_1D_K.H:369
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:27
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_sum_Ax(P const &pred, S const &sig, int i, int j, Real facx, Real facy, Array4< Real const > const &phi, bool is_rz) noexcept
Definition AMReX_MLNodeLap_2D_K.H:1057
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_mknewu_eb_c(int i, int j, int, Array4< Real > const &u, Array4< Real const > const &p, Real sig, Array4< Real const > const &vfrac, Array4< Real const > const &intg, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_2D_K.H:1836
__host__ __device__ constexpr const T & min(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:21
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_mknewu(int i, int, int, Array4< Real > const &u, Array4< Real const > const &p, Array4< Real const > const &sig, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_1D_K.H:312
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_rhcc_fine_contrib(int, int, int, Box const &, Array4< Real > const &, Array4< Real const > const &, Array4< int const > const &) noexcept
Definition AMReX_MLNodeLap_1D_K.H:332
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_semi_interpadd_aa(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &, int) noexcept
Definition AMReX_MLNodeLap_1D_K.H:270
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_set_stencil(Box const &, Array4< Real > const &, Array4< Real const > const &, GpuArray< Real, 3 > const &) noexcept
Definition AMReX_MLNodeLap_1D_K.H:381
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real neumann_scale(int i, int j, Box const &nddom, GpuArray< LinOpBCType, 3 > const &bclo, GpuArray< LinOpBCType, 3 > const &bchi) noexcept
Definition AMReX_MLNodeLap_2D_K.H:930
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real aa_interp_line_y(Array4< Real const > const &crse, Array4< Real const > const &sig, int i, int j, int ic, int jc) noexcept
Definition AMReX_MLNodeLap_2D_K.H:582
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_zero_fine(int i, int, int, Array4< Real > const &phi, Array4< int const > const &msk, int fine_flag) noexcept
Definition AMReX_MLNodeLap_1D_K.H:8
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_Ax_fine_contrib_doit(S const &sig, int i, int j, Box const &ndbx, Box const &ccbx, Array4< Real > const &f, Array4< Real const > const &res, Array4< Real const > const &rhs, Array4< Real const > const &phi, Array4< int const > const &msk, bool is_rz, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_2D_K.H:1099
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_set_stencil_eb(int i, int j, int, Array4< Real > const &sten, Array4< Real const > const &sig, Array4< Real const > const &conn, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_2D_K.H:1713
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_normalize_aa(int i, int j, int k, Array4< Real > const &x, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_1D_K.H:84
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real ha_interp_face_xy(Array4< Real const > const &crse, Array4< Real const > const &sigx, Array4< Real const > const &sigy, int i, int j, int ic, int jc) noexcept
Definition AMReX_MLNodeLap_2D_K.H:694
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_interpadd_aa(int i, int, int, Array4< Real > const &fine, Array4< Real const > const &crse, Array4< Real const > const &sig, Array4< int const > const &msk) noexcept
Definition AMReX_MLNodeLap_1D_K.H:251
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_divu(int i, int, int, Array4< Real > const &rhs, Array4< Real const > const &vel, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv, Box const &, GpuArray< LinOpBCType, 3 > const &, GpuArray< LinOpBCType, 3 > const &) noexcept
Definition AMReX_MLNodeLap_1D_K.H:284
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_Ax_fine_contrib(int i, int j, int, Box const &ndbx, Box const &ccbx, Array4< Real > const &f, Array4< Real const > const &res, Array4< Real const > const &rhs, Array4< Real const > const &phi, Array4< Real const > const &sig, Array4< int const > const &msk, bool is_rz, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_2D_K.H:1143
void mlndlap_gauss_seidel_sten(Box const &, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &) noexcept
Definition AMReX_MLNodeLap_1D_K.H:401
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_rhcc_eb(int i, int j, int, Array4< Real const > const &rhcc, Array4< Real const > const &vfrac, Array4< Real const > const &intg, Array4< int const > const &msk) noexcept
Definition AMReX_MLNodeLap_2D_K.H:1854
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_adotx_ha(int i, int, int, Array4< Real const > const &x, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_1D_K.H:52
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlndlap_jacobi_c(int i, int, int, Array4< Real > const &sol, Real Ax, Array4< Real const > const &rhs, Real sig, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_1D_K.H:141
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_gscolor_sten(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &, int) noexcept
Definition AMReX_MLNodeLap_1D_K.H:479
__host__ __device__ constexpr const T & max(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:35
void mlndlap_gauss_seidel_ha(Box const &bx, Array4< Real > const &sol, Array4< Real const > const &rhs, Array4< Real const > const &sx, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_1D_K.H:170
void mlndlap_gauss_seidel_c(Box const &bx, Array4< Real > const &sol, Array4< Real const > const &rhs, Real sig, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_1D_K.H:203
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_adotx_c(int i, int, int, Array4< Real const > const &x, Real sigma, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_1D_K.H:37
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_divu_cf_contrib(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &, Array4< int const > const &, Array4< int const > const &, GpuArray< Real, 3 > const &, Box const &, GpuArray< LinOpBCType, 3 > const &, GpuArray< LinOpBCType, 3 > const &, bool) noexcept
Definition AMReX_MLNodeLap_1D_K.H:338
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_restriction_rap(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &) noexcept
Definition AMReX_MLNodeLap_1D_K.H:414
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void add_eb_flow_contribution(int i, int j, int, Array4< Real > const &rhs, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv, Array4< Real const > const &bareaarr, Array4< Real const > const &sintg, Array4< Real const > const &eb_vel_dot_n) noexcept
Definition AMReX_MLNodeLap_2D_K.H:1786
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real aa_interp_face_yz(Array4< Real const > const &crse, Array4< Real const > const &sig, int i, int j, int k, int ic, int jc, int kc) noexcept
Definition AMReX_MLNodeLap_3D_K.H:978
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_sum_Df(int ii, int jj, Real facx, Real facy, Array4< Real const > const &vel, Box const &velbx, bool is_rz) noexcept
Definition AMReX_MLNodeLap_2D_K.H:843
void LoopConcurrentOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition AMReX_Loop.H:388
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real aa_interp_face_xy(Array4< Real const > const &crse, Array4< Real const > const &sig, int i, int j, int ic, int jc) noexcept
Definition AMReX_MLNodeLap_2D_K.H:591
AMREX_GPU_DEVICE AMREX_FORCE_INLINE int mlndlap_color(int i, int, int)
Definition AMReX_MLNodeLap_1D_K.H:420
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:230
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void mlndlap_jacobi_aa(int i, int j, int k, Array4< Real > const &sol, Real Ax, Array4< Real const > const &rhs, Array4< Real const > const &sig, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv) noexcept
Definition AMReX_MLNodeLap_1D_K.H:125
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_avgdown_coeff_x(int i, int, int, Array4< Real > const &crse, Array4< Real const > const &fine) noexcept
Definition AMReX_MLNodeLap_1D_K.H:21
void LoopOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition AMReX_Loop.H:365
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_interpadd_ha(int i, int j, int k, Array4< Real > const &fine, Array4< Real const > const &crse, Array4< Real const > const &sig, Array4< int const > const &msk) noexcept
Definition AMReX_MLNodeLap_1D_K.H:276
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real aa_interp_line_x(Array4< Real const > const &crse, Array4< Real const > const &sig, int i, int j, int ic, int jc) noexcept
Definition AMReX_MLNodeLap_2D_K.H:573
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_stencil_rap(int, int, int, Array4< Real > const &, Array4< Real const > const &) noexcept
Definition AMReX_MLNodeLap_1D_K.H:391
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_adotx_sten_doit(int i, int j, int k, Array4< Real const > const &x, Array4< Real const > const &sten) noexcept
Definition AMReX_MLNodeLap_2D_K.H:1507
AMREX_FORCE_INLINE void tridiagonal_solve(Array1D< T, 0, 31 > &a_ls, Array1D< T, 0, 31 > &b_ls, Array1D< T, 0, 31 > &c_ls, Array1D< T, 0, 31 > &r_ls, Array1D< T, 0, 31 > &u_ls, Array1D< T, 0, 31 > &gam, int ilen) noexcept
Definition AMReX_MLABecLap_3D_K.H:432
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlndlap_rhcc(int i, int, int, Array4< Real const > const &rhcc, Array4< int const > const &msk) noexcept
Definition AMReX_MLNodeLap_1D_K.H:299
__host__ __device__ IntVectND< dim > scale(const IntVectND< dim > &p, int s) noexcept
Returns a IntVectND obtained by multiplying each of the components of this IntVectND by s.
Definition AMReX_IntVect.H:1016
__host__ __device__ void LoopConcurrent(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition AMReX_Loop.H:152
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_divu_eb(int i, int j, int, Array4< Real > const &rhs, Array4< Real const > const &vel, Array4< Real const > const &vfrac, Array4< Real const > const &intg, Array4< int const > const &msk, GpuArray< Real, 3 > const &dxinv, Box const &nodal_domain, GpuArray< LinOpBCType, 3 > const &bclo, GpuArray< LinOpBCType, 3 > const &bchi) noexcept
Definition AMReX_MLNodeLap_2D_K.H:1729
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real aa_interp_face_xz(Array4< Real const > const &crse, Array4< Real const > const &sig, int i, int j, int k, int ic, int jc, int kc) noexcept
Definition AMReX_MLNodeLap_3D_K.H:964
__host__ __device__ Dim3 lbound(Array4< T > const &a) noexcept
Definition AMReX_Array4.H:312
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndlap_res_cf_contrib(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< Real const > const &, Array4< int const > const &, Array4< int const > const &, Array4< int const > const &, Array4< Real const > const &, GpuArray< Real, 3 > const &, Box const &, GpuArray< LinOpBCType, 3 > const &, GpuArray< LinOpBCType, 3 > const &, bool) noexcept
Definition AMReX_MLNodeLap_1D_K.H:357
Definition AMReX_Array4.H:61
Fixed-size array that can be used on GPU.
Definition AMReX_Array.H:40