Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
grid_pipe_and_waveguide.h
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
4#ifndef lethe_grid_pipe_and_waveguide_h
5#define lethe_grid_pipe_and_waveguide_h
6
7#include <deal.II/base/utilities.h>
8
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
13#include <array>
14#include <sstream>
15
16using namespace dealii;
17
18/**
19 * @brief Generates a 3D mesh of a waveguide embedded in a cylindrical cavity in which a liquid flows
20 *
21 * The geometry consists of three sections joined along the z-axis:
22 * - A bottom cylinder
23 * - A central cylinder into which the rectangular-based waveguide is embedded
24 * - A top cylinder
25 *
26 * Note that the mesh of the cylinder is inspired from the hyper_ball function
27 * of the deal.II library.
28 *
29 * Boundary IDs are assigned as follows:
30 * -0: Microwaves (MW) inlet
31 * -1: Fluid flow inlet (bottom surface of the cylinder)
32 * -2: Fluid flow outlet (top surface of the cylinder)
33 * -3: Walls
34 *
35 * Material IDs are assigned as follows:
36 * -0: Fluid in the channel (cylinder)
37 * -1: Air in the waveguide (paving stone)
38 *
39 * A CylindricalManifold is attached to the curved lateral surfaces of the
40 * cylinder so that mesh refinement preserves the shape of the fluid
41 * channel.
42 *
43 * @tparam dim The dimension of the mesh, must be 3.
44 * @tparam spacedim The dimension of the space, must be 3.
45 */
46
47template <int dim, int spacedim>
49
50{
51public:
52 /**
53 * @brief Constructor that parses grid parameters from a colon-separated
54 * string.
55 *
56 * @param[in] grid_arguments A string with the following format:
57 * @code "rectangle_width : rectangle_length : outer_radius : inner_length :
58 * bottom_height : middle_height : top_height : bottom_resolution :
59 * middle_resolution : top_resolution : inner_circle" @endcode
60 *
61 * | # | Field | Format | Required | Description |
62 * |-----|-------------------|---------------|----------|----------------------------------------------------------------------------------------------------------|
63 * | 0 | rectangle_width | double | yes | Waveguide width |
64 * | 1 | rectangle_length | double | yes | Waveguide length |
65 * | 2 | outer_radius | double | yes | Radius of the main cylinder |
66 * | 3 | inner_length | double | yes | Depending on the inner shape, it can be the square side or the circle radius |
67 * | 4 | bottom_height | double | yes | Height of the bottom cylinder |
68 * | 5 | middle_height | double | yes | Height of the waveguide |
69 * | 6 | top_height | double | yes | Height of the top cylinder |
70 * | 7 | bottom_resolution | int | yes | Number of slices generated by the extrusion of the bottom cylinder (at least 2 slices are required) |
71 * | 8 | middle_resolution | int | yes | Number of slices generated by the extrusion of the center cylinder |
72 * | 9 | top_resolution | int | yes | Number of slices generated by the extrusion of the top cylinder |
73 * | 10 | inner_circle | true/false | no | True (default): The inner shape is a circle False: Inner square |
74 * Example: @code "0.07 : 0.05 : 0.1 : 0.07 : 0.1 : 0.07 : 0.1 : 3 : 2 : 3 :
75 * true" @endcode
76 */
77 GridPipeAndWaveguide(const std::string &grid_arguments);
78
79 /**
80 * @brief Generate a cylindrical fluid conduit in which a block-shaped waveguide is embedded.
81 *
82 * The three parts of the geometry (bottom cylinder, center_cylinder (with the
83 * waveguide), top cylinder) are first merged and returned coarse
84 *
85 * @param[in,out] triangulation The triangulation to fill with the mesh.
86 */
87
88 void
89 make_grid(Triangulation<dim, spacedim> &triangulation);
90
91private:
92 /**
93 * @brief The function detailed_circle is a tool used in the core of the file
94 *
95 * This function is an extension of the 2D part of the hyper_ball in-built
96 * deal.ii function.
97 *
98 * Since the deal.ii merge function needs the two trangulations to have
99 * overlapped points, we needed to produce a coarse circular mesh with two
100 * points at the exact place where the rectangle would fit. This is why this
101 * function was created.
102 *
103 * There are three main differences between hyper_ball and detailed_circle:
104 *
105 * -Fourteen points were added to the mesh (8 points in the original one)
106 * to link the circle with the rectangle we want to merge and to
107 * prevent triangular cells from being generated.
108 *
109 * - A central rectangle of width equal to the waveguide width crosses the
110 * circle along the x-axis. This minimizes the aspect ratio of the cells
111 * contained within the central rectangle because their shape stay nearly
112 * rectangular.
113 *
114 * - In the original function, a square lies in the center of the circle. An
115 * argument has been added to this function to chose between a square and
116 * a circle. We call this shape the "inner shape" of the circle.
117 *
118 * @param[in] tria
119 * @param[in] p
120 * @param[in] a
121 * @param[in] b
122 * @param[in] r
123 * @param[in] R
124 * @param[in] inner_circle
125 *
126 * @code "detailed_circle(&tria,&p,&a,&b,r,R,inner_circle)" @endcode
127 *
128 * | # | Field | Format | Required | Description |
129 * |-----|---------------|--------------------------------|----------|------------------------------------------------------------------|
130 * | 0 | &tria | Triangulation <dim, spacedim> | yes | Triangulation used for the mesh |
131 * | 1 | &p | Point<spacedim> | yes | Center of the circle |
132 * | 2 | a | double | yes | Rectangle width |
133 * | 3 | &b | double | yes | Rectangle length |
134 * | 4 | r | double | yes | Outer radius of the circle |
135 * | 5 | R | double | yes | Inner circle radius or inner square side |
136 * | 6 | inner_circle | true/false | yes | True : the inner shape is a circle, False : it is a square |
137 * Example: @code "0.07 : 0.05 : 0.1 : 0.07 : 0.1 : 0.07 : 0.1 : 3 : 2 : 3 :
138 * true" @endcode
139 */
140 void
141 detailed_circle(Triangulation<2, 2> &tria,
142 const Point<2> &p,
143 const double &a,
144 const double &b,
145 const double r,
146 const double R,
147 const bool inner_circle);
148
149
150
151 /// Width of the rectangular waveguide
152 double rectangle_width;
153
154 /// Length of the rectangular waveguide
155 double rectangle_length;
156
157 /// Outer radius of the cylindrical cavity
158 double outer_radius;
159
160 /// Inner length (radius if circle, side if square) of the central shape
161 double inner_length;
162
163 /// Height of the bottom cylinder
164 double bottom_height;
165
166 /// Height of the center section (waveguide embedded in cylinder)
167 double middle_height;
168
169 /// Height of the top cylinder
170 double top_height;
171
172 /// Number of cells generated by the extrusion of the bottom cylinder
173 int bottom_resolution;
174
175 /// Number of cells generated by the extrusion of the center cylinder
176 int middle_resolution;
177
178 /// Number of cells generated by the extrusion of the tops cylinder
179 int top_resolution;
180
181 /// Shape of the inner region: true = circle, false = square
182 bool inner_circle;
183};
184
185
186#endif
Generates a 3D mesh of a waveguide embedded in a cylindrical cavity in which a liquid flows.