6#include <unordered_map>
12 std::map<std::string, t_index> name_2_id;
14 void clear() { name_2_id.clear(); }
16 t_index operator[](
const std::string &name)
18 auto found = name_2_id.find(name);
19 if (found == name_2_id.end())
20 return name_2_id[name] =
static_cast<t_index>(name_2_id.size());
22 return (*found).second;
26 static const t_index BC_ID_INTERNAL = 0;
27 static const t_index BC_ID_PERIODIC_1 = -1;
28 static const t_index BC_ID_PERIODIC_2 = -2;
29 static const t_index BC_ID_PERIODIC_3 = -3;
31 static const t_index BC_ID_PERIODIC_1_DONOR = -4;
32 static const t_index BC_ID_PERIODIC_2_DONOR = -5;
33 static const t_index BC_ID_PERIODIC_3_DONOR = -6;
35 static const t_index BC_ID_NULL = 1;
36 static const t_index BC_ID_DEFAULT_WALL = 2;
37 static const t_index BC_ID_DEFAULT_FAR = 3;
38 static const t_index BC_ID_DEFAULT_WALL_INVIS = 4;
40 static const t_index BC_ID_DEFAULT_SPECIAL_DMR_FAR = 11;
41 static const t_index BC_ID_DEFAULT_SPECIAL_RT_FAR = 12;
42 static const t_index BC_ID_DEFAULT_SPECIAL_IV_FAR = 13;
43 static const t_index BC_ID_DEFAULT_SPECIAL_2DRiemann_FAR = 14;
44 static const t_index BC_ID_DEFAULT_MAX = 20;
51 std::unordered_map<std::string, t_index> ret = {
52 {
"PERIODIC_1", BC_ID_PERIODIC_1},
53 {
"PERIODIC_2", BC_ID_PERIODIC_2},
54 {
"PERIODIC_3", BC_ID_PERIODIC_3},
55 {
"PERIODIC_1_DONOR", BC_ID_PERIODIC_1_DONOR},
56 {
"PERIODIC_2_DONOR", BC_ID_PERIODIC_2_DONOR},
57 {
"PERIODIC_3_DONOR", BC_ID_PERIODIC_3_DONOR},
58 {
"WALL", BC_ID_DEFAULT_WALL},
59 {
"bc-4", BC_ID_DEFAULT_WALL},
60 {
"FAR", BC_ID_DEFAULT_FAR},
61 {
"bc-2", BC_ID_DEFAULT_FAR},
62 {
"WALL_INVIS", BC_ID_DEFAULT_WALL_INVIS},
63 {
"bc-3", BC_ID_DEFAULT_WALL_INVIS},
64 {
"bc-DMRFar", BC_ID_DEFAULT_SPECIAL_DMR_FAR},
65 {
"bc-IVFar", BC_ID_DEFAULT_SPECIAL_IV_FAR},
66 {
"bc-RTFar", BC_ID_DEFAULT_SPECIAL_RT_FAR},
67 {
"bc-2DRiemannFar", BC_ID_DEFAULT_SPECIAL_2DRiemann_FAR}};
75 if (n2id_map.count(name))
76 return n2id_map.at(name);
97 return id == BC_ID_PERIODIC_1 ||
98 id == BC_ID_PERIODIC_2 ||
99 id == BC_ID_PERIODIC_3 ||
100 id == BC_ID_PERIODIC_1_DONOR ||
101 id == BC_ID_PERIODIC_2_DONOR ||
102 id == BC_ID_PERIODIC_3_DONOR;
107 return id == BC_ID_PERIODIC_1 ||
108 id == BC_ID_PERIODIC_1_DONOR;
113 return id == BC_ID_PERIODIC_2 ||
114 id == BC_ID_PERIODIC_2_DONOR;
119 return id == BC_ID_PERIODIC_3 ||
120 id == BC_ID_PERIODIC_3_DONOR;
125 return id == BC_ID_PERIODIC_1 ||
126 id == BC_ID_PERIODIC_2 ||
127 id == BC_ID_PERIODIC_3;
132 return id == BC_ID_PERIODIC_1_DONOR ||
133 id == BC_ID_PERIODIC_2_DONOR ||
134 id == BC_ID_PERIODIC_3_DONOR;
141 struct AutoAppendName2ID
144 t_index id_cap = BC_ID_DEFAULT_MAX;
148 for (
auto [k,
v] : n2id_map)
149 id_cap = std::max(
v + 1, id_cap);
152 t_index operator()(
const std::string name)
154 if (n2id_map.count(name))
155 return n2id_map.at(name);
158 n2id_map[name] = id_cap;
#define DNDS_DEVICE_CALLABLE
MPI wrappers: MPIInfo, collective operations, type mapping, CommStrategy.
DNDS_DEVICE_CALLABLE bool FaceIDIsTrueInternal(t_index id)
DNDS_DEVICE_CALLABLE bool FaceIDIsInternal(t_index id)
std::function< std::string(t_index)> t_FBCID_2_Name
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodic(t_index id)
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodicDonor(t_index id)
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodicMain(t_index id)
std::function< t_index(const std::string &)> t_FBCName_2_ID
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodic3(t_index id)
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodic2(t_index id)
DNDS_DEVICE_CALLABLE bool FaceIDIsExternalBC(t_index id)
auto GetFaceName2IDDefault()
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodic1(t_index id)
Eigen::Matrix< real, 5, 1 > v