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 EXADG_GRID_BOUNDARY_LAYER_MANIFOLD_H_
23#define EXADG_GRID_BOUNDARY_LAYER_MANIFOLD_H_
24
25// deal.II
26#include <deal.II/grid/manifold_lib.h>
27
28namespace ExaDG
29{
40template<int dim>
41class BoundaryLayerManifold : public dealii::ChartManifold<dim, dim, dim>
42{
43public:
44 BoundaryLayerManifold(dealii::Tensor<1, dim> const & dimensions_in,
45 double const grid_stretch_factor_in)
46 {
47 dimensions = dimensions_in;
48 grid_stretch_factor = grid_stretch_factor_in;
49 }
50
51 /*
52 * push_forward operation that maps point xi in reference coordinates [0,1]^d to
53 * point x in physical coordinates
54 */
55 dealii::Point<dim>
56 push_forward(dealii::Point<dim> const & xi) const final
57 {
58 dealii::Point<dim> x;
59
60 x[0] = xi[0] * dimensions[0] - dimensions[0] / 2.0;
61 x[1] = grid_transform_y(xi[1]);
62
63 if(dim == 3)
64 x[2] = xi[2] * dimensions[2] - dimensions[2] / 2.0;
65
66 return x;
67 }
68
69 /*
70 * pull_back operation that maps point x in physical coordinates
71 * to point xi in reference coordinates [0,1]^d
72 */
73 dealii::Point<dim>
74 pull_back(dealii::Point<dim> const & x) const final
75 {
76 dealii::Point<dim> xi;
77
78 xi[0] = x[0] / dimensions[0] + 0.5;
79 xi[1] = inverse_grid_transform_y(x[1]);
80
81 if(dim == 3)
82 xi[2] = x[2] / dimensions[2] + 0.5;
83
84 return xi;
85 }
86
87 std::unique_ptr<dealii::Manifold<dim>>
88 clone() const final
89 {
90 return std::make_unique<BoundaryLayerManifold<dim>>(dimensions, grid_stretch_factor);
91 }
92
93 /*
94 * maps eta in [0,1] --> y in [-1,1]*length_y/2.0 (using a hyperbolic mesh stretching)
95 */
96 double
97 grid_transform_y(double const & eta) const
98 {
99 double y = 0.0;
100
101 if(grid_stretch_factor >= 0)
102 y = dimensions[1] / 2.0 * std::tanh(grid_stretch_factor * (2. * eta - 1.)) /
103 std::tanh(grid_stretch_factor);
104 else // use a negative grid_stretch_factorTOR deactivate grid stretching
105 y = dimensions[1] / 2.0 * (2. * eta - 1.);
106
107 return y;
108 }
109
110 /*
111 * inverse mapping:
112 *
113 * maps y in [-1,1]*length_y/2.0 --> eta in [0,1]
114 */
115 double
116 inverse_grid_transform_y(double const & y) const
117 {
118 double eta = 0.0;
119
120 if(grid_stretch_factor >= 0)
121 eta = (std::atanh(y * std::tanh(grid_stretch_factor) * 2.0 / dimensions[1]) /
122 grid_stretch_factor +
123 1.0) /
124 2.0;
125 else // use a negative grid_stretch_factorTOR deactivate grid stretching
126 eta = (2. * y / dimensions[1] + 1.) / 2.0;
127
128 return eta;
129 }
130
131private:
132 dealii::Tensor<1, dim> dimensions;
133
134 // use a negative grid_stretch_factor to deactivate grid stretching
135 double grid_stretch_factor = 1.8;
136};
137} // namespace ExaDG
138
139#endif /* EXADG_GRID_BOUNDARY_LAYER_MANIFOLD_H_ */
Definition driver.cpp:33