Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
grid_impinging_jet_mixer.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
5
6#include <deal.II/base/point.h>
7
8#include <deal.II/grid/cell_data.h>
9#include <deal.II/grid/grid_generator.h>
10#include <deal.II/grid/grid_tools.h>
11#include <deal.II/grid/manifold_lib.h>
12#include <deal.II/grid/tria.h>
13
14#include <array>
15#include <cmath>
16#include <limits>
17#include <map>
18#include <set>
19#include <vector>
20
21namespace
22{
23 // The mixer geometry dimensions live in the MixerGeometry struct declared in
24 // the header (the single container for those dimensions); they are parsed
25 // from the grid arguments in the constructor. The vessel is first built in a
26 // construction datum whose origin sits on the chamber floor: there the
27 // chamber spans z in [0, H_chamber], the conical reduction and the outlet
28 // pipe hang below it at negative z, and the dome caps it from above. All the
29 // derived axial coordinates (z_cone_bottom, z_outlet_bottom, ...) and all
30 // boundary-id assignments are expressed in that frame. This construction
31 // datum is NOT the datum of the delivered mesh: as a final step make_grid()
32 // rigidly shifts the whole mesh downward by the locked inlet-axis height, so
33 // that in the delivered mesh z = 0 is the common axis of the two inlet pipes
34 // (the impingement plane) and the chamber floor ends up at z = -inlet_axis_z.
35
36 // Discretisation parameters
37 // -------------------------
38 // The axial subdivisions below are chosen so that, after global refinement,
39 // every region carries axial cells close to the size of the chamber
40 // wall faces (which is itself set by the circumferential resolution, so that
41 // the wall faces are square). Keeping all regions near that single target
42 // size makes the volumetric mesh about as uniform as this topology allows,
43 // and avoids the previous strong over-refinement of the (short) cone and
44 // outlet sections. This worked well for the parameter set I tested but I
45 // am not sure this will work for arbitrary configurations. This will
46 // need to be tested down the road.
47 // chamber : 0.16 / (2 * 8) = 0.0100
48 // cone : 0.06 / (1 * 8) = 0.0075
49 // outlet : 0.05 / (1 * 8) = 0.0063
50 // pipe : 0.08 / 6 = 0.0133 (matches the ~r_inlet/3 cross-section)
51 constexpr unsigned int chamber_axial_subdiv = 2;
52 constexpr unsigned int cone_axial_subdiv = 1;
53 constexpr unsigned int outlet_axial_subdiv = 1;
54 // global_refinements sets the circumferential/radial (and thus the wall)
55 // resolution. It is effectively fixed at 3: it is what keeps the chamber
56 // wall a 32-faceted circle, so the 3x3 inlet-port patch stays smaller than
57 // the inlet diameter and maps onto the inlet circle with little chamber
58 // distortion. Lowering it makes the wall coarse and blocky at the ports.
59 constexpr unsigned int global_refinements = 3; // wall resolution for ports
60 // Cells along each inlet pipe. Six layers give correct cell size, matching
61 // the in-plane pipe cell size (r_inlet mapped through the 3x3 patch) so the
62 // pipe cells stay roughly cubic instead of being stretched along the axis.
63 constexpr unsigned int n_pipe_layers = 6; // cells along the pipe axis
64
65 // --- Manifold ids. ------------------------------------------------------
66 constexpr types::manifold_id cylinder_z_manifold_id = 0;
67 constexpr types::manifold_id dome_manifold_id = 1;
68 constexpr types::manifold_id inlet_manifold_id = 2;
69
70 // --- Boundary ids. ------------------------------------------------------
71 constexpr types::boundary_id inlet1_boundary_id = 0; // +x
72 constexpr types::boundary_id inlet2_boundary_id = 1; // -x
73 constexpr types::boundary_id outlet_boundary_id = 2;
74 constexpr types::boundary_id wall_boundary_id = 3;
75
76 // --- Material ids (internal: used only to tag the inlet-pipe cells vs the
77 // vessel cells so the correct manifold can be assigned to each). ------
78 constexpr types::material_id vessel_material_id = 0;
79 constexpr types::material_id pipe_material_id = 1;
80 // The central pipe column straddles the pipe axis, where the pipe's
81 // cylinder-about-x manifold is singular; it is tagged separately so it can be
82 // left flat while the surrounding ring cells take the cylindrical manifold.
83 constexpr types::material_id pipe_core_material_id = 2;
84
85 // Rotation mapping the native cylinder axis (+x) onto the mixer axis (+z):
86 // a rotation of -pi/2 about +y sends (1,0,0) -> (0,0,1).
87 void
88 align_x_axis_to_z(Triangulation<3> &tria)
89 {
90 GridTools::rotate(Tensor<1, 3>({0., 1., 0.}), -numbers::PI_2, tria);
91 }
92
93 // Relabel every boundary face (and its lines) with manifold id `from` to id
94 // `to` (used to give the dome its own spherical-manifold id before merging).
95 void
96 relabel_manifold(Triangulation<3> &tria,
97 const types::manifold_id from,
98 const types::manifold_id to)
99 {
100 for (const auto &cell : tria.active_cell_iterators())
101 for (const unsigned int f : GeometryInfo<3>::face_indices())
102 if (cell->face(f)->at_boundary() &&
103 cell->face(f)->manifold_id() == from)
104 cell->face(f)->set_all_manifold_ids(to);
105 }
106
107 // Build the vessel (chamber + dome + reduction + outlet) as one conforming,
108 // manifold-equipped triangulation.
109 void
110 build_vessel(Triangulation<3> &vessel, const MixerGeometry &g)
111 {
112 // Mixing chamber: vertical cylinder of radius R_chamber,
113 // z in [0, H_chamber].
114 Triangulation<3> chamber;
115 GridGenerator::subdivided_cylinder(chamber,
116 chamber_axial_subdiv,
117 g.R_chamber,
118 g.H_chamber / 2.0);
119 align_x_axis_to_z(chamber);
120 GridTools::shift(Tensor<1, 3>({0., 0., g.H_chamber / 2.0}), chamber);
121
122 // Hemispherical dome closing the top; it shares the chamber's cross
123 // section.
124 Triangulation<3> dome;
125 GridGenerator::half_hyper_ball(dome, Point<3>(0, 0, 0), g.R_chamber);
126 align_x_axis_to_z(dome);
127 GridTools::shift(Tensor<1, 3>({0., 0., g.z_dome_center()}), dome);
128 relabel_manifold(dome, cylinder_z_manifold_id, dome_manifold_id);
129
130 // Conical reduction R_chamber -> r_outlet, built as a cylinder whose radius
131 // is tapered linearly along the axis so it keeps the chamber's cross
132 // section and merges conformingly with both the chamber and the outlet
133 // pipe.
134 Triangulation<3> cone;
135 GridGenerator::subdivided_cylinder(cone,
136 cone_axial_subdiv,
137 g.R_chamber,
138 g.L_cone / 2.0);
139 GridTools::transform(
140 [&g](const Point<3> &p) {
141 const double s = (p[0] + g.L_cone / 2.0) / g.L_cone; // 0 at -x, 1 at +x
142 const double factor =
143 g.r_outlet / g.R_chamber + s * (1.0 - g.r_outlet / g.R_chamber);
144 return Point<3>(p[0], factor * p[1], factor * p[2]);
145 },
146 cone);
147 align_x_axis_to_z(cone);
148 GridTools::shift(Tensor<1, 3>({0., 0., g.z_cone_bottom() + g.L_cone / 2.0}),
149 cone);
150
151 // Straight outlet pipe of radius r_outlet.
152 Triangulation<3> outlet;
153 GridGenerator::subdivided_cylinder(outlet,
154 outlet_axial_subdiv,
155 g.r_outlet,
156 g.L_outlet / 2.0);
157 align_x_axis_to_z(outlet);
158 GridTools::shift(
159 Tensor<1, 3>({0., 0., g.z_outlet_bottom() + g.L_outlet / 2.0}), outlet);
160
161 const double tol = 1e-6 * g.r_outlet;
162 GridGenerator::merge_triangulations({&chamber, &dome, &cone, &outlet},
163 vessel,
164 tol,
165 /*copy_manifold_ids=*/true,
166 /*copy_boundary_ids=*/false);
167
168 vessel.set_manifold(cylinder_z_manifold_id,
169 CylindricalManifold<3>(Tensor<1, 3>({0., 0., 1.}),
170 Point<3>(0., 0., 0.)));
171 vessel.set_manifold(dome_manifold_id,
172 SphericalManifold<3>(
173 Point<3>(0., 0., g.z_dome_center())));
174 }
175} // namespace
176
177
178template <int dim, int spacedim>
180 const std::string &grid_arguments)
181{
182 if constexpr (!(dim == 3 && spacedim == 3))
183 {
184 AssertThrow(
185 false,
186 ExcMessage(
187 "The impinging-jet mixer mesh is only supported in 3D space with 3D elements."));
188 }
189
190 this->grid_arguments = grid_arguments;
191
192 // The geometry dimensions default to the values set in the header. An empty
193 // argument string keeps those defaults; otherwise all eight dimensions must
194 // be supplied, colon-separated, in this order:
195 // R_chamber:r_inlet:r_outlet:H_chamber:L_cone:L_outlet:L_inlet:z_inlet
196 // (The discretisation is intentionally not exposed and stays hardcoded for
197 // now.)
198 if (!grid_arguments.empty())
199 {
200 AssertThrow(grid_arguments.find(';') == std::string::npos,
201 ExcMessage(
202 "The impinging-jet mixer grid arguments must be separated "
203 "by colons (:), not semicolons (;)."));
204
205 const std::vector<std::string> tokens =
206 Utilities::split_string_list(grid_arguments, ':');
207 AssertThrow(
208 tokens.size() == 8,
209 ExcMessage(
210 "The impinging-jet mixer expects exactly 8 colon-separated geometry "
211 "arguments, in the order "
212 "R_chamber:r_inlet:r_outlet:H_chamber:L_cone:L_outlet:L_inlet:"
213 "z_inlet."));
214
215 this->geometry.R_chamber = Utilities::string_to_double(tokens[0]);
216 this->geometry.r_inlet = Utilities::string_to_double(tokens[1]);
217 this->geometry.r_outlet = Utilities::string_to_double(tokens[2]);
218 this->geometry.H_chamber = Utilities::string_to_double(tokens[3]);
219 this->geometry.L_cone = Utilities::string_to_double(tokens[4]);
220 this->geometry.L_outlet = Utilities::string_to_double(tokens[5]);
221 this->geometry.L_inlet = Utilities::string_to_double(tokens[6]);
222 this->geometry.z_inlet = Utilities::string_to_double(tokens[7]);
223 }
224
225 // Sanity checks: all dimensions positive, the inlet/outlet pipes fit inside
226 // the chamber cross-section, and the inlet axis lies strictly inside the
227 // cylindrical part of the chamber wall (where the port patch is grown).
228 const MixerGeometry &g = this->geometry;
229 AssertThrow(g.R_chamber > 0.0 && g.r_inlet > 0.0 && g.r_outlet > 0.0 &&
230 g.H_chamber > 0.0 && g.L_cone > 0.0 && g.L_outlet > 0.0 &&
231 g.L_inlet > 0.0,
232 ExcMessage("All impinging-jet mixer dimensions must be strictly "
233 "positive."));
234 AssertThrow(g.r_inlet < g.R_chamber && g.r_outlet < g.R_chamber,
235 ExcMessage("The inlet and outlet radii must be smaller than the "
236 "chamber radius."));
237 AssertThrow(g.z_inlet > 0.0 && g.z_inlet < g.H_chamber,
238 ExcMessage("The inlet axis height (z_inlet) must lie strictly "
239 "between the chamber floor (0) and its top "
240 "(H_chamber)."));
241}
242
243
244template <>
245void
246GridImpingingJetMixer<3, 3>::make_grid(Triangulation<3, 3> &triangulation)
247{
248 // All geometry dimensions come from the single MixerGeometry member. The
249 // individual dimensions and derived axial coordinates that the rest of the
250 // code refers to by name are aliased as locals here to facilitate
251 // understanding.
252 const MixerGeometry &g = this->geometry;
253 const double R_chamber = g.R_chamber;
254 const double r_inlet = g.r_inlet;
255 const double L_inlet = g.L_inlet;
256 const double z_inlet = g.z_inlet;
257 const double z_chamber_top = g.z_chamber_top();
258 const double z_outlet_bottom = g.z_outlet_bottom();
259 const double z_dome_center = g.z_dome_center();
260
261 // ---------------------------------------------------------------------
262 // 1. Vessel, refined so the chamber wall carries fine faces, then
263 // flattened into a plain coarse mesh whose curved geometry is baked in.
264 // ---------------------------------------------------------------------
265 Triangulation<3> vessel;
266 build_vessel(vessel, g);
267 // Rotate the chamber about its axis by half a refined wall-face width so that
268 // a wall face ends up centered on the +/- x meridian. The inlet-port patch
269 // is then symmetric about +/- x and each tube stays aligned with the x-axis.
270 // (The z-cylinder and dome manifolds are invariant under this rotation.)
271 GridTools::rotate(Tensor<1, 3>({0., 0., 1.}),
272 numbers::PI_4 / std::pow(2.0, global_refinements),
273 vessel);
274 vessel.refine_global(global_refinements);
275
276 Triangulation<3> flat_vessel;
277 GridGenerator::flatten_triangulation(vessel, flat_vessel);
278
279 // ---------------------------------------------------------------------
280 // 2. Copy the vessel cells into a (vertices, cells) description we can add
281 // the inlet-pipe cells to.
282 // ---------------------------------------------------------------------
283 std::vector<Point<3>> vertices = flat_vessel.get_vertices();
284 std::vector<CellData<3>> cells;
285 for (const auto &cell : flat_vessel.active_cell_iterators())
286 {
287 CellData<3> cell_data;
288 for (const unsigned int v : GeometryInfo<3>::vertex_indices())
289 cell_data.vertices[v] = cell->vertex_index(v);
290 cell_data.material_id = vessel_material_id;
291 cells.push_back(cell_data);
292 }
293
294 // ---------------------------------------------------------------------
295 // 3. For each inlet (+x, -x) collect the chamber-wall faces inside the port
296 // footprint and extrude them outward to build the pipe. New pipe cells
297 // reuse the wall-patch vertices, so the patch faces become interior and
298 // the inlet genuinely opens into the chamber.
299 // ---------------------------------------------------------------------
300 // Height of the inlet axis actually used: set from the selected port patch
301 // (the nearest wall-face-centre row to z_inlet) and reused for the manifold.
302 // The first pipe fixes this height; the second pipe then targets the very
303 // same z (rather than z_inlet) so both inlets sit on the same wall-face row
304 // and face one another exactly. This matters because z_inlet can fall
305 // exactly between two candidate rows, where an independent search on each
306 // side could otherwise tie-break to different rows.
307 double inlet_axis_z = z_inlet;
308 bool axis_z_locked = false;
309
310 const auto grow_inlet = [&](const double direction /* +1 : +x, -1 : -x */) {
311 // A chamber lateral-wall face on the requested (+x or -x) side.
312 const auto is_wall_face = [&](const Point<3> &c) {
313 const double r_xy = std::sqrt(c[0] * c[0] + c[1] * c[1]);
314 return std::abs(r_xy - R_chamber) <= 0.15 * R_chamber &&
315 c[2] > 1e-4 * R_chamber &&
316 c[2] < z_chamber_top - 1e-4 * R_chamber && direction * c[0] > 0.0;
317 };
318
319 // 3a. Find the wall face F0 nearest the ideal port centre, then take the
320 // 3x3 block of wall faces around it (F0 plus every wall face sharing a
321 // vertex with it). A 3x3 face block is a 4x4 vertex grid whose centre
322 // is a face, so no vertex maps onto the pipe axis: the tube is then a
323 // clean butterfly (square core + surrounding ring) with no gaps and no
324 // axis singularity.
325 // Target the height fixed by the first pipe once it is locked, so the
326 // second pipe lands on the same wall-face row and both inlets are coaxial.
327 const double target_z = axis_z_locked ? inlet_axis_z : z_inlet;
328 const Point<3> ideal(direction * R_chamber, 0.0, target_z);
329 double best = std::numeric_limits<double>::max();
330 std::array<unsigned int, 4> f0{};
331 Point<3> f0_center;
332 bool found = false;
333 for (const auto &cell : flat_vessel.active_cell_iterators())
334 for (const unsigned int f : GeometryInfo<3>::face_indices())
335 {
336 const auto face = cell->face(f);
337 if (!face->at_boundary() || !is_wall_face(face->center()))
338 continue;
339 const double d = (face->center() - ideal).norm();
340 if (d < best)
341 {
342 best = d;
343 f0_center = face->center();
344 for (unsigned int i = 0; i < 4; ++i)
345 f0[i] = face->vertex_index(i);
346 found = true;
347 }
348 }
349 if (!found)
350 return std::size_t(0);
351 inlet_axis_z = f0_center[2];
352 axis_z_locked = true;
353
354 const std::set<unsigned int> f0_vertices(f0.begin(), f0.end());
355 std::vector<std::array<unsigned int, 4>> port_faces;
356 for (const auto &cell : flat_vessel.active_cell_iterators())
357 for (const unsigned int f : GeometryInfo<3>::face_indices())
358 {
359 const auto face = cell->face(f);
360 if (!face->at_boundary() || !is_wall_face(face->center()))
361 continue;
362 bool shares = false;
363 for (unsigned int i = 0; i < 4; ++i)
364 if (f0_vertices.count(face->vertex_index(i)))
365 shares = true;
366 if (!shares)
367 continue;
368 std::array<unsigned int, 4> vids;
369 for (unsigned int i = 0; i < 4; ++i)
370 vids[i] = face->vertex_index(i);
371 port_faces.push_back(vids);
372 }
373
374 // 3b. Half-extents of the patch (about its centre y = 0, z = inlet_axis_z),
375 // used to map the patch onto the inlet disk of radius r_inlet.
376 std::set<unsigned int> patch_vertices;
377 for (const auto &face : port_faces)
378 for (const unsigned int vid : face)
379 patch_vertices.insert(vid);
380
381 double a_max = 0.0; // max |y|
382 double b_max = 0.0; // max |z - inlet_axis_z|
383 for (const unsigned int vid : patch_vertices)
384 {
385 a_max = std::max(a_max, std::abs(vertices[vid][1]));
386 b_max = std::max(b_max, std::abs(vertices[vid][2] - inlet_axis_z));
387 }
388
389 // 3c. One column of vertices outward per patch vertex. Layer 0 stays on
390 // the chamber wall (so the tube is connected and the mouth is a
391 // circular hole); the square-to-disk map sends the patch boundary onto
392 // the inlet circle while the four inner vertices keep a square core ->
393 // a butterfly cross section that refines cleanly (no vertex on the
394 // axis).
395 const double dL = L_inlet / n_pipe_layers;
396 std::map<unsigned int, std::vector<unsigned int>> column;
397 for (const unsigned int vid : patch_vertices)
398 {
399 const double u = (a_max > 0.0) ? vertices[vid][1] / a_max : 0.0;
400 const double v =
401 (b_max > 0.0) ? (vertices[vid][2] - inlet_axis_z) / b_max : 0.0;
402 const double disk_y = u * std::sqrt(std::max(0.0, 1.0 - 0.5 * v * v));
403 const double disk_z = v * std::sqrt(std::max(0.0, 1.0 - 0.5 * u * u));
404 const double ty = r_inlet * disk_y;
405 const double tz = inlet_axis_z + r_inlet * disk_z;
406
407 std::vector<unsigned int> col(n_pipe_layers + 1);
408 const double x_wall =
409 std::sqrt(std::max(0.0, R_chamber * R_chamber - ty * ty));
410 vertices[vid] = Point<3>(direction * x_wall, ty, tz);
411 col[0] = vid;
412 for (unsigned int j = 1; j <= n_pipe_layers; ++j)
413 {
414 vertices.emplace_back(direction * (R_chamber + j * dL), ty, tz);
415 col[j] = static_cast<unsigned int>(vertices.size() - 1);
416 }
417 column[vid] = std::move(col);
418 }
419
420 // 3d. One hexahedron per patch face per pipe layer. The column grown from
421 // the patch's centre face f0 straddles the pipe axis, so it is tagged
422 // with pipe_core_material_id and later kept flat; the surrounding ring
423 // columns take the pipe's cylinder-about-x manifold (see the manifold
424 // assignment below).
425 for (const auto &face : port_faces)
426 {
427 const bool is_core_column =
428 std::set<unsigned int>(face.begin(), face.end()) == f0_vertices;
429 for (unsigned int j = 1; j <= n_pipe_layers; ++j)
430 {
431 CellData<3> hex;
432 for (unsigned int i = 0; i < 4; ++i)
433 {
434 hex.vertices[i] = column[face[i]][j - 1];
435 hex.vertices[i + 4] = column[face[i]][j];
436 }
437 hex.material_id =
438 is_core_column ? pipe_core_material_id : pipe_material_id;
439 cells.push_back(hex);
440 }
441 }
442
443 return port_faces.size();
444 };
445
446 // Build both inlet pipes. Each must yield the full 3x3 wall-face patch
447 // (9 faces): fewer means the port search failed or the patch was clipped by
448 // the chamber ends (e.g. z_inlet too close to the floor or dome for extreme
449 // geometries), which would silently drop or malform an inlet -- treat it as a
450 // hard error rather than emit a mesh missing a pipe.
451 constexpr std::size_t expected_port_faces = 9; // 3x3 butterfly patch
452 const std::size_t n_port_faces_pos = grow_inlet(+1.0);
453 const std::size_t n_port_faces_neg = grow_inlet(-1.0);
454 AssertThrow(
455 n_port_faces_pos == expected_port_faces &&
456 n_port_faces_neg == expected_port_faces,
457 ExcMessage(
458 "Failed to build the impinging-jet inlet pipes: expected a 3x3 wall-face "
459 "patch (9 faces) for each inlet, but did not obtain one. This can happen "
460 "for extreme geometry parameters (e.g. an inlet axis too close to the "
461 "chamber floor or dome) or if the discretisation is changed."));
462
463 // ---------------------------------------------------------------------
464 // 4. Assemble the final triangulation. Fix cell orientation robustly.
465 // ---------------------------------------------------------------------
466 GridTools::invert_cells_with_negative_measure(vertices, cells);
467 GridTools::consistently_order_cells(cells);
468
469 triangulation.create_triangulation(vertices, cells, SubCellData());
470
471 // ---------------------------------------------------------------------
472 // 5. Reassign boundary ids and manifold ids per mesh region (material id).
473 // Edges shared between the pipe and the vessel -- the port rim, i.e. the
474 // junction between each tube and the chamber wall -- are written by
475 // whichever pass runs LAST (set_all_manifold_ids touches a face and all
476 // its lines). We deliberately run the pipe pass last so the rim edges
477 // take the pipe's cylinder-about-x manifold. The rim vertices already sit
478 // at exactly r_inlet from the pipe axis, so this keeps the circular mouth
479 // round under refinement; leaving the rim on the chamber's z-cylinder
480 // (the other pass order) instead lets the small opening drift off-circle.
481 // ---------------------------------------------------------------------
482 const auto is_axial_opening = [](const auto &face, const auto &cell) {
483 const Tensor<1, 3> outward = face->center() - cell->center();
484 return std::abs(outward[0]) > 0.6 * outward.norm();
485 };
486
487 // pass 1: vessel cells -> dome / outlet cap / cylindrical walls.
488 for (const auto &cell : triangulation.active_cell_iterators())
489 if (cell->material_id() == vessel_material_id)
490 for (const unsigned int f : GeometryInfo<3>::face_indices())
491 {
492 const auto face = cell->face(f);
493 if (!face->at_boundary())
494 continue;
495
496 const Point<3> c = face->center();
497 if (c[2] < z_outlet_bottom + 1e-4 * R_chamber)
498 {
499 // Bottom of the outlet pipe.
500 face->set_boundary_id(outlet_boundary_id);
501 face->set_all_manifold_ids(numbers::flat_manifold_id);
502 }
503 else if (c[2] > z_chamber_top + 1e-4 * R_chamber)
504 {
505 // Hemispherical dome.
506 face->set_boundary_id(wall_boundary_id);
507 face->set_all_manifold_ids(dome_manifold_id);
508 }
509 else
510 {
511 // Chamber / reduction / outlet lateral walls.
512 face->set_boundary_id(wall_boundary_id);
513 face->set_all_manifold_ids(cylinder_z_manifold_id);
514 }
515 }
516
517 // pass 1.5: give the inlet-pipe cells a volume manifold so the pipes refine
518 // cylindrically (keeping the cell shape) instead of only their outer
519 // wall faces following the circle while the interior is interpolated
520 // linearly -- the latter is what slowly degrades the pipe cells under
521 // repeated refinement. set_all_manifold_ids() tags each cell
522 // together with its faces and lines. The ring columns take the
523 // pipe's cylinder-about-x manifold; the central core column is then
524 // reset to flat, because that manifold is singular on the pipe axis
525 // the column straddles (and a flat core keeps its square
526 // cross-section crisp). Running the ring pass before the core pass
527 // makes the shared ring/core faces flat, so the square core stays
528 // straight-sided.
529 for (const auto &cell : triangulation.active_cell_iterators())
530 if (cell->material_id() == pipe_material_id)
531 cell->set_all_manifold_ids(inlet_manifold_id);
532 // numbers::flat_manifold_id is deal.II's reserved flat id (not manifold id
533 // 0); it always resolves to a FlatManifold, so the core column stays flat
534 // regardless of the cylindrical manifolds assigned to ids 0 and 2 below.
535 for (const auto &cell : triangulation.active_cell_iterators())
536 if (cell->material_id() == pipe_core_material_id)
537 cell->set_all_manifold_ids(numbers::flat_manifold_id);
538
539 // pass 2 (last): inlet-pipe cells -> cylindrical about x; the axial end is
540 // the inlet opening (flat), the rest is the circular pipe wall.
541 // Running last, this also claims the shared port-rim edges for the
542 // pipe's x-cylinder, so each junction stays a clean circle when
543 // refined.
544 for (const auto &cell : triangulation.active_cell_iterators())
545 if (cell->material_id() == pipe_material_id ||
546 cell->material_id() == pipe_core_material_id)
547 for (const unsigned int f : GeometryInfo<3>::face_indices())
548 {
549 const auto face = cell->face(f);
550 if (!face->at_boundary())
551 continue;
552
553 // The pipe *wall* (circumference, at radius r_inlet) takes the
554 // x-cylinder manifold; the end-cap disks stay flat. The cap must not
555 // be cylindrical: the central butterfly column's cap is centred on
556 // the pipe axis, where the cylindrical manifold is singular.
557 if (is_axial_opening(face, cell))
558 {
559 face->set_boundary_id(face->center()[0] > 0.0 ?
560 inlet1_boundary_id :
561 inlet2_boundary_id);
562 face->set_all_manifold_ids(numbers::flat_manifold_id);
563 }
564 else
565 {
566 face->set_boundary_id(wall_boundary_id);
567 face->set_all_manifold_ids(inlet_manifold_id);
568 }
569 }
570
571 // The material ids were only an internal device to steer the manifold
572 // assignment above; reset them so the whole domain is a single material.
573 for (const auto &cell : triangulation.active_cell_iterators())
574 cell->set_material_id(0);
575
576 // Re-datum the mesh vertically so that the common axis of the two inlet pipes
577 // lies on the z = 0 plane (the plane where the opposing jets impinge). The
578 // whole geometry is translated rigidly by -inlet_axis_z, so the mesh that
579 // already works is untouched -- only the origin moves. Because the shift is
580 // applied to the vertices after all boundary ids have been assigned (those
581 // use face centres in the original datum), the assignments are unaffected.
582 const double z_shift = -inlet_axis_z;
583 GridTools::shift(Tensor<1, 3>({0., 0., z_shift}), triangulation);
584
585 // GridTools::shift moves the vertices but NOT the Manifold objects attached
586 // to the triangulation: a manifold does not follow the transformation of the
587 // grid. All manifolds must therefore be (re)defined here, after the final
588 // translation, with their reference points expressed in the delivered
589 // (shifted) datum. In particular the hemispherical dome's spherical manifold
590 // is re-centred on the *translated* position of the sphere centre,
591 // z_dome_center + z_shift, so that the dome keeps its exact spherical shape
592 // under later refinement. Leaving this centre in the construction datum
593 // would silently distort the dome even though the coarse mesh looks correct.
594 // Both cylindrical manifolds keep their reference point at (0, 0, 0): the
595 // vertical mixer (z-)axis passes through the origin and is invariant under a
596 // vertical shift, and the horizontal inlet (x-)axis has just been brought
597 // onto the impingement plane z = 0 by the re-datuming.
598 const Point<3> dome_center(0., 0., z_dome_center + z_shift);
599
600 triangulation.set_manifold(cylinder_z_manifold_id,
601 CylindricalManifold<3>(Tensor<1, 3>({0., 0., 1.}),
602 Point<3>(0., 0., 0.)));
603 triangulation.set_manifold(dome_manifold_id,
604 SphericalManifold<3>(dome_center));
605 triangulation.set_manifold(inlet_manifold_id,
606 CylindricalManifold<3>(Tensor<1, 3>({1., 0., 0.}),
607 Point<3>(0., 0., 0.)));
608}
609
610// Fallback make_grid definition for unsupported template parameters. This
611// provides a linker-visible symbol and a clear runtime error when the
612// class is instantiated for dim/spacedim combinations that are not
613// specialized above.
614template <int dim, int spacedim>
615void
617 Triangulation<dim, spacedim> & /*triangulation*/)
618{
619 AssertThrow(
620 false,
621 ExcMessage(
622 "GridImpingingJetMixer is only implemented for dim = 3 and spacedim = 3."));
623}
624
625// Explicit template instantiations
626template class GridImpingingJetMixer<2, 2>;
627template class GridImpingingJetMixer<2, 3>;
628template class GridImpingingJetMixer<3, 3>;
Generates a 3D mesh for an impinging-jet mixer geometry.
std::string grid_arguments
Arguments used to generate the grid.
GridImpingingJetMixer(const std::string &grid_arguments)
Constructor that parses the geometry dimensions from a colon-separated string.
void make_grid(Triangulation< dim, spacedim > &triangulation)
Generate the impinging-jet mixer mesh.
Geometry dimensions of the impinging-jet mixer (SI units, metres).
double z_inlet
inlet-axis height above the chamber floor
double z_cone_bottom() const
double R_chamber
mixing-chamber radius
double r_inlet
inlet-pipe radius
double L_cone
axial length of the conical reduction
double L_inlet
length of each inlet pipe
double z_chamber_top() const
double z_dome_center() const
double r_outlet
outlet-pipe radius
double H_chamber
chamber height (axial extent)
double z_outlet_bottom() const
double L_outlet
length of the straight outlet pipe