Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
AMReX_Habec_1D_K.H
Go to the documentation of this file.
1#ifndef AMREX_HABEC_2D_H_
2#define AMREX_HABEC_2D_H_
3#include <AMReX_Config.H>
4
5namespace amrex {
6
8void 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,
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) {
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) {
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
50template <typename Int>
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,
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) {
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) {
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
108template <typename Int>
110void 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
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
Encapsulation of the Orientation of the Faces of a Box.
Definition AMReX_Orientation.H:29
@ low
Definition AMReX_Orientation.H:34
@ high
Definition AMReX_Orientation.H:34
__host__ __device__ void comp_bf(Real &bf1, Real &bf2, Real sb, Real h, int bct, Real bcl, int bho)
Definition AMReX_Habec_K.H:11
Definition AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void habec_cols(GpuArray< Int, 2 *3+1 > &sten, int i, int j, int, Array4< Int const > const &cell_id)
Definition AMReX_Habec_1D_K.H:110
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void habec_mat(GpuArray< Real, 2 *3+1 > &sten, int i, int j, int k, Dim3 const &boxlo, Dim3 const &boxhi, Real sa, Array4< Real const > const &a, Real sb, GpuArray< Real, 3 > const &dx, GpuArray< Array4< Real const >, 3 > const &b, GpuArray< int, 3 *2 > const &bctype, GpuArray< Real, 3 *2 > const &bcl, int bho, GpuArray< Array4< int const >, 3 *2 > const &msk, Array4< Real > const &diaginv)
Definition AMReX_Habec_1D_K.H:8
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void habec_ijmat(GpuArray< Real, 2 *3+1 > &sten, Array4< Int > const &ncols, Array4< Real > const &diaginv, int i, int j, int k, Array4< Int const > const &cell_id, Real sa, Array4< Real const > const &a, Real sb, GpuArray< Real, 3 > const &dx, GpuArray< Array4< Real const >, 3 > const &b, GpuArray< int, 3 *2 > const &bctype, GpuArray< Real, 3 *2 > const &bcl, int bho, Array4< int const > const &osm)
Definition AMReX_Habec_1D_K.H:52
Definition AMReX_Array4.H:61
Definition AMReX_Dim3.H:12
int x
Definition AMReX_Dim3.H:12
Definition AMReX_Array.H:34