12 namespace GridGenerator
28 template <
int dim,
int spacedim,
template <
int,
int>
class Triangulation>
35 AssertThrow(
false, dealii::ExcNotImplemented());
41 template <
template <
int,
int>
class Triangulation>
42 void cylinder(Triangulation<2, 2> &triangulation,
45 const double cylinder_position,
46 const double cylinder_diameter)
48 constexpr int dim = 2;
50 using namespace dealii;
52 dealii::Triangulation<dim, dim> tria1, tria2, tria3, tria4, tria5, tria6,
55 GridGenerator::hyper_cube_with_cylindrical_hole(
56 tria1, cylinder_diameter / 2., cylinder_diameter, 0.5, 1,
false);
58 GridGenerator::subdivided_hyper_rectangle(
61 Point<2>(-cylinder_diameter, -cylinder_diameter),
62 Point<2>(cylinder_diameter, -height / 2.));
64 GridGenerator::subdivided_hyper_rectangle(
67 Point<2>(-cylinder_diameter, cylinder_diameter),
68 Point<2>(cylinder_diameter, height / 2.));
70 GridGenerator::subdivided_hyper_rectangle(
73 Point<2>(cylinder_diameter, -cylinder_diameter),
74 Point<2>(length - cylinder_position, cylinder_diameter));
76 GridGenerator::subdivided_hyper_rectangle(
79 Point<2>(cylinder_diameter, cylinder_diameter),
80 Point<2>(length - cylinder_position, height / 2.));
82 GridGenerator::subdivided_hyper_rectangle(
85 Point<2>(cylinder_diameter, -height / 2.),
86 Point<2>(length - cylinder_position, -cylinder_diameter));
88 tria7.set_mesh_smoothing(triangulation.get_mesh_smoothing());
89 GridGenerator::merge_triangulations(
90 {&tria1, &tria2, &tria3, &tria4, &tria5, &tria6},
94 triangulation.copy_triangulation(tria7);
98 triangulation.set_manifold(0, PolarManifold<2>(Point<2>()));
102 for (
auto cell : triangulation.active_cell_iterators())
103 for (
unsigned int v : cell->vertex_indices()) {
104 auto &vertex = cell->vertex(v);
105 if (vertex[0] <= -cylinder_diameter + 1.e-6)
106 vertex[0] = -cylinder_position;
113 for (
auto cell : triangulation.active_cell_iterators()) {
114 for (
auto f : cell->face_indices()) {
115 const auto face = cell->face(f);
117 if (!face->at_boundary())
127 const auto center = face->center();
129 if (center[0] > length - cylinder_position - 1.e-6) {
134 if (center[0] < -cylinder_position + 1.e-6) {
146 template <
template <
int,
int>
class Triangulation>
147 void cylinder(Triangulation<3, 3> &triangulation,
150 const double cylinder_position,
151 const double cylinder_diameter)
153 using namespace dealii;
155 dealii::Triangulation<2, 2> tria1;
157 cylinder(tria1, length, height, cylinder_position, cylinder_diameter);
159 dealii::Triangulation<3, 3> tria2;
160 tria2.set_mesh_smoothing(triangulation.get_mesh_smoothing());
162 GridGenerator::extrude_triangulation(tria1, 4, height, tria2,
true);
163 GridTools::transform(
164 [height](
auto point) {
165 return point - dealii::Tensor<1, 3>{{0, 0, height / 2.}};
169 triangulation.copy_triangulation(tria2);
175 triangulation.set_manifold(
176 0, CylindricalManifold<3>(Tensor<1, 3>{{0., 0., 1.}}, Point<3>()));
182 for (
auto cell : triangulation.active_cell_iterators()) {
183 for (
auto f : cell->face_indices()) {
184 const auto face = cell->face(f);
186 if (!face->at_boundary())
196 const auto center = face->center();
198 if (center[0] > length - cylinder_position - 1.e-6) {
203 if (center[0] < -cylinder_position + 1.e-6) {
230 :
Geometry<dim>(
"cylinder", subsection)
234 "length", length_,
"length of computational domain");
238 "height", height_,
"height of computational domain");
240 object_position_ = 0.6;
241 this->add_parameter(
"object position",
243 "x position of immersed cylinder center point");
245 object_diameter_ = 0.5;
246 this->add_parameter(
"object diameter",
248 "diameter of immersed cylinder");
264 double object_position_;
265 double object_diameter_;
Cylinder(const std::string subsection)
void create_triangulation(typename Geometry< dim >::Triangulation &triangulation) final
typename Discretization< dim >::Triangulation Triangulation
void cylinder(Triangulation< dim, spacedim > &, const double, const double, const double, const double)