50 : airfoil_type(
"NACA")
52 , joukowski_center(-0.1, 0.14)
58 , incline_factor(0.35)
61 , n_subdivision_x_0(3)
62 , n_subdivision_x_1(2)
63 , n_subdivision_x_2(5)
65 , airfoil_sampling_factor(2)
68 airfoil_length <= height,
70 "Mesh is to small to enclose airfoil! Choose larger field or smaller"
72 Assert(incline_factor < 1.0 && incline_factor >= 0.0,
73 ExcMessage(
"incline_factor has to be in [0,1)!"));
86 "Mesh height measured from airfoil nose to horizontal boundaries");
90 "Length measured from airfoil leading edge to vertical outlet boundary");
94 "Define obliqueness of the vertical mesh around the airfoil");
103 "Type of airfoil geometry, either NACA or Joukowski airfoil",
118 "Joukowski circle center coordinates");
121 "Joukowski airfoil length leading to trailing edge");
129 "Number of global refinements");
131 "NumberSubdivisionX0",
133 "Number of subdivisions along the airfoil in blocks with material ID 1 and 4");
135 "NumberSubdivisionX1",
137 "Number of subdivisions along the airfoil in blocks with material ID 2 and 5");
139 "NumberSubdivisionX2",
141 "Number of subdivisions in horizontal direction on the right of the trailing edge, i.e., blocks with material ID 3 and 6");
144 "Number of subdivisions normal to airfoil");
148 "Factor to obtain a finer mesh at the airfoil surface");
163 static const unsigned int id_block_1 = 1;
164 static const unsigned int id_block_2 = 2;
165 static const unsigned int id_block_3 = 3;
166 static const unsigned int id_block_4 = 4;
167 static const unsigned int id_block_5 = 5;
168 static const unsigned int id_block_6 = 6;
173 MeshGenerator(
const AdditionalData &
data)
174 : refinements(
data.refinements)
175 , n_subdivision_x_0(
data.n_subdivision_x_0)
176 , n_subdivision_x_1(
data.n_subdivision_x_1)
177 , n_subdivision_x_2(
data.n_subdivision_x_2)
178 , n_subdivision_y(
data.n_subdivision_y)
179 , height(
data.height)
180 , length_b2(
data.length_b2)
181 , incline_factor(
data.incline_factor)
182 , bias_factor(
data.bias_factor)
184 , n_cells_x_0(
Utilities::
pow(2, refinements) * n_subdivision_x_0)
185 , n_cells_x_1(
Utilities::
pow(2, refinements) * n_subdivision_x_1)
186 , n_cells_x_2(
Utilities::
pow(2, refinements) * n_subdivision_x_2)
187 , n_cells_y(
Utilities::
pow(2, refinements) * n_subdivision_y)
188 , n_points_on_each_side(n_cells_x_0 + n_cells_x_1 + 1)
190 , airfoil_1D(set_airfoil_length(
192 data.airfoil_type ==
"Joukowski" ?
193 joukowski(
data.joukowski_center,
194 n_points_on_each_side,
195 data.airfoil_sampling_factor) :
196 (
data.airfoil_type ==
"NACA" ?
198 n_points_on_each_side,
199 data.airfoil_sampling_factor) :
202 std::vector<Point<2>>{
206 data.airfoil_length))
207 , end_b0_x_u(airfoil_1D[0][n_cells_x_0][0])
208 , end_b0_x_l(airfoil_1D[1][n_cells_x_0][0])
209 , nose_x(airfoil_1D[0].front()[0])
210 , tail_x(airfoil_1D[0].back()[0])
211 , tail_y(airfoil_1D[0].back()[1])
212 , center_mesh(0.5 *
std::abs(end_b0_x_u + end_b0_x_l))
213 , length_b1_x(tail_x - center_mesh)
215 (edge_length +
std::abs(nose_x - center_mesh))))
219 , A(nose_x - edge_length, 0)
222 , D(center_mesh, height)
224 ,
F(center_mesh, -height)
228 , J(tail_x + length_b2, 0)
233 data.airfoil_type ==
"NACA",
246 make_coarse_grid(tria_grid);
248 set_boundary_ids(tria_grid);
250 if (periodic_faces !=
nullptr)
253 tria_grid, 5, 4, 1, *periodic_faces);
271 (void)periodic_faces;
278 const unsigned int refinements;
281 const unsigned int n_subdivision_x_0;
284 const unsigned int n_subdivision_x_1;
287 const unsigned int n_subdivision_x_2;
291 const unsigned int n_subdivision_y;
298 const double length_b2;
302 const double incline_factor;
305 const double bias_factor;
308 const double edge_length;
311 const unsigned int n_cells_x_0;
314 const unsigned int n_cells_x_1;
317 const unsigned int n_cells_x_2;
321 const unsigned int n_cells_y;
324 const unsigned int n_points_on_each_side;
328 const std::array<std::vector<Point<2>>, 2> airfoil_1D;
332 const double end_b0_x_u;
336 const double end_b0_x_l;
350 const double center_mesh;
353 const double length_b1_x;
380 const Point<2> A, B,
C, D,
E,
F, G, H, I, J,
K, L;
419 static std::array<std::vector<Point<2>>, 2>
420 joukowski(
const Point<2> ¢erpoint,
421 const unsigned int number_points,
422 const unsigned int factor)
424 std::array<std::vector<Point<2>>, 2> airfoil_1D;
425 const unsigned int total_points = 2 * number_points - 2;
426 const unsigned int n_airfoilpoints = factor * total_points;
428 const auto jouk_points =
429 joukowski_transform(joukowski_circle(centerpoint, n_airfoilpoints));
432 std::vector<Point<2>> upper_points;
433 std::vector<Point<2>> lower_points;
437 unsigned int nose_index = 0;
438 unsigned int tail_index = 0;
439 double nose_x_coordinate = 0;
440 double tail_x_coordinate = 0;
444 for (
unsigned int i = 0; i < jouk_points.size(); ++i)
446 if (jouk_points[i][0] < nose_x_coordinate)
448 nose_x_coordinate = jouk_points[i][0];
451 if (jouk_points[i][0] > tail_x_coordinate)
453 tail_x_coordinate = jouk_points[i][0];
459 for (
unsigned int i = tail_index; i < jouk_points.size(); ++i)
460 upper_points.emplace_back(jouk_points[i]);
461 for (
unsigned int i = 0; i <= nose_index; ++i)
462 upper_points.emplace_back(jouk_points[i]);
463 std::reverse(upper_points.begin(), upper_points.end());
466 lower_points.insert(lower_points.end(),
467 jouk_points.begin() + nose_index,
468 jouk_points.begin() + tail_index + 1);
471 airfoil_1D[0] = make_points_equidistant(upper_points, number_points);
472 airfoil_1D[1] = make_points_equidistant(lower_points, number_points);
475 auto move_nose_to_origin = [](std::vector<Point<2>> &vector) {
476 const double nose_x_pos = vector.front()[0];
477 for (
auto &i : vector)
481 move_nose_to_origin(airfoil_1D[1]);
482 move_nose_to_origin(airfoil_1D[0]);
511 static std::vector<Point<2>>
512 joukowski_circle(
const Point<2> ¢er,
513 const unsigned int number_points)
515 std::vector<Point<2>> circle_points;
522 const double radius =
std::sqrt(center[1] * center[1] +
523 (1 - center[0]) * (1 - center[0]));
525 center[1] * center[1] + (1 + center[0]) * (1 + center[0]));
529 radius_test < radius,
531 "Error creating lower circle: Circle for Joukowski-transform does"
532 " not enclose point zeta = -1! Choose different center "
536 const double theta = 2 *
numbers::PI / number_points;
538 for (
unsigned int i = 0; i < number_points; ++i)
539 circle_points.emplace_back(center[0] - radius *
cos(i * theta),
540 center[1] - radius *
sin(i * theta));
542 return circle_points;
553 static std::vector<Point<2>>
554 joukowski_transform(
const std::vector<
Point<2>> &circle_points)
556 std::vector<Point<2>> joukowski_points(circle_points.size());
559 for (
unsigned int i = 0; i < circle_points.size(); ++i)
561 const double chi = circle_points[i][0];
562 const double eta = circle_points[i][1];
563 const std::complex<double> zeta(chi, eta);
564 const std::complex<double> z = zeta + 1. / zeta;
566 joukowski_points[i] = {real(z), imag(z)};
568 return joukowski_points;
587 static std::array<std::vector<Point<2>>, 2>
588 naca(
const std::string &serialnumber,
589 const unsigned int number_points,
590 const unsigned int factor)
594 const unsigned int n_airfoilpoints = factor * number_points;
597 return {{make_points_equidistant(
598 naca_create_points(serialnumber, n_airfoilpoints,
true),
600 make_points_equidistant(
601 naca_create_points(serialnumber, n_airfoilpoints,
false),
616 static std::vector<Point<2>>
617 naca_create_points(
const std::string &serialnumber,
618 const unsigned int number_points,
621 Assert(serialnumber.size() == 4,
622 ExcMessage(
"This NACA-serial number is not implemented!"));
624 return naca_create_points_4_digits(serialnumber,
643 static std::vector<Point<2>>
644 naca_create_points_4_digits(
const std::string &serialnumber,
645 const unsigned int number_points,
649 const unsigned int digit_0 = (serialnumber[0] -
'0');
650 const unsigned int digit_1 = (serialnumber[1] -
'0');
651 const unsigned int digit_2 = (serialnumber[2] -
'0');
652 const unsigned int digit_3 = (serialnumber[3] -
'0');
654 const unsigned int digit_23 = 10 * digit_2 + digit_3;
657 const double t =
static_cast<double>(digit_23) / 100.0;
659 std::vector<Point<2>> naca_points;
661 if (digit_0 == 0 && digit_1 == 0)
662 for (
unsigned int i = 0; i < number_points; ++i)
664 const double x = i * 1 / (1.0 * number_points - 1);
668 0.3516 * Utilities::fixed_power<2>(x) +
669 0.2843 * Utilities::fixed_power<3>(x) -
670 0.1036 * Utilities::fixed_power<4>(
674 naca_points.emplace_back(x, +y_t);
676 naca_points.emplace_back(x, -y_t);
679 for (
unsigned int i = 0; i < number_points; ++i)
681 const double m = 1.0 * digit_0 / 100;
682 const double p = 1.0 * digit_1 / 10;
683 const double x = i * 1 / (1.0 * number_points - 1);
687 m / Utilities::fixed_power<2>(p) *
688 (2 * p * x - Utilities::fixed_power<2>(x)) :
693 (x <= p) ? 2 * m / Utilities::fixed_power<2>(p) * (p - x) :
699 0.3516 * Utilities::fixed_power<2>(x) +
700 0.2843 * Utilities::fixed_power<3>(x) -
701 0.1036 * Utilities::fixed_power<4>(
707 naca_points.emplace_back(x - y_t *
std::sin(theta),
710 naca_points.emplace_back(x + y_t *
std::sin(theta),
727 static std::array<std::vector<Point<2>>, 2>
728 set_airfoil_length(
const std::array<std::vector<
Point<2>>, 2> &input,
729 const double desired_len)
731 std::array<std::vector<Point<2>>, 2> output;
732 output[0] = set_airfoil_length(input[0], desired_len);
733 output[1] = set_airfoil_length(input[1], desired_len);
745 static std::vector<Point<2>>
746 set_airfoil_length(
const std::vector<
Point<2>> &input,
747 const double desired_len)
749 std::vector<Point<2>> output = input;
752 desired_len / input.front().distance(input.back());
754 for (
auto &x : output)
770 static std::vector<Point<2>>
771 make_points_equidistant(
772 const std::vector<
Point<2>> &non_equidistant_points,
773 const unsigned int number_points)
775 const unsigned int n_points =
776 non_equidistant_points
780 std::vector<double> arclength_L(non_equidistant_points.size(), 0);
781 for (
unsigned int i = 0; i < non_equidistant_points.size() - 1; ++i)
784 non_equidistant_points[i + 1].distance(non_equidistant_points[i]);
787 const auto airfoil_length =
789 const auto deltaX = airfoil_length / (number_points - 1);
793 std::vector<Point<2>> equidist(
796 equidist[0] = non_equidistant_points[0];
797 equidist[number_points - 1] = non_equidistant_points[n_points - 1];
801 for (
unsigned int j = 0, i = 1; j < n_points - 1; ++j)
804 const auto Lj = arclength_L[j];
805 const auto Ljp = arclength_L[j + 1];
807 while (Lj <= i * deltaX && i * deltaX <= Ljp &&
808 i < number_points - 1)
810 equidist[i] =
Point<2>((i * deltaX - Lj) / (Ljp - Lj) *
811 (non_equidistant_points[j + 1] -
812 non_equidistant_points[j]) +
813 non_equidistant_points[j]);
833 std::vector<Triangulation<2>> trias(10);
837 const std::vector<Point<2>> &corner_vertices,
838 const std::vector<unsigned int> &repetitions,
850 auto &
point = it->vertex();
851 const double xi =
point[0];
852 const double eta =
point[1];
855 point = 0.25 * ((1 - xi) * (1 - eta) * corner_vertices[0] +
856 (1 + xi) * (1 - eta) * corner_vertices[1] +
857 (1 - xi) * (1 + eta) * corner_vertices[2] +
858 (1 + xi) * (1 + eta) * corner_vertices[3]);
862 for (
auto cell : tria.active_cell_iterators())
870 {n_subdivision_y, n_subdivision_x_0},
874 {n_subdivision_y, n_subdivision_x_0},
878 {n_subdivision_x_1, n_subdivision_y},
882 {n_subdivision_x_1, n_subdivision_y},
886 {n_subdivision_x_2, n_subdivision_y},
890 {n_subdivision_x_2, n_subdivision_y},
917 for (
auto cell : tria.active_cell_iterators())
920 if (cell->face(f)->at_boundary() ==
false)
923 const auto mid = cell->material_id();
925 if ((mid == id_block_1 && f == 0) ||
926 (mid == id_block_4 && f == 0))
927 cell->face(f)->set_boundary_id(0);
928 else if ((mid == id_block_3 && f == 0) ||
929 (mid == id_block_6 && f == 2))
930 cell->face(f)->set_boundary_id(1);
931 else if ((mid == id_block_1 && f == 1) ||
932 (mid == id_block_2 && f == 1))
933 cell->face(f)->set_boundary_id(2);
934 else if ((mid == id_block_4 && f == 1) ||
935 (mid == id_block_5 && f == 3))
936 cell->face(f)->set_boundary_id(3);
937 else if ((mid == id_block_2 && f == 0) ||
938 (mid == id_block_3 && f == 2))
939 cell->face(f)->set_boundary_id(4);
940 else if ((mid == id_block_5 && f == 2) ||
941 (mid == id_block_6 && f == 0))
942 cell->face(f)->set_boundary_id(5);
962 std::vector<bool> vertex_processed(tria.
n_vertices(),
false);
979 for (
const auto &cell : tria.cell_iterators())
983 if (vertex_processed[cell->vertex_index(v)])
987 vertex_processed[cell->vertex_index(v)] =
true;
989 auto &node = cell->vertex(v);
992 if (cell->material_id() == id_block_1 ||
993 cell->material_id() == id_block_4)
1002 if (cell->material_id() == id_block_1)
1005 (node - horizontal_offset) +
1011 else if (cell->material_id() == id_block_4)
1014 (node - horizontal_offset) -
1020 const double trapeze_height =
1022 const double L = height /
std::sin(gamma);
1023 const double l_a =
std::cos(gamma) * edge_length;
1024 const double l_b = trapeze_height *
std::tan(gamma);
1026 const double x2 = L - l_a - l_b;
1028 const double Dx = x1 + x2 + x3;
1029 const double deltax =
1031 const double dx = Dx / n_cells_x_0;
1032 const double dy = trapeze_height / n_cells_y;
1034 static_cast<int>(std::round((node_[0] - deltax) / dx));
1036 static_cast<int>(std::round(
std::abs(node_[1]) / dy));
1038 node_[0] =
numbers::PI / 2 * (1.0 * ix) / n_cells_x_0;
1039 node_[1] = height * (1.0 * iy) / n_cells_y;
1046 const double dy = height / n_cells_y;
1048 static_cast<int>(std::round(node_[0] / dx));
1050 static_cast<int>(std::round(node_[1] / dy));
1051 const double alpha =
1052 bias_alpha(1 - (1.0 * iy) / n_cells_y);
1053 const double theta = node_[0];
1055 ((cell->material_id() == id_block_1) ?
1060 (cell->material_id() == id_block_1) ? (0) : (1))]
1066 else if (cell->material_id() == id_block_2 ||
1067 cell->material_id() == id_block_5)
1075 "Points D,C,G and E,F,I are not defined symmetric to "
1076 "x-axis, which is required to interpolate block 2"
1077 " and 5 with same geometric computations."));
1078 const double l_y = D[1] -
C[1];
1079 const double l_h = D[1] - l_y;
1080 const double by = -l_h / length_b1_x * (node[0] - H[0]);
1081 const double dy = (height - by) / n_cells_y;
1082 const int iy =
static_cast<int>(
1083 std::round((
std::abs(node[1]) - by) / dy));
1084 const double dx = length_b1_x / n_cells_x_1;
1085 const int ix =
static_cast<int>(
1086 std::round(
std::abs(node[0] - center_mesh) / dx));
1088 const double alpha = bias_alpha(1 - (1.0 * iy) / n_cells_y);
1092 const Point<2> p(ix * dx + center_mesh +
1093 incline_factor * length_b2 * ix /
1095 ((cell->material_id() == id_block_2) ?
1101 (cell->material_id() == id_block_2) ? (0) : (1))]
1102 [n_cells_x_0 + ix] *
1106 else if (cell->material_id() == id_block_3 ||
1107 cell->material_id() == id_block_6)
1110 const double dx = length_b2 / n_cells_x_2;
1111 const double dy = height / n_cells_y;
1112 const int ix =
static_cast<int>(
1113 std::round(
std::abs(node[0] - H[0]) / dx));
1115 static_cast<int>(std::round(
std::abs(node[1]) / dy));
1117 const double alpha_y = bias_alpha(1 - 1.0 * iy / n_cells_y);
1118 const double alpha_x =
1119 bias_alpha(1 - (
static_cast<double>(ix)) / n_cells_x_2);
1123 const Point<2> p1(J[0] - (1 - incline_factor) * length_b2 *
1125 ((cell->material_id() == id_block_3) ?
1130 const Point<2> p2(J[0] - alpha_x * length_b2, tail_y);
1131 node = p1 * (1 - alpha_y) + p2 * alpha_y;
1151 bias_alpha(
double alpha)
const
1161 internal_create_triangulation(
1165 const AdditionalData &additional_data)
1167 MeshGenerator mesh_generator(additional_data);
1170 if (
auto *parallel_tria =
1173 mesh_generator.create_triangulation(*parallel_tria, periodic_faces);
1174 else if (
auto *parallel_tria =
dynamic_cast<
1177 mesh_generator.create_triangulation(*parallel_tria, periodic_faces);
1179 mesh_generator.create_triangulation(tria, periodic_faces);
1196 const AdditionalData &)
1206 const AdditionalData &additional_data)
1208 internal_create_triangulation(tria,
nullptr, additional_data);
1219 const AdditionalData &additional_data)
1221 internal_create_triangulation(tria, &periodic_faces, additional_data);
1232 const AdditionalData &additional_data)
1236 (void)additional_data;
1237 (void)periodic_faces;
1248 template <
int dim,
int spacedim>
1260 cell->face(f)->set_boundary_id(f);
1266 template <
int spacedim>
1277 if (cell->center()[0] > 0)
1278 cell->set_material_id(1);
1285 template <
int dim,
int spacedim>
1290 const double epsilon)
1303 for (; face != endface; ++face)
1304 if (face->at_boundary())
1305 if (face->boundary_id() == 0)
1309 if (
std::abs(center[0] - p1[0]) < epsilon)
1310 face->set_boundary_id(0);
1311 else if (
std::abs(center[0] - p2[0]) < epsilon)
1312 face->set_boundary_id(1);
1313 else if (dim > 1 &&
std::abs(center[1] - p1[1]) < epsilon)
1314 face->set_boundary_id(2);
1315 else if (dim > 1 &&
std::abs(center[1] - p2[1]) < epsilon)
1316 face->set_boundary_id(3);
1317 else if (dim > 2 &&
std::abs(center[2] - p1[2]) < epsilon)
1318 face->set_boundary_id(4);
1319 else if (dim > 2 &&
std::abs(center[2] - p2[2]) < epsilon)
1320 face->set_boundary_id(5);
1329 for (
const auto &cell : tria.cell_iterators())
1332 for (
unsigned int d = 0;
d < dim; ++
d)
1333 if (cell->center()[d] > 0)
1335 cell->set_material_id(
id);
1344 template <
int spacdim>
1357 for (
auto cell = tria.
begin(); cell != tria.
end(); ++cell)
1360 cell->face(2)->set_all_boundary_ids(1);
1384 cell->face(4)->set_all_boundary_ids(1);
1388 cell->face(2)->set_all_boundary_ids(1);
1392 cell->face(2)->set_all_boundary_ids(1);
1396 cell->face(0)->set_all_boundary_ids(1);
1400 cell->face(2)->set_all_boundary_ids(1);
1404 cell->face(0)->set_all_boundary_ids(1);
1406 else if (tria.
n_cells() == 12)
1415 cell->face(5)->set_all_boundary_ids(1);
1418 else if (tria.
n_cells() == 96)
1425 unsigned int count = 0;
1426 for (
const auto &cell : tria.cell_iterators())
1427 if (cell->face(5)->at_boundary())
1429 cell->face(5)->set_all_boundary_ids(1);
1449 const double inner_radius,
1450 const double outer_radius)
1455 double middle = (outer_radius - inner_radius) / 2e0 + inner_radius;
1456 double eps = 1
e-3 * middle;
1459 for (; cell != tria.
end(); ++cell)
1460 for (
const unsigned int f :
GeometryInfo<3>::face_indices())
1462 if (!cell->face(f)->at_boundary())
1465 double radius = cell->face(f)->center().norm() - center.
norm();
1466 if (std::fabs(cell->face(f)->center()[0]) <
1469 cell->face(f)->set_boundary_id(2);
1470 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
1472 if (cell->face(f)->line(j)->at_boundary())
1473 if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() -
1474 cell->face(f)->line(j)->vertex(1).norm()) >
1476 cell->face(f)->line(j)->set_boundary_id(2);
1478 else if (std::fabs(cell->face(f)->center()[1]) <
1481 cell->face(f)->set_boundary_id(3);
1482 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
1484 if (cell->face(f)->line(j)->at_boundary())
1485 if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() -
1486 cell->face(f)->line(j)->vertex(1).norm()) >
1488 cell->face(f)->line(j)->set_boundary_id(3);
1490 else if (std::fabs(cell->face(f)->center()[2]) <
1493 cell->face(f)->set_boundary_id(4);
1494 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
1496 if (cell->face(f)->line(j)->at_boundary())
1497 if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() -
1498 cell->face(f)->line(j)->vertex(1).norm()) >
1500 cell->face(f)->line(j)->set_boundary_id(4);
1502 else if (radius < middle)
1504 cell->face(f)->set_boundary_id(0);
1505 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
1507 if (cell->face(f)->line(j)->at_boundary())
1508 if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() -
1509 cell->face(f)->line(j)->vertex(1).norm()) <
1511 cell->face(f)->line(j)->set_boundary_id(0);
1513 else if (radius > middle)
1515 cell->face(f)->set_boundary_id(1);
1516 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
1518 if (cell->face(f)->line(j)->at_boundary())
1519 if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() -
1520 cell->face(f)->line(j)->vertex(1).norm()) <
1522 cell->face(f)->line(j)->set_boundary_id(1);
1532 template <
int dim,
int spacedim>
1543 for (
unsigned int i = 0; i < dim; ++i)
1557 vertices[0] = vertices[1] = p1;
1558 vertices[2] = vertices[3] = p2;
1560 vertices[1][0] = p2[0];
1561 vertices[2][0] = p1[0];
1564 vertices[0] = vertices[1] = vertices[2] = vertices[3] = p1;
1565 vertices[4] = vertices[5] = vertices[6] = vertices[7] = p2;
1567 vertices[1][0] = p2[0];
1568 vertices[2][1] = p2[1];
1569 vertices[3][0] = p2[0];
1570 vertices[3][1] = p2[1];
1572 vertices[4][0] = p1[0];
1573 vertices[4][1] = p1[1];
1574 vertices[5][1] = p1[1];
1575 vertices[6][0] = p1[0];
1583 std::vector<CellData<dim>> cells(1);
1585 cells[0].vertices[i] = i;
1586 cells[0].material_id = 0;
1592 colorize_hyper_rectangle(tria);
1597 template <
int dim,
int spacedim>
1605 ExcMessage(
"Invalid left-to-right bounds of hypercube"));
1608 for (
unsigned int i = 0; i < dim; ++i)
1628 for (
unsigned int d = 0;
d < dim; ++
d)
1629 for (
unsigned int c = 1; c <= dim; ++c)
1630 vector_matrix[c - 1][d] = vertices[c][d] - vertices[0][d];
1632 ExcMessage(
"Vertices of simplex must form a right handed system"));
1636 std::vector<Point<dim>> points = vertices;
1640 for (
unsigned int i = 0; i <= dim; ++i)
1642 points.push_back(0.5 * (points[i] + points[(i + 1) % (dim + 1)]));
1643 center += points[i];
1648 for (
unsigned int i = 1; i < dim; ++i)
1649 points.push_back(0.5 * (points[i - 1] + points[i + 1]));
1651 for (
unsigned int i = 0; i <= dim; ++i)
1652 points.push_back(1. / 3. *
1653 (points[i] + points[(i + 1) % (dim + 1)] +
1654 points[(i + 2) % (dim + 1)]));
1656 points.push_back((1. / (dim + 1)) * center);
1658 std::vector<CellData<dim>> cells(dim + 1);
1663 cells[0].vertices[0] = 0;
1664 cells[0].vertices[1] = 3;
1665 cells[0].vertices[2] = 5;
1666 cells[0].vertices[3] = 6;
1667 cells[0].material_id = 0;
1669 cells[1].vertices[0] = 3;
1670 cells[1].vertices[1] = 1;
1671 cells[1].vertices[2] = 6;
1672 cells[1].vertices[3] = 4;
1673 cells[1].material_id = 0;
1675 cells[2].vertices[0] = 5;
1676 cells[2].vertices[1] = 6;
1677 cells[2].vertices[2] = 2;
1678 cells[2].vertices[3] = 4;
1679 cells[2].material_id = 0;
1683 cells[0].vertices[0] = 0;
1684 cells[0].vertices[1] = 4;
1685 cells[0].vertices[2] = 8;
1686 cells[0].vertices[3] = 10;
1687 cells[0].vertices[4] = 7;
1688 cells[0].vertices[5] = 13;
1689 cells[0].vertices[6] = 12;
1690 cells[0].vertices[7] = 14;
1691 cells[0].material_id = 0;
1693 cells[1].vertices[0] = 4;
1694 cells[1].vertices[1] = 1;
1695 cells[1].vertices[2] = 10;
1696 cells[1].vertices[3] = 5;
1697 cells[1].vertices[4] = 13;
1698 cells[1].vertices[5] = 9;
1699 cells[1].vertices[6] = 14;
1700 cells[1].vertices[7] = 11;
1701 cells[1].material_id = 0;
1703 cells[2].vertices[0] = 8;
1704 cells[2].vertices[1] = 10;
1705 cells[2].vertices[2] = 2;
1706 cells[2].vertices[3] = 5;
1707 cells[2].vertices[4] = 12;
1708 cells[2].vertices[5] = 14;
1709 cells[2].vertices[6] = 6;
1710 cells[2].vertices[7] = 11;
1711 cells[2].material_id = 0;
1713 cells[3].vertices[0] = 7;
1714 cells[3].vertices[1] = 13;
1715 cells[3].vertices[2] = 12;
1716 cells[3].vertices[3] = 14;
1717 cells[3].vertices[4] = 3;
1718 cells[3].vertices[5] = 9;
1719 cells[3].vertices[6] = 6;
1720 cells[3].vertices[7] = 11;
1721 cells[3].material_id = 0;
1731 template <
int dim,
int spacedim>
1738 if (reference_cell == ReferenceCells::get_hypercube<dim>())
1747 std::vector<Point<spacedim>> vertices(
reference_cell.n_vertices());
1751 for (
unsigned int d = 0;
d < dim; ++
d)
1752 vertices[v][d] = this_vertex[d];
1760 std::vector<CellData<dim>> cells(1);
1763 cells[0].vertices[v] = v;
1772 const unsigned int n_cells,
1773 const unsigned int n_rotations,
1777 const unsigned int dim = 3;
1780 "More than 4 cells are needed to create a moebius grid."));
1782 ExcMessage(
"Outer and inner radius must be positive."));
1784 ExcMessage(
"Outer radius must be greater than inner radius."));
1787 std::vector<Point<dim>> vertices(4 * n_cells);
1791 for (
unsigned int i = 0; i <
n_cells; ++i)
1792 for (
unsigned int j = 0; j < 4; ++j)
1794 vertices[4 * i + j][0] =
1798 vertices[4 * i + j][1] =
1802 vertices[4 * i + j][2] =
1806 unsigned int offset = 0;
1811 static constexpr std::array<unsigned int, 8> local_vertex_numbering{
1812 {0, 1, 5, 4, 2, 3, 7, 6}};
1813 std::vector<CellData<dim>> cells(n_cells);
1814 for (
unsigned int i = 0; i <
n_cells; ++i)
1816 for (
unsigned int j = 0; j < 2; ++j)
1818 cells[i].vertices[local_vertex_numbering[0 + 4 * j]] =
1820 cells[i].vertices[local_vertex_numbering[1 + 4 * j]] =
1822 cells[i].vertices[local_vertex_numbering[2 + 4 * j]] =
1824 cells[i].vertices[local_vertex_numbering[3 + 4 * j]] =
1828 cells[i].material_id = 0;
1832 cells[
n_cells - 1].vertices[local_vertex_numbering[4]] =
1833 (0 + n_rotations) % 4;
1834 cells[
n_cells - 1].vertices[local_vertex_numbering[5]] =
1835 (3 + n_rotations) % 4;
1836 cells[
n_cells - 1].vertices[local_vertex_numbering[6]] =
1837 (2 + n_rotations) % 4;
1838 cells[
n_cells - 1].vertices[local_vertex_numbering[7]] =
1839 (1 + n_rotations) % 4;
1850 const double centerline_radius,
1851 const double inner_radius,
1855 Assert(centerline_radius > inner_radius,
1856 ExcMessage(
"The centerline radius must be greater than the "
1858 Assert(inner_radius > 0.0,
1859 ExcMessage(
"The inner radius must be positive."));
1861 const unsigned int dim = 2;
1862 const unsigned int spacedim = 3;
1863 std::vector<Point<spacedim>> vertices(16);
1865 vertices[0] =
Point<spacedim>(centerline_radius - inner_radius, 0, 0);
1867 vertices[2] =
Point<spacedim>(centerline_radius + inner_radius, 0, 0);
1869 vertices[4] =
Point<spacedim>(0, 0, centerline_radius - inner_radius);
1871 vertices[6] =
Point<spacedim>(0, 0, centerline_radius + inner_radius);
1873 vertices[8] =
Point<spacedim>(-(centerline_radius - inner_radius), 0, 0);
1875 vertices[10] =
Point<spacedim>(-(centerline_radius + inner_radius), 0, 0);
1877 vertices[12] =
Point<spacedim>(0, 0, -(centerline_radius - inner_radius));
1879 vertices[14] =
Point<spacedim>(0, 0, -(centerline_radius + inner_radius));
1882 std::vector<CellData<dim>> cells(16);
1884 cells[0].vertices[0] = 0;
1885 cells[0].vertices[1] = 4;
1886 cells[0].vertices[2] = 3;
1887 cells[0].vertices[3] = 7;
1888 cells[0].material_id = 0;
1890 cells[1].vertices[0] = 1;
1891 cells[1].vertices[1] = 5;
1892 cells[1].vertices[2] = 0;
1893 cells[1].vertices[3] = 4;
1894 cells[1].material_id = 0;
1896 cells[2].vertices[0] = 2;
1897 cells[2].vertices[1] = 6;
1898 cells[2].vertices[2] = 1;
1899 cells[2].vertices[3] = 5;
1900 cells[2].material_id = 0;
1902 cells[3].vertices[0] = 3;
1903 cells[3].vertices[1] = 7;
1904 cells[3].vertices[2] = 2;
1905 cells[3].vertices[3] = 6;
1906 cells[3].material_id = 0;
1908 cells[4].vertices[0] = 4;
1909 cells[4].vertices[1] = 8;
1910 cells[4].vertices[2] = 7;
1911 cells[4].vertices[3] = 11;
1912 cells[4].material_id = 0;
1914 cells[5].vertices[0] = 5;
1915 cells[5].vertices[1] = 9;
1916 cells[5].vertices[2] = 4;
1917 cells[5].vertices[3] = 8;
1918 cells[5].material_id = 0;
1920 cells[6].vertices[0] = 6;
1921 cells[6].vertices[1] = 10;
1922 cells[6].vertices[2] = 5;
1923 cells[6].vertices[3] = 9;
1924 cells[6].material_id = 0;
1926 cells[7].vertices[0] = 7;
1927 cells[7].vertices[1] = 11;
1928 cells[7].vertices[2] = 6;
1929 cells[7].vertices[3] = 10;
1930 cells[7].material_id = 0;
1932 cells[8].vertices[0] = 8;
1933 cells[8].vertices[1] = 12;
1934 cells[8].vertices[2] = 11;
1935 cells[8].vertices[3] = 15;
1936 cells[8].material_id = 0;
1938 cells[9].vertices[0] = 9;
1939 cells[9].vertices[1] = 13;
1940 cells[9].vertices[2] = 8;
1941 cells[9].vertices[3] = 12;
1942 cells[9].material_id = 0;
1944 cells[10].vertices[0] = 10;
1945 cells[10].vertices[1] = 14;
1946 cells[10].vertices[2] = 9;
1947 cells[10].vertices[3] = 13;
1948 cells[10].material_id = 0;
1950 cells[11].vertices[0] = 11;
1951 cells[11].vertices[1] = 15;
1952 cells[11].vertices[2] = 10;
1953 cells[11].vertices[3] = 14;
1954 cells[11].material_id = 0;
1956 cells[12].vertices[0] = 12;
1957 cells[12].vertices[1] = 0;
1958 cells[12].vertices[2] = 15;
1959 cells[12].vertices[3] = 3;
1960 cells[12].material_id = 0;
1962 cells[13].vertices[0] = 13;
1963 cells[13].vertices[1] = 1;
1964 cells[13].vertices[2] = 12;
1965 cells[13].vertices[3] = 0;
1966 cells[13].material_id = 0;
1968 cells[14].vertices[0] = 14;
1969 cells[14].vertices[1] = 2;
1970 cells[14].vertices[2] = 13;
1971 cells[14].vertices[3] = 1;
1972 cells[14].material_id = 0;
1974 cells[15].vertices[0] = 15;
1975 cells[15].vertices[1] = 3;
1976 cells[15].vertices[2] = 14;
1977 cells[15].vertices[3] = 2;
1978 cells[15].material_id = 0;
1991 static constexpr int circle_cell_vertices[5][4] = {{0, 1, 2, 3},
2003 const double centerline_radius,
2004 const double inner_radius,
2005 const unsigned int n_cells_toroidal,
2008 Assert(centerline_radius > inner_radius,
2009 ExcMessage(
"The centerline radius must be greater than the "
2011 Assert(inner_radius > 0.0,
2012 ExcMessage(
"The inner radius must be positive."));
2014 ExcMessage(
"Number of cells in toroidal direction has "
2015 "to be at least 3 for a torus of polar extent 2*pi."));
2021 const double a = 1. / (1 +
std::sqrt(2.0));
2024 const unsigned int additional_layer =
2028 const unsigned int n_point_layers_toroidal =
2029 n_cells_toroidal + additional_layer;
2030 std::vector<Point<3>> vertices(8 * n_point_layers_toroidal);
2042 const double phi_cell = phi / n_cells_toroidal;
2043 for (
unsigned int c = 1; c < n_point_layers_toroidal; ++c)
2045 for (
unsigned int v = 0; v < 8; ++v)
2047 const double inner_radius_2d = vertices[v][0];
2048 vertices[8 * c + v][0] = inner_radius_2d *
std::cos(phi_cell * c);
2049 vertices[8 * c + v][1] = vertices[v][1];
2050 vertices[8 * c + v][2] = inner_radius_2d *
std::sin(phi_cell * c);
2055 std::vector<CellData<3>> cells(5 * n_cells_toroidal);
2056 for (
unsigned int c = 0; c < n_cells_toroidal; ++c)
2058 for (
unsigned int j = 0; j < 2; ++j)
2060 const unsigned int offset =
2061 (8 * (c + j)) % (8 * n_point_layers_toroidal);
2064 for (
unsigned int c2 = 0; c2 < 5; ++c2)
2065 for (
unsigned int i = 0; i < 4; ++i)
2066 cells[5 * c + c2].vertices[i + j * 4] =
2067 offset + circle_cell_vertices[c2][i];
2070 cells[5 * c].material_id = 0;
2072 cells[5 * c + 1].material_id = 0;
2073 cells[5 * c + 2].material_id = 1;
2074 cells[5 * c + 3].material_id = 0;
2075 cells[5 * c + 4].material_id = 0;
2083 for (
const auto &cell : tria.cell_iterators())
2086 for (
const unsigned int f :
GeometryInfo<3>::face_indices())
2090 if (cell->face(f)->at_boundary() && f != 4 && f != 5)
2092 cell->face(f)->set_all_manifold_ids(1);
2097 if (cell->material_id() == 1)
2099 cell->set_all_manifold_ids(2);
2101 cell->set_material_id(0);
2118 template <
int dim,
int spacedim>
2133 cell->vertex(i) = vertices[i];
2139 "The volume of the cell is not greater than zero. "
2140 "This could be due to the wrong ordering of the vertices."));
2171 std::array<Tensor<1, 2>, 2> edges;
2172 edges[0] = corners[0];
2173 edges[1] = corners[1];
2174 std::vector<unsigned int> subdivisions;
2175 subdivided_parallelepiped<2, 2>(
2176 tria, origin, edges, subdivisions,
colorize);
2187 unsigned int n_subdivisions[dim];
2188 for (
unsigned int i = 0; i < dim; ++i)
2189 n_subdivisions[i] = 1;
2198 const unsigned int n_subdivisions,
2204 unsigned int n_subdivisions_[dim];
2205 for (
unsigned int i = 0; i < dim; ++i)
2206 n_subdivisions_[i] = n_subdivisions;
2216 const unsigned int (&n_subdivisions)[dim],
2218 const unsigned int *n_subdivisions,
2224 std::vector<unsigned int> subdivisions;
2225 std::array<Tensor<1, dim>, dim> edges;
2226 for (
unsigned int i = 0; i < dim; ++i)
2228 subdivisions.push_back(n_subdivisions[i]);
2229 edges[i] = corners[i];
2232 subdivided_parallelepiped<dim, dim>(
2233 tria, origin, edges, subdivisions,
colorize);
2239 template <
int dim,
int spacedim>
2244 const std::vector<unsigned int> &subdivisions,
2247 std::vector<unsigned int> compute_subdivisions = subdivisions;
2248 if (compute_subdivisions.empty())
2250 compute_subdivisions.resize(dim, 1);
2253 Assert(compute_subdivisions.size() == dim,
2254 ExcMessage(
"One subdivision must be provided for each dimension."));
2256 for (
unsigned int i = 0; i < dim; ++i)
2258 Assert(compute_subdivisions[i] > 0,
2259 ExcInvalidRepetitions(subdivisions[i]));
2261 edges[i].
norm() > 0,
2263 "Edges in subdivided_parallelepiped() must not be degenerate."));
2271 bool twisted_data =
false;
2276 twisted_data = (edges[0][0] < 0);
2283 const double plane_normal =
2284 edges[0][0] * edges[1][1] - edges[0][1] * edges[1][0];
2285 twisted_data = (plane_normal < 0.0);
2294 (edges[0].
norm() * edges[1].
norm()) -
2297 "Edges in subdivided_parallelepiped() must point in"
2298 " different directions."));
2300 cross_product_3d(edges[0], edges[1]);
2314 twisted_data = (plane_normal * edges[2] < 0.0);
2323 ExcInvalidInputOrientation(
2324 "The triangulation you are trying to create will consist of cells"
2325 " with negative measures. This is usually the result of input data"
2326 " that does not define a right-handed coordinate system. The usual"
2327 " fix for this is to ensure that in 1d the given point is to the"
2328 " right of the origin (or the given edge tensor is positive), in 2d"
2329 " that the two edges (and their cross product) obey the right-hand"
2330 " rule (which may usually be done by switching the order of the"
2331 " points or edge tensors), or in 3d that the edges form a"
2332 " right-handed coordinate system (which may also be accomplished by"
2333 " switching the order of the first two points or edge tensors)."));
2336 for (
unsigned int i = 0; i < dim; ++i)
2337 for (
unsigned int j = i + 1; j < dim; ++j)
2338 Assert((edges[i] != edges[j]),
2340 "Degenerate edges of subdivided_parallelepiped encountered."));
2343 std::vector<Point<spacedim>> points;
2348 for (
unsigned int x = 0; x <= compute_subdivisions[0]; ++x)
2349 points.push_back(origin + edges[0] / compute_subdivisions[0] * x);
2353 for (
unsigned int y = 0; y <= compute_subdivisions[1]; ++y)
2354 for (
unsigned int x = 0; x <= compute_subdivisions[0]; ++x)
2355 points.push_back(origin + edges[0] / compute_subdivisions[0] * x +
2356 edges[1] / compute_subdivisions[1] * y);
2360 for (
unsigned int z = 0; z <= compute_subdivisions[2]; ++z)
2361 for (
unsigned int y = 0; y <= compute_subdivisions[1]; ++y)
2362 for (
unsigned int x = 0; x <= compute_subdivisions[0]; ++x)
2363 points.push_back(origin +
2364 edges[0] / compute_subdivisions[0] * x +
2365 edges[1] / compute_subdivisions[1] * y +
2366 edges[2] / compute_subdivisions[2] * z);
2375 for (
unsigned int i = 0; i < dim; ++i)
2376 n_cells *= compute_subdivisions[i];
2377 std::vector<CellData<dim>> cells(n_cells);
2383 for (
unsigned int x = 0; x < compute_subdivisions[0]; ++x)
2385 cells[x].vertices[0] = x;
2386 cells[x].vertices[1] = x + 1;
2389 cells[x].material_id = 0;
2396 const unsigned int n_dy = compute_subdivisions[1];
2397 const unsigned int n_dx = compute_subdivisions[0];
2399 for (
unsigned int y = 0; y < n_dy; ++y)
2400 for (
unsigned int x = 0; x < n_dx; ++x)
2402 const unsigned int c = y * n_dx + x;
2403 cells[c].vertices[0] = y * (n_dx + 1) + x;
2404 cells[c].vertices[1] = y * (n_dx + 1) + x + 1;
2405 cells[c].vertices[2] = (y + 1) * (n_dx + 1) + x;
2406 cells[c].vertices[3] = (y + 1) * (n_dx + 1) + x + 1;
2409 cells[c].material_id = 0;
2417 const unsigned int n_dz = compute_subdivisions[2];
2418 const unsigned int n_dy = compute_subdivisions[1];
2419 const unsigned int n_dx = compute_subdivisions[0];
2421 for (
unsigned int z = 0; z < n_dz; ++z)
2422 for (
unsigned int y = 0; y < n_dy; ++y)
2423 for (
unsigned int x = 0; x < n_dx; ++x)
2425 const unsigned int c = z * n_dy * n_dx + y * n_dx + x;
2427 cells[c].vertices[0] =
2428 z * (n_dy + 1) * (n_dx + 1) + y * (n_dx + 1) + x;
2429 cells[c].vertices[1] =
2430 z * (n_dy + 1) * (n_dx + 1) + y * (n_dx + 1) + x + 1;
2431 cells[c].vertices[2] =
2432 z * (n_dy + 1) * (n_dx + 1) + (y + 1) * (n_dx + 1) + x;
2433 cells[c].vertices[3] = z * (n_dy + 1) * (n_dx + 1) +
2434 (y + 1) * (n_dx + 1) + x + 1;
2435 cells[c].vertices[4] =
2436 (z + 1) * (n_dy + 1) * (n_dx + 1) + y * (n_dx + 1) + x;
2437 cells[c].vertices[5] = (z + 1) * (n_dy + 1) * (n_dx + 1) +
2438 y * (n_dx + 1) + x + 1;
2439 cells[c].vertices[6] = (z + 1) * (n_dy + 1) * (n_dx + 1) +
2440 (y + 1) * (n_dx + 1) + x;
2441 cells[c].vertices[7] = (z + 1) * (n_dy + 1) * (n_dx + 1) +
2442 (y + 1) * (n_dx + 1) + x + 1;
2445 cells[c].material_id = 0;
2466 for (; cell != endc; ++cell)
2468 for (
const unsigned int face :
GeometryInfo<dim>::face_indices())
2470 if (cell->face(face)->at_boundary())
2471 cell->face(face)->set_boundary_id(face);
2478 template <
int dim,
int spacedim>
2481 const unsigned int repetitions,
2486 Assert(repetitions >= 1, ExcInvalidRepetitions(repetitions));
2488 ExcMessage(
"Invalid left-to-right bounds of hypercube"));
2491 for (
unsigned int i = 0; i < dim; ++i)
2497 std::vector<unsigned int> reps(dim, repetitions);
2503 template <
int dim,
int spacedim>
2506 const std::vector<unsigned int> &repetitions,
2511 Assert(repetitions.size() == dim, ExcInvalidRepetitionsDimension(dim));
2517 for (
unsigned int i = 0; i < dim; ++i)
2524 std::array<Point<spacedim>, dim> delta;
2525 for (
unsigned int i = 0; i < dim; ++i)
2527 Assert(repetitions[i] >= 1, ExcInvalidRepetitions(repetitions[i]));
2529 delta[i][i] = (p2[i] - p1[i]) / repetitions[i];
2533 "The first dim entries of coordinates of p1 and p2 need to be different."));
2537 std::vector<Point<spacedim>> points;
2541 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
2542 points.push_back(p1 + x * delta[0]);
2546 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
2547 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
2548 points.push_back(p1 + x * delta[0] + y * delta[1]);
2552 for (
unsigned int z = 0; z <= repetitions[2]; ++z)
2553 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
2554 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
2555 points.push_back(p1 + x * delta[0] + y * delta[1] +
2564 std::vector<CellData<dim>> cells;
2569 cells.resize(repetitions[0]);
2570 for (
unsigned int x = 0; x < repetitions[0]; ++x)
2572 cells[x].vertices[0] = x;
2573 cells[x].vertices[1] = x + 1;
2574 cells[x].material_id = 0;
2581 cells.resize(repetitions[1] * repetitions[0]);
2582 for (
unsigned int y = 0; y < repetitions[1]; ++y)
2583 for (
unsigned int x = 0; x < repetitions[0]; ++x)
2585 const unsigned int c = x + y * repetitions[0];
2586 cells[c].vertices[0] = y * (repetitions[0] + 1) + x;
2587 cells[c].vertices[1] = y * (repetitions[0] + 1) + x + 1;
2588 cells[c].vertices[2] = (y + 1) * (repetitions[0] + 1) + x;
2589 cells[c].vertices[3] = (y + 1) * (repetitions[0] + 1) + x + 1;
2590 cells[c].material_id = 0;
2597 const unsigned int n_x = (repetitions[0] + 1);
2598 const unsigned int n_xy =
2599 (repetitions[0] + 1) * (repetitions[1] + 1);
2601 cells.resize(repetitions[2] * repetitions[1] * repetitions[0]);
2602 for (
unsigned int z = 0; z < repetitions[2]; ++z)
2603 for (
unsigned int y = 0; y < repetitions[1]; ++y)
2604 for (
unsigned int x = 0; x < repetitions[0]; ++x)
2606 const unsigned int c = x + y * repetitions[0] +
2607 z * repetitions[0] * repetitions[1];
2608 cells[c].vertices[0] = z * n_xy + y * n_x + x;
2609 cells[c].vertices[1] = z * n_xy + y * n_x + x + 1;
2610 cells[c].vertices[2] = z * n_xy + (y + 1) * n_x + x;
2611 cells[c].vertices[3] = z * n_xy + (y + 1) * n_x + x + 1;
2612 cells[c].vertices[4] = (z + 1) * n_xy + y * n_x + x;
2613 cells[c].vertices[5] = (z + 1) * n_xy + y * n_x + x + 1;
2614 cells[c].vertices[6] = (z + 1) * n_xy + (y + 1) * n_x + x;
2615 cells[c].vertices[7] =
2616 (z + 1) * n_xy + (y + 1) * n_x + x + 1;
2617 cells[c].material_id = 0;
2638 double epsilon = std::numeric_limits<double>::max();
2639 for (
unsigned int i = 0; i < dim; ++i)
2640 epsilon =
std::min(epsilon, 0.01 * delta[i][i]);
2643 "The distance between corner points must be positive."));
2647 colorize_subdivided_hyper_rectangle(tria, p1, p2, epsilon);
2656 const std::vector<std::vector<double>> &step_sz,
2661 Assert(step_sz.size() == dim, ExcInvalidRepetitionsDimension(dim));
2671 std::vector<std::vector<double>> step_sizes(step_sz);
2673 for (
unsigned int i = 0; i < dim; ++i)
2677 std::swap(p1[i], p2[i]);
2678 std::reverse(step_sizes[i].
begin(), step_sizes[i].
end());
2683 for (
unsigned int j = 0; j < step_sizes.at(i).
size(); ++j)
2684 x += step_sizes[i][j];
2685 Assert(std::fabs(x - (p2[i] - p1[i])) <= 1e-12 * std::fabs(x),
2687 "The sequence of step sizes in coordinate direction " +
2689 " must be equal to the distance of the two given "
2690 "points in this coordinate direction."));
2697 std::vector<Point<dim>> points;
2703 for (
unsigned int i = 0;; ++i)
2712 if (i == step_sizes[0].
size())
2715 x += step_sizes[0][i];
2723 for (
unsigned int j = 0;; ++j)
2726 for (
unsigned int i = 0;; ++i)
2728 points.push_back(
Point<dim>(p1[0] + x, p1[1] + y));
2729 if (i == step_sizes[0].
size())
2732 x += step_sizes[0][i];
2735 if (j == step_sizes[1].
size())
2738 y += step_sizes[1][j];
2745 for (
unsigned int k = 0;; ++k)
2748 for (
unsigned int j = 0;; ++j)
2751 for (
unsigned int i = 0;; ++i)
2754 Point<dim>(p1[0] + x, p1[1] + y, p1[2] + z));
2755 if (i == step_sizes[0].
size())
2758 x += step_sizes[0][i];
2761 if (j == step_sizes[1].
size())
2764 y += step_sizes[1][j];
2767 if (k == step_sizes[2].
size())
2770 z += step_sizes[2][k];
2781 std::vector<CellData<dim>> cells;
2786 cells.resize(step_sizes[0].
size());
2787 for (
unsigned int x = 0; x < step_sizes[0].size(); ++x)
2789 cells[x].vertices[0] = x;
2790 cells[x].vertices[1] = x + 1;
2791 cells[x].material_id = 0;
2798 cells.resize(step_sizes[1].
size() * step_sizes[0].
size());
2799 for (
unsigned int y = 0; y < step_sizes[1].size(); ++y)
2800 for (
unsigned int x = 0; x < step_sizes[0].size(); ++x)
2802 const unsigned int c = x + y * step_sizes[0].size();
2803 cells[c].vertices[0] = y * (step_sizes[0].size() + 1) + x;
2804 cells[c].vertices[1] = y * (step_sizes[0].size() + 1) + x + 1;
2805 cells[c].vertices[2] =
2806 (y + 1) * (step_sizes[0].
size() + 1) + x;
2807 cells[c].vertices[3] =
2808 (y + 1) * (step_sizes[0].
size() + 1) + x + 1;
2809 cells[c].material_id = 0;
2816 const unsigned int n_x = (step_sizes[0].size() + 1);
2817 const unsigned int n_xy =
2818 (step_sizes[0].size() + 1) * (step_sizes[1].
size() + 1);
2820 cells.resize(step_sizes[2].
size() * step_sizes[1].size() *
2821 step_sizes[0].size());
2822 for (
unsigned int z = 0; z < step_sizes[2].size(); ++z)
2823 for (
unsigned int y = 0; y < step_sizes[1].size(); ++y)
2824 for (
unsigned int x = 0; x < step_sizes[0].size(); ++x)
2826 const unsigned int c =
2827 x + y * step_sizes[0].size() +
2828 z * step_sizes[0].size() * step_sizes[1].size();
2829 cells[c].vertices[0] = z * n_xy + y * n_x + x;
2830 cells[c].vertices[1] = z * n_xy + y * n_x + x + 1;
2831 cells[c].vertices[2] = z * n_xy + (y + 1) * n_x + x;
2832 cells[c].vertices[3] = z * n_xy + (y + 1) * n_x + x + 1;
2833 cells[c].vertices[4] = (z + 1) * n_xy + y * n_x + x;
2834 cells[c].vertices[5] = (z + 1) * n_xy + y * n_x + x + 1;
2835 cells[c].vertices[6] = (z + 1) * n_xy + (y + 1) * n_x + x;
2836 cells[c].vertices[7] =
2837 (z + 1) * n_xy + (y + 1) * n_x + x + 1;
2838 cells[c].material_id = 0;
2860 *std::min_element(step_sizes[0].
begin(), step_sizes[0].
end());
2861 for (
unsigned int i = 1; i < dim; ++i)
2863 *std::min_element(step_sizes[i].
begin(),
2864 step_sizes[i].
end()));
2865 const double epsilon = 0.01 * min_size;
2869 colorize_subdivided_hyper_rectangle(tria, p1, p2, epsilon);
2878 const std::vector<std::vector<double>> &spacing,
2883 Assert(spacing.size() == 1, ExcInvalidRepetitionsDimension(1));
2887 Assert(spacing[0].
size() == n_cells, ExcInvalidRepetitionsDimension(1));
2889 double delta = std::numeric_limits<double>::max();
2890 for (
unsigned int i = 0; i <
n_cells; ++i)
2892 Assert(spacing[0][i] >= 0, ExcInvalidRepetitions(-1));
2893 delta =
std::min(delta, spacing[0][i]);
2897 std::vector<Point<1>> points;
2899 for (
unsigned int x = 0; x <=
n_cells; ++x)
2901 points.emplace_back(ax);
2903 ax += spacing[0][x];
2906 unsigned int n_val_cells = 0;
2907 for (
unsigned int i = 0; i <
n_cells; ++i)
2911 std::vector<CellData<1>> cells(n_val_cells);
2912 unsigned int id = 0;
2913 for (
unsigned int x = 0; x <
n_cells; ++x)
2916 cells[id].vertices[0] = x;
2917 cells[id].vertices[1] = x + 1;
2936 const std::vector<std::vector<double>> &spacing,
2941 Assert(spacing.size() == 2, ExcInvalidRepetitionsDimension(2));
2943 std::vector<unsigned int> repetitions(2);
2944 double delta = std::numeric_limits<double>::max();
2945 for (
unsigned int i = 0; i < 2; ++i)
2947 repetitions[i] = spacing[i].size();
2948 for (
unsigned int j = 0; j < repetitions[i]; ++j)
2950 Assert(spacing[i][j] >= 0, ExcInvalidRepetitions(-1));
2951 delta =
std::min(delta, spacing[i][j]);
2954 ExcInvalidRepetitionsDimension(i));
2958 std::vector<Point<2>> points;
2960 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
2963 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
2965 points.emplace_back(ax, ay);
2966 if (x < repetitions[0])
2967 ax += spacing[0][x];
2969 if (y < repetitions[1])
2970 ay += spacing[1][y];
2974 unsigned int n_val_cells = 0;
2975 for (
unsigned int i = 0; i <
material_id.size(0); ++i)
2976 for (
unsigned int j = 0; j <
material_id.size(1); ++j)
2980 std::vector<CellData<2>> cells(n_val_cells);
2981 unsigned int id = 0;
2982 for (
unsigned int y = 0; y < repetitions[1]; ++y)
2983 for (
unsigned int x = 0; x < repetitions[0]; ++x)
2986 cells[id].vertices[0] = y * (repetitions[0] + 1) + x;
2987 cells[id].vertices[1] = y * (repetitions[0] + 1) + x + 1;
2988 cells[id].vertices[2] = (y + 1) * (repetitions[0] + 1) + x;
2989 cells[id].vertices[3] = (y + 1) * (repetitions[0] + 1) + x + 1;
3003 double eps = 0.01 * delta;
3005 for (; cell != endc; ++cell)
3007 Point<2> cell_center = cell->center();
3008 for (
const unsigned int f :
GeometryInfo<2>::face_indices())
3011 Point<2> face_center = cell->face(f)->center();
3012 for (
unsigned int i = 0; i < 2; ++i)
3014 if (face_center[i] < cell_center[i] - eps)
3015 cell->face(f)->set_boundary_id(i * 2);
3016 if (face_center[i] > cell_center[i] + eps)
3017 cell->face(f)->set_boundary_id(i * 2 + 1);
3028 const std::vector<std::vector<double>> &spacing,
3033 const unsigned int dim = 3;
3035 Assert(spacing.size() == dim, ExcInvalidRepetitionsDimension(dim));
3037 std::array<unsigned int, dim> repetitions;
3038 double delta = std::numeric_limits<double>::max();
3039 for (
unsigned int i = 0; i < dim; ++i)
3041 repetitions[i] = spacing[i].size();
3042 for (
unsigned int j = 0; j < repetitions[i]; ++j)
3044 Assert(spacing[i][j] >= 0, ExcInvalidRepetitions(-1));
3045 delta =
std::min(delta, spacing[i][j]);
3048 ExcInvalidRepetitionsDimension(i));
3052 std::vector<Point<dim>> points;
3054 for (
unsigned int z = 0; z <= repetitions[2]; ++z)
3057 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
3060 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
3062 points.emplace_back(ax, ay, az);
3063 if (x < repetitions[0])
3064 ax += spacing[0][x];
3066 if (y < repetitions[1])
3067 ay += spacing[1][y];
3069 if (z < repetitions[2])
3070 az += spacing[2][z];
3074 unsigned int n_val_cells = 0;
3075 for (
unsigned int i = 0; i <
material_id.size(0); ++i)
3076 for (
unsigned int j = 0; j <
material_id.size(1); ++j)
3077 for (
unsigned int k = 0; k <
material_id.size(2); ++k)
3081 std::vector<CellData<dim>> cells(n_val_cells);
3082 unsigned int id = 0;
3083 const unsigned int n_x = (repetitions[0] + 1);
3084 const unsigned int n_xy = (repetitions[0] + 1) * (repetitions[1] + 1);
3085 for (
unsigned int z = 0; z < repetitions[2]; ++z)
3086 for (
unsigned int y = 0; y < repetitions[1]; ++y)
3087 for (
unsigned int x = 0; x < repetitions[0]; ++x)
3090 cells[id].vertices[0] = z * n_xy + y * n_x + x;
3091 cells[id].vertices[1] = z * n_xy + y * n_x + x + 1;
3092 cells[id].vertices[2] = z * n_xy + (y + 1) * n_x + x;
3093 cells[id].vertices[3] = z * n_xy + (y + 1) * n_x + x + 1;
3094 cells[id].vertices[4] = (z + 1) * n_xy + y * n_x + x;
3095 cells[id].vertices[5] = (z + 1) * n_xy + y * n_x + x + 1;
3096 cells[id].vertices[6] = (z + 1) * n_xy + (y + 1) * n_x + x;
3097 cells[id].vertices[7] = (z + 1) * n_xy + (y + 1) * n_x + x + 1;
3111 double eps = 0.01 * delta;
3114 for (; cell != endc; ++cell)
3120 Point<dim> face_center = cell->face(f)->center();
3121 for (
unsigned int i = 0; i < dim; ++i)
3123 if (face_center[i] < cell_center[i] - eps)
3124 cell->face(f)->set_boundary_id(i * 2);
3125 if (face_center[i] > cell_center[i] + eps)
3126 cell->face(f)->set_boundary_id(i * 2 + 1);
3133 template <
int dim,
int spacedim>
3136 const std::vector<unsigned int> &holes)
3145 for (
unsigned int d = 0;
d < dim; ++
d)
3152 std::array<Point<spacedim>, dim> delta;
3153 std::array<unsigned int, dim> repetitions;
3154 for (
unsigned int i = 0; i < dim; ++i)
3157 ExcMessage(
"At least one hole needed in each direction"));
3158 repetitions[i] = 2 * holes[i] + 1;
3159 delta[i][i] = (p2[i] - p1[i]);
3164 std::vector<Point<spacedim>> points;
3168 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
3169 points.push_back(p1 + x * delta[0]);
3173 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
3174 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
3175 points.push_back(p1 + x * delta[0] + y * delta[1]);
3179 for (
unsigned int z = 0; z <= repetitions[2]; ++z)
3180 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
3181 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
3182 points.push_back(p1 + x * delta[0] + y * delta[1] +
3192 std::vector<CellData<dim>> cells;
3197 cells.resize(repetitions[1] * repetitions[0] - holes[1] * holes[0]);
3199 for (
unsigned int y = 0; y < repetitions[1]; ++y)
3200 for (
unsigned int x = 0; x < repetitions[0]; ++x)
3202 if ((x % 2 == 1) && (y % 2 == 1))
3205 cells[c].vertices[0] = y * (repetitions[0] + 1) + x;
3206 cells[c].vertices[1] = y * (repetitions[0] + 1) + x + 1;
3207 cells[c].vertices[2] = (y + 1) * (repetitions[0] + 1) + x;
3208 cells[c].vertices[3] = (y + 1) * (repetitions[0] + 1) + x + 1;
3209 cells[c].material_id = 0;
3217 const unsigned int n_x = (repetitions[0] + 1);
3218 const unsigned int n_xy =
3219 (repetitions[0] + 1) * (repetitions[1] + 1);
3221 cells.resize(repetitions[2] * repetitions[1] * repetitions[0]);
3224 for (
unsigned int z = 0; z < repetitions[2]; ++z)
3225 for (
unsigned int y = 0; y < repetitions[1]; ++y)
3226 for (
unsigned int x = 0; x < repetitions[0]; ++x)
3229 cells[c].vertices[0] = z * n_xy + y * n_x + x;
3230 cells[c].vertices[1] = z * n_xy + y * n_x + x + 1;
3231 cells[c].vertices[2] = z * n_xy + (y + 1) * n_x + x;
3232 cells[c].vertices[3] = z * n_xy + (y + 1) * n_x + x + 1;
3233 cells[c].vertices[4] = (z + 1) * n_xy + y * n_x + x;
3234 cells[c].vertices[5] = (z + 1) * n_xy + y * n_x + x + 1;
3235 cells[c].vertices[6] = (z + 1) * n_xy + (y + 1) * n_x + x;
3236 cells[c].vertices[7] =
3237 (z + 1) * n_xy + (y + 1) * n_x + x + 1;
3238 cells[c].material_id = 0;
3266 const unsigned int ,
3278 const unsigned int ,
3290 bool inline point_in_2d_box(
const Point<2> &p,
3292 const double radius)
3294 return (
std::abs(p[0] - c[0]) < radius) &&
3303 template <
int dim,
int spacedim>
3307 double length = std::numeric_limits<double>::max();
3308 for (
const auto &cell :
triangulation.active_cell_iterators())
3309 for (unsigned
int n = 0; n < GeometryInfo<dim>::lines_per_cell; ++n)
3310 length =
std::min(length, cell->line(n)->diameter());
3320 const double inner_radius,
3321 const double outer_radius,
3322 const double pad_bottom,
3323 const double pad_top,
3324 const double pad_left,
3325 const double pad_right,
3330 const unsigned int ,
3333 const bool with_padding =
3334 pad_bottom > 0 || pad_top > 0 || pad_left > 0 || pad_right > 0;
3344 double length = std::numeric_limits<double>::max();
3345 for (
const auto &cell : tria.active_cell_iterators())
3346 for (unsigned
int n = 0; n < cell->n_lines(); ++n)
3347 length =
std::min(length, cell->line(n)->diameter());
3353 Triangulation<2> &cylinder_tria = with_padding ? cylinder_tria_maybe : tria;
3362 for (
const auto &cell : cylinder_tria.active_cell_iterators())
3363 cell->set_manifold_id(tfi_manifold_id);
3365 const Point<2> bl(-outer_radius - pad_left, -outer_radius - pad_bottom);
3366 const Point<2> tr(outer_radius + pad_right, outer_radius + pad_top);
3372 auto add_sizes = [](std::vector<double> &step_sizes,
3373 const double padding,
3374 const double h) ->
void {
3377 const auto rounded =
3378 static_cast<unsigned int>(std::round(padding / h));
3381 const unsigned int num = (padding > 0. && rounded == 0) ? 1 : rounded;
3382 for (
unsigned int i = 0; i < num; ++i)
3383 step_sizes.push_back(padding / num);
3386 std::vector<std::vector<double>> step_sizes(2);
3389 add_sizes(step_sizes[0], pad_left, outer_radius);
3391 step_sizes[0].push_back(outer_radius);
3392 step_sizes[0].push_back(outer_radius);
3394 add_sizes(step_sizes[0], pad_right, outer_radius);
3397 add_sizes(step_sizes[1], pad_bottom, outer_radius);
3399 step_sizes[1].push_back(outer_radius);
3400 step_sizes[1].push_back(outer_radius);
3402 add_sizes(step_sizes[1], pad_top, outer_radius);
3407 bulk_tria, step_sizes, bl, tr,
colorize);
3410 std::set<Triangulation<2>::active_cell_iterator> cells_to_remove;
3411 for (
const auto &cell : bulk_tria.active_cell_iterators())
3412 if (
internal::point_in_2d_box(cell->center(), center, outer_radius))
3413 cells_to_remove.
insert(cell);
3417 bulk_tria, cells_to_remove, tria_without_cylinder);
3419 const double tolerance =
3420 std::min(min_line_length(tria_without_cylinder),
3421 min_line_length(cylinder_tria)) /
3425 tria_without_cylinder, cylinder_tria, tria, tolerance,
true);
3429 for (
const auto &cell : tria.active_cell_iterators())
3433 if (cell->manifold_id() == tfi_manifold_id)
3435 for (
const unsigned int face_n : cell->face_indices())
3437 const auto &face = cell->face(face_n);
3438 if (face->at_boundary() &&
3439 internal::point_in_2d_box(face->center(),
3441 outer_radius * (1. - 1e-12)))
3442 face->set_manifold_id(polar_manifold_id);
3444 face->set_manifold_id(tfi_manifold_id);
3455 static constexpr double tol =
3456 std::numeric_limits<double>::epsilon() * 10000;
3458 for (
const auto &cell : tria.active_cell_iterators())
3459 for (const unsigned
int face_n : cell->face_indices())
3461 const auto face = cell->face(face_n);
3462 if (face->at_boundary())
3464 const Point<2> center = face->center();
3467 face->set_boundary_id(0);
3470 face->set_boundary_id(1);
3473 face->set_boundary_id(2);
3476 face->set_boundary_id(3);
3480 Assert(cell->manifold_id() == tfi_manifold_id,
3482 face->set_boundary_id(4);
3503 const double inner_radius,
3504 const double outer_radius,
3505 const double pad_bottom,
3506 const double pad_top,
3507 const double pad_left,
3508 const double pad_right,
3513 const unsigned int n_slices,
3524 Point<2>(new_center[0], new_center[1]),
3547 tria.
set_manifold(polar_manifold_id, cylindrical_manifold);
3556 const double shell_region_width,
3557 const unsigned int n_shells,
3558 const double skewness,
3561 Assert(0.0 <= shell_region_width && shell_region_width < 0.05,
3562 ExcMessage(
"The width of the shell region must be less than 0.05 "
3563 "(and preferably close to 0.03)"));
3597 std::set<Triangulation<2>::active_cell_iterator> cells_to_remove;
3599 for (
const auto &cell : bulk_tria.active_cell_iterators())
3601 if ((cell->center() -
Point<2>(0.2, 0.2)).norm() < 0.15)
3602 cells_to_remove.insert(cell);
3606 for (
const unsigned int vertex_n :
3608 if (cell->vertex(vertex_n) ==
Point<2>())
3612 cylinder_triangulation_offset =
3613 2.0 * (cell->vertex(3) -
Point<2>());
3620 bulk_tria, cells_to_remove, tria_without_cylinder);
3627 0.05 + shell_region_width,
3632 for (
const auto &cell : cylinder_tria.active_cell_iterators())
3635 if (
std::abs(cell->vertex(vertex_n)[0] - -0.41 / 4.0) < 1e-10)
3636 cell->vertex(vertex_n)[0] = -0.1;
3637 else if (
std::abs(cell->vertex(vertex_n)[0] - 0.41 / 4.0) < 1e-10)
3638 cell->vertex(vertex_n)[0] = 0.1;
3642 for (
const auto &cell : cylinder_tria.active_cell_iterators())
3644 cell->set_manifold_id(tfi_manifold_id);
3645 for (
const unsigned int face_n :
GeometryInfo<2>::face_indices())
3646 if (!cell->face(face_n)->at_boundary())
3647 cell->face(face_n)->set_manifold_id(tfi_manifold_id);
3649 if (0.0 < shell_region_width)
3652 ExcMessage(
"If the shell region has positive width then "
3653 "there must be at least one shell."));
3658 0.05 + shell_region_width,
3665 const double vertex_tolerance =
3666 std::min(internal::minimal_vertex_distance(shell_tria),
3667 internal::minimal_vertex_distance(cylinder_tria)) *
3673 shell_tria, cylinder_tria, temp, vertex_tolerance,
true);
3674 cylinder_tria = std::move(temp);
3680 const double vertex_tolerance =
3681 std::min(internal::minimal_vertex_distance(tria_without_cylinder),
3682 internal::minimal_vertex_distance(cylinder_tria)) /
3685 tria_without_cylinder, cylinder_tria, tria, vertex_tolerance,
true);
3698 const double shift =
3699 std::min(0.125 + shell_region_width * 0.5, 0.1 * 4. / 3.);
3700 for (
const auto &cell : tria.active_cell_iterators())
3702 if (cell->vertex(v).distance(
Point<2>(0.1, 0.205)) < 1
e-10)
3703 cell->vertex(v) =
Point<2>(0.2 -
shift, 0.205);
3704 else if (cell->vertex(v).distance(
Point<2>(0.3, 0.205)) < 1e-10)
3705 cell->vertex(v) =
Point<2>(0.2 + shift, 0.205);
3706 else if (cell->vertex(v).distance(
Point<2>(0.2, 0.1025)) < 1e-10)
3707 cell->vertex(v) =
Point<2>(0.2, 0.2 - shift);
3708 else if (cell->vertex(v).distance(
Point<2>(0.2, 0.3075)) < 1e-10)
3709 cell->vertex(v) =
Point<2>(0.2, 0.2 + shift);
3714 for (
const auto &cell : tria.active_cell_iterators())
3716 cell->set_all_manifold_ids(polar_manifold_id);
3720 for (
const auto &cell : tria.active_cell_iterators())
3727 std::vector<Point<2> *> cylinder_pointers;
3728 for (
const auto &face : tria.active_face_iterators())
3731 cylinder_pointers.push_back(&face->vertex(0));
3732 cylinder_pointers.push_back(&face->vertex(1));
3735 std::sort(cylinder_pointers.begin(), cylinder_pointers.end());
3736 cylinder_pointers.erase(std::unique(cylinder_pointers.begin(),
3737 cylinder_pointers.end()),
3738 cylinder_pointers.end());
3742 for (
const Point<2> *
const ptr : cylinder_pointers)
3743 center += *ptr / double(cylinder_pointers.
size());
3746 for (
Point<2> *
const ptr : cylinder_pointers)
3747 *ptr +=
Point<2>(0.2, 0.2) - center;
3759 for (
const auto &face : tria.active_face_iterators())
3760 if (face->at_boundary())
3762 const Point<2> center = face->center();
3764 if (
std::abs(center[0] - 0.0) < 1e-10)
3765 face->set_boundary_id(0);
3767 else if (
std::abs(center[0] - 2.2) < 1e-10)
3768 face->set_boundary_id(1);
3770 else if (face->manifold_id() == polar_manifold_id)
3771 face->set_boundary_id(2);
3776 std::abs(center[1] - 0.41) < 1.0e-10,
3778 face->set_boundary_id(3);
3788 const double shell_region_width,
3789 const unsigned int n_shells,
3790 const double skewness,
3795 tria_2, shell_region_width, n_shells, skewness,
colorize);
3813 tria.
set_manifold(cylindrical_manifold_id, cylindrical_manifold);
3820 for (
const auto &face : tria.active_face_iterators())
3822 face->set_boundary_id(3);
3827 template <
int dim,
int spacedim>
3830 const std::vector<unsigned int> &sizes,
3840 for (
unsigned int d = 0;
d < dim; ++
d)
3843 std::vector<Point<spacedim>> points;
3845 for (
const unsigned int i :
GeometryInfo<dim>::face_indices())
3848 std::vector<CellData<dim>> cells(n_cells);
3853 for (
unsigned int d = 0;
d < dim; ++
d)
3854 p[d] = 0.5 * dimensions[d] *
3857 points.push_back(p);
3858 cells[0].vertices[i] = i;
3860 cells[0].material_id = 0;
3865 for (
const unsigned int face :
GeometryInfo<dim>::face_indices())
3871 for (
unsigned int j = 0; j < sizes[face]; ++j, ++
cell_index)
3873 const unsigned int last_cell = (j == 0) ? 0U : (
cell_index - 1);
3875 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_face;
3878 const unsigned int cellv =
3880 const unsigned int ocellv =
3884 cells[last_cell].vertices[cellv];
3887 cells[
cell_index].vertices[cellv] = points.size();
3892 points.push_back(p);
4050 const double thickness,
4054 ExcMessage(
"Invalid left-to-right bounds of enclosed hypercube"));
4056 std::vector<Point<2>> vertices(16);
4058 coords[0] = left - thickness;
4061 coords[3] = right + thickness;
4064 for (
const double y : coords)
4065 for (const double x : coords)
4066 vertices[k++] =
Point<2>(x, y);
4070 std::vector<CellData<2>> cells(9);
4072 for (
unsigned int i0 = 0; i0 < 3; ++i0)
4073 for (
unsigned int i1 = 0; i1 < 3; ++i1)
4075 cells[k].vertices[0] = i1 + 4 * i0;
4076 cells[k].vertices[1] = i1 + 4 * i0 + 1;
4077 cells[k].vertices[2] = i1 + 4 * i0 + 4;
4078 cells[k].vertices[3] = i1 + 4 * i0 + 5;
4080 cells[k].material_id = materials[k];
4098 const double rl2 = (right + left) / 2;
4109 const int cell_vertices[4][4] = {{0, 1, 3, 2},
4114 for (
unsigned int i = 0; i < 4; ++i)
4116 for (
unsigned int j = 0; j < 4; ++j)
4117 cells[i].vertices[j] = cell_vertices[i][j];
4118 cells[i].material_id = 0;
4121 std::end(vertices)),
4128 cell->face(1)->set_boundary_id(1);
4130 cell->face(0)->set_boundary_id(2);
4139 const double radius_0,
4140 const double radius_1,
4141 const double half_length)
4145 vertices_tmp[0] =
Point<2>(-half_length, -radius_0);
4146 vertices_tmp[1] =
Point<2>(half_length, -radius_1);
4147 vertices_tmp[2] =
Point<2>(-half_length, radius_0);
4148 vertices_tmp[3] =
Point<2>(half_length, radius_1);
4150 const std::vector<Point<2>> vertices(std::begin(vertices_tmp),
4151 std::end(vertices_tmp));
4155 cell_vertices[0][i] = i;
4160 cells[0].vertices[i] = cell_vertices[0][i];
4162 cells[0].material_id = 0;
4167 cell->face(0)->set_boundary_id(1);
4168 cell->face(1)->set_boundary_id(2);
4170 for (
unsigned int i = 2; i < 4; ++i)
4171 cell->face(i)->set_boundary_id(0);
4188 Point<2>((a + b) / 2, (a + b) / 2),
4192 const int cell_vertices[3][4] = {{0, 1, 3, 4}, {1, 2, 4, 5}, {3, 4, 6, 7}};
4196 for (
unsigned int i = 0; i < 3; ++i)
4198 for (
unsigned int j = 0; j < 4; ++j)
4199 cells[i].vertices[j] = cell_vertices[i][j];
4200 cells[i].material_id = 0;
4204 std::end(vertices)),
4212 cell->face(0)->set_boundary_id(0);
4213 cell->face(2)->set_boundary_id(1);
4216 cell->face(1)->set_boundary_id(2);
4217 cell->face(2)->set_boundary_id(1);
4218 cell->face(3)->set_boundary_id(3);
4221 cell->face(0)->set_boundary_id(0);
4222 cell->face(1)->set_boundary_id(4);
4223 cell->face(3)->set_boundary_id(5);
4229 template <
int dim,
int spacedim>
4232 const std::vector<unsigned int> &repetitions,
4235 const std::vector<int> &n_cells_to_remove)
4241 for (
unsigned int d = 0;
d < dim; ++
d)
4243 Assert(std::fabs(n_cells_to_remove[d]) <= repetitions[d],
4244 ExcMessage(
"Attempting to cut away too many cells."));
4254 std::array<double, dim> h;
4256 for (
unsigned int d = 0;
d < dim; ++
d)
4259 h[
d] = (top_right[
d] - bottom_left[
d]) / repetitions[d];
4261 if (n_cells_to_remove[d] >= 0)
4265 h[
d] * std::fabs(n_cells_to_remove[d]) + bottom_left[
d];
4270 cut_step[
d] = top_right[
d] - h[
d] * std::fabs(n_cells_to_remove[d]);
4276 std::set<typename Triangulation<dim, spacedim>::active_cell_iterator>
4278 for (
const auto &cell : rectangle.active_cell_iterators())
4280 bool remove_cell =
true;
4281 for (
unsigned int d = 0;
d < dim && remove_cell; ++
d)
4282 if ((n_cells_to_remove[d] > 0 && cell->center()[d] >= cut_step[d]) ||
4283 (n_cells_to_remove[d] < 0 && cell->center()[d] <= cut_step[d]))
4284 remove_cell =
false;
4286 cells_to_remove.insert(cell);
4301 const double radius,
4302 const bool internal_manifolds)
4307 const double a = 1. / (1 +
std::sqrt(2.0));
4320 for (
unsigned int i = 0; i < 5; ++i)
4322 for (
unsigned int j = 0; j < 4; ++j)
4323 cells[i].vertices[j] = circle_cell_vertices[i][j];
4324 cells[i].material_id = 0;
4329 std::end(vertices)),
4334 if (internal_manifolds)
4342 template <
int spacedim>
4346 const double inner_radius,
4347 const double outer_radius,
4348 const unsigned int n_cells,
4351 Assert((inner_radius > 0) && (inner_radius < outer_radius),
4365 const unsigned int N =
4366 (
n_cells == 0 ?
static_cast<unsigned int>(
4367 std::ceil((2 * pi * (outer_radius + inner_radius) / 2) /
4368 (outer_radius - inner_radius))) :
4377 std::vector<Point<spacedim>> vertices(2 * N);
4378 for (
unsigned int i = 0; i < N; ++i)
4384 vertices[i] =
point * outer_radius;
4385 vertices[i + N] = vertices[i] * (inner_radius / outer_radius);
4387 vertices[i] += center;
4388 vertices[i + N] += center;
4393 for (
unsigned int i = 0; i < N; ++i)
4395 cells[i].vertices[0] = i;
4396 cells[i].vertices[1] = (i + 1) % N;
4397 cells[i].vertices[2] = N + i;
4398 cells[i].vertices[3] = N + ((i + 1) % N);
4400 cells[i].material_id = 0;
4406 colorize_hyper_shell(tria, center, inner_radius, outer_radius);
4418 const double inner_radius,
4419 const double outer_radius,
4420 const unsigned int n_cells,
4423 hyper_shell_2D(tria, center, inner_radius, outer_radius, n_cells,
colorize);
4432 const double inner_radius,
4433 const double outer_radius,
4434 const unsigned int n_cells,
4437 hyper_shell_2D(tria, center, inner_radius, outer_radius, n_cells,
colorize);
4447 const double inner_radius,
4448 const double outer_radius,
4449 const unsigned int n_cells)
4452 tria, outer_center, inner_radius, outer_radius, n_cells,
true);
4456 outer_radius - inner_radius > outer_center.
distance(inner_center),
4458 "The inner radius is greater than or equal to the outer radius plus eccentricity."));
4462 std::set<Point<dim> *> vertices_to_move;
4464 for (
const auto &face : tria.active_face_iterators())
4466 for (unsigned
int v = 0; v < GeometryInfo<dim>::vertices_per_face; ++v)
4467 vertices_to_move.insert(&face->vertex(v));
4469 const auto shift = inner_center - outer_center;
4470 for (
const auto &p : vertices_to_move)
4501 const double radius,
4502 const double half_length)
4504 Point<2> p1(-half_length, -radius);
4513 switch (f->boundary_id())
4516 f->set_boundary_id(1);
4519 f->set_boundary_id(2);
4522 f->set_boundary_id(0);
4560 const double radius)
4562 const unsigned int dim = 2;
4576 const int cell_vertices[3][4] = {{0, 2, 3, 4}, {1, 6, 2, 4}, {5, 3, 6, 4}};
4580 for (
unsigned int i = 0; i < 3; ++i)
4582 for (
unsigned int j = 0; j < 4; ++j)
4583 cells[i].vertices[j] = cell_vertices[i][j];
4584 cells[i].material_id = 0;
4588 std::end(vertices)),
4599 for (
const unsigned int i :
GeometryInfo<dim>::face_indices())
4601 if (cell->face(i)->boundary_id() ==
4607 if (cell->face(i)->center()[0] < p[0] + 1.e-5 * radius ||
4608 cell->face(i)->center()[1] < p[1] + 1.e-5 * radius)
4610 cell->face(i)->set_boundary_id(1);
4624 const double radius)
4629 const double a = 1. / (1 +
std::sqrt(2.0));
4640 const int cell_vertices[5][4] = {{0, 1, 2, 3},
4647 for (
unsigned int i = 0; i < 4; ++i)
4649 for (
unsigned int j = 0; j < 4; ++j)
4650 cells[i].vertices[j] = cell_vertices[i][j];
4651 cells[i].material_id = 0;
4655 std::end(vertices)),
4666 for (
const unsigned int i :
GeometryInfo<2>::face_indices())
4668 if (cell->face(i)->boundary_id() ==
4673 if (cell->face(i)->center()[0] < p[0] + 1.e-5 * radius)
4675 cell->face(i)->set_boundary_id(1);
4691 const double inner_radius,
4692 const double outer_radius,
4693 const unsigned int n_cells,
4696 Assert((inner_radius > 0) && (inner_radius < outer_radius),
4709 const unsigned int N =
4710 (
n_cells == 0 ?
static_cast<unsigned int>(
4711 std::ceil((pi * (outer_radius + inner_radius) / 2) /
4712 (outer_radius - inner_radius))) :
4721 std::vector<Point<2>> vertices(2 * (N + 1));
4722 for (
unsigned int i = 0; i <= N; ++i)
4731 Point<2>(((i == 0) || (i == N) ? 0 :
std::
cos(pi * i / N - pi / 2)),
4732 std::
sin(pi * i / N - pi / 2)) *
4734 vertices[i + N + 1] = vertices[i] * (inner_radius / outer_radius);
4736 vertices[i] += center;
4737 vertices[i + N + 1] += center;
4743 for (
unsigned int i = 0; i < N; ++i)
4745 cells[i].vertices[0] = i;
4746 cells[i].vertices[1] = (i + 1) % (N + 1);
4747 cells[i].vertices[2] = N + 1 + i;
4748 cells[i].vertices[3] = N + 1 + ((i + 1) % (N + 1));
4750 cells[i].material_id = 0;
4758 for (; cell != tria.
end(); ++cell)
4760 cell->face(2)->set_boundary_id(1);
4762 tria.
begin()->face(0)->set_boundary_id(3);
4764 tria.
last()->face(1)->set_boundary_id(2);
4775 const double inner_radius,
4776 const double outer_radius,
4777 const unsigned int n_cells,
4780 Assert((inner_radius > 0) && (inner_radius < outer_radius),
4793 const unsigned int N =
4794 (
n_cells == 0 ?
static_cast<unsigned int>(
4795 std::ceil((pi * (outer_radius + inner_radius) / 4) /
4796 (outer_radius - inner_radius))) :
4805 std::vector<Point<2>> vertices(2 * (N + 1));
4806 for (
unsigned int i = 0; i <= N; ++i)
4813 vertices[i] =
Point<2>(((i == N) ? 0 :
std::
cos(pi * i / N / 2)),
4814 std::
sin(pi * i / N / 2)) *
4816 vertices[i + N + 1] = vertices[i] * (inner_radius / outer_radius);
4818 vertices[i] += center;
4819 vertices[i + N + 1] += center;
4825 for (
unsigned int i = 0; i < N; ++i)
4827 cells[i].vertices[0] = i;
4828 cells[i].vertices[1] = (i + 1) % (N + 1);
4829 cells[i].vertices[2] = N + 1 + i;
4830 cells[i].vertices[3] = N + 1 + ((i + 1) % (N + 1));
4832 cells[i].material_id = 0;
4840 for (; cell != tria.
end(); ++cell)
4842 cell->face(2)->set_boundary_id(1);
4844 tria.
begin()->face(0)->set_boundary_id(3);
4846 tria.
last()->face(1)->set_boundary_id(2);
4863 const double rl2 = (right + left) / 2;
4864 const double len = (right - left) / 2.;
4877 const int cell_vertices[4][8] = {{0, 1, 3, 2, 10, 11, 13, 12},
4878 {9, 4, 2, 5, 19, 14, 12, 15},
4879 {3, 2, 7, 6, 13, 12, 17, 16},
4880 {2, 5, 6, 8, 12, 15, 16, 18}};
4882 for (
unsigned int i = 0; i < 4; ++i)
4884 for (
unsigned int j = 0; j < 8; ++j)
4885 cells[i].vertices[j] = cell_vertices[i][j];
4886 cells[i].material_id = 0;
4889 std::end(vertices)),
4896 cell->face(1)->set_boundary_id(1);
4898 cell->face(0)->set_boundary_id(2);
4910 const double thickness,
4914 ExcMessage(
"Invalid left-to-right bounds of enclosed hypercube"));
4916 std::vector<Point<3>> vertices(64);
4918 coords[0] = left - thickness;
4921 coords[3] = right + thickness;
4924 for (
const double z : coords)
4925 for (const double y : coords)
4926 for (const double x : coords)
4927 vertices[k++] =
Point<3>(x, y, z);
4930 24, 26, 5, 4, 6, 1, 0,
4931 2, 9, 8, 10, 37, 36, 38,
4932 33, 32, 34, 41, 40, 42};
4934 std::vector<CellData<3>> cells(27);
4936 for (
unsigned int z = 0; z < 3; ++z)
4937 for (
unsigned int y = 0; y < 3; ++y)
4938 for (
unsigned int x = 0; x < 3; ++x)
4940 cells[k].vertices[0] = x + 4 * y + 16 * z;
4941 cells[k].vertices[1] = x + 4 * y + 16 * z + 1;
4942 cells[k].vertices[2] = x + 4 * y + 16 * z + 4;
4943 cells[k].vertices[3] = x + 4 * y + 16 * z + 5;
4944 cells[k].vertices[4] = x + 4 * y + 16 * z + 16;
4945 cells[k].vertices[5] = x + 4 * y + 16 * z + 17;
4946 cells[k].vertices[6] = x + 4 * y + 16 * z + 20;
4947 cells[k].vertices[7] = x + 4 * y + 16 * z + 21;
4949 cells[k].material_id = materials[k];
4962 const double radius_0,
4963 const double radius_1,
4964 const double half_length)
4967 ExcMessage(
"The output triangulation object needs to be empty."));
4972 const auto n_slices = 1 +
static_cast<unsigned int>(std::ceil(
4973 half_length /
std::max(radius_0, radius_1)));
4986 auto shift_radii = [=](
const Point<3> &p) {
4987 const double slope = (radius_1 / radius_0 - 1.0) / (2.0 * half_length);
4988 const double factor = slope * (p[0] - -half_length) + 1.0;
4989 return Point<3>(p[0], factor * p[1], factor * p[2]);
4995 for (
const auto &face :
triangulation.active_face_iterators())
4996 if (face->at_boundary())
4998 if (
std::abs(face->center()[0] - -half_length) < 1e-8 * half_length)
4999 face->set_boundary_id(1);
5000 else if (
std::abs(face->center()[0] - half_length) <
5002 face->set_boundary_id(2);
5004 face->set_all_manifold_ids(0);
5027 Point<3>((a + b) / 2, a, (a + b) / 2),
5034 Point<3>((a + b) / 2, (a + b) / 2, a),
5036 Point<3>(a, (a + b) / 2, (a + b) / 2),
5037 Point<3>((a + b) / 2, (a + b) / 2, (a + b) / 2),
5038 Point<3>(b, (a + b) / 2, (a + b) / 2),
5040 Point<3>((a + b) / 2, (a + b) / 2, b),
5048 Point<3>((a + b) / 2, b, (a + b) / 2),
5052 const int cell_vertices[7][8] = {{0, 1, 9, 10, 3, 4, 12, 13},
5053 {1, 2, 10, 11, 4, 5, 13, 14},
5054 {3, 4, 12, 13, 6, 7, 15, 16},
5055 {4, 5, 13, 14, 7, 8, 16, 17},
5056 {9, 10, 18, 19, 12, 13, 21, 22},
5057 {10, 11, 19, 20, 13, 14, 22, 23},
5058 {12, 13, 21, 22, 15, 16, 24, 25}};
5062 for (
unsigned int i = 0; i < 7; ++i)
5064 for (
unsigned int j = 0; j < 8; ++j)
5065 cells[i].vertices[j] = cell_vertices[i][j];
5066 cells[i].material_id = 0;
5070 std::end(vertices)),
5087 const double radius,
5088 const bool internal_manifold)
5094 const unsigned int n_vertices = 16;
5095 const Point<3> vertices[n_vertices] = {
5120 const unsigned int n_cells = 7;
5121 const int cell_vertices[
n_cells][8] = {
5122 {0, 1, 4, 5, 3, 2, 7, 6},
5123 {8, 9, 12, 13, 0, 1, 4, 5},
5124 {9, 13, 1, 5, 10, 14, 2, 6},
5125 {11, 10, 3, 2, 15, 14, 7, 6},
5126 {8, 0, 12, 4, 11, 3, 15, 7},
5127 {8, 9, 0, 1, 11, 10, 3, 2},
5128 {12, 4, 13, 5, 15, 7, 14, 6}};
5130 std::vector<CellData<3>> cells(n_cells,
CellData<3>());
5132 for (
unsigned int i = 0; i <
n_cells; ++i)
5135 cells[i].vertices[j] = cell_vertices[i][j];
5136 cells[i].material_id = 0;
5141 std::end(vertices)),
5146 if (internal_manifold)
5156 const unsigned int n_rotate_middle_square)
5159 ExcMessage(
"The number of rotation by pi/2 of the right square "
5160 "must be in the half-open range [0,4)."));
5162 constexpr unsigned int dim = 2;
5164 const unsigned int n_cells = 5;
5165 std::vector<CellData<dim>> cells(n_cells);
5168 const std::vector<Point<dim>> vertices = {
Point<dim>(0, 0),
5183 unsigned int cell_vertices[
n_cells][4] = {{0, 1, 2, 3},
5189 switch (n_rotate_middle_square)
5193 cell_vertices[1][0] = 4;
5194 cell_vertices[1][1] = 5;
5195 cell_vertices[1][2] = 1;
5196 cell_vertices[1][3] = 3;
5202 cell_vertices[1][0] = 5;
5203 cell_vertices[1][1] = 3;
5204 cell_vertices[1][2] = 4;
5205 cell_vertices[1][3] = 1;
5211 cell_vertices[1][0] = 3;
5212 cell_vertices[1][1] = 1;
5213 cell_vertices[1][2] = 5;
5214 cell_vertices[1][3] = 4;
5226 for (
const unsigned int vertex_index :
5241 const bool face_orientation,
5242 const bool face_flip,
5243 const bool face_rotation,
5244 const bool manipulate_left_cube)
5246 constexpr unsigned int dim = 3;
5248 const unsigned int n_cells = 2;
5249 std::vector<CellData<dim>> cells(n_cells);
5252 const std::vector<Point<dim>> vertices = {
Point<dim>(0, 0, 0),
5265 unsigned int cell_vertices[
n_cells][8] = {
5266 {0, 1, 2, 3, 4, 5, 6, 7},
5267 {1, 8, 3, 9, 5, 10, 7, 11}};
5270 const unsigned int this_case = 4 *
static_cast<int>(face_orientation) +
5271 2 *
static_cast<int>(face_flip) +
5272 static_cast<int>(face_rotation);
5274 if (manipulate_left_cube)
5280 cell_vertices[0][0] = 1;
5281 cell_vertices[0][1] = 0;
5282 cell_vertices[0][2] = 5;
5283 cell_vertices[0][3] = 4;
5284 cell_vertices[0][4] = 3;
5285 cell_vertices[0][5] = 2;
5286 cell_vertices[0][6] = 7;
5287 cell_vertices[0][7] = 6;
5293 cell_vertices[0][0] = 5;
5294 cell_vertices[0][1] = 4;
5295 cell_vertices[0][2] = 7;
5296 cell_vertices[0][3] = 6;
5297 cell_vertices[0][4] = 1;
5298 cell_vertices[0][5] = 0;
5299 cell_vertices[0][6] = 3;
5300 cell_vertices[0][7] = 2;
5306 cell_vertices[0][0] = 7;
5307 cell_vertices[0][1] = 6;
5308 cell_vertices[0][2] = 3;
5309 cell_vertices[0][3] = 2;
5310 cell_vertices[0][4] = 5;
5311 cell_vertices[0][5] = 4;
5312 cell_vertices[0][6] = 1;
5313 cell_vertices[0][7] = 0;
5318 cell_vertices[0][0] = 3;
5319 cell_vertices[0][1] = 2;
5320 cell_vertices[0][2] = 1;
5321 cell_vertices[0][3] = 0;
5322 cell_vertices[0][4] = 7;
5323 cell_vertices[0][5] = 6;
5324 cell_vertices[0][6] = 5;
5325 cell_vertices[0][7] = 4;
5331 cell_vertices[0][0] = 0;
5332 cell_vertices[0][1] = 1;
5333 cell_vertices[0][2] = 2;
5334 cell_vertices[0][3] = 3;
5335 cell_vertices[0][4] = 4;
5336 cell_vertices[0][5] = 5;
5337 cell_vertices[0][6] = 6;
5338 cell_vertices[0][7] = 7;
5344 cell_vertices[0][0] = 2;
5345 cell_vertices[0][1] = 3;
5346 cell_vertices[0][2] = 6;
5347 cell_vertices[0][3] = 7;
5348 cell_vertices[0][4] = 0;
5349 cell_vertices[0][5] = 1;
5350 cell_vertices[0][6] = 4;
5351 cell_vertices[0][7] = 5;
5357 cell_vertices[0][0] = 6;
5358 cell_vertices[0][1] = 7;
5359 cell_vertices[0][2] = 4;
5360 cell_vertices[0][3] = 5;
5361 cell_vertices[0][4] = 2;
5362 cell_vertices[0][5] = 3;
5363 cell_vertices[0][6] = 0;
5364 cell_vertices[0][7] = 1;
5370 cell_vertices[0][0] = 4;
5371 cell_vertices[0][1] = 5;
5372 cell_vertices[0][2] = 0;
5373 cell_vertices[0][3] = 1;
5374 cell_vertices[0][4] = 6;
5375 cell_vertices[0][5] = 7;
5376 cell_vertices[0][6] = 2;
5377 cell_vertices[0][7] = 3;
5388 cell_vertices[1][0] = 8;
5389 cell_vertices[1][1] = 1;
5390 cell_vertices[1][2] = 10;
5391 cell_vertices[1][3] = 5;
5392 cell_vertices[1][4] = 9;
5393 cell_vertices[1][5] = 3;
5394 cell_vertices[1][6] = 11;
5395 cell_vertices[1][7] = 7;
5401 cell_vertices[1][0] = 10;
5402 cell_vertices[1][1] = 5;
5403 cell_vertices[1][2] = 11;
5404 cell_vertices[1][3] = 7;
5405 cell_vertices[1][4] = 8;
5406 cell_vertices[1][5] = 1;
5407 cell_vertices[1][6] = 9;
5408 cell_vertices[1][7] = 3;
5414 cell_vertices[1][0] = 11;
5415 cell_vertices[1][1] = 7;
5416 cell_vertices[1][2] = 9;
5417 cell_vertices[1][3] = 3;
5418 cell_vertices[1][4] = 10;
5419 cell_vertices[1][5] = 5;
5420 cell_vertices[1][6] = 8;
5421 cell_vertices[1][7] = 1;
5427 cell_vertices[1][0] = 9;
5428 cell_vertices[1][1] = 3;
5429 cell_vertices[1][2] = 8;
5430 cell_vertices[1][3] = 1;
5431 cell_vertices[1][4] = 11;
5432 cell_vertices[1][5] = 7;
5433 cell_vertices[1][6] = 10;
5434 cell_vertices[1][7] = 5;
5440 cell_vertices[1][0] = 1;
5441 cell_vertices[1][1] = 8;
5442 cell_vertices[1][2] = 3;
5443 cell_vertices[1][3] = 9;
5444 cell_vertices[1][4] = 5;
5445 cell_vertices[1][5] = 10;
5446 cell_vertices[1][6] = 7;
5447 cell_vertices[1][7] = 11;
5453 cell_vertices[1][0] = 5;
5454 cell_vertices[1][1] = 10;
5455 cell_vertices[1][2] = 1;
5456 cell_vertices[1][3] = 8;
5457 cell_vertices[1][4] = 7;
5458 cell_vertices[1][5] = 11;
5459 cell_vertices[1][6] = 3;
5460 cell_vertices[1][7] = 9;
5466 cell_vertices[1][0] = 7;
5467 cell_vertices[1][1] = 11;
5468 cell_vertices[1][2] = 5;
5469 cell_vertices[1][3] = 10;
5470 cell_vertices[1][4] = 3;
5471 cell_vertices[1][5] = 9;
5472 cell_vertices[1][6] = 1;
5473 cell_vertices[1][7] = 8;
5479 cell_vertices[1][0] = 3;
5480 cell_vertices[1][1] = 9;
5481 cell_vertices[1][2] = 7;
5482 cell_vertices[1][3] = 11;
5483 cell_vertices[1][4] = 1;
5484 cell_vertices[1][5] = 8;
5485 cell_vertices[1][6] = 5;
5486 cell_vertices[1][7] = 10;
5496 for (
const unsigned int vertex_index :
5510 template <
int spacedim>
5514 const double radius)
5518 const std::set<types::boundary_id> boundary_ids = {0};
5530 const unsigned int x_subdivisions,
5531 const double radius,
5532 const double half_length)
5539 std::vector<Point<3>> vertices;
5540 const double initial_height = -half_length;
5541 const double height_increment = 2. * half_length / x_subdivisions;
5543 for (
unsigned int rep = 0; rep < (x_subdivisions + 1); ++rep)
5545 const double height = initial_height + height_increment * rep;
5547 vertices.emplace_back(-d, height, -d);
5548 vertices.emplace_back(d, height, -d);
5549 vertices.emplace_back(-a, height, -a);
5550 vertices.emplace_back(a, height, -a);
5551 vertices.emplace_back(-a, height, a);
5552 vertices.emplace_back(a, height, a);
5553 vertices.emplace_back(-d, height, d);
5554 vertices.emplace_back(d, height, d);
5558 for (
auto &vertex : vertices)
5560 const double h = vertex[1];
5561 vertex[1] = -vertex[0];
5565 std::vector<std::vector<int>> cell_vertices;
5566 cell_vertices.push_back({0, 1, 8, 9, 2, 3, 10, 11});
5567 cell_vertices.push_back({0, 2, 8, 10, 6, 4, 14, 12});
5568 cell_vertices.push_back({2, 3, 10, 11, 4, 5, 12, 13});
5569 cell_vertices.push_back({1, 7, 9, 15, 3, 5, 11, 13});
5570 cell_vertices.push_back({6, 4, 14, 12, 7, 5, 15, 13});
5572 for (
unsigned int rep = 1; rep < x_subdivisions; ++rep)
5574 for (
unsigned int i = 0; i < 5; ++i)
5576 std::vector<int> new_cell_vertices(8);
5577 for (
unsigned int j = 0; j < 8; ++j)
5578 new_cell_vertices[j] = cell_vertices[i][j] + 8 * rep;
5579 cell_vertices.push_back(new_cell_vertices);
5583 unsigned int n_cells = x_subdivisions * 5;
5585 std::vector<CellData<3>> cells(n_cells,
CellData<3>());
5587 for (
unsigned int i = 0; i <
n_cells; ++i)
5589 for (
unsigned int j = 0; j < 8; ++j)
5590 cells[i].vertices[j] = cell_vertices[i][j];
5591 cells[i].material_id = 0;
5595 std::end(vertices)),
5613 const double tolerance = 1
e-5 *
std::min(radius, half_length);
5615 for (
const auto &cell : tria.cell_iterators())
5617 if (cell->at_boundary(i))
5619 if (cell->face(i)->center()[0] > half_length - tolerance)
5621 cell->face(i)->set_boundary_id(2);
5624 for (
unsigned int e = 0; e < GeometryInfo<3>::lines_per_face;
5626 if ((std::fabs(cell->face(i)->line(e)->vertex(0)[1]) == a) ||
5627 (std::fabs(cell->face(i)->line(e)->vertex(0)[2]) == a) ||
5628 (std::fabs(cell->face(i)->line(e)->vertex(1)[1]) == a) ||
5629 (std::fabs(cell->face(i)->line(e)->vertex(1)[2]) == a))
5631 cell->face(i)->line(e)->set_boundary_id(2);
5632 cell->face(i)->line(e)->set_manifold_id(
5636 else if (cell->face(i)->center()[0] < -half_length + tolerance)
5638 cell->face(i)->set_boundary_id(1);
5641 for (
unsigned int e = 0; e < GeometryInfo<3>::lines_per_face;
5643 if ((std::fabs(cell->face(i)->line(e)->vertex(0)[1]) == a) ||
5644 (std::fabs(cell->face(i)->line(e)->vertex(0)[2]) == a) ||
5645 (std::fabs(cell->face(i)->line(e)->vertex(1)[1]) == a) ||
5646 (std::fabs(cell->face(i)->line(e)->vertex(1)[2]) == a))
5648 cell->face(i)->line(e)->set_boundary_id(1);
5649 cell->face(i)->line(e)->set_manifold_id(
5661 const double radius,
5662 const double half_length)
5671 const double radius)
5673 const unsigned int dim = 3;
5681 const double a = 0.528;
5682 const double b = 0.4533;
5683 const double c = 0.3752;
5687 center +
Point<dim>(+1, 0, 0) * (radius * a),
5688 center +
Point<dim>(0, +1, 0) * (radius * a),
5696 center +
Point<dim>(+1, +1, 1) * (radius * c),
5700 const int cell_vertices[4][8] = {{0, 2, 3, 4, 7, 9, 10, 11},
5701 {1, 6, 2, 4, 8, 13, 9, 11},
5702 {5, 3, 6, 4, 12, 10, 13, 11},
5703 {7, 9, 10, 11, 14, 8, 12, 13}};
5707 for (
unsigned int i = 0; i < 4; ++i)
5709 for (
unsigned int j = 0; j < 8; ++j)
5710 cells[i].vertices[j] = cell_vertices[i][j];
5711 cells[i].material_id = 0;
5715 std::end(vertices)),
5725 for (
const unsigned int i :
GeometryInfo<dim>::face_indices())
5727 if (cell->face(i)->boundary_id() ==
5732 if (cell->face(i)->center()[0] < center[0] + 1.e-5 * radius ||
5733 cell->face(i)->center()[1] < center[1] + 1.e-5 * radius ||
5734 cell->face(i)->center()[2] < center[2] + 1.e-5 * radius)
5736 cell->face(i)->set_boundary_id(1);
5740 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
5743 const Point<3> line_vertices[2] = {
5744 cell->face(i)->line(j)->vertex(0),
5745 cell->face(i)->line(j)->vertex(1)};
5746 if ((std::fabs(line_vertices[0].distance(center) - radius) >
5748 (std::fabs(line_vertices[1].distance(center) - radius) >
5751 cell->face(i)->line(j)->set_boundary_id(1);
5752 cell->face(i)->line(j)->set_manifold_id(
5770 const double radius)
5776 const double b = a / 2.0;
5777 const double c =
d / 2.0;
5779 const double hb = radius *
std::sqrt(3.0) / 4.0;
5780 const double hc = radius *
std::sqrt(3.0) / 2.0;
5802 int cell_vertices[6][8] = {{0, 1, 8, 9, 2, 3, 10, 11},
5803 {0, 2, 8, 10, 6, 4, 14, 12},
5804 {2, 3, 10, 11, 4, 5, 12, 13},
5805 {1, 7, 9, 15, 3, 5, 11, 13},
5806 {6, 4, 14, 12, 7, 5, 15, 13},
5807 {8, 10, 9, 11, 14, 12, 15, 13}};
5811 for (
unsigned int i = 0; i < 6; ++i)
5813 for (
unsigned int j = 0; j < 8; ++j)
5814 cells[i].vertices[j] = cell_vertices[i][j];
5815 cells[i].material_id = 0;
5819 std::end(vertices)),
5835 for (
const unsigned int i :
GeometryInfo<3>::face_indices())
5837 if (!cell->at_boundary(i))
5843 if (cell->face(i)->center()[0] < center[0] + 1.e-5 * radius)
5845 cell->face(i)->set_boundary_id(1);
5847 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
5850 const Point<3> line_vertices[2] = {
5851 cell->face(i)->line(j)->vertex(0),
5852 cell->face(i)->line(j)->vertex(1)};
5853 if ((std::fabs(line_vertices[0].distance(center) - radius) >
5855 (std::fabs(line_vertices[1].distance(center) - radius) >
5858 cell->face(i)->line(j)->set_boundary_id(1);
5859 cell->face(i)->line(j)->set_manifold_id(
5876 const double radius)
5889 for (
unsigned int round = 0; round < dim; ++round)
5894 std::vector<Point<dim>> new_points(tria_copy.
n_vertices());
5896 for (
unsigned int v = 0; v < tria_copy.
n_vertices(); ++v)
5904 else if (round == 1)
5906 for (
unsigned int v = 0; v < tria_copy.
n_vertices(); ++v)
5915 else if (round == 2)
5916 for (
unsigned int v = 0; v < tria_copy.
n_vertices(); ++v)
5929 std::vector<CellData<dim>> cells;
5930 cells.reserve(tria_copy.
n_cells());
5931 for (
const auto &cell : tria_copy.cell_iterators())
5935 data.vertices[v] = cell->vertex_index(v);
5936 data.material_id = cell->material_id();
5937 data.manifold_id = cell->manifold_id();
5938 cells.push_back(
data);
5946 if (round == dim - 1)
5955 for (
const auto &cell : tria.cell_iterators())
5956 if (cell->center().norm_square() > 0.4 * radius)
5957 cell->set_manifold_id(1);
5978 const double inner_radius,
5979 const double outer_radius)
5981 std::vector<Point<3>> vertices;
5982 std::vector<CellData<3>> cells;
5984 const double irad = inner_radius /
std::sqrt(3.0);
5985 const double orad = outer_radius /
std::sqrt(3.0);
5988 static const std::array<Point<3>, 8> hexahedron = {{{-1, -1, -1},
5998 for (
unsigned int i = 0; i < 8; ++i)
5999 vertices.push_back(p + hexahedron[i] * irad);
6000 for (
unsigned int i = 0; i < 8; ++i)
6001 vertices.push_back(p + hexahedron[i] * orad);
6003 const unsigned int n_cells = 6;
6004 const int cell_vertices[
n_cells][8] = {
6005 {8, 9, 10, 11, 0, 1, 2, 3},
6006 {9, 11, 1, 3, 13, 15, 5, 7},
6007 {12, 13, 4, 5, 14, 15, 6, 7},
6008 {8, 0, 10, 2, 12, 4, 14, 6},
6009 {8, 9, 0, 1, 12, 13, 4, 5},
6010 {10, 2, 11, 3, 14, 6, 15, 7}};
6014 for (
unsigned int i = 0; i <
n_cells; ++i)
6017 cells[i].vertices[j] = cell_vertices[i][j];
6018 cells[i].material_id = 0;
6029 const double inner_radius,
6030 const double outer_radius)
6032 std::vector<Point<3>> vertices;
6033 std::vector<CellData<3>> cells;
6035 const double irad = inner_radius /
std::sqrt(3.0);
6036 const double orad = outer_radius /
std::sqrt(3.0);
6042 static const std::array<Point<3>, 6> octahedron = {{{-1, 0, 0},
6050 static const std::array<Point<3>, 8> hexahedron = {{{-1, -1, -1},
6059 for (
unsigned int i = 0; i < 8; ++i)
6060 vertices.push_back(p + hexahedron[i] * irad);
6061 for (
unsigned int i = 0; i < 6; ++i)
6062 vertices.push_back(p + octahedron[i] * inner_radius);
6063 for (
unsigned int i = 0; i < 8; ++i)
6064 vertices.push_back(p + hexahedron[i] * orad);
6065 for (
unsigned int i = 0; i < 6; ++i)
6066 vertices.push_back(p + octahedron[i] * outer_radius);
6068 const unsigned int n_cells = 12;
6069 const unsigned int rhombi[
n_cells][4] = {{10, 4, 0, 8},
6084 for (
unsigned int i = 0; i <
n_cells; ++i)
6086 for (
unsigned int j = 0; j < 4; ++j)
6088 cells[i].vertices[j] = rhombi[i][j];
6089 cells[i].vertices[j + 4] = rhombi[i][j] + 14;
6091 cells[i].material_id = 0;
6101 const unsigned int n,
6102 const unsigned int n_refinement_steps,
6104 const double inner_radius,
6105 const double outer_radius)
6118 const unsigned int outer_radius_factor = 1 << n_refinement_steps;
6123 outer_radius_factor * outer_radius -
6124 (outer_radius_factor - 1) * inner_radius);
6129 outer_radius_factor * outer_radius -
6130 (outer_radius_factor - 1) * inner_radius);
6133 for (
unsigned int r = 0; r < n_refinement_steps; ++r)
6136 std::set<Triangulation<3>::active_cell_iterator> cells_to_remove;
6140 for (
const auto &cell : tmp.active_cell_iterators())
6142 unsigned int n_vertices_inside = 0;
6144 if ((cell->vertex(v) - p).norm_square() <
6145 inner_radius * inner_radius * (1 + 1
e-12))
6146 ++n_vertices_inside;
6147 if (n_vertices_inside < 4)
6148 cells_to_remove.insert(cell);
6152 if (r == n_refinement_steps - 1)
6162 tmp = std::move(copy);
6180 const double inner_radius,
6181 const double outer_radius,
6182 const unsigned int n_cells,
6185 Assert((inner_radius > 0) && (inner_radius < outer_radius),
6188 unsigned int n_refinement_steps = 0;
6189 unsigned int n_cells_coarsened =
n_cells;
6190 if (n_cells != 96 && n_cells > 12)
6191 while (n_cells_coarsened > 12 && n_cells_coarsened % 4 == 0)
6193 ++n_refinement_steps;
6194 n_cells_coarsened /= 4;
6196 Assert(n_cells == 0 || n_cells == 6 || n_cells == 12 || n_cells == 96 ||
6197 (n_refinement_steps > 0 &&
6198 (n_cells_coarsened == 6 || n_cells_coarsened == 12)),
6199 ExcMessage(
"Invalid number of coarse mesh cells"));
6201 const unsigned int n = n_refinement_steps > 0 ?
6202 4 * n_cells_coarsened :
6208 internal::hyper_shell_6(tria, p, inner_radius, outer_radius);
6211 internal::hyper_shell_12(tria, p, inner_radius, outer_radius);
6215 internal::hyper_shell_24_48(
6216 tria, n, n_refinement_steps, p, inner_radius, outer_radius);
6225 internal::hyper_shell_12(tmp, p, inner_radius, outer_radius);
6242 colorize_hyper_shell(tria, p, inner_radius, outer_radius);
6252 const double inner_radius,
6253 const double outer_radius,
6254 const unsigned int ,
6257 Assert((inner_radius > 0) && (inner_radius < outer_radius),
6261 const double d = outer_radius /
std::sqrt(2.0);
6262 const double a = inner_radius /
std::sqrt(2.0);
6264 const double b = a / 2.0;
6265 const double c =
d / 2.0;
6267 const double hb = inner_radius *
std::sqrt(3.0) / 2.0;
6268 const double hc = outer_radius *
std::sqrt(3.0) / 2.0;
6290 int cell_vertices[5][8] = {{0, 1, 8, 9, 2, 3, 10, 11},
6291 {0, 2, 8, 10, 6, 4, 14, 12},
6292 {1, 7, 9, 15, 3, 5, 11, 13},
6293 {6, 4, 14, 12, 7, 5, 15, 13},
6294 {8, 10, 9, 11, 14, 12, 15, 13}};
6298 for (
unsigned int i = 0; i < 5; ++i)
6300 for (
unsigned int j = 0; j < 8; ++j)
6301 cells[i].vertices[j] = cell_vertices[i][j];
6302 cells[i].material_id = 0;
6306 std::end(vertices)),
6316 for (; cell != tria.
end(); ++cell)
6317 for (
const unsigned int i :
GeometryInfo<3>::face_indices())
6318 if (cell->at_boundary(i))
6319 cell->face(i)->set_all_boundary_ids(2);
6325 for (cell = tria.
begin(); cell != tria.
end(); ++cell)
6326 for (
const unsigned int i :
GeometryInfo<3>::face_indices())
6327 if (cell->at_boundary(i))
6331 const Point<3> face_center(face->center());
6332 if (
std::abs(face_center[0] - center[0]) >
6333 1.e-6 * face_center.
norm())
6335 if (
std::abs((face_center - center).
norm() - inner_radius) <
6336 std::abs((face_center - center).
norm() - outer_radius))
6337 face->set_all_boundary_ids(0);
6339 face->set_all_boundary_ids(1);
6353 const double inner_radius,
6354 const double outer_radius,
6355 const unsigned int n,
6358 Assert((inner_radius > 0) && (inner_radius < outer_radius),
6360 if (n == 0 || n == 3)
6362 const double a = inner_radius *
std::sqrt(2.0) / 2e0;
6363 const double b = outer_radius *
std::sqrt(2.0) / 2e0;
6364 const double c = a *
std::sqrt(3.0) / 2e0;
6366 const double e = outer_radius / 2e0;
6367 const double h = inner_radius / 2e0;
6369 std::vector<Point<3>> vertices;
6371 vertices.push_back(center +
Point<3>(0, inner_radius, 0));
6372 vertices.push_back(center +
Point<3>(a, a, 0));
6373 vertices.push_back(center +
Point<3>(b, b, 0));
6374 vertices.push_back(center +
Point<3>(0, outer_radius, 0));
6375 vertices.push_back(center +
Point<3>(0, a, a));
6376 vertices.push_back(center +
Point<3>(c, c, h));
6377 vertices.push_back(center +
Point<3>(d, d, e));
6378 vertices.push_back(center +
Point<3>(0, b, b));
6379 vertices.push_back(center +
Point<3>(inner_radius, 0, 0));
6380 vertices.push_back(center +
Point<3>(outer_radius, 0, 0));
6381 vertices.push_back(center +
Point<3>(a, 0, a));
6382 vertices.push_back(center +
Point<3>(b, 0, b));
6383 vertices.push_back(center +
Point<3>(0, 0, inner_radius));
6384 vertices.push_back(center +
Point<3>(0, 0, outer_radius));
6386 const int cell_vertices[3][8] = {
6387 {0, 1, 3, 2, 4, 5, 7, 6},
6388 {1, 8, 2, 9, 5, 10, 6, 11},
6389 {4, 5, 7, 6, 12, 10, 13, 11},
6391 std::vector<CellData<3>> cells(3);
6393 for (
unsigned int i = 0; i < 3; ++i)
6395 for (
unsigned int j = 0; j < 8; ++j)
6396 cells[i].vertices[j] = cell_vertices[i][j];
6397 cells[i].material_id = 0;
6410 colorize_quarter_hyper_shell(tria, center, inner_radius, outer_radius);
6421 const double length,
6422 const double inner_radius,
6423 const double outer_radius,
6424 const unsigned int n_radial_cells,
6425 const unsigned int n_axial_cells,
6428 Assert((inner_radius > 0) && (inner_radius < outer_radius),
6442 const unsigned int N_r =
6443 (n_radial_cells == 0 ?
static_cast<unsigned int>(std::ceil(
6444 (2 * pi * (outer_radius + inner_radius) / 2) /
6445 (outer_radius - inner_radius))) :
6447 const unsigned int N_z =
6448 (n_axial_cells == 0 ?
6449 static_cast<unsigned int>(std::ceil(
6450 length / (2 * pi * (outer_radius + inner_radius) / 2 / N_r))) :
6459 std::vector<Point<2>> vertices_2d(2 * N_r);
6460 for (
unsigned int i = 0; i < N_r; ++i)
6465 vertices_2d[i + N_r] = vertices_2d[i] * (inner_radius / outer_radius);
6468 std::vector<Point<3>> vertices_3d;
6469 vertices_3d.reserve(2 * N_r * (N_z + 1));
6470 for (
unsigned int j = 0; j <= N_z; ++j)
6471 for (
unsigned int i = 0; i < 2 * N_r; ++i)
6473 const Point<3> v(vertices_2d[i][0],
6476 vertices_3d.push_back(v);
6479 std::vector<CellData<3>> cells(N_r * N_z,
CellData<3>());
6481 for (
unsigned int j = 0; j < N_z; ++j)
6482 for (
unsigned int i = 0; i < N_r; ++i)
6484 cells[i + j * N_r].vertices[0] = i + (j + 1) * 2 * N_r;
6485 cells[i + j * N_r].vertices[1] = (i + 1) % N_r + (j + 1) * 2 * N_r;
6486 cells[i + j * N_r].vertices[2] = i + j * 2 * N_r;
6487 cells[i + j * N_r].vertices[3] = (i + 1) % N_r + j * 2 * N_r;
6489 cells[i + j * N_r].vertices[4] = N_r + i + (j + 1) * 2 * N_r;
6490 cells[i + j * N_r].vertices[5] =
6491 N_r + ((i + 1) % N_r) + (j + 1) * 2 * N_r;
6492 cells[i + j * N_r].vertices[6] = N_r + i + j * 2 * N_r;
6493 cells[i + j * N_r].vertices[7] = N_r + ((i + 1) % N_r) + j * 2 * N_r;
6495 cells[i + j * N_r].material_id = 0;
6514 double eps_z = 1
e-6 * length;
6519 double face_inner_radius = std::numeric_limits<double>::max();
6520 double face_outer_radius = 0.;
6525 for (
const auto &cell : tria.active_cell_iterators())
6528 if (!cell->face(f)->at_boundary())
6531 const auto face_center = cell->face(f)->center();
6532 const double z = face_center[2];
6534 if ((std::fabs(z) > eps_z) &&
6535 (std::fabs(z - length) > eps_z))
6537 const double radius =
std::sqrt(face_center[0] * face_center[0] +
6538 face_center[1] * face_center[1]);
6539 face_inner_radius =
std::min(face_inner_radius, radius);
6540 face_outer_radius =
std::max(face_outer_radius, radius);
6544 double mid_radial_distance = 0.5 * (face_outer_radius - face_inner_radius);
6546 for (
const auto &cell : tria.active_cell_iterators())
6549 if (cell->face(f)->at_boundary())
6551 const auto face_center = cell->face(f)->center();
6553 const double radius =
std::sqrt(face_center[0] * face_center[0] +
6554 face_center[1] * face_center[1]);
6556 const double z = face_center[2];
6558 if (std::fabs(z) < eps_z)
6560 cell->face(f)->set_boundary_id(2);
6562 else if (std::fabs(z - length) <
6565 cell->face(f)->set_boundary_id(3);
6567 else if (std::fabs(radius - face_inner_radius) >
6568 mid_radial_distance)
6570 cell->face(f)->set_boundary_id(1);
6572 else if (std::fabs(radius - face_inner_radius) <
6573 mid_radial_distance)
6575 cell->face(f)->set_boundary_id(0);
6584 template <
int dim,
int spacedim>
6589 const double duplicated_vertex_tolerance,
6590 const bool copy_manifold_ids,
6591 const bool copy_boundary_ids)
6593 std::vector<Point<spacedim>> vertices;
6594 std::vector<CellData<dim>> cells;
6597 unsigned int n_accumulated_vertices = 0;
6601 ExcMessage(
"The input triangulations must be non-empty "
6602 "and must not be refined."));
6604 auto [tria_vertices, tria_cells, tria_subcell_data] =
6614 vertices.insert(vertices.end(),
6615 tria_vertices.begin(),
6616 tria_vertices.end());
6619 for (
unsigned int &vertex_n : cell_data.vertices)
6620 vertex_n += n_accumulated_vertices;
6621 cells.push_back(cell_data);
6625 if (copy_manifold_ids)
6627 for (
CellData<1> &line_data : tria_subcell_data.boundary_lines)
6631 for (
unsigned int &vertex_n : line_data.vertices)
6632 vertex_n += n_accumulated_vertices;
6633 line_data.boundary_id =
6638 for (
CellData<2> &quad_data : tria_subcell_data.boundary_quads)
6642 for (
unsigned int &vertex_n : quad_data.vertices)
6643 vertex_n += n_accumulated_vertices;
6644 quad_data.boundary_id =
6654 std::vector<unsigned int> considered_vertices;
6658 considered_vertices,
6659 duplicated_vertex_tolerance);
6663 if (std::all_of(cells.begin(), cells.end(), [](
const auto &cell) {
6664 return cell.vertices.size() ==
6665 ReferenceCells::get_hypercube<dim>().n_vertices();
6671 if (!copy_manifold_ids)
6674 if (copy_boundary_ids)
6676 auto result_cell = result.
begin();
6677 for (
const auto &tria : triangulations)
6679 for (
const auto &cell : tria->cell_iterators())
6681 for (
const auto &f : cell->face_indices())
6682 if (result_cell->face(f)->at_boundary())
6683 result_cell->face(f)->set_boundary_id(
6690 Assert(duplicated_vertex_tolerance > 0.0 ||
6691 n_accumulated_vertices == result.
n_vertices(),
6697 template <
int dim,
int spacedim>
6702 const double duplicated_vertex_tolerance,
6703 const bool copy_manifold_ids,
6704 const bool copy_boundary_ids)
6707 if (triangulation_1.
n_cells() == 0)
6709 if (&result != &triangulation_2)
6712 else if (triangulation_2.
n_cells() == 0)
6714 if (&result != &triangulation_1)
6720 duplicated_vertex_tolerance,
6750 template <
int structdim>
6754 static_assert(structdim == 1 || structdim == 2,
6755 "This function is only implemented for lines and "
6763 std::sort(std::begin(cell_data.vertices),
6764 std::end(cell_data.vertices));
6765 else if (structdim == 2)
6768 std::array<unsigned int, 4> renumbering{};
6769 std::copy(std::begin(cell_data.vertices),
6770 std::end(cell_data.vertices),
6771 renumbering.begin());
6782 std::swap(renumbering[2], renumbering[3]);
6783 std::rotate(renumbering.begin(),
6784 std::min_element(renumbering.begin(),
6788 std::swap(renumbering[2], renumbering[3]);
6796 if (renumbering[1] > renumbering[2])
6797 std::swap(renumbering[1], renumbering[2]);
6798 std::copy(renumbering.begin(),
6800 std::begin(cell_data.vertices));
6807 return std::lexicographical_compare(std::begin(a.
vertices),
6809 std::begin(
b.vertices),
6810 std::end(
b.vertices));
6812 std::sort(subcell_data.begin(), subcell_data.end(), compare);
6817 auto left = subcell_data.begin();
6818 while (left != subcell_data.end())
6821 std::upper_bound(left, subcell_data.end(), *left, compare);
6824 if (left + 1 != right)
6825 for (
auto it = left; it != right; ++it)
6828 Assert(it->manifold_id == left->manifold_id,
6830 "In the process of grid generation a single "
6831 "line or quadrilateral has been assigned two "
6832 "different manifold ids. This can happen when "
6833 "a Triangulation is copied, e.g., via "
6834 "GridGenerator::replicate_triangulation() and "
6835 "not all external boundary faces have the same "
6836 "manifold id. Double check that all faces "
6837 "which you expect to be merged together have "
6838 "the same manifold id."));
6843 subcell_data.erase(std::unique(subcell_data.begin(), subcell_data.end()),
6844 subcell_data.end());
6850 template <
int dim,
int spacedim>
6853 const std::vector<unsigned int> &extents,
6858 for (
const auto &extent : extents)
6860 ExcMessage(
"The Triangulation must be copied at least one time in "
6861 "each coordinate dimension."));
6864 const auto &
min = bbox.get_boundary_points().first;
6865 const auto &
max = bbox.get_boundary_points().second;
6867 std::array<Tensor<1, spacedim>, dim> offsets;
6868 for (
unsigned int d = 0;
d < dim; ++
d)
6869 offsets[d][d] = max[d] - min[d];
6873 for (
unsigned int d = 0;
d < dim; ++
d)
6875 auto [input_vertices, input_cell_data, input_subcell_data] =
6878 std::vector<Point<spacedim>> output_vertices = input_vertices;
6879 std::vector<CellData<dim>> output_cell_data = input_cell_data;
6880 SubCellData output_subcell_data = input_subcell_data;
6882 for (
unsigned int k = 1; k < extents[
d]; ++k)
6884 const std::size_t vertex_offset = k * input_vertices.size();
6887 output_vertices.push_back(
point + double(k) * offsets[
d]);
6891 output_cell_data.push_back(cell_data);
6892 for (
unsigned int &vertex : output_cell_data.back().vertices)
6893 vertex += vertex_offset;
6897 input_subcell_data.boundary_lines)
6900 for (
unsigned int &vertex :
6901 output_subcell_data.boundary_lines.back().vertices)
6902 vertex += vertex_offset;
6905 input_subcell_data.boundary_quads)
6908 for (
unsigned int &vertex :
6909 output_subcell_data.boundary_quads.back().vertices)
6910 vertex += vertex_offset;
6915 std::vector<unsigned int> boundary_vertices;
6919 output_subcell_data,
6934 output_subcell_data.boundary_lines)
6940 tria_to_replicate.
clear();
6943 output_subcell_data);
6951 template <
int dim,
int spacedim>
6959 ExcMessage(
"The two input triangulations are not derived from "
6960 "the same coarse mesh as required."));
6963 &triangulation_1) ==
nullptr) &&
6966 &triangulation_2) ==
nullptr),
6967 ExcMessage(
"The source triangulations for this function must both "
6968 "be available entirely locally, and not be distributed "
6969 "triangulations."));
6986 for (
unsigned int iteration = 0; iteration < triangulation_2.
n_levels();
6992 bool any_cell_flagged =
false;
6993 for (
const auto &result_cell : result.active_cell_iterators())
6994 if (intergrid_map[result_cell]->has_children())
6996 any_cell_flagged =
true;
6997 result_cell->set_refine_flag();
7000 if (any_cell_flagged ==
false)
7009 template <
int dim,
int spacedim>
7019 std::vector<Point<spacedim>> vertices = input_triangulation.
get_vertices();
7023 std::vector<CellData<dim>> cells;
7024 for (
const auto &cell : input_triangulation.active_cell_iterators())
7025 if (cells_to_remove.find(cell) == cells_to_remove.
end())
7027 Assert(
static_cast<unsigned int>(cell->level()) ==
7028 input_triangulation.
n_levels() - 1,
7030 "Your input triangulation appears to have "
7031 "adaptively refined cells. This is not allowed. You can "
7032 "only call this function on a triangulation in which "
7033 "all cells are on the same refinement level."));
7037 this_cell.vertices[v] = cell->vertex_index(v);
7039 cells.push_back(this_cell);
7045 std::vector<unsigned int> considered_vertices;
7049 considered_vertices);
7061 const unsigned int n_slices,
7062 const double height,
7064 const bool copy_manifold_ids,
7065 const std::vector<types::manifold_id> &manifold_priorities)
7069 "The input triangulation must be a coarse mesh, i.e., it must "
7070 "not have been refined."));
7072 ExcMessage(
"The output triangulation object needs to be empty."));
7074 ExcMessage(
"The given height for extrusion must be positive."));
7077 "The number of slices for extrusion must be at least 2."));
7079 const double delta_h = height / (n_slices - 1);
7080 std::vector<double> slices_z_values;
7081 for (
unsigned int i = 0; i < n_slices; ++i)
7082 slices_z_values.push_back(i * delta_h);
7084 input, slices_z_values, result, copy_manifold_ids, manifold_priorities);
7092 const unsigned int n_slices,
7093 const double height,
7095 const bool copy_manifold_ids,
7096 const std::vector<types::manifold_id> &manifold_priorities)
7102 (void)copy_manifold_ids;
7103 (void)manifold_priorities;
7107 "GridTools::extrude_triangulation() is only available "
7108 "for Triangulation<3, 3> as output triangulation."));
7116 const std::vector<double> &slice_coordinates,
7118 const bool copy_manifold_ids,
7119 const std::vector<types::manifold_id> &manifold_priorities)
7123 "The input triangulation must be a coarse mesh, i.e., it must "
7124 "not have been refined."));
7126 ExcMessage(
"The output triangulation object needs to be empty."));
7127 Assert(slice_coordinates.size() >= 2,
7129 "The number of slices for extrusion must be at least 2."));
7130 Assert(std::is_sorted(slice_coordinates.begin(), slice_coordinates.end()),
7131 ExcMessage(
"Slice z-coordinates should be in ascending order"));
7134 "This function is only implemented for quadrilateral meshes."));
7136 const auto priorities = [&]() -> std::vector<types::manifold_id> {
7140 if (0 < manifold_priorities.size())
7144 std::vector<types::manifold_id> sorted_manifold_priorities =
7145 manifold_priorities;
7146 std::sort(sorted_manifold_priorities.begin(),
7147 sorted_manifold_priorities.end());
7148 Assert(std::unique(sorted_manifold_priorities.begin(),
7149 sorted_manifold_priorities.end()) ==
7150 sorted_manifold_priorities.end(),
7152 "The given vector of manifold ids may not contain any "
7153 "duplicated entries."));
7154 std::vector<types::manifold_id> sorted_manifold_ids =
7156 std::sort(sorted_manifold_ids.begin(), sorted_manifold_ids.end());
7157 if (sorted_manifold_priorities != sorted_manifold_ids)
7159 std::ostringstream message;
7160 message <<
"The given triangulation has manifold ids {";
7164 message << sorted_manifold_ids.back() <<
"}, but \n"
7165 <<
" the given vector of manifold ids is {";
7170 << manifold_priorities.back() <<
"}.\n"
7171 <<
" These vectors should contain the same elements.\n";
7172 const std::string m = message.str();
7176 return manifold_priorities;
7180 std::vector<types::manifold_id> default_priorities =
7182 const auto first_tfi_it = std::partition(
7183 default_priorities.begin(),
7184 default_priorities.end(),
7186 return dynamic_cast<const TransfiniteInterpolationManifold<2, 2> *>(
7187 &input.get_manifold(id)) == nullptr;
7189 std::sort(default_priorities.begin(), first_tfi_it);
7190 std::sort(first_tfi_it, default_priorities.end());
7192 return default_priorities;
7195 const std::size_t n_slices = slice_coordinates.size();
7196 std::vector<Point<3>> points(n_slices * input.
n_vertices());
7197 std::vector<CellData<3>> cells;
7202 for (std::size_t slice_n = 0; slice_n < n_slices; ++slice_n)
7204 for (std::size_t vertex_n = 0; vertex_n < input.
n_vertices();
7208 points[slice_n * input.
n_vertices() + vertex_n] =
7209 Point<3>(vertex[0], vertex[1], slice_coordinates[slice_n]);
7215 for (
const auto &cell : input.active_cell_iterators())
7217 for (std::size_t slice_n = 0; slice_n < n_slices - 1; ++slice_n)
7220 for (
const unsigned int vertex_n :
7224 cell->vertex_index(vertex_n) + slice_n * input.
n_vertices();
7227 cell->vertex_index(vertex_n) +
7232 if (copy_manifold_ids)
7234 cells.push_back(this_cell);
7245 for (
const auto &face : input.active_face_iterators())
7249 if (face->at_boundary())
7251 if (copy_manifold_ids)
7253 for (std::size_t slice_n = 0; slice_n < n_slices - 1; ++slice_n)
7256 face->vertex_index(0) + slice_n * input.
n_vertices();
7258 face->vertex_index(1) + slice_n * input.
n_vertices();
7260 face->vertex_index(0) + (slice_n + 1) * input.
n_vertices();
7262 face->vertex_index(1) + (slice_n + 1) * input.
n_vertices();
7263 quads.push_back(quad);
7269 if (copy_manifold_ids)
7270 for (
const auto &cell : input.active_cell_iterators())
7275 for (std::size_t slice_n = 1; slice_n < n_slices - 1; ++slice_n)
7278 cell->vertex_index(0) + slice_n * input.
n_vertices();
7280 cell->vertex_index(1) + slice_n * input.
n_vertices();
7282 cell->vertex_index(2) + slice_n * input.
n_vertices();
7284 cell->vertex_index(3) + slice_n * input.
n_vertices();
7285 quads.push_back(quad);
7296 "The input triangulation to this function is using boundary "
7297 "indicators in a range that do not allow using "
7298 "max_boundary_id+1 and max_boundary_id+2 as boundary "
7299 "indicators for the bottom and top faces of the "
7300 "extruded triangulation."));
7303 for (
const auto &cell : input.active_cell_iterators())
7307 quad.
vertices[0] = cell->vertex_index(0);
7308 quad.
vertices[1] = cell->vertex_index(1);
7309 quad.
vertices[2] = cell->vertex_index(2);
7310 quad.
vertices[3] = cell->vertex_index(3);
7311 if (copy_manifold_ids)
7313 quads.push_back(quad);
7316 for (
unsigned int &vertex : quad.vertices)
7317 vertex += (n_slices - 1) * input.n_vertices();
7318 if (copy_manifold_ids)
7320 quads.push_back(quad);
7333 for (
auto manifold_id_it = priorities.rbegin();
7334 manifold_id_it != priorities.rend();
7336 for (
const auto &face : result.active_face_iterators())
7338 for (unsigned
int line_n = 0;
7339 line_n < GeometryInfo<3>::lines_per_face;
7341 face->line(line_n)->set_manifold_id(*manifold_id_it);
7349 const std::vector<double> &slice_coordinates,
7351 const bool copy_manifold_ids,
7352 const std::vector<types::manifold_id> &manifold_priorities)
7355 (void)slice_coordinates;
7357 (void)copy_manifold_ids;
7358 (void)manifold_priorities;
7362 "GridTools::extrude_triangulation() is only available "
7363 "for Triangulation<3, 3> as output triangulation."));
7382 template <
int spacedim>
7385 const double inner_radius,
7386 const double outer_radius,
7393 Assert(inner_radius < outer_radius,
7394 ExcMessage(
"outer_radius has to be bigger than inner_radius."));
7403 std::vector<bool> treated_vertices(
triangulation.n_vertices(),
false);
7404 for (
const auto &cell :
triangulation.active_cell_iterators())
7407 if (cell->face(f)->at_boundary())
7410 (
std::
fabs(cell->face(f)->vertex(v).
norm() - outer_radius) <
7411 1
e-12 * outer_radius)
7416 std::
fabs(cell->face(f)->vertex(v)[1])) <
7417 1
e-12 * outer_radius))
7418 cell->face(f)->vertex(v) *=
std::
sqrt(2.);
7420 const double eps = 1
e-3 * outer_radius;
7421 for (
const auto &cell :
triangulation.active_cell_iterators())
7423 for (
const unsigned int f : cell->face_indices())
7424 if (cell->face(f)->at_boundary())
7426 const double dx = cell->face(f)->center()[0] - center[0];
7427 const double dy = cell->face(f)->center()[1] - center[1];
7430 if (
std::abs(dx + outer_radius) < eps)
7431 cell->face(f)->set_boundary_id(0);
7432 else if (
std::abs(dx - outer_radius) < eps)
7433 cell->face(f)->set_boundary_id(1);
7434 else if (
std::abs(dy + outer_radius) < eps)
7435 cell->face(f)->set_boundary_id(2);
7436 else if (
std::abs(dy - outer_radius) < eps)
7437 cell->face(f)->set_boundary_id(3);
7440 cell->face(f)->set_boundary_id(4);
7441 cell->face(f)->set_manifold_id(0);
7446 const double d = (cell->face(f)->center() - center).
norm();
7447 if (d - inner_radius < 0)
7449 cell->face(f)->set_boundary_id(1);
7450 cell->face(f)->set_manifold_id(0);
7453 cell->face(f)->set_boundary_id(0);
7465 const double inner_radius,
7466 const double outer_radius,
7468 const unsigned int width_repetition,
7484 const double inner_radius,
7485 const double outer_radius,
7487 const unsigned int width_repetition,
7504 const double inner_radius,
7505 const double outer_radius,
7506 const unsigned int n_shells,
7507 const double skewness,
7508 const unsigned int n_cells,
7514 Assert(inner_radius < outer_radius,
7515 ExcMessage(
"outer_radius has to be bigger than inner_radius."));
7519 std::vector<double> radii;
7520 radii.push_back(inner_radius);
7521 for (
unsigned int shell_n = 1; shell_n < n_shells; ++shell_n)
7522 if (skewness == 0.0)
7524 radii.push_back(inner_radius +
7525 (outer_radius - inner_radius) *
7526 (1.0 - (1.0 -
double(shell_n) / n_shells)));
7530 (outer_radius - inner_radius) *
7531 (1.0 -
std::tanh(skewness * (1.0 -
double(shell_n) / n_shells)) /
7533 radii.push_back(outer_radius);
7535 double grid_vertex_tolerance = 0.0;
7536 for (
unsigned int shell_n = 0; shell_n < radii.size() - 1; ++shell_n)
7543 n_cells == 0 ? (dim == 2 ? 8 : 12) :
7548 if (grid_vertex_tolerance == 0.0)
7549 grid_vertex_tolerance =
7550 0.5 * internal::minimal_vertex_distance(current_shell);
7557 grid_vertex_tolerance);
7569 constexpr double radial_vertex_tolerance =
7570 100.0 * std::numeric_limits<double>::epsilon();
7571 auto assert_vertex_distance_within_tolerance =
7572 [center, radial_vertex_tolerance](
7574 const double radius) {
7576 (void)radial_vertex_tolerance;
7579 for (
unsigned int vertex_n = 0;
7580 vertex_n < GeometryInfo<dim>::vertices_per_face;
7583 Assert(
std::abs((face->vertex(vertex_n) - center).norm() - radius) <
7584 (center.
norm() + radius) * radial_vertex_tolerance,
7589 for (
const auto &cell :
triangulation.active_cell_iterators())
7592 auto face = cell->face(face_n);
7593 if (face->at_boundary())
7595 if (((face->vertex(0) - center).norm() - inner_radius) <
7596 (center.
norm() + inner_radius) * radial_vertex_tolerance)
7599 assert_vertex_distance_within_tolerance(face, inner_radius);
7600 face->set_all_boundary_ids(0);
7605 assert_vertex_distance_within_tolerance(face, outer_radius);
7606 face->set_all_boundary_ids(1);
7617 const double inner_radius,
7618 const double outer_radius,
7620 const unsigned int Nz,
7625 Assert(inner_radius < outer_radius,
7626 ExcMessage(
"outer_radius has to be bigger than inner_radius."));
7640 std::vector<bool> treated_vertices(
triangulation.n_vertices(),
false);
7641 for (
const auto &cell :
triangulation.active_cell_iterators())
7643 for (
const auto f : cell->face_indices())
7644 if (cell->face(f)->at_boundary())
7648 const unsigned int vv = cell->face(f)->vertex_index(v);
7649 if (treated_vertices[vv] ==
false)
7651 treated_vertices[vv] =
true;
7661 cell->face(f)->vertex(v);
7662 if ((std::fabs(std::fabs(vertex_location[0]) -
7663 std::fabs(vertex_location[1])) <
7664 1e-12 * outer_radius) &&
7665 (std::fabs(vertex_location[0] * vertex_location[0] +
7666 vertex_location[1] * vertex_location[1] -
7667 outer_radius * outer_radius) <
7668 1e-12 * outer_radius))
7669 cell->face(f)->vertex(v) =
7672 vertex_location[2]);
7677 double eps = 1
e-3 * outer_radius;
7678 for (
const auto &cell :
triangulation.active_cell_iterators())
7680 for (
const unsigned int f : cell->face_indices())
7681 if (cell->face(f)->at_boundary())
7683 const double dx = cell->face(f)->center()[0];
7684 const double dy = cell->face(f)->center()[1];
7685 const double dz = cell->face(f)->center()[2];
7689 if (
std::abs(dx + outer_radius) < eps)
7690 cell->face(f)->set_boundary_id(0);
7692 else if (
std::abs(dx - outer_radius) < eps)
7693 cell->face(f)->set_boundary_id(1);
7695 else if (
std::abs(dy + outer_radius) < eps)
7696 cell->face(f)->set_boundary_id(2);
7698 else if (
std::abs(dy - outer_radius) < eps)
7699 cell->face(f)->set_boundary_id(3);
7702 cell->face(f)->set_boundary_id(4);
7705 cell->face(f)->set_boundary_id(5);
7709 cell->face(f)->set_all_boundary_ids(6);
7710 cell->face(f)->set_all_manifold_ids(0);
7717 const double d = c.
norm();
7718 if (d - inner_radius < 0)
7720 cell->face(f)->set_all_boundary_ids(1);
7721 cell->face(f)->set_all_manifold_ids(0);
7724 cell->face(f)->set_boundary_id(0);
7733 template <
int dim,
int spacedim1,
int spacedim2>
7740 &in_tria) ==
nullptr),
7742 "This function cannot be used on "
7743 "parallel::distributed::Triangulation objects as inputs."));
7745 ExcMessage(
"This function does not work for meshes that have "
7749 const unsigned int spacedim =
std::min(spacedim1, spacedim2);
7750 const std::vector<Point<spacedim1>> &in_vertices = in_tria.
get_vertices();
7754 std::vector<Point<spacedim2>> v(in_vertices.size());
7755 for (
unsigned int i = 0; i < in_vertices.size(); ++i)
7756 for (
unsigned int d = 0;
d < spacedim; ++
d)
7757 v[i][d] = in_vertices[i][d];
7760 for (
const auto &cell : in_tria.active_cell_iterators())
7762 const unsigned int id = cell->active_cell_index();
7764 cells[id].vertices.resize(cell->n_vertices());
7766 cells[id].vertices[i] = cell->vertex_index(i);
7767 cells[id].material_id = cell->material_id();
7768 cells[id].manifold_id = cell->manifold_id();
7782 std::vector<bool> user_flags_line;
7785 .clear_user_flags_line();
7789 for (
const auto &face : in_tria.active_face_iterators())
7791 if (face->at_boundary())
7795 boundary_line.
vertices.resize(face->n_vertices());
7797 boundary_line.vertices[i] = face->vertex_index(i);
7802 std::move(boundary_line));
7815 if ((face->user_flag_set() ==
false) &&
7820 boundary_line.
vertices.resize(face->n_vertices());
7822 boundary_line.vertices[i] = face->vertex_index(i);
7828 std::move(boundary_line));
7830 face->set_user_flag();
7836 .load_user_flags_line(user_flags_line);
7843 std::vector<bool> user_flags_line;
7846 .clear_user_flags_line();
7848 std::vector<bool> user_flags_quad;
7851 .clear_user_flags_quad();
7855 for (
const auto &face : in_tria.active_face_iterators())
7857 if (face->at_boundary())
7861 boundary_face.
vertices.resize(face->n_vertices());
7863 boundary_face.vertices[i] = face->vertex_index(i);
7868 std::move(boundary_face));
7875 for (
unsigned int e = 0;
e < face->n_lines(); ++
e)
7876 if (face->line(e)->user_flag_set() ==
false)
7879 spacedim1>::line_iterator
7880 edge = face->line(e);
7883 boundary_edge.
vertices.resize(edge->n_vertices());
7885 boundary_edge.vertices[i] = edge->vertex_index(i);
7890 std::move(boundary_edge));
7892 edge->set_user_flag();
7910 if (face->user_flag_set() ==
false)
7916 boundary_face.
vertices.resize(face->n_vertices());
7918 boundary_face.vertices[i] = face->vertex_index(i);
7924 std::move(boundary_face));
7926 face->set_user_flag();
7935 for (
unsigned int e = 0;
e < face->n_lines(); ++
e)
7936 if (face->line(e)->at_boundary() ==
false)
7937 if (face->line(e)->user_flag_set() ==
false)
7940 line_iterator edge = face->line(e);
7945 boundary_edge.vertices[i] =
7946 edge->vertex_index(i);
7952 std::move(boundary_edge));
7954 edge->set_user_flag();
7961 .load_user_flags_line(user_flags_line);
7963 .load_user_flags_quad(user_flags_quad);
7973 for (
const auto i : out_tria.get_manifold_ids())
7975 out_tria.set_manifold(i,
FlatManifold<dim, spacedim2>());
7980 template <
int dim,
int spacedim>
7989 "GridGenerator::convert_hypercube_to_simplex_mesh() expects a mesh that consists only of quads/hexes."));
8021 {{{0, 1, 12, 10}}, {{2, 3, 11, 12}}, {{7, 6, 11, 13}},
8022 {{5, 4, 13, 10}}, {{0, 2, 8, 12}}, {{4, 6, 13, 8}},
8023 {{5, 13, 7, 9}}, {{1, 9, 3, 12}}, {{0, 8, 4, 10}},
8024 {{1, 5, 9, 10}}, {{3, 7, 11, 9}}, {{2, 6, 8, 11}},
8025 {{12, 13, 10, 9}}, {{12, 13, 9, 11}}, {{12, 13, 11, 8}},
8026 {{12, 13, 8, 10}}, {{13, 8, 10, 4}}, {{13, 10, 9, 5}},
8027 {{13, 9, 11, 7}}, {{13, 11, 8, 6}}, {{10, 12, 9, 1}},
8028 {{9, 12, 11, 3}}, {{11, 12, 8, 2}}, {{8, 12, 10, 0}}}};
8035 vertex_ids_for_boundary_faces_2d = {{{{{{0, 4}}, {{4, 2}}}},
8036 {{{{1, 5}}, {{5, 3}}}},
8037 {{{{0, 6}}, {{6, 1}}}},
8038 {{{{2, 7}}, {{7, 3}}}}}};
8045 vertex_ids_for_boundary_faces_3d = {
8046 {{{{{0, 4, 8}}, {{4, 8, 6}}, {{8, 6, 2}}, {{0, 2, 8}}}},
8047 {{{{1, 3, 9}}, {{3, 9, 7}}, {{9, 7, 5}}, {{1, 9, 5}}}},
8048 {{{{0, 1, 10}}, {{1, 10, 5}}, {{10, 5, 4}}, {{0, 10, 4}}}},
8049 {{{{2, 3, 11}}, {{3, 11, 7}}, {{11, 7, 6}}, {{2, 11, 6}}}},
8050 {{{{0, 1, 12}}, {{1, 12, 3}}, {{12, 3, 2}}, {{0, 12, 2}}}},
8051 {{{{4, 5, 13}}, {{5, 13, 7}}, {{13, 7, 6}}, {{4, 13, 6}}}}}};
8070 {{{0, 12, 10}}, {{12, 1, 10}}, {{12, 1, 9}}, {{12, 3, 9}},
8071 {{12, 2, 11}}, {{12, 3, 11}}, {{12, 0, 8}}, {{12, 2, 8}},
8072 {{9, 13, 5}}, {{13, 7, 9}}, {{11, 7, 13}}, {{11, 6, 13}},
8073 {{4, 8, 13}}, {{6, 8, 13}}, {{4, 13, 10}}, {{13, 5, 10}},
8074 {{10, 9, 5}}, {{10, 9, 1}}, {{11, 9, 7}}, {{11, 9, 3}},
8075 {{8, 11, 2}}, {{8, 11, 6}}, {{8, 10, 0}}, {{8, 10, 4}},
8076 {{12, 3, 9}}, {{12, 9, 11}}, {{12, 3, 11}}, {{3, 9, 11}},
8077 {{2, 12, 8}}, {{2, 12, 11}}, {{2, 11, 8}}, {{8, 12, 11}},
8078 {{0, 12, 10}}, {{0, 12, 8}}, {{0, 8, 10}}, {{8, 10, 12}},
8079 {{12, 1, 10}}, {{12, 1, 9}}, {{1, 10, 9}}, {{10, 9, 12}},
8080 {{10, 8, 4}}, {{10, 8, 13}}, {{4, 13, 8}}, {{4, 13, 10}},
8081 {{10, 9, 13}}, {{10, 9, 5}}, {{13, 5, 10}}, {{13, 5, 9}},
8082 {{13, 7, 9}}, {{13, 7, 11}}, {{9, 11, 13}}, {{9, 11, 7}},
8083 {{8, 11, 13}}, {{8, 11, 6}}, {{6, 13, 8}}, {{6, 13, 11}},
8084 {{12, 13, 10}}, {{12, 13, 8}}, {{8, 10, 13}}, {{8, 10, 12}},
8085 {{12, 13, 10}}, {{12, 13, 9}}, {{10, 9, 13}}, {{10, 9, 12}},
8086 {{12, 13, 9}}, {{12, 13, 11}}, {{9, 11, 13}}, {{9, 11, 12}},
8087 {{12, 13, 11}}, {{12, 13, 8}}, {{8, 11, 13}}, {{8, 11, 12}}}};
8093 {{{12, 10}}, {{12, 9}}, {{12, 11}}, {{12, 8}}, {{9, 13}}, {{11, 13}},
8094 {{8, 13}}, {{10, 13}}, {{10, 9}}, {{9, 11}}, {{11, 8}}, {{8, 10}},
8095 {{12, 9}}, {{12, 11}}, {{11, 9}}, {{12, 8}}, {{12, 11}}, {{11, 8}},
8096 {{12, 8}}, {{12, 10}}, {{10, 8}}, {{12, 10}}, {{12, 9}}, {{9, 10}},
8097 {{13, 10}}, {{13, 8}}, {{8, 10}}, {{13, 10}}, {{13, 9}}, {{9, 10}},
8098 {{13, 11}}, {{13, 9}}, {{11, 9}}, {{13, 11}}, {{13, 8}}, {{11, 8}},
8099 {{12, 13}}, {{8, 10}}, {{8, 13}}, {{10, 13}}, {{8, 12}}, {{10, 12}},
8100 {{12, 13}}, {{10, 9}}, {{10, 13}}, {{9, 13}}, {{10, 12}}, {{9, 12}},
8101 {{12, 13}}, {{9, 11}}, {{9, 13}}, {{11, 13}}, {{9, 12}}, {{11, 12}},
8102 {{12, 13}}, {{11, 8}}, {{11, 13}}, {{8, 13}}, {{11, 12}}, {{8, 12}}}};
8114 vertex_ids_for_new_boundary_edges_3d = {
8115 {{{{{4, 8}}, {{6, 8}}, {{0, 8}}, {{2, 8}}}},
8116 {{{{5, 9}}, {{7, 9}}, {{1, 9}}, {{3, 9}}}},
8117 {{{{4, 10}}, {{5, 10}}, {{0, 10}}, {{1, 10}}}},
8118 {{{{6, 11}}, {{7, 11}}, {{2, 11}}, {{3, 11}}}},
8119 {{{{2, 12}}, {{3, 12}}, {{0, 12}}, {{1, 12}}}},
8120 {{{{6, 13}}, {{7, 13}}, {{4, 13}}, {{5, 13}}}}}};
8122 std::vector<Point<spacedim>> vertices;
8123 std::vector<CellData<dim>> cells;
8128 std::vector<unsigned int> old_to_new_vertex_indices(
8130 std::vector<unsigned int> face_to_new_vertex_indices(
8140 for (
const auto &cell : ref_tria.cell_iterators())
8144 std::array<unsigned int, dim == 2 ? 9 : 14> local_vertex_indices;
8149 const auto v_global = cell->vertex_index(v);
8151 if (old_to_new_vertex_indices[v_global] ==
8154 old_to_new_vertex_indices[v_global] = vertices.size();
8155 vertices.push_back(cell->vertex(v));
8159 local_vertex_indices[v] = old_to_new_vertex_indices[v_global];
8163 for (
const auto f : cell->face_indices())
8165 const auto f_global = cell->face_index(f);
8167 if (face_to_new_vertex_indices[f_global] ==
8170 face_to_new_vertex_indices[f_global] = vertices.size();
8172 cell->face(f)->center(
true));
8176 local_vertex_indices.size());
8177 local_vertex_indices[cell->n_vertices() + f] =
8178 face_to_new_vertex_indices[f_global];
8185 local_vertex_indices.size());
8186 local_vertex_indices[cell->n_vertices() + cell->n_faces()] =
8188 vertices.push_back(cell->center(
true));
8192 const auto add_cell = [&](
const unsigned int struct_dim,
8193 const auto &index_vertices,
8194 const unsigned int material_or_boundary_id,
8198 if (struct_dim < dim &&
8203 if (struct_dim == dim)
8208 cell_data.material_id =
8209 material_or_boundary_id;
8211 for (
unsigned int i = 0; i < index_vertices.size(); ++i)
8214 local_vertex_indices.size());
8215 cell_data.vertices[i] =
8216 local_vertex_indices[index_vertices[i]];
8218 cells.push_back(cell_data);
8220 else if (dim == 2 && struct_dim == 1)
8224 boundary_line.
boundary_id = material_or_boundary_id;
8226 for (
unsigned int i = 0; i < index_vertices.size(); ++i)
8229 local_vertex_indices.size());
8231 local_vertex_indices[index_vertices[i]];
8235 else if (dim == 3 && struct_dim == 2)
8239 boundary_quad.material_id = material_or_boundary_id;
8241 for (
unsigned int i = 0; i < index_vertices.size(); ++i)
8244 local_vertex_indices.size());
8245 boundary_quad.vertices[i] =
8246 local_vertex_indices[index_vertices[i]];
8250 else if (dim == 3 && struct_dim == 1)
8254 boundary_line.
boundary_id = material_or_boundary_id;
8256 for (
unsigned int i = 0; i < index_vertices.size(); ++i)
8259 local_vertex_indices.size());
8261 local_vertex_indices[index_vertices[i]];
8271 const auto material_id_cell = cell->material_id();
8277 const auto manifold_id_cell = cell->manifold_id();
8279 for (
const auto &cell_vertices : table_2D_cell)
8280 add_cell(dim, cell_vertices, material_id_cell, manifold_id_cell);
8283 for (
const auto &face_vertices : vertex_ids_for_inner_faces_2d)
8295 const auto manifold_id_cell = cell->manifold_id();
8297 for (
const auto &cell_vertices : vertex_ids_for_cells_3d)
8298 add_cell(dim, cell_vertices, material_id_cell, manifold_id_cell);
8302 for (
const auto &face_vertices : vertex_ids_for_inner_faces_3d)
8310 for (
const auto &edge_vertices : vertex_ids_for_inner_edges_3d)
8320 for (
const auto f : cell->face_indices())
8322 const auto bid = cell->face(f)->boundary_id();
8323 const auto mid = cell->face(f)->manifold_id();
8328 for (
const auto &face_vertices :
8329 vertex_ids_for_boundary_faces_2d[f])
8330 add_cell(1, face_vertices, bid, mid);
8336 for (
const auto &face_vertices :
8337 vertex_ids_for_boundary_faces_3d[f])
8338 add_cell(2, face_vertices, bid, mid);
8341 for (
const auto &edge_vertices :
8342 vertex_ids_for_new_boundary_edges_3d[f])
8343 add_cell(1, edge_vertices, bid, mid);
8353 for (
const auto e : cell->line_indices())
8355 auto edge = cell->line(e);
8361 old_to_new_vertex_indices[edge->vertex_index(0)];
8363 old_to_new_vertex_indices[edge->vertex_index(1)];
8375 for (
const auto i : out_tria.get_manifold_ids())
8377 out_tria.set_manifold(i,
FlatManifold<dim, spacedim>());
8382 template <
int spacedim>
8393 template <
int dim,
int spacedim>
8411 {{{0, 1, 3}}, {{1, 2, 3}}, {{2, 0, 3}}}};
8416 vertex_ids_for_boundary_faces_2d = {
8417 {{{{{0, 1}}}}, {{{{1, 2}}}}, {{{{2, 0}}}}}};
8419 std::vector<Point<spacedim>> vertices;
8420 std::vector<CellData<dim>> cells;
8425 std::vector<unsigned int> old_to_new_vertex_indices(
8433 for (
const auto &cell : ref_tria.cell_iterators())
8436 cell->reference_cell().is_simplex(),
8438 "Cell with invalid ReferenceCell encountered. GridGenerator::alfeld_split_of_simplex_mesh() "
8439 "only supports simplex meshes as input."));
8443 std::array<unsigned int, 4> local_vertex_indices;
8449 const auto v_global = cell->vertex_index(v);
8451 if (old_to_new_vertex_indices[v_global] ==
8454 old_to_new_vertex_indices[v_global] = vertices.size();
8455 vertices.push_back(cell->vertex(v));
8459 local_vertex_indices[v] = old_to_new_vertex_indices[v_global];
8465 local_vertex_indices[3] = vertices.size();
8466 vertices.push_back(barycenter / 3.);
8469 const auto add_cell = [&](
const unsigned int struct_dim,
8470 const auto &index_vertices,
8471 const unsigned int material_or_boundary_id,
8475 if (struct_dim < dim &&
8480 if (struct_dim == dim)
8485 for (
unsigned int i = 0; i < index_vertices.size(); ++i)
8488 local_vertex_indices.size());
8489 cell_data.vertices[i] =
8490 local_vertex_indices[index_vertices[i]];
8492 cell_data.material_id =
8493 material_or_boundary_id;
8495 cells.push_back(cell_data);
8497 else if (dim == 2 && struct_dim == 1)
8501 boundary_line.
boundary_id = material_or_boundary_id;
8503 for (
unsigned int i = 0; i < index_vertices.size(); ++i)
8506 local_vertex_indices.size());
8508 local_vertex_indices[index_vertices[i]];
8512 else if (dim == 3 && struct_dim == 2)
8516 boundary_quad.material_id = material_or_boundary_id;
8518 for (
unsigned int i = 0; i < index_vertices.size(); ++i)
8521 local_vertex_indices.size());
8522 boundary_quad.vertices[i] =
8523 local_vertex_indices[index_vertices[i]];
8527 else if (dim == 3 && struct_dim == 1)
8531 boundary_line.
boundary_id = material_or_boundary_id;
8533 for (
unsigned int i = 0; i < index_vertices.size(); ++i)
8536 local_vertex_indices.size());
8538 local_vertex_indices[index_vertices[i]];
8548 const auto material_id_cell = cell->material_id();
8554 const auto manifold_id_cell = cell->manifold_id();
8556 for (
const auto &cell_vertices : table_2D_cell)
8557 add_cell(dim, cell_vertices, material_id_cell, manifold_id_cell);
8563 for (
const auto f : cell->face_indices())
8565 const auto bid = cell->face(f)->boundary_id();
8566 const auto mid = cell->face(f)->manifold_id();
8571 for (
const auto &face_vertices :
8572 vertex_ids_for_boundary_faces_2d[f])
8573 add_cell(1, face_vertices, bid, mid);
8583 for (
const auto i : out_tria.get_manifold_ids())
8585 out_tria.set_manifold(i,
FlatManifold<dim, spacedim>());
8590 template <
template <
int,
int>
class MeshType,
int dim,
int spacedim>
8594 std::map<
typename MeshType<dim - 1, spacedim>::cell_iterator,
8595 typename MeshType<dim, spacedim>::face_iterator>
8597 typename ExtractBoundaryMesh<MeshType, dim, spacedim>::return_type
8600 MeshType<dim - 1, spacedim> &surface_mesh,
8601 const std::set<types::boundary_id> &boundary_ids)
8605 &volume_mesh.get_triangulation()) ==
nullptr),
8614 const unsigned int boundary_dim = dim - 1;
8621 std::pair<typename MeshType<dim, spacedim>::face_iterator,
unsigned int>>
8622 temporary_mapping_level0;
8627 std::vector<bool> touched(volume_mesh.get_triangulation().n_vertices(),
8631 std::vector<CellData<boundary_dim>> cells;
8633 std::vector<Point<spacedim>> vertices;
8636 std::map<unsigned int, unsigned int> map_vert_index;
8649 for (
unsigned int i1 = 0; i1 < GeometryInfo<spacedim>::faces_per_cell; ++i1)
8651 for (
unsigned int i2 = 0; i2 <
GeometryInfo<dim - 1>::vertices_per_cell;
8653 swap_matrix[i1][i2] = i2;
8659 std::swap(swap_matrix[0][1], swap_matrix[0][2]);
8660 std::swap(swap_matrix[2][1], swap_matrix[2][2]);
8661 std::swap(swap_matrix[4][1], swap_matrix[4][2]);
8665 std::swap(swap_matrix[1][0], swap_matrix[1][1]);
8666 std::swap(swap_matrix[2][0], swap_matrix[2][1]);
8671 for (
typename MeshType<dim, spacedim>::cell_iterator cell =
8672 volume_mesh.begin(0);
8673 cell != volume_mesh.end(0);
8675 for (
const unsigned int i :
GeometryInfo<dim>::face_indices())
8677 const typename MeshType<dim, spacedim>::face_iterator face =
8680 if (face->at_boundary() &&
8681 (boundary_ids.empty() ||
8682 (boundary_ids.find(face->boundary_id()) != boundary_ids.end())))
8686 for (
const unsigned int j :
8689 const unsigned int v_index = face->vertex_index(j);
8691 if (!touched[v_index])
8693 vertices.push_back(face->vertex(j));
8694 map_vert_index[v_index] = vertices.size() - 1;
8695 touched[v_index] =
true;
8698 c_data.
vertices[swap_matrix[i][j]] = map_vert_index[v_index];
8712 for (
unsigned int e = 0;
e < 4; ++
e)
8718 bool edge_found =
false;
8719 for (
auto &boundary_line : subcell_data.boundary_lines)
8720 if (((boundary_line.vertices[0] ==
8721 map_vert_index[face->line(
e)->vertex_index(0)]) &&
8722 (boundary_line.vertices[1] ==
8723 map_vert_index[face->line(
e)->vertex_index(
8725 ((boundary_line.vertices[0] ==
8726 map_vert_index[face->line(
e)->vertex_index(1)]) &&
8727 (boundary_line.vertices[1] ==
8728 map_vert_index[face->line(
e)->vertex_index(0)])))
8735 if (edge_found ==
true)
8742 map_vert_index[face->line(e)->vertex_index(0)];
8744 map_vert_index[face->line(e)->vertex_index(1)];
8751 cells.push_back(c_data);
8752 temporary_mapping_level0.push_back(std::make_pair(face, i));
8759 surface_mesh.get_triangulation())
8765 for (
const auto &cell : surface_mesh.active_cell_iterators())
8766 for (unsigned
int vertex = 0; vertex < 2; ++vertex)
8767 if (cell->face(vertex)->at_boundary())
8768 cell->face(vertex)->set_boundary_id(0);
8776 std::vector<std::pair<
8777 const typename MeshType<dim - 1, spacedim>::cell_iterator,
8778 std::pair<typename MeshType<dim, spacedim>::face_iterator,
unsigned int>>>
8779 temporary_map_boundary_cell_face;
8780 for (
const auto &cell : surface_mesh.active_cell_iterators())
8781 temporary_map_boundary_cell_face.push_back(
8782 std::make_pair(cell, temporary_mapping_level0.at(cell->
index())));
8794 unsigned int index_cells_deepest_level = 0;
8797 bool changed =
false;
8801 std::vector<unsigned int> cells_refined;
8804 for (
unsigned int cell_n = index_cells_deepest_level;
8805 cell_n < temporary_map_boundary_cell_face.size();
8810 if (temporary_map_boundary_cell_face[cell_n]
8811 .
second.first->has_children())
8815 Assert(temporary_map_boundary_cell_face[cell_n]
8816 .
second.first->refinement_case() ==
8819 temporary_map_boundary_cell_face[cell_n]
8820 .first->set_refine_flag();
8821 cells_refined.push_back(cell_n);
8832 surface_mesh.get_triangulation())
8833 .execute_coarsening_and_refinement();
8836 index_cells_deepest_level = temporary_map_boundary_cell_face.size();
8837 for (
const auto &refined_cell_n : cells_refined)
8839 const typename MeshType<dim - 1, spacedim>::cell_iterator
8841 temporary_map_boundary_cell_face[refined_cell_n].first;
8842 const typename MeshType<dim,
8843 spacedim>::face_iterator refined_face =
8844 temporary_map_boundary_cell_face[refined_cell_n].second.first;
8845 const unsigned int refined_face_number =
8846 temporary_map_boundary_cell_face[refined_cell_n]
8848 for (
unsigned int child_n = 0;
8849 child_n < refined_cell->n_children();
8854 temporary_map_boundary_cell_face.push_back(
8855 std::make_pair(refined_cell->child(
8856 swap_matrix[refined_face_number][child_n]),
8857 std::make_pair(refined_face->child(child_n),
8858 refined_face_number)));
8868 std::map<
typename MeshType<dim - 1, spacedim>::cell_iterator,
8869 typename MeshType<dim, spacedim>::face_iterator>
8870 surface_to_volume_mapping;
8871 for (
unsigned int i = 0; i < temporary_map_boundary_cell_face.size(); ++i)
8872 surface_to_volume_mapping[temporary_map_boundary_cell_face[i].
first] =
8873 temporary_map_boundary_cell_face[i].
second.first;
8876 const auto attached_mids =
8877 surface_mesh.get_triangulation().get_manifold_ids();
8878 for (
const auto i : volume_mesh.get_triangulation().get_manifold_ids())
8880 std::find(attached_mids.
begin(), attached_mids.
end(), i) ==
8881 attached_mids.
end())
8883 surface_mesh.get_triangulation())
8886 return surface_to_volume_mapping;
8891 template <
int dim,
int spacedim>
8895 const std::vector<unsigned int> &repetitions,
8902 std::vector<Point<spacedim>> vertices;
8903 std::vector<CellData<dim>> cells;
8909 (p2[1] - p1[1]) / repetitions[1]);
8912 for (
unsigned int j = 0; j <= repetitions[1]; ++j)
8913 for (
unsigned int i = 0; i <= repetitions[0]; ++i)
8918 for (
unsigned int j = 0; j < repetitions[1]; ++j)
8919 for (
unsigned int i = 0; i < repetitions[0]; ++i)
8922 std::array<unsigned int, 4> quad{{
8923 (j + 0) * (repetitions[0] + 1) + i + 0,
8924 (j + 0) * (repetitions[0] + 1) + i + 1,
8925 (j + 1) * (repetitions[0] + 1) + i + 0,
8926 (j + 1) * (repetitions[0] + 1) + i + 1
8932 tri.
vertices = {quad[0], quad[1], quad[2]};
8933 cells.push_back(tri);
8939 tri.
vertices = {quad[3], quad[2], quad[1]};
8940 cells.push_back(tri);
8948 (p2[1] - p1[1]) / repetitions[1],
8949 (p2[2] - p1[2]) / repetitions[2]);
8952 for (
unsigned int k = 0; k <= repetitions[2]; ++k)
8953 for (
unsigned int j = 0; j <= repetitions[1]; ++j)
8954 for (
unsigned int i = 0; i <= repetitions[0]; ++i)
8957 p1[2] + dx[2] * k));
8960 for (
unsigned int k = 0; k < repetitions[2]; ++k)
8961 for (
unsigned int j = 0; j < repetitions[1]; ++j)
8962 for (
unsigned int i = 0; i < repetitions[0]; ++i)
8965 std::array<unsigned int, 8> quad{
8966 {(k + 0) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8967 (j + 0) * (repetitions[0] + 1) + i + 0,
8968 (k + 0) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8969 (j + 0) * (repetitions[0] + 1) + i + 1,
8970 (k + 0) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8971 (j + 1) * (repetitions[0] + 1) + i + 0,
8972 (k + 0) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8973 (j + 1) * (repetitions[0] + 1) + i + 1,
8974 (k + 1) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8975 (j + 0) * (repetitions[0] + 1) + i + 0,
8976 (k + 1) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8977 (j + 0) * (repetitions[0] + 1) + i + 1,
8978 (k + 1) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8979 (j + 1) * (repetitions[0] + 1) + i + 0,
8980 (k + 1) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8981 (j + 1) * (repetitions[0] + 1) + i + 1}};
8986 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
8987 cell.
vertices = {{quad[0], quad[1], quad[2], quad[4]}};
8989 cell.
vertices = {{quad[0], quad[1], quad[3], quad[5]}};
8991 cells.push_back(cell);
8997 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
8998 cell.
vertices = {{quad[2], quad[1], quad[3], quad[7]}};
9000 cell.
vertices = {{quad[0], quad[3], quad[2], quad[6]}};
9001 cells.push_back(cell);
9007 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
9008 cell.
vertices = {{quad[1], quad[4], quad[5], quad[7]}};
9010 cell.
vertices = {{quad[0], quad[4], quad[5], quad[6]}};
9011 cells.push_back(cell);
9017 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
9018 cell.
vertices = {{quad[2], quad[4], quad[7], quad[6]}};
9020 cell.
vertices = {{quad[3], quad[5], quad[7], quad[6]}};
9021 cells.push_back(cell);
9027 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
9028 cell.
vertices = {{quad[1], quad[2], quad[4], quad[7]}};
9030 cell.
vertices = {{quad[0], quad[3], quad[6], quad[5]}};
9031 cells.push_back(cell);
9053 double epsilon = std::numeric_limits<double>::max();
9054 for (
unsigned int i = 0; i < dim; ++i)
9056 0.01 * (
std::abs(p2[i] - p1[i]) / repetitions[i]));
9059 "The distance between corner points must be positive."));
9063 colorize_subdivided_hyper_rectangle(tria, p1, p2, epsilon);
9069 template <
int dim,
int spacedim>
9072 const unsigned int repetitions,
9080 tria, {{repetitions, repetitions}}, {p1, p1}, {p2, p2},
colorize);
9086 {{repetitions, repetitions, repetitions}},
9099# include "grid_generator.inst"
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)
numbers::NumberTraits< Number >::real_type distance(const Point< dim, Number > &p) const
const Point< spacedim > center
numbers::NumberTraits< Number >::real_type norm() const
void initialize(const Triangulation< dim, spacedim > &triangulation)
virtual void add_periodicity(const std::vector< GridTools::PeriodicFacePair< cell_iterator > > &)
virtual types::global_cell_index n_global_active_cells() 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
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
active_cell_iterator begin_active(const unsigned int level=0) const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_CXX20_REQUIRES(condition)
#define DEAL_II_NAMESPACE_CLOSE
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)
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 consistently_order_cells(std::vector< CellData< dim > > &cells)
#define DEAL_II_ASSERT_UNREACHABLE()
#define DEAL_II_NOT_IMPLEMENTED()
const Mapping< dim, spacedim > & get_default_linear_mapping(const Triangulation< dim, spacedim > &triangulation)
std::vector< index_type > data
CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt K
Expression fabs(const Expression &x)
void create_triangulation(Triangulation< dim, dim > &tria, const AdditionalData &additional_data=AdditionalData())
void subdivided_hyper_cube_with_simplices(Triangulation< dim, spacedim > &tria, const unsigned int repetitions, const double p1=0.0, const double p2=1.0, const bool colorize=false)
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 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 hyper_cube_slit(Triangulation< dim > &tria, const double left=0., const double right=1., const bool colorize=false)
void hyper_ball(Triangulation< dim > &tria, const Point< dim > ¢er=Point< dim >(), const double radius=1., const bool attach_spherical_manifold_on_boundary_cells=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 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 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 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 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 convert_hypercube_to_simplex_mesh(const Triangulation< dim, spacedim > &in_tria, Triangulation< dim, spacedim > &out_tria)
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 reference_cell(Triangulation< dim, spacedim > &tria, const ReferenceCell &reference_cell)
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)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
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)
VectorType::value_type * end(VectorType &V)
VectorType::value_type * begin(VectorType &V)
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)
const types::material_id invalid_material_id
static constexpr double PI_2
const types::boundary_id invalid_boundary_id
static constexpr double PI
const types::boundary_id internal_face_boundary_id
static const unsigned int invalid_unsigned_int
const types::manifold_id flat_manifold_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
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
std::vector< unsigned int > vertices
types::manifold_id manifold_id
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)
std::vector< CellData< 2 > > boundary_quads
std::vector< CellData< 1 > > boundary_lines
DEAL_II_HOST constexpr Number determinant(const SymmetricTensor< 2, dim, Number > &)