DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
BoundaryCondition.hpp
Go to the documentation of this file.
1#pragma once
2#include "Geometric.hpp"
3#include "DNDS/MPI.hpp"
4#include <map>
5#include <functional>
6#include <unordered_map>
7
8namespace DNDS::Geom
9{
11 {
12 std::map<std::string, t_index> name_2_id;
13
14 void clear() { name_2_id.clear(); }
15
16 t_index operator[](const std::string &name)
17 {
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());
21 else
22 return (*found).second;
23 }
24 };
25
26 static const t_index BC_ID_INTERNAL = 0; // do not change
27 static const t_index BC_ID_PERIODIC_1 = -1; // * periodic-s do not count as external face
28 static const t_index BC_ID_PERIODIC_2 = -2; // but should be identified also
29 static const t_index BC_ID_PERIODIC_3 = -3;
30
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;
34
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;
39
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;
45
46 using t_FBCName_2_ID = std::function<t_index(const std::string &)>;
47 using t_FBCID_2_Name = std::function<std::string(t_index)>;
48
50 {
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}};
68 return ret;
69 }
70
71 static const t_FBCName_2_ID FBC_Name_2_ID_Default = [](const std::string &name) -> t_index
72 {
73 // if (name == "PERIODI
74 auto n2id_map = GetFaceName2IDDefault();
75 if (n2id_map.count(name))
76 return n2id_map.at(name);
77 return BC_ID_NULL;
78 };
79
81 {
82 return id > 0;
83 }
84
86 {
87 return id <= 0;
88 }
89
91 {
92 return id == 0;
93 }
94
96 {
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;
103 }
104
106 {
107 return id == BC_ID_PERIODIC_1 ||
108 id == BC_ID_PERIODIC_1_DONOR;
109 }
110
112 {
113 return id == BC_ID_PERIODIC_2 ||
114 id == BC_ID_PERIODIC_2_DONOR;
115 }
116
118 {
119 return id == BC_ID_PERIODIC_3 ||
120 id == BC_ID_PERIODIC_3_DONOR;
121 }
122
124 {
125 return id == BC_ID_PERIODIC_1 ||
126 id == BC_ID_PERIODIC_2 ||
127 id == BC_ID_PERIODIC_3;
128 }
129
131 {
132 return id == BC_ID_PERIODIC_1_DONOR ||
133 id == BC_ID_PERIODIC_2_DONOR ||
134 id == BC_ID_PERIODIC_3_DONOR;
135 }
136
137} // namespace DNDS::Geom
138
139namespace DNDS::Geom
140{
141 struct AutoAppendName2ID
142 {
143 std::unordered_map<std::string, t_index> n2id_map = GetFaceName2IDDefault();
144 t_index id_cap = BC_ID_DEFAULT_MAX;
145
146 AutoAppendName2ID()
147 {
148 for (auto [k, v] : n2id_map)
149 id_cap = std::max(v + 1, id_cap);
150 }
151
152 t_index operator()(const std::string name)
153 {
154 if (n2id_map.count(name))
155 return n2id_map.at(name);
156 else
157 {
158 n2id_map[name] = id_cap;
159 id_cap++;
160 return id_cap - 1;
161 }
162 }
163 };
164}
#define DNDS_DEVICE_CALLABLE
Definition Defines.hpp:76
MPI wrappers: MPIInfo, collective operations, type mapping, CommStrategy.
DNDS_DEVICE_CALLABLE bool FaceIDIsTrueInternal(t_index id)
int32_t t_index
Definition Geometric.hpp:6
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