74 #ifndef BC_CONSTANT_H_
75 #define BC_CONSTANT_H_
77 #include <AMReX_ParallelDescriptor.H>
78 #include <AMReX_ParmParse.H>
79 #include <AMReX_BCRec.H>
80 #include <AMReX_PhysBCFunct.H>
81 #include <AMReX_Array.H>
90 :
public BC<Set::Scalar>
98 #elif AMREX_SPACEDIM==3
100 XLO, YLO, ZLO, XHI, YHI, ZHI,
112 Constant(
int ncomp, amrex::Vector<std::string> bc_hi_str,
113 amrex::Vector<std::string> bc_lo_str,
115 amrex::Vector<amrex::Real> _bc_lo_2,
116 amrex::Vector<amrex::Real> _bc_lo_3),
118 amrex::Vector<amrex::Real> _bc_hi_2,
119 amrex::Vector<amrex::Real> _bc_hi_3));
123 virtual void FillBoundary(amrex::BaseFab<Set::Scalar>& in,
const amrex::Box& box,
124 int ngrow,
int dcomp,
int ncomp, amrex::Real time,
126 const amrex::Mask* mask =
nullptr)
override;
131 virtual amrex::Array<int, AMREX_SPACEDIM>
IsPeriodic()
override;
132 virtual amrex::Periodicity
Periodicity()
const override;
133 virtual amrex::Periodicity
Periodicity(
const amrex::Box& b)
override;
138 const amrex::Array<amrex::Array<T, AMREX_SPACEDIM>, 2>
GetBCTypes()
146 #if AMREX_SPACEDIM==2
147 static const int m_nfaces = 4;
148 #elif AMREX_SPACEDIM==3
149 static const int m_nfaces = 6;
160 std::array<std::vector<Numeric::Interpolator::Linear<Set::Scalar>>, m_nfaces>
m_bc_val;
165 std::map<std::string, int> bcmap;
166 bcmap[
"BOGUS_BC"] = amrex::BCType::mathematicalBndryTypes::bogus;
167 bcmap[
"INT_DIR"] = amrex::BCType::mathematicalBndryTypes::int_dir;
168 bcmap[
"REFLECT_ODD"] = amrex::BCType::mathematicalBndryTypes::reflect_odd;
169 bcmap[
"INT_DIR"] = amrex::BCType::mathematicalBndryTypes::int_dir;
170 bcmap[
"REFLECT_EVEN"] = amrex::BCType::mathematicalBndryTypes::reflect_even;
171 bcmap[
"FOEXTRAP"] = amrex::BCType::mathematicalBndryTypes::foextrap;
172 bcmap[
"EXT_DIR"] = amrex::BCType::mathematicalBndryTypes::ext_dir;
173 bcmap[
"HOEXTRAP"] = amrex::BCType::mathematicalBndryTypes::hoextrap;
174 bcmap[
"Interior"] = amrex::BCType::mathematicalBndryTypes::int_dir;
175 bcmap[
"Inflow"] = amrex::BCType::mathematicalBndryTypes::ext_dir;
176 bcmap[
"Outflow"] = amrex::BCType::mathematicalBndryTypes::foextrap;
177 bcmap[
"Symmetry"] = amrex::BCType::mathematicalBndryTypes::reflect_even;
178 bcmap[
"SlipWall"] = amrex::BCType::mathematicalBndryTypes::ext_dir;
179 bcmap[
"NoSlipWall"] = amrex::BCType::mathematicalBndryTypes::ext_dir;
181 bcmap[
"interior"] = (int)amrex::LinOpBCType::interior;
182 bcmap[
"Dirichlet"] = (int)amrex::LinOpBCType::Dirichlet;
183 bcmap[
"dirichlet"] = (int)amrex::LinOpBCType::Dirichlet;
184 bcmap[
"Neumann"] = (int)amrex::LinOpBCType::Neumann;
185 bcmap[
"NEUMANN"] = (int)amrex::LinOpBCType::Neumann;
186 bcmap[
"neumann"] = (int)amrex::LinOpBCType::Neumann;
187 bcmap[
"reflect_odd"] = (int)amrex::LinOpBCType::reflect_odd;
188 bcmap[
"Marshak"] = (int)amrex::LinOpBCType::Marshak;
189 bcmap[
"SanchezPomraning"] = (int)amrex::LinOpBCType::SanchezPomraning;
190 bcmap[
"inflow"] = (int)amrex::LinOpBCType::inflow;
191 bcmap[
"Periodic"] = (int)amrex::LinOpBCType::Periodic;
192 bcmap[
"periodic"] = (int)amrex::LinOpBCType::Periodic;
200 #if AMREX_SPACEDIM == 3
207 std::vector<std::string> str;
209 for (
unsigned int i = 0; i < str.size(); i++)
if (!bcmap.count(str[i]))
Util::Exception(
INFO,
"Invalid BC: ", str[i]);
210 if (str.size() == value.
m_ncomp)
for (
unsigned int i = 0; i < value.
m_ncomp; i++) value.
m_bc_type[Face::XLO].push_back(bcmap[str[i]]);
211 else if (str.size() == 1) value.
m_bc_type[Face::XLO].resize(value.
m_ncomp, bcmap[str[0]]);
214 for (
unsigned int i = 0; i < str.size(); i++)
if (!bcmap.count(str[i]))
Util::Exception(
INFO,
"Invalid BC: ", str[i]);
215 if (str.size() == value.
m_ncomp)
for (
unsigned int i = 0; i < value.
m_ncomp; i++) value.
m_bc_type[Face::XHI].push_back(bcmap[str[i]]);
216 else if (str.size() == 1) value.
m_bc_type[Face::XHI].resize(value.
m_ncomp, bcmap[str[0]]);
219 for (
unsigned int i = 0; i < str.size(); i++)
if (!bcmap.count(str[i]))
Util::Exception(
INFO,
"Invalid BC: ", str[i]);
220 if (str.size() == value.
m_ncomp)
for (
unsigned int i = 0; i < value.
m_ncomp; i++) value.
m_bc_type[Face::YLO].push_back(bcmap[str[i]]);
221 else if (str.size() == 1) value.
m_bc_type[Face::YLO].resize(value.
m_ncomp, bcmap[str[0]]);
224 for (
unsigned int i = 0; i < str.size(); i++)
if (!bcmap.count(str[i]))
Util::Exception(
INFO,
"Invalid BC: ", str[i]);
225 if (str.size() == value.
m_ncomp)
for (
unsigned int i = 0; i < value.
m_ncomp; i++) value.
m_bc_type[Face::YHI].push_back(bcmap[str[i]]);
226 else if (str.size() == 1) value.
m_bc_type[Face::YHI].resize(value.
m_ncomp, bcmap[str[0]]);
229 #if AMREX_SPACEDIM==3
230 for (
unsigned int i = 0; i < str.size(); i++)
if (!bcmap.count(str[i]))
Util::Exception(
INFO,
"Invalid BC: ", str[i]);
231 if (str.size() == value.
m_ncomp)
for (
unsigned int i = 0; i < value.
m_ncomp; i++) value.
m_bc_type[Face::ZLO].push_back(bcmap[str[i]]);
232 else if (str.size() == 1) value.
m_bc_type[Face::ZLO].resize(value.
m_ncomp, bcmap[str[0]]);
236 #if AMREX_SPACEDIM==3
237 for (
unsigned int i = 0; i < str.size(); i++)
if (!bcmap.count(str[i]))
Util::Exception(
INFO,
"Invalid BC: ", str[i]);
238 if (str.size() == value.
m_ncomp)
for (
unsigned int i = 0; i < value.
m_ncomp; i++) value.
m_bc_type[Face::ZHI].push_back(bcmap[str[i]]);
239 else if (str.size() == 1) value.
m_bc_type[Face::ZHI].resize(value.
m_ncomp, bcmap[str[0]]);
244 std::vector<std::string> val;
249 else if (val.size() == 0) value.
m_bc_val[Face::XLO].resize(value.
m_ncomp, 0.0);
255 else if (val.size() == 0) value.
m_bc_val[Face::XHI].resize(value.
m_ncomp, 0.0);
261 else if (val.size() == 0) value.
m_bc_val[Face::YLO].resize(value.
m_ncomp, 0.0);
267 else if (val.size() == 0) value.
m_bc_val[Face::YHI].resize(value.
m_ncomp, 0.0);
270 #if AMREX_SPACEDIM==3
274 else if (val.size() == 0) value.
m_bc_val[Face::ZLO].resize(value.
m_ncomp, 0.0);
278 #if AMREX_SPACEDIM==3
282 else if (val.size() == 0) value.
m_bc_val[Face::ZHI].resize(value.
m_ncomp, 0.0);