Skip to content

Commit 5a28a59

Browse files
committed
add new files
1 parent f0f5c09 commit 5a28a59

File tree

4 files changed

+449
-2
lines changed

4 files changed

+449
-2
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#ifndef AMREX_HABEC_2D_H_
2+
#define AMREX_HABEC_2D_H_
3+
#include <AMReX_Config.H>
4+
5+
namespace amrex {
6+
7+
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
8+
void habec_mat (GpuArray<Real,2*AMREX_SPACEDIM+1>& sten, int i, int j, int k,
9+
Dim3 const& boxlo, Dim3 const& boxhi,
10+
Real sa, Array4<Real const> const& a,
11+
Real sb, GpuArray<Real,AMREX_SPACEDIM> const& dx,
12+
GpuArray<Array4<Real const>, AMREX_SPACEDIM> const& b,
13+
GpuArray<int,AMREX_SPACEDIM*2> const& bctype,
14+
GpuArray<Real,AMREX_SPACEDIM*2> const& bcl, int bho,
15+
GpuArray<Array4<int const>, AMREX_SPACEDIM*2> const& msk,
16+
Array4<Real> const& diaginv)
17+
{
18+
sten[1] = -(sb / (dx[0]*dx[0])) * b[0](i,j,k);
19+
sten[2] = -(sb / (dx[0]*dx[0])) * b[0](i+1,j,k);
20+
sten[0] = -(sten[1] + sten[2]);
21+
if (sa != Real(0.0)) {
22+
sten[0] += sa * a(i,j,k);
23+
}
24+
25+
// xlo
26+
if (i == boxlo.x) {
27+
int cdir = Orientation(Direction::x, Orientation::low);
28+
if (msk[cdir](i-1,j,k) > 0) {
29+
Real bf1, bf2;
30+
detail::comp_bf(bf1, bf2, sb, dx[0], bctype[cdir], bcl[cdir], bho);
31+
sten[0] += bf1 * b[0](i,j,k);
32+
sten[1] = Real(0.0);
33+
sten[2] += bf2 * b[0](i,j,k);
34+
}
35+
}
36+
37+
// xhi
38+
if (i == boxhi.x) {
39+
int cdir = Orientation(Direction::x, Orientation::high);
40+
if (msk[cdir](i+1,j,k) > 0) {
41+
Real bf1, bf2;
42+
detail::comp_bf(bf1, bf2, sb, dx[0], bctype[cdir], bcl[cdir], bho);
43+
sten[0] += bf1 * b[0](i+1,j,k);
44+
sten[1] += bf2 * b[0](i+1,j,k);
45+
sten[2] = Real(0.0);
46+
}
47+
}
48+
}
49+
50+
template <typename Int>
51+
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
52+
void habec_ijmat (GpuArray<Real,2*AMREX_SPACEDIM+1>& sten, Array4<Int> const& ncols,
53+
Array4<Real> const& diaginv, int i, int j, int k,
54+
Array4<Int const> const& cell_id,
55+
Real sa, Array4<Real const> const& a,
56+
Real sb, GpuArray<Real,AMREX_SPACEDIM> const& dx,
57+
GpuArray<Array4<Real const>, AMREX_SPACEDIM> const& b,
58+
GpuArray<int,AMREX_SPACEDIM*2> const& bctype,
59+
GpuArray<Real,AMREX_SPACEDIM*2> const& bcl, int bho,
60+
Array4<int const> const& osm)
61+
{
62+
if (!osm || osm(i,j,k) != 0) {
63+
sten[1] = -(sb / (dx[0]*dx[0])) * b[0](i,j,k);
64+
sten[2] = -(sb / (dx[0]*dx[0])) * b[0](i+1,j,k);
65+
sten[0] = -(sten[1] + sten[2]);
66+
if (sa != Real(0.0)) {
67+
sten[0] += sa * a(i,j,k);
68+
}
69+
70+
// xlo
71+
if (cell_id(i-1,j,k) < 0) {
72+
int cdir = Orientation(Direction::x, Orientation::low);
73+
Real bf1, bf2;
74+
detail::comp_bf(bf1, bf2, sb, dx[0], bctype[cdir], bcl[cdir], bho);
75+
sten[0] += bf1 * b[0](i,j,k);
76+
sten[1] = Real(0.0);
77+
sten[2] += bf2 * b[0](i,j,k);
78+
}
79+
80+
// xhi
81+
if (cell_id(i+1,j,k) < 0) {
82+
int cdir = Orientation(Direction::x, Orientation::high);
83+
Real bf1, bf2;
84+
detail::comp_bf(bf1, bf2, sb, dx[0], bctype[cdir], bcl[cdir], bho);
85+
sten[0] += bf1 * b[0](i+1,j,k);
86+
sten[1] += bf2 * b[0](i+1,j,k);
87+
sten[2] = Real(0.0);
88+
}
89+
} else {
90+
sten[0] = Real(1.0);
91+
for (int m = 1; m < 2*AMREX_SPACEDIM+1; ++m) {
92+
sten[m] = Real(0.0);
93+
}
94+
}
95+
96+
diaginv(i,j,k) = Real(1.0) / sten[0];
97+
sten[0] = Real(1.0);
98+
for (int m = 1; m < 2*AMREX_SPACEDIM+1; ++m) {
99+
sten[m] *= diaginv(i,j,k);
100+
}
101+
102+
ncols(i,j,k) = 0;
103+
for (int m = 0; m < 2*AMREX_SPACEDIM+1; ++m) {
104+
ncols(i,j,k) += (sten[m] != Real(0.0));
105+
}
106+
}
107+
108+
template <typename Int>
109+
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
110+
void habec_cols (GpuArray<Int,2*AMREX_SPACEDIM+1>& sten, int i, int j, int /*k*/,
111+
Array4<Int const> const& cell_id)
112+
{
113+
sten[0] = cell_id(i ,j ,0);
114+
sten[1] = cell_id(i-1,j ,0);
115+
sten[2] = cell_id(i+1,j ,0);
116+
}
117+
118+
}
119+
#endif

Src/Extern/HYPRE/AMReX_Habec_K.H

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ namespace amrex::detail {
5656
}
5757
}
5858

59-
#if (AMREX_SPACEDIM == 2)
59+
#if (AMREX_SPACEDIM == 1)
60+
#include <AMReX_Habec_1D_K.H>
61+
#elif (AMREX_SPACEDIM == 2)
6062
#include <AMReX_Habec_2D_K.H>
6163
#elif (AMREX_SPACEDIM == 3)
6264
#include <AMReX_Habec_3D_K.H>

0 commit comments

Comments
 (0)