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