ExaDG
Loading...
Searching...
No Matches
boundary_layer_manifold.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2021 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef INCLUDE_EXADG_GRID_BOUNDARY_LAYER_MANIFOLD_H_
23#define INCLUDE_EXADG_GRID_BOUNDARY_LAYER_MANIFOLD_H_
24
25#include <deal.II/grid/manifold_lib.h>
26
27namespace ExaDG
28{
39template<int dim>
40class BoundaryLayerManifold : public dealii::ChartManifold<dim, dim, dim>
41{
42public:
43 BoundaryLayerManifold(dealii::Tensor<1, dim> const & dimensions_in,
44 double const grid_stretch_factor_in)
45 {
46 dimensions = dimensions_in;
47 grid_stretch_factor = grid_stretch_factor_in;
48 }
49
50 /*
51 * push_forward operation that maps point xi in reference coordinates [0,1]^d to
52 * point x in physical coordinates
53 */
54 dealii::Point<dim>
55 push_forward(dealii::Point<dim> const & xi) const final
56 {
57 dealii::Point<dim> x;
58
59 x[0] = xi[0] * dimensions[0] - dimensions[0] / 2.0;
60 x[1] = grid_transform_y(xi[1]);
61
62 if(dim == 3)
63 x[2] = xi[2] * dimensions[2] - dimensions[2] / 2.0;
64
65 return x;
66 }
67
68 /*
69 * pull_back operation that maps point x in physical coordinates
70 * to point xi in reference coordinates [0,1]^d
71 */
72 dealii::Point<dim>
73 pull_back(dealii::Point<dim> const & x) const final
74 {
75 dealii::Point<dim> xi;
76
77 xi[0] = x[0] / dimensions[0] + 0.5;
78 xi[1] = inverse_grid_transform_y(x[1]);
79
80 if(dim == 3)
81 xi[2] = x[2] / dimensions[2] + 0.5;
82
83 return xi;
84 }
85
86 std::unique_ptr<dealii::Manifold<dim>>
87 clone() const final
88 {
89 return std::make_unique<BoundaryLayerManifold<dim>>(dimensions, grid_stretch_factor);
90 }
91
92 /*
93 * maps eta in [0,1] --> y in [-1,1]*length_y/2.0 (using a hyperbolic mesh stretching)
94 */
95 double
96 grid_transform_y(double const & eta) const
97 {
98 double y = 0.0;
99
100 if(grid_stretch_factor >= 0)
101 y = dimensions[1] / 2.0 * std::tanh(grid_stretch_factor * (2. * eta - 1.)) /
102 std::tanh(grid_stretch_factor);
103 else // use a negative grid_stretch_factorTOR deactivate grid stretching
104 y = dimensions[1] / 2.0 * (2. * eta - 1.);
105
106 return y;
107 }
108
109 /*
110 * inverse mapping:
111 *
112 * maps y in [-1,1]*length_y/2.0 --> eta in [0,1]
113 */
114 double
115 inverse_grid_transform_y(double const & y) const
116 {
117 double eta = 0.0;
118
119 if(grid_stretch_factor >= 0)
120 eta = (std::atanh(y * std::tanh(grid_stretch_factor) * 2.0 / dimensions[1]) /
121 grid_stretch_factor +
122 1.0) /
123 2.0;
124 else // use a negative grid_stretch_factorTOR deactivate grid stretching
125 eta = (2. * y / dimensions[1] + 1.) / 2.0;
126
127 return eta;
128 }
129
130private:
131 dealii::Tensor<1, dim> dimensions;
132
133 // use a negative grid_stretch_factor to deactivate grid stretching
134 double grid_stretch_factor = 1.8;
135};
136} // namespace ExaDG
137
138
139
140#endif /* INCLUDE_EXADG_GRID_BOUNDARY_LAYER_MANIFOLD_H_ */
Definition boundary_layer_manifold.h:41
Definition driver.cpp:33