Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
AMReX_FilCC_2D_C.H
Go to the documentation of this file.
1#ifndef AMREX_FILCC_2D_C_H_
2#define AMREX_FILCC_2D_C_H_
3#include <AMReX_Config.H>
4
5#include <AMReX_FArrayBox.H>
6#include <AMReX_BCRec.H>
7#include <AMReX_Geometry.H>
8
9namespace amrex {
10
11struct 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 const int j = iv[1];
21
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 jlo = domain_lo[1];
26 const int ihi = domain_hi[0];
27 const int jhi = domain_hi[1];
28 const int is = amrex::max(q.begin.x,ilo);
29 const int js = amrex::max(q.begin.y,jlo);
30 const int ie = amrex::min(q.end.x-1,ihi);
31 const int je = amrex::min(q.end.y-1,jhi);
32
33 for (int n = dcomp; n < numcomp+dcomp; ++n)
34 {
35 const BCRec& bc = bcr[bcomp+n-dcomp];
36
37 if (i < ilo)
38 {
39 switch (bc.lo(0)) {
40 case (BCType::foextrap):
41 {
42 q(i,j,0,n) = q(ilo,j,0,n);
43 break;
44 }
45 case (BCType::hoextrap):
46 {
47 if (i < ilo - 1)
48 {
49 q(i,j,0,n) = q(ilo,j,0,n);
50 }
51 // i == ilo-1
52 else if (ilo+2 <= ie)
53 {
54 q(i,j,0,n) = Real(0.125)*(Real(15.)*q(i+1,j,0,n) - Real(10.)*q(i+2,j,0,n) + Real(3.)*q(i+3,j,0,n));
55 }
56 else
57 {
58 q(i,j,0,n) = Real(0.5)*(Real(3.)*q(i+1,j,0,n) - q(i+2,j,0,n));
59 }
60 break;
61 }
62 case (BCType::hoextrapcc):
63 {
64 q(i,j,0,n) = Real(ilo-i)*(q(ilo,j,0,n) - q(ilo+1,j,0,n)) + q(ilo,j,0,n);
65 break;
66 }
67 case (BCType::reflect_even):
68 {
69 q(i,j,0,n) = q(2*ilo-i-1,j,0,n);
70 break;
71 }
72 case (BCType::reflect_odd):
73 {
74 q(i,j,0,n) = -q(2*ilo-i-1,j,0,n);
75 break;
76 }
77 default: { break; }
78 }
79 }
80 else if (i > ihi)
81 {
82 switch (bc.hi(0)) {
83 case (BCType::foextrap):
84 {
85 q(i,j,0,n) = q(ihi,j,0,n);
86 break;
87 }
88 case (BCType::hoextrap):
89 {
90 if (i > ihi + 1)
91 {
92 q(i,j,0,n) = q(ihi,j,0,n);
93 }
94 // i == ihi+1
95 else if (ihi-2 >= is)
96 {
97 q(i,j,0,n) = Real(0.125)*(Real(15.)*q(i-1,j,0,n) - Real(10.)*q(i-2,j,0,n) + Real(3.)*q(i-3,j,0,n));
98 }
99 else
100 {
101 q(i,j,0,n) = Real(0.5)*(Real(3.)*q(i-1,j,0,n) - q(i-2,j,0,n));
102 }
103 break;
104 }
105 case (BCType::hoextrapcc):
106 {
107 q(i,j,0,n) = Real(i-ihi)*(q(ihi,j,0,n) - q(ihi-1,j,0,n)) + q(ihi,j,0,n);
108 break;
109 }
110 case (BCType::reflect_even):
111 {
112 q(i,j,0,n) = q(2*ihi-i+1,j,0,n);
113 break;
114 }
115 case (BCType::reflect_odd):
116 {
117 q(i,j,0,n) = -q(2*ihi-i+1,j,0,n);
118 break;
119 }
120 default: { break; }
121 }
122 }
123
124 if (j < jlo)
125 {
126 switch (bc.lo(1)) {
127 case (BCType::foextrap):
128 {
129 q(i,j,0,n) = q(i,jlo,0,n);
130 break;
131 }
132 case (BCType::hoextrap):
133 {
134 if (j < jlo - 1)
135 {
136 q(i,j,0,n) = q(i,jlo,0,n);
137 }
138 // j == jlo-1
139 else if (jlo+2 <= je)
140 {
141 q(i,j,0,n) = Real(0.125)*(Real(15.)*q(i,j+1,0,n) - Real(10.)*q(i,j+2,0,n) + Real(3.)*q(i,j+3,0,n));
142 }
143 else
144 {
145 q(i,j,0,n) = Real(0.5)*(Real(3.)*q(i,j+1,0,n) - q(i,j+2,0,n));
146 }
147 break;
148 }
149 case (BCType::hoextrapcc):
150 {
151 q(i,j,0,n) = Real(jlo-j)*(q(i,jlo,0,n) - q(i,jlo+1,0,n)) + q(i,jlo,0,n);
152 break;
153 }
154 case (BCType::reflect_even):
155 {
156 q(i,j,0,n) = q(i,2*jlo-j-1,0,n);
157 break;
158 }
159 case (BCType::reflect_odd):
160 {
161 q(i,j,0,n) = -q(i,2*jlo-j-1,0,n);
162 break;
163 }
164 default: { break; }
165 }
166 }
167 else if (j > jhi)
168 {
169 switch (bc.hi(1)) {
170 case (BCType::foextrap):
171 {
172 q(i,j,0,n) = q(i,jhi,0,n);
173 break;
174 }
175 case (BCType::hoextrap):
176 {
177 if (j > jhi + 1)
178 {
179 q(i,j,0,n) = q(i,jhi,0,n);
180 }
181 // j == jhi+1
182 else if (jhi-2 >= js)
183 {
184 q(i,j,0,n) = Real(0.125)*(Real(15.)*q(i,j-1,0,n) - Real(10.)*q(i,j-2,0,n) + Real(3.)*q(i,j-3,0,n));
185 }
186 else
187 {
188 q(i,j,0,n) = Real(0.5)*(Real(3.)*q(i,j-1,0,n) - q(i,j-2,0,n));
189 }
190 break;
191 }
192 case (BCType::hoextrapcc):
193 {
194 q(i,j,0,n) = Real(j-jhi)*(q(i,jhi,0,n) - q(i,jhi-1,0,n)) + q(i,jhi,0,n);
195 break;
196 }
197 case (BCType::reflect_even):
198 {
199 q(i,j,0,n) = q(i,2*jhi-j+1,0,n);
200 break;
201 }
202 case (BCType::reflect_odd):
203 {
204 q(i,j,0,n) = -q(i,2*jhi-j+1,0,n);
205 break;
206 }
207 default: { break; }
208 }
209 }
210 }
211 }
212};
213
214}
215
216#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 AMREX_FORCE_INLINE constexpr const T & min(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:21
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr const T & max(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:35
Definition AMReX_Array4.H:61
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