Block-Structured AMR Software Framework
AMReX_FilCC_1D_C.H
Go to the documentation of this file.
1 #ifndef AMREX_FILCC_1D_C_H_
2 #define AMREX_FILCC_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 FilccCell
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  const auto& domain_lo = domain_box.loVect();
22  const auto& domain_hi = domain_box.hiVect();
23  const int ilo = domain_lo[0];
24  const int ihi = domain_hi[0];
25  const int is = amrex::max(q.begin.x,ilo);
26  const int ie = amrex::min(q.end.x-1,ihi);
27 
28  for (int n = dcomp; n < numcomp+dcomp; ++n)
29  {
30  const BCRec& bc = bcr[bcomp+n-dcomp];
31 
32  if (i < ilo)
33  {
34  switch (bc.lo(0)) {
35  case (BCType::foextrap):
36  {
37  q(i,0,0,n) = q(ilo,0,0,n);
38  break;
39  }
40  case (BCType::hoextrap):
41  {
42  if (i < ilo - 1)
43  {
44  q(i,0,0,n) = q(ilo,0,0,n);
45  }
46  // i == ilo-1
47  else if (ilo+2 <= ie)
48  {
49  q(i,0,0,n) = Real(0.125)*(Real(15.)*q(i+1,0,0,n) - Real(10.)*q(i+2,0,0,n) + Real(3.)*q(i+3,0,0,n));
50  }
51  else
52  {
53  q(i,0,0,n) = Real(0.5)*(Real(3.)*q(i+1,0,0,n) - q(i+2,0,0,n));
54  }
55  break;
56  }
57  case (BCType::hoextrapcc):
58  {
59  q(i,0,0,n) = Real(ilo-i)*(q(ilo,0,0,n) - q(ilo+1,0,0,n)) + q(ilo,0,0,n);
60  break;
61  }
62  case (BCType::reflect_even):
63  {
64  q(i,0,0,n) = q(2*ilo-i-1,0,0,n);
65  break;
66  }
67  case (BCType::reflect_odd):
68  {
69  q(i,0,0,n) = -q(2*ilo-i-1,0,0,n);
70  break;
71  }
72  default: { break; }
73  }
74  }
75  else if (i > ihi)
76  {
77  switch (bc.hi(0)) {
78  case (BCType::foextrap):
79  {
80  q(i,0,0,n) = q(ihi,0,0,n);
81  break;
82  }
83  case (BCType::hoextrap):
84  {
85  if (i > ihi + 1)
86  {
87  q(i,0,0,n) = q(ihi,0,0,n);
88  }
89  // i == ihi+1
90  else if (ihi-2 >= is)
91  {
92  q(i,0,0,n) = Real(0.125)*(Real(15.)*q(i-1,0,0,n) - Real(10.)*q(i-2,0,0,n) + Real(3.)*q(i-3,0,0,n));
93  }
94  else
95  {
96  q(i,0,0,n) = Real(0.5)*(Real(3.)*q(i-1,0,0,n) - q(i-2,0,0,n));
97  }
98  break;
99  }
100  case (BCType::hoextrapcc):
101  {
102  q(i,0,0,n) = Real(i-ihi)*(q(ihi,0,0,n) - q(ihi-1,0,0,n)) + q(ihi,0,0,n);
103  break;
104  }
105  case (BCType::reflect_even):
106  {
107  q(i,0,0,n) = q(2*ihi-i+1,0,0,n);
108  break;
109  }
110  case (BCType::reflect_odd):
111  {
112  q(i,0,0,n) = -q(2*ihi-i+1,0,0,n);
113  break;
114  }
115  default: { break; }
116  }
117  }
118  }
119  }
120 };
121 
122 }
123 
124 #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
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const T & max(const T &a, const T &b) noexcept
Definition: AMReX_Algorithm.H:35
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const T & min(const T &a, const T &b) noexcept
Definition: AMReX_Algorithm.H:21
Definition: AMReX_Array4.H:61
Definition: AMReX_FilCC_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_FilCC_1D_C.H:14