49 : airfoil_type(
"NACA")
51 , joukowski_center(-0.1, 0.14)
57 , incline_factor(0.35)
60 , n_subdivision_x_0(3)
61 , n_subdivision_x_1(2)
62 , n_subdivision_x_2(5)
64 , airfoil_sampling_factor(2)
69 "Mesh is to small to enclose airfoil! Choose larger field or smaller"
71 Assert(incline_factor < 1.0 && incline_factor >= 0.0,
72 ExcMessage(
"incline_factor has to be in [0,1)!"));
85 "Mesh height measured from airfoil nose to horizontal boundaries");
89 "Length measured from airfoil leading edge to vertical outlet boundary");
93 "Define obliqueness of the vertical mesh around the airfoil");
102 "Type of airfoil geometry, either NACA or Joukowski airfoil",
117 "Joukowski circle center coordinates");
120 "Joukowski airfoil length leading to trailing edge");
128 "Number of global refinements");
130 "NumberSubdivisionX0",
132 "Number of subdivisions along the airfoil in blocks with material ID 1 and 4");
134 "NumberSubdivisionX1",
136 "Number of subdivisions along the airfoil in blocks with material ID 2 and 5");
138 "NumberSubdivisionX2",
140 "Number of subdivisions in horizontal direction on the right of the trailing edge, i.e., blocks with material ID 3 and 6");
143 "Number of subdivisions normal to airfoil");
147 "Factor to obtain a finer mesh at the airfoil surface");
162 static const unsigned int id_block_1 = 1;
163 static const unsigned int id_block_2 = 2;
164 static const unsigned int id_block_3 = 3;
165 static const unsigned int id_block_4 = 4;
166 static const unsigned int id_block_5 = 5;
167 static const unsigned int id_block_6 = 6;
172 MeshGenerator(
const AdditionalData &data)
173 : refinements(data.refinements)
174 , n_subdivision_x_0(data.n_subdivision_x_0)
175 , n_subdivision_x_1(data.n_subdivision_x_1)
176 , n_subdivision_x_2(data.n_subdivision_x_2)
177 , n_subdivision_y(data.n_subdivision_y)
179 , length_b2(data.length_b2)
180 , incline_factor(data.incline_factor)
181 , bias_factor(data.bias_factor)
183 , n_cells_x_0(Utilities::
pow(2, refinements) * n_subdivision_x_0)
184 , n_cells_x_1(Utilities::
pow(2, refinements) * n_subdivision_x_1)
185 , n_cells_x_2(Utilities::
pow(2, refinements) * n_subdivision_x_2)
186 , n_cells_y(Utilities::
pow(2, refinements) * n_subdivision_y)
187 , n_points_on_each_side(n_cells_x_0 + n_cells_x_1 + 1)
189 , airfoil_1D(set_airfoil_length(
191 data.airfoil_type ==
"Joukowski" ?
192 joukowski(data.joukowski_center,
193 n_points_on_each_side,
194 data.airfoil_sampling_factor) :
195 (data.airfoil_type ==
"NACA" ?
197 n_points_on_each_side,
198 data.airfoil_sampling_factor) :
199 std::array<std::vector<Point<2>>, 2>{
200 {std::vector<Point<2>>{Point<2>(0), Point<2>(1)},
201 std::vector<Point<2>>{
205 data.airfoil_length))
206 , end_b0_x_u(airfoil_1D[0][n_cells_x_0][0])
207 , end_b0_x_l(airfoil_1D[1][n_cells_x_0][0])
208 , nose_x(airfoil_1D[0].front()[0])
209 , tail_x(airfoil_1D[0].back()[0])
210 , tail_y(airfoil_1D[0].back()[1])
211 , center_mesh(0.5 *
std::abs(end_b0_x_u + end_b0_x_l))
212 , length_b1_x(tail_x - center_mesh)
214 (edge_length +
std::abs(nose_x - center_mesh))))
218 ,
A(nose_x - edge_length, 0)
227 ,
J(tail_x + length_b2, 0)
231 Assert(data.airfoil_type ==
"Joukowski" ||
232 data.airfoil_type ==
"NACA",
241 Triangulation<2> &tria_grid,
242 std::vector<GridTools::PeriodicFacePair<
245 make_coarse_grid(tria_grid);
247 set_boundary_ids(tria_grid);
249 if (periodic_faces !=
nullptr)
252 tria_grid, 5, 4, 1, *periodic_faces);
265 parallel::fullydistributed::Triangulation<2> ¶llel_grid,
266 std::vector<GridTools::PeriodicFacePair<
270 (void)periodic_faces;
277 const unsigned int refinements;
280 const unsigned int n_subdivision_x_0;
283 const unsigned int n_subdivision_x_1;
286 const unsigned int n_subdivision_x_2;
290 const unsigned int n_subdivision_y;
297 const double length_b2;
301 const double incline_factor;
304 const double bias_factor;
307 const double edge_length;
310 const unsigned int n_cells_x_0;
313 const unsigned int n_cells_x_1;
316 const unsigned int n_cells_x_2;
320 const unsigned int n_cells_y;
323 const unsigned int n_points_on_each_side;
327 const std::array<std::vector<Point<2>>, 2> airfoil_1D;
331 const double end_b0_x_u;
335 const double end_b0_x_l;
349 const double center_mesh;
352 const double length_b1_x;
379 const Point<2>
A, B,
C, D,
E,
F, G, H, I,
J,
K,
L;
418 static std::array<std::vector<Point<2>>, 2>
419 joukowski(
const Point<2> ¢erpoint,
420 const unsigned int number_points,
421 const unsigned int factor)
423 std::array<std::vector<Point<2>>, 2> airfoil_1D;
424 const unsigned int total_points = 2 * number_points - 2;
425 const unsigned int n_airfoilpoints = factor * total_points;
427 const auto jouk_points =
428 joukowski_transform(joukowski_circle(centerpoint, n_airfoilpoints));
431 std::vector<Point<2>> upper_points;
432 std::vector<Point<2>> lower_points;
436 unsigned int nose_index = 0;
437 unsigned int tail_index = 0;
438 double nose_x_coordinate = 0;
439 double tail_x_coordinate = 0;
443 for (
unsigned int i = 0; i < jouk_points.size(); ++i)
445 if (jouk_points[i][0] < nose_x_coordinate)
447 nose_x_coordinate = jouk_points[i][0];
450 if (jouk_points[i][0] > tail_x_coordinate)
452 tail_x_coordinate = jouk_points[i][0];
458 for (
unsigned int i = tail_index; i < jouk_points.size(); ++i)
459 upper_points.emplace_back(jouk_points[i]);
460 for (
unsigned int i = 0; i <= nose_index; ++i)
461 upper_points.emplace_back(jouk_points[i]);
462 std::reverse(upper_points.begin(), upper_points.end());
465 lower_points.insert(lower_points.end(),
466 jouk_points.begin() + nose_index,
467 jouk_points.begin() + tail_index + 1);
470 airfoil_1D[0] = make_points_equidistant(upper_points, number_points);
471 airfoil_1D[1] = make_points_equidistant(lower_points, number_points);
474 auto move_nose_to_origin = [](std::vector<Point<2>> &vector) {
475 const double nose_x_pos = vector.front()[0];
476 for (
auto &i : vector)
480 move_nose_to_origin(airfoil_1D[1]);
481 move_nose_to_origin(airfoil_1D[0]);
510 static std::vector<Point<2>>
511 joukowski_circle(
const Point<2> ¢er,
512 const unsigned int number_points)
514 std::vector<Point<2>> circle_points;
522 (1 - center[0]) * (1 - center[0]));
524 center[1] * center[1] + (1 + center[0]) * (1 + center[0]));
530 "Error creating lower circle: Circle for Joukowski-transform does"
531 " not enclose point zeta = -1! Choose different center "
537 circle_points.reserve(number_points);
538 for (
unsigned int i = 0; i < number_points; ++i)
539 circle_points.emplace_back(center[0] -
radius *
std::cos(i * theta),
543 return circle_points;
554 static std::vector<Point<2>>
555 joukowski_transform(
const std::vector<Point<2>> &circle_points)
557 std::vector<Point<2>> joukowski_points(circle_points.size());
560 for (
unsigned int i = 0; i < circle_points.size(); ++i)
562 const double chi = circle_points[i][0];
563 const double eta = circle_points[i][1];
564 const std::complex<double> zeta(chi, eta);
565 const std::complex<double> z = zeta + 1. / zeta;
567 joukowski_points[i] = {std::real(z), std::imag(z)};
569 return joukowski_points;
588 static std::array<std::vector<Point<2>>, 2>
589 naca(
const std::string &serialnumber,
590 const unsigned int number_points,
591 const unsigned int factor)
595 const unsigned int n_airfoilpoints = factor * number_points;
598 return {{make_points_equidistant(
599 naca_create_points(serialnumber, n_airfoilpoints,
true),
601 make_points_equidistant(
602 naca_create_points(serialnumber, n_airfoilpoints,
false),
617 static std::vector<Point<2>>
618 naca_create_points(
const std::string &serialnumber,
619 const unsigned int number_points,
622 Assert(serialnumber.size() == 4,
623 ExcMessage(
"This NACA-serial number is not implemented!"));
625 return naca_create_points_4_digits(serialnumber,
644 static std::vector<Point<2>>
645 naca_create_points_4_digits(
const std::string &serialnumber,
646 const unsigned int number_points,
650 const unsigned int digit_0 = (serialnumber[0] -
'0');
651 const unsigned int digit_1 = (serialnumber[1] -
'0');
652 const unsigned int digit_2 = (serialnumber[2] -
'0');
653 const unsigned int digit_3 = (serialnumber[3] -
'0');
655 const unsigned int digit_23 = 10 * digit_2 + digit_3;
658 const double t =
static_cast<double>(digit_23) / 100.0;
660 std::vector<Point<2>> naca_points;
662 if (digit_0 == 0 && digit_1 == 0)
663 for (
unsigned int i = 0; i < number_points; ++i)
665 const double x = i * 1 / (1.0 * number_points - 1);
675 naca_points.emplace_back(x, +y_t);
677 naca_points.emplace_back(x, -y_t);
680 for (
unsigned int i = 0; i < number_points; ++i)
682 const double m = 1.0 * digit_0 / 100;
683 const double p = 1.0 * digit_1 / 10;
684 const double x = i * 1 / (1.0 * number_points - 1);
691 ((1 - 2 * p) + 2 * p * x - Utilities::
fixed_power<2>(x));
695 2 * m / Utilities::
fixed_power<2>(1 - p) * (p - x);
708 naca_points.emplace_back(x - y_t *
std::sin(theta),
711 naca_points.emplace_back(x + y_t *
std::sin(theta),
728 static std::array<std::vector<Point<2>>, 2>
729 set_airfoil_length(
const std::array<std::vector<Point<2>>, 2> &input,
730 const double desired_len)
732 std::array<std::vector<Point<2>>, 2> output;
733 output[0] = set_airfoil_length(input[0], desired_len);
734 output[1] = set_airfoil_length(input[1], desired_len);
746 static std::vector<Point<2>>
747 set_airfoil_length(
const std::vector<Point<2>> &input,
748 const double desired_len)
750 std::vector<Point<2>> output = input;
753 desired_len / input.front().distance(input.back());
755 for (
auto &x : output)
771 static std::vector<Point<2>>
772 make_points_equidistant(
773 const std::vector<Point<2>> &non_equidistant_points,
774 const unsigned int number_points)
776 const unsigned int n_points =
777 non_equidistant_points
781 std::vector<double> arclength_L(non_equidistant_points.size(), 0);
782 for (
unsigned int i = 0; i < non_equidistant_points.size() - 1; ++i)
785 non_equidistant_points[i + 1].distance(non_equidistant_points[i]);
788 const auto airfoil_length =
790 const auto deltaX = airfoil_length / (number_points - 1);
794 std::vector<Point<2>> equidist(
797 equidist[0] = non_equidistant_points[0];
798 equidist[number_points - 1] = non_equidistant_points[n_points - 1];
802 for (
unsigned int j = 0, i = 1; j < n_points - 1; ++j)
805 const auto Lj = arclength_L[j];
806 const auto Ljp = arclength_L[j + 1];
808 while (Lj <= i * deltaX && i * deltaX <= Ljp &&
809 i < number_points - 1)
811 equidist[i] = Point<2>((i * deltaX - Lj) / (Ljp - Lj) *
812 (non_equidistant_points[j + 1] -
813 non_equidistant_points[j]) +
814 non_equidistant_points[j]);
830 make_coarse_grid(Triangulation<2> &tria)
const
834 std::vector<Triangulation<2>> trias(10);
837 auto make = [](Triangulation<2> &tria,
838 const std::vector<Point<2>> &corner_vertices,
839 const std::vector<unsigned int> &repetitions,
851 auto &
point = it->vertex();
852 const double xi =
point[0];
853 const double eta =
point[1];
856 point = 0.25 * ((1 - xi) * (1 - eta) * corner_vertices[0] +
857 (1 + xi) * (1 - eta) * corner_vertices[1] +
858 (1 - xi) * (1 + eta) * corner_vertices[2] +
859 (1 + xi) * (1 + eta) * corner_vertices[3]);
864 cell->set_material_id(material_id);
871 {n_subdivision_y, n_subdivision_x_0},
875 {n_subdivision_y, n_subdivision_x_0},
879 {n_subdivision_x_1, n_subdivision_y},
883 {n_subdivision_x_1, n_subdivision_y},
887 {n_subdivision_x_2, n_subdivision_y},
891 {n_subdivision_x_2, n_subdivision_y},
916 set_boundary_ids(Triangulation<2> &tria)
919 for (
const unsigned int f : cell->face_indices())
921 if (cell->face(f)->at_boundary() ==
false)
924 const auto mid = cell->material_id();
926 if ((mid == id_block_1 && f == 0) ||
927 (mid == id_block_4 && f == 0))
928 cell->face(f)->set_boundary_id(0);
929 else if ((mid == id_block_3 && f == 0) ||
930 (mid == id_block_6 && f == 2))
931 cell->face(f)->set_boundary_id(1);
932 else if ((mid == id_block_1 && f == 1) ||
933 (mid == id_block_2 && f == 1))
934 cell->face(f)->set_boundary_id(2);
935 else if ((mid == id_block_4 && f == 1) ||
936 (mid == id_block_5 && f == 3))
937 cell->face(f)->set_boundary_id(3);
938 else if ((mid == id_block_2 && f == 0) ||
939 (mid == id_block_3 && f == 2))
940 cell->face(f)->set_boundary_id(4);
941 else if ((mid == id_block_5 && f == 2) ||
942 (mid == id_block_6 && f == 0))
943 cell->face(f)->set_boundary_id(5);
963 std::vector<bool> vertex_processed(tria.
n_vertices(),
false);
966 const Tensor<2, 2, double> rotation_matrix_1 =
968 const Tensor<2, 2, double> rotation_matrix_2 =
973 const Point<2, double> horizontal_offset(A[0], 0.0);
976 const Point<2, double> trapeze_offset(0.0,
981 for (
const unsigned int v : cell->vertex_indices())
984 if (vertex_processed[cell->vertex_index(v)])
988 vertex_processed[cell->vertex_index(v)] =
true;
990 auto &node = cell->vertex(v);
993 if (cell->material_id() == id_block_1 ||
994 cell->material_id() == id_block_4)
1002 Point<2, double> node_;
1003 if (cell->material_id() == id_block_1)
1005 node_ = Point<2, double>(rotation_matrix_1 *
1006 (node - horizontal_offset) +
1012 else if (cell->material_id() == id_block_4)
1014 node_ = Point<2, double>(rotation_matrix_2 *
1015 (node - horizontal_offset) -
1021 const double trapeze_height =
1024 const double l_a =
std::cos(gamma) * edge_length;
1025 const double l_b = trapeze_height *
std::tan(gamma);
1027 const double x2 =
L - l_a - l_b;
1029 const double Dx = x1 + x2 + x3;
1030 const double deltax =
1032 const double dx = Dx / n_cells_x_0;
1033 const double dy = trapeze_height / n_cells_y;
1035 static_cast<int>(std::round((node_[0] - deltax) / dx));
1037 static_cast<int>(std::round(
std::abs(node_[1]) / dy));
1039 node_[0] =
numbers::PI / 2 * (1.0 * ix) / n_cells_x_0;
1040 node_[1] =
height * (1.0 * iy) / n_cells_y;
1047 const double dy =
height / n_cells_y;
1049 static_cast<int>(std::round(node_[0] / dx));
1051 static_cast<int>(std::round(node_[1] / dy));
1052 const double alpha =
1053 bias_alpha(1 - (1.0 * iy) / n_cells_y);
1054 const double theta = node_[0];
1056 ((cell->material_id() == id_block_1) ?
1061 (cell->material_id() == id_block_1) ? (0) : (1))]
1067 else if (cell->material_id() == id_block_2 ||
1068 cell->material_id() == id_block_5)
1076 "Points D,C,G and E,F,I are not defined symmetric to "
1077 "x-axis, which is required to interpolate block 2"
1078 " and 5 with same geometric computations."));
1079 const double l_y = D[1] -
C[1];
1080 const double l_h = D[1] - l_y;
1081 const double by = -l_h / length_b1_x * (node[0] - H[0]);
1082 const double dy = (
height - by) / n_cells_y;
1083 const int iy =
static_cast<int>(
1084 std::round((
std::abs(node[1]) - by) / dy));
1085 const double dx = length_b1_x / n_cells_x_1;
1086 const int ix =
static_cast<int>(
1087 std::round(
std::abs(node[0] - center_mesh) / dx));
1089 const double alpha = bias_alpha(1 - (1.0 * iy) / n_cells_y);
1093 const Point<2> p(ix * dx + center_mesh +
1094 incline_factor * length_b2 * ix /
1096 ((cell->material_id() == id_block_2) ?
1102 (cell->material_id() == id_block_2) ? (0) : (1))]
1103 [n_cells_x_0 + ix] *
1107 else if (cell->material_id() == id_block_3 ||
1108 cell->material_id() == id_block_6)
1111 const double dx = length_b2 / n_cells_x_2;
1112 const double dy =
height / n_cells_y;
1113 const int ix =
static_cast<int>(
1114 std::round(
std::abs(node[0] - H[0]) / dx));
1116 static_cast<int>(std::round(
std::abs(node[1]) / dy));
1118 const double alpha_y = bias_alpha(1 - 1.0 * iy / n_cells_y);
1119 const double alpha_x =
1120 bias_alpha(1 - (
static_cast<double>(ix)) / n_cells_x_2);
1124 const Point<2> p1(J[0] - (1 - incline_factor) * length_b2 *
1126 ((cell->material_id() == id_block_3) ?
1131 const Point<2> p2(J[0] - alpha_x * length_b2, tail_y);
1132 node = p1 * (1 - alpha_y) + p2 * alpha_y;
1152 bias_alpha(
double alpha)
const
1162 internal_create_triangulation(
1166 const AdditionalData &additional_data)
1168 MeshGenerator mesh_generator(additional_data);
1171 if (
auto *parallel_tria =
1174 mesh_generator.create_triangulation(*parallel_tria, periodic_faces);
1175 else if (
auto *parallel_tria =
dynamic_cast<
1178 mesh_generator.create_triangulation(*parallel_tria, periodic_faces);
1180 mesh_generator.create_triangulation(tria, periodic_faces);
1197 const AdditionalData &)
1207 const AdditionalData &additional_data)
1209 internal_create_triangulation(tria,
nullptr, additional_data);
1220 const AdditionalData &additional_data)
1222 internal_create_triangulation(tria, &periodic_faces, additional_data);
1233 const AdditionalData &additional_data)
1237 (void)additional_data;
1238 (void)periodic_faces;
1249 template <
int dim,
int spacedim>
1254 if constexpr (dim > 1)
1258 tria.
begin()->
face(f)->set_boundary_id(f);
1264 template <
int spacedim>
1274 if (cell->center()[0] > 0)
1275 cell->set_material_id(1);
1280 template <
int dim,
int spacedim>
1285 const double epsilon)
1298 for (; face != endface; ++face)
1299 if (face->at_boundary())
1300 if (face->boundary_id() == 0)
1304 if (
std::abs(center[0] - p1[0]) < epsilon)
1305 face->set_boundary_id(0);
1306 else if (
std::abs(center[0] - p2[0]) < epsilon)
1307 face->set_boundary_id(1);
1308 else if (dim > 1 &&
std::abs(center[1] - p1[1]) < epsilon)
1309 face->set_boundary_id(2);
1310 else if (dim > 1 &&
std::abs(center[1] - p2[1]) < epsilon)
1311 face->set_boundary_id(3);
1312 else if (dim > 2 &&
std::abs(center[2] - p1[2]) < epsilon)
1313 face->set_boundary_id(4);
1314 else if (dim > 2 &&
std::abs(center[2] - p2[2]) < epsilon)
1315 face->set_boundary_id(5);
1327 for (
unsigned int d = 0;
d < dim; ++
d)
1328 if (cell->center()[d] > 0)
1330 cell->set_material_id(
id);
1339 template <
int spacdim>
1352 for (
auto cell = tria.
begin(); cell != tria.
end(); ++cell)
1355 cell->face(2)->set_all_boundary_ids(1);
1379 cell->
face(4)->set_all_boundary_ids(1);
1383 cell->
face(2)->set_all_boundary_ids(1);
1387 cell->
face(2)->set_all_boundary_ids(1);
1391 cell->
face(0)->set_all_boundary_ids(1);
1395 cell->
face(2)->set_all_boundary_ids(1);
1399 cell->
face(0)->set_all_boundary_ids(1);
1401 else if (tria.
n_cells() == 12)
1410 cell->
face(5)->set_all_boundary_ids(1);
1413 else if (tria.
n_cells() == 96)
1420 unsigned int count = 0;
1422 if (cell->
face(5)->at_boundary())
1424 cell->
face(5)->set_all_boundary_ids(1);
1443 const double inner_radius,
1449 const double middle_radius =
1451 const double eps = 1
e-3 * middle_radius;
1456 const auto face = cell->
face(f);
1457 if (!face->at_boundary())
1460 const double face_center_radius =
1461 (face->center(
true) - center).norm();
1463 if (std::fabs(face->center()[0]) < eps)
1465 face->set_boundary_id(2);
1466 for (
const unsigned int line_no : face->line_indices())
1467 if (face->line(line_no)->at_boundary())
1468 if (std::fabs(face->line(line_no)->vertex(0).norm() -
1469 face->line(line_no)->vertex(1).norm()) > eps)
1470 face->line(line_no)->set_boundary_id(2);
1472 else if (std::fabs(face->center()[1]) < eps)
1474 face->set_boundary_id(3);
1475 for (
const unsigned int line_no : face->line_indices())
1476 if (face->line(line_no)->at_boundary())
1477 if (std::fabs(face->line(line_no)->vertex(0).norm() -
1478 face->line(line_no)->vertex(1).norm()) > eps)
1479 face->line(line_no)->set_boundary_id(3);
1481 else if (std::fabs(face->center()[2]) < eps)
1483 face->set_boundary_id(4);
1484 for (
const unsigned int line_no : face->line_indices())
1485 if (face->line(line_no)->at_boundary())
1486 if (std::fabs(face->line(line_no)->vertex(0).norm() -
1487 face->line(line_no)->vertex(1).norm()) > eps)
1488 face->line(line_no)->set_boundary_id(4);
1490 else if (face_center_radius <
1493 face->set_boundary_id(0);
1494 for (
const unsigned int line_no : face->line_indices())
1495 if (face->line(line_no)->at_boundary())
1496 if (std::fabs(face->line(line_no)->vertex(0).norm() -
1497 face->line(line_no)->vertex(1).norm()) < eps)
1498 face->line(line_no)->set_boundary_id(0);
1500 else if (face_center_radius >
1503 face->set_boundary_id(1);
1504 for (
const unsigned int line_no : face->line_indices())
1505 if (face->line(line_no)->at_boundary())
1506 if (std::fabs(face->line(line_no)->vertex(0).norm() -
1507 face->line(line_no)->vertex(1).norm()) < eps)
1508 face->line(line_no)->set_boundary_id(1);
1518 template <
int dim,
int spacedim>
1523 const bool colorize)
1529 for (
unsigned int i = 0; i < dim; ++i)
1535 std::vector<Point<spacedim>> vertices(
1544 vertices[0] = vertices[1] = p1;
1545 vertices[2] = vertices[3] = p2;
1547 vertices[1][0] = p2[0];
1548 vertices[2][0] = p1[0];
1551 vertices[0] = vertices[1] = vertices[2] = vertices[3] = p1;
1552 vertices[4] = vertices[5] = vertices[6] = vertices[7] = p2;
1554 vertices[1][0] = p2[0];
1555 vertices[2][1] = p2[1];
1556 vertices[3][0] = p2[0];
1557 vertices[3][1] = p2[1];
1559 vertices[4][0] = p1[0];
1560 vertices[4][1] = p1[1];
1561 vertices[5][1] = p1[1];
1562 vertices[6][0] = p1[0];
1570 std::vector<CellData<dim>> cells(1);
1571 for (
const unsigned int i :
1573 cells[0].vertices[i] = i;
1574 cells[0].material_id = 0;
1580 colorize_hyper_rectangle(tria);
1585 template <
int dim,
int spacedim>
1590 const bool colorize)
1593 ExcMessage(
"Invalid left-to-right bounds of hypercube"));
1596 for (
unsigned int i = 0; i < dim; ++i)
1617 for (
unsigned int d = 0;
d < dim; ++
d)
1618 for (
unsigned int c = 1; c <= dim; ++c)
1619 vector_matrix[c - 1][d] = vertices[c][d] - vertices[0][d];
1622 "Vertices of simplex must form a right handed system"));
1626 std::vector<Point<dim>> points = vertices;
1630 for (
unsigned int i = 0; i <= dim; ++i)
1632 points.push_back(0.5 * (points[i] + points[(i + 1) % (dim + 1)]));
1633 center += points[i];
1638 for (
unsigned int i = 1; i < dim; ++i)
1639 points.push_back(0.5 * (points[i - 1] + points[i + 1]));
1641 for (
unsigned int i = 0; i <= dim; ++i)
1642 points.push_back(1. / 3. *
1643 (points[i] + points[(i + 1) % (dim + 1)] +
1644 points[(i + 2) % (dim + 1)]));
1646 points.push_back((1. / (dim + 1)) * center);
1648 std::vector<CellData<dim>> cells(dim + 1);
1653 cells[0].vertices[0] = 0;
1654 cells[0].vertices[1] = 3;
1655 cells[0].vertices[2] = 5;
1656 cells[0].vertices[3] = 6;
1657 cells[0].material_id = 0;
1659 cells[1].vertices[0] = 3;
1660 cells[1].vertices[1] = 1;
1661 cells[1].vertices[2] = 6;
1662 cells[1].vertices[3] = 4;
1663 cells[1].material_id = 0;
1665 cells[2].vertices[0] = 5;
1666 cells[2].vertices[1] = 6;
1667 cells[2].vertices[2] = 2;
1668 cells[2].vertices[3] = 4;
1669 cells[2].material_id = 0;
1673 cells[0].vertices[0] = 0;
1674 cells[0].vertices[1] = 4;
1675 cells[0].vertices[2] = 8;
1676 cells[0].vertices[3] = 10;
1677 cells[0].vertices[4] = 7;
1678 cells[0].vertices[5] = 13;
1679 cells[0].vertices[6] = 12;
1680 cells[0].vertices[7] = 14;
1681 cells[0].material_id = 0;
1683 cells[1].vertices[0] = 4;
1684 cells[1].vertices[1] = 1;
1685 cells[1].vertices[2] = 10;
1686 cells[1].vertices[3] = 5;
1687 cells[1].vertices[4] = 13;
1688 cells[1].vertices[5] = 9;
1689 cells[1].vertices[6] = 14;
1690 cells[1].vertices[7] = 11;
1691 cells[1].material_id = 0;
1693 cells[2].vertices[0] = 8;
1694 cells[2].vertices[1] = 10;
1695 cells[2].vertices[2] = 2;
1696 cells[2].vertices[3] = 5;
1697 cells[2].vertices[4] = 12;
1698 cells[2].vertices[5] = 14;
1699 cells[2].vertices[6] = 6;
1700 cells[2].vertices[7] = 11;
1701 cells[2].material_id = 0;
1703 cells[3].vertices[0] = 7;
1704 cells[3].vertices[1] = 13;
1705 cells[3].vertices[2] = 12;
1706 cells[3].vertices[3] = 14;
1707 cells[3].vertices[4] = 3;
1708 cells[3].vertices[5] = 9;
1709 cells[3].vertices[6] = 6;
1710 cells[3].vertices[7] = 11;
1711 cells[3].material_id = 0;
1721 template <
int dim,
int spacedim>
1737 std::vector<Point<spacedim>> vertices(
reference_cell.n_vertices());
1741 for (
unsigned int d = 0;
d < dim; ++
d)
1742 vertices[v][d] = this_vertex[d];
1750 std::vector<CellData<dim>> cells(1);
1753 cells[0].vertices[v] = v;
1762 const unsigned int n_cells,
1763 const unsigned int n_rotations,
1767 const unsigned int dim = 3;
1770 "More than 4 cells are needed to create a moebius grid."));
1772 ExcMessage(
"Outer and inner radius must be positive."));
1774 ExcMessage(
"Outer radius must be greater than inner radius."));
1777 std::vector<Point<dim>> vertices(4 * n_cells);
1781 for (
unsigned int i = 0; i <
n_cells; ++i)
1782 for (
unsigned int j = 0; j < 4; ++j)
1784 vertices[4 * i + j][0] =
1788 vertices[4 * i + j][1] =
1792 vertices[4 * i + j][2] =
1796 unsigned int offset = 0;
1801 static constexpr std::array<unsigned int, 8> local_vertex_numbering{
1802 {0, 1, 5, 4, 2, 3, 7, 6}};
1803 std::vector<CellData<dim>> cells(n_cells);
1804 for (
unsigned int i = 0; i <
n_cells; ++i)
1806 for (
unsigned int j = 0; j < 2; ++j)
1808 cells[i].vertices[local_vertex_numbering[0 + 4 * j]] =
1810 cells[i].vertices[local_vertex_numbering[1 + 4 * j]] =
1812 cells[i].vertices[local_vertex_numbering[2 + 4 * j]] =
1814 cells[i].vertices[local_vertex_numbering[3 + 4 * j]] =
1818 cells[i].material_id = 0;
1822 cells[
n_cells - 1].vertices[local_vertex_numbering[4]] =
1823 (0 + n_rotations) % 4;
1824 cells[
n_cells - 1].vertices[local_vertex_numbering[5]] =
1825 (3 + n_rotations) % 4;
1826 cells[
n_cells - 1].vertices[local_vertex_numbering[6]] =
1827 (2 + n_rotations) % 4;
1828 cells[
n_cells - 1].vertices[local_vertex_numbering[7]] =
1829 (1 + n_rotations) % 4;
1840 const double centerline_radius,
1841 const double inner_radius,
1845 Assert(centerline_radius > inner_radius,
1846 ExcMessage(
"The centerline radius must be greater than the "
1848 Assert(inner_radius > 0.0,
1849 ExcMessage(
"The inner radius must be positive."));
1851 const unsigned int dim = 2;
1852 const unsigned int spacedim = 3;
1853 std::vector<Point<spacedim>> vertices(16);
1855 vertices[0] =
Point<spacedim>(centerline_radius - inner_radius, 0, 0);
1857 vertices[2] =
Point<spacedim>(centerline_radius + inner_radius, 0, 0);
1859 vertices[4] =
Point<spacedim>(0, 0, centerline_radius - inner_radius);
1861 vertices[6] =
Point<spacedim>(0, 0, centerline_radius + inner_radius);
1863 vertices[8] =
Point<spacedim>(-(centerline_radius - inner_radius), 0, 0);
1865 vertices[10] =
Point<spacedim>(-(centerline_radius + inner_radius), 0, 0);
1867 vertices[12] =
Point<spacedim>(0, 0, -(centerline_radius - inner_radius));
1869 vertices[14] =
Point<spacedim>(0, 0, -(centerline_radius + inner_radius));
1872 std::vector<CellData<dim>> cells(16);
1874 cells[0].vertices[0] = 0;
1875 cells[0].vertices[1] = 4;
1876 cells[0].vertices[2] = 3;
1877 cells[0].vertices[3] = 7;
1878 cells[0].material_id = 0;
1880 cells[1].vertices[0] = 1;
1881 cells[1].vertices[1] = 5;
1882 cells[1].vertices[2] = 0;
1883 cells[1].vertices[3] = 4;
1884 cells[1].material_id = 0;
1886 cells[2].vertices[0] = 2;
1887 cells[2].vertices[1] = 6;
1888 cells[2].vertices[2] = 1;
1889 cells[2].vertices[3] = 5;
1890 cells[2].material_id = 0;
1892 cells[3].vertices[0] = 3;
1893 cells[3].vertices[1] = 7;
1894 cells[3].vertices[2] = 2;
1895 cells[3].vertices[3] = 6;
1896 cells[3].material_id = 0;
1898 cells[4].vertices[0] = 4;
1899 cells[4].vertices[1] = 8;
1900 cells[4].vertices[2] = 7;
1901 cells[4].vertices[3] = 11;
1902 cells[4].material_id = 0;
1904 cells[5].vertices[0] = 5;
1905 cells[5].vertices[1] = 9;
1906 cells[5].vertices[2] = 4;
1907 cells[5].vertices[3] = 8;
1908 cells[5].material_id = 0;
1910 cells[6].vertices[0] = 6;
1911 cells[6].vertices[1] = 10;
1912 cells[6].vertices[2] = 5;
1913 cells[6].vertices[3] = 9;
1914 cells[6].material_id = 0;
1916 cells[7].vertices[0] = 7;
1917 cells[7].vertices[1] = 11;
1918 cells[7].vertices[2] = 6;
1919 cells[7].vertices[3] = 10;
1920 cells[7].material_id = 0;
1922 cells[8].vertices[0] = 8;
1923 cells[8].vertices[1] = 12;
1924 cells[8].vertices[2] = 11;
1925 cells[8].vertices[3] = 15;
1926 cells[8].material_id = 0;
1928 cells[9].vertices[0] = 9;
1929 cells[9].vertices[1] = 13;
1930 cells[9].vertices[2] = 8;
1931 cells[9].vertices[3] = 12;
1932 cells[9].material_id = 0;
1934 cells[10].vertices[0] = 10;
1935 cells[10].vertices[1] = 14;
1936 cells[10].vertices[2] = 9;
1937 cells[10].vertices[3] = 13;
1938 cells[10].material_id = 0;
1940 cells[11].vertices[0] = 11;
1941 cells[11].vertices[1] = 15;
1942 cells[11].vertices[2] = 10;
1943 cells[11].vertices[3] = 14;
1944 cells[11].material_id = 0;
1946 cells[12].vertices[0] = 12;
1947 cells[12].vertices[1] = 0;
1948 cells[12].vertices[2] = 15;
1949 cells[12].vertices[3] = 3;
1950 cells[12].material_id = 0;
1952 cells[13].vertices[0] = 13;
1953 cells[13].vertices[1] = 1;
1954 cells[13].vertices[2] = 12;
1955 cells[13].vertices[3] = 0;
1956 cells[13].material_id = 0;
1958 cells[14].vertices[0] = 14;
1959 cells[14].vertices[1] = 2;
1960 cells[14].vertices[2] = 13;
1961 cells[14].vertices[3] = 1;
1962 cells[14].material_id = 0;
1964 cells[15].vertices[0] = 15;
1965 cells[15].vertices[1] = 3;
1966 cells[15].vertices[2] = 14;
1967 cells[15].vertices[3] = 2;
1968 cells[15].material_id = 0;
1981 static constexpr int circle_cell_vertices[5][4] = {{0, 1, 2, 3},
1993 const double centerline_radius,
1994 const double inner_radius,
1995 const unsigned int n_cells_toroidal,
1998 Assert(centerline_radius > inner_radius,
1999 ExcMessage(
"The centerline radius must be greater than the "
2001 Assert(inner_radius > 0.0,
2002 ExcMessage(
"The inner radius must be positive."));
2004 ExcMessage(
"Number of cells in toroidal direction has "
2005 "to be at least 3 for a torus of polar extent 2*pi."));
2011 const double a = 1. / (1 +
std::sqrt(2.0));
2014 const unsigned int additional_layer =
2018 const unsigned int n_point_layers_toroidal =
2019 n_cells_toroidal + additional_layer;
2020 std::vector<Point<3>> vertices(8 * n_point_layers_toroidal);
2032 const double phi_cell = phi / n_cells_toroidal;
2033 for (
unsigned int c = 1; c < n_point_layers_toroidal; ++c)
2035 for (
unsigned int v = 0; v < 8; ++v)
2037 const double inner_radius_2d = vertices[v][0];
2038 vertices[8 * c + v][0] = inner_radius_2d *
std::cos(phi_cell * c);
2039 vertices[8 * c + v][1] = vertices[v][1];
2040 vertices[8 * c + v][2] = inner_radius_2d *
std::sin(phi_cell * c);
2045 std::vector<CellData<3>> cells(5 * n_cells_toroidal);
2046 for (
unsigned int c = 0; c < n_cells_toroidal; ++c)
2048 for (
unsigned int j = 0; j < 2; ++j)
2050 const unsigned int offset =
2051 (8 * (c + j)) % (8 * n_point_layers_toroidal);
2054 for (
unsigned int c2 = 0; c2 < 5; ++c2)
2055 for (
unsigned int i = 0; i < 4; ++i)
2056 cells[5 * c + c2].vertices[i + j * 4] =
2057 offset + circle_cell_vertices[c2][i];
2060 cells[5 * c].material_id = 0;
2062 cells[5 * c + 1].material_id = 0;
2063 cells[5 * c + 2].material_id = 1;
2064 cells[5 * c + 3].material_id = 0;
2065 cells[5 * c + 4].material_id = 0;
2080 if (cell->
face(f)->at_boundary() && f != 4 && f != 5)
2082 cell->
face(f)->set_all_manifold_ids(1);
2108 template <
int dim,
int spacedim>
2112 const bool colorize)
2123 for (
const unsigned int i : cell->vertex_indices())
2124 cell->vertex(i) = vertices[i];
2130 "The volume of the cell is not greater than zero. "
2131 "This could be due to the wrong ordering of the vertices."));
2159 const bool colorize)
2162 std::array<Tensor<1, 2>, 2> edges;
2163 edges[0] = corners[0];
2164 edges[1] = corners[1];
2165 std::vector<unsigned int> subdivisions;
2166 subdivided_parallelepiped<2, 2>(
2167 tria, origin, edges, subdivisions, colorize);
2176 const bool colorize)
2178 unsigned int n_subdivisions[dim];
2179 for (
unsigned int i = 0; i < dim; ++i)
2180 n_subdivisions[i] = 1;
2189 const unsigned int n_subdivisions,
2191 const bool colorize)
2195 unsigned int n_subdivisions_[dim];
2196 for (
unsigned int i = 0; i < dim; ++i)
2197 n_subdivisions_[i] = n_subdivisions;
2207 const unsigned int (&n_subdivisions)[dim],
2209 const unsigned int *n_subdivisions,
2212 const bool colorize)
2215 std::vector<unsigned int> subdivisions;
2216 std::array<Tensor<1, dim>, dim> edges;
2217 for (
unsigned int i = 0; i < dim; ++i)
2219 subdivisions.push_back(n_subdivisions[i]);
2220 edges[i] = corners[i];
2223 subdivided_parallelepiped<dim, dim>(
2224 tria, origin, edges, subdivisions, colorize);
2230 template <
int dim,
int spacedim>
2235 const std::vector<unsigned int> &subdivisions,
2236 const bool colorize)
2238 std::vector<unsigned int> compute_subdivisions = subdivisions;
2239 if (compute_subdivisions.empty())
2241 compute_subdivisions.resize(dim, 1);
2244 Assert(compute_subdivisions.size() == dim,
2245 ExcMessage(
"One subdivision must be provided for each dimension."));
2247 for (
unsigned int i = 0; i < dim; ++i)
2249 Assert(compute_subdivisions[i] > 0,
2250 ExcInvalidRepetitions(subdivisions[i]));
2252 edges[i].
norm() > 0,
2254 "Edges in subdivided_parallelepiped() must not be degenerate."));
2262 bool twisted_data =
false;
2267 twisted_data = (edges[0][0] < 0);
2274 const double plane_normal =
2275 edges[0][0] * edges[1][1] - edges[0][1] * edges[1][0];
2276 twisted_data = (plane_normal < 0.0);
2285 (edges[0].
norm() * edges[1].
norm()) -
2288 "Edges in subdivided_parallelepiped() must point in"
2289 " different directions."));
2305 twisted_data = (plane_normal * edges[2] < 0.0);
2313 ExcInvalidInputOrientation(
2314 "The triangulation you are trying to create will consist of cells"
2315 " with negative measures. This is usually the result of input data"
2316 " that does not define a right-handed coordinate system. The usual"
2317 " fix for this is to ensure that in 1d the given point is to the"
2318 " right of the origin (or the given edge tensor is positive), in 2d"
2319 " that the two edges (and their cross product) obey the right-hand"
2320 " rule (which may usually be done by switching the order of the"
2321 " points or edge tensors), or in 3d that the edges form a"
2322 " right-handed coordinate system (which may also be accomplished by"
2323 " switching the order of the first two points or edge tensors)."));
2326 for (
unsigned int i = 0; i < dim; ++i)
2327 for (
unsigned int j = i + 1; j < dim; ++j)
2328 Assert((edges[i] != edges[j]),
2330 "Degenerate edges of subdivided_parallelepiped encountered."));
2333 std::vector<Point<spacedim>> points;
2338 for (
unsigned int x = 0; x <= compute_subdivisions[0]; ++x)
2339 points.push_back(origin + edges[0] / compute_subdivisions[0] * x);
2343 for (
unsigned int y = 0; y <= compute_subdivisions[1]; ++y)
2344 for (
unsigned int x = 0; x <= compute_subdivisions[0]; ++x)
2345 points.push_back(origin + edges[0] / compute_subdivisions[0] * x +
2346 edges[1] / compute_subdivisions[1] * y);
2350 for (
unsigned int z = 0; z <= compute_subdivisions[2]; ++z)
2351 for (
unsigned int y = 0; y <= compute_subdivisions[1]; ++y)
2352 for (
unsigned int x = 0; x <= compute_subdivisions[0]; ++x)
2353 points.push_back(origin +
2354 edges[0] / compute_subdivisions[0] * x +
2355 edges[1] / compute_subdivisions[1] * y +
2356 edges[2] / compute_subdivisions[2] * z);
2365 for (
unsigned int i = 0; i < dim; ++i)
2366 n_cells *= compute_subdivisions[i];
2367 std::vector<CellData<dim>> cells(n_cells);
2373 for (
unsigned int x = 0; x < compute_subdivisions[0]; ++x)
2375 cells[x].vertices[0] = x;
2376 cells[x].vertices[1] = x + 1;
2379 cells[x].material_id = 0;
2386 const unsigned int n_dy = compute_subdivisions[1];
2387 const unsigned int n_dx = compute_subdivisions[0];
2389 for (
unsigned int y = 0; y < n_dy; ++y)
2390 for (
unsigned int x = 0; x < n_dx; ++x)
2392 const unsigned int c = y * n_dx + x;
2393 cells[c].vertices[0] = y * (n_dx + 1) + x;
2394 cells[c].vertices[1] = y * (n_dx + 1) + x + 1;
2395 cells[c].vertices[2] = (y + 1) * (n_dx + 1) + x;
2396 cells[c].vertices[3] = (y + 1) * (n_dx + 1) + x + 1;
2399 cells[c].material_id = 0;
2407 const unsigned int n_dz = compute_subdivisions[2];
2408 const unsigned int n_dy = compute_subdivisions[1];
2409 const unsigned int n_dx = compute_subdivisions[0];
2411 for (
unsigned int z = 0; z < n_dz; ++z)
2412 for (
unsigned int y = 0; y < n_dy; ++y)
2413 for (
unsigned int x = 0; x < n_dx; ++x)
2415 const unsigned int c = z * n_dy * n_dx + y * n_dx + x;
2417 cells[c].vertices[0] =
2418 z * (n_dy + 1) * (n_dx + 1) + y * (n_dx + 1) + x;
2419 cells[c].vertices[1] =
2420 z * (n_dy + 1) * (n_dx + 1) + y * (n_dx + 1) + x + 1;
2421 cells[c].vertices[2] =
2422 z * (n_dy + 1) * (n_dx + 1) + (y + 1) * (n_dx + 1) + x;
2423 cells[c].vertices[3] = z * (n_dy + 1) * (n_dx + 1) +
2424 (y + 1) * (n_dx + 1) + x + 1;
2425 cells[c].vertices[4] =
2426 (z + 1) * (n_dy + 1) * (n_dx + 1) + y * (n_dx + 1) + x;
2427 cells[c].vertices[5] = (z + 1) * (n_dy + 1) * (n_dx + 1) +
2428 y * (n_dx + 1) + x + 1;
2429 cells[c].vertices[6] = (z + 1) * (n_dy + 1) * (n_dx + 1) +
2430 (y + 1) * (n_dx + 1) + x;
2431 cells[c].vertices[7] = (z + 1) * (n_dy + 1) * (n_dx + 1) +
2432 (y + 1) * (n_dx + 1) + x + 1;
2435 cells[c].material_id = 0;
2454 for (
const unsigned int face : cell->face_indices())
2456 if (cell->face(face)->at_boundary())
2457 cell->face(face)->set_boundary_id(face);
2463 template <
int dim,
int spacedim>
2466 const unsigned int repetitions,
2469 const bool colorize)
2471 Assert(repetitions >= 1, ExcInvalidRepetitions(repetitions));
2473 ExcMessage(
"Invalid left-to-right bounds of hypercube"));
2476 for (
unsigned int i = 0; i < dim; ++i)
2482 std::vector<unsigned int> reps(dim, repetitions);
2488 template <
int dim,
int spacedim>
2491 const std::vector<unsigned int> &repetitions,
2494 const bool colorize)
2496 Assert(repetitions.size() == dim, ExcInvalidRepetitionsDimension(dim));
2502 for (
unsigned int i = 0; i < dim; ++i)
2509 std::array<Point<spacedim>, dim> delta;
2510 for (
unsigned int i = 0; i < dim; ++i)
2512 Assert(repetitions[i] >= 1, ExcInvalidRepetitions(repetitions[i]));
2514 delta[i][i] = (p2[i] - p1[i]) / repetitions[i];
2518 "The first dim entries of coordinates of p1 and p2 need to be different."));
2522 std::vector<Point<spacedim>> points;
2526 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
2527 points.push_back(p1 + x * delta[0]);
2531 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
2532 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
2533 points.push_back(p1 + x * delta[0] + y * delta[1]);
2537 for (
unsigned int z = 0; z <= repetitions[2]; ++z)
2538 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
2539 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
2540 points.push_back(p1 + x * delta[0] + y * delta[1] +
2549 std::vector<CellData<dim>> cells;
2554 cells.resize(repetitions[0]);
2555 for (
unsigned int x = 0; x < repetitions[0]; ++x)
2557 cells[x].vertices[0] = x;
2558 cells[x].vertices[1] = x + 1;
2559 cells[x].material_id = 0;
2566 cells.resize(repetitions[1] * repetitions[0]);
2567 for (
unsigned int y = 0; y < repetitions[1]; ++y)
2568 for (
unsigned int x = 0; x < repetitions[0]; ++x)
2570 const unsigned int c = x + y * repetitions[0];
2571 cells[c].vertices[0] = y * (repetitions[0] + 1) + x;
2572 cells[c].vertices[1] = y * (repetitions[0] + 1) + x + 1;
2573 cells[c].vertices[2] = (y + 1) * (repetitions[0] + 1) + x;
2574 cells[c].vertices[3] = (y + 1) * (repetitions[0] + 1) + x + 1;
2575 cells[c].material_id = 0;
2582 const unsigned int n_x = (repetitions[0] + 1);
2583 const unsigned int n_xy =
2584 (repetitions[0] + 1) * (repetitions[1] + 1);
2586 cells.resize(repetitions[2] * repetitions[1] * repetitions[0]);
2587 for (
unsigned int z = 0; z < repetitions[2]; ++z)
2588 for (
unsigned int y = 0; y < repetitions[1]; ++y)
2589 for (
unsigned int x = 0; x < repetitions[0]; ++x)
2591 const unsigned int c = x + y * repetitions[0] +
2592 z * repetitions[0] * repetitions[1];
2593 cells[c].vertices[0] = z * n_xy + y * n_x + x;
2594 cells[c].vertices[1] = z * n_xy + y * n_x + x + 1;
2595 cells[c].vertices[2] = z * n_xy + (y + 1) * n_x + x;
2596 cells[c].vertices[3] = z * n_xy + (y + 1) * n_x + x + 1;
2597 cells[c].vertices[4] = (z + 1) * n_xy + y * n_x + x;
2598 cells[c].vertices[5] = (z + 1) * n_xy + y * n_x + x + 1;
2599 cells[c].vertices[6] = (z + 1) * n_xy + (y + 1) * n_x + x;
2600 cells[c].vertices[7] =
2601 (z + 1) * n_xy + (y + 1) * n_x + x + 1;
2602 cells[c].material_id = 0;
2623 double epsilon = std::numeric_limits<double>::max();
2624 for (
unsigned int i = 0; i < dim; ++i)
2625 epsilon =
std::min(epsilon, 0.01 * delta[i][i]);
2628 "The distance between corner points must be positive."));
2632 colorize_subdivided_hyper_rectangle(tria, p1, p2, epsilon);
2641 const std::vector<std::vector<double>> &step_sz,
2644 const bool colorize)
2646 Assert(step_sz.size() == dim, ExcInvalidRepetitionsDimension(dim));
2656 std::vector<std::vector<double>> step_sizes(step_sz);
2658 for (
unsigned int i = 0; i < dim; ++i)
2662 std::swap(p1[i], p2[i]);
2663 std::reverse(step_sizes[i].
begin(), step_sizes[i].
end());
2669 for (
unsigned int j = 0; j < step_sizes.at(i).size(); ++j)
2670 x += step_sizes[i][j];
2671 Assert(std::fabs(x - (p2[i] - p1[i])) <= 1e-12 * std::fabs(x),
2673 "The sequence of step sizes in coordinate direction " +
2675 " must be equal to the distance of the two given "
2676 "points in this coordinate direction."));
2683 std::vector<Point<dim>> points;
2689 for (
unsigned int i = 0;; ++i)
2698 if (i == step_sizes[0].size())
2701 x += step_sizes[0][i];
2709 for (
unsigned int j = 0;; ++j)
2712 for (
unsigned int i = 0;; ++i)
2714 points.push_back(
Point<dim>(p1[0] + x, p1[1] + y));
2715 if (i == step_sizes[0].size())
2718 x += step_sizes[0][i];
2721 if (j == step_sizes[1].size())
2724 y += step_sizes[1][j];
2731 for (
unsigned int k = 0;; ++k)
2734 for (
unsigned int j = 0;; ++j)
2737 for (
unsigned int i = 0;; ++i)
2740 Point<dim>(p1[0] + x, p1[1] + y, p1[2] + z));
2741 if (i == step_sizes[0].size())
2744 x += step_sizes[0][i];
2747 if (j == step_sizes[1].size())
2750 y += step_sizes[1][j];
2753 if (k == step_sizes[2].size())
2756 z += step_sizes[2][k];
2767 std::vector<CellData<dim>> cells;
2772 cells.resize(step_sizes[0].size());
2773 for (
unsigned int x = 0; x < step_sizes[0].size(); ++x)
2775 cells[x].vertices[0] = x;
2776 cells[x].vertices[1] = x + 1;
2777 cells[x].material_id = 0;
2784 cells.resize(step_sizes[1].size() * step_sizes[0].size());
2785 for (
unsigned int y = 0; y < step_sizes[1].size(); ++y)
2786 for (
unsigned int x = 0; x < step_sizes[0].size(); ++x)
2788 const unsigned int c = x + y * step_sizes[0].size();
2789 cells[c].vertices[0] = y * (step_sizes[0].size() + 1) + x;
2790 cells[c].vertices[1] = y * (step_sizes[0].size() + 1) + x + 1;
2791 cells[c].vertices[2] =
2792 (y + 1) * (step_sizes[0].size() + 1) + x;
2793 cells[c].vertices[3] =
2794 (y + 1) * (step_sizes[0].size() + 1) + x + 1;
2795 cells[c].material_id = 0;
2802 const unsigned int n_x = (step_sizes[0].size() + 1);
2803 const unsigned int n_xy =
2804 (step_sizes[0].size() + 1) * (step_sizes[1].size() + 1);
2806 cells.resize(step_sizes[2].size() * step_sizes[1].size() *
2807 step_sizes[0].size());
2808 for (
unsigned int z = 0; z < step_sizes[2].size(); ++z)
2809 for (
unsigned int y = 0; y < step_sizes[1].size(); ++y)
2810 for (
unsigned int x = 0; x < step_sizes[0].size(); ++x)
2812 const unsigned int c =
2813 x + y * step_sizes[0].size() +
2814 z * step_sizes[0].size() * step_sizes[1].size();
2815 cells[c].vertices[0] = z * n_xy + y * n_x + x;
2816 cells[c].vertices[1] = z * n_xy + y * n_x + x + 1;
2817 cells[c].vertices[2] = z * n_xy + (y + 1) * n_x + x;
2818 cells[c].vertices[3] = z * n_xy + (y + 1) * n_x + x + 1;
2819 cells[c].vertices[4] = (z + 1) * n_xy + y * n_x + x;
2820 cells[c].vertices[5] = (z + 1) * n_xy + y * n_x + x + 1;
2821 cells[c].vertices[6] = (z + 1) * n_xy + (y + 1) * n_x + x;
2822 cells[c].vertices[7] =
2823 (z + 1) * n_xy + (y + 1) * n_x + x + 1;
2824 cells[c].material_id = 0;
2846 *std::min_element(step_sizes[0].
begin(), step_sizes[0].
end());
2847 for (
unsigned int i = 1; i < dim; ++i)
2849 *std::min_element(step_sizes[i].
begin(),
2850 step_sizes[i].
end()));
2851 const double epsilon = 0.01 * min_size;
2855 colorize_subdivided_hyper_rectangle(tria, p1, p2, epsilon);
2864 const std::vector<std::vector<double>> &spacing,
2867 const bool colorize)
2869 Assert(spacing.size() == 1, ExcInvalidRepetitionsDimension(1));
2873 Assert(spacing[0].size() == n_cells, ExcInvalidRepetitionsDimension(1));
2875 double delta = std::numeric_limits<double>::max();
2876 for (
unsigned int i = 0; i <
n_cells; ++i)
2878 Assert(spacing[0][i] >= 0, ExcInvalidRepetitions(-1));
2879 delta =
std::min(delta, spacing[0][i]);
2883 std::vector<Point<1>> points;
2885 for (
unsigned int x = 0; x <=
n_cells; ++x)
2887 points.emplace_back(ax);
2889 ax += spacing[0][x];
2892 unsigned int n_val_cells = 0;
2893 for (
unsigned int i = 0; i <
n_cells; ++i)
2897 std::vector<CellData<1>> cells(n_val_cells);
2898 unsigned int id = 0;
2899 for (
unsigned int x = 0; x <
n_cells; ++x)
2902 cells[id].vertices[0] = x;
2903 cells[id].vertices[1] = x + 1;
2922 const std::vector<std::vector<double>> &spacing,
2925 const bool colorize)
2927 Assert(spacing.size() == 2, ExcInvalidRepetitionsDimension(2));
2929 std::vector<unsigned int> repetitions(2);
2930 double delta = std::numeric_limits<double>::max();
2931 for (
unsigned int i = 0; i < 2; ++i)
2933 repetitions[i] = spacing[i].size();
2934 for (
unsigned int j = 0; j < repetitions[i]; ++j)
2936 Assert(spacing[i][j] >= 0, ExcInvalidRepetitions(-1));
2937 delta =
std::min(delta, spacing[i][j]);
2940 ExcInvalidRepetitionsDimension(i));
2944 std::vector<Point<2>> points;
2946 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
2949 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
2951 points.emplace_back(ax, ay);
2952 if (x < repetitions[0])
2953 ax += spacing[0][x];
2955 if (y < repetitions[1])
2956 ay += spacing[1][y];
2960 unsigned int n_val_cells = 0;
2961 for (
unsigned int i = 0; i <
material_id.size(0); ++i)
2962 for (
unsigned int j = 0; j <
material_id.size(1); ++j)
2966 std::vector<CellData<2>> cells(n_val_cells);
2967 unsigned int id = 0;
2968 for (
unsigned int y = 0; y < repetitions[1]; ++y)
2969 for (
unsigned int x = 0; x < repetitions[0]; ++x)
2972 cells[id].vertices[0] = y * (repetitions[0] + 1) + x;
2973 cells[id].vertices[1] = y * (repetitions[0] + 1) + x + 1;
2974 cells[id].vertices[2] = (y + 1) * (repetitions[0] + 1) + x;
2975 cells[id].vertices[3] = (y + 1) * (repetitions[0] + 1) + x + 1;
2989 double eps = 0.01 * delta;
2991 for (; cell != endc; ++cell)
2995 if (cell->
face(f)->boundary_id() == 0)
2998 for (
unsigned int i = 0; i < 2; ++i)
3000 if (face_center[i] < cell_center[i] - eps)
3001 cell->
face(f)->set_boundary_id(i * 2);
3002 if (face_center[i] > cell_center[i] + eps)
3003 cell->
face(f)->set_boundary_id(i * 2 + 1);
3014 const std::vector<std::vector<double>> &spacing,
3017 const bool colorize)
3019 const unsigned int dim = 3;
3021 Assert(spacing.size() == dim, ExcInvalidRepetitionsDimension(dim));
3023 std::array<unsigned int, dim> repetitions;
3024 double delta = std::numeric_limits<double>::max();
3025 for (
unsigned int i = 0; i < dim; ++i)
3027 repetitions[i] = spacing[i].size();
3028 for (
unsigned int j = 0; j < repetitions[i]; ++j)
3030 Assert(spacing[i][j] >= 0, ExcInvalidRepetitions(-1));
3031 delta =
std::min(delta, spacing[i][j]);
3034 ExcInvalidRepetitionsDimension(i));
3038 std::vector<Point<dim>> points;
3040 for (
unsigned int z = 0; z <= repetitions[2]; ++z)
3043 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
3046 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
3048 points.emplace_back(ax, ay, az);
3049 if (x < repetitions[0])
3050 ax += spacing[0][x];
3052 if (y < repetitions[1])
3053 ay += spacing[1][y];
3055 if (z < repetitions[2])
3056 az += spacing[2][z];
3060 unsigned int n_val_cells = 0;
3061 for (
unsigned int i = 0; i <
material_id.size(0); ++i)
3062 for (
unsigned int j = 0; j <
material_id.size(1); ++j)
3063 for (
unsigned int k = 0; k <
material_id.size(2); ++k)
3067 std::vector<CellData<dim>> cells(n_val_cells);
3068 unsigned int id = 0;
3069 const unsigned int n_x = (repetitions[0] + 1);
3070 const unsigned int n_xy = (repetitions[0] + 1) * (repetitions[1] + 1);
3071 for (
unsigned int z = 0; z < repetitions[2]; ++z)
3072 for (
unsigned int y = 0; y < repetitions[1]; ++y)
3073 for (
unsigned int x = 0; x < repetitions[0]; ++x)
3076 cells[id].vertices[0] = z * n_xy + y * n_x + x;
3077 cells[id].vertices[1] = z * n_xy + y * n_x + x + 1;
3078 cells[id].vertices[2] = z * n_xy + (y + 1) * n_x + x;
3079 cells[id].vertices[3] = z * n_xy + (y + 1) * n_x + x + 1;
3080 cells[id].vertices[4] = (z + 1) * n_xy + y * n_x + x;
3081 cells[id].vertices[5] = (z + 1) * n_xy + y * n_x + x + 1;
3082 cells[id].vertices[6] = (z + 1) * n_xy + (y + 1) * n_x + x;
3083 cells[id].vertices[7] = (z + 1) * n_xy + (y + 1) * n_x + x + 1;
3097 double eps = 0.01 * delta;
3100 for (; cell != endc; ++cell)
3104 if (cell->
face(f)->boundary_id() == 0)
3107 for (
unsigned int i = 0; i < dim; ++i)
3109 if (face_center[i] < cell_center[i] - eps)
3110 cell->
face(f)->set_boundary_id(i * 2);
3111 if (face_center[i] > cell_center[i] + eps)
3112 cell->
face(f)->set_boundary_id(i * 2 + 1);
3121 template <
int dim,
int spacedim>
3124 const std::vector<unsigned int> &holes)
3135 std::array<Point<spacedim>, dim> delta;
3136 std::array<unsigned int, dim> repetitions;
3137 for (
unsigned int i = 0; i < dim; ++i)
3140 ExcMessage(
"At least one hole needed in each direction"));
3141 repetitions[i] = 2 * holes[i] + 1;
3147 std::vector<Point<spacedim>> points;
3151 points.reserve(repetitions[0] + 1);
3152 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
3153 points.push_back(origin + x * delta[0]);
3157 points.reserve((repetitions[0] + 1) * (repetitions[1] + 1));
3158 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
3159 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
3160 points.push_back(origin + x * delta[0] + y * delta[1]);
3164 points.reserve((repetitions[0] + 1) * (repetitions[1] + 1) *
3165 (repetitions[2] + 1));
3166 for (
unsigned int z = 0; z <= repetitions[2]; ++z)
3167 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
3168 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
3169 points.push_back(origin + x * delta[0] + y * delta[1] +
3179 std::vector<CellData<dim>> cells;
3184 const unsigned int n_x = (repetitions[0] + 1);
3186 cells.resize(repetitions[1] * repetitions[0] - holes[1] * holes[0]);
3188 for (
unsigned int y = 0; y < repetitions[1]; ++y)
3189 for (
unsigned int x = 0; x < repetitions[0]; ++x)
3193 if ((x % 2 == 1) && (y % 2 == 1))
3197 cells[c].vertices[0] = y * n_x + x;
3198 cells[c].vertices[1] = y * n_x + x + 1;
3199 cells[c].vertices[2] = (y + 1) * n_x + x;
3200 cells[c].vertices[3] = (y + 1) * n_x + x + 1;
3201 cells[c].material_id = 0;
3210 const unsigned int n_x = (repetitions[0] + 1);
3211 const unsigned int n_xy =
3212 (repetitions[0] + 1) * (repetitions[1] + 1);
3216 cells.resize(repetitions[2] * repetitions[1] * repetitions[0]);
3219 for (
unsigned int z = 0; z < repetitions[2]; ++z)
3220 for (
unsigned int y = 0; y < repetitions[1]; ++y)
3221 for (
unsigned int x = 0; x < repetitions[0]; ++x)
3226 if ((x % 2 == 1) && (y % 2 == 1) && z % 2 == 1)
3230 cells[c].vertices[0] = z * n_xy + y * n_x + x;
3231 cells[c].vertices[1] = z * n_xy + y * n_x + x + 1;
3232 cells[c].vertices[2] = z * n_xy + (y + 1) * n_x + x;
3233 cells[c].vertices[3] = z * n_xy + (y + 1) * n_x + x + 1;
3234 cells[c].vertices[4] = (z + 1) * n_xy + y * n_x + x;
3235 cells[c].vertices[5] = (z + 1) * n_xy + y * n_x + x + 1;
3236 cells[c].vertices[6] = (z + 1) * n_xy + (y + 1) * n_x + x;
3237 cells[c].vertices[7] =
3238 (z + 1) * n_xy + (y + 1) * n_x + x + 1;
3239 cells[c].material_id = 0;
3259 template <
int dim,
int spacedim>
3263 const double voxel_edge_length)
3268 std::array<unsigned int, dim> voxels_per_direction;
3269 for (
unsigned int d = 0;
d < dim; ++
d)
3271 Assert(present_voxels.size()[d] > 0,
3273 "The 2d or 3d array that describes which pixels/voxels "
3274 "are present in the domain must have a non-zero extent in"
3275 "in coordinate direction."));
3276 voxels_per_direction[
d] = present_voxels.size()[
d];
3279 std::vector<Point<spacedim>> points;
3283 points.reserve(voxels_per_direction[0] + 1);
3284 for (
unsigned int x = 0; x < voxels_per_direction[0] + 1; ++x)
3285 points.emplace_back(x * voxel_edge_length);
3289 points.reserve((voxels_per_direction[0] + 1) *
3290 (voxels_per_direction[1] + 1));
3291 for (
unsigned int y = 0; y < voxels_per_direction[1] + 1; ++y)
3292 for (
unsigned int x = 0; x < voxels_per_direction[0] + 1; ++x)
3293 points.emplace_back(x * voxel_edge_length, y * voxel_edge_length);
3297 points.reserve((voxels_per_direction[0] + 1) *
3298 (voxels_per_direction[1] + 1) *
3299 (voxels_per_direction[2] + 1));
3300 for (
unsigned int z = 0; z < voxels_per_direction[2] + 1; ++z)
3301 for (
unsigned int y = 0; y < voxels_per_direction[1] + 1; ++y)
3302 for (
unsigned int x = 0; x < voxels_per_direction[0] + 1; ++x)
3303 points.emplace_back(x * voxel_edge_length,
3304 y * voxel_edge_length,
3305 z * voxel_edge_length);
3313 unsigned int n_voxels = 0;
3314 if constexpr (dim == 2)
3316 for (
unsigned int x = 0; x < voxels_per_direction[0]; ++x)
3317 for (
unsigned int y = 0; y < voxels_per_direction[1]; ++y)
3318 if (present_voxels[x][y] ==
true)
3321 else if constexpr (dim == 3)
3323 for (
unsigned int x = 0; x < voxels_per_direction[0]; ++x)
3324 for (
unsigned int y = 0; y < voxels_per_direction[1]; ++y)
3325 for (
unsigned int z = 0; z < voxels_per_direction[2]; ++z)
3326 if (present_voxels[x][y][z] ==
true)
3332 std::vector<CellData<dim>> cells(n_voxels);
3333 if constexpr (dim == 2)
3335 const unsigned int n_x = (voxels_per_direction[0] + 1);
3338 for (
unsigned int y = 0; y < voxels_per_direction[1]; ++y)
3339 for (
unsigned int x = 0; x < voxels_per_direction[0]; ++x)
3340 if (present_voxels[x][y] ==
true)
3342 cells[c].vertices[0] = y * n_x + x;
3343 cells[c].vertices[1] = y * n_x + x + 1;
3344 cells[c].vertices[2] = (y + 1) * n_x + x;
3345 cells[c].vertices[3] = (y + 1) * n_x + x + 1;
3346 cells[c].material_id = 0;
3351 else if constexpr (dim == 3)
3353 const unsigned int n_x = (voxels_per_direction[0] + 1);
3354 const unsigned int n_xy =
3355 (voxels_per_direction[0] + 1) * (voxels_per_direction[1] + 1);
3358 for (
unsigned int z = 0; z < voxels_per_direction[2]; ++z)
3359 for (
unsigned int y = 0; y < voxels_per_direction[1]; ++y)
3360 for (
unsigned int x = 0; x < voxels_per_direction[0]; ++x)
3361 if (present_voxels[x][y][z] ==
true)
3364 cells[c].vertices[0] = z * n_xy + y * n_x + x;
3365 cells[c].vertices[1] = z * n_xy + y * n_x + x + 1;
3366 cells[c].vertices[2] = z * n_xy + (y + 1) * n_x + x;
3367 cells[c].vertices[3] = z * n_xy + (y + 1) * n_x + x + 1;
3368 cells[c].vertices[4] = (z + 1) * n_xy + y * n_x + x;
3369 cells[c].vertices[5] = (z + 1) * n_xy + y * n_x + x + 1;
3370 cells[c].vertices[6] = (z + 1) * n_xy + (y + 1) * n_x + x;
3371 cells[c].vertices[7] = (z + 1) * n_xy + (y + 1) * n_x + x + 1;
3372 cells[c].material_id = 0;
3403 const unsigned int ,
3415 const unsigned int ,
3428 point_in_2d_box(
const Point<2> &p,
const Point<2> &c,
const double radius)
3439 template <
int dim,
int spacedim>
3441 minimal_vertex_distance(
const Triangulation<dim, spacedim> &triangulation)
3443 double length = std::numeric_limits<double>::max();
3445 for (
unsigned int n = 0; n < GeometryInfo<dim>::lines_per_cell; ++n)
3456 const double inner_radius,
3458 const double pad_bottom,
3459 const double pad_top,
3460 const double pad_left,
3461 const double pad_right,
3466 const unsigned int ,
3467 const bool colorize)
3469 const bool with_padding =
3470 pad_bottom > 0 || pad_top > 0 || pad_left > 0 || pad_right > 0;
3480 double length = std::numeric_limits<double>::max();
3482 for (
unsigned int n = 0; n < cell->
n_lines(); ++n)
3489 Triangulation<2> &cylinder_tria = with_padding ? cylinder_tria_maybe : tria;
3508 auto add_sizes = [](std::vector<double> &step_sizes,
3509 const double padding,
3510 const double h) ->
void {
3513 const auto rounded =
3514 static_cast<unsigned int>(std::round(padding / h));
3517 const unsigned int num = (padding > 0. && rounded == 0) ? 1 : rounded;
3518 for (
unsigned int i = 0; i < num; ++i)
3519 step_sizes.push_back(padding / num);
3522 std::vector<std::vector<double>> step_sizes(2);
3543 bulk_tria, step_sizes, bl, tr, colorize);
3546 std::set<Triangulation<2>::active_cell_iterator> cells_to_remove;
3549 cells_to_remove.insert(cell);
3553 bulk_tria, cells_to_remove, tria_without_cylinder);
3555 const double tolerance =
3556 std::min(min_line_length(tria_without_cylinder),
3557 min_line_length(cylinder_tria)) /
3561 tria_without_cylinder, cylinder_tria, tria, tolerance,
true);
3573 const auto &face = cell->
face(face_n);
3574 if (face->at_boundary() &&
3575 internal::point_in_2d_box(face->center(),
3578 face->set_manifold_id(polar_manifold_id);
3580 face->set_manifold_id(tfi_manifold_id);
3591 static constexpr double tol =
3592 std::numeric_limits<double>::epsilon() * 10000;
3597 const auto face = cell->
face(face_n);
3598 if (face->at_boundary())
3600 const Point<2> center = face->center();
3603 face->set_boundary_id(0);
3606 face->set_boundary_id(1);
3609 face->set_boundary_id(2);
3612 face->set_boundary_id(3);
3618 face->set_boundary_id(4);
3639 const double inner_radius,
3641 const double pad_bottom,
3642 const double pad_top,
3643 const double pad_left,
3644 const double pad_right,
3649 const unsigned int n_slices,
3650 const bool colorize)
3660 Point<2>(new_center[0], new_center[1]),
3683 tria.
set_manifold(polar_manifold_id, cylindrical_manifold);
3692 const double shell_region_width,
3693 const unsigned int n_shells,
3694 const double skewness,
3695 const bool colorize)
3697 Assert(0.0 <= shell_region_width && shell_region_width < 0.05,
3698 ExcMessage(
"The width of the shell region must be less than 0.05 "
3699 "(and preferably close to 0.03)"));
3733 std::set<Triangulation<2>::active_cell_iterator> cells_to_remove;
3738 cells_to_remove.insert(cell);
3742 for (
const unsigned int vertex_n :
3748 cylinder_triangulation_offset =
3756 bulk_tria, cells_to_remove, tria_without_cylinder);
3763 0.05 + shell_region_width,
3772 cell->
vertex(vertex_n)[0] = -0.1;
3773 else if (
std::abs(cell->
vertex(vertex_n)[0] - 0.41 / 4.0) < 1e-10)
3774 cell->
vertex(vertex_n)[0] = 0.1;
3782 if (!cell->
face(face_n)->at_boundary())
3783 cell->
face(face_n)->set_manifold_id(tfi_manifold_id);
3785 if (0.0 < shell_region_width)
3788 ExcMessage(
"If the shell region has positive width then "
3789 "there must be at least one shell."));
3794 0.05 + shell_region_width,
3801 const double vertex_tolerance =
3802 std::min(internal::minimal_vertex_distance(shell_tria),
3803 internal::minimal_vertex_distance(cylinder_tria)) *
3809 shell_tria, cylinder_tria, temp, vertex_tolerance,
true);
3810 cylinder_tria = std::move(temp);
3816 const double vertex_tolerance =
3817 std::min(internal::minimal_vertex_distance(tria_without_cylinder),
3818 internal::minimal_vertex_distance(cylinder_tria)) /
3821 tria_without_cylinder, cylinder_tria, tria, vertex_tolerance,
true);
3834 const double shift =
3835 std::min(0.125 + shell_region_width * 0.5, 0.1 * 4. / 3.);
3863 std::vector<Point<2> *> cylinder_pointers;
3865 if (face->manifold_id() == polar_manifold_id)
3867 cylinder_pointers.push_back(&face->vertex(0));
3868 cylinder_pointers.push_back(&face->vertex(1));
3871 std::sort(cylinder_pointers.begin(), cylinder_pointers.end());
3872 cylinder_pointers.erase(std::unique(cylinder_pointers.begin(),
3873 cylinder_pointers.end()),
3874 cylinder_pointers.end());
3878 for (
const Point<2> *
const ptr : cylinder_pointers)
3879 center += *ptr / double(cylinder_pointers.size());
3882 for (
Point<2> *
const ptr : cylinder_pointers)
3883 *ptr +=
Point<2>(0.2, 0.2) - center;
3896 if (face->at_boundary())
3898 const Point<2> center = face->center();
3900 if (
std::abs(center[0] - 0.0) < 1e-10)
3901 face->set_boundary_id(0);
3903 else if (
std::abs(center[0] - 2.2) < 1e-10)
3904 face->set_boundary_id(1);
3906 else if (face->manifold_id() == polar_manifold_id)
3907 face->set_boundary_id(2);
3912 std::abs(center[1] - 0.41) < 1.0e-10,
3914 face->set_boundary_id(3);
3924 const double shell_region_width,
3925 const unsigned int n_shells,
3926 const double skewness,
3927 const bool colorize)
3931 tria_2, shell_region_width, n_shells, skewness, colorize);
3951 tria.
set_manifold(cylindrical_manifold_id, cylindrical_manifold);
3959 if (face->boundary_id() == 4 || face->boundary_id() == 5)
3960 face->set_boundary_id(3);
3966 const std::vector<unsigned int> &,
3982 const std::vector<unsigned int> &lengths_and_heights,
3985 const double shell_region_radius,
3986 const unsigned int n_shells,
3987 const double skewness,
3988 const bool use_transfinite_region,
3989 const bool colorize)
3995 const double radius = 0.5;
3996 const double box_radius = 1;
4003 const unsigned int length_pre = lengths_and_heights[0];
4004 const unsigned int length_post = lengths_and_heights[1];
4005 const unsigned int height_below = lengths_and_heights[2];
4006 const unsigned int height_above = lengths_and_heights[3];
4008 const unsigned int length_repetitions = length_pre + length_post;
4009 const unsigned int height_repetitions = height_above + height_below;
4016 {(length_repetitions), height_repetitions},
4017 Point<2>(-
double(length_pre), -
double(height_below)),
4018 Point<2>(
double(length_post),
double(height_above)));
4036 std::set<Triangulation<2>::active_cell_iterator> cells_to_remove;
4039 if ((cell->
center() -
Point<2>(0., 0.)).norm() < 1.1 * box_radius)
4040 cells_to_remove.insert(cell);
4045 bulk_tria, cells_to_remove, tria_without_cylinder);
4052 shell_region_radius,
4060 if (!cell->
face(face_n)->at_boundary())
4061 cell->
face(face_n)->set_manifold_id(tfi_manifold_id);
4066 if (
radius < shell_region_radius)
4069 ExcMessage(
"If the shell region has positive width then "
4070 "there must be at least one shell."));
4075 shell_region_radius,
4082 const double vertex_tolerance =
4083 std::min(internal::minimal_vertex_distance(shell_tria),
4084 internal::minimal_vertex_distance(cylinder_tria)) *
4090 shell_tria, cylinder_tria, temp, vertex_tolerance,
true);
4091 cylinder_tria = std::move(temp);
4096 const double vertex_tolerance =
4097 std::min(internal::minimal_vertex_distance(tria_without_cylinder),
4098 internal::minimal_vertex_distance(cylinder_tria)) /
4102 tria_without_cylinder, cylinder_tria, tria, vertex_tolerance,
true);
4121 if (use_transfinite_region)
4131 if (face->at_boundary())
4133 const Point<2> center = face->center();
4135 if (
std::abs(center[0] - (-
static_cast<double>(length_pre))) <
4137 face->set_boundary_id(0);
4139 else if (
std::abs(center[0] -
static_cast<double>(length_post)) <
4141 face->set_boundary_id(1);
4143 else if (face->manifold_id() == polar_manifold_id)
4144 face->set_boundary_id(2);
4147 (-
static_cast<double>(height_below))) < 1e-10)
4148 face->set_boundary_id(3);
4151 face->set_boundary_id(4);
4159 const std::vector<unsigned int> &lengths_and_heights,
4161 unsigned int depth_division,
4162 const double shell_region_radius,
4163 const unsigned int n_shells,
4164 const double skewness,
4165 const bool use_transfinite_region,
4166 const bool colorize)
4170 lengths_and_heights,
4173 shell_region_radius,
4176 use_transfinite_region,
4198 tria.
set_manifold(cylindrical_manifold_id, cylindrical_manifold);
4200 if (use_transfinite_region)
4211 template <
int dim,
int spacedim>
4214 const std::vector<unsigned int> &sizes,
4215 const bool colorize)
4224 for (
unsigned int d = 0;
d < dim; ++
d)
4227 std::vector<Point<spacedim>> points;
4232 std::vector<CellData<dim>> cells(n_cells);
4237 for (
unsigned int d = 0;
d < dim; ++
d)
4238 p[d] = 0.5 * dimensions[d] *
4241 points.push_back(p);
4242 cells[0].vertices[i] = i;
4244 cells[0].material_id = 0;
4247 unsigned int cell_index = 1;
4255 for (
unsigned int j = 0; j < sizes[face]; ++j, ++cell_index)
4257 const unsigned int last_cell = (j == 0) ? 0U : (cell_index - 1);
4259 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_face;
4262 const unsigned int cellv =
4264 const unsigned int ocellv =
4267 cells[cell_index].vertices[ocellv] =
4268 cells[last_cell].vertices[cellv];
4271 cells[cell_index].vertices[cellv] = points.size();
4276 points.push_back(p);
4278 cells[cell_index].material_id = (colorize) ? (face + 1U) : 0
U;
4425 const double thickness,
4426 const bool colorize)
4429 ExcMessage(
"Invalid left-to-right bounds of enclosed hypercube"));
4431 std::vector<Point<2>> vertices(16);
4433 coords[0] = left - thickness;
4436 coords[3] = right + thickness;
4439 for (
const double y : coords)
4440 for (
const double x : coords)
4445 std::vector<CellData<2>> cells(9);
4447 for (
unsigned int i0 = 0; i0 < 3; ++i0)
4448 for (
unsigned int i1 = 0; i1 < 3; ++i1)
4450 cells[k].vertices[0] = i1 + 4 * i0;
4451 cells[k].vertices[1] = i1 + 4 * i0 + 1;
4452 cells[k].vertices[2] = i1 + 4 * i0 + 4;
4453 cells[k].vertices[3] = i1 + 4 * i0 + 5;
4455 cells[k].material_id = materials[k];
4471 const bool colorize)
4473 const double rl2 = (right + left) / 2;
4484 const int cell_vertices[4][4] = {{0, 1, 3, 2},
4489 for (
unsigned int i = 0; i < 4; ++i)
4491 for (
unsigned int j = 0; j < 4; ++j)
4492 cells[i].vertices[j] = cell_vertices[i][j];
4493 cells[i].material_id = 0;
4496 std::end(vertices)),
4503 cell->
face(1)->set_boundary_id(1);
4505 cell->
face(0)->set_boundary_id(2);
4514 const double radius_0,
4515 const double radius_1,
4516 const double half_length)
4520 vertices_tmp[0] =
Point<2>(-half_length, -radius_0);
4521 vertices_tmp[1] =
Point<2>(half_length, -radius_1);
4522 vertices_tmp[2] =
Point<2>(-half_length, radius_0);
4523 vertices_tmp[3] =
Point<2>(half_length, radius_1);
4525 const std::vector<Point<2>> vertices(std::begin(vertices_tmp),
4526 std::end(vertices_tmp));
4530 cell_vertices[0][i] = i;
4535 cells[0].vertices[i] = cell_vertices[0][i];
4537 cells[0].material_id = 0;
4542 cell->
face(0)->set_boundary_id(1);
4543 cell->
face(1)->set_boundary_id(2);
4545 for (
unsigned int i = 2; i < 4; ++i)
4546 cell->
face(i)->set_boundary_id(0);
4557 const bool colorize)
4563 Point<2>((a + b) / 2, (a + b) / 2),
4567 const int cell_vertices[3][4] = {{0, 1, 3, 4}, {1, 2, 4, 5}, {3, 4, 6, 7}};
4571 for (
unsigned int i = 0; i < 3; ++i)
4573 for (
unsigned int j = 0; j < 4; ++j)
4574 cells[i].vertices[j] = cell_vertices[i][j];
4575 cells[i].material_id = 0;
4579 std::end(vertices)),
4587 cell->
face(0)->set_boundary_id(0);
4588 cell->
face(2)->set_boundary_id(1);
4591 cell->
face(1)->set_boundary_id(2);
4592 cell->
face(2)->set_boundary_id(1);
4593 cell->
face(3)->set_boundary_id(3);
4596 cell->
face(0)->set_boundary_id(0);
4597 cell->
face(1)->set_boundary_id(4);
4598 cell->
face(3)->set_boundary_id(5);
4604 template <
int dim,
int spacedim>
4607 const std::vector<unsigned int> &repetitions,
4610 const std::vector<int> &n_cells_to_remove)
4616 for (
unsigned int d = 0;
d < dim; ++
d)
4618 Assert(std::fabs(n_cells_to_remove[d]) <= repetitions[d],
4619 ExcMessage(
"Attempting to cut away too many cells."));
4629 std::array<double, dim> h;
4631 for (
unsigned int d = 0;
d < dim; ++
d)
4634 h[
d] = (top_right[
d] - bottom_left[
d]) / repetitions[d];
4636 if (n_cells_to_remove[d] >= 0)
4640 h[
d] * std::fabs(n_cells_to_remove[d]) + bottom_left[
d];
4645 cut_step[
d] = top_right[
d] - h[
d] * std::fabs(n_cells_to_remove[d]);
4651 std::set<typename Triangulation<dim, spacedim>::active_cell_iterator>
4655 bool remove_cell =
true;
4656 for (
unsigned int d = 0;
d < dim && remove_cell; ++
d)
4657 if ((n_cells_to_remove[d] > 0 && cell->
center()[d] >= cut_step[d]) ||
4658 (n_cells_to_remove[d] < 0 && cell->
center()[d] <= cut_step[d]))
4659 remove_cell =
false;
4661 cells_to_remove.insert(cell);
4671 template <
int dim,
int spacedim>
4676 const bool internal_manifolds)
4678 if constexpr (dim == 2)
4680 const auto embed_point = [](
const double x,
4682 if constexpr (spacedim == 2)
4684 else if constexpr (spacedim == 3)
4693 const double a = 1. / (1 +
std::sqrt(2.0));
4706 for (
unsigned int i = 0; i < 5; ++i)
4708 for (
unsigned int j = 0; j < 4; ++j)
4709 cells[i].vertices[j] = circle_cell_vertices[i][j];
4710 cells[i].material_id = 0;
4715 std::begin(vertices), std::end(vertices)),
4720 if (internal_manifolds)
4725 else if constexpr (dim == 3)
4731 const unsigned int n_vertices = 16;
4732 const Point<3> vertices[n_vertices] = {
4757 const unsigned int n_cells = 7;
4758 const int cell_vertices[
n_cells][8] = {
4759 {0, 1, 4, 5, 3, 2, 7, 6},
4760 {8, 9, 12, 13, 0, 1, 4, 5},
4761 {9, 13, 1, 5, 10, 14, 2, 6},
4762 {11, 10, 3, 2, 15, 14, 7, 6},
4763 {8, 0, 12, 4, 11, 3, 15, 7},
4764 {8, 9, 0, 1, 11, 10, 3, 2},
4765 {12, 4, 13, 5, 15, 7, 14, 6}};
4767 std::vector<CellData<3>> cells(n_cells,
CellData<3>());
4769 for (
unsigned int i = 0; i <
n_cells; ++i)
4772 cells[i].vertices[j] = cell_vertices[i][j];
4773 cells[i].material_id = 0;
4778 std::end(vertices)),
4783 if (internal_manifolds)
4794 template <
int spacedim>
4798 const double inner_radius,
4800 const unsigned int n_cells,
4801 const bool colorize)
4817 const unsigned int N =
4818 (
n_cells == 0 ?
static_cast<unsigned int>(
4819 std::ceil((2 * pi * (
outer_radius + inner_radius) / 2) /
4829 std::vector<Point<spacedim>> vertices(2 * N);
4830 for (
unsigned int i = 0; i <
N; ++i)
4837 vertices[i +
N] = vertices[i] * (inner_radius /
outer_radius);
4839 vertices[i] += center;
4840 vertices[i +
N] += center;
4845 for (
unsigned int i = 0; i <
N; ++i)
4847 cells[i].vertices[0] = i;
4848 cells[i].vertices[1] = (i + 1) % N;
4849 cells[i].vertices[2] =
N + i;
4850 cells[i].vertices[3] =
N + ((i + 1) %
N);
4852 cells[i].material_id = 0;
4858 colorize_hyper_shell(tria, center, inner_radius,
outer_radius);
4870 const double inner_radius,
4872 const unsigned int n_cells,
4873 const bool colorize)
4875 hyper_shell_2D(tria, center, inner_radius,
outer_radius, n_cells, colorize);
4884 const double inner_radius,
4886 const unsigned int n_cells,
4887 const bool colorize)
4889 hyper_shell_2D(tria, center, inner_radius,
outer_radius, n_cells, colorize);
4899 const double inner_radius,
4901 const unsigned int n_cells)
4904 tria, outer_center, inner_radius,
outer_radius, n_cells,
true);
4910 "The inner radius is greater than or equal to the outer radius plus eccentricity."));
4914 std::set<Point<dim> *> vertices_to_move;
4917 if (face->boundary_id() == 0)
4918 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_face; ++v)
4919 vertices_to_move.insert(&face->vertex(v));
4921 const auto shift = inner_center - outer_center;
4922 for (
const auto &p : vertices_to_move)
4954 const double half_length)
4965 switch (f->boundary_id())
4968 f->set_boundary_id(1);
4971 f->set_boundary_id(2);
4974 f->set_boundary_id(0);
5014 const unsigned int dim = 2;
5028 const int cell_vertices[3][4] = {{0, 2, 3, 4}, {1, 6, 2, 4}, {5, 3, 6, 4}};
5032 for (
unsigned int i = 0; i < 3; ++i)
5034 for (
unsigned int j = 0; j < 4; ++j)
5035 cells[i].vertices[j] = cell_vertices[i][j];
5036 cells[i].material_id = 0;
5040 std::end(vertices)),
5053 if (cell->
face(i)->boundary_id() ==
5059 if (cell->
face(i)->center()[0] < p[0] + 1.e-5 *
radius ||
5060 cell->
face(i)->center()[1] < p[1] + 1.e-5 *
radius)
5062 cell->
face(i)->set_boundary_id(1);
5081 const double a = 1. / (1 +
std::sqrt(2.0));
5092 const int cell_vertices[5][4] = {{0, 1, 2, 3},
5099 for (
unsigned int i = 0; i < 4; ++i)
5101 for (
unsigned int j = 0; j < 4; ++j)
5102 cells[i].vertices[j] = cell_vertices[i][j];
5103 cells[i].material_id = 0;
5107 std::end(vertices)),
5120 if (cell->
face(i)->boundary_id() ==
5125 if (cell->
face(i)->center()[0] < p[0] + 1.e-5 *
radius)
5127 cell->
face(i)->set_boundary_id(1);
5143 const double inner_radius,
5145 const unsigned int n_cells,
5146 const bool colorize)
5161 const unsigned int N =
5162 (
n_cells == 0 ?
static_cast<unsigned int>(
5173 std::vector<Point<2>> vertices(2 * (N + 1));
5174 for (
unsigned int i = 0; i <=
N; ++i)
5186 vertices[i +
N + 1] = vertices[i] * (inner_radius /
outer_radius);
5188 vertices[i] += center;
5189 vertices[i +
N + 1] += center;
5195 for (
unsigned int i = 0; i <
N; ++i)
5197 cells[i].vertices[0] = i;
5198 cells[i].vertices[1] = (i + 1) % (N + 1);
5199 cells[i].vertices[2] =
N + 1 + i;
5200 cells[i].vertices[3] =
N + 1 + ((i + 1) % (
N + 1));
5202 cells[i].material_id = 0;
5210 for (; cell != tria.
end(); ++cell)
5212 cell->
face(2)->set_boundary_id(1);
5214 tria.
begin()->
face(0)->set_boundary_id(3);
5216 tria.
last()->
face(1)->set_boundary_id(2);
5227 const double inner_radius,
5229 const unsigned int n_cells,
5230 const bool colorize)
5245 const unsigned int N =
5246 (
n_cells == 0 ?
static_cast<unsigned int>(
5257 std::vector<Point<2>> vertices(2 * (N + 1));
5258 for (
unsigned int i = 0; i <=
N; ++i)
5268 vertices[i +
N + 1] = vertices[i] * (inner_radius /
outer_radius);
5270 vertices[i] += center;
5271 vertices[i +
N + 1] += center;
5277 for (
unsigned int i = 0; i <
N; ++i)
5279 cells[i].vertices[0] = i;
5280 cells[i].vertices[1] = (i + 1) % (N + 1);
5281 cells[i].vertices[2] =
N + 1 + i;
5282 cells[i].vertices[3] =
N + 1 + ((i + 1) % (
N + 1));
5284 cells[i].material_id = 0;
5292 for (; cell != tria.
end(); ++cell)
5294 cell->
face(2)->set_boundary_id(1);
5296 tria.
begin()->
face(0)->set_boundary_id(3);
5298 tria.
last()->
face(1)->set_boundary_id(2);
5313 const bool colorize)
5315 const double rl2 = (right + left) / 2;
5316 const double len = (right - left) / 2.;
5329 const int cell_vertices[4][8] = {{0, 1, 3, 2, 10, 11, 13, 12},
5330 {9, 4, 2, 5, 19, 14, 12, 15},
5331 {3, 2, 7, 6, 13, 12, 17, 16},
5332 {2, 5, 6, 8, 12, 15, 16, 18}};
5334 for (
unsigned int i = 0; i < 4; ++i)
5336 for (
unsigned int j = 0; j < 8; ++j)
5337 cells[i].vertices[j] = cell_vertices[i][j];
5338 cells[i].material_id = 0;
5341 std::end(vertices)),
5348 cell->
face(1)->set_boundary_id(1);
5350 cell->
face(0)->set_boundary_id(2);
5362 const double thickness,
5363 const bool colorize)
5366 ExcMessage(
"Invalid left-to-right bounds of enclosed hypercube"));
5368 std::vector<Point<3>> vertices(64);
5370 coords[0] = left - thickness;
5373 coords[3] = right + thickness;
5376 for (
const double z : coords)
5377 for (
const double y : coords)
5378 for (
const double x : coords)
5382 24, 26, 5, 4, 6, 1, 0,
5383 2, 9, 8, 10, 37, 36, 38,
5384 33, 32, 34, 41, 40, 42};
5386 std::vector<CellData<3>> cells(27);
5388 for (
unsigned int z = 0; z < 3; ++z)
5389 for (
unsigned int y = 0; y < 3; ++y)
5390 for (
unsigned int x = 0; x < 3; ++x)
5392 cells[k].vertices[0] = x + 4 * y + 16 * z;
5393 cells[k].vertices[1] = x + 4 * y + 16 * z + 1;
5394 cells[k].vertices[2] = x + 4 * y + 16 * z + 4;
5395 cells[k].vertices[3] = x + 4 * y + 16 * z + 5;
5396 cells[k].vertices[4] = x + 4 * y + 16 * z + 16;
5397 cells[k].vertices[5] = x + 4 * y + 16 * z + 17;
5398 cells[k].vertices[6] = x + 4 * y + 16 * z + 20;
5399 cells[k].vertices[7] = x + 4 * y + 16 * z + 21;
5401 cells[k].material_id = materials[k];
5414 const double radius_0,
5415 const double radius_1,
5416 const double half_length)
5419 ExcMessage(
"The output triangulation object needs to be empty."));
5424 const auto n_slices = 1 +
static_cast<unsigned int>(std::ceil(
5425 half_length /
std::max(radius_0, radius_1)));
5438 auto shift_radii = [=](
const Point<3> &p) {
5439 const double slope = (radius_1 / radius_0 - 1.0) / (2.0 * half_length);
5440 const double factor = slope * (p[0] - -half_length) + 1.0;
5441 return Point<3>(p[0], factor * p[1], factor * p[2]);
5448 if (face->at_boundary())
5450 if (
std::abs(face->center()[0] - -half_length) < 1e-8 * half_length)
5451 face->set_boundary_id(1);
5452 else if (
std::abs(face->center()[0] - half_length) <
5454 face->set_boundary_id(2);
5456 face->set_all_manifold_ids(0);
5469 const bool colorize)
5479 Point<3>((a + b) / 2, a, (a + b) / 2),
5486 Point<3>((a + b) / 2, (a + b) / 2, a),
5488 Point<3>(a, (a + b) / 2, (a + b) / 2),
5489 Point<3>((a + b) / 2, (a + b) / 2, (a + b) / 2),
5490 Point<3>(b, (a + b) / 2, (a + b) / 2),
5492 Point<3>((a + b) / 2, (a + b) / 2, b),
5500 Point<3>((a + b) / 2, b, (a + b) / 2),
5504 const int cell_vertices[7][8] = {{0, 1, 9, 10, 3, 4, 12, 13},
5505 {1, 2, 10, 11, 4, 5, 13, 14},
5506 {3, 4, 12, 13, 6, 7, 15, 16},
5507 {4, 5, 13, 14, 7, 8, 16, 17},
5508 {9, 10, 18, 19, 12, 13, 21, 22},
5509 {10, 11, 19, 20, 13, 14, 22, 23},
5510 {12, 13, 21, 22, 15, 16, 24, 25}};
5514 for (
unsigned int i = 0; i < 7; ++i)
5516 for (
unsigned int j = 0; j < 8; ++j)
5517 cells[i].vertices[j] = cell_vertices[i][j];
5518 cells[i].material_id = 0;
5522 std::end(vertices)),
5536 const unsigned int n_rotate_middle_square)
5539 ExcMessage(
"The number of rotation by pi/2 of the right square "
5540 "must be in the half-open range [0,4)."));
5542 constexpr unsigned int dim = 2;
5544 const unsigned int n_cells = 5;
5545 std::vector<CellData<dim>> cells(n_cells);
5548 const std::vector<Point<dim>> vertices = {
Point<dim>(0, 0),
5563 unsigned int cell_vertices[
n_cells][4] = {{0, 1, 2, 3},
5569 switch (n_rotate_middle_square)
5573 cell_vertices[1][0] = 4;
5574 cell_vertices[1][1] = 5;
5575 cell_vertices[1][2] = 1;
5576 cell_vertices[1][3] = 3;
5582 cell_vertices[1][0] = 5;
5583 cell_vertices[1][1] = 3;
5584 cell_vertices[1][2] = 4;
5585 cell_vertices[1][3] = 1;
5591 cell_vertices[1][0] = 3;
5592 cell_vertices[1][1] = 1;
5593 cell_vertices[1][2] = 5;
5594 cell_vertices[1][3] = 4;
5604 for (
unsigned int cell_index = 0; cell_index <
n_cells; ++cell_index)
5606 for (
const unsigned int vertex_index :
5609 cells[cell_index].vertices[vertex_index] =
5610 cell_vertices[cell_index][vertex_index];
5611 cells[cell_index].material_id = 0;
5621 const bool face_orientation,
5622 const bool face_flip,
5623 const bool face_rotation,
5624 const bool manipulate_left_cube)
5626 constexpr unsigned int dim = 3;
5628 const unsigned int n_cells = 2;
5629 std::vector<CellData<dim>> cells(n_cells);
5632 const std::vector<Point<dim>> vertices = {
Point<dim>(0, 0, 0),
5645 unsigned int cell_vertices[
n_cells][8] = {
5646 {0, 1, 2, 3, 4, 5, 6, 7},
5647 {1, 8, 3, 9, 5, 10, 7, 11}};
5650 const unsigned int this_case = 4 *
static_cast<int>(face_orientation) +
5651 2 *
static_cast<int>(face_flip) +
5652 static_cast<int>(face_rotation);
5654 if (manipulate_left_cube)
5660 cell_vertices[0][0] = 1;
5661 cell_vertices[0][1] = 0;
5662 cell_vertices[0][2] = 5;
5663 cell_vertices[0][3] = 4;
5664 cell_vertices[0][4] = 3;
5665 cell_vertices[0][5] = 2;
5666 cell_vertices[0][6] = 7;
5667 cell_vertices[0][7] = 6;
5673 cell_vertices[0][0] = 5;
5674 cell_vertices[0][1] = 4;
5675 cell_vertices[0][2] = 7;
5676 cell_vertices[0][3] = 6;
5677 cell_vertices[0][4] = 1;
5678 cell_vertices[0][5] = 0;
5679 cell_vertices[0][6] = 3;
5680 cell_vertices[0][7] = 2;
5686 cell_vertices[0][0] = 7;
5687 cell_vertices[0][1] = 6;
5688 cell_vertices[0][2] = 3;
5689 cell_vertices[0][3] = 2;
5690 cell_vertices[0][4] = 5;
5691 cell_vertices[0][5] = 4;
5692 cell_vertices[0][6] = 1;
5693 cell_vertices[0][7] = 0;
5698 cell_vertices[0][0] = 3;
5699 cell_vertices[0][1] = 2;
5700 cell_vertices[0][2] = 1;
5701 cell_vertices[0][3] = 0;
5702 cell_vertices[0][4] = 7;
5703 cell_vertices[0][5] = 6;
5704 cell_vertices[0][6] = 5;
5705 cell_vertices[0][7] = 4;
5711 cell_vertices[0][0] = 0;
5712 cell_vertices[0][1] = 1;
5713 cell_vertices[0][2] = 2;
5714 cell_vertices[0][3] = 3;
5715 cell_vertices[0][4] = 4;
5716 cell_vertices[0][5] = 5;
5717 cell_vertices[0][6] = 6;
5718 cell_vertices[0][7] = 7;
5724 cell_vertices[0][0] = 2;
5725 cell_vertices[0][1] = 3;
5726 cell_vertices[0][2] = 6;
5727 cell_vertices[0][3] = 7;
5728 cell_vertices[0][4] = 0;
5729 cell_vertices[0][5] = 1;
5730 cell_vertices[0][6] = 4;
5731 cell_vertices[0][7] = 5;
5737 cell_vertices[0][0] = 6;
5738 cell_vertices[0][1] = 7;
5739 cell_vertices[0][2] = 4;
5740 cell_vertices[0][3] = 5;
5741 cell_vertices[0][4] = 2;
5742 cell_vertices[0][5] = 3;
5743 cell_vertices[0][6] = 0;
5744 cell_vertices[0][7] = 1;
5750 cell_vertices[0][0] = 4;
5751 cell_vertices[0][1] = 5;
5752 cell_vertices[0][2] = 0;
5753 cell_vertices[0][3] = 1;
5754 cell_vertices[0][4] = 6;
5755 cell_vertices[0][5] = 7;
5756 cell_vertices[0][6] = 2;
5757 cell_vertices[0][7] = 3;
5768 cell_vertices[1][0] = 8;
5769 cell_vertices[1][1] = 1;
5770 cell_vertices[1][2] = 10;
5771 cell_vertices[1][3] = 5;
5772 cell_vertices[1][4] = 9;
5773 cell_vertices[1][5] = 3;
5774 cell_vertices[1][6] = 11;
5775 cell_vertices[1][7] = 7;
5781 cell_vertices[1][0] = 10;
5782 cell_vertices[1][1] = 5;
5783 cell_vertices[1][2] = 11;
5784 cell_vertices[1][3] = 7;
5785 cell_vertices[1][4] = 8;
5786 cell_vertices[1][5] = 1;
5787 cell_vertices[1][6] = 9;
5788 cell_vertices[1][7] = 3;
5794 cell_vertices[1][0] = 11;
5795 cell_vertices[1][1] = 7;
5796 cell_vertices[1][2] = 9;
5797 cell_vertices[1][3] = 3;
5798 cell_vertices[1][4] = 10;
5799 cell_vertices[1][5] = 5;
5800 cell_vertices[1][6] = 8;
5801 cell_vertices[1][7] = 1;
5807 cell_vertices[1][0] = 9;
5808 cell_vertices[1][1] = 3;
5809 cell_vertices[1][2] = 8;
5810 cell_vertices[1][3] = 1;
5811 cell_vertices[1][4] = 11;
5812 cell_vertices[1][5] = 7;
5813 cell_vertices[1][6] = 10;
5814 cell_vertices[1][7] = 5;
5820 cell_vertices[1][0] = 1;
5821 cell_vertices[1][1] = 8;
5822 cell_vertices[1][2] = 3;
5823 cell_vertices[1][3] = 9;
5824 cell_vertices[1][4] = 5;
5825 cell_vertices[1][5] = 10;
5826 cell_vertices[1][6] = 7;
5827 cell_vertices[1][7] = 11;
5833 cell_vertices[1][0] = 5;
5834 cell_vertices[1][1] = 10;
5835 cell_vertices[1][2] = 1;
5836 cell_vertices[1][3] = 8;
5837 cell_vertices[1][4] = 7;
5838 cell_vertices[1][5] = 11;
5839 cell_vertices[1][6] = 3;
5840 cell_vertices[1][7] = 9;
5846 cell_vertices[1][0] = 7;
5847 cell_vertices[1][1] = 11;
5848 cell_vertices[1][2] = 5;
5849 cell_vertices[1][3] = 10;
5850 cell_vertices[1][4] = 3;
5851 cell_vertices[1][5] = 9;
5852 cell_vertices[1][6] = 1;
5853 cell_vertices[1][7] = 8;
5859 cell_vertices[1][0] = 3;
5860 cell_vertices[1][1] = 9;
5861 cell_vertices[1][2] = 7;
5862 cell_vertices[1][3] = 11;
5863 cell_vertices[1][4] = 1;
5864 cell_vertices[1][5] = 8;
5865 cell_vertices[1][6] = 5;
5866 cell_vertices[1][7] = 10;
5874 for (
unsigned int cell_index = 0; cell_index <
n_cells; ++cell_index)
5876 for (
const unsigned int vertex_index :
5879 cells[cell_index].vertices[vertex_index] =
5880 cell_vertices[cell_index][vertex_index];
5881 cells[cell_index].material_id = 0;
5890 template <
int spacedim>
5898 const std::set<types::boundary_id> boundary_ids = {0};
5910 const unsigned int x_subdivisions,
5912 const double half_length)
5919 std::vector<Point<3>> vertices;
5920 const double initial_height = -half_length;
5921 const double height_increment = 2. * half_length / x_subdivisions;
5923 for (
unsigned int rep = 0; rep < (x_subdivisions + 1); ++rep)
5925 const double height = initial_height + height_increment * rep;
5927 vertices.emplace_back(-d,
height, -d);
5928 vertices.emplace_back(d,
height, -d);
5929 vertices.emplace_back(-a,
height, -a);
5930 vertices.emplace_back(a,
height, -a);
5931 vertices.emplace_back(-a,
height, a);
5932 vertices.emplace_back(a,
height, a);
5933 vertices.emplace_back(-d,
height, d);
5934 vertices.emplace_back(d,
height, d);
5938 for (
auto &vertex : vertices)
5940 const double h = vertex[1];
5941 vertex[1] = -vertex[0];
5945 std::vector<std::vector<int>> cell_vertices;
5946 cell_vertices.push_back({0, 1, 8, 9, 2, 3, 10, 11});
5947 cell_vertices.push_back({0, 2, 8, 10, 6, 4, 14, 12});
5948 cell_vertices.push_back({2, 3, 10, 11, 4, 5, 12, 13});
5949 cell_vertices.push_back({1, 7, 9, 15, 3, 5, 11, 13});
5950 cell_vertices.push_back({6, 4, 14, 12, 7, 5, 15, 13});
5952 for (
unsigned int rep = 1; rep < x_subdivisions; ++rep)
5954 for (
unsigned int i = 0; i < 5; ++i)
5956 std::vector<int> new_cell_vertices(8);
5957 for (
unsigned int j = 0; j < 8; ++j)
5958 new_cell_vertices[j] = cell_vertices[i][j] + 8 * rep;
5959 cell_vertices.push_back(new_cell_vertices);
5963 unsigned int n_cells = x_subdivisions * 5;
5965 std::vector<CellData<3>> cells(n_cells,
CellData<3>());
5967 for (
unsigned int i = 0; i <
n_cells; ++i)
5969 for (
unsigned int j = 0; j < 8; ++j)
5970 cells[i].vertices[j] = cell_vertices[i][j];
5971 cells[i].material_id = 0;
5975 std::end(vertices)),
5999 if (cell->
face(i)->center()[0] > half_length - tolerance)
6001 cell->
face(i)->set_boundary_id(2);
6004 for (
unsigned int e = 0; e < GeometryInfo<3>::lines_per_face;
6006 if ((std::fabs(cell->
face(i)->line(e)->vertex(0)[1]) == a) ||
6007 (std::fabs(cell->
face(i)->line(e)->vertex(0)[2]) == a) ||
6008 (std::fabs(cell->
face(i)->line(e)->vertex(1)[1]) == a) ||
6009 (std::fabs(cell->
face(i)->line(e)->vertex(1)[2]) == a))
6011 cell->
face(i)->line(e)->set_boundary_id(2);
6012 cell->
face(i)->line(e)->set_manifold_id(
6016 else if (cell->
face(i)->center()[0] < -half_length + tolerance)
6018 cell->
face(i)->set_boundary_id(1);
6021 for (
unsigned int e = 0; e < GeometryInfo<3>::lines_per_face;
6023 if ((std::fabs(cell->
face(i)->line(e)->vertex(0)[1]) == a) ||
6024 (std::fabs(cell->
face(i)->line(e)->vertex(0)[2]) == a) ||
6025 (std::fabs(cell->
face(i)->line(e)->vertex(1)[1]) == a) ||
6026 (std::fabs(cell->
face(i)->line(e)->vertex(1)[2]) == a))
6028 cell->
face(i)->line(e)->set_boundary_id(1);
6029 cell->
face(i)->line(e)->set_manifold_id(
6042 const double half_length)
6053 const unsigned int dim = 3;
6061 const double a = 0.528;
6062 const double b = 0.4533;
6063 const double c = 0.3752;
6080 const int cell_vertices[4][8] = {{0, 2, 3, 4, 7, 9, 10, 11},
6081 {1, 6, 2, 4, 8, 13, 9, 11},
6082 {5, 3, 6, 4, 12, 10, 13, 11},
6083 {7, 9, 10, 11, 14, 8, 12, 13}};
6087 for (
unsigned int i = 0; i < 4; ++i)
6089 for (
unsigned int j = 0; j < 8; ++j)
6090 cells[i].vertices[j] = cell_vertices[i][j];
6091 cells[i].material_id = 0;
6095 std::end(vertices)),
6107 if (cell->
face(i)->boundary_id() ==
6112 if (cell->
face(i)->center()[0] < center[0] + 1.e-5 *
radius ||
6113 cell->
face(i)->center()[1] < center[1] + 1.e-5 *
radius ||
6114 cell->
face(i)->center()[2] < center[2] + 1.e-5 *
radius)
6116 cell->
face(i)->set_boundary_id(1);
6120 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
6123 const Point<3> line_vertices[2] = {
6124 cell->
face(i)->line(j)->vertex(0),
6125 cell->
face(i)->line(j)->vertex(1)};
6126 if ((std::fabs(line_vertices[0].distance(center) -
radius) >
6128 (std::fabs(line_vertices[1].distance(center) -
radius) >
6131 cell->
face(i)->line(j)->set_boundary_id(1);
6132 cell->
face(i)->line(j)->set_manifold_id(
6156 const double b = a / 2.0;
6157 const double c =
d / 2.0;
6182 int cell_vertices[6][8] = {{0, 1, 8, 9, 2, 3, 10, 11},
6183 {0, 2, 8, 10, 6, 4, 14, 12},
6184 {2, 3, 10, 11, 4, 5, 12, 13},
6185 {1, 7, 9, 15, 3, 5, 11, 13},
6186 {6, 4, 14, 12, 7, 5, 15, 13},
6187 {8, 10, 9, 11, 14, 12, 15, 13}};
6191 for (
unsigned int i = 0; i < 6; ++i)
6193 for (
unsigned int j = 0; j < 8; ++j)
6194 cells[i].vertices[j] = cell_vertices[i][j];
6195 cells[i].material_id = 0;
6199 std::end(vertices)),
6223 if (cell->
face(i)->center()[0] < center[0] + 1.e-5 *
radius)
6225 cell->
face(i)->set_boundary_id(1);
6227 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
6230 const Point<3> line_vertices[2] = {
6231 cell->
face(i)->line(j)->vertex(0),
6232 cell->
face(i)->line(j)->vertex(1)};
6233 if ((std::fabs(line_vertices[0].distance(center) -
radius) >
6235 (std::fabs(line_vertices[1].distance(center) -
radius) >
6238 cell->
face(i)->line(j)->set_boundary_id(1);
6239 cell->
face(i)->line(j)->set_manifold_id(
6269 for (
unsigned int round = 0; round < dim; ++round)
6274 std::vector<Point<dim>> new_points(tria_copy.
n_vertices());
6276 for (
unsigned int v = 0; v < tria_copy.
n_vertices(); ++v)
6284 else if (round == 1)
6286 for (
unsigned int v = 0; v < tria_copy.
n_vertices(); ++v)
6295 else if (round == 2)
6296 for (
unsigned int v = 0; v < tria_copy.
n_vertices(); ++v)
6309 std::vector<CellData<dim>> cells;
6310 cells.reserve(tria_copy.
n_cells());
6318 cells.push_back(data);
6326 if (round == dim - 1)
6356 hyper_shell_6(Triangulation<3> &tria,
6358 const double inner_radius,
6361 std::vector<Point<3>> vertices;
6362 std::vector<CellData<3>> cells;
6364 const double irad = inner_radius /
std::sqrt(3.0);
6368 static const std::array<Point<3>, 8> hexahedron = {{{-1, -1, -1},
6378 vertices.reserve(8);
6379 for (
unsigned int i = 0; i < 8; ++i)
6380 vertices.push_back(p + hexahedron[i] * irad);
6381 for (
unsigned int i = 0; i < 8; ++i)
6382 vertices.push_back(p + hexahedron[i] * orad);
6384 const unsigned int n_cells = 6;
6385 const int cell_vertices[
n_cells][8] = {
6386 {8, 9, 10, 11, 0, 1, 2, 3},
6387 {9, 11, 1, 3, 13, 15, 5, 7},
6388 {12, 13, 4, 5, 14, 15, 6, 7},
6389 {8, 0, 10, 2, 12, 4, 14, 6},
6390 {8, 9, 0, 1, 12, 13, 4, 5},
6391 {10, 2, 11, 3, 14, 6, 15, 7}};
6393 cells.resize(n_cells, CellData<3>());
6395 for (
unsigned int i = 0; i <
n_cells; ++i)
6398 cells[i].vertices[j] = cell_vertices[i][j];
6399 cells[i].material_id = 0;
6408 hyper_shell_12(Triangulation<3> &tria,
6410 const double inner_radius,
6413 std::vector<Point<3>> vertices;
6414 std::vector<CellData<3>> cells;
6416 const double irad = inner_radius /
std::sqrt(3.0);
6423 static const std::array<Point<3>, 6> octahedron = {{{-1, 0, 0},
6431 static const std::array<Point<3>, 8> hexahedron = {{{-1, -1, -1},
6440 vertices.reserve(8);
6441 for (
unsigned int i = 0; i < 8; ++i)
6442 vertices.push_back(p + hexahedron[i] * irad);
6443 for (
unsigned int i = 0; i < 6; ++i)
6444 vertices.push_back(p + octahedron[i] * inner_radius);
6445 for (
unsigned int i = 0; i < 8; ++i)
6446 vertices.push_back(p + hexahedron[i] * orad);
6447 for (
unsigned int i = 0; i < 6; ++i)
6450 const unsigned int n_cells = 12;
6451 const unsigned int rhombi[
n_cells][4] = {{10, 4, 0, 8},
6464 cells.resize(n_cells, CellData<3>());
6466 for (
unsigned int i = 0; i <
n_cells; ++i)
6468 for (
unsigned int j = 0; j < 4; ++j)
6470 cells[i].vertices[j] = rhombi[i][j];
6471 cells[i].vertices[j + 4] = rhombi[i][j] + 14;
6473 cells[i].material_id = 0;
6482 hyper_shell_24_48(Triangulation<3> &tria,
6483 const unsigned int n,
6484 const unsigned int n_refinement_steps,
6486 const double inner_radius,
6499 Triangulation<3> tmp;
6500 const unsigned int outer_radius_factor = 1 << n_refinement_steps;
6506 (outer_radius_factor - 1) * inner_radius);
6512 (outer_radius_factor - 1) * inner_radius);
6515 for (
unsigned int r = 0; r < n_refinement_steps; ++r)
6518 std::set<Triangulation<3>::active_cell_iterator> cells_to_remove;
6524 unsigned int n_vertices_inside = 0;
6526 if ((cell->
vertex(v) - p).norm_square() <
6527 inner_radius * inner_radius * (1 + 1e-12))
6528 ++n_vertices_inside;
6529 if (n_vertices_inside < 4)
6530 cells_to_remove.insert(cell);
6534 if (r == n_refinement_steps - 1)
6540 Triangulation<3>
copy;
6544 tmp = std::move(copy);
6562 const double inner_radius,
6564 const unsigned int n_cells,
6565 const bool colorize)
6570 unsigned int n_refinement_steps = 0;
6571 unsigned int n_cells_coarsened =
n_cells;
6572 if (n_cells != 96 && n_cells > 12)
6573 while (n_cells_coarsened > 12 && n_cells_coarsened % 4 == 0)
6575 ++n_refinement_steps;
6576 n_cells_coarsened /= 4;
6578 Assert(n_cells == 0 || n_cells == 6 || n_cells == 12 || n_cells == 96 ||
6579 (n_refinement_steps > 0 &&
6580 (n_cells_coarsened == 6 || n_cells_coarsened == 12)),
6581 ExcMessage(
"Invalid number of coarse mesh cells"));
6583 const unsigned int n = n_refinement_steps > 0 ?
6584 4 * n_cells_coarsened :
6590 internal::hyper_shell_6(tria, p, inner_radius,
outer_radius);
6593 internal::hyper_shell_12(tria, p, inner_radius,
outer_radius);
6597 internal::hyper_shell_24_48(
6598 tria, n, n_refinement_steps, p, inner_radius,
outer_radius);
6607 internal::hyper_shell_12(tmp, p, inner_radius,
outer_radius);
6624 colorize_hyper_shell(tria, p, inner_radius,
outer_radius);
6634 const double inner_radius,
6636 const unsigned int ,
6637 const bool colorize)
6644 const double a = inner_radius /
std::sqrt(2.0);
6646 const double b = a / 2.0;
6647 const double c =
d / 2.0;
6649 const double hb = inner_radius *
std::sqrt(3.0) / 2.0;
6672 int cell_vertices[5][8] = {{0, 1, 8, 9, 2, 3, 10, 11},
6673 {0, 2, 8, 10, 6, 4, 14, 12},
6674 {1, 7, 9, 15, 3, 5, 11, 13},
6675 {6, 4, 14, 12, 7, 5, 15, 13},
6676 {8, 10, 9, 11, 14, 12, 15, 13}};
6680 for (
unsigned int i = 0; i < 5; ++i)
6682 for (
unsigned int j = 0; j < 8; ++j)
6683 cells[i].vertices[j] = cell_vertices[i][j];
6684 cells[i].material_id = 0;
6688 std::end(vertices)),
6703 cell->
face(f)->set_all_boundary_ids(2);
6714 const Point<3> face_center(face->center(
true));
6716 if (
std::abs(face_center[0] - center[0]) >
6717 1.e-6 * face_center.
norm())
6719 if (
std::abs((face_center - center).
norm() - inner_radius) <
6721 face->set_all_boundary_ids(0);
6723 face->set_all_boundary_ids(1);
6735 const double inner_radius,
6737 const unsigned int n,
6738 const bool colorize)
6742 if (n == 0 || n == 3)
6744 const double a = inner_radius *
std::sqrt(2.0) / 2e0;
6746 const double c = a *
std::sqrt(3.0) / 2e0;
6749 const double h = inner_radius / 2e0;
6751 std::vector<Point<3>> vertices;
6753 vertices.push_back(center +
Point<3>(0, inner_radius, 0));
6754 vertices.push_back(center +
Point<3>(a, a, 0));
6755 vertices.push_back(center +
Point<3>(b, b, 0));
6757 vertices.push_back(center +
Point<3>(0, a, a));
6758 vertices.push_back(center +
Point<3>(c, c, h));
6759 vertices.push_back(center +
Point<3>(d, d, e));
6760 vertices.push_back(center +
Point<3>(0, b, b));
6761 vertices.push_back(center +
Point<3>(inner_radius, 0, 0));
6763 vertices.push_back(center +
Point<3>(a, 0, a));
6764 vertices.push_back(center +
Point<3>(b, 0, b));
6765 vertices.push_back(center +
Point<3>(0, 0, inner_radius));
6768 const int cell_vertices[3][8] = {
6769 {0, 1, 3, 2, 4, 5, 7, 6},
6770 {1, 8, 2, 9, 5, 10, 6, 11},
6771 {4, 5, 7, 6, 12, 10, 13, 11},
6773 std::vector<CellData<3>> cells(3);
6775 for (
unsigned int i = 0; i < 3; ++i)
6777 for (
unsigned int j = 0; j < 8; ++j)
6778 cells[i].vertices[j] = cell_vertices[i][j];
6779 cells[i].material_id = 0;
6795 colorize_quarter_hyper_shell(tria, center, inner_radius,
outer_radius);
6803 const double length,
6804 const double inner_radius,
6806 const unsigned int n_radial_cells,
6807 const unsigned int n_axial_cells,
6808 const bool colorize)
6824 const unsigned int N_r =
6825 (n_radial_cells == 0 ?
static_cast<unsigned int>(std::ceil(
6829 const unsigned int N_z =
6830 (n_axial_cells == 0 ?
6831 static_cast<unsigned int>(std::ceil(
6832 length / (2 * pi * (
outer_radius + inner_radius) / 2 / N_r))) :
6841 std::vector<Point<2>> vertices_2d(2 * N_r);
6842 for (
unsigned int i = 0; i < N_r; ++i)
6847 vertices_2d[i + N_r] = vertices_2d[i] * (inner_radius /
outer_radius);
6850 std::vector<Point<3>> vertices_3d;
6851 vertices_3d.reserve(2 * N_r * (N_z + 1));
6852 for (
unsigned int j = 0; j <= N_z; ++j)
6853 for (
unsigned int i = 0; i < 2 * N_r; ++i)
6855 const Point<3> v(vertices_2d[i][0],
6858 vertices_3d.push_back(v);
6861 std::vector<CellData<3>> cells(N_r * N_z,
CellData<3>());
6863 for (
unsigned int j = 0; j < N_z; ++j)
6864 for (
unsigned int i = 0; i < N_r; ++i)
6866 cells[i + j * N_r].vertices[0] = i + (j + 1) * 2 * N_r;
6867 cells[i + j * N_r].vertices[1] = (i + 1) % N_r + (j + 1) * 2 * N_r;
6868 cells[i + j * N_r].vertices[2] = i + j * 2 * N_r;
6869 cells[i + j * N_r].vertices[3] = (i + 1) % N_r + j * 2 * N_r;
6871 cells[i + j * N_r].vertices[4] = N_r + i + (j + 1) * 2 * N_r;
6872 cells[i + j * N_r].vertices[5] =
6873 N_r + ((i + 1) % N_r) + (j + 1) * 2 * N_r;
6874 cells[i + j * N_r].vertices[6] = N_r + i + j * 2 * N_r;
6875 cells[i + j * N_r].vertices[7] = N_r + ((i + 1) % N_r) + j * 2 * N_r;
6877 cells[i + j * N_r].material_id = 0;
6896 double eps_z = 1
e-6 * length;
6901 double face_inner_radius = std::numeric_limits<double>::max();
6902 double face_outer_radius = 0.;
6910 if (!cell->
face(f)->at_boundary())
6913 const auto face_center = cell->
face(f)->center();
6914 const double z = face_center[2];
6916 if ((std::fabs(z) > eps_z) &&
6917 (std::fabs(z - length) > eps_z))
6920 face_center[1] * face_center[1]);
6926 double mid_radial_distance = 0.5 * (face_outer_radius - face_inner_radius);
6931 if (cell->
face(f)->at_boundary())
6933 const auto face_center = cell->
face(f)->center();
6936 face_center[1] * face_center[1]);
6938 const double z = face_center[2];
6940 if (std::fabs(z) < eps_z)
6942 cell->
face(f)->set_boundary_id(2);
6944 else if (std::fabs(z - length) <
6947 cell->
face(f)->set_boundary_id(3);
6949 else if (std::fabs(
radius - face_inner_radius) >
6950 mid_radial_distance)
6952 cell->
face(f)->set_boundary_id(1);
6954 else if (std::fabs(
radius - face_inner_radius) <
6955 mid_radial_distance)
6957 cell->
face(f)->set_boundary_id(0);
6966 template <
int dim,
int spacedim>
6971 const double duplicated_vertex_tolerance,
6972 const bool copy_manifold_ids,
6973 const bool copy_boundary_ids)
6975 std::vector<Point<spacedim>> vertices;
6976 std::vector<CellData<dim>> cells;
6979 unsigned int n_accumulated_vertices = 0;
6980 for (
const auto triangulation : triangulations)
6983 ExcMessage(
"The input triangulations must be non-empty "
6984 "and must not be refined."));
6986 auto [tria_vertices, tria_cells, tria_subcell_data] =
6996 vertices.insert(vertices.end(),
6997 tria_vertices.begin(),
6998 tria_vertices.end());
7001 for (
unsigned int &vertex_n : cell_data.vertices)
7002 vertex_n += n_accumulated_vertices;
7003 cells.push_back(cell_data);
7007 if (copy_manifold_ids)
7009 for (
CellData<1> &line_data : tria_subcell_data.boundary_lines)
7013 for (
unsigned int &vertex_n : line_data.
vertices)
7014 vertex_n += n_accumulated_vertices;
7020 for (
CellData<2> &quad_data : tria_subcell_data.boundary_quads)
7024 for (
unsigned int &vertex_n : quad_data.
vertices)
7025 vertex_n += n_accumulated_vertices;
7032 n_accumulated_vertices += triangulation->
n_vertices();
7036 std::vector<unsigned int> considered_vertices;
7040 considered_vertices,
7041 duplicated_vertex_tolerance);
7045 if (std::all_of(cells.begin(), cells.end(), [](
const auto &cell) {
7046 return cell.vertices.size() ==
7047 ReferenceCells::get_hypercube<dim>().n_vertices();
7053 if (!copy_manifold_ids)
7056 if (copy_boundary_ids)
7058 auto result_cell = result.
begin();
7059 for (
const auto &tria : triangulations)
7064 if (result_cell->face(f)->at_boundary())
7065 result_cell->face(f)->set_boundary_id(
7066 cell->
face(f)->boundary_id());
7072 Assert(duplicated_vertex_tolerance > 0.0 ||
7073 n_accumulated_vertices == result.
n_vertices(),
7079 template <
int dim,
int spacedim>
7084 const double duplicated_vertex_tolerance,
7085 const bool copy_manifold_ids,
7086 const bool copy_boundary_ids)
7089 if (triangulation_1.
n_cells() == 0)
7091 if (&result != &triangulation_2)
7094 else if (triangulation_2.
n_cells() == 0)
7096 if (&result != &triangulation_1)
7102 duplicated_vertex_tolerance,
7132 template <
int structdim>
7136 static_assert(structdim == 1 || structdim == 2,
7137 "This function is only implemented for lines and "
7145 std::sort(std::begin(cell_data.vertices),
7146 std::end(cell_data.vertices));
7147 else if (structdim == 2)
7150 std::array<unsigned int, 4> renumbering{};
7151 std::copy(std::begin(cell_data.vertices),
7152 std::end(cell_data.vertices),
7153 renumbering.begin());
7164 std::swap(renumbering[2], renumbering[3]);
7165 std::rotate(renumbering.begin(),
7166 std::min_element(renumbering.begin(),
7170 std::swap(renumbering[2], renumbering[3]);
7178 if (renumbering[1] > renumbering[2])
7179 std::swap(renumbering[1], renumbering[2]);
7180 std::copy(renumbering.begin(),
7182 std::begin(cell_data.vertices));
7189 return std::lexicographical_compare(std::begin(a.
vertices),
7191 std::begin(
b.vertices),
7192 std::end(
b.vertices));
7194 std::sort(subcell_data.begin(), subcell_data.end(), compare);
7199 auto left = subcell_data.begin();
7200 while (left != subcell_data.end())
7203 std::upper_bound(left, subcell_data.end(), *left, compare);
7206 if (left + 1 != right)
7207 for (
auto it = left; it != right; ++it)
7210 Assert(it->manifold_id == left->manifold_id,
7212 "In the process of grid generation a single "
7213 "line or quadrilateral has been assigned two "
7214 "different manifold ids. This can happen when "
7215 "a Triangulation is copied, e.g., via "
7216 "GridGenerator::replicate_triangulation() and "
7217 "not all external boundary faces have the same "
7218 "manifold id. Double check that all faces "
7219 "which you expect to be merged together have "
7220 "the same manifold id."));
7225 subcell_data.erase(std::unique(subcell_data.begin(), subcell_data.end()),
7226 subcell_data.end());
7232 template <
int dim,
int spacedim>
7235 const std::vector<unsigned int> &extents,
7241 for (
const auto &extent : extents)
7244 "The Triangulation must be copied at least one time in "
7245 "each coordinate dimension."));
7248 const auto &
min = bbox.get_boundary_points().first;
7249 const auto &
max = bbox.get_boundary_points().second;
7251 std::array<Tensor<1, spacedim>, dim> offsets;
7252 for (
unsigned int d = 0;
d < dim; ++
d)
7253 offsets[d][d] = max[d] - min[d];
7257 for (
unsigned int d = 0;
d < dim; ++
d)
7259 auto [input_vertices, input_cell_data, input_subcell_data] =
7262 std::vector<Point<spacedim>> output_vertices = input_vertices;
7263 std::vector<CellData<dim>> output_cell_data = input_cell_data;
7264 SubCellData output_subcell_data = input_subcell_data;
7266 for (
unsigned int k = 1; k < extents[
d]; ++k)
7268 const std::size_t vertex_offset = k * input_vertices.size();
7271 output_vertices.push_back(point +
double(k) * offsets[d]);
7275 output_cell_data.push_back(cell_data);
7276 for (
unsigned int &vertex : output_cell_data.back().vertices)
7277 vertex += vertex_offset;
7281 input_subcell_data.boundary_lines)
7284 for (
unsigned int &vertex :
7286 vertex += vertex_offset;
7289 input_subcell_data.boundary_quads)
7292 for (
unsigned int &vertex :
7294 vertex += vertex_offset;
7299 std::vector<unsigned int> boundary_vertices;
7303 output_subcell_data,
7324 tria_to_replicate.
clear();
7327 output_subcell_data);
7335 template <
int dim,
int spacedim>
7343 ExcMessage(
"The two input triangulations are not derived from "
7344 "the same coarse mesh as required."));
7347 &triangulation_1) ==
nullptr) &&
7350 &triangulation_2) ==
nullptr),
7351 ExcMessage(
"The source triangulations for this function must both "
7352 "be available entirely locally, and not be distributed "
7353 "triangulations."));
7370 for (
unsigned int iteration = 0; iteration < triangulation_2.
n_levels();
7376 bool any_cell_flagged =
false;
7378 if (intergrid_map[result_cell]->has_children())
7380 any_cell_flagged =
true;
7381 result_cell->set_refine_flag();
7384 if (any_cell_flagged ==
false)
7393 template <
int dim,
int spacedim>
7403 std::vector<Point<spacedim>> vertices = input_triangulation.
get_vertices();
7407 std::vector<CellData<dim>> cells;
7409 if (cells_to_remove.find(cell) == cells_to_remove.end())
7411 Assert(
static_cast<unsigned int>(cell->
level()) ==
7412 input_triangulation.
n_levels() - 1,
7414 "Your input triangulation appears to have "
7415 "adaptively refined cells. This is not allowed. You can "
7416 "only call this function on a triangulation in which "
7417 "all cells are on the same refinement level."));
7423 cells.push_back(this_cell);
7429 std::vector<unsigned int> considered_vertices;
7433 considered_vertices);
7445 const unsigned int n_slices,
7448 const bool copy_manifold_ids,
7449 const std::vector<types::manifold_id> &manifold_priorities)
7453 "The input triangulation must be a coarse mesh, i.e., it must "
7454 "not have been refined."));
7456 ExcMessage(
"The output triangulation object needs to be empty."));
7458 ExcMessage(
"The given height for extrusion must be positive."));
7461 "The number of slices for extrusion must be at least 2."));
7463 const double delta_h =
height / (n_slices - 1);
7464 std::vector<double> slices_z_values;
7465 slices_z_values.reserve(n_slices);
7466 for (
unsigned int i = 0; i < n_slices; ++i)
7467 slices_z_values.push_back(i * delta_h);
7469 input, slices_z_values, result, copy_manifold_ids, manifold_priorities);
7477 const unsigned int n_slices,
7480 const bool copy_manifold_ids,
7481 const std::vector<types::manifold_id> &manifold_priorities)
7487 (void)copy_manifold_ids;
7488 (void)manifold_priorities;
7492 "GridTools::extrude_triangulation() is only available "
7493 "for Triangulation<3, 3> as output triangulation."));
7501 const std::vector<double> &slice_coordinates,
7503 const bool copy_manifold_ids,
7504 const std::vector<types::manifold_id> &manifold_priorities)
7508 "The input triangulation must be a coarse mesh, i.e., it must "
7509 "not have been refined."));
7511 ExcMessage(
"The output triangulation object needs to be empty."));
7512 Assert(slice_coordinates.size() >= 2,
7514 "The number of slices for extrusion must be at least 2."));
7515 Assert(std::is_sorted(slice_coordinates.begin(), slice_coordinates.end()),
7516 ExcMessage(
"Slice z-coordinates should be in ascending order"));
7519 "This function is only implemented for quadrilateral meshes."));
7521 const auto priorities = [&]() -> std::vector<types::manifold_id> {
7525 if (0 < manifold_priorities.size())
7530 std::vector<types::manifold_id> sorted_manifold_priorities =
7531 manifold_priorities;
7532 std::sort(sorted_manifold_priorities.begin(),
7533 sorted_manifold_priorities.end());
7534 Assert(std::unique(sorted_manifold_priorities.begin(),
7535 sorted_manifold_priorities.end()) ==
7536 sorted_manifold_priorities.end(),
7538 "The given vector of manifold ids may not contain any "
7539 "duplicated entries."));
7540 std::vector<types::manifold_id> sorted_manifold_ids =
7542 std::sort(sorted_manifold_ids.begin(), sorted_manifold_ids.end());
7543 if (sorted_manifold_priorities != sorted_manifold_ids)
7545 std::ostringstream message;
7546 message <<
"The given triangulation has manifold ids {";
7548 sorted_manifold_ids)
7549 if (manifold_id != sorted_manifold_ids.back())
7551 message << sorted_manifold_ids.back() <<
"}, but \n"
7552 <<
" the given vector of manifold ids is {";
7554 manifold_priorities)
7555 if (manifold_id != manifold_priorities.back())
7558 << manifold_priorities.back() <<
"}.\n"
7559 <<
" These vectors should contain the same elements.\n";
7560 const std::string m = message.str();
7564 return manifold_priorities;
7568 std::vector<types::manifold_id> default_priorities =
7570 const auto first_tfi_it = std::partition(
7571 default_priorities.begin(),
7572 default_priorities.end(),
7574 return dynamic_cast<const TransfiniteInterpolationManifold<2, 2> *>(
7575 &input.get_manifold(id)) == nullptr;
7577 std::sort(default_priorities.begin(), first_tfi_it);
7578 std::sort(first_tfi_it, default_priorities.end());
7580 return default_priorities;
7583 const std::size_t n_slices = slice_coordinates.size();
7584 std::vector<Point<3>> points(n_slices * input.
n_vertices());
7585 std::vector<CellData<3>> cells;
7590 for (std::size_t slice_n = 0; slice_n < n_slices; ++slice_n)
7592 for (std::size_t vertex_n = 0; vertex_n < input.
n_vertices();
7596 points[slice_n * input.
n_vertices() + vertex_n] =
7597 Point<3>(vertex[0], vertex[1], slice_coordinates[slice_n]);
7605 for (std::size_t slice_n = 0; slice_n < n_slices - 1; ++slice_n)
7608 for (
const unsigned int vertex_n :
7620 if (copy_manifold_ids)
7622 cells.push_back(this_cell);
7637 if (face->at_boundary())
7639 if (copy_manifold_ids)
7641 for (std::size_t slice_n = 0; slice_n < n_slices - 1; ++slice_n)
7644 face->vertex_index(0) + slice_n * input.
n_vertices();
7646 face->vertex_index(1) + slice_n * input.
n_vertices();
7648 face->vertex_index(0) + (slice_n + 1) * input.
n_vertices();
7650 face->vertex_index(1) + (slice_n + 1) * input.
n_vertices();
7651 quads.push_back(quad);
7657 if (copy_manifold_ids)
7663 for (std::size_t slice_n = 1; slice_n < n_slices - 1; ++slice_n)
7673 quads.push_back(quad);
7684 "The input triangulation to this function is using boundary "
7685 "indicators in a range that do not allow using "
7686 "max_boundary_id+1 and max_boundary_id+2 as boundary "
7687 "indicators for the bottom and top faces of the "
7688 "extruded triangulation."));
7699 if (copy_manifold_ids)
7701 quads.push_back(quad);
7704 for (
unsigned int &vertex : quad.
vertices)
7705 vertex += (n_slices - 1) * input.
n_vertices();
7706 if (copy_manifold_ids)
7708 quads.push_back(quad);
7721 for (
auto manifold_id_it = priorities.rbegin();
7722 manifold_id_it != priorities.rend();
7725 if (face->manifold_id() == *manifold_id_it)
7726 for (
unsigned int line_n = 0;
7727 line_n < GeometryInfo<3>::lines_per_face;
7729 face->line(line_n)->set_manifold_id(*manifold_id_it);
7737 const std::vector<double> &slice_coordinates,
7739 const bool copy_manifold_ids,
7740 const std::vector<types::manifold_id> &manifold_priorities)
7743 (void)slice_coordinates;
7745 (void)copy_manifold_ids;
7746 (void)manifold_priorities;
7750 "GridTools::extrude_triangulation() is only available "
7751 "for Triangulation<3, 3> as output triangulation."));
7770 template <
int spacedim>
7773 const double inner_radius,
7777 const bool colorize)
7782 ExcMessage(
"outer_radius has to be bigger than inner_radius."));
7791 std::vector<bool> treated_vertices(triangulation.
n_vertices(),
false);
7795 if (cell->
face(f)->at_boundary())
7796 for (
const unsigned int v : cell->
face(f)->vertex_indices())
7803 (std::fabs(std::fabs(cell->
face(f)->vertex(v)[0]) -
7804 std::fabs(cell->
face(f)->vertex(v)[1])) <
7812 if (cell->
face(f)->at_boundary())
7814 const double dx = cell->
face(f)->center()[0] - center[0];
7815 const double dy = cell->
face(f)->center()[1] - center[1];
7819 cell->
face(f)->set_boundary_id(0);
7821 cell->
face(f)->set_boundary_id(1);
7823 cell->
face(f)->set_boundary_id(2);
7825 cell->
face(f)->set_boundary_id(3);
7828 cell->
face(f)->set_boundary_id(4);
7829 cell->
face(f)->set_manifold_id(0);
7834 const double d = (cell->
face(f)->center() - center).norm();
7835 if (d - inner_radius < 0)
7837 cell->
face(f)->set_boundary_id(1);
7838 cell->
face(f)->set_manifold_id(0);
7841 cell->
face(f)->set_boundary_id(0);
7853 const double inner_radius,
7856 const unsigned int width_repetition,
7857 const bool colorize)
7859 hyper_cube_with_cylindrical_hole_2D(triangulation,
7872 const double inner_radius,
7875 const unsigned int width_repetition,
7876 const bool colorize)
7878 hyper_cube_with_cylindrical_hole_2D(triangulation,
7892 const double inner_radius,
7894 const unsigned int n_shells,
7895 const double skewness,
7896 const unsigned int n_cells,
7897 const bool colorize)
7901 ExcMessage(
"outer_radius has to be bigger than inner_radius."));
7905 std::vector<double> radii;
7906 radii.push_back(inner_radius);
7907 for (
unsigned int shell_n = 1; shell_n < n_shells; ++shell_n)
7908 if (skewness == 0.0)
7910 radii.push_back(inner_radius +
7912 (1.0 - (1.0 -
double(shell_n) / n_shells)));
7917 (1.0 -
std::tanh(skewness * (1.0 -
double(shell_n) / n_shells)) /
7921 double grid_vertex_tolerance = 0.0;
7922 for (
unsigned int shell_n = 0; shell_n < radii.size() - 1; ++shell_n)
7929 n_cells == 0 ? (dim == 2 ? 8 : 12) :
7934 if (grid_vertex_tolerance == 0.0)
7935 grid_vertex_tolerance =
7936 0.5 * internal::minimal_vertex_distance(current_shell);
7939 triangulation.
clear();
7943 grid_vertex_tolerance);
7955 constexpr double radial_vertex_tolerance =
7956 100.0 * std::numeric_limits<double>::epsilon();
7957 auto assert_vertex_distance_within_tolerance =
7958 [center, radial_vertex_tolerance](
7962 (void)radial_vertex_tolerance;
7963 for (
unsigned int vertex_n = 0;
7964 vertex_n < GeometryInfo<dim>::vertices_per_face;
7968 (center.
norm() +
radius) * radial_vertex_tolerance,
7976 auto face = cell->
face(face_n);
7977 if (face->at_boundary())
7979 if (((face->vertex(0) - center).norm() - inner_radius) <
7980 (center.
norm() + inner_radius) * radial_vertex_tolerance)
7983 assert_vertex_distance_within_tolerance(face, inner_radius);
7984 face->set_all_boundary_ids(0);
7989 assert_vertex_distance_within_tolerance(face,
outer_radius);
7990 face->set_all_boundary_ids(1);
8001 const double inner_radius,
8004 const unsigned int Nz,
8005 const bool colorize)
8010 ExcMessage(
"outer_radius has to be bigger than inner_radius."));
8024 std::vector<bool> treated_vertices(triangulation.
n_vertices(),
false);
8028 if (cell->
face(f)->at_boundary())
8030 for (
const unsigned int v : cell->
face(f)->vertex_indices())
8032 const unsigned int vv = cell->
face(f)->vertex_index(v);
8033 if (treated_vertices[vv] ==
false)
8035 treated_vertices[vv] =
true;
8045 cell->
face(f)->vertex(v);
8046 if ((std::fabs(std::fabs(vertex_location[0]) -
8047 std::fabs(vertex_location[1])) <
8049 (std::fabs(vertex_location[0] * vertex_location[0] +
8050 vertex_location[1] * vertex_location[1] -
8053 cell->
face(f)->vertex(v) =
8056 vertex_location[2]);
8065 if (cell->
face(f)->at_boundary())
8067 const double dx = cell->
face(f)->center()[0];
8068 const double dy = cell->
face(f)->center()[1];
8069 const double dz = cell->
face(f)->center()[2];
8074 cell->
face(f)->set_boundary_id(0);
8077 cell->
face(f)->set_boundary_id(1);
8080 cell->
face(f)->set_boundary_id(2);
8083 cell->
face(f)->set_boundary_id(3);
8086 cell->
face(f)->set_boundary_id(4);
8089 cell->
face(f)->set_boundary_id(5);
8093 cell->
face(f)->set_all_boundary_ids(6);
8094 cell->
face(f)->set_all_manifold_ids(0);
8101 const double d = c.
norm();
8102 if (d - inner_radius < 0)
8104 cell->
face(f)->set_all_boundary_ids(1);
8105 cell->
face(f)->set_all_manifold_ids(0);
8108 cell->
face(f)->set_boundary_id(0);
8117 template <
int dim,
int spacedim1,
int spacedim2>
8124 &in_tria) ==
nullptr),
8126 "This function cannot be used on "
8127 "parallel::distributed::Triangulation objects as inputs."));
8129 ExcMessage(
"This function does not work for meshes that have "
8133 const unsigned int spacedim =
std::min(spacedim1, spacedim2);
8134 const std::vector<Point<spacedim1>> &in_vertices = in_tria.
get_vertices();
8138 std::vector<Point<spacedim2>> v(in_vertices.size());
8139 for (
unsigned int i = 0; i < in_vertices.size(); ++i)
8140 for (
unsigned int d = 0;
d < spacedim; ++
d)
8141 v[i][d] = in_vertices[i][d];
8148 cells[id].vertices.resize(cell->
n_vertices());
8166 std::vector<bool> user_flags_line;
8169 .clear_user_flags_line();
8175 if (face->at_boundary())
8180 for (
const auto i : face->vertex_indices())
8181 boundary_line.
vertices[i] = face->vertex_index(i);
8186 std::move(boundary_line));
8199 if ((face->user_flag_set() ==
false) &&
8205 for (
const auto i : face->vertex_indices())
8206 boundary_line.
vertices[i] = face->vertex_index(i);
8212 std::move(boundary_line));
8214 face->set_user_flag();
8220 .load_user_flags_line(user_flags_line);
8227 std::vector<bool> user_flags_line;
8230 .clear_user_flags_line();
8232 std::vector<bool> user_flags_quad;
8235 .clear_user_flags_quad();
8241 if (face->at_boundary())
8246 for (
const auto i : face->vertex_indices())
8247 boundary_face.
vertices[i] = face->vertex_index(i);
8252 std::move(boundary_face));
8259 for (
unsigned int e = 0;
e < face->n_lines(); ++
e)
8260 if (face->line(e)->user_flag_set() ==
false)
8263 spacedim1>::line_iterator
8264 edge = face->line(e);
8268 for (
const auto i : edge->vertex_indices())
8269 boundary_edge.
vertices[i] = edge->vertex_index(i);
8274 std::move(boundary_edge));
8276 edge->set_user_flag();
8294 if (face->user_flag_set() ==
false)
8301 for (
const auto i : face->vertex_indices())
8302 boundary_face.
vertices[i] = face->vertex_index(i);
8308 std::move(boundary_face));
8310 face->set_user_flag();
8319 for (
unsigned int e = 0;
e < face->n_lines(); ++
e)
8320 if (face->line(e)->at_boundary() ==
false)
8321 if (face->line(e)->user_flag_set() ==
false)
8324 line_iterator edge = face->line(e);
8328 for (
const auto i : edge->vertex_indices())
8330 edge->vertex_index(i);
8336 std::move(boundary_edge));
8338 edge->set_user_flag();
8345 .load_user_flags_line(user_flags_line);
8347 .load_user_flags_quad(user_flags_quad);
8364 template <
int dim,
int spacedim>
8368 const unsigned int n_divisions)
8370 if constexpr (dim == 1)
8375 else if constexpr (dim == 2)
8377 n_divisions == 2 || n_divisions == 8,
8379 "Quadrilaterals must be split into either 2 or 8 triangles."));
8380 else if constexpr (dim == 3)
8381 AssertThrow(n_divisions == 6 || n_divisions == 24,
8383 "Hexahedra must be split into either 6 or 24 tetrahedra."));
8387 "GridGenerator::convert_hypercube_to_simplex_mesh() expects "
8388 "a Triangulation that consists only of quads/hexes."));
8406 {{{0, 1, 2}}, {{3, 2, 1}}}};
8416 [[maybe_unused]]
const auto vertex_ids_for_cells_2d =
8429 {{{0, 1, 12, 10}}, {{2, 3, 11, 12}}, {{7, 6, 11, 13}},
8430 {{5, 4, 13, 10}}, {{0, 2, 8, 12}}, {{4, 6, 13, 8}},
8431 {{5, 13, 7, 9}}, {{1, 9, 3, 12}}, {{0, 8, 4, 10}},
8432 {{1, 5, 9, 10}}, {{3, 7, 11, 9}}, {{2, 6, 8, 11}},
8433 {{12, 13, 10, 9}}, {{12, 13, 9, 11}}, {{12, 13, 11, 8}},
8434 {{12, 13, 8, 10}}, {{13, 8, 10, 4}}, {{13, 10, 9, 5}},
8435 {{13, 9, 11, 7}}, {{13, 11, 8, 6}}, {{10, 12, 9, 1}},
8436 {{9, 12, 11, 3}}, {{11, 12, 8, 2}}, {{8, 12, 10, 0}}}};
8438 [[maybe_unused]]
const auto vertex_ids_for_cells_3d =
8445 array<std::pair<unsigned int, std::array<unsigned int, 2>>, 4>
8446 vertex_ids_for_boundary_faces_2d_2 = {
8447 {{0, {{0, 2}}}, {1, {{1, 3}}}, {2, {{0, 1}}}, {3, {{2, 3}}}}};
8452 array<std::pair<unsigned int, std::array<unsigned int, 2>>, 8>
8453 vertex_ids_for_boundary_faces_2d_8 = {{{0, {{0, 4}}},
8461 [[maybe_unused]]
const auto vertex_ids_for_boundary_faces_2d =
8462 n_divisions == 2 ?
make_array_view(vertex_ids_for_boundary_faces_2d_2) :
8468 array<std::pair<unsigned int, std::array<unsigned int, 3>>, 12>
8469 vertex_ids_for_boundary_faces_3d_6 = {{{0, {{2, 6, 0}}},
8485 array<std::pair<unsigned int, std::array<unsigned int, 3>>, 24>
8486 vertex_ids_for_boundary_faces_3d_24 = {
8487 {{0, {{0, 4, 8}}}, {0, {{4, 8, 6}}}, {0, {{8, 6, 2}}},
8488 {0, {{0, 2, 8}}}, {1, {{1, 3, 9}}}, {1, {{3, 9, 7}}},
8489 {1, {{9, 7, 5}}}, {1, {{1, 9, 5}}}, {2, {{0, 1, 10}}},
8490 {2, {{1, 10, 5}}}, {2, {{10, 5, 4}}}, {2, {{0, 10, 4}}},
8491 {3, {{2, 3, 11}}}, {3, {{3, 11, 7}}}, {3, {{11, 7, 6}}},
8492 {3, {{2, 11, 6}}}, {4, {{0, 1, 12}}}, {4, {{1, 12, 3}}},
8493 {4, {{12, 3, 2}}}, {4, {{0, 12, 2}}}, {5, {{4, 5, 13}}},
8494 {5, {{5, 13, 7}}}, {5, {{13, 7, 6}}}, {5, {{4, 13, 6}}}}};
8495 [[maybe_unused]]
const auto vertex_ids_for_boundary_faces_3d =
8496 n_divisions == 6 ?
make_array_view(vertex_ids_for_boundary_faces_3d_6) :
8514 [[maybe_unused]]
const auto vertex_ids_for_inner_faces_2d =
8533 {{0, 12, 10}}, {{12, 1, 10}}, {{12, 1, 9}}, {{12, 3, 9}},
8534 {{12, 2, 11}}, {{12, 3, 11}}, {{12, 0, 8}}, {{12, 2, 8}},
8535 {{9, 13, 5}}, {{13, 7, 9}}, {{11, 7, 13}}, {{11, 6, 13}},
8536 {{4, 8, 13}}, {{6, 8, 13}}, {{4, 13, 10}}, {{13, 5, 10}},
8537 {{10, 9, 5}}, {{10, 9, 1}}, {{11, 9, 7}}, {{11, 9, 3}},
8538 {{8, 11, 2}}, {{8, 11, 6}}, {{8, 10, 0}}, {{8, 10, 4}},
8539 {{12, 3, 9}}, {{12, 9, 11}}, {{12, 3, 11}}, {{3, 9, 11}},
8540 {{2, 12, 8}}, {{2, 12, 11}}, {{2, 11, 8}}, {{8, 12, 11}},
8541 {{0, 12, 10}}, {{0, 12, 8}}, {{0, 8, 10}}, {{8, 10, 12}},
8542 {{12, 1, 10}}, {{12, 1, 9}}, {{1, 10, 9}}, {{10, 9, 12}},
8543 {{10, 8, 4}}, {{10, 8, 13}}, {{4, 13, 8}}, {{4, 13, 10}},
8544 {{10, 9, 13}}, {{10, 9, 5}}, {{13, 5, 10}}, {{13, 5, 9}},
8545 {{13, 7, 9}}, {{13, 7, 11}}, {{9, 11, 13}}, {{9, 11, 7}},
8546 {{8, 11, 13}}, {{8, 11, 6}}, {{6, 13, 8}}, {{6, 13, 11}},
8547 {{12, 13, 10}}, {{12, 13, 8}}, {{8, 10, 13}}, {{8, 10, 12}},
8548 {{12, 13, 10}}, {{12, 13, 9}}, {{10, 9, 13}}, {{10, 9, 12}},
8549 {{12, 13, 9}}, {{12, 13, 11}}, {{9, 11, 13}}, {{9, 11, 12}},
8550 {{12, 13, 11}}, {{12, 13, 8}}, {{8, 11, 13}}, {{8, 11, 12}},
8552 [[maybe_unused]]
const auto vertex_ids_for_inner_faces_3d =
8563 {{{{12, 10}}, {{12, 9}}, {{12, 11}}, {{12, 8}}, {{9, 13}}, {{11, 13}},
8564 {{8, 13}}, {{10, 13}}, {{10, 9}}, {{9, 11}}, {{11, 8}}, {{8, 10}},
8565 {{12, 9}}, {{12, 11}}, {{11, 9}}, {{12, 8}}, {{12, 11}}, {{11, 8}},
8566 {{12, 8}}, {{12, 10}}, {{10, 8}}, {{12, 10}}, {{12, 9}}, {{9, 10}},
8567 {{13, 10}}, {{13, 8}}, {{8, 10}}, {{13, 10}}, {{13, 9}}, {{9, 10}},
8568 {{13, 11}}, {{13, 9}}, {{11, 9}}, {{13, 11}}, {{13, 8}}, {{11, 8}},
8569 {{12, 13}}, {{8, 10}}, {{8, 13}}, {{10, 13}}, {{8, 12}}, {{10, 12}},
8570 {{12, 13}}, {{10, 9}}, {{10, 13}}, {{9, 13}}, {{10, 12}}, {{9, 12}},
8571 {{12, 13}}, {{9, 11}}, {{9, 13}}, {{11, 13}}, {{9, 12}}, {{11, 12}},
8572 {{12, 13}}, {{11, 8}}, {{11, 13}}, {{8, 13}}, {{11, 12}}, {{8, 12}}}};
8573 [[maybe_unused]]
const auto vertex_ids_for_inner_edges_3d =
8585 array<std::pair<unsigned int, std::array<unsigned int, 2>>, 6>
8586 vertex_ids_for_new_boundary_edges_3d_6 = {{{0, {{0, 6}}},
8601 array<std::pair<unsigned int, std::array<unsigned int, 2>>, 24>
8602 vertex_ids_for_new_boundary_edges_3d_24 = {
8603 {{0, {{4, 8}}}, {0, {{6, 8}}}, {0, {{0, 8}}}, {0, {{2, 8}}},
8604 {1, {{5, 9}}}, {1, {{7, 9}}}, {1, {{1, 9}}}, {1, {{3, 9}}},
8605 {2, {{4, 10}}}, {2, {{5, 10}}}, {2, {{0, 10}}}, {2, {{1, 10}}},
8606 {3, {{6, 11}}}, {3, {{7, 11}}}, {3, {{2, 11}}}, {3, {{3, 11}}},
8607 {4, {{2, 12}}}, {4, {{3, 12}}}, {4, {{0, 12}}}, {4, {{1, 12}}},
8608 {5, {{6, 13}}}, {5, {{7, 13}}}, {5, {{4, 13}}}, {5, {{5, 13}}}}};
8609 [[maybe_unused]]
const auto vertex_ids_for_new_boundary_edges_3d =
8614 std::vector<Point<spacedim>> vertices;
8615 std::vector<CellData<dim>> cells;
8620 std::vector<unsigned int> old_to_new_vertex_indices(
8622 std::vector<unsigned int> face_to_new_vertex_indices(
8636 std::array<unsigned int, dim == 2 ? 9 : 14> local_vertex_indices;
8644 if (old_to_new_vertex_indices[v_global] ==
8647 old_to_new_vertex_indices[v_global] = vertices.size();
8648 vertices.push_back(cell->
vertex(v));
8652 local_vertex_indices[v] = old_to_new_vertex_indices[v_global];
8656 if constexpr (dim > 1)
8661 if (face_to_new_vertex_indices[f_global] ==
8664 face_to_new_vertex_indices[f_global] = vertices.size();
8666 cell->
face(f)->center(
true));
8670 local_vertex_indices.size());
8671 local_vertex_indices[cell->
n_vertices() + f] =
8672 face_to_new_vertex_indices[f_global];
8679 local_vertex_indices.size());
8682 vertices.push_back(cell->
center(
true));
8686 [[maybe_unused]]
const auto add_cell =
8687 [&](
const unsigned int struct_dim,
8688 const auto &index_vertices,
8689 const unsigned int material_or_boundary_id,
8693 if (struct_dim < dim && (material_or_boundary_id ==
8698 if (struct_dim == dim)
8703 cell_data.material_id =
8704 material_or_boundary_id;
8706 for (
unsigned int i = 0; i < cell_data.vertices.size(); ++i)
8709 local_vertex_indices.size());
8710 cell_data.vertices[i] =
8711 local_vertex_indices[index_vertices[i]];
8713 cells.emplace_back(std::move(cell_data));
8715 else if (dim == 2 && struct_dim == 1)
8720 boundary_line.
boundary_id = material_or_boundary_id;
8722 for (
unsigned int i = 0; i < boundary_line.
vertices.
size(); ++i)
8725 local_vertex_indices.size());
8727 local_vertex_indices[index_vertices[i]];
8730 std::move(boundary_line));
8732 else if (dim == 3 && struct_dim == 2)
8737 boundary_quad.
material_id = material_or_boundary_id;
8739 for (
unsigned int i = 0; i < boundary_quad.
vertices.
size(); ++i)
8742 local_vertex_indices.size());
8744 local_vertex_indices[index_vertices[i]];
8747 std::move(boundary_quad));
8749 else if (dim == 3 && struct_dim == 1)
8754 boundary_line.
boundary_id = material_or_boundary_id;
8756 for (
unsigned int i = 0; i < boundary_line.
vertices.
size(); ++i)
8759 local_vertex_indices.size());
8761 local_vertex_indices[index_vertices[i]];
8764 std::move(boundary_line));
8773 if constexpr (dim == 2)
8776 const auto manifold_id_cell = cell->
manifold_id();
8777 const auto material_id_cell = cell->
material_id();
8780 for (
const auto &cell_vertices : vertex_ids_for_cells_2d)
8781 add_cell(dim, cell_vertices, material_id_cell, manifold_id_cell);
8784 for (
const auto &face_vertices : vertex_ids_for_inner_faces_2d)
8793 else if constexpr (dim == 3)
8796 const auto manifold_id_cell = cell->
manifold_id();
8797 const auto material_id_cell = cell->
material_id();
8799 for (
const auto &cell_vertices : vertex_ids_for_cells_3d)
8800 add_cell(dim, cell_vertices, material_id_cell, manifold_id_cell);
8804 for (
const auto &face_vertices : vertex_ids_for_inner_faces_3d)
8812 for (
const auto &edge_vertices : vertex_ids_for_inner_edges_3d)
8822 if constexpr (dim == 2)
8824 for (
const auto &[quad_face_no, tri_face_vertices] :
8825 vertex_ids_for_boundary_faces_2d)
8827 const auto face = cell->
face(quad_face_no);
8830 face->boundary_id(),
8831 face->manifold_id());
8834 else if constexpr (dim == 3)
8836 for (
const auto &[hex_face_no, tet_face_vertices] :
8837 vertex_ids_for_boundary_faces_3d)
8839 const auto face = cell->
face(hex_face_no);
8842 face->boundary_id(),
8843 face->manifold_id());
8846 for (
const auto &[hex_face_no, tet_edge_vertices] :
8847 vertex_ids_for_new_boundary_edges_3d)
8849 const auto face = cell->
face(hex_face_no);
8852 face->boundary_id(),
8853 face->manifold_id());
8861 if constexpr (dim == 3)
8865 auto edge = cell->
line(e);
8871 old_to_new_vertex_indices[edge->vertex_index(0)];
8873 old_to_new_vertex_indices[edge->vertex_index(1)];
8892 template <
int dim,
int spacedim>
8897 if constexpr (dim == 1)
8907 "GridGenerator::convert_simplex_to_hypercube_mesh() expects "
8908 "a Triangulation that consists only of triangles/tetrahedra."));
8921 std::vector<Point<spacedim>> vertices = ref_tria.
get_vertices();
8923 (dim > 2 ? ref_tria.
n_quads() : 0) +
8925 std::map<typename Triangulation<dim, spacedim>::line_iterator,
8927 line_to_midpoint_vertex_map;
8928 std::map<typename Triangulation<dim, spacedim>::face_iterator,
8930 face_to_midpoint_vertex_map;
8931 std::map<typename Triangulation<dim, spacedim>::cell_iterator,
8933 cell_to_midpoint_vertex_map;
8939 if (face_to_midpoint_vertex_map.find(face) ==
8940 face_to_midpoint_vertex_map.end())
8945 vertices.push_back(new_vertex);
8949 face_to_midpoint_vertex_map[face] = vertices.size() - 1;
8953 if constexpr (dim == 3)
8955 for (
unsigned int l = 0;
l < face->n_lines(); ++
l)
8958 spacedim>::line_iterator
8959 line = face->line(l);
8960 if (line_to_midpoint_vertex_map.find(line) ==
8961 line_to_midpoint_vertex_map.end())
8967 vertices.push_back(new_vertex);
8972 line_to_midpoint_vertex_map[line] =
8973 vertices.size() - 1;
8983 vertices.push_back(new_vertex);
8987 cell_to_midpoint_vertex_map[cell] = vertices.size() - 1;
8990 Assert(vertices.size() ==
8998 std::vector<CellData<dim>> cell_data;
8999 cell_data.reserve(ref_tria.
n_cells() * (dim + 1));
9002 for (
unsigned int v = 0; v < cell->
n_vertices(); ++v)
9006 if constexpr (dim == 2)
9013 face_to_midpoint_vertex_map[cell->
line(v)],
9014 face_to_midpoint_vertex_map[cell->
line((v + 2) % 3)],
9015 cell_to_midpoint_vertex_map[cell]};
9023 line_to_midpoint_vertex_map[cell->
line(0)],
9024 line_to_midpoint_vertex_map[cell->
line(2)],
9025 face_to_midpoint_vertex_map[cell->
face(0)],
9026 line_to_midpoint_vertex_map[cell->
line(3)],
9027 face_to_midpoint_vertex_map[cell->
face(1)],
9028 face_to_midpoint_vertex_map[cell->
face(2)],
9029 cell_to_midpoint_vertex_map[cell]};
9034 line_to_midpoint_vertex_map[cell->
line(0)],
9036 face_to_midpoint_vertex_map[cell->
face(0)],
9037 line_to_midpoint_vertex_map[cell->
line(1)],
9038 face_to_midpoint_vertex_map[cell->
face(1)],
9039 line_to_midpoint_vertex_map[cell->
line(4)],
9040 cell_to_midpoint_vertex_map[cell],
9041 face_to_midpoint_vertex_map[cell->
face(3)]};
9046 line_to_midpoint_vertex_map[cell->
line(2)],
9047 face_to_midpoint_vertex_map[cell->
face(0)],
9049 line_to_midpoint_vertex_map[cell->
line(1)],
9050 face_to_midpoint_vertex_map[cell->
face(2)],
9051 cell_to_midpoint_vertex_map[cell],
9052 line_to_midpoint_vertex_map[cell->
line(5)],
9053 face_to_midpoint_vertex_map[cell->
face(3)]};
9058 line_to_midpoint_vertex_map[cell->
line(3)],
9059 face_to_midpoint_vertex_map[cell->
face(1)],
9060 face_to_midpoint_vertex_map[cell->
face(2)],
9061 cell_to_midpoint_vertex_map[cell],
9063 line_to_midpoint_vertex_map[cell->
line(4)],
9064 line_to_midpoint_vertex_map[cell->
line(5)],
9065 face_to_midpoint_vertex_map[cell->
face(3)]};
9074 cell_data.emplace_back(std::move(new_cell));
9081 if (face->at_boundary() && (face->boundary_id() != 0))
9085 if constexpr (dim == 2)
9087 CellData<dim - 1> child_face_1, child_face_2;
9088 child_face_1.
vertices = {face->vertex_index(0),
9089 face_to_midpoint_vertex_map[face]};
9090 child_face_1.boundary_id = face->boundary_id();
9091 child_face_2.vertices = {face_to_midpoint_vertex_map[face],
9092 face->vertex_index(1)};
9093 child_face_2.boundary_id = face->boundary_id();
9095 std::move(child_face_1));
9097 std::move(child_face_2));
9101 CellData<dim - 1> child_face_1, child_face_2, child_face_3;
9104 face->vertex_index(0),
9105 line_to_midpoint_vertex_map[face->line(0)],
9106 line_to_midpoint_vertex_map[face->line(2)],
9107 face_to_midpoint_vertex_map[face]};
9108 child_face_1.boundary_id = face->boundary_id();
9110 child_face_2.vertices = {
9111 line_to_midpoint_vertex_map[face->line(0)],
9112 face->vertex_index(1),
9113 face_to_midpoint_vertex_map[face],
9114 line_to_midpoint_vertex_map[face->line(1)]};
9116 child_face_2.boundary_id = face->boundary_id();
9118 child_face_3.vertices = {
9119 line_to_midpoint_vertex_map[face->line(2)],
9120 face_to_midpoint_vertex_map[face],
9121 face->vertex_index(2),
9122 line_to_midpoint_vertex_map[face->line(1)]};
9123 child_face_3.boundary_id = face->boundary_id();
9126 std::move(child_face_1));
9128 std::move(child_face_2));
9130 std::move(child_face_3));
9140 if constexpr (dim == 3)
9155 template <
int dim,
int spacedim>
9171 {{{0, 1, 3}}, {{1, 2, 3}}, {{2, 0, 3}}}};
9176 vertex_ids_for_boundary_faces_2d = {
9177 {{{{{0, 1}}}}, {{{{1, 2}}}}, {{{{2, 0}}}}}};
9181 {{{0, 1, 2, 4}}, {{1, 0, 3, 4}}, {{0, 2, 3, 4}}, {{2, 1, 3, 4}}}};
9186 vertex_ids_for_boundary_faces_3d = {
9187 {{{{{0, 1, 2}}}}, {{{{1, 0, 3}}}}, {{{{0, 2, 3}}}}, {{{{2, 1, 3}}}}}};
9193 vertex_ids_for_boundary_lines_3d = {{{{{{0, 1}}}},
9200 std::vector<Point<spacedim>> vertices;
9201 std::vector<CellData<dim>> cells;
9206 std::vector<unsigned int> old_to_new_vertex_indices(
9218 "Cell with invalid ReferenceCell encountered. GridGenerator::alfeld_split_of_simplex_mesh() "
9219 "only supports simplex meshes as input."));
9223 std::array<
unsigned int, (dim == 3) ? 5 : 4> local_vertex_indices;
9231 if (old_to_new_vertex_indices[v_global] ==
9234 old_to_new_vertex_indices[v_global] = vertices.size();
9235 vertices.push_back(cell->
vertex(v));
9239 local_vertex_indices[v] = old_to_new_vertex_indices[v_global];
9245 local_vertex_indices[local_vertex_indices.size() - 1] = vertices.size();
9246 vertices.push_back(barycenter /
static_cast<double>(dim + 1));
9249 const auto add_cell = [&](
const unsigned int struct_dim,
9250 const auto &index_vertices,
9251 const unsigned int material_or_boundary_id,
9255 if (struct_dim < dim &&
9260 if (struct_dim == dim)
9265 for (
unsigned int i = 0; i < index_vertices.size(); ++i)
9268 local_vertex_indices.size());
9269 cell_data.vertices[i] =
9270 local_vertex_indices[index_vertices[i]];
9272 cell_data.material_id =
9273 material_or_boundary_id;
9275 cells.emplace_back(std::move(cell_data));
9277 else if (dim == 2 && struct_dim == 1)
9282 boundary_line.
boundary_id = material_or_boundary_id;
9284 for (
unsigned int i = 0; i < boundary_line.
vertices.
size(); ++i)
9287 local_vertex_indices.size());
9289 local_vertex_indices[index_vertices[i]];
9292 std::move(boundary_line));
9294 else if (dim == 3 && struct_dim == 2)
9299 boundary_quad.
material_id = material_or_boundary_id;
9301 for (
unsigned int i = 0; i < boundary_quad.
vertices.
size(); ++i)
9304 local_vertex_indices.size());
9306 local_vertex_indices[index_vertices[i]];
9309 std::move(boundary_quad));
9311 else if (dim == 3 && struct_dim == 1)
9316 boundary_line.
boundary_id = material_or_boundary_id;
9318 for (
unsigned int i = 0; i < boundary_line.
vertices.
size(); ++i)
9321 local_vertex_indices.size());
9323 local_vertex_indices[index_vertices[i]];
9326 std::move(boundary_line));
9334 const auto material_id_cell = cell->
material_id();
9335 const auto manifold_id_cell = cell->
manifold_id();
9340 for (
const auto &cell_vertices : vertex_ids_for_cells_2d)
9341 add_cell(dim, cell_vertices, material_id_cell, manifold_id_cell);
9345 for (
const auto &cell_vertices : vertex_ids_for_cells_3d)
9346 add_cell(dim, cell_vertices, material_id_cell, manifold_id_cell);
9354 const auto bid = cell->
face(f)->boundary_id();
9355 const auto mid = cell->
face(f)->manifold_id();
9360 for (
const auto &face_vertices :
9361 vertex_ids_for_boundary_faces_2d[f])
9362 add_cell(1, face_vertices, bid, mid);
9366 for (
const auto &face_vertices :
9367 vertex_ids_for_boundary_faces_3d[f])
9368 add_cell(2, face_vertices, bid, mid);
9379 const auto bid = cell->
line(l)->boundary_id();
9380 const auto mid = cell->
line(l)->manifold_id();
9382 for (
const auto &line_vertices :
9383 vertex_ids_for_boundary_lines_3d[l])
9384 add_cell(1, line_vertices, bid, mid);
9399 template <
template <
int,
int>
class MeshType,
int dim,
int spacedim>
9403 std::map<
typename MeshType<dim - 1, spacedim>::cell_iterator,
9404 typename MeshType<dim, spacedim>::face_iterator>
9406 typename ExtractBoundaryMesh<MeshType, dim, spacedim>::return_type
9409 MeshType<dim - 1, spacedim> &surface_mesh,
9410 const std::set<types::boundary_id> &boundary_ids)
9414 &volume_mesh.get_triangulation()) ==
nullptr),
9423 constexpr unsigned int boundary_dim = dim - 1;
9430 std::pair<typename MeshType<dim, spacedim>::face_iterator,
unsigned int>>
9431 temporary_mapping_level0;
9436 std::vector<bool> touched(volume_mesh.get_triangulation().n_vertices(),
9440 std::vector<CellData<boundary_dim>> cells;
9442 std::vector<Point<spacedim>> vertices;
9445 std::map<unsigned int, unsigned int> map_vert_index;
9458 (volume_mesh.get_triangulation().is_mixed_mesh() ==
false),
9460 "Boundary extraction for mixed meshes is currently not supported."));
9462 volume_mesh.begin(0)->reference_cell();
9467 const unsigned int max_n_face_vertices =
9471 max_n_face_vertices);
9473 for (
unsigned int j = 0; j < max_n_face_vertices; ++j)
9474 swap_matrix[f][j] = j;
9481 std::swap(swap_matrix[0][1], swap_matrix[0][2]);
9482 std::swap(swap_matrix[2][1], swap_matrix[2][2]);
9483 std::swap(swap_matrix[4][1], swap_matrix[4][2]);
9487 std::swap(swap_matrix[1][0], swap_matrix[1][1]);
9488 std::swap(swap_matrix[2][0], swap_matrix[2][1]);
9498 std::swap(swap_matrix[f][0], swap_matrix[f][1]);
9508 for (
typename MeshType<dim, spacedim>::cell_iterator cell =
9509 volume_mesh.begin(0);
9510 cell != volume_mesh.end(0);
9512 for (
const unsigned int i : cell->
reference_cell().face_indices())
9514 const typename MeshType<dim, spacedim>::face_iterator face =
9517 if (face->at_boundary() &&
9518 (boundary_ids.empty() ||
9519 (boundary_ids.find(face->boundary_id()) != boundary_ids.end())))
9523 for (
const unsigned int j : face->vertex_indices())
9525 const unsigned int v_index = face->vertex_index(j);
9527 if (!touched[v_index])
9529 vertices.push_back(face->vertex(j));
9530 map_vert_index[v_index] = vertices.size() - 1;
9531 touched[v_index] =
true;
9534 c_data.vertices[swap_matrix[i][j]] = map_vert_index[v_index];
9536 c_data.material_id =
9538 c_data.manifold_id = face->manifold_id();
9548 for (
unsigned int e = 0;
e < face->n_lines(); ++
e)
9554 bool edge_found =
false;
9557 map_vert_index[face->line(e)->vertex_index(0)]) &&
9559 map_vert_index[face->line(e)->vertex_index(
9562 map_vert_index[face->line(e)->vertex_index(1)]) &&
9564 map_vert_index[face->line(e)->vertex_index(0)])))
9571 if (edge_found ==
true)
9578 map_vert_index[face->line(e)->vertex_index(0)];
9580 map_vert_index[face->line(e)->vertex_index(1)];
9587 cells.emplace_back(std::move(c_data));
9588 temporary_mapping_level0.push_back(std::make_pair(face, i));
9595 surface_mesh.get_triangulation())
9601 for (
const auto &cell : surface_mesh.active_cell_iterators())
9602 for (
unsigned int vertex = 0; vertex < 2; ++vertex)
9603 if (cell->
face(vertex)->at_boundary())
9604 cell->
face(vertex)->set_boundary_id(0);
9612 std::vector<std::pair<
9613 const typename MeshType<dim - 1, spacedim>::cell_iterator,
9614 std::pair<typename MeshType<dim, spacedim>::face_iterator,
unsigned int>>>
9615 temporary_map_boundary_cell_face;
9616 for (
const auto &cell : surface_mesh.active_cell_iterators())
9617 temporary_map_boundary_cell_face.push_back(
9618 std::make_pair(cell, temporary_mapping_level0.at(cell->
index())));
9630 unsigned int index_cells_deepest_level = 0;
9633 bool changed =
false;
9637 std::vector<unsigned int> cells_refined;
9641 for (
unsigned int cell_n = index_cells_deepest_level;
9642 cell_n < temporary_map_boundary_cell_face.size();
9647 if (temporary_map_boundary_cell_face[cell_n]
9648 .second.first->has_children())
9652 Assert(temporary_map_boundary_cell_face[cell_n]
9653 .second.first->refinement_case() ==
9656 temporary_map_boundary_cell_face[cell_n]
9657 .first->set_refine_flag();
9658 cells_refined.push_back(cell_n);
9669 surface_mesh.get_triangulation())
9673 index_cells_deepest_level = temporary_map_boundary_cell_face.size();
9674 for (
const auto &refined_cell_n : cells_refined)
9676 const typename MeshType<dim - 1, spacedim>::cell_iterator
9678 temporary_map_boundary_cell_face[refined_cell_n].first;
9679 const typename MeshType<dim,
9680 spacedim>::face_iterator refined_face =
9681 temporary_map_boundary_cell_face[refined_cell_n].second.first;
9682 const unsigned int refined_face_number =
9683 temporary_map_boundary_cell_face[refined_cell_n]
9685 for (
unsigned int child_n = 0;
9686 child_n < refined_cell->n_children();
9691 temporary_map_boundary_cell_face.push_back(
9692 std::make_pair(refined_cell->child(
9693 swap_matrix[refined_face_number][child_n]),
9694 std::make_pair(refined_face->child(child_n),
9695 refined_face_number)));
9705 std::map<
typename MeshType<dim - 1, spacedim>::cell_iterator,
9706 typename MeshType<dim, spacedim>::face_iterator>
9707 surface_to_volume_mapping;
9708 for (
unsigned int i = 0; i < temporary_map_boundary_cell_face.size(); ++i)
9709 surface_to_volume_mapping[temporary_map_boundary_cell_face[i].first] =
9710 temporary_map_boundary_cell_face[i].second.first;
9714 const auto attached_mids =
9715 surface_mesh.get_triangulation().get_manifold_ids();
9716 for (
const auto i : volume_mesh.get_triangulation().get_manifold_ids())
9718 std::find(attached_mids.begin(), attached_mids.end(), i) ==
9719 attached_mids.end())
9721 surface_mesh.get_triangulation())
9724 return surface_to_volume_mapping;
9729 template <
int dim,
int spacedim>
9733 const std::vector<unsigned int> &repetitions,
9736 const bool colorize)
9740 std::vector<Point<spacedim>> vertices;
9741 std::vector<CellData<dim>> cells;
9747 (p2[1] - p1[1]) / repetitions[1]);
9750 for (
unsigned int j = 0; j <= repetitions[1]; ++j)
9751 for (
unsigned int i = 0; i <= repetitions[0]; ++i)
9756 for (
unsigned int j = 0; j < repetitions[1]; ++j)
9757 for (
unsigned int i = 0; i < repetitions[0]; ++i)
9760 std::array<unsigned int, 4> quad{{
9761 (j + 0) * (repetitions[0] + 1) + i + 0,
9762 (j + 0) * (repetitions[0] + 1) + i + 1,
9763 (j + 1) * (repetitions[0] + 1) + i + 0,
9764 (j + 1) * (repetitions[0] + 1) + i + 1
9770 tri.
vertices = {quad[0], quad[1], quad[2]};
9771 cells.emplace_back(std::move(tri));
9777 tri.
vertices = {quad[3], quad[2], quad[1]};
9778 cells.emplace_back(std::move(tri));
9786 (p2[1] - p1[1]) / repetitions[1],
9787 (p2[2] - p1[2]) / repetitions[2]);
9790 for (
unsigned int k = 0; k <= repetitions[2]; ++k)
9791 for (
unsigned int j = 0; j <= repetitions[1]; ++j)
9792 for (
unsigned int i = 0; i <= repetitions[0]; ++i)
9795 p1[2] + dx[2] * k));
9798 for (
unsigned int k = 0; k < repetitions[2]; ++k)
9799 for (
unsigned int j = 0; j < repetitions[1]; ++j)
9800 for (
unsigned int i = 0; i < repetitions[0]; ++i)
9803 std::array<unsigned int, 8> quad{
9804 {(k + 0) * (repetitions[0] + 1) * (repetitions[1] + 1) +
9805 (j + 0) * (repetitions[0] + 1) + i + 0,
9806 (k + 0) * (repetitions[0] + 1) * (repetitions[1] + 1) +
9807 (j + 0) * (repetitions[0] + 1) + i + 1,
9808 (k + 0) * (repetitions[0] + 1) * (repetitions[1] + 1) +
9809 (j + 1) * (repetitions[0] + 1) + i + 0,
9810 (k + 0) * (repetitions[0] + 1) * (repetitions[1] + 1) +
9811 (j + 1) * (repetitions[0] + 1) + i + 1,
9812 (k + 1) * (repetitions[0] + 1) * (repetitions[1] + 1) +
9813 (j + 0) * (repetitions[0] + 1) + i + 0,
9814 (k + 1) * (repetitions[0] + 1) * (repetitions[1] + 1) +
9815 (j + 0) * (repetitions[0] + 1) + i + 1,
9816 (k + 1) * (repetitions[0] + 1) * (repetitions[1] + 1) +
9817 (j + 1) * (repetitions[0] + 1) + i + 0,
9818 (k + 1) * (repetitions[0] + 1) * (repetitions[1] + 1) +
9819 (j + 1) * (repetitions[0] + 1) + i + 1}};
9824 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
9825 cell.
vertices = {{quad[0], quad[1], quad[2], quad[4]}};
9827 cell.
vertices = {{quad[0], quad[1], quad[3], quad[5]}};
9829 cells.emplace_back(std::move(cell));
9835 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
9836 cell.
vertices = {{quad[2], quad[1], quad[3], quad[7]}};
9838 cell.
vertices = {{quad[0], quad[3], quad[2], quad[6]}};
9839 cells.emplace_back(std::move(cell));
9845 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
9846 cell.
vertices = {{quad[1], quad[4], quad[5], quad[7]}};
9848 cell.
vertices = {{quad[0], quad[4], quad[5], quad[6]}};
9849 cells.emplace_back(std::move(cell));
9855 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
9856 cell.
vertices = {{quad[2], quad[4], quad[7], quad[6]}};
9858 cell.
vertices = {{quad[3], quad[5], quad[7], quad[6]}};
9859 cells.emplace_back(std::move(cell));
9865 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
9866 cell.
vertices = {{quad[1], quad[2], quad[4], quad[7]}};
9868 cell.
vertices = {{quad[0], quad[3], quad[6], quad[5]}};
9869 cells.emplace_back(std::move(cell));
9891 double epsilon = std::numeric_limits<double>::max();
9892 for (
unsigned int i = 0; i < dim; ++i)
9894 0.01 * (
std::abs(p2[i] - p1[i]) / repetitions[i]));
9897 "The distance between corner points must be positive."));
9901 colorize_subdivided_hyper_rectangle(tria, p1, p2, epsilon);
9907 template <
int dim,
int spacedim>
9910 const unsigned int repetitions,
9913 const bool colorize)
9918 {{repetitions, repetitions}},
9927 {{repetitions, repetitions, repetitions}},
9929 {right, right, right},
9943 const double inner_radius,
9945 const bool colorize)
9949 ExcMessage(
"outer_radius has to be bigger than inner_radius."));
9957 if (cell->face(f)->at_boundary())
9958 for (
const unsigned int v : cell->face(f)->vertex_indices())
9959 if (std::fabs(cell->face(f)->vertex(v).norm() -
outer_radius) <
9962 const double ax = std::fabs(cell->face(f)->vertex(v)[0]);
9963 const double ay = std::fabs(cell->face(f)->vertex(v)[1]);
9964 const double az = std::fabs(cell->face(f)->vertex(v)[2]);
9965 const double max_coord =
std::max({ax, ay, az});
9975 for (
const unsigned int f : cell->face_indices())
9976 if (cell->face(f)->at_boundary())
9978 bool vertex_on_sphere =
true;
9979 for (
const unsigned int v : cell->face(f)->vertex_indices())
9980 if (
std::abs(cell->face(f)->vertex(v).norm() - inner_radius) >
9983 vertex_on_sphere =
false;
9987 if (vertex_on_sphere)
9989 cell->face(f)->set_all_manifold_ids(0);
9990 cell->face(f)->set_boundary_id(colorize ? 6 : 1);
9994 const Point<3> fc = cell->face(f)->center();
9996 cell->face(f)->set_boundary_id(0);
9998 cell->face(f)->set_boundary_id(1);
10000 cell->face(f)->set_boundary_id(2);
10002 cell->face(f)->set_boundary_id(3);
10004 cell->face(f)->set_boundary_id(4);
10006 cell->face(f)->set_boundary_id(5);
10040 const std::vector<unsigned int> &lengths_heights_widths,
10041 const double inner_radius,
10043 const bool use_transfinite_region,
10044 const bool colorize)
10048 ExcMessage(
"outer_radius has to be bigger than inner_radius."));
10051 const double length_pre = lengths_heights_widths[0] * 2 *
outer_radius;
10052 const double length_post = lengths_heights_widths[1] * 2 *
outer_radius;
10053 const double height_below = lengths_heights_widths[2] * 2 *
outer_radius;
10054 const double height_above = lengths_heights_widths[3] * 2 *
outer_radius;
10055 const double width_front = lengths_heights_widths[4] * 2 *
outer_radius;
10056 const double width_back = lengths_heights_widths[5] * 2 *
outer_radius;
10059 const unsigned int length_pre_repetitions = lengths_heights_widths[0];
10060 const unsigned int length_post_repetitions = lengths_heights_widths[1];
10061 const unsigned int height_below_repetitions = lengths_heights_widths[2];
10062 const unsigned int height_above_repetitions = lengths_heights_widths[3];
10063 const unsigned int width_front_repetitions = lengths_heights_widths[4];
10064 const unsigned int width_back_repetitions = lengths_heights_widths[5];
10069 {length_pre_repetitions + length_post_repetitions + 1,
10070 height_below_repetitions + height_above_repetitions + 1,
10071 width_front_repetitions + width_back_repetitions + 1},
10080 std::set<Triangulation<3>::active_cell_iterator> cells_to_remove;
10083 const Point<3> center = cell->center();
10087 cells_to_remove.insert(cell);
10093 tria_without_sphere);
10096 const double shell_radius = 0.5 * (inner_radius +
outer_radius);
10104 shell_tria,
Point<3>(), inner_radius, shell_radius, 1, 0.1, 6,
false);
10106 const double vertex_tol =
10107 std::min(internal::minimal_vertex_distance(shell_tria),
10108 internal::minimal_vertex_distance(sphere_tria)) *
10113 shell_tria, sphere_tria, temp, vertex_tol,
true);
10114 sphere_tria = std::move(temp);
10116 const double vertex_tolerance =
10117 std::min(internal::minimal_vertex_distance(tria_without_sphere),
10118 internal::minimal_vertex_distance(sphere_tria)) /
10122 tria_without_sphere, sphere_tria, tria, vertex_tolerance,
true);
10129 for (
const auto &face : cell->face_iterators())
10131 bool face_spherical =
true;
10132 for (
const auto v : face->vertex_indices())
10134 if (face->vertex(v).norm_square() >
std::sqrt(inner_radius))
10135 face_spherical =
false;
10137 if (face_spherical)
10138 face->set_all_manifold_ids(1);
10144 if (use_transfinite_region)
10156 const double tol = 1
e-6;
10158 if (face->at_boundary())
10160 const Point<3> center = face->center();
10162 if (
std::abs(center[0] - (-
static_cast<double>(
10164 face->set_boundary_id(0);
10166 else if (
std::abs(center[0] -
static_cast<double>(length_post +
10169 face->set_boundary_id(1);
10171 else if (face->manifold_id() == 1)
10172 face->set_boundary_id(2);
10174 else if (
std::abs(center[1] - (-
static_cast<double>(
10177 face->set_boundary_id(3);
10179 else if (
std::abs(center[1] -
static_cast<double>(height_above +
10182 face->set_boundary_id(4);
10184 else if (
std::abs(center[2] - (-
static_cast<double>(
10187 face->set_boundary_id(5);
10189 else if (
std::abs(center[2] -
static_cast<double>(
10191 face->set_boundary_id(6);
10201 const std::vector<unsigned int> &,
10215 const std::vector<unsigned int> &,
10226# include "grid/grid_generator.inst"
* * const Number outer_radius
ArrayView< std::remove_reference_t< typename std::iterator_traits< Iterator >::reference >, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
boost::container::small_vector< TriaIterator< TriaAccessor< dim - 1, dim, spacedim > >, ReferenceCells::max_n_faces< dim >() > face_iterators() const
unsigned int face_index(const unsigned int i) const
bool at_boundary(const unsigned int i) const
TriaIterator< TriaAccessor< dim - 1, dim, spacedim > > face(const unsigned int i) const
void set_material_id(const types::material_id new_material_id) const
unsigned int active_cell_index() const
types::material_id material_id() const
void make_mapping(const MeshType &source_grid, const MeshType &destination_grid)
void add_parameter(const std::string &entry, ParameterType ¶meter, const std::string &documentation="", const Patterns::PatternBase &pattern= *Patterns::Tools::Convert< ParameterType >::to_pattern(), const bool has_to_be_set=false)
void enter_subsection(const std::string &subsection, const bool create_path_if_needed=true)
static constexpr Point< dim, Number > unit_vector(const unsigned int i)
numbers::NumberTraits< Number >::real_type distance(const Point< dim, Number > &p) const
const Point< spacedim > & get_center() const
numbers::NumberTraits< Number >::real_type norm() const
constexpr numbers::NumberTraits< double >::real_type norm_square() const
void initialize(const Triangulation< dim, spacedim > &triangulation)
std_cxx20::ranges::iota_view< unsigned int, unsigned int > vertex_indices() const
unsigned int n_lines() const
unsigned int n_vertices() const
std_cxx20::ranges::iota_view< unsigned int, unsigned int > line_indices() const
void set_all_manifold_ids(const types::manifold_id manifold_ind) const
std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices() const
types::manifold_id manifold_id() const
unsigned int vertex_index(const unsigned int i) const
Point< spacedim > center(const bool respect_manifold=false, const bool interpolate_from_surrounding=false) const
ReferenceCell< structdim > reference_cell() const
Point< spacedim > & vertex(const unsigned int i) const
typename::internal::TriangulationImplementation::Iterators< dim, spacedim >::line_iterator line(const unsigned int i) const
unsigned int n_faces() const
virtual void add_periodicity(const std::vector< GridTools::PeriodicFacePair< cell_iterator > > &)
virtual types::global_cell_index n_global_active_cells() const
unsigned int n_quads() const
virtual void copy_triangulation(const Triangulation< dim, spacedim > &other_tria)
unsigned int n_faces() const
bool all_reference_cells_are_hyper_cube() const
void save_user_flags_line(std::ostream &out) const
face_iterator end_face() const
cell_iterator begin(const unsigned int level=0) const
unsigned int n_lines() const
std::vector< Point< spacedim > > vertices
virtual void create_triangulation(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
unsigned int n_active_cells() const
void refine_global(const unsigned int times=1)
const std::vector< Point< spacedim > > & get_vertices() const
unsigned int n_active_lines() const
unsigned int n_levels() const
cell_iterator end() const
virtual bool has_hanging_nodes() const
vertex_iterator begin_vertex() const
vertex_iterator end_vertex() const
virtual void execute_coarsening_and_refinement()
virtual unsigned int n_global_levels() const
cell_iterator last() const
face_iterator begin_face() const
unsigned int n_cells() const
void save_user_flags_quad(std::ostream &out) const
unsigned int n_vertices() const
bool all_reference_cells_are_simplex() const
active_cell_iterator begin_active(const unsigned int level=0) const
constexpr size_type size() const noexcept
#define DEAL_II_NAMESPACE_OPEN
constexpr bool running_in_debug_mode()
#define DEAL_II_CXX20_REQUIRES(condition)
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ASSERT_UNREACHABLE()
#define DEAL_II_NOT_IMPLEMENTED()
IteratorRange< active_face_iterator > active_face_iterators() const
IteratorRange< active_cell_iterator > active_cell_iterators() const
IteratorRange< cell_iterator > cell_iterators() const
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcLowerRange(int arg1, int arg2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcIndexRange(std::size_t arg1, std::size_t arg2, std::size_t arg3)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
TriaActiveIterator< CellAccessor< dim, spacedim > > active_cell_iterator
TriaIterator< TriaAccessor< dim - 1, dim, spacedim > > face_iterator
TriaIterator< CellAccessor< dim, spacedim > > cell_iterator
void set_all_manifold_ids_on_boundary(const types::manifold_id number)
const Manifold< dim, spacedim > & get_manifold(const types::manifold_id number) const
void copy_boundary_to_manifold_id(Triangulation< dim, spacedim > &tria, const bool reset_boundary_ids=false)
virtual std::vector< types::manifold_id > get_manifold_ids() const
void set_manifold(const types::manifold_id number, const Manifold< dim, spacedim > &manifold_object)
void reset_all_manifolds()
void set_all_manifold_ids(const types::manifold_id number)
void set_manifold_id(const types::manifold_id) const
void consistently_order_cells(std::vector< CellData< dim > > &cells)
const Mapping< dim, spacedim > & get_default_linear_mapping(const Triangulation< dim, spacedim > &triangulation)
CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt K
void create_triangulation(Triangulation< dim, dim > &tria, const AdditionalData &additional_data=AdditionalData())
void parallelepiped(Triangulation< dim > &tria, const Point< dim >(&corners)[dim], const bool colorize=false)
void hyper_cross(Triangulation< dim, spacedim > &tria, const std::vector< unsigned int > &sizes, const bool colorize_cells=false)
A center cell with stacks of cell protruding from each surface.
void hyper_cube_with_cylindrical_hole(Triangulation< dim, spacedim > &triangulation, const double inner_radius=.25, const double outer_radius=.5, const double L=.5, const unsigned int repetitions=1, const bool colorize=false)
void hyper_ball_balanced(Triangulation< dim > &tria, const Point< dim > ¢er=Point< dim >(), const double radius=1.)
void plate_with_a_hole(Triangulation< dim > &tria, const double inner_radius=0.4, const double outer_radius=1., const double pad_bottom=2., const double pad_top=2., const double pad_left=1., const double pad_right=1., const Point< dim > ¢er=Point< dim >(), const types::manifold_id polar_manifold_id=0, const types::manifold_id tfi_manifold_id=1, const double L=1., const unsigned int n_slices=2, const bool colorize=false)
Rectangular plate with an (offset) cylindrical hole.
void enclosed_hyper_cube(Triangulation< dim > &tria, const double left=0., const double right=1., const double thickness=1., const bool colorize=false)
void uniform_channel_with_sphere(Triangulation< dim > &tria, const std::vector< unsigned int > &lengths_heights_widths, const double inner_radius, const double outer_radius, const bool use_transfinite_region=false, const bool colorize=false)
void replicate_triangulation(const Triangulation< dim, spacedim > &input, const std::vector< unsigned int > &extents, Triangulation< dim, spacedim > &result)
Replicate a given triangulation in multiple coordinate axes.
void parallelogram(Triangulation< dim > &tria, const Point< dim >(&corners)[dim], const bool colorize=false)
void general_cell(Triangulation< dim, spacedim > &tria, const std::vector< Point< spacedim > > &vertices, const bool colorize=false)
void subdivided_hyper_cube(Triangulation< dim, spacedim > &tria, const unsigned int repetitions, const double left=0., const double right=1., const bool colorize=false)
void hyper_shell(Triangulation< dim, spacedim > &tria, const Point< spacedim > ¢er, const double inner_radius, const double outer_radius, const unsigned int n_cells=0, bool colorize=false)
void hyper_L(Triangulation< dim > &tria, const double left=-1., const double right=1., const bool colorize=false)
void subdivided_hyper_cube_with_simplices(Triangulation< dim, spacedim > &tria, const unsigned int repetitions, const double left=0.0, const double right=1.0, const bool colorize=false)
void hyper_cube_slit(Triangulation< dim > &tria, const double left=0., const double right=1., const bool colorize=false)
void hyper_cube_with_spherical_hole(Triangulation< dim > &tria, const double inner_radius=0.25, const double outer_radius=0.5, const bool colorize=false)
void eccentric_hyper_shell(Triangulation< dim > &triangulation, const Point< dim > &inner_center, const Point< dim > &outer_center, const double inner_radius, const double outer_radius, const unsigned int n_cells)
void hyper_rectangle(Triangulation< dim, spacedim > &tria, const Point< dim > &p1, const Point< dim > &p2, const bool colorize=false)
void uniform_channel_with_cylinder(Triangulation< dim > &tria, const std::vector< unsigned int > &lengths_and_heights, const double depth=1, const unsigned int depth_division=1, const double shell_region_radius=0.75, const unsigned int n_shells=2, const double skewness=2.0, const bool use_transfinite_region=false, const bool colorize=false)
void cylinder(Triangulation< dim > &tria, const double radius=1., const double half_length=1.)
void moebius(Triangulation< 3, 3 > &tria, const unsigned int n_cells, const unsigned int n_rotations, const double R, const double r)
void extrude_triangulation(const Triangulation< 2, 2 > &input, const unsigned int n_slices, const double height, Triangulation< 3, 3 > &result, const bool copy_manifold_ids=false, const std::vector< types::manifold_id > &manifold_priorities={})
void half_hyper_shell(Triangulation< dim > &tria, const Point< dim > ¢er, const double inner_radius, const double outer_radius, const unsigned int n_cells=0, const bool colorize=false)
void quarter_hyper_ball(Triangulation< dim > &tria, const Point< dim > ¢er=Point< dim >(), const double radius=1.)
void cheese(Triangulation< dim, spacedim > &tria, const std::vector< unsigned int > &holes)
Rectangular domain with rectangular pattern of holes.
void create_union_triangulation(const Triangulation< dim, spacedim > &triangulation_1, const Triangulation< dim, spacedim > &triangulation_2, Triangulation< dim, spacedim > &result)
void hyper_ball(Triangulation< dim, spacedim > &tria, const Point< spacedim > ¢er={}, const double radius=1., const bool attach_spherical_manifold_on_boundary_cells=false)
void subdivided_hyper_rectangle_with_simplices(Triangulation< dim, spacedim > &tria, const std::vector< unsigned int > &repetitions, const Point< dim > &p1, const Point< dim > &p2, const bool colorize=false)
void non_standard_orientation_mesh(Triangulation< 2 > &tria, const unsigned int n_rotate_middle_square)
return_type extract_boundary_mesh(const MeshType< dim, spacedim > &volume_mesh, MeshType< dim - 1, spacedim > &surface_mesh, const std::set< types::boundary_id > &boundary_ids=std::set< types::boundary_id >())
void alfeld_split_of_simplex_mesh(const Triangulation< dim, spacedim > &in_tria, Triangulation< dim, spacedim > &out_tria)
void subdivided_parallelepiped(Triangulation< dim > &tria, const unsigned int n_subdivisions, const Point< dim >(&corners)[dim], const bool colorize=false)
void subdivided_cylinder(Triangulation< dim > &tria, const unsigned int x_subdivisions, const double radius=1., const double half_length=1.)
void convert_hypercube_to_simplex_mesh(const Triangulation< dim, spacedim > &in_tria, Triangulation< dim, spacedim > &out_tria, const unsigned int n_divisions=(dim==2 ? 8u :24u))
void channel_with_cylinder(Triangulation< dim > &tria, const double shell_region_width=0.03, const unsigned int n_shells=2, const double skewness=2.0, const bool colorize=false)
void subdivided_hyper_L(Triangulation< dim, spacedim > &tria, const std::vector< unsigned int > &repetitions, const Point< dim > &bottom_left, const Point< dim > &top_right, const std::vector< int > &n_cells_to_remove)
void convert_simplex_to_hypercube_mesh(const Triangulation< dim, spacedim > &in_tria, Triangulation< dim, spacedim > &out_tria)
void hyper_sphere(Triangulation< spacedim - 1, spacedim > &tria, const Point< spacedim > ¢er=Point< spacedim >(), const double radius=1.)
void concentric_hyper_shells(Triangulation< dim > &triangulation, const Point< dim > ¢er, const double inner_radius=0.125, const double outer_radius=0.25, const unsigned int n_shells=1, const double skewness=0.1, const unsigned int n_cells_per_shell=0, const bool colorize=false)
void reference_cell(Triangulation< dim, spacedim > &tria, const ReferenceCell< dim > &reference_cell)
void subdivided_hyper_rectangle(Triangulation< dim, spacedim > &tria, const std::vector< unsigned int > &repetitions, const Point< dim > &p1, const Point< dim > &p2, const bool colorize=false)
void quarter_hyper_shell(Triangulation< dim > &tria, const Point< dim > ¢er, const double inner_radius, const double outer_radius, const unsigned int n_cells=0, const bool colorize=false)
void hyper_cube(Triangulation< dim, spacedim > &tria, const double left=0., const double right=1., const bool colorize=false)
void create_triangulation_with_removed_cells(const Triangulation< dim, spacedim > &input_triangulation, const std::set< typename Triangulation< dim, spacedim >::active_cell_iterator > &cells_to_remove, Triangulation< dim, spacedim > &result)
void simplex(Triangulation< dim, dim > &tria, const std::vector< Point< dim > > &vertices)
void truncated_cone(Triangulation< dim > &tria, const double radius_0=1.0, const double radius_1=0.5, const double half_length=1.0)
void merge_triangulations(const Triangulation< dim, spacedim > &triangulation_1, const Triangulation< dim, spacedim > &triangulation_2, Triangulation< dim, spacedim > &result, const double duplicated_vertex_tolerance=1.0e-12, const bool copy_manifold_ids=false, const bool copy_boundary_ids=false)
void half_hyper_ball(Triangulation< dim > &tria, const Point< dim > ¢er=Point< dim >(), const double radius=1.)
void cylinder_shell(Triangulation< dim > &tria, const double length, const double inner_radius, const double outer_radius, const unsigned int n_radial_cells=0, const unsigned int n_axial_cells=0, const bool colorize=false)
void flatten_triangulation(const Triangulation< dim, spacedim1 > &in_tria, Triangulation< dim, spacedim2 > &out_tria)
double norm(const FEValuesBase< dim > &fe, const ArrayView< const std::vector< Tensor< 1, dim > > > &Du)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
SymmetricTensor< 2, dim, Number > C(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
SymmetricTensor< 2, dim, Number > epsilon(const Tensor< 2, dim, Number > &Grad_u)
Tensor< 2, dim, Number > F(const Tensor< 2, dim, Number > &Grad_u)
constexpr const ReferenceCell< dim > & get_simplex()
constexpr const ReferenceCell< dim > & get_hypercube()
constexpr T fixed_power(const T t)
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
long double gamma(const unsigned int n)
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
void copy(const T *begin, const T *end, U *dest)
constexpr unsigned int invalid_unsigned_int
constexpr types::boundary_id internal_face_boundary_id
constexpr types::boundary_id invalid_boundary_id
constexpr types::manifold_id flat_manifold_id
constexpr types::material_id invalid_material_id
::VectorizedArray< Number, width > tan(const ::VectorizedArray< Number, width > &)
inline ::VectorizedArray< Number, width > tanh(const ::VectorizedArray< Number, width > &x)
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > cos(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sin(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
inline ::VectorizedArray< Number, width > atan(const ::VectorizedArray< Number, width > &x)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
typename internal::ndarray::HelperArray< T, Ns... >::type ndarray
types::manifold_id manifold_id
std_cxx26::inplace_vector< unsigned int, ReferenceCells::max_n_vertices< structdim >()> vertices
types::material_id material_id
types::boundary_id boundary_id
static unsigned int face_to_cell_vertices(const unsigned int face, const unsigned int vertex, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
static constexpr unsigned int vertices_per_cell
static constexpr std::array< int, faces_per_cell > unit_normal_orientation
static constexpr ndarray< unsigned int, vertices_per_cell, dim > vertex_to_face
static constexpr unsigned int faces_per_cell
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices()
static constexpr std::array< unsigned int, faces_per_cell > unit_normal_direction
static constexpr std::array< unsigned int, faces_per_cell > opposite_face
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > vertex_indices()
std::vector< CellData< 2 > > boundary_quads
std::vector< CellData< 1 > > boundary_lines
constexpr Number determinant(const SymmetricTensor< 2, dim, Number > &)
constexpr Tensor< 1, dim, typename ProductType< Number1, Number2 >::type > cross_product_3d(const Tensor< 1, dim, Number1 > &src1, const Tensor< 1, dim, Number2 > &src2)