ryujin 2.1.1 revision 0348cbb53a3e4b1da2a4c037e81f88f2d21ce219
geometry_step.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2022 - 2023 by the ryujin authors
4//
5
6#pragma once
7
9
10namespace ryujin
11{
12 namespace GridGenerator
13 {
22 template <int dim, template <int, int> class Triangulation>
23 void step(Triangulation<dim, dim> &,
24 const double /*length*/,
25 const double /*height*/,
26 const double /*step_position*/,
27 const double /*step_height*/)
28 {
29 AssertThrow(false, dealii::ExcNotImplemented());
30 __builtin_trap();
31 }
32
33
34#ifndef DOXYGEN
35 template <template <int, int> class Triangulation>
36 void step(Triangulation<2, 2> &triangulation,
37 const double length,
38 const double height,
39 const double step_position,
40 const double step_height)
41 {
42 using namespace dealii;
43
44 dealii::Triangulation<2, 2> tria1, tria2, tria3;
45 tria3.set_mesh_smoothing(triangulation.get_mesh_smoothing());
46
47 GridGenerator::subdivided_hyper_rectangle(
48 tria1, {15, 4}, Point<2>(0., step_height), Point<2>(length, height));
49
50 GridGenerator::subdivided_hyper_rectangle(
51 tria2,
52 {3, 1},
53 Point<2>(0., 0.),
54 Point<2>(step_position, step_height));
55
56 GridGenerator::merge_triangulations(tria1, tria2, tria3);
57 triangulation.copy_triangulation(tria3);
58
59 /*
60 * Set boundary ids:
61 */
62
63 for (auto cell : triangulation.active_cell_iterators()) {
64 for (auto f : cell->face_indices()) {
65 const auto face = cell->face(f);
66
67 if (!face->at_boundary())
68 continue;
69
70 /*
71 * We want slip boundary conditions (i.e. indicator 1) at top
72 * and bottom of the rectangle. On the left we set inflow
73 * conditions (i.e. indicator 2), and we do nothing on the right
74 * side (i.e. indicator 0).
75 */
76
77 const auto center = face->center();
78
79 if (center[0] > 0. + 1.e-6 && center[0] < length - 1.e-6)
80 face->set_boundary_id(Boundary::slip);
81
82 if (center[0] < 0. + 1.e-06)
83 face->set_boundary_id(Boundary::dirichlet);
84 }
85 }
86
87 /*
88 * Refine four times and round off corner with radius 0.0125:
89 */
90
91 triangulation.refine_global(4);
92
93 Point<2> point(step_position + 0.0125, step_height - 0.0125);
94 triangulation.set_manifold(1, SphericalManifold<2>(point));
95
96 for (auto cell : triangulation.active_cell_iterators())
97 for (unsigned int v : cell->vertex_indices()) {
98 double distance =
99 (cell->vertex(v) - Point<2>(step_position, step_height)).norm();
100 if (distance < 1.e-6) {
101 for (auto f : cell->face_indices()) {
102 const auto face = cell->face(f);
103 if (face->at_boundary())
104 face->set_manifold_id(1);
105 cell->set_manifold_id(1); // temporarily for second loop
106 }
107 }
108 }
109
110 for (auto cell : triangulation.active_cell_iterators()) {
111 if (cell->manifold_id() != 1)
112 continue;
113
114 cell->set_manifold_id(0); // reset manifold id again
115
116 for (unsigned int v : cell->vertex_indices()) {
117 auto &vertex = cell->vertex(v);
118
119 if (std::abs(vertex[0] - step_position) < 1.e-6 &&
120 vertex[1] > step_height - 1.e-6)
121 vertex[0] = step_position + 0.0125 * (1 - std::sqrt(1. / 2.));
122
123 if (std::abs(vertex[1] - step_height) < 1.e-6 &&
124 vertex[0] < step_position + 0.005)
125 vertex[1] = step_height - 0.0125 * (1 - std::sqrt(1. / 2.));
126 }
127 }
128 }
129#endif
130 } /* namespace GridGenerator */
131
132
133 namespace Geometries
134 {
140 template <int dim>
141 class Step : public Geometry<dim>
142 {
143 public:
144 Step(const std::string subsection)
145 : Geometry<dim>("step", subsection)
146 {
147 length_ = 3.;
148 this->add_parameter(
149 "length", length_, "length of computational domain");
150
151 height_ = 1.;
152 this->add_parameter(
153 "height", height_, "height of computational domain");
154
155 step_position_ = 0.6;
156 this->add_parameter(
157 "step position", step_position_, "x position of step");
158
159 step_height_ = 0.2;
160 this->add_parameter("step height", step_height_, "height of step");
161 }
162
164 typename Geometry<dim>::Triangulation &triangulation) final
165 {
167 triangulation, length_, height_, step_position_, step_height_);
168 }
169
170 private:
171 double length_;
172 double height_;
173 double step_position_;
174 double step_height_;
175 };
176 } /* namespace Geometries */
177
178} /* namespace ryujin */
Step(const std::string subsection)
void create_triangulation(typename Geometry< dim >::Triangulation &triangulation) final
typename Discretization< dim >::Triangulation Triangulation
Definition: geometry.h:38
void step(Triangulation< dim, dim > &, const double, const double, const double, const double)
Definition: geometry_step.h:23