Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
AMReX_MLNodeLinOp_K.H
Go to the documentation of this file.
1#ifndef AMREX_ML_NODE_LINOP_K_H_
2#define AMREX_ML_NODE_LINOP_K_H_
3#include <AMReX_Config.H>
4
5#include <AMReX_FArrayBox.H>
6
8namespace amrex::nodelap_detail {
9
10#ifdef AMREX_USE_HYPRE
11
12 struct GetNode {
13 AMREX_GPU_DEVICE Dim3 operator() (Dim3 const& lo, Dim3 const& len, int& offset)
14 {
15 Dim3 node;
16 constexpr int nsten = AMREX_D_TERM(3,*3,*3);
17 int icell = offset / nsten;
18 node.z = icell / (len.x*len.y);
19 node.y = (icell - node.z*(len.x*len.y)) / len.x;
20 node.x = (icell - node.z*(len.x*len.y)) - node.y*len.x;
21 node.x += lo.x;
22 node.y += lo.y;
23 node.z += lo.z;
24 offset -= icell*nsten;
25 return node;
26 }
27 };
28
29 struct GetNode2 {
30 AMREX_GPU_DEVICE Dim3 operator() (int offset, Dim3 const& node)
31 {
32 // In 2D the offsets are
33 // 6 7 8
34 // 4 0 5
35 // 1 2 3
36 constexpr int nstenhalf = AMREX_SPACEDIM == 2 ? 4 : 13;
37 if (offset == 0) {
38 return node;
39 } else {
40 if (offset <= nstenhalf) { --offset; }
41 Dim3 node2;
42 node2.z = offset / 9;
43 node2.y = (offset - node2.z*9) / 3;
44 node2.x = (offset - node2.z*9) - node2.y*3;
45 AMREX_D_TERM(node2.x += node.x-1;,
46 node2.y += node.y-1;,
47 node2.z += node.z-1);
48 return node2;
49 }
50 }
51 };
52
53#endif /* AMREX_USE_HYPRE */
54
55 constexpr int crse_cell = 0; // Do NOT change the values
56 constexpr int fine_cell = 1;
57 constexpr int crse_node = 0;
58 constexpr int crse_fine_node = 1;
59 constexpr int fine_node = 2;
60}
62
63namespace amrex {
64
65template <typename T>
66void mlndlap_fillbc_cc (Box const& vbx, Array4<T> const& sigma, Box const& domain,
69{
71 bclo[1] != LinOpBCType::Periodic,
72 bclo[2] != LinOpBCType::Periodic)}};
74 bchi[1] != LinOpBCType::Periodic,
75 bchi[2] != LinOpBCType::Periodic)}};
76 mlndlap_bc_doit(vbx, sigma, domain, bflo, bfhi);
77}
78
79template <typename T>
80void mlndlap_applybc (Box const& vbx, Array4<T> const& phi, Box const& domain,
83{
85 bclo[0] == LinOpBCType::inflow,
86 bclo[1] == LinOpBCType::Neumann ||
87 bclo[1] == LinOpBCType::inflow,
88 bclo[2] == LinOpBCType::Neumann ||
89 bclo[2] == LinOpBCType::inflow)}};
91 bchi[0] == LinOpBCType::inflow,
92 bchi[1] == LinOpBCType::Neumann ||
93 bchi[1] == LinOpBCType::inflow,
94 bchi[2] == LinOpBCType::Neumann ||
95 bchi[2] == LinOpBCType::inflow)}};
96 mlndlap_bc_doit(vbx, phi, domain, bflo, bfhi);
97}
98
99}
100
101#if (AMREX_SPACEDIM == 1)
103#elif (AMREX_SPACEDIM == 2)
105#else
107#endif
108
109#endif
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
Array4< int const > offset
Definition AMReX_HypreMLABecLap.cpp:1089
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Definition AMReX_Amr.cpp:49
void mlndlap_bc_doit(Box const &vbx, Array4< T > const &a, Box const &domain, GpuArray< bool, 3 > const &bflo, GpuArray< bool, 3 > const &bfhi) noexcept
Definition AMReX_MLNodeLinOp_1D_K.H:8
void mlndlap_fillbc_cc(Box const &vbx, Array4< T > const &sigma, Box const &domain, GpuArray< LinOpBCType, 3 > bclo, GpuArray< LinOpBCType, 3 > bchi) noexcept
Definition AMReX_MLNodeLinOp_K.H:66
void mlndlap_applybc(Box const &vbx, Array4< T > const &phi, Box const &domain, GpuArray< LinOpBCType, 3 > bclo, GpuArray< LinOpBCType, 3 > bchi) noexcept
Definition AMReX_MLNodeLinOp_K.H:80
Definition AMReX_Array4.H:61
Fixed-size array that can be used on GPU.
Definition AMReX_Array.H:40