43 const double r_small = 0.154 / 2;
44 const double r_large = 0.254 / 2;
45 const double half_len_bot = 0.924 / 2;
46 const double half_len_cone = 0.285 / 2;
47 const double half_len_top = 0.5 / 2;
48 const double chimney_length = 0.1;
49 const unsigned int n_chimney_refinements = 1;
50 const unsigned int n_axial_bot = 10;
51 const unsigned int n_axial_top = 5;
52 const unsigned int n_axial_chimney = 2;
53 const double tol = 1e-10;
60 const double extended_half_len_bot = half_len_bot +
inlet_offset / 2.0;
61 const unsigned int n_axial_bot_total =
63 static_cast<unsigned int>(
64 std::round(n_axial_bot * (2.0 * half_len_bot +
inlet_offset) /
65 (2.0 * half_len_bot))));
67 Triangulation<3> tria_bottom;
68 GridGenerator::subdivided_cylinder(tria_bottom,
71 extended_half_len_bot);
72 GridTools::shift(Point<3>(half_len_bot -
inlet_offset / 2.0, 0, 0),
77 Triangulation<3> tria_cone;
78 GridGenerator::truncated_cone(tria_cone, r_small, r_large, half_len_cone);
79 GridTools::shift(Point<3>(2.0 * half_len_bot + half_len_cone, 0, 0),
84 Triangulation<3> tria_top;
85 GridGenerator::subdivided_cylinder(tria_top,
90 Point<3>(2.0 * half_len_bot + 2.0 * half_len_cone + half_len_top, 0, 0),
94 const double base_length =
95 2.0 * (half_len_bot + half_len_cone + half_len_top);
98 Triangulation<3> tria_temp1;
99 GridGenerator::merge_triangulations(tria_bottom, tria_cone, tria_temp1);
100 Triangulation<3> tria_merged;
101 GridGenerator::merge_triangulations(tria_temp1, tria_top, tria_merged);
109 for (
const auto &cell : tria_merged.active_cell_iterators())
111 cell->set_manifold_id(0);
112 for (
unsigned int f = 0; f < GeometryInfo<3>::faces_per_cell; ++f)
114 if (!cell->face(f)->at_boundary())
117 bool is_end_cap =
true;
118 for (
unsigned int v = 0; v < GeometryInfo<3>::vertices_per_face;
121 const double x = cell->face(f)->vertex(v)[0];
123 std::abs(x - base_length) > tol)
131 cell->face(f)->set_manifold_id(1);
132 for (
unsigned int l = 0; l < GeometryInfo<3>::lines_per_face;
134 cell->face(f)->line(l)->set_manifold_id(1);
139 tria_merged.set_manifold(1, CylindricalManifold<3>(0));
140 tria_merged.set_manifold(0, FlatManifold<3>());
142 tria_merged.refine_global(n_chimney_refinements);
148 Triangulation<3> tria_flat;
149 GridGenerator::flatten_triangulation(tria_merged, tria_flat);
154 const Point<3> chimney_target(base_length, 0.0, r_large / 2.0);
156 double best_dist_sq = r_large * r_large + 1.0;
157 std::array<Point<3>, 4> best_face_vertices;
159 for (
const auto &cell : tria_flat.active_cell_iterators())
160 for (
unsigned int f = 0; f < GeometryInfo<3>::faces_per_cell; ++f)
162 if (!cell->face(f)->at_boundary())
164 const auto &face = cell->face(f);
167 bool on_top_cap =
true;
168 for (
unsigned int v = 0; v < GeometryInfo<3>::vertices_per_face;
170 if (std::abs(face->vertex(v)[0] - base_length) > tol)
178 const Point<3> center = face->center();
179 const double dist_sq = (center - chimney_target).norm_square();
181 if (dist_sq < best_dist_sq)
183 best_dist_sq = dist_sq;
184 for (
unsigned int v = 0; v < 4; ++v)
185 best_face_vertices[v] = face->vertex(v);
189 AssertThrow(best_dist_sq < r_large * r_large,
191 "Could not find a suitable face on the top end cap "
192 "for the chimney placement."));
199 Point<3> face_center;
200 for (
const auto &p : best_face_vertices)
204 std::array<Point<3>, 4> sorted_fv;
205 for (
const auto &p : best_face_vertices)
207 unsigned int idx = 0;
208 if (p[1] > face_center[1])
210 if (p[2] > face_center[2])
217 const unsigned int n_layers = n_axial_chimney;
218 std::vector<Point<3>> chimney_vertices(4 * (n_layers + 1));
219 for (
unsigned int layer = 0; layer <= n_layers; ++layer)
221 const double dx = chimney_length * layer / n_layers;
222 for (
unsigned int v = 0; v < 4; ++v)
224 chimney_vertices[layer * 4 + v] = sorted_fv[v];
225 chimney_vertices[layer * 4 + v][0] += dx;
232 std::vector<CellData<3>> chimney_cells(n_layers);
233 for (
unsigned int layer = 0; layer < n_layers; ++layer)
235 const unsigned int L = layer * 4;
236 const unsigned int R = (layer + 1) * 4;
237 chimney_cells[layer].vertices = {L + 0,
247 Triangulation<3> tria_chimney;
248 tria_chimney.create_triangulation(chimney_vertices,
254 GridGenerator::merge_triangulations(tria_flat,
264 const double total_length = base_length + chimney_length;
266 for (
const auto &cell : triangulation.active_cell_iterators())
268 cell->set_manifold_id(0);
269 for (
unsigned int f = 0; f < GeometryInfo<3>::faces_per_cell; ++f)
271 if (!cell->face(f)->at_boundary())
274 bool is_inlet =
true;
275 bool is_outlet =
true;
276 bool at_or_beyond_base =
true;
278 for (
unsigned int v = 0; v < GeometryInfo<3>::vertices_per_face;
281 const double x = cell->face(f)->vertex(v)[0];
284 if (std::abs(x - total_length) > tol)
286 if (x < base_length - tol)
287 at_or_beyond_base =
false;
292 cell->face(f)->set_boundary_id(1);
296 cell->face(f)->set_boundary_id(2);
298 else if (at_or_beyond_base)
302 cell->face(f)->set_boundary_id(0);
307 cell->face(f)->set_manifold_id(1);
308 for (
unsigned int l = 0; l < GeometryInfo<3>::lines_per_face;
310 cell->face(f)->line(l)->set_manifold_id(1);
311 cell->face(f)->set_boundary_id(0);
316 triangulation.set_manifold(1, CylindricalManifold<3>(0));
317 triangulation.set_manifold(0, FlatManifold<3>());
323 triangulation.copy_triangulation(tria_merged);
325 for (
const auto &cell : triangulation.active_cell_iterators())
327 cell->set_manifold_id(0);
328 for (
unsigned int f = 0; f < GeometryInfo<3>::faces_per_cell; ++f)
330 if (!cell->face(f)->at_boundary())
333 bool is_end_cap =
true;
334 for (
unsigned int v = 0; v < GeometryInfo<3>::vertices_per_face;
337 const double x = cell->face(f)->vertex(v)[0];
339 std::abs(x - base_length) > tol)
348 cell->face(f)->set_manifold_id(1);
349 for (
unsigned int l = 0; l < GeometryInfo<3>::lines_per_face;
351 cell->face(f)->line(l)->set_manifold_id(1);
352 cell->face(f)->set_boundary_id(0);
356 const double x = cell->face(f)->center()[0];
358 cell->face(f)->set_boundary_id(1);
360 cell->face(f)->set_boundary_id(2);
365 triangulation.set_manifold(1, CylindricalManifold<3>(0));
366 triangulation.set_manifold(0, FlatManifold<3>());