Block-Structured AMR Software Framework
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
7namespace amrex::nodelap_detail {
8
9#ifdef AMREX_USE_HYPRE
10
11 struct GetNode {
12 AMREX_GPU_DEVICE Dim3 operator() (Dim3 const& lo, Dim3 const& len, int& offset)
13 {
14 Dim3 node;
15 constexpr int nsten = AMREX_D_TERM(3,*3,*3);
16 int icell = offset / nsten;
17 node.z = icell / (len.x*len.y);
18 node.y = (icell - node.z*(len.x*len.y)) / len.x;
19 node.x = (icell - node.z*(len.x*len.y)) - node.y*len.x;
20 node.x += lo.x;
21 node.y += lo.y;
22 node.z += lo.z;
23 offset -= icell*nsten;
24 return node;
25 }
26 };
27
28 struct GetNode2 {
29 AMREX_GPU_DEVICE Dim3 operator() (int offset, Dim3 const& node)
30 {
31 // In 2D the offsets are
32 // 6 7 8
33 // 4 0 5
34 // 1 2 3
35 constexpr int nstenhalf = AMREX_SPACEDIM == 2 ? 4 : 13;
36 if (offset == 0) {
37 return node;
38 } else {
39 if (offset <= nstenhalf) { --offset; }
40 Dim3 node2;
41 node2.z = offset / 9;
42 node2.y = (offset - node2.z*9) / 3;
43 node2.x = (offset - node2.z*9) - node2.y*3;
44 AMREX_D_TERM(node2.x += node.x-1;,
45 node2.y += node.y-1;,
46 node2.z += node.z-1);
47 return node2;
48 }
49 }
50 };
51
52#endif /* AMREX_USE_HYPRE */
53
54 constexpr int crse_cell = 0; // Do NOT change the values
55 constexpr int fine_cell = 1;
56 constexpr int crse_node = 0;
57 constexpr int crse_fine_node = 1;
58 constexpr int fine_node = 2;
59}
60
61namespace amrex {
62
63template <typename T>
64void mlndlap_fillbc_cc (Box const& vbx, Array4<T> const& sigma, Box const& domain,
67{
68 GpuArray<bool,AMREX_SPACEDIM> bflo{{AMREX_D_DECL(bclo[0] != LinOpBCType::Periodic,
69 bclo[1] != LinOpBCType::Periodic,
70 bclo[2] != LinOpBCType::Periodic)}};
71 GpuArray<bool,AMREX_SPACEDIM> bfhi{{AMREX_D_DECL(bchi[0] != LinOpBCType::Periodic,
72 bchi[1] != LinOpBCType::Periodic,
73 bchi[2] != LinOpBCType::Periodic)}};
74 mlndlap_bc_doit(vbx, sigma, domain, bflo, bfhi);
75}
76
77template <typename T>
78void mlndlap_applybc (Box const& vbx, Array4<T> const& phi, Box const& domain,
81{
82 GpuArray<bool,AMREX_SPACEDIM> bflo{{AMREX_D_DECL(bclo[0] == LinOpBCType::Neumann ||
83 bclo[0] == LinOpBCType::inflow,
84 bclo[1] == LinOpBCType::Neumann ||
85 bclo[1] == LinOpBCType::inflow,
86 bclo[2] == LinOpBCType::Neumann ||
87 bclo[2] == LinOpBCType::inflow)}};
88 GpuArray<bool,AMREX_SPACEDIM> bfhi{{AMREX_D_DECL(bchi[0] == LinOpBCType::Neumann ||
89 bchi[0] == LinOpBCType::inflow,
90 bchi[1] == LinOpBCType::Neumann ||
91 bchi[1] == LinOpBCType::inflow,
92 bchi[2] == LinOpBCType::Neumann ||
93 bchi[2] == LinOpBCType::inflow)}};
94 mlndlap_bc_doit(vbx, phi, domain, bflo, bfhi);
95}
96
97}
98
99#if (AMREX_SPACEDIM == 1)
101#elif (AMREX_SPACEDIM == 2)
103#else
105#endif
106
107#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:129
Definition AMReX_MLNodeLap_3D_K.H:1947
constexpr int fine_cell
Definition AMReX_MLNodeLinOp_K.H:55
constexpr int fine_node
Definition AMReX_MLNodeLinOp_K.H:58
constexpr int crse_node
Definition AMReX_MLNodeLinOp_K.H:56
constexpr int crse_cell
Definition AMReX_MLNodeLinOp_K.H:54
constexpr int crse_fine_node
Definition AMReX_MLNodeLinOp_K.H:57
Definition AMReX_Amr.cpp:49
void mlndlap_bc_doit(Box const &vbx, Array4< T > const &a, Box const &domain, GpuArray< bool, AMREX_SPACEDIM > const &bflo, GpuArray< bool, AMREX_SPACEDIM > 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, AMREX_SPACEDIM > bclo, GpuArray< LinOpBCType, AMREX_SPACEDIM > bchi) noexcept
Definition AMReX_MLNodeLinOp_K.H:64
void mlndlap_applybc(Box const &vbx, Array4< T > const &phi, Box const &domain, GpuArray< LinOpBCType, AMREX_SPACEDIM > bclo, GpuArray< LinOpBCType, AMREX_SPACEDIM > bchi) noexcept
Definition AMReX_MLNodeLinOp_K.H:78
Definition AMReX_Array4.H:61
Definition AMReX_Array.H:34