Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
grid_periodic_hills.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2020-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_per_hills_grid_h
5#define lethe_per_hills_grid_h
6
7#include <deal.II/base/auto_derivative_function.h>
8#include <deal.II/base/utilities.h>
9
10#include <deal.II/grid/manifold_lib.h>
11#include <deal.II/grid/tria.h>
12
13#include <deal.II/lac/vector.h>
14
15#include <sstream>
16
17using namespace dealii;
18
19/**
20 * @brief Class that creates a hyper_rectangle and transforms it to obtain the hill geometry with
21 * the hill_geometry function. It also attaches a manifold to the geometry.
22 */
23
24template <int dim, int spacedim>
26{
27public:
28 /**
29 * @brief Constructor for the PeriodicHillsGrid.
30 *
31 * @param grid_arguments. A string with 5 parameters
32 * spacing_y : allows to control the shifting of horizontal line [0 - 1]
33 * alpha : allows to elongate while keeping the same flat region [0.5 - 3]
34 * repetitions_x : number of separation of cells in x before refinement
35 * repetitions_y : number of separation of cells in y before refinement
36 * repetitions_z : number of separation of cells in z before refinement
37 */
38 GridPeriodicHills(const std::string &grid_arguments);
39
40 /**
41 * @brief The hill_geometry function calculates all the domain of the geometry with 6
42 * polynomials depending the x position. (See Hill Geometry Definition file :
43 * https://turbmodels.larc.nasa.gov/Other_LES_Data/2dhill_periodic.html)
44 * This code has nondimensionalized geometry, but the coefficients provided
45 * need a hill height of 28.
46 * This function also does a gradual shifting of the horizontal lines
47 * prior to have smaller element on the bottom of the geometry where results
48 * are more important.
49 *
50 * @param p A point in space which will be adapted to the periodic hill geometry
51 *
52 * @param param Non-linear solver parameters
53 *
54 */
55 Point<spacedim> static hill_geometry(const Point<spacedim> &p,
56 double spacing_y,
57 double alpha);
58
59 /**
60 * @brief make_grid. The make_grid function generates a hyper rectangle of the size of the domain
61 * and then transforms it to the hill geometry. It also constructs the
62 * geometry manifold with FunctionManifold and finally sets the manifold.
63 *
64 * @param triangulation. The triangulation object on which the grid is generated
65 */
66 void
67 make_grid(Triangulation<dim, spacedim> &triangulation);
68
69private:
70 std::string grid_arguments;
71 double spacing_y;
75 double alpha;
76};
77
78/**
79 * @brief The push_forward & the pull_back classes create the vector_value functions
80 * gradient function and because it inherits from Function<spacedim>. (formula
81 * is currently Euler and can be changed. See AutoDerivativeFunction
82 * documentation)
83 */
84template <int dim, int spacedim>
85class PeriodicHillsPushForward : public AutoDerivativeFunction<spacedim>
86{
87public:
89 : AutoDerivativeFunction<spacedim>(1e-6, spacedim)
91 , alpha(alpha)
92 {}
93 /**
94 * @brief vector_value. This function is used to construct the geometry manifold.
95 * It changes the original point (op) of the transformed hyper_rectangle
96 * with hill_geometry to a new point (np) of the hill grid with per_hills_grid
97 * function.
98 *
99 * @param p. A point in space
100 *
101 * @param values. The vector of values which will be calculated at the position p.
102 */
103 virtual void
104 vector_value(const Point<spacedim> &p, Vector<double> &values) const override;
105
106 /**
107 * @brief value. The value function does the same thing than vector_value for one component.
108 * This implementation is needed to use the gradient function inherited by
109 * AutoDerivativeFunction.
110 *
111 * @param op. An original point in space
112 *
113 * @param component. The component of the point (x=0, y=1, z=2)
114 */
115 virtual double
116 value(const Point<spacedim> &p, const unsigned int component) const override;
117
118private:
119 double spacing_y;
120 double alpha;
121};
122
123
124template <int dim, int spacedim>
125class PeriodicHillsPullBack : public AutoDerivativeFunction<spacedim>
126{
127public:
129 : AutoDerivativeFunction<spacedim>(1e-6, spacedim)
131 , alpha(alpha)
132 {}
133
134 /**
135 * \brief vector_value. This vector_value function is used to construct the
136 * geometry manifold. It changes the new point (np) of the hill grid to the
137 * original point (op) of the transformed hyper_rectangle grid. This function
138 * is mandatory to use FunctionManifold. First, it finds the minimum value of
139 * y depending the x position and then calculates the op with the inverse of
140 * the transformation done by hill_geometry function.
141 *
142 * \param np. A point in space.
143 *
144 * @param values. The vector of values which will be calculated at the position p.
145 */
146 virtual void
147 vector_value(const Point<spacedim> &np,
148 Vector<double> &values) const override;
149
150 /**
151 * @brief value. The value function does the same thing than vector_value for one component.
152 * This implementation is needed to use the gradient function inherited by
153 * AutoDerivativeFunction.
154 *
155 * @param p. An original point in space
156 *
157 * @param component. The component of the point (x=0, y=1, z=2)
158 *
159 */
160 virtual double
161 value(const Point<spacedim> &np, const unsigned int component) const override;
162
163private:
164 double spacing_y;
165 double alpha;
166};
167
168
169
170#endif
GridPeriodicHills(const std::string &grid_arguments)
Constructor for the PeriodicHillsGrid.
static Point< spacedim > hill_geometry(const Point< spacedim > &p, double spacing_y, double alpha)
The hill_geometry function calculates all the domain of the geometry with 6 polynomials depending the...
void make_grid(Triangulation< dim, spacedim > &triangulation)
make_grid. The make_grid function generates a hyper rectangle of the size of the domain and then tran...
PeriodicHillsPullBack(double spacing_y, double alpha)
virtual double value(const Point< spacedim > &np, const unsigned int component) const override
value. The value function does the same thing than vector_value for one component....
virtual void vector_value(const Point< spacedim > &np, Vector< double > &values) const override
vector_value. This vector_value function is used to construct the geometry manifold....
virtual double value(const Point< spacedim > &p, const unsigned int component) const override
value. The value function does the same thing than vector_value for one component....
virtual void vector_value(const Point< spacedim > &p, Vector< double > &values) const override
vector_value. This function is used to construct the geometry manifold. It changes the original point...
PeriodicHillsPushForward(double spacing_y, double alpha)