Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
grid_cylinder.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_cylinder_grid_h
5#define lethe_cylinder_grid_h
6
7#include <deal.II/base/utilities.h>
8
9#include <deal.II/grid/manifold_lib.h>
10
11#include <sstream>
12
13using namespace dealii;
14
15/**
16 * @brief Class that creates a custom cylinder geometry with different ways to mesh the circular part of the geometry.
17 *
18 * @tparam dim The dimension of the mesh, must be 3.
19 * @tparam spacedim The dimension of the space where the mesh is defined, must be 3.
20 */
21
22template <int dim, int spacedim>
23class GridCylinder
24{
25public:
26 /**
27 * @brief Constructor for the GridCylinder.
28 *
29 * @param[in] grid_type. The type of cylinder mesh to be generated. The
30 * choices are:
31 * cylinder_classic|cylinder_balanced|cylinder_squared|cylinder_regularized.
32 * For more details on the different types of cylinder meshes, refer to the
33 * make_grid function.
34 * @param[in] grid_arguments. A string with 3 parameters, @code "subdivisions:
35 * radius : half height", separated by a colon. The subdivisions parameter is
36 * the number of subdivisions in the x direction, the radius parameter is the
37 * radius of the cylinder and the half height parameter is half the height of
38 * the cylinder.
39 */
40 GridCylinder(const std::string &grid_type, const std::string &grid_arguments);
41
42 /**
43 * @brief make_grid. The make_grid function generates cylindrical meshes with different meshing strategies for the circular part of the geometry, depending on the cylinder type specified in the constructor. It also constructs the geometry manifold with SphericalManifold.
44 *
45 * @param[out] triangulation. The triangulation object on which the grid is
46 * generated
47 */
48 void
49 make_grid(Triangulation<dim, spacedim> &triangulation);
50
51private:
52 std::string grid_arguments;
53 int subdivisions;
54 double radius;
55 double half_height;
56
57 // Enum for the different types of cylinder meshes.
58 // The types are:
59 // - ``cyclinder_classic``, equivalent to a subdivided cylinder from deal.II;
60 // - ``cylinder_balanced``, a cylinder with a more balanced element size and
61 // aspect ratio;
62 // - ``cylinder_squared``, has squared type meshing in the middle of the
63 // circular part and becomes more and more skewed towards the outer part of
64 // the circular geometry to fit the circle;
65 // - ``cylinder_regularized``, a regularized version of the squared type to
66 // reduce the skewness of the elements at the outer part of the circular
67 // geometry.
68 enum class CylinderType : std::int8_t
69 {
70 /// Classic cylinder grid generated by deal.II
71 classic,
72 /// Cylinder grid with balanced element size
73 balanced,
74 /// Cylinder grid with square-type meshing in the center
75 squared,
76 /// Regularized square cylinder to reduce element skewness
77 regularized
78 };
79 CylinderType cylinder_type;
80};
81
82
83#endif