16 if constexpr (dim == 1 || spacedim == 1)
21 "The uniform_channel_with_meshed_cylinder mesh is only supported in 2D and 3D space."));
24 else if constexpr (dim == 2 && spacedim == 3)
29 "The uniform_channel_with_meshed_cylinder mesh is only supported in 3D space with 3D elements."));
33 const std::vector<std::string> arguments =
34 Utilities::split_string_list(grid_arguments,
':');
36 if (arguments.size() < 5)
41 "Mandatory uniform_channel_with_meshed_cylinder parameters are (bottom left point : top right point : center of the cylinder : inner radius : outer radius). The points should be given as x,y and the radii should be given as a single number. The optional parameters are (pad bottom : pad top : pad left : pad right : height : n_slices : use_transfinite_region : mesh_obstacle : colorize). The padding parameters should be given as a single integer, the height should be given as a single double, the n_slices should be given as a single integer, use_transfinite_region should be given as true/false, mesh_obstacle should be given as true/false, and the colorize parameter should be given as true/false."));
49 Point<dim>(bottom_left_coords[0], bottom_left_coords[1]) :
50 Point<dim>(bottom_left_coords[0], bottom_left_coords[1], 0.0);
52 catch (
const std::exception &e)
57 "The bottom left point should have 2 components coordinates (x,y format) because the channel is extruded in the z direction."));
65 (dim == 2) ? Point<dim>(top_right_coords[0], top_right_coords[1]) :
66 Point<dim>(top_right_coords[0], top_right_coords[1], 0.0);
68 catch (
const std::exception &e)
73 "The top right point should have 2 components coordinates (x,y format) because the channel is extruded in the z direction."));
81 this->
center = (dim == 2) ?
82 Point<dim>(center_coords[0], center_coords[1]) :
83 Point<dim>(center_coords[0], center_coords[1], 0.0);
85 catch (
const std::exception &e)
90 "The center point should have 2 components coordinates (x,y format) because the channel is extruded in the z direction."));
94 this->
inner_radius = Utilities::string_to_double(arguments[3]);
97 this->
outer_radius = Utilities::string_to_double(arguments[4]);
105 "The cylinder outer radius does not fit in the channel."));
110 (arguments.size() > 5) ? Utilities::string_to_int(arguments[5]) : 0;
112 (arguments.size() > 6) ? Utilities::string_to_int(arguments[6]) : 0;
114 (arguments.size() > 7) ? Utilities::string_to_int(arguments[7]) : 0;
116 (arguments.size() > 8) ? Utilities::string_to_int(arguments[8]) : 0;
122 ExcMessage(
"Bottom padding is required because the transition "
123 "region does not reach the bottom channel boundary."));
124 AssertThrow(!((
pad_top == 0) &&
126 ExcMessage(
"Top padding is required because the transition "
127 "region does not reach the top channel boundary."));
130 ExcMessage(
"Left padding is required because the transition "
131 "region does not reach the left channel boundary."));
134 ExcMessage(
"Right padding is required because the transition "
135 "region does not reach the right channel boundary."));
138 (arguments.size() > 9) ? Utilities::string_to_double(arguments[9]) : 1.0;
140 (arguments.size() > 10) ? Utilities::string_to_int(arguments[10]) : 2.;
141 AssertThrow(
n_slices >= 2, ExcMessage(
"The minimum number of slices is 2."));
143 (arguments.size() > 11 && arguments[11] ==
"true") ? true :
false;
145 (arguments.size() > 12 && arguments[12] ==
"true") ? true :
false;
147 (arguments.size() > 13 && arguments[13] ==
"true") ? true :
false;
154 Triangulation<2> &triangulation,
166 const types::material_id fluid_material_id = 0;
167 const types::material_id solid_material_id = 1;
168 const types::manifold_id tfi_manifold_id = 0;
169 const types::manifold_id polar_manifold_id = 1;
172 Triangulation<2> cylinder_tria;
179 Triangulation<2> box_tria;
181 for (
const auto &cell : box_tria.active_cell_iterators())
183 for (
unsigned int v = 0; v < GeometryInfo<2>::vertices_per_cell; ++v)
185 Point<2> &vertex = cell->vertex(v);
186 const double dist = vertex.distance(
center);
189 (std::abs(std::abs(vertex[0] -
center[0]) -
190 std::abs(vertex[1] -
center[1]))) <
193 vertex =
center + std::numbers::sqrt2 * (vertex -
center);
201 Triangulation<2> pad_bottom_tria;
204 GridGenerator::subdivided_hyper_rectangle(
211 Triangulation<2> pad_top_tria;
214 GridGenerator::subdivided_hyper_rectangle(
221 Triangulation<2> pad_left_tria;
224 GridGenerator::subdivided_hyper_rectangle(
231 Triangulation<2> pad_right_tria;
234 GridGenerator::subdivided_hyper_rectangle(
241 Triangulation<2> pad_bottom_left_corner_tria;
244 GridGenerator::subdivided_hyper_rectangle(
245 pad_bottom_left_corner_tria,
251 Triangulation<2> pad_bottom_right_corner_tria;
254 GridGenerator::subdivided_hyper_rectangle(
255 pad_bottom_right_corner_tria,
261 Triangulation<2> pad_top_left_corner_tria;
264 GridGenerator::subdivided_hyper_rectangle(
265 pad_top_left_corner_tria,
271 Triangulation<2> pad_top_right_corner_tria;
274 GridGenerator::subdivided_hyper_rectangle(
275 pad_top_right_corner_tria,
282 std::vector<const Triangulation<2> *> trias = {&cylinder_tria, &box_tria};
284 trias.push_back(&pad_bottom_tria);
286 trias.push_back(&pad_top_tria);
288 trias.push_back(&pad_left_tria);
290 trias.push_back(&pad_right_tria);
292 trias.push_back(&pad_bottom_left_corner_tria);
294 trias.push_back(&pad_bottom_right_corner_tria);
296 trias.push_back(&pad_top_left_corner_tria);
298 trias.push_back(&pad_top_right_corner_tria);
299 GridGenerator::merge_triangulations(trias, triangulation);
306 triangulation.reset_all_manifolds();
307 triangulation.set_all_manifold_ids(
310 for (
const auto &cell : triangulation.active_cell_iterators())
318 if (cell_in_cylinder)
320 cell->set_material_id(solid_material_id);
327 cell->set_material_id(fluid_material_id);
334 std::set<typename Triangulation<2>::active_cell_iterator> obstacle_cells;
335 for (
const auto &cell : triangulation.active_cell_iterators())
336 if (cell->material_id() == solid_material_id)
337 obstacle_cells.insert(cell);
339 Triangulation<2> temp_tria;
340 GridGenerator::create_triangulation_with_removed_cells(triangulation,
343 triangulation.clear();
344 triangulation.copy_triangulation(temp_tria);
355 for (
const auto &face : triangulation.active_face_iterators())
357 if (!face->at_boundary())
360 const Point<2> face_center = face->center();
362 if (std::abs(face_center[0] -
bottom_left[0]) < tol_x)
364 else if (std::abs(face_center[0] -
top_right[0]) < tol_x)
366 else if (std::abs(face_center[1] -
bottom_left[1]) < tol_y)
368 else if (std::abs(face_center[1] -
top_right[1]) < tol_y)
371 face->set_boundary_id(0);
376 for (
const auto &cell : triangulation.active_cell_iterators())
378 for (
const auto &face : cell->face_iterators())
380 bool all_vertices_on_circle =
true;
381 for (
unsigned int v = 0; v < GeometryInfo<2>::vertices_per_face; ++v)
386 all_vertices_on_circle =
false;
390 if (all_vertices_on_circle)
391 face->set_all_manifold_ids(polar_manifold_id);
394 PolarManifold<2, 2> polar_manifold(
center);
395 triangulation.set_manifold(1, polar_manifold);
401 TransfiniteInterpolationManifold<2> tfi_manifold;
402 tfi_manifold.initialize(triangulation);
403 triangulation.set_manifold(0, tfi_manifold);
431 Triangulation<3, 3> &triangulation)
434 Triangulation<2> tria_2D;
449 GridGenerator::extrude_triangulation(
454 const Tensor<1, 3> direction{{0.0, 0.0, 1.0}};
455 const CylindricalManifold<3> cylindrical_manifold(direction,
center);
456 triangulation.set_manifold(1, cylindrical_manifold);
460 TransfiniteInterpolationManifold<3> tfi_manifold;
461 tfi_manifold.initialize(triangulation);
462 triangulation.set_manifold(0, tfi_manifold);
468 for (
const auto &face : triangulation.active_face_iterators())
470 if (!face->at_boundary())
473 const Point<3> face_center = face->center();