4 #ifndef BC_EXPRESSION_H_
5 #define BC_EXPRESSION_H_
7 #include <AMReX_ParallelDescriptor.H>
8 #include <AMReX_ParmParse.H>
9 #include <AMReX_BCRec.H>
10 #include <AMReX_PhysBCFunct.H>
11 #include <AMReX_Array.H>
12 #include <AMReX_Parser.H>
21 :
public BC<Set::Scalar>
26 static const constexpr
char *
const facestr[] = {
27 "xlo",
"ylo",
"xhi",
"yhi"
29 #elif AMREX_SPACEDIM==3
30 static const constexpr
char *
const facestr[] = {
31 "xlo",
"ylo",
"zlo",
"xhi",
"yhi",
"zhi",
40 #elif AMREX_SPACEDIM==3
42 XLO, YLO, ZLO, XHI, YHI, ZHI,
57 virtual void FillBoundary(amrex::BaseFab<Set::Scalar>& in,
const amrex::Box& box,
58 int ngrow,
int dcomp,
int ncomp, amrex::Real time,
60 const amrex::Mask* mask =
nullptr)
override;
65 virtual amrex::Array<int, AMREX_SPACEDIM>
IsPeriodic()
override;
66 virtual amrex::Periodicity
Periodicity()
const override;
67 virtual amrex::Periodicity
Periodicity(
const amrex::Box& b)
override;
72 const amrex::Array<amrex::Array<T, AMREX_SPACEDIM>, 2>
GetBCTypes()
81 static const int m_nfaces = 4;
82 #elif AMREX_SPACEDIM==3
83 static const int m_nfaces = 6;
90 std::array<std::vector<amrex::ParserExecutor<4>>, m_nfaces>
m_bc_func;
97 std::map<std::string, int> bcmap;
98 bcmap[
"BOGUS_BC"] = amrex::BCType::mathematicalBndryTypes::bogus;
99 bcmap[
"INT_DIR"] = amrex::BCType::mathematicalBndryTypes::int_dir;
100 bcmap[
"REFLECT_ODD"] = amrex::BCType::mathematicalBndryTypes::reflect_odd;
101 bcmap[
"INT_DIR"] = amrex::BCType::mathematicalBndryTypes::int_dir;
102 bcmap[
"REFLECT_EVEN"] = amrex::BCType::mathematicalBndryTypes::reflect_even;
103 bcmap[
"FOEXTRAP"] = amrex::BCType::mathematicalBndryTypes::foextrap;
104 bcmap[
"EXT_DIR"] = amrex::BCType::mathematicalBndryTypes::ext_dir;
105 bcmap[
"HOEXTRAP"] = amrex::BCType::mathematicalBndryTypes::hoextrap;
106 bcmap[
"Interior"] = amrex::BCType::mathematicalBndryTypes::int_dir;
107 bcmap[
"Inflow"] = amrex::BCType::mathematicalBndryTypes::ext_dir;
108 bcmap[
"Outflow"] = amrex::BCType::mathematicalBndryTypes::foextrap;
109 bcmap[
"Symmetry"] = amrex::BCType::mathematicalBndryTypes::reflect_even;
110 bcmap[
"SlipWall"] = amrex::BCType::mathematicalBndryTypes::ext_dir;
111 bcmap[
"NoSlipWall"] = amrex::BCType::mathematicalBndryTypes::ext_dir;
113 bcmap[
"interior"] = (int)amrex::LinOpBCType::interior;
114 bcmap[
"Dirichlet"] = (int)amrex::LinOpBCType::Dirichlet;
115 bcmap[
"dirichlet"] = (int)amrex::LinOpBCType::Dirichlet;
116 bcmap[
"Neumann"] = (int)amrex::LinOpBCType::Neumann;
117 bcmap[
"NEUMANN"] = (int)amrex::LinOpBCType::Neumann;
118 bcmap[
"neumann"] = (int)amrex::LinOpBCType::Neumann;
119 bcmap[
"reflect_odd"] = (int)amrex::LinOpBCType::reflect_odd;
120 bcmap[
"Marshak"] = (int)amrex::LinOpBCType::Marshak;
121 bcmap[
"SanchezPomraning"] = (int)amrex::LinOpBCType::SanchezPomraning;
122 bcmap[
"inflow"] = (int)amrex::LinOpBCType::inflow;
123 bcmap[
"Periodic"] = (int)amrex::LinOpBCType::Periodic;
124 bcmap[
"periodic"] = (int)amrex::LinOpBCType::Periodic;
130 std::vector<std::string> str;
132 for (
unsigned int i = 0; i < str.size(); i++)
if (!bcmap.count(str[i]))
Util::Abort(
INFO,
"Invalid BC: ", str[i]);
133 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]]);
134 else if (str.size() == 1) value.
m_bc_type[Face::XLO].resize(value.
m_ncomp, bcmap[str[0]]);
137 for (
unsigned int i = 0; i < str.size(); i++)
if (!bcmap.count(str[i]))
Util::Abort(
INFO,
"Invalid BC: ", str[i]);
138 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]]);
139 else if (str.size() == 1) value.
m_bc_type[Face::XHI].resize(value.
m_ncomp, bcmap[str[0]]);
142 for (
unsigned int i = 0; i < str.size(); i++)
if (!bcmap.count(str[i]))
Util::Abort(
INFO,
"Invalid BC: ", str[i]);
143 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]]);
144 else if (str.size() == 1) value.
m_bc_type[Face::YLO].resize(value.
m_ncomp, bcmap[str[0]]);
147 for (
unsigned int i = 0; i < str.size(); i++)
if (!bcmap.count(str[i]))
Util::Abort(
INFO,
"Invalid BC: ", str[i]);
148 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]]);
149 else if (str.size() == 1) value.
m_bc_type[Face::YHI].resize(value.
m_ncomp, bcmap[str[0]]);
152 #if AMREX_SPACEDIM==3
153 for (
unsigned int i = 0; i < str.size(); i++)
if (!bcmap.count(str[i]))
Util::Abort(
INFO,
"Invalid BC: ", str[i]);
154 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]]);
155 else if (str.size() == 1) value.
m_bc_type[Face::ZLO].resize(value.
m_ncomp, bcmap[str[0]]);
159 #if AMREX_SPACEDIM==3
160 for (
unsigned int i = 0; i < str.size(); i++)
if (!bcmap.count(str[i]))
Util::Abort(
INFO,
"Invalid BC: ", str[i]);
161 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]]);
162 else if (str.size() == 1) value.
m_bc_type[Face::ZHI].resize(value.
m_ncomp, bcmap[str[0]]);
167 std::vector<std::string> val;
168 for (
int face = 0; face != Face::INT; face++)
170 std::string querystr = std::string(
"val.") + std::string(facestr[face]);
172 else val.resize(value.
m_ncomp,
"0.0");
173 if (val.size() != value.
m_ncomp)
Util::Abort(
INFO,
"Incorrect number of expressions specified for ",querystr,
": expected 1 or ",value.
m_ncomp,
" but received ",val.size());
177 for (
unsigned int i = 0 ; i < value.
m_ncomp; i++)
185 #if AMREX_SPACEDIM==2
188 std::vector<std::string> ignore_in_2d = {
190 "zhixlo",
"zloxlo",
"zhixhi",
"zloxhi",
"ylozlo",
"ylozhi",
"yhizlo",
"yhizhi",
191 "xloylozlo",
"xloylozhi",
"xloyhizlo",
"xloyhizhi",
"xhiylozlo",
"xhiylozhi",
"xhiyhizlo",
"xhiyhizhi"};
193 for (
unsigned int n = 0; n < ignore_in_2d.size(); n++)
195 std::string querystr = std::string(
"val.") + ignore_in_2d[n];
198 querystr = std::string(
"type.") + ignore_in_2d[n];