ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
geometry_tank.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2024 - 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 {
28 template <int dim, int spacedim, template <int, int> class Triangulation>
29 void wavetank(Triangulation<dim, spacedim> &,
30 const double /*reservoir_length*/,
31 const double /*reservoir_width*/,
32 const double /*flume_length*/,
33 const double /*flume_width*/)
34 {
35 AssertThrow(false, dealii::ExcNotImplemented());
36 __builtin_trap();
37 }
38
39
40#ifndef DOXYGEN
41 template <template <int, int> class Triangulation>
42 void wavetank(Triangulation<2, 2> &triangulation,
43 const double reservoir_length,
44 const double reservoir_width,
45 const double flume_length,
46 const double flume_width)
47 {
48 using namespace dealii;
49
50 dealii::Triangulation<2, 2> res1, res2, res3, flume, final;
51
52 const double tolerance = 1.e-8;
53
54 Assert(reservoir_width - flume_width > tolerance,
55 dealii::ExcInternalError());
56
57 /* We split the reservoir into three triangulations and subdivide to
58 * get close to uniform refinement */
59
60 const double diff = (reservoir_width - flume_width) / 2.;
61 unsigned int sub_x = int(std::round(reservoir_length * 100.));
62 unsigned int sub_y = int(std::round(diff * 100.));
63
64 GridGenerator::subdivided_hyper_rectangle(
65 res1,
66 {sub_x, sub_y},
67 Point<2>(-reservoir_length, -reservoir_width / 2.),
68 Point<2>(0, -flume_width / 2.));
69
70 GridGenerator::subdivided_hyper_rectangle(
71 res3,
72 {sub_x, sub_y},
73 Point<2>(-reservoir_length, flume_width / 2.),
74 Point<2>(0, reservoir_width / 2.));
75
76 sub_y = int(std::round(flume_width * 100.));
77
78 GridGenerator::subdivided_hyper_rectangle(
79 res2,
80 {sub_x, sub_y},
81 Point<2>(-reservoir_length, -flume_width / 2.),
82 Point<2>(0, flume_width / 2.));
83
84 sub_x = int(std::round(flume_length * 100.));
85
86 GridGenerator::subdivided_hyper_rectangle(
87 flume,
88 {sub_x, sub_y},
89 Point<2>(0., -flume_width / 2.),
90 Point<2>(flume_length, flume_width / 2.));
91
92 final.set_mesh_smoothing(triangulation.get_mesh_smoothing());
93 GridGenerator::merge_triangulations(
94 {&res1, &res2, &res3, &flume}, final, tolerance);
95 triangulation.copy_triangulation(final);
96
97 /*
98 * Set boundary ids:
99 */
100
101 for (auto cell : triangulation.active_cell_iterators()) {
102 for (auto f : cell->face_indices()) {
103 const auto face = cell->face(f);
104
105 if (!face->at_boundary())
106 continue;
107
108 /*
109 * We want slip everywhere except right edge of tank.
110 */
111
112 face->set_boundary_id(Boundary::slip);
113
114 const auto center = face->center();
115 if (center[0] > flume_length - tolerance)
116 face->set_boundary_id(Boundary::dynamic);
117
118 } /*f*/
119 } /*cell*/
120 }
121#endif
122 } // namespace GridGenerator
123
124
125 namespace Geometries
126 {
132 template <int dim>
133 class WaveTank : public Geometry<dim>
134 {
135 public:
136 WaveTank(const std::string &subsection)
137 : Geometry<dim>("wave tank", subsection)
138 {
139 reservoir_length_ = 157. / 100.;
140 this->add_parameter("reservoir length",
141 reservoir_length_,
142 "length of water reservoir [meters]");
143
144 reservoir_width_ = 81 / 100.;
145 this->add_parameter("reservoir width",
146 reservoir_width_,
147 "width of water reservoir [meters]");
148
149 flume_length_ = 600.78 / 100.;
150 this->add_parameter(
151 "flume length", flume_length_, "length of flume [meters]");
152
153 flume_width_ = 24 / 100.;
154 this->add_parameter(
155 "flume width", flume_width_, "width of flume [meters]");
156 }
157
159 dealii::Triangulation<dim> &triangulation) const final
160 {
161 GridGenerator::wavetank(triangulation,
162 reservoir_length_,
163 reservoir_width_,
164 flume_length_,
165 flume_width_);
166 }
167
168 private:
169 double reservoir_length_;
170 double reservoir_width_;
171 double flume_length_;
172 double flume_width_;
173 };
174 } // namespace Geometries
175} // namespace ryujin
void create_coarse_triangulation(dealii::Triangulation< dim > &triangulation) const final
WaveTank(const std::string &subsection)
void wavetank(Triangulation< dim, spacedim > &, const double, const double, const double, const double)