19 const std::vector<ElementBases> &bases,
20 const std::vector<ElementBases> &geom_bases,
21 const std::vector<ElementBases> &pressure_bases,
22 std::vector<LocalBoundary> &local_boundary,
23 std::vector<int> &boundary_nodes,
24 std::vector<LocalBoundary> &local_neumann_boundary,
25 std::vector<LocalBoundary> &local_pressure_boundary,
26 std::unordered_map<
int, std::vector<LocalBoundary>> &local_pressure_cavity,
27 std::vector<int> &pressure_boundary_nodes,
28 std::vector<int> &dirichlet_nodes,
29 std::vector<int> &neumann_nodes)
31 std::vector<LocalBoundary> new_local_boundary;
32 std::vector<LocalBoundary> new_local_pressure_dirichlet_boundary;
33 local_neumann_boundary.clear();
34 local_pressure_boundary.clear();
35 local_pressure_cavity.clear();
37 for (
auto it = local_boundary.begin(); it != local_boundary.end(); ++it)
43 LocalBoundary new_pressure_dirichlet_lb(lb.element_id(), lb.type());
44 for (
int i = 0; i < lb.size(); ++i)
46 LocalBoundary new_pressure_cavity_lb(lb.element_id(), lb.type());
48 const int primitive_g_id = lb.global_primitive_id(i);
67 if (!new_pressure_cavity_lb.
empty())
69 if (local_pressure_cavity.find(tag) == local_pressure_cavity.end())
70 local_pressure_cavity[tag] = std::vector<LocalBoundary>();
71 local_pressure_cavity[tag].emplace_back(new_pressure_cavity_lb);
76 new_local_boundary.emplace_back(new_lb);
77 if (!new_neumann_lb.
empty())
78 local_neumann_boundary.emplace_back(new_neumann_lb);
79 if (!new_pressure_lb.
empty())
80 local_pressure_boundary.emplace_back(new_pressure_lb);
81 if (!new_pressure_dirichlet_lb.
empty())
82 new_local_pressure_dirichlet_boundary.emplace_back(new_pressure_dirichlet_lb);
84 local_boundary.clear();
85 std::swap(local_boundary, new_local_boundary);
87 boundary_nodes.clear();
88 pressure_boundary_nodes.clear();
92 for (
auto it = local_boundary.begin(); it != local_boundary.end(); ++it)
95 const auto &b = bases[lb.element_id()];
96 for (
int i = 0; i < lb.size(); ++i)
98 const int primitive_global_id = lb.global_primitive_id(i);
99 const auto nodes = b.local_nodes_for_primitive(primitive_global_id, mesh);
101 for (
long n = 0; n < nodes.size(); ++n)
103 auto &bs = b.bases[nodes(n)];
104 for (
size_t g = 0; g < bs.global().size(); ++g)
106 const int base_index = bs.global()[g].index * dim;
107 for (
int d = 0; d < dim; ++d)
110 boundary_nodes.push_back(base_index + d);
117 for (
auto it = new_local_pressure_dirichlet_boundary.begin(); it != new_local_pressure_dirichlet_boundary.end(); ++it)
119 const auto &lb = *it;
120 const auto &b = pressure_bases[lb.element_id()];
121 for (
int i = 0; i < lb.size(); ++i)
123 const int primitive_global_id = lb.global_primitive_id(i);
124 const auto nodes = b.local_nodes_for_primitive(primitive_global_id, mesh);
126 for (
long n = 0; n < nodes.size(); ++n)
128 auto &bs = b.bases[nodes(n)];
129 for (
size_t g = 0; g < bs.global().size(); ++g)
131 const int base_index = bs.global()[g].index;
132 pressure_boundary_nodes.push_back(base_index);
140 for (
int n_id = 0; n_id < n_bases; ++n_id)
146 dirichlet_nodes.push_back(n_id);
148 for (
int d = 0; d < dim; ++d)
151 boundary_nodes.push_back(n_id * dim + d);
156 neumann_nodes.push_back(n_id);
161 std::sort(boundary_nodes.begin(), boundary_nodes.end());
162 auto it = std::unique(boundary_nodes.begin(), boundary_nodes.end());
163 boundary_nodes.resize(std::distance(boundary_nodes.begin(), it));
165 std::sort(pressure_boundary_nodes.begin(), pressure_boundary_nodes.end());
166 auto it_ = std::unique(pressure_boundary_nodes.begin(), pressure_boundary_nodes.end());
167 pressure_boundary_nodes.resize(std::distance(pressure_boundary_nodes.begin(), it_));
void setup_bc(const mesh::Mesh &mesh, const int n_bases, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &geom_bases, const std::vector< basis::ElementBases > &pressure_bases, std::vector< mesh::LocalBoundary > &local_boundary, std::vector< int > &boundary_nodes, std::vector< mesh::LocalBoundary > &local_neumann_boundary, std::vector< mesh::LocalBoundary > &local_pressure_boundary, std::unordered_map< int, std::vector< mesh::LocalBoundary > > &local_pressure_cavity, std::vector< int > &pressure_boundary_nodes, std::vector< int > &dirichlet_nodes, std::vector< int > &neumann_nodes)