Block-Structured AMR Software Framework
AMReX_FilFC_1D_C.H
Go to the documentation of this file.
1 #ifndef AMREX_FILFC_1D_C_H_
2 #define AMREX_FILFC_1D_C_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_FArrayBox.H>
6 #include <AMReX_BCRec.H>
7 #include <AMReX_Geometry.H>
8 
9 namespace amrex {
10 
11 struct FilfcFace
12 {
14  void operator() (const IntVect& iv, Array4<Real> const& q,
15  const int dcomp, const int numcomp,
16  Box const& domain_box, const BCRec* bcr,
17  const int bcomp) const noexcept
18  {
19  const int i = iv[0];
20 
21  // Domain box is indexed according to the face currently treating
22  const auto& domain_lo = domain_box.loVect();
23  const auto& domain_hi = domain_box.hiVect();
24  const int ilo = domain_lo[0];
25  const int ihi = domain_hi[0];
26 
27  for (int n = dcomp; n < numcomp+dcomp; ++n)
28  {
29  const BCRec& bc = bcr[bcomp+n-dcomp];
30 
31  if (i == ilo)
32  {
33  // Enforce reflect_odd on the domain face
34  if (bc.lo(0) == BCType::reflect_odd) {
35  q(i,0,0,n) = 0.0;
36  }
37  }
38  else if (i < ilo)
39  {
40  switch (bc.lo(0)) {
41  case (BCType::foextrap):
42  {
43  q(i,0,0,n) = q(ilo,0,0,n);
44  break;
45  }
46  case (BCType::hoextrap):
47  {
48  if (i < ilo - 1)
49  {
50  q(i,0,0,n) = q(ilo,0,0,n);
51  }
52  // i == ilo-1
53  else
54  {
55  q(i,0,0,n) = Real(2.0)*q(i+1,0,0,n) - q(i+2,0,0,n);
56  }
57  break;
58  }
59  case (BCType::reflect_even):
60  {
61  q(i,0,0,n) = q(2*ilo-i,0,0,n);
62  break;
63  }
64  case (BCType::reflect_odd):
65  {
66  q(i,0,0,n) = -q(2*ilo-i,0,0,n);
67  break;
68  }
69  default: { break; }
70  }
71  }
72  else if (i == ihi)
73  {
74  // Enforce reflect_odd on the domain face
75  if (bc.hi(0) == BCType::reflect_odd) {
76  q(i,0,0,n) = 0.0;
77  }
78  }
79  else if (i > ihi)
80  {
81  switch (bc.hi(0)) {
82  case (BCType::foextrap):
83  {
84  q(i,0,0,n) = q(ihi,0,0,n);
85  break;
86  }
87  case (BCType::hoextrap):
88  {
89  if (i > ihi + 1)
90  {
91  q(i,0,0,n) = q(ihi,0,0,n);
92  }
93  // i == ihi+1
94  else
95  {
96  q(i,0,0,n) = Real(2.0)*q(i-1,0,0,n) - q(i-2,0,0,n);
97  }
98  break;
99  }
100  case (BCType::reflect_even):
101  {
102  q(i,0,0,n) = q(2*ihi-i,0,0,n);
103  break;
104  }
105  case (BCType::reflect_odd):
106  {
107  q(i,0,0,n) = -q(2*ihi-i,0,0,n);
108  break;
109  }
110  default: { break; }
111  }
112  }
113  }
114  }
115 };
116 
117 }
118 
119 #endif
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
Boundary Condition Records. Necessary information and functions for computing boundary conditions.
Definition: AMReX_BCRec.H:17
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int * hi() const &noexcept
Return high-end boundary data.
Definition: AMReX_BCRec.H:106
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int * lo() const &noexcept
Return low-end boundary data.
Definition: AMReX_BCRec.H:100
Definition: AMReX_Amr.cpp:49
Definition: AMReX_Array4.H:61
Definition: AMReX_FilFC_1D_C.H:12
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(const IntVect &iv, Array4< Real > const &q, const int dcomp, const int numcomp, Box const &domain_box, const BCRec *bcr, const int bcomp) const noexcept
Definition: AMReX_FilFC_1D_C.H:14