1 #ifndef AMREX_MLNODETENSORLAP_2D_K_H_
2 #define AMREX_MLNODETENSORLAP_2D_K_H_
3 #include <AMReX_Config.H>
7 namespace mlndts_detail {
12 return (
crse(ic,jc,0)+
crse(ic+1,jc,0))*Real(0.5);
18 return (
crse(ic,jc,0)+
crse(ic,jc+1,0))*Real(0.5);
33 Array4<Real const>
const&
crse, Array4<int const>
const& msk) noexcept
35 using namespace mlndts_detail;
40 bool i_is_odd = (ic*2 != i);
41 bool j_is_odd = (jc*2 != j);
42 if (i_is_odd && j_is_odd) {
45 }
else if (i_is_odd) {
48 }
else if (j_is_odd) {
60 Array4<Real const>
const&
crse, Array4<int const>
const& msk,
61 int semi_dir) noexcept
63 using namespace mlndts_detail;
68 bool j_is_odd = (jc*2 != j);
78 bool i_is_odd = (ic*2 != i);
97 y(i,j,k) = s[0] * (
x(i-1,j,0) +
x(i+1,j,0))
98 + s[2] * (
x(i,j-1,0) +
x(i,j+1,0))
99 - Real(2.)*(s[0]+s[2]) *
x(i,j,0)
100 + Real(0.5)*s[1] * (
x(i-1,j-1,0) +
x(i+1,j+1,0) -
x(i-1,j+1,0) -
x(i+1,j-1,0));
112 constexpr Real omega = Real(1.25);
113 Real s0 = Real(-2.)*(s[0]+s[2]);
114 Real Ax = s[0] * (sol(i-1,j,0) + sol(i+1,j,0))
115 + s[2] * (sol(i,j-1,0) + sol(i,j+1,0))
117 + Real(0.5)*s[1] * (sol(i-1,j-1,0) + sol(i+1,j+1,0) - sol(i-1,j+1,0) - sol(i+1,j-1,0));
118 sol(i,j,k) += (rhs(i,j,k) - Ax) * (omega/s0);
122 #if defined(AMREX_USE_HYPRE) && (AMREX_SPACEDIM > 1)
124 template <
typename HypreInt,
typename AtomicInt>
125 void mlndtslap_fill_ijmatrix_cpu (
Box const& ndbx,
126 Array4<AtomicInt const>
const& gid,
127 Array4<int const>
const& lid,
128 HypreInt*
const ncols, HypreInt*
const cols, Real*
const mat,
129 GpuArray<Real,3>
const& s) noexcept
137 HypreInt nelems_old = nelems;
139 cols[nelems] = gid(i,j,k);
140 mat[nelems] = Real(-2.)*(s[0]+s[2]);
143 if (gid(i-1,j-1,k) < gidmax) {
144 cols[nelems] = gid(i-1,j-1,k);
145 mat[nelems] = Real(0.5)*s[1];
149 if (gid(i,j-1,k) < gidmax) {
150 cols[nelems] = gid(i,j-1,k);
155 if (gid(i+1,j-1,k) < gidmax) {
156 cols[nelems] = gid(i+1,j-1,k);
157 mat[nelems] = Real(-0.5)*s[1];
161 if (gid(i-1,j,k) < gidmax) {
162 cols[nelems] = gid(i-1,j,k);
167 if (gid(i+1,j,k) < gidmax) {
168 cols[nelems] = gid(i+1,j,k);
173 if (gid(i-1,j+1,k) < gidmax) {
174 cols[nelems] = gid(i-1,j+1,k);
175 mat[nelems] = Real(-0.5)*s[1];
179 if (gid(i,j+1,k) < gidmax) {
180 cols[nelems] = gid(i,j+1,k);
185 if (gid(i+1,j+1,k) < gidmax) {
186 cols[nelems] = gid(i+1,j+1,k);
187 mat[nelems] = Real(0.5)*s[1];
191 ncols[lid(i,j,k)] = nelems - nelems_old;
197 template <
typename HypreInt,
typename AtomicInt>
199 void mlndtslap_fill_ijmatrix_gpu (
const int ps,
const int i,
const int j,
const int k,
201 Array4<AtomicInt const>
const& gid,
202 Array4<int const>
const& lid,
203 HypreInt*
const ncols, HypreInt*
const cols, Real*
const mat,
204 GpuArray<Real,3>
const& s) noexcept
211 cols[ps] = gid(i,j,k);
212 mat[ps] = Real(-2.)*(s[0]+s[2]);
214 if (gid(i-1,j-1,k) < gidmax) { ++nc; }
215 if (gid(i ,j-1,k) < gidmax) { ++nc; }
216 if (gid(i+1,j-1,k) < gidmax) { ++nc; }
217 if (gid(i-1,j ,k) < gidmax) { ++nc; }
218 if (gid(i+1,j ,k) < gidmax) { ++nc; }
219 if (gid(i-1,j+1,k) < gidmax) { ++nc; }
220 if (gid(i ,j+1,k) < gidmax) { ++nc; }
221 if (gid(i+1,j+1,k) < gidmax) { ++nc; }
222 ncols[lid(i,j,k)] = nc;
224 else if (
offset == 1 && gid(i-1,j-1,k) < gidmax) {
225 cols[ps] = gid(i-1,j-1,k);
226 mat[ps] = Real(0.5)*s[1];
228 else if (
offset == 2 && gid(i ,j-1,k) < gidmax) {
229 cols[ps] = gid(i ,j-1,k);
232 else if (
offset == 3 && gid(i+1,j-1,k) < gidmax) {
233 cols[ps] = gid(i+1,j-1,k);
234 mat[ps] = Real(-0.5)*s[1];
236 else if (
offset == 4 && gid(i-1,j ,k) < gidmax) {
237 cols[ps] = gid(i-1,j ,k);
240 else if (
offset == 5 && gid(i+1,j ,k) < gidmax) {
241 cols[ps] = gid(i+1,j ,k);
244 else if (
offset == 6 && gid(i-1,j+1,k) < gidmax) {
245 cols[ps] = gid(i-1,j+1,k);
246 mat[ps] = Real(-0.5)*s[1];
248 else if (
offset == 7 && gid(i ,j+1,k) < gidmax) {
249 cols[ps] = gid(i ,j+1,k);
252 else if (
offset == 8 && gid(i+1,j+1,k) < gidmax) {
253 cols[ps] = gid(i+1,j+1,k);
254 mat[ps] = Real(0.5)*s[1];
#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
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
@ max
Definition: AMReX_ParallelReduce.H:17
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real ts_interp_line_x(Array4< Real const > const &crse, int ic, int jc) noexcept
Definition: AMReX_MLNodeTensorLap_2D_K.H:10
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real ts_interp_line_y(Array4< Real const > const &crse, int ic, int jc) noexcept
Definition: AMReX_MLNodeTensorLap_2D_K.H:16
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real ts_interp_face_xy(Array4< Real const > const &crse, int ic, int jc) noexcept
Definition: AMReX_MLNodeTensorLap_2D_K.H:22
Definition: AMReX_Amr.cpp:49
AMREX_ATTRIBUTE_FLATTEN_FOR void LoopOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition: AMReX_Loop.H:355
BoxND< AMREX_SPACEDIM > Box
Definition: AMReX_BaseFwd.H:27
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndtslap_adotx(int i, int j, int k, Array4< Real > const &y, Array4< Real const > const &x, Array4< int const > const &msk, GpuArray< Real, 3 > const &s) noexcept
Definition: AMReX_MLNodeTensorLap_2D_K.H:91
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndtslap_gauss_seidel(int i, int j, int k, Array4< Real > const &sol, Array4< Real const > const &rhs, Array4< int const > const &msk, GpuArray< Real, 3 > const &s) noexcept
Definition: AMReX_MLNodeTensorLap_2D_K.H:105
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndtslap_semi_interpadd(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< int const > const &, int) noexcept
Definition: AMReX_MLNodeTensorLap_1D_K.H:13
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlndtslap_interpadd(int, int, int, Array4< Real > const &, Array4< Real const > const &, Array4< int const > const &) noexcept
Definition: AMReX_MLNodeTensorLap_1D_K.H:8
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > coarsen(const BoxND< dim > &b, int ref_ratio) noexcept
Coarsen BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo/rati...
Definition: AMReX_Box.H:1304
Definition: AMReX_Array4.H:61