51 : airfoil_type(
"NACA")
53 , joukowski_center(-0.1, 0.14)
59 , incline_factor(0.35)
62 , n_subdivision_x_0(3)
63 , n_subdivision_x_1(2)
64 , n_subdivision_x_2(5)
66 , airfoil_sampling_factor(2)
69 airfoil_length <= height,
71 "Mesh is to small to enclose airfoil! Choose larger field or smaller"
73 Assert(incline_factor < 1.0 && incline_factor >= 0.0,
74 ExcMessage(
"incline_factor has to be in [0,1)!"));
87 "Mesh height measured from airfoil nose to horizontal boundaries");
91 "Length measured from airfoil leading edge to vertical outlet boundary");
95 "Define obliqueness of the vertical mesh around the airfoil");
104 "Type of airfoil geometry, either NACA or Joukowski airfoil",
119 "Joukowski circle center coordinates");
122 "Joukowski airfoil length leading to trailing edge");
130 "Number of global refinements");
132 "NumberSubdivisionX0",
134 "Number of subdivisions along the airfoil in blocks with material ID 1 and 4");
136 "NumberSubdivisionX1",
138 "Number of subdivisions along the airfoil in blocks with material ID 2 and 5");
140 "NumberSubdivisionX2",
142 "Number of subdivisions in horizontal direction on the right of the trailing edge, i.e., blocks with material ID 3 and 6");
145 "Number of subdivisions normal to airfoil");
149 "Factor to obtain a finer mesh at the airfoil surface");
164 static const unsigned int id_block_1 = 1;
165 static const unsigned int id_block_2 = 2;
166 static const unsigned int id_block_3 = 3;
167 static const unsigned int id_block_4 = 4;
168 static const unsigned int id_block_5 = 5;
169 static const unsigned int id_block_6 = 6;
174 MeshGenerator(
const AdditionalData &data)
175 : refinements(data.refinements)
176 , n_subdivision_x_0(data.n_subdivision_x_0)
177 , n_subdivision_x_1(data.n_subdivision_x_1)
178 , n_subdivision_x_2(data.n_subdivision_x_2)
179 , n_subdivision_y(data.n_subdivision_y)
180 , height(data.height)
181 , length_b2(data.length_b2)
182 , incline_factor(data.incline_factor)
183 , bias_factor(data.bias_factor)
185 , n_cells_x_0(
Utilities::
pow(2, refinements) * n_subdivision_x_0)
186 , n_cells_x_1(
Utilities::
pow(2, refinements) * n_subdivision_x_1)
187 , n_cells_x_2(
Utilities::
pow(2, refinements) * n_subdivision_x_2)
188 , n_cells_y(
Utilities::
pow(2, refinements) * n_subdivision_y)
189 , n_points_on_each_side(n_cells_x_0 + n_cells_x_1 + 1)
191 , airfoil_1D(set_airfoil_length(
193 data.airfoil_type ==
"Joukowski" ?
194 joukowski(data.joukowski_center,
195 n_points_on_each_side,
196 data.airfoil_sampling_factor) :
197 (data.airfoil_type ==
"NACA" ?
199 n_points_on_each_side,
200 data.airfoil_sampling_factor) :
203 std::vector<Point<2>>{
207 data.airfoil_length))
208 , end_b0_x_u(airfoil_1D[0][n_cells_x_0](0))
209 , end_b0_x_l(airfoil_1D[1][n_cells_x_0](0))
210 , nose_x(airfoil_1D[0].front()(0))
211 , tail_x(airfoil_1D[0].back()(0))
212 , tail_y(airfoil_1D[0].back()(1))
213 , center_mesh(0.5 *
std::abs(end_b0_x_u + end_b0_x_l))
214 , length_b1_x(tail_x - center_mesh)
215 ,
gamma(std::atan(height /
216 (edge_length +
std::abs(nose_x - center_mesh))))
220 , A(nose_x - edge_length, 0)
223 , D(center_mesh, height)
225 ,
F(center_mesh, -height)
229 , J(tail_x + length_b2, 0)
233 Assert(data.airfoil_type ==
"Joukowski" ||
234 data.airfoil_type ==
"NACA",
247 make_coarse_grid(tria_grid);
249 set_boundary_ids(tria_grid);
251 if (periodic_faces !=
nullptr)
254 tria_grid, 5, 4, 1, *periodic_faces);
272 (void)periodic_faces;
279 const unsigned int refinements;
282 const unsigned int n_subdivision_x_0;
285 const unsigned int n_subdivision_x_1;
288 const unsigned int n_subdivision_x_2;
292 const unsigned int n_subdivision_y;
299 const double length_b2;
303 const double incline_factor;
306 const double bias_factor;
309 const double edge_length;
312 const unsigned int n_cells_x_0;
315 const unsigned int n_cells_x_1;
318 const unsigned int n_cells_x_2;
322 const unsigned int n_cells_y;
325 const unsigned int n_points_on_each_side;
329 const std::array<std::vector<Point<2>>, 2> airfoil_1D;
333 const double end_b0_x_u;
337 const double end_b0_x_l;
351 const double center_mesh;
354 const double length_b1_x;
381 const Point<2> A, B,
C, D,
E,
F, G, H, I, J, K, L;
420 static std::array<std::vector<Point<2>>, 2>
421 joukowski(
const Point<2> & centerpoint,
422 const unsigned int number_points,
423 const unsigned int factor)
425 std::array<std::vector<Point<2>>, 2> airfoil_1D;
426 const unsigned int total_points = 2 * number_points - 2;
427 const unsigned int n_airfoilpoints = factor * total_points;
429 const auto jouk_points =
430 joukowski_transform(joukowski_circle(centerpoint, n_airfoilpoints));
433 std::vector<Point<2>> upper_points;
434 std::vector<Point<2>> lower_points;
438 unsigned int nose_index = 0;
439 unsigned int tail_index = 0;
440 double nose_x_coordinate = 0;
441 double tail_x_coordinate = 0;
445 for (
unsigned int i = 0; i < jouk_points.size(); ++i)
447 if (jouk_points[i](0) < nose_x_coordinate)
449 nose_x_coordinate = jouk_points[i](0);
452 if (jouk_points[i](0) > tail_x_coordinate)
454 tail_x_coordinate = jouk_points[i](0);
460 for (
unsigned int i = tail_index; i < jouk_points.size(); ++i)
461 upper_points.emplace_back(jouk_points[i]);
462 for (
unsigned int i = 0; i <= nose_index; ++i)
463 upper_points.emplace_back(jouk_points[i]);
464 std::reverse(upper_points.begin(), upper_points.end());
467 lower_points.insert(lower_points.end(),
468 jouk_points.begin() + nose_index,
469 jouk_points.begin() + tail_index + 1);
472 airfoil_1D[0] = make_points_equidistant(upper_points, number_points);
473 airfoil_1D[1] = make_points_equidistant(lower_points, number_points);
476 auto move_nose_to_origin = [](std::vector<Point<2>> &vector) {
477 const double nose_x_pos = vector.front()(0);
478 for (
auto &i : vector)
482 move_nose_to_origin(airfoil_1D[1]);
483 move_nose_to_origin(airfoil_1D[0]);
512 static std::vector<Point<2>>
514 const unsigned int number_points)
516 std::vector<Point<2>> circle_points;
530 radius_test < radius,
532 "Error creating lower circle: Circle for Joukowski-transform does"
533 " not enclose point zeta = -1! Choose different center "
537 const double theta = 2 *
numbers::PI / number_points;
539 for (
unsigned int i = 0; i < number_points; ++i)
540 circle_points.emplace_back(
center[0] - radius *
cos(i * theta),
543 return circle_points;
554 static std::vector<Point<2>>
555 joukowski_transform(
const std::vector<
Point<2>> &circle_points)
557 std::vector<Point<2>> joukowski_points(circle_points.size());
560 for (
unsigned int i = 0; i < circle_points.size(); ++i)
562 const double chi = circle_points[i](0);
563 const double eta = circle_points[i](1);
564 const std::complex<double> zeta(chi, eta);
565 const std::complex<double> z = zeta + 1. / zeta;
567 joukowski_points[i] = {real(z), imag(z)};
569 return joukowski_points;
588 static std::array<std::vector<Point<2>>, 2>
589 naca(
const std::string &serialnumber,
590 const unsigned int number_points,
591 const unsigned int factor)
595 const unsigned int n_airfoilpoints = factor * number_points;
598 return {{make_points_equidistant(
599 naca_create_points(serialnumber, n_airfoilpoints,
true),
601 make_points_equidistant(
602 naca_create_points(serialnumber, n_airfoilpoints,
false),
617 static std::vector<Point<2>>
618 naca_create_points(
const std::string &serialnumber,
619 const unsigned int number_points,
622 Assert(serialnumber.size() == 4,
623 ExcMessage(
"This NACA-serial number is not implemented!"));
625 return naca_create_points_4_digits(serialnumber,
644 static std::vector<Point<2>>
645 naca_create_points_4_digits(
const std::string &serialnumber,
646 const unsigned int number_points,
650 const unsigned int digit_0 = (serialnumber[0] -
'0');
651 const unsigned int digit_1 = (serialnumber[1] -
'0');
652 const unsigned int digit_2 = (serialnumber[2] -
'0');
653 const unsigned int digit_3 = (serialnumber[3] -
'0');
655 const unsigned int digit_23 = 10 * digit_2 + digit_3;
658 const double t =
static_cast<double>(digit_23) / 100.0;
660 std::vector<Point<2>> naca_points;
662 if (digit_0 == 0 && digit_1 == 0)
663 for (
unsigned int i = 0; i < number_points; ++i)
665 const double x = i * 1 / (1.0 * number_points - 1);
668 (0.2969 *
std::pow(x, 0.5) - 0.126 * x -
673 naca_points.emplace_back(x, +y_t);
675 naca_points.emplace_back(x, -y_t);
678 for (
unsigned int i = 0; i < number_points; ++i)
680 const double m = 1.0 * digit_0 / 100;
681 const double p = 1.0 * digit_1 / 10;
682 const double x = i * 1 / (1.0 * number_points - 1);
687 ((1 - 2 * p) + 2 * p * x -
std::pow(x, 2));
689 const double dy_c = (x <= p) ?
691 2 * m /
std::pow(1 - p, 2) * (p - x);
695 (0.2969 *
std::pow(x, 0.5) - 0.126 * x -
699 const double theta = std::atan(dy_c);
702 naca_points.emplace_back(x - y_t *
std::sin(theta),
705 naca_points.emplace_back(x + y_t *
std::sin(theta),
722 static std::array<std::vector<Point<2>>, 2>
723 set_airfoil_length(
const std::array<std::vector<
Point<2>>, 2> &input,
724 const double desired_len)
726 std::array<std::vector<Point<2>>, 2> output;
727 output[0] = set_airfoil_length(input[0], desired_len);
728 output[1] = set_airfoil_length(input[1], desired_len);
740 static std::vector<Point<2>>
741 set_airfoil_length(
const std::vector<
Point<2>> &input,
742 const double desired_len)
744 std::vector<Point<2>> output = input;
747 desired_len / input.front().distance(input.back());
749 for (
auto &x : output)
765 static std::vector<Point<2>>
766 make_points_equidistant(
767 const std::vector<
Point<2>> &non_equidistant_points,
768 const unsigned int number_points)
770 const unsigned int n_points =
771 non_equidistant_points
775 std::vector<double> arclength_L(non_equidistant_points.size(), 0);
776 for (
unsigned int i = 0; i < non_equidistant_points.size() - 1; ++i)
779 non_equidistant_points[i + 1].distance(non_equidistant_points[i]);
782 const auto airfoil_length =
784 const auto deltaX = airfoil_length / (number_points - 1);
788 std::vector<Point<2>> equidist(
791 equidist[0] = non_equidistant_points[0];
792 equidist[number_points - 1] = non_equidistant_points[n_points - 1];
796 for (
unsigned int j = 0, i = 1; j < n_points - 1; ++j)
799 const auto Lj = arclength_L[j];
800 const auto Ljp = arclength_L[j + 1];
802 while (Lj <= i * deltaX && i * deltaX <= Ljp &&
803 i < number_points - 1)
805 equidist[i] =
Point<2>((i * deltaX - Lj) / (Ljp - Lj) *
806 (non_equidistant_points[j + 1] -
807 non_equidistant_points[j]) +
808 non_equidistant_points[j]);
828 std::vector<Triangulation<2>> trias(10);
832 const std::vector<Point<2>> & corner_vertices,
833 const std::vector<unsigned int> &repetitions,
845 auto &
point = it->vertex();
846 const double xi =
point(0);
847 const double eta =
point(1);
850 point = 0.25 * ((1 - xi) * (1 - eta) * corner_vertices[0] +
851 (1 + xi) * (1 - eta) * corner_vertices[1] +
852 (1 - xi) * (1 + eta) * corner_vertices[2] +
853 (1 + xi) * (1 + eta) * corner_vertices[3]);
858 cell->set_material_id(material_id);
865 {n_subdivision_y, n_subdivision_x_0},
869 {n_subdivision_y, n_subdivision_x_0},
873 {n_subdivision_x_1, n_subdivision_y},
877 {n_subdivision_x_1, n_subdivision_y},
881 {n_subdivision_x_2, n_subdivision_y},
885 {n_subdivision_x_2, n_subdivision_y},
915 if (cell->face(f)->at_boundary() ==
false)
918 const auto mid = cell->material_id();
920 if ((mid == id_block_1 && f == 0) ||
921 (mid == id_block_4 && f == 0))
922 cell->face(f)->set_boundary_id(0);
923 else if ((mid == id_block_3 && f == 0) ||
924 (mid == id_block_6 && f == 2))
925 cell->face(f)->set_boundary_id(1);
926 else if ((mid == id_block_1 && f == 1) ||
927 (mid == id_block_2 && f == 1))
928 cell->face(f)->set_boundary_id(2);
929 else if ((mid == id_block_4 && f == 1) ||
930 (mid == id_block_5 && f == 3))
931 cell->face(f)->set_boundary_id(3);
932 else if ((mid == id_block_2 && f == 0) ||
933 (mid == id_block_3 && f == 2))
934 cell->face(f)->set_boundary_id(4);
935 else if ((mid == id_block_5 && f == 2) ||
936 (mid == id_block_6 && f == 0))
937 cell->face(f)->set_boundary_id(5);
974 for (
auto &cell :
tria)
978 if (vertex_processed[cell.vertex_index(v)])
982 vertex_processed[cell.vertex_index(v)] =
true;
984 auto &node = cell.vertex(v);
987 if (cell.material_id() == id_block_1 ||
988 cell.material_id() == id_block_4)
997 if (cell.material_id() == id_block_1)
1000 (node - horizontal_offset) +
1006 else if (cell.material_id() == id_block_4)
1009 (node - horizontal_offset) -
1015 const double trapeze_height =
1017 const double L = height /
std::sin(gamma);
1018 const double l_a =
std::cos(gamma) * edge_length;
1019 const double l_b = trapeze_height *
std::tan(gamma);
1021 const double x2 = L - l_a - l_b;
1023 const double Dx = x1 + x2 + x3;
1024 const double deltax =
1026 const double dx = Dx / n_cells_x_0;
1027 const double dy = trapeze_height / n_cells_y;
1029 static_cast<int>(std::round((node_(0) - deltax) / dx));
1031 static_cast<int>(std::round(
std::abs(node_(1)) / dy));
1033 node_(0) =
numbers::PI / 2 * (1.0 * ix) / n_cells_x_0;
1034 node_(1) = height * (1.0 * iy) / n_cells_y;
1041 const double dy = height / n_cells_y;
1043 static_cast<int>(std::round(node_(0) / dx));
1045 static_cast<int>(std::round(node_(1) / dy));
1046 const double alpha =
1047 bias_alpha(1 - (1.0 * iy) / n_cells_y);
1048 const double theta = node_(0);
1050 ((cell.material_id() == id_block_1) ?
1056 (cell.material_id() == id_block_1) ? (0) : (1))][ix] *
1061 else if (cell.material_id() == id_block_2 ||
1062 cell.material_id() == id_block_5)
1070 "Points D,C,G and E,F,I are not defined symmetric to "
1071 "x-axis, which is required to interpolate block 2"
1072 " and 5 with same geometric computations."));
1073 const double l_y = D(1) -
C(1);
1074 const double l_h = D(1) - l_y;
1075 const double by = -l_h / length_b1_x * (node(0) - H(0));
1076 const double dy = (height - by) / n_cells_y;
1077 const int iy =
static_cast<int>(
1078 std::round((
std::abs(node(1)) - by) / dy));
1079 const double dx = length_b1_x / n_cells_x_1;
1080 const int ix =
static_cast<int>(
1081 std::round(
std::abs(node(0) - center_mesh) / dx));
1083 const double alpha = bias_alpha(1 - (1.0 * iy) / n_cells_y);
1087 const Point<2> p(ix * dx + center_mesh +
1088 incline_factor * length_b2 * ix /
1090 ((cell.material_id() == id_block_2) ?
1096 (cell.material_id() == id_block_2) ? (0) : (1))]
1097 [n_cells_x_0 + ix] *
1101 else if (cell.material_id() == id_block_3 ||
1102 cell.material_id() == id_block_6)
1105 const double dx = length_b2 / n_cells_x_2;
1106 const double dy = height / n_cells_y;
1107 const int ix =
static_cast<int>(
1108 std::round(
std::abs(node(0) - H(0)) / dx));
1110 static_cast<int>(std::round(
std::abs(node(1)) / dy));
1112 const double alpha_y = bias_alpha(1 - 1.0 * iy / n_cells_y);
1113 const double alpha_x =
1114 bias_alpha(1 - (
static_cast<double>(ix)) / n_cells_x_2);
1118 const Point<2> p1(J(0) - (1 - incline_factor) * length_b2 *
1120 ((cell.material_id() == id_block_3) ?
1125 const Point<2> p2(J(0) - alpha_x * length_b2, tail_y);
1126 node = p1 * (1 - alpha_y) + p2 * alpha_y;
1146 bias_alpha(
double alpha)
const
1148 return std::tanh(bias_factor * alpha) / std::tanh(bias_factor);
1156 internal_create_triangulation(
1160 const AdditionalData & additional_data)
1162 MeshGenerator mesh_generator(additional_data);
1165 if (
auto parallel_tria =
1168 mesh_generator.create_triangulation(*parallel_tria, periodic_faces);
1169 else if (
auto parallel_tria =
dynamic_cast<
1172 mesh_generator.create_triangulation(*parallel_tria, periodic_faces);
1174 mesh_generator.create_triangulation(
tria, periodic_faces);
1191 const AdditionalData &)
1201 const AdditionalData &additional_data)
1203 internal_create_triangulation(
tria,
nullptr, additional_data);
1214 const AdditionalData & additional_data)
1216 internal_create_triangulation(
tria, &periodic_faces, additional_data);
1227 const AdditionalData & additional_data)
1231 (void)additional_data;
1232 (void)periodic_faces;
1243 template <
int dim,
int spacedim>
1255 cell->face(f)->set_boundary_id(f);
1261 template <
int spacedim>
1272 if (cell->center()(0) > 0)
1273 cell->set_material_id(1);
1280 template <
int dim,
int spacedim>
1285 const double epsilon)
1298 for (; face != endface; ++face)
1299 if (face->at_boundary())
1300 if (face->boundary_id() == 0)
1305 face->set_boundary_id(0);
1307 face->set_boundary_id(1);
1309 face->set_boundary_id(2);
1311 face->set_boundary_id(3);
1313 face->set_boundary_id(4);
1315 face->set_boundary_id(5);
1327 for (
unsigned int d = 0;
d < dim; ++
d)
1328 if (cell->center()(d) > 0)
1330 cell->set_material_id(
id);
1356 cell->face(2)->set_all_boundary_ids(1);
1380 cell->face(4)->set_all_boundary_ids(1);
1384 cell->face(2)->set_all_boundary_ids(1);
1388 cell->face(2)->set_all_boundary_ids(1);
1392 cell->face(0)->set_all_boundary_ids(1);
1396 cell->face(2)->set_all_boundary_ids(1);
1400 cell->face(0)->set_all_boundary_ids(1);
1411 cell->face(5)->set_all_boundary_ids(1);
1427 unsigned int count = 0;
1431 if (cell->face(5)->at_boundary())
1433 cell->face(5)->set_all_boundary_ids(1);
1452 const double inner_radius,
1453 const double outer_radius)
1458 double middle = (outer_radius - inner_radius) / 2e0 + inner_radius;
1459 double eps = 1
e-3 * middle;
1462 for (; cell !=
tria.
end(); ++cell)
1465 if (!cell->face(f)->at_boundary())
1468 double radius = cell->face(f)->center().norm() -
center.
norm();
1469 if (std::fabs(cell->face(f)->center()(0)) <
1472 cell->face(f)->set_boundary_id(2);
1473 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
1475 if (cell->face(f)->line(j)->at_boundary())
1476 if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() -
1477 cell->face(f)->line(j)->vertex(1).norm()) >
1479 cell->face(f)->line(j)->set_boundary_id(2);
1481 else if (std::fabs(cell->face(f)->center()(1)) <
1484 cell->face(f)->set_boundary_id(3);
1485 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
1487 if (cell->face(f)->line(j)->at_boundary())
1488 if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() -
1489 cell->face(f)->line(j)->vertex(1).norm()) >
1491 cell->face(f)->line(j)->set_boundary_id(3);
1493 else if (std::fabs(cell->face(f)->center()(2)) <
1496 cell->face(f)->set_boundary_id(4);
1497 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
1499 if (cell->face(f)->line(j)->at_boundary())
1500 if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() -
1501 cell->face(f)->line(j)->vertex(1).norm()) >
1503 cell->face(f)->line(j)->set_boundary_id(4);
1505 else if (radius < middle)
1507 cell->face(f)->set_boundary_id(0);
1508 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
1510 if (cell->face(f)->line(j)->at_boundary())
1511 if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() -
1512 cell->face(f)->line(j)->vertex(1).norm()) <
1514 cell->face(f)->line(j)->set_boundary_id(0);
1516 else if (radius > middle)
1518 cell->face(f)->set_boundary_id(1);
1519 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
1521 if (cell->face(f)->line(j)->at_boundary())
1522 if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() -
1523 cell->face(f)->line(j)->vertex(1).norm()) <
1525 cell->face(f)->line(j)->set_boundary_id(1);
1535 template <
int dim,
int spacedim>
1546 for (
unsigned int i = 0; i < dim; ++i)
1586 std::vector<CellData<dim>> cells(1);
1588 cells[0].vertices[i] = i;
1589 cells[0].material_id = 0;
1595 colorize_hyper_rectangle(
tria);
1600 template <
int dim,
int spacedim>
1608 ExcMessage(
"Invalid left-to-right bounds of hypercube"));
1611 for (
unsigned int i = 0; i < dim; ++i)
1631 for (
unsigned int d = 0;
d < dim; ++
d)
1632 for (
unsigned int c = 1; c <= dim; ++c)
1635 ExcMessage(
"Vertices of simplex must form a right handed system"));
1639 std::vector<Point<dim>> points =
vertices;
1643 for (
unsigned int i = 0; i <= dim; ++i)
1645 points.push_back(0.5 * (points[i] + points[(i + 1) % (dim + 1)]));
1651 for (
unsigned int i = 1; i < dim; ++i)
1652 points.push_back(0.5 * (points[i - 1] + points[i + 1]));
1654 for (
unsigned int i = 0; i <= dim; ++i)
1655 points.push_back(1. / 3. *
1656 (points[i] + points[(i + 1) % (dim + 1)] +
1657 points[(i + 2) % (dim + 1)]));
1659 points.push_back((1. / (dim + 1)) *
center);
1661 std::vector<CellData<dim>> cells(dim + 1);
1666 cells[0].vertices[0] = 0;
1667 cells[0].vertices[1] = 3;
1668 cells[0].vertices[2] = 5;
1669 cells[0].vertices[3] = 6;
1670 cells[0].material_id = 0;
1672 cells[1].vertices[0] = 3;
1673 cells[1].vertices[1] = 1;
1674 cells[1].vertices[2] = 6;
1675 cells[1].vertices[3] = 4;
1676 cells[1].material_id = 0;
1678 cells[2].vertices[0] = 5;
1679 cells[2].vertices[1] = 6;
1680 cells[2].vertices[2] = 2;
1681 cells[2].vertices[3] = 4;
1682 cells[2].material_id = 0;
1686 cells[0].vertices[0] = 0;
1687 cells[0].vertices[1] = 4;
1688 cells[0].vertices[2] = 8;
1689 cells[0].vertices[3] = 10;
1690 cells[0].vertices[4] = 7;
1691 cells[0].vertices[5] = 13;
1692 cells[0].vertices[6] = 12;
1693 cells[0].vertices[7] = 14;
1694 cells[0].material_id = 0;
1696 cells[1].vertices[0] = 4;
1697 cells[1].vertices[1] = 1;
1698 cells[1].vertices[2] = 10;
1699 cells[1].vertices[3] = 5;
1700 cells[1].vertices[4] = 13;
1701 cells[1].vertices[5] = 9;
1702 cells[1].vertices[6] = 14;
1703 cells[1].vertices[7] = 11;
1704 cells[1].material_id = 0;
1706 cells[2].vertices[0] = 8;
1707 cells[2].vertices[1] = 10;
1708 cells[2].vertices[2] = 2;
1709 cells[2].vertices[3] = 5;
1710 cells[2].vertices[4] = 12;
1711 cells[2].vertices[5] = 14;
1712 cells[2].vertices[6] = 6;
1713 cells[2].vertices[7] = 11;
1714 cells[2].material_id = 0;
1716 cells[3].vertices[0] = 7;
1717 cells[3].vertices[1] = 13;
1718 cells[3].vertices[2] = 12;
1719 cells[3].vertices[3] = 14;
1720 cells[3].vertices[4] = 3;
1721 cells[3].vertices[5] = 9;
1722 cells[3].vertices[6] = 6;
1723 cells[3].vertices[7] = 11;
1724 cells[3].material_id = 0;
1734 template <
int dim,
int spacedim>
1741 if (reference_cell == ReferenceCells::get_hypercube<dim>())
1754 for (
unsigned int d = 0;
d < dim; ++
d)
1763 std::vector<CellData<dim>> cells(1);
1766 cells[0].vertices[v] = v;
1775 const unsigned int n_cells,
1776 const unsigned int n_rotations,
1780 const unsigned int dim = 3;
1783 "More than 4 cells are needed to create a moebius grid."));
1785 ExcMessage(
"Outer and inner radius must be positive."));
1787 ExcMessage(
"Outer radius must be greater than inner radius."));
1790 std::vector<Point<dim>>
vertices(4 * n_cells);
1794 for (
unsigned int i = 0; i <
n_cells; ++i)
1795 for (
unsigned int j = 0; j < 4; ++j)
1809 unsigned int offset = 0;
1814 std::vector<CellData<dim>> cells(n_cells);
1815 for (
unsigned int i = 0; i <
n_cells; ++i)
1817 for (
unsigned int j = 0; j < 2; ++j)
1829 cells[i].material_id = 0;
1834 (0 + n_rotations) % 4;
1836 (3 + n_rotations) % 4;
1838 (2 + n_rotations) % 4;
1840 (1 + n_rotations) % 4;
1857 ExcMessage(
"Outer radius R must be greater than the inner "
1861 const unsigned int dim = 2;
1862 const unsigned int spacedim = 3;
1863 std::vector<Point<spacedim>>
vertices(16);
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;
1994 const unsigned int n_cells_toroidal,
1998 ExcMessage(
"Outer radius R must be greater than the inner "
2001 Assert(n_cells_toroidal > 2,
2002 ExcMessage(
"Number of cells in toroidal direction has "
2003 "to be at least 3."));
2009 double const a = 1. / (1 +
std::sqrt(2.0));
2012 const unsigned int additional_layer =
2016 const unsigned int n_point_layers_toroidal =
2017 n_cells_toroidal + additional_layer;
2018 std::vector<Point<3>>
vertices(8 * n_point_layers_toroidal);
2030 double const phi_cell = phi / n_cells_toroidal;
2031 for (
unsigned int c = 1; c < n_point_layers_toroidal; ++c)
2033 for (
unsigned int v = 0; v < 8; ++v)
2035 double const r_2d =
vertices[v][0];
2043 std::vector<CellData<3>> cells(5 * n_cells_toroidal);
2044 for (
unsigned int c = 0; c < n_cells_toroidal; ++c)
2046 for (
unsigned int j = 0; j < 2; ++j)
2048 const unsigned int offset =
2049 (8 * (c + j)) % (8 * n_point_layers_toroidal);
2052 cells[5 * c].vertices[0 + j * 4] = offset + 0;
2053 cells[5 * c].vertices[1 + j * 4] = offset + 1;
2054 cells[5 * c].vertices[2 + j * 4] = offset + 2;
2055 cells[5 * c].vertices[3 + j * 4] = offset + 3;
2057 cells[5 * c + 1].vertices[0 + j * 4] = offset + 2;
2058 cells[5 * c + 1].vertices[1 + j * 4] = offset + 3;
2059 cells[5 * c + 1].vertices[2 + j * 4] = offset + 4;
2060 cells[5 * c + 1].vertices[3 + j * 4] = offset + 5;
2062 cells[5 * c + 2].vertices[0 + j * 4] = offset + 4;
2063 cells[5 * c + 2].vertices[1 + j * 4] = offset + 5;
2064 cells[5 * c + 2].vertices[2 + j * 4] = offset + 6;
2065 cells[5 * c + 2].vertices[3 + j * 4] = offset + 7;
2067 cells[5 * c + 3].vertices[0 + j * 4] = offset + 0;
2068 cells[5 * c + 3].vertices[1 + j * 4] = offset + 2;
2069 cells[5 * c + 3].vertices[2 + j * 4] = offset + 6;
2070 cells[5 * c + 3].vertices[3 + j * 4] = offset + 4;
2072 cells[5 * c + 4].vertices[0 + j * 4] = offset + 3;
2073 cells[5 * c + 4].vertices[1 + j * 4] = offset + 1;
2074 cells[5 * c + 4].vertices[2 + j * 4] = offset + 5;
2075 cells[5 * c + 4].vertices[3 + j * 4] = offset + 7;
2078 cells[5 * c].material_id = 0;
2080 cells[5 * c + 1].material_id = 1;
2081 cells[5 * c + 2].material_id = 0;
2082 cells[5 * c + 3].material_id = 0;
2083 cells[5 * c + 4].material_id = 0;
2098 if (cell->face(f)->at_boundary() && f != 4 && f != 5)
2100 cell->face(f)->set_all_manifold_ids(1);
2105 if (cell->material_id() == 1)
2107 cell->set_all_manifold_ids(2);
2109 cell->set_material_id(0);
2124 template <
int dim,
int spacedim>
2145 "The volume of the cell is not greater than zero. "
2146 "This could be due to the wrong ordering of the vertices."));
2177 std::array<Tensor<1, 2>, 2> edges;
2178 edges[0] = corners[0];
2179 edges[1] = corners[1];
2180 std::vector<unsigned int> subdivisions;
2181 subdivided_parallelepiped<2, 2>(
2193 unsigned int n_subdivisions[dim];
2194 for (
unsigned int i = 0; i < dim; ++i)
2195 n_subdivisions[i] = 1;
2204 const unsigned int n_subdivisions,
2210 unsigned int n_subdivisions_[dim];
2211 for (
unsigned int i = 0; i < dim; ++i)
2212 n_subdivisions_[i] = n_subdivisions;
2222 const unsigned int (&n_subdivisions)[dim],
2224 const unsigned int *n_subdivisions,
2230 std::vector<unsigned int> subdivisions;
2231 std::array<Tensor<1, dim>, dim> edges;
2232 for (
unsigned int i = 0; i < dim; ++i)
2234 subdivisions.push_back(n_subdivisions[i]);
2235 edges[i] = corners[i];
2238 subdivided_parallelepiped<dim, dim>(
2245 template <
int dim,
int spacedim>
2250 const std::vector<unsigned int> &subdivisions,
2253 std::vector<unsigned int> compute_subdivisions = subdivisions;
2254 if (compute_subdivisions.size() == 0)
2256 compute_subdivisions.resize(dim, 1);
2259 Assert(compute_subdivisions.size() == dim,
2260 ExcMessage(
"One subdivision must be provided for each dimension."));
2262 for (
unsigned int i = 0; i < dim; ++i)
2264 Assert(compute_subdivisions[i] > 0,
2265 ExcInvalidRepetitions(subdivisions[i]));
2267 edges[i].
norm() > 0,
2269 "Edges in subdivided_parallelepiped() must not be degenerate."));
2277 bool twisted_data =
false;
2282 twisted_data = (edges[0][0] < 0);
2289 const double plane_normal =
2290 edges[0][0] * edges[1][1] - edges[0][1] * edges[1][0];
2291 twisted_data = (plane_normal < 0.0);
2300 (edges[0].
norm() * edges[1].
norm()) -
2303 "Edges in subdivided_parallelepiped() must point in"
2304 " different directions."));
2320 twisted_data = (plane_normal * edges[2] < 0.0);
2329 ExcInvalidInputOrientation(
2330 "The triangulation you are trying to create will consist of cells"
2331 " with negative measures. This is usually the result of input data"
2332 " that does not define a right-handed coordinate system. The usual"
2333 " fix for this is to ensure that in 1D the given point is to the"
2334 " right of the origin (or the given edge tensor is positive), in 2D"
2335 " that the two edges (and their cross product) obey the right-hand"
2336 " rule (which may usually be done by switching the order of the"
2337 " points or edge tensors), or in 3D that the edges form a"
2338 " right-handed coordinate system (which may also be accomplished by"
2339 " switching the order of the first two points or edge tensors)."));
2342 for (
unsigned int i = 0; i < dim; ++i)
2343 for (
unsigned int j = i + 1; j < dim; ++j)
2344 Assert((edges[i] != edges[j]),
2346 "Degenerate edges of subdivided_parallelepiped encountered."));
2349 std::vector<Point<spacedim>> points;
2354 for (
unsigned int x = 0; x <= compute_subdivisions[0]; ++x)
2355 points.push_back(origin + edges[0] / compute_subdivisions[0] * x);
2359 for (
unsigned int y = 0; y <= compute_subdivisions[1]; ++y)
2360 for (
unsigned int x = 0; x <= compute_subdivisions[0]; ++x)
2361 points.push_back(origin + edges[0] / compute_subdivisions[0] * x +
2362 edges[1] / compute_subdivisions[1] * y);
2366 for (
unsigned int z = 0; z <= compute_subdivisions[2]; ++z)
2367 for (
unsigned int y = 0; y <= compute_subdivisions[1]; ++y)
2368 for (
unsigned int x = 0; x <= compute_subdivisions[0]; ++x)
2369 points.push_back(origin +
2370 edges[0] / compute_subdivisions[0] * x +
2371 edges[1] / compute_subdivisions[1] * y +
2372 edges[2] / compute_subdivisions[2] * z);
2381 for (
unsigned int i = 0; i < dim; ++i)
2382 n_cells *= compute_subdivisions[i];
2383 std::vector<CellData<dim>> cells(n_cells);
2389 for (
unsigned int x = 0; x < compute_subdivisions[0]; ++x)
2391 cells[x].vertices[0] = x;
2392 cells[x].vertices[1] = x + 1;
2395 cells[x].material_id = 0;
2402 const unsigned int n_dy = compute_subdivisions[1];
2403 const unsigned int n_dx = compute_subdivisions[0];
2405 for (
unsigned int y = 0; y < n_dy; ++y)
2406 for (
unsigned int x = 0; x < n_dx; ++x)
2408 const unsigned int c = y * n_dx + x;
2409 cells[c].vertices[0] = y * (n_dx + 1) + x;
2410 cells[c].vertices[1] = y * (n_dx + 1) + x + 1;
2411 cells[c].vertices[2] = (y + 1) * (n_dx + 1) + x;
2412 cells[c].vertices[3] = (y + 1) * (n_dx + 1) + x + 1;
2415 cells[c].material_id = 0;
2423 const unsigned int n_dz = compute_subdivisions[2];
2424 const unsigned int n_dy = compute_subdivisions[1];
2425 const unsigned int n_dx = compute_subdivisions[0];
2427 for (
unsigned int z = 0; z < n_dz; ++z)
2428 for (
unsigned int y = 0; y < n_dy; ++y)
2429 for (
unsigned int x = 0; x < n_dx; ++x)
2431 const unsigned int c = z * n_dy * n_dx + y * n_dx + x;
2433 cells[c].vertices[0] =
2434 z * (n_dy + 1) * (n_dx + 1) + y * (n_dx + 1) + x;
2435 cells[c].vertices[1] =
2436 z * (n_dy + 1) * (n_dx + 1) + y * (n_dx + 1) + x + 1;
2437 cells[c].vertices[2] =
2438 z * (n_dy + 1) * (n_dx + 1) + (y + 1) * (n_dx + 1) + x;
2439 cells[c].vertices[3] = z * (n_dy + 1) * (n_dx + 1) +
2440 (y + 1) * (n_dx + 1) + x + 1;
2441 cells[c].vertices[4] =
2442 (z + 1) * (n_dy + 1) * (n_dx + 1) + y * (n_dx + 1) + x;
2443 cells[c].vertices[5] = (z + 1) * (n_dy + 1) * (n_dx + 1) +
2444 y * (n_dx + 1) + x + 1;
2445 cells[c].vertices[6] = (z + 1) * (n_dy + 1) * (n_dx + 1) +
2446 (y + 1) * (n_dx + 1) + x;
2447 cells[c].vertices[7] = (z + 1) * (n_dy + 1) * (n_dx + 1) +
2448 (y + 1) * (n_dx + 1) + x + 1;
2451 cells[c].material_id = 0;
2472 for (; cell != endc; ++cell)
2476 if (cell->face(face)->at_boundary())
2477 cell->face(face)->set_boundary_id(face);
2484 template <
int dim,
int spacedim>
2487 const unsigned int repetitions,
2492 Assert(repetitions >= 1, ExcInvalidRepetitions(repetitions));
2494 ExcMessage(
"Invalid left-to-right bounds of hypercube"));
2497 for (
unsigned int i = 0; i < dim; ++i)
2503 std::vector<unsigned int> reps(dim, repetitions);
2509 template <
int dim,
int spacedim>
2512 const std::vector<unsigned int> &repetitions,
2517 Assert(repetitions.size() == dim, ExcInvalidRepetitionsDimension(dim));
2523 for (
unsigned int i = 0; i < dim; ++i)
2530 std::array<Point<spacedim>, dim> delta;
2531 for (
unsigned int i = 0; i < dim; ++i)
2533 Assert(repetitions[i] >= 1, ExcInvalidRepetitions(repetitions[i]));
2535 delta[i][i] = (p2[i] - p1[i]) / repetitions[i];
2539 "The first dim entries of coordinates of p1 and p2 need to be different."));
2543 std::vector<Point<spacedim>> points;
2547 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
2548 points.push_back(p1 + x * delta[0]);
2552 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
2553 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
2554 points.push_back(p1 + x * delta[0] + y * delta[1]);
2558 for (
unsigned int z = 0; z <= repetitions[2]; ++z)
2559 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
2560 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
2561 points.push_back(p1 + x * delta[0] + y * delta[1] +
2570 std::vector<CellData<dim>> cells;
2575 cells.resize(repetitions[0]);
2576 for (
unsigned int x = 0; x < repetitions[0]; ++x)
2578 cells[x].vertices[0] = x;
2579 cells[x].vertices[1] = x + 1;
2580 cells[x].material_id = 0;
2587 cells.resize(repetitions[1] * repetitions[0]);
2588 for (
unsigned int y = 0; y < repetitions[1]; ++y)
2589 for (
unsigned int x = 0; x < repetitions[0]; ++x)
2591 const unsigned int c = x + y * repetitions[0];
2592 cells[c].vertices[0] = y * (repetitions[0] + 1) + x;
2593 cells[c].vertices[1] = y * (repetitions[0] + 1) + x + 1;
2594 cells[c].vertices[2] = (y + 1) * (repetitions[0] + 1) + x;
2595 cells[c].vertices[3] = (y + 1) * (repetitions[0] + 1) + x + 1;
2596 cells[c].material_id = 0;
2603 const unsigned int n_x = (repetitions[0] + 1);
2604 const unsigned int n_xy =
2605 (repetitions[0] + 1) * (repetitions[1] + 1);
2607 cells.resize(repetitions[2] * repetitions[1] * repetitions[0]);
2608 for (
unsigned int z = 0; z < repetitions[2]; ++z)
2609 for (
unsigned int y = 0; y < repetitions[1]; ++y)
2610 for (
unsigned int x = 0; x < repetitions[0]; ++x)
2612 const unsigned int c = x + y * repetitions[0] +
2613 z * repetitions[0] * repetitions[1];
2614 cells[c].vertices[0] = z * n_xy + y * n_x + x;
2615 cells[c].vertices[1] = z * n_xy + y * n_x + x + 1;
2616 cells[c].vertices[2] = z * n_xy + (y + 1) * n_x + x;
2617 cells[c].vertices[3] = z * n_xy + (y + 1) * n_x + x + 1;
2618 cells[c].vertices[4] = (z + 1) * n_xy + y * n_x + x;
2619 cells[c].vertices[5] = (z + 1) * n_xy + y * n_x + x + 1;
2620 cells[c].vertices[6] = (z + 1) * n_xy + (y + 1) * n_x + x;
2621 cells[c].vertices[7] =
2622 (z + 1) * n_xy + (y + 1) * n_x + x + 1;
2623 cells[c].material_id = 0;
2645 for (
unsigned int i = 0; i < dim; ++i)
2646 epsilon =
std::min(epsilon, 0.01 * delta[i][i]);
2649 "The distance between corner points must be positive."))
2653 colorize_subdivided_hyper_rectangle(
tria, p1, p2, epsilon);
2662 const
std::vector<
std::vector<
double>> &step_sz,
2663 const
Point<dim> & p_1,
2664 const
Point<dim> & p_2,
2667 Assert(step_sz.size() == dim, ExcInvalidRepetitionsDimension(dim));
2677 std::vector<std::vector<double>> step_sizes(step_sz);
2679 for (
unsigned int i = 0; i < dim; ++i)
2683 std::swap(p1(i), p2(i));
2684 std::reverse(step_sizes[i].
begin(), step_sizes[i].
end());
2689 for (
unsigned int j = 0; j < step_sizes.at(i).size(); ++j)
2690 x += step_sizes[i][j];
2691 Assert(std::fabs(x - (p2(i) - p1(i))) <= 1e-12 * std::fabs(x),
2693 "The sequence of step sizes in coordinate direction " +
2695 " must be equal to the distance of the two given "
2696 "points in this coordinate direction."));
2703 std::vector<Point<dim>> points;
2709 for (
unsigned int i = 0;; ++i)
2718 if (i == step_sizes[0].size())
2721 x += step_sizes[0][i];
2729 for (
unsigned int j = 0;; ++j)
2732 for (
unsigned int i = 0;; ++i)
2734 points.push_back(
Point<dim>(p1[0] + x, p1[1] + y));
2735 if (i == step_sizes[0].size())
2738 x += step_sizes[0][i];
2741 if (j == step_sizes[1].size())
2744 y += step_sizes[1][j];
2751 for (
unsigned int k = 0;; ++k)
2754 for (
unsigned int j = 0;; ++j)
2757 for (
unsigned int i = 0;; ++i)
2760 Point<dim>(p1[0] + x, p1[1] + y, p1[2] + z));
2761 if (i == step_sizes[0].size())
2764 x += step_sizes[0][i];
2767 if (j == step_sizes[1].size())
2770 y += step_sizes[1][j];
2773 if (k == step_sizes[2].size())
2776 z += step_sizes[2][k];
2787 std::vector<CellData<dim>> cells;
2792 cells.resize(step_sizes[0].size());
2793 for (
unsigned int x = 0; x < step_sizes[0].size(); ++x)
2795 cells[x].vertices[0] = x;
2796 cells[x].vertices[1] = x + 1;
2797 cells[x].material_id = 0;
2804 cells.resize(step_sizes[1].size() * step_sizes[0].size());
2805 for (
unsigned int y = 0; y < step_sizes[1].size(); ++y)
2806 for (
unsigned int x = 0; x < step_sizes[0].size(); ++x)
2808 const unsigned int c = x + y * step_sizes[0].size();
2809 cells[c].vertices[0] = y * (step_sizes[0].size() + 1) + x;
2810 cells[c].vertices[1] = y * (step_sizes[0].size() + 1) + x + 1;
2811 cells[c].vertices[2] =
2812 (y + 1) * (step_sizes[0].size() + 1) + x;
2813 cells[c].vertices[3] =
2814 (y + 1) * (step_sizes[0].size() + 1) + x + 1;
2815 cells[c].material_id = 0;
2822 const unsigned int n_x = (step_sizes[0].size() + 1);
2823 const unsigned int n_xy =
2824 (step_sizes[0].size() + 1) * (step_sizes[1].size() + 1);
2826 cells.resize(step_sizes[2].size() * step_sizes[1].size() *
2827 step_sizes[0].size());
2828 for (
unsigned int z = 0; z < step_sizes[2].size(); ++z)
2829 for (
unsigned int y = 0; y < step_sizes[1].size(); ++y)
2830 for (
unsigned int x = 0; x < step_sizes[0].size(); ++x)
2832 const unsigned int c =
2833 x + y * step_sizes[0].size() +
2834 z * step_sizes[0].size() * step_sizes[1].size();
2835 cells[c].vertices[0] = z * n_xy + y * n_x + x;
2836 cells[c].vertices[1] = z * n_xy + y * n_x + x + 1;
2837 cells[c].vertices[2] = z * n_xy + (y + 1) * n_x + x;
2838 cells[c].vertices[3] = z * n_xy + (y + 1) * n_x + x + 1;
2839 cells[c].vertices[4] = (z + 1) * n_xy + y * n_x + x;
2840 cells[c].vertices[5] = (z + 1) * n_xy + y * n_x + x + 1;
2841 cells[c].vertices[6] = (z + 1) * n_xy + (y + 1) * n_x + x;
2842 cells[c].vertices[7] =
2843 (z + 1) * n_xy + (y + 1) * n_x + x + 1;
2844 cells[c].material_id = 0;
2866 *std::min_element(step_sizes[0].
begin(), step_sizes[0].
end());
2867 for (
unsigned int i = 1; i < dim; ++i)
2869 *std::min_element(step_sizes[i].
begin(),
2870 step_sizes[i].
end()));
2871 const double epsilon = 0.01 * min_size;
2875 colorize_subdivided_hyper_rectangle(
tria, p1, p2, epsilon);
2884 const std::vector<std::vector<double>> &spacing,
2889 Assert(spacing.size() == 1, ExcInvalidRepetitionsDimension(1));
2893 Assert(spacing[0].size() == n_cells, ExcInvalidRepetitionsDimension(1));
2895 double delta = std::numeric_limits<double>::max();
2896 for (
unsigned int i = 0; i <
n_cells; ++i)
2898 Assert(spacing[0][i] >= 0, ExcInvalidRepetitions(-1));
2899 delta =
std::min(delta, spacing[0][i]);
2903 std::vector<Point<1>> points;
2905 for (
unsigned int x = 0; x <=
n_cells; ++x)
2907 points.emplace_back(ax);
2909 ax += spacing[0][x];
2912 unsigned int n_val_cells = 0;
2913 for (
unsigned int i = 0; i <
n_cells; ++i)
2917 std::vector<CellData<1>> cells(n_val_cells);
2918 unsigned int id = 0;
2919 for (
unsigned int x = 0; x <
n_cells; ++x)
2922 cells[id].vertices[0] = x;
2923 cells[id].vertices[1] = x + 1;
2942 const std::vector<std::vector<double>> &spacing,
2947 Assert(spacing.size() == 2, ExcInvalidRepetitionsDimension(2));
2949 std::vector<unsigned int> repetitions(2);
2950 double delta = std::numeric_limits<double>::max();
2951 for (
unsigned int i = 0; i < 2; ++i)
2953 repetitions[i] = spacing[i].size();
2954 for (
unsigned int j = 0; j < repetitions[i]; ++j)
2956 Assert(spacing[i][j] >= 0, ExcInvalidRepetitions(-1));
2957 delta =
std::min(delta, spacing[i][j]);
2960 ExcInvalidRepetitionsDimension(i));
2964 std::vector<Point<2>> points;
2966 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
2969 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
2971 points.emplace_back(ax, ay);
2972 if (x < repetitions[0])
2973 ax += spacing[0][x];
2975 if (y < repetitions[1])
2976 ay += spacing[1][y];
2980 unsigned int n_val_cells = 0;
2981 for (
unsigned int i = 0; i <
material_id.size(0); ++i)
2982 for (
unsigned int j = 0; j <
material_id.size(1); ++j)
2986 std::vector<CellData<2>> cells(n_val_cells);
2987 unsigned int id = 0;
2988 for (
unsigned int y = 0; y < repetitions[1]; ++y)
2989 for (
unsigned int x = 0; x < repetitions[0]; ++x)
2992 cells[id].vertices[0] = y * (repetitions[0] + 1) + x;
2993 cells[id].vertices[1] = y * (repetitions[0] + 1) + x + 1;
2994 cells[id].vertices[2] = (y + 1) * (repetitions[0] + 1) + x;
2995 cells[id].vertices[3] = (y + 1) * (repetitions[0] + 1) + x + 1;
3009 double eps = 0.01 * delta;
3011 for (; cell != endc; ++cell)
3013 Point<2> cell_center = cell->center();
3015 if (cell->face(f)->boundary_id() == 0)
3017 Point<2> face_center = cell->face(f)->center();
3018 for (
unsigned int i = 0; i < 2; ++i)
3020 if (face_center[i] < cell_center[i] - eps)
3021 cell->face(f)->set_boundary_id(i * 2);
3022 if (face_center[i] > cell_center[i] + eps)
3023 cell->face(f)->set_boundary_id(i * 2 + 1);
3034 const std::vector<std::vector<double>> &spacing,
3039 const unsigned int dim = 3;
3041 Assert(spacing.size() == dim, ExcInvalidRepetitionsDimension(dim));
3043 std::array<unsigned int, dim> repetitions;
3044 double delta = std::numeric_limits<double>::max();
3045 for (
unsigned int i = 0; i < dim; ++i)
3047 repetitions[i] = spacing[i].size();
3048 for (
unsigned int j = 0; j < repetitions[i]; ++j)
3050 Assert(spacing[i][j] >= 0, ExcInvalidRepetitions(-1));
3051 delta =
std::min(delta, spacing[i][j]);
3054 ExcInvalidRepetitionsDimension(i));
3058 std::vector<Point<dim>> points;
3060 for (
unsigned int z = 0; z <= repetitions[2]; ++z)
3063 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
3066 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
3068 points.emplace_back(ax, ay, az);
3069 if (x < repetitions[0])
3070 ax += spacing[0][x];
3072 if (y < repetitions[1])
3073 ay += spacing[1][y];
3075 if (z < repetitions[2])
3076 az += spacing[2][z];
3080 unsigned int n_val_cells = 0;
3081 for (
unsigned int i = 0; i <
material_id.size(0); ++i)
3082 for (
unsigned int j = 0; j <
material_id.size(1); ++j)
3083 for (
unsigned int k = 0; k <
material_id.size(2); ++k)
3087 std::vector<CellData<dim>> cells(n_val_cells);
3088 unsigned int id = 0;
3089 const unsigned int n_x = (repetitions[0] + 1);
3090 const unsigned int n_xy = (repetitions[0] + 1) * (repetitions[1] + 1);
3091 for (
unsigned int z = 0; z < repetitions[2]; ++z)
3092 for (
unsigned int y = 0; y < repetitions[1]; ++y)
3093 for (
unsigned int x = 0; x < repetitions[0]; ++x)
3096 cells[id].vertices[0] = z * n_xy + y * n_x + x;
3097 cells[id].vertices[1] = z * n_xy + y * n_x + x + 1;
3098 cells[id].vertices[2] = z * n_xy + (y + 1) * n_x + x;
3099 cells[id].vertices[3] = z * n_xy + (y + 1) * n_x + x + 1;
3100 cells[id].vertices[4] = (z + 1) * n_xy + y * n_x + x;
3101 cells[id].vertices[5] = (z + 1) * n_xy + y * n_x + x + 1;
3102 cells[id].vertices[6] = (z + 1) * n_xy + (y + 1) * n_x + x;
3103 cells[id].vertices[7] = (z + 1) * n_xy + (y + 1) * n_x + x + 1;
3117 double eps = 0.01 * delta;
3120 for (; cell != endc; ++cell)
3124 if (cell->face(f)->boundary_id() == 0)
3126 Point<dim> face_center = cell->face(f)->center();
3127 for (
unsigned int i = 0; i < dim; ++i)
3129 if (face_center[i] < cell_center[i] - eps)
3130 cell->face(f)->set_boundary_id(i * 2);
3131 if (face_center[i] > cell_center[i] + eps)
3132 cell->face(f)->set_boundary_id(i * 2 + 1);
3139 template <
int dim,
int spacedim>
3142 const std::vector<unsigned int> &holes)
3151 for (
unsigned int d = 0;
d < dim; ++
d)
3158 std::array<Point<spacedim>, dim> delta;
3159 std::array<unsigned int, dim> repetitions;
3160 for (
unsigned int i = 0; i < dim; ++i)
3163 ExcMessage(
"At least one hole needed in each direction"));
3164 repetitions[i] = 2 * holes[i] + 1;
3165 delta[i][i] = (p2[i] - p1[i]);
3170 std::vector<Point<spacedim>> points;
3174 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
3175 points.push_back(p1 + x * delta[0]);
3179 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
3180 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
3181 points.push_back(p1 + x * delta[0] + y * delta[1]);
3185 for (
unsigned int z = 0; z <= repetitions[2]; ++z)
3186 for (
unsigned int y = 0; y <= repetitions[1]; ++y)
3187 for (
unsigned int x = 0; x <= repetitions[0]; ++x)
3188 points.push_back(p1 + x * delta[0] + y * delta[1] +
3198 std::vector<CellData<dim>> cells;
3203 cells.resize(repetitions[1] * repetitions[0] - holes[1] * holes[0]);
3205 for (
unsigned int y = 0; y < repetitions[1]; ++y)
3206 for (
unsigned int x = 0; x < repetitions[0]; ++x)
3208 if ((x % 2 == 1) && (y % 2 == 1))
3211 cells[c].vertices[0] = y * (repetitions[0] + 1) + x;
3212 cells[c].vertices[1] = y * (repetitions[0] + 1) + x + 1;
3213 cells[c].vertices[2] = (y + 1) * (repetitions[0] + 1) + x;
3214 cells[c].vertices[3] = (y + 1) * (repetitions[0] + 1) + x + 1;
3215 cells[c].material_id = 0;
3223 const unsigned int n_x = (repetitions[0] + 1);
3224 const unsigned int n_xy =
3225 (repetitions[0] + 1) * (repetitions[1] + 1);
3227 cells.resize(repetitions[2] * repetitions[1] * repetitions[0]);
3230 for (
unsigned int z = 0; z < repetitions[2]; ++z)
3231 for (
unsigned int y = 0; y < repetitions[1]; ++y)
3232 for (
unsigned int x = 0; x < repetitions[0]; ++x)
3235 cells[c].vertices[0] = z * n_xy + y * n_x + x;
3236 cells[c].vertices[1] = z * n_xy + y * n_x + x + 1;
3237 cells[c].vertices[2] = z * n_xy + (y + 1) * n_x + x;
3238 cells[c].vertices[3] = z * n_xy + (y + 1) * n_x + x + 1;
3239 cells[c].vertices[4] = (z + 1) * n_xy + y * n_x + x;
3240 cells[c].vertices[5] = (z + 1) * n_xy + y * n_x + x + 1;
3241 cells[c].vertices[6] = (z + 1) * n_xy + (y + 1) * n_x + x;
3242 cells[c].vertices[7] =
3243 (z + 1) * n_xy + (y + 1) * n_x + x + 1;
3244 cells[c].material_id = 0;
3272 const unsigned int ,
3284 const unsigned int ,
3296 bool inline point_in_2d_box(
const Point<2> &p,
3298 const double radius)
3300 return (
std::abs(p[0] - c[0]) < radius) &&
3309 template <
int dim,
int spacedim>
3313 double length = std::numeric_limits<double>::max();
3314 for (
const auto &cell :
triangulation.active_cell_iterators())
3315 for (
unsigned int n = 0; n < GeometryInfo<dim>::lines_per_cell; ++n)
3316 length =
std::min(length, cell->line(n)->diameter());
3326 const double inner_radius,
3327 const double outer_radius,
3328 const double pad_bottom,
3329 const double pad_top,
3330 const double pad_left,
3331 const double pad_right,
3336 const unsigned int ,
3339 const bool with_padding =
3340 pad_bottom > 0 || pad_top > 0 || pad_left > 0 || pad_right > 0;
3350 double length = std::numeric_limits<double>::max();
3352 for (
unsigned int n = 0; n < GeometryInfo<2>::lines_per_cell; ++n)
3353 length =
std::min(length, cell->line(n)->diameter());
3369 cell->set_manifold_id(tfi_manifold_id);
3371 const Point<2> bl(-outer_radius - pad_left, -outer_radius - pad_bottom);
3372 const Point<2> tr(outer_radius + pad_right, outer_radius + pad_top);
3378 auto add_sizes = [](std::vector<double> &step_sizes,
3379 const double padding,
3380 const double h) ->
void {
3383 const auto rounded =
3384 static_cast<unsigned int>(std::round(padding / h));
3387 const unsigned int num = (padding > 0. && rounded == 0) ? 1 : rounded;
3388 for (
unsigned int i = 0; i < num; ++i)
3389 step_sizes.push_back(padding / num);
3392 std::vector<std::vector<double>> step_sizes(2);
3395 add_sizes(step_sizes[0], pad_left, outer_radius);
3397 step_sizes[0].push_back(outer_radius);
3398 step_sizes[0].push_back(outer_radius);
3400 add_sizes(step_sizes[0], pad_right, outer_radius);
3403 add_sizes(step_sizes[1], pad_bottom, outer_radius);
3405 step_sizes[1].push_back(outer_radius);
3406 step_sizes[1].push_back(outer_radius);
3408 add_sizes(step_sizes[1], pad_top, outer_radius);
3413 bulk_tria, step_sizes, bl, tr,
colorize);
3416 std::set<Triangulation<2>::active_cell_iterator> cells_to_remove;
3418 if (internal::point_in_2d_box(cell->center(),
center, outer_radius))
3419 cells_to_remove.insert(cell);
3423 bulk_tria, cells_to_remove, tria_without_cylinder);
3425 const double tolerance =
3426 std::min(min_line_length(tria_without_cylinder),
3427 min_line_length(cylinder_tria)) /
3441 if (cell->manifold_id() == tfi_manifold_id)
3445 const auto &face = cell->face(face_n);
3446 if (face->at_boundary() &&
3447 internal::point_in_2d_box(face->center(),
3450 face->set_manifold_id(polar_manifold_id);
3452 face->set_manifold_id(tfi_manifold_id);
3463 static constexpr double tol =
3464 std::numeric_limits<double>::epsilon() * 10000;
3469 const auto face = cell->face(face_n);
3470 if (face->at_boundary())
3475 face->set_boundary_id(0);
3478 face->set_boundary_id(1);
3481 face->set_boundary_id(2);
3484 face->set_boundary_id(3);
3488 Assert(cell->manifold_id() == tfi_manifold_id,
3490 face->set_boundary_id(4);
3510 const double inner_radius,
3511 const double outer_radius,
3512 const double pad_bottom,
3513 const double pad_top,
3514 const double pad_left,
3515 const double pad_right,
3520 const unsigned int n_slices,
3531 Point<2>(new_center[0], new_center[1]),
3560 const double shell_region_width,
3561 const unsigned int n_shells,
3562 const double skewness,
3565 Assert(0.0 <= shell_region_width && shell_region_width < 0.05,
3566 ExcMessage(
"The width of the shell region must be less than 0.05 "
3567 "(and preferably close to 0.03)"));
3601 std::set<Triangulation<2>::active_cell_iterator> cells_to_remove;
3605 if ((cell->center() -
Point<2>(0.2, 0.2)).norm() < 0.15)
3606 cells_to_remove.insert(cell);
3610 for (
const unsigned int vertex_n :
3612 if (cell->vertex(vertex_n) ==
Point<2>())
3616 cylinder_triangulation_offset =
3617 2.0 * (cell->vertex(3) -
Point<2>());
3624 bulk_tria, cells_to_remove, tria_without_cylinder);
3631 0.05 + shell_region_width,
3639 if (
std::abs(cell->vertex(vertex_n)[0] - -0.41 / 4.0) < 1e-10)
3640 cell->vertex(vertex_n)[0] = -0.1;
3641 else if (
std::abs(cell->vertex(vertex_n)[0] - 0.41 / 4.0) < 1e-10)
3642 cell->vertex(vertex_n)[0] = 0.1;
3648 cell->set_manifold_id(tfi_manifold_id);
3650 if (!cell->face(face_n)->at_boundary())
3651 cell->face(face_n)->set_manifold_id(tfi_manifold_id);
3653 if (0.0 < shell_region_width)
3656 ExcMessage(
"If the shell region has positive width then "
3657 "there must be at least one shell."));
3662 0.05 + shell_region_width,
3669 const double vertex_tolerance =
3670 std::min(internal::minimal_vertex_distance(shell_tria),
3671 internal::minimal_vertex_distance(cylinder_tria)) *
3677 shell_tria, cylinder_tria, temp, vertex_tolerance,
true);
3678 cylinder_tria = std::move(temp);
3684 const double vertex_tolerance =
3685 std::min(internal::minimal_vertex_distance(tria_without_cylinder),
3686 internal::minimal_vertex_distance(cylinder_tria)) /
3689 tria_without_cylinder, cylinder_tria,
tria, vertex_tolerance,
true);
3702 const double shift =
3703 std::min(0.125 + shell_region_width * 0.5, 0.1 * 4. / 3.);
3706 if (cell->vertex(v).distance(
Point<2>(0.1, 0.205)) < 1e-10)
3707 cell->vertex(v) =
Point<2>(0.2 - shift, 0.205);
3708 else if (cell->vertex(v).distance(
Point<2>(0.3, 0.205)) < 1e-10)
3709 cell->vertex(v) =
Point<2>(0.2 + shift, 0.205);
3710 else if (cell->vertex(v).distance(
Point<2>(0.2, 0.1025)) < 1e-10)
3711 cell->vertex(v) =
Point<2>(0.2, 0.2 - shift);
3712 else if (cell->vertex(v).distance(
Point<2>(0.2, 0.3075)) < 1e-10)
3713 cell->vertex(v) =
Point<2>(0.2, 0.2 + shift);
3719 if (cell->manifold_id() == polar_manifold_id)
3720 cell->set_all_manifold_ids(polar_manifold_id);
3725 if (cell->manifold_id() != polar_manifold_id &&
3726 cell->manifold_id() != tfi_manifold_id)
3731 std::vector<Point<2> *> cylinder_pointers;
3733 if (face->manifold_id() == polar_manifold_id)
3735 cylinder_pointers.push_back(&face->vertex(0));
3736 cylinder_pointers.push_back(&face->vertex(1));
3739 std::sort(cylinder_pointers.begin(), cylinder_pointers.end());
3740 cylinder_pointers.erase(std::unique(cylinder_pointers.begin(),
3741 cylinder_pointers.end()),
3742 cylinder_pointers.end());
3746 for (
const Point<2> *
const ptr : cylinder_pointers)
3747 center += *ptr / double(cylinder_pointers.size());
3750 for (
Point<2> *
const ptr : cylinder_pointers)
3762 if (face->at_boundary())
3767 face->set_boundary_id(0);
3770 face->set_boundary_id(1);
3772 else if (face->manifold_id() == polar_manifold_id)
3773 face->set_boundary_id(2);
3780 face->set_boundary_id(3);
3790 const double shell_region_width,
3791 const unsigned int n_shells,
3792 const double skewness,
3797 tria_2, shell_region_width, n_shells, skewness,
colorize);
3821 if (face->boundary_id() == 4 || face->boundary_id() == 5)
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;
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;
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);
4049 const double thickness,
4053 ExcMessage(
"Invalid left-to-right bounds of enclosed hypercube"));
4055 std::vector<Point<2>>
vertices(16);
4057 coords[0] = left - thickness;
4060 coords[3] = right + thickness;
4063 for (
const double y : coords)
4064 for (
const double x : coords)
4069 std::vector<CellData<2>> cells(9);
4071 for (
unsigned int i0 = 0; i0 < 3; ++i0)
4072 for (
unsigned int i1 = 0; i1 < 3; ++i1)
4074 cells[k].vertices[0] = i1 + 4 * i0;
4075 cells[k].vertices[1] = i1 + 4 * i0 + 1;
4076 cells[k].vertices[2] = i1 + 4 * i0 + 4;
4077 cells[k].vertices[3] = i1 + 4 * i0 + 5;
4079 cells[k].material_id = materials[k];
4097 const double rl2 = (right + left) / 2;
4108 const int cell_vertices[4][4] = {{0, 1, 3, 2},
4113 for (
unsigned int i = 0; i < 4; ++i)
4115 for (
unsigned int j = 0; j < 4; ++j)
4116 cells[i].
vertices[j] = cell_vertices[i][j];
4117 cells[i].material_id = 0;
4127 cell->face(1)->set_boundary_id(1);
4129 cell->face(0)->set_boundary_id(2);
4138 const double radius_0,
4139 const double radius_1,
4140 const double half_length)
4144 vertices_tmp[0] =
Point<2>(-half_length, -radius_0);
4145 vertices_tmp[1] =
Point<2>(half_length, -radius_1);
4146 vertices_tmp[2] =
Point<2>(-half_length, radius_0);
4147 vertices_tmp[3] =
Point<2>(half_length, radius_1);
4149 const std::vector<Point<2>>
vertices(std::begin(vertices_tmp),
4150 std::end(vertices_tmp));
4154 cell_vertices[0][i] = i;
4159 cells[0].vertices[i] = cell_vertices[0][i];
4161 cells[0].material_id = 0;
4166 cell->face(0)->set_boundary_id(1);
4167 cell->face(1)->set_boundary_id(2);
4169 for (
unsigned int i = 2; i < 4; ++i)
4170 cell->face(i)->set_boundary_id(0);
4187 Point<2>((a + b) / 2, (a + b) / 2),
4191 const int cell_vertices[3][4] = {{0, 1, 3, 4}, {1, 2, 4, 5}, {3, 4, 6, 7}};
4195 for (
unsigned int i = 0; i < 3; ++i)
4197 for (
unsigned int j = 0; j < 4; ++j)
4198 cells[i].
vertices[j] = cell_vertices[i][j];
4199 cells[i].material_id = 0;
4211 cell->face(0)->set_boundary_id(0);
4212 cell->face(2)->set_boundary_id(1);
4215 cell->face(1)->set_boundary_id(2);
4216 cell->face(2)->set_boundary_id(1);
4217 cell->face(3)->set_boundary_id(3);
4220 cell->face(0)->set_boundary_id(0);
4221 cell->face(1)->set_boundary_id(4);
4222 cell->face(3)->set_boundary_id(5);
4228 template <
int dim,
int spacedim>
4231 const std::vector<unsigned int> &repetitions,
4234 const std::vector<int> & n_cells_to_remove)
4240 for (
unsigned int d = 0;
d < dim; ++
d)
4242 Assert(std::fabs(n_cells_to_remove[d]) <= repetitions[d],
4243 ExcMessage(
"Attempting to cut away too many cells."));
4253 std::array<double, dim> h;
4255 for (
unsigned int d = 0;
d < dim; ++
d)
4258 h[
d] = (top_right[
d] - bottom_left[
d]) / repetitions[d];
4260 if (n_cells_to_remove[d] >= 0)
4264 h[
d] * std::fabs(n_cells_to_remove[d]) + bottom_left[
d];
4269 cut_step[
d] = top_right[
d] - h[
d] * std::fabs(n_cells_to_remove[d]);
4275 std::set<typename Triangulation<dim, spacedim>::active_cell_iterator>
4279 bool remove_cell =
true;
4280 for (
unsigned int d = 0;
d < dim && remove_cell; ++
d)
4281 if ((n_cells_to_remove[d] > 0 && cell->center()[d] >= cut_step[d]) ||
4282 (n_cells_to_remove[d] < 0 && cell->center()[d] <= cut_step[d]))
4283 remove_cell =
false;
4285 cells_to_remove.insert(cell);
4300 const double radius,
4301 const bool internal_manifolds)
4306 const double a = 1. / (1 +
std::sqrt(2.0));
4317 const int cell_vertices[5][4] = {
4318 {0, 1, 2, 3}, {0, 2, 6, 4}, {2, 3, 4, 5}, {1, 7, 3, 5}, {6, 4, 7, 5}};
4322 for (
unsigned int i = 0; i < 5; ++i)
4324 for (
unsigned int j = 0; j < 4; ++j)
4325 cells[i].
vertices[j] = cell_vertices[i][j];
4326 cells[i].material_id = 0;
4336 if (internal_manifolds)
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<2>>
vertices(2 * N);
4378 for (
unsigned int i = 0; i < N; ++i)
4391 for (
unsigned int i = 0; i < N; ++i)
4393 cells[i].vertices[0] = i;
4394 cells[i].vertices[1] = (i + 1) % N;
4395 cells[i].vertices[2] = N + i;
4396 cells[i].vertices[3] = N + ((i + 1) % N);
4398 cells[i].material_id = 0;
4404 colorize_hyper_shell(
tria,
center, inner_radius, outer_radius);
4417 const double inner_radius,
4418 const double outer_radius,
4419 const unsigned int n_cells)
4422 tria, outer_center, inner_radius, outer_radius, n_cells,
true);
4426 outer_radius - inner_radius > outer_center.
distance(inner_center),
4428 "The inner radius is greater than or equal to the outer radius plus eccentricity."));
4432 std::set<Point<dim> *> vertices_to_move;
4435 if (face->boundary_id() == 0)
4436 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_face; ++v)
4437 vertices_to_move.insert(&face->vertex(v));
4439 const auto shift = inner_center - outer_center;
4440 for (
const auto &p : vertices_to_move)
4468 const double radius,
4469 const double half_length)
4471 Point<2> p1(-half_length, -radius);
4480 switch (f->boundary_id())
4483 f->set_boundary_id(1);
4486 f->set_boundary_id(2);
4489 f->set_boundary_id(0);
4526 const double radius)
4528 const unsigned int dim = 2;
4542 const int cell_vertices[3][4] = {{0, 2, 3, 4}, {1, 6, 2, 4}, {5, 3, 6, 4}};
4546 for (
unsigned int i = 0; i < 3; ++i)
4548 for (
unsigned int j = 0; j < 4; ++j)
4549 cells[i].
vertices[j] = cell_vertices[i][j];
4550 cells[i].material_id = 0;
4567 if (cell->face(i)->boundary_id() ==
4573 if (cell->face(i)->center()(0) < p(0) + 1.e-5 * radius ||
4574 cell->face(i)->center()(1) < p(1) + 1.e-5 * radius)
4576 cell->face(i)->set_boundary_id(1);
4590 const double radius)
4595 const double a = 1. / (1 +
std::sqrt(2.0));
4606 const int cell_vertices[5][4] = {{0, 1, 2, 3},
4613 for (
unsigned int i = 0; i < 4; ++i)
4615 for (
unsigned int j = 0; j < 4; ++j)
4616 cells[i].
vertices[j] = cell_vertices[i][j];
4617 cells[i].material_id = 0;
4634 if (cell->face(i)->boundary_id() ==
4639 if (cell->face(i)->center()(0) < p(0) + 1.e-5 * radius)
4641 cell->face(i)->set_boundary_id(1);
4657 const double inner_radius,
4658 const double outer_radius,
4659 const unsigned int n_cells,
4662 Assert((inner_radius > 0) && (inner_radius < outer_radius),
4675 const unsigned int N =
4676 (
n_cells == 0 ?
static_cast<unsigned int>(
4677 std::ceil((pi * (outer_radius + inner_radius) / 2) /
4678 (outer_radius - inner_radius))) :
4687 std::vector<Point<2>>
vertices(2 * (N + 1));
4688 for (
unsigned int i = 0; i <= N; ++i)
4709 for (
unsigned int i = 0; i < N; ++i)
4711 cells[i].vertices[0] = i;
4712 cells[i].vertices[1] = (i + 1) % (N + 1);
4713 cells[i].vertices[2] = N + 1 + i;
4714 cells[i].vertices[3] = N + 1 + ((i + 1) % (N + 1));
4716 cells[i].material_id = 0;
4724 for (; cell !=
tria.
end(); ++cell)
4726 cell->face(2)->set_boundary_id(1);
4728 tria.
begin()->face(0)->set_boundary_id(3);
4730 tria.
last()->face(1)->set_boundary_id(2);
4741 const double inner_radius,
4742 const double outer_radius,
4743 const unsigned int n_cells,
4746 Assert((inner_radius > 0) && (inner_radius < outer_radius),
4759 const unsigned int N =
4760 (
n_cells == 0 ?
static_cast<unsigned int>(
4761 std::ceil((pi * (outer_radius + inner_radius) / 4) /
4762 (outer_radius - inner_radius))) :
4771 std::vector<Point<2>>
vertices(2 * (N + 1));
4772 for (
unsigned int i = 0; i <= N; ++i)
4791 for (
unsigned int i = 0; i < N; ++i)
4793 cells[i].vertices[0] = i;
4794 cells[i].vertices[1] = (i + 1) % (N + 1);
4795 cells[i].vertices[2] = N + 1 + i;
4796 cells[i].vertices[3] = N + 1 + ((i + 1) % (N + 1));
4798 cells[i].material_id = 0;
4806 for (; cell !=
tria.
end(); ++cell)
4808 cell->face(2)->set_boundary_id(1);
4810 tria.
begin()->face(0)->set_boundary_id(3);
4812 tria.
last()->face(1)->set_boundary_id(2);
4829 const double rl2 = (right + left) / 2;
4830 const double len = (right - left) / 2.;
4843 const int cell_vertices[4][8] = {{0, 1, 3, 2, 10, 11, 13, 12},
4844 {9, 4, 2, 5, 19, 14, 12, 15},
4845 {3, 2, 7, 6, 13, 12, 17, 16},
4846 {2, 5, 6, 8, 12, 15, 16, 18}};
4848 for (
unsigned int i = 0; i < 4; ++i)
4850 for (
unsigned int j = 0; j < 8; ++j)
4851 cells[i].
vertices[j] = cell_vertices[i][j];
4852 cells[i].material_id = 0;
4862 cell->face(1)->set_boundary_id(1);
4864 cell->face(0)->set_boundary_id(2);
4876 const double thickness,
4880 ExcMessage(
"Invalid left-to-right bounds of enclosed hypercube"));
4882 std::vector<Point<3>>
vertices(64);
4884 coords[0] = left - thickness;
4887 coords[3] = right + thickness;
4890 for (
const double z : coords)
4891 for (
const double y : coords)
4892 for (
const double x : coords)
4896 24, 26, 5, 4, 6, 1, 0,
4897 2, 9, 8, 10, 37, 36, 38,
4898 33, 32, 34, 41, 40, 42};
4900 std::vector<CellData<3>> cells(27);
4902 for (
unsigned int z = 0; z < 3; ++z)
4903 for (
unsigned int y = 0; y < 3; ++y)
4904 for (
unsigned int x = 0; x < 3; ++x)
4906 cells[k].vertices[0] = x + 4 * y + 16 * z;
4907 cells[k].vertices[1] = x + 4 * y + 16 * z + 1;
4908 cells[k].vertices[2] = x + 4 * y + 16 * z + 4;
4909 cells[k].vertices[3] = x + 4 * y + 16 * z + 5;
4910 cells[k].vertices[4] = x + 4 * y + 16 * z + 16;
4911 cells[k].vertices[5] = x + 4 * y + 16 * z + 17;
4912 cells[k].vertices[6] = x + 4 * y + 16 * z + 20;
4913 cells[k].vertices[7] = x + 4 * y + 16 * z + 21;
4915 cells[k].material_id = materials[k];
4928 const double radius_0,
4929 const double radius_1,
4930 const double half_length)
4933 ExcMessage(
"The output triangulation object needs to be empty."));
4938 const auto n_slices = 1 +
static_cast<unsigned int>(std::ceil(
4939 half_length /
std::max(radius_0, radius_1)));
4952 auto shift_radii = [=](
const Point<3> &p) {
4953 const double slope = (radius_1 / radius_0 - 1.0) / (2.0 * half_length);
4954 const double factor = slope * (p[0] - -half_length) + 1.0;
4955 return Point<3>(p[0], factor * p[1], factor * p[2]);
4961 for (
const auto &face :
triangulation.active_face_iterators())
4962 if (face->at_boundary())
4964 if (
std::abs(face->center()[0] - -half_length) < 1e-8 * half_length)
4965 face->set_boundary_id(1);
4966 else if (
std::abs(face->center()[0] - half_length) <
4968 face->set_boundary_id(2);
4970 face->set_all_manifold_ids(0);
4993 Point<3>((a + b) / 2, a, (a + b) / 2),
5000 Point<3>((a + b) / 2, (a + b) / 2, a),
5002 Point<3>(a, (a + b) / 2, (a + b) / 2),
5003 Point<3>((a + b) / 2, (a + b) / 2, (a + b) / 2),
5004 Point<3>(b, (a + b) / 2, (a + b) / 2),
5006 Point<3>((a + b) / 2, (a + b) / 2, b),
5014 Point<3>((a + b) / 2, b, (a + b) / 2),
5018 const int cell_vertices[7][8] = {{0, 1, 9, 10, 3, 4, 12, 13},
5019 {1, 2, 10, 11, 4, 5, 13, 14},
5020 {3, 4, 12, 13, 6, 7, 15, 16},
5021 {4, 5, 13, 14, 7, 8, 16, 17},
5022 {9, 10, 18, 19, 12, 13, 21, 22},
5023 {10, 11, 19, 20, 13, 14, 22, 23},
5024 {12, 13, 21, 22, 15, 16, 24, 25}};
5028 for (
unsigned int i = 0; i < 7; ++i)
5030 for (
unsigned int j = 0; j < 8; ++j)
5031 cells[i].
vertices[j] = cell_vertices[i][j];
5032 cells[i].material_id = 0;
5053 const double radius,
5054 const bool internal_manifold)
5060 const unsigned int n_vertices = 16;
5086 const unsigned int n_cells = 7;
5087 const int cell_vertices[
n_cells][8] = {
5088 {0, 1, 4, 5, 3, 2, 7, 6},
5089 {8, 9, 12, 13, 0, 1, 4, 5},
5090 {9, 13, 1, 5, 10, 14, 2, 6},
5091 {11, 10, 3, 2, 15, 14, 7, 6},
5092 {8, 0, 12, 4, 11, 3, 15, 7},
5093 {8, 9, 0, 1, 11, 10, 3, 2},
5094 {12, 4, 13, 5, 15, 7, 14, 6}};
5096 std::vector<CellData<3>> cells(n_cells,
CellData<3>());
5098 for (
unsigned int i = 0; i <
n_cells; ++i)
5101 cells[i].vertices[j] = cell_vertices[i][j];
5102 cells[i].material_id = 0;
5112 if (internal_manifold)
5120 const unsigned int n_rotate_middle_square)
5123 ExcMessage(
"The number of rotation by pi/2 of the right square "
5124 "must be in the half-open range [0,4)."))
5126 constexpr
unsigned int dim = 2;
5128 const
unsigned int n_cells = 5;
5147 unsigned int cell_vertices[
n_cells][4] = {{0, 1, 2, 3},
5153 switch (n_rotate_middle_square)
5157 cell_vertices[1][0] = 4;
5158 cell_vertices[1][1] = 5;
5159 cell_vertices[1][2] = 1;
5160 cell_vertices[1][3] = 3;
5166 cell_vertices[1][0] = 5;
5167 cell_vertices[1][1] = 3;
5168 cell_vertices[1][2] = 4;
5169 cell_vertices[1][3] = 1;
5175 cell_vertices[1][0] = 3;
5176 cell_vertices[1][1] = 1;
5177 cell_vertices[1][2] = 5;
5178 cell_vertices[1][3] = 4;
5190 for (
const unsigned int vertex_index :
5205 const bool face_orientation,
5206 const bool face_flip,
5207 const bool face_rotation,
5208 const bool manipulate_left_cube)
5210 constexpr unsigned int dim = 3;
5212 const unsigned int n_cells = 2;
5213 std::vector<CellData<dim>> cells(n_cells);
5229 unsigned int cell_vertices[
n_cells][8] = {
5230 {0, 1, 2, 3, 4, 5, 6, 7},
5231 {1, 8, 3, 9, 5, 10, 7, 11}};
5234 const unsigned int this_case = 4 *
static_cast<int>(face_orientation) +
5235 2 *
static_cast<int>(face_flip) +
5236 static_cast<int>(face_rotation);
5238 if (manipulate_left_cube)
5244 cell_vertices[0][0] = 1;
5245 cell_vertices[0][1] = 0;
5246 cell_vertices[0][2] = 5;
5247 cell_vertices[0][3] = 4;
5248 cell_vertices[0][4] = 3;
5249 cell_vertices[0][5] = 2;
5250 cell_vertices[0][6] = 7;
5251 cell_vertices[0][7] = 6;
5257 cell_vertices[0][0] = 5;
5258 cell_vertices[0][1] = 4;
5259 cell_vertices[0][2] = 7;
5260 cell_vertices[0][3] = 6;
5261 cell_vertices[0][4] = 1;
5262 cell_vertices[0][5] = 0;
5263 cell_vertices[0][6] = 3;
5264 cell_vertices[0][7] = 2;
5270 cell_vertices[0][0] = 7;
5271 cell_vertices[0][1] = 6;
5272 cell_vertices[0][2] = 3;
5273 cell_vertices[0][3] = 2;
5274 cell_vertices[0][4] = 5;
5275 cell_vertices[0][5] = 4;
5276 cell_vertices[0][6] = 1;
5277 cell_vertices[0][7] = 0;
5282 cell_vertices[0][0] = 3;
5283 cell_vertices[0][1] = 2;
5284 cell_vertices[0][2] = 1;
5285 cell_vertices[0][3] = 0;
5286 cell_vertices[0][4] = 7;
5287 cell_vertices[0][5] = 6;
5288 cell_vertices[0][6] = 5;
5289 cell_vertices[0][7] = 4;
5295 cell_vertices[0][0] = 0;
5296 cell_vertices[0][1] = 1;
5297 cell_vertices[0][2] = 2;
5298 cell_vertices[0][3] = 3;
5299 cell_vertices[0][4] = 4;
5300 cell_vertices[0][5] = 5;
5301 cell_vertices[0][6] = 6;
5302 cell_vertices[0][7] = 7;
5308 cell_vertices[0][0] = 2;
5309 cell_vertices[0][1] = 3;
5310 cell_vertices[0][2] = 6;
5311 cell_vertices[0][3] = 7;
5312 cell_vertices[0][4] = 0;
5313 cell_vertices[0][5] = 1;
5314 cell_vertices[0][6] = 4;
5315 cell_vertices[0][7] = 5;
5321 cell_vertices[0][0] = 6;
5322 cell_vertices[0][1] = 7;
5323 cell_vertices[0][2] = 4;
5324 cell_vertices[0][3] = 5;
5325 cell_vertices[0][4] = 2;
5326 cell_vertices[0][5] = 3;
5327 cell_vertices[0][6] = 0;
5328 cell_vertices[0][7] = 1;
5334 cell_vertices[0][0] = 4;
5335 cell_vertices[0][1] = 5;
5336 cell_vertices[0][2] = 0;
5337 cell_vertices[0][3] = 1;
5338 cell_vertices[0][4] = 6;
5339 cell_vertices[0][5] = 7;
5340 cell_vertices[0][6] = 2;
5341 cell_vertices[0][7] = 3;
5352 cell_vertices[1][0] = 8;
5353 cell_vertices[1][1] = 1;
5354 cell_vertices[1][2] = 10;
5355 cell_vertices[1][3] = 5;
5356 cell_vertices[1][4] = 9;
5357 cell_vertices[1][5] = 3;
5358 cell_vertices[1][6] = 11;
5359 cell_vertices[1][7] = 7;
5365 cell_vertices[1][0] = 10;
5366 cell_vertices[1][1] = 5;
5367 cell_vertices[1][2] = 11;
5368 cell_vertices[1][3] = 7;
5369 cell_vertices[1][4] = 8;
5370 cell_vertices[1][5] = 1;
5371 cell_vertices[1][6] = 9;
5372 cell_vertices[1][7] = 3;
5378 cell_vertices[1][0] = 11;
5379 cell_vertices[1][1] = 7;
5380 cell_vertices[1][2] = 9;
5381 cell_vertices[1][3] = 3;
5382 cell_vertices[1][4] = 10;
5383 cell_vertices[1][5] = 5;
5384 cell_vertices[1][6] = 8;
5385 cell_vertices[1][7] = 1;
5391 cell_vertices[1][0] = 9;
5392 cell_vertices[1][1] = 3;
5393 cell_vertices[1][2] = 8;
5394 cell_vertices[1][3] = 1;
5395 cell_vertices[1][4] = 11;
5396 cell_vertices[1][5] = 7;
5397 cell_vertices[1][6] = 10;
5398 cell_vertices[1][7] = 5;
5404 cell_vertices[1][0] = 1;
5405 cell_vertices[1][1] = 8;
5406 cell_vertices[1][2] = 3;
5407 cell_vertices[1][3] = 9;
5408 cell_vertices[1][4] = 5;
5409 cell_vertices[1][5] = 10;
5410 cell_vertices[1][6] = 7;
5411 cell_vertices[1][7] = 11;
5417 cell_vertices[1][0] = 5;
5418 cell_vertices[1][1] = 10;
5419 cell_vertices[1][2] = 1;
5420 cell_vertices[1][3] = 8;
5421 cell_vertices[1][4] = 7;
5422 cell_vertices[1][5] = 11;
5423 cell_vertices[1][6] = 3;
5424 cell_vertices[1][7] = 9;
5430 cell_vertices[1][0] = 7;
5431 cell_vertices[1][1] = 11;
5432 cell_vertices[1][2] = 5;
5433 cell_vertices[1][3] = 10;
5434 cell_vertices[1][4] = 3;
5435 cell_vertices[1][5] = 9;
5436 cell_vertices[1][6] = 1;
5437 cell_vertices[1][7] = 8;
5443 cell_vertices[1][0] = 3;
5444 cell_vertices[1][1] = 9;
5445 cell_vertices[1][2] = 7;
5446 cell_vertices[1][3] = 11;
5447 cell_vertices[1][4] = 1;
5448 cell_vertices[1][5] = 8;
5449 cell_vertices[1][6] = 5;
5450 cell_vertices[1][7] = 10;
5460 for (
const unsigned int vertex_index :
5474 template <
int spacedim>
5478 const double radius)
5482 const std::set<types::boundary_id> boundary_ids = {0};
5494 const unsigned int x_subdivisions,
5495 const double radius,
5496 const double half_length)
5504 const double initial_height = -half_length;
5505 const double height_increment = 2. * half_length / x_subdivisions;
5507 for (
unsigned int rep = 0; rep < (x_subdivisions + 1); ++rep)
5509 const double height = initial_height + height_increment * rep;
5524 const double h = vertex(1);
5525 vertex(1) = -vertex(0);
5529 std::vector<std::vector<int>> cell_vertices;
5530 cell_vertices.push_back({0, 1, 8, 9, 2, 3, 10, 11});
5531 cell_vertices.push_back({0, 2, 8, 10, 6, 4, 14, 12});
5532 cell_vertices.push_back({2, 3, 10, 11, 4, 5, 12, 13});
5533 cell_vertices.push_back({1, 7, 9, 15, 3, 5, 11, 13});
5534 cell_vertices.push_back({6, 4, 14, 12, 7, 5, 15, 13});
5536 for (
unsigned int rep = 1; rep < x_subdivisions; ++rep)
5538 for (
unsigned int i = 0; i < 5; ++i)
5540 std::vector<int> new_cell_vertices(8);
5541 for (
unsigned int j = 0; j < 8; ++j)
5542 new_cell_vertices[j] = cell_vertices[i][j] + 8 * rep;
5543 cell_vertices.push_back(new_cell_vertices);
5547 unsigned int n_cells = x_subdivisions * 5;
5549 std::vector<CellData<3>> cells(n_cells,
CellData<3>());
5551 for (
unsigned int i = 0; i <
n_cells; ++i)
5553 for (
unsigned int j = 0; j < 8; ++j)
5554 cells[i].
vertices[j] = cell_vertices[i][j];
5555 cells[i].material_id = 0;
5577 const double tolerance = 1
e-5 *
std::min(radius, half_length);
5581 if (cell->at_boundary(i))
5583 if (cell->face(i)->center()(0) > half_length - tolerance)
5585 cell->face(i)->set_boundary_id(2);
5588 for (
unsigned int e = 0; e < GeometryInfo<3>::lines_per_face;
5590 if ((std::fabs(cell->face(i)->line(e)->vertex(0)[1]) == a) ||
5591 (std::fabs(cell->face(i)->line(e)->vertex(0)[2]) == a) ||
5592 (std::fabs(cell->face(i)->line(e)->vertex(1)[1]) == a) ||
5593 (std::fabs(cell->face(i)->line(e)->vertex(1)[2]) == a))
5595 cell->face(i)->line(e)->set_boundary_id(2);
5596 cell->face(i)->line(e)->set_manifold_id(
5600 else if (cell->face(i)->center()(0) < -half_length + tolerance)
5602 cell->face(i)->set_boundary_id(1);
5605 for (
unsigned int e = 0; e < GeometryInfo<3>::lines_per_face;
5607 if ((std::fabs(cell->face(i)->line(e)->vertex(0)[1]) == a) ||
5608 (std::fabs(cell->face(i)->line(e)->vertex(0)[2]) == a) ||
5609 (std::fabs(cell->face(i)->line(e)->vertex(1)[1]) == a) ||
5610 (std::fabs(cell->face(i)->line(e)->vertex(1)[2]) == a))
5612 cell->face(i)->line(e)->set_boundary_id(1);
5613 cell->face(i)->line(e)->set_manifold_id(
5625 const double radius,
5626 const double half_length)
5635 const double radius)
5637 const unsigned int dim = 3;
5645 const double a = 0.528;
5646 const double b = 0.4533;
5647 const double c = 0.3752;
5664 const int cell_vertices[4][8] = {{0, 2, 3, 4, 7, 9, 10, 11},
5665 {1, 6, 2, 4, 8, 13, 9, 11},
5666 {5, 3, 6, 4, 12, 10, 13, 11},
5667 {7, 9, 10, 11, 14, 8, 12, 13}};
5671 for (
unsigned int i = 0; i < 4; ++i)
5673 for (
unsigned int j = 0; j < 8; ++j)
5674 cells[i].
vertices[j] = cell_vertices[i][j];
5675 cells[i].material_id = 0;
5691 if (cell->face(i)->boundary_id() ==
5696 if (cell->face(i)->center()(0) <
center(0) + 1.e-5 * radius ||
5697 cell->face(i)->center()(1) <
center(1) + 1.e-5 * radius ||
5698 cell->face(i)->center()(2) <
center(2) + 1.e-5 * radius)
5700 cell->face(i)->set_boundary_id(1);
5704 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
5707 const Point<3> line_vertices[2] = {
5708 cell->face(i)->line(j)->vertex(0),
5709 cell->face(i)->line(j)->vertex(1)};
5710 if ((std::fabs(line_vertices[0].distance(
center) - radius) >
5712 (std::fabs(line_vertices[1].distance(
center) - radius) >
5715 cell->face(i)->line(j)->set_boundary_id(1);
5716 cell->face(i)->line(j)->set_manifold_id(
5734 const double radius)
5740 const double b = a / 2.0;
5741 const double c =
d / 2.0;
5743 const double hb = radius *
std::sqrt(3.0) / 4.0;
5744 const double hc = radius *
std::sqrt(3.0) / 2.0;
5766 int cell_vertices[6][8] = {{0, 1, 8, 9, 2, 3, 10, 11},
5767 {0, 2, 8, 10, 6, 4, 14, 12},
5768 {2, 3, 10, 11, 4, 5, 12, 13},
5769 {1, 7, 9, 15, 3, 5, 11, 13},
5770 {6, 4, 14, 12, 7, 5, 15, 13},
5771 {8, 10, 9, 11, 14, 12, 15, 13}};
5775 for (
unsigned int i = 0; i < 6; ++i)
5777 for (
unsigned int j = 0; j < 8; ++j)
5778 cells[i].
vertices[j] = cell_vertices[i][j];
5779 cells[i].material_id = 0;
5801 if (!cell->at_boundary(i))
5807 if (cell->face(i)->center()(0) <
center(0) + 1.e-5 * radius)
5809 cell->face(i)->set_boundary_id(1);
5811 for (
unsigned int j = 0; j < GeometryInfo<3>::lines_per_face;
5814 const Point<3> line_vertices[2] = {
5815 cell->face(i)->line(j)->vertex(0),
5816 cell->face(i)->line(j)->vertex(1)};
5817 if ((std::fabs(line_vertices[0].distance(
center) - radius) >
5819 (std::fabs(line_vertices[1].distance(
center) - radius) >
5822 cell->face(i)->line(j)->set_boundary_id(1);
5823 cell->face(i)->line(j)->set_manifold_id(
5840 const double radius)
5853 for (
unsigned int round = 0; round < dim; ++round)
5858 std::vector<Point<dim>> new_points(tria_copy.
n_vertices());
5860 for (
unsigned int v = 0; v < tria_copy.
n_vertices(); ++v)
5868 else if (round == 1)
5870 for (
unsigned int v = 0; v < tria_copy.
n_vertices(); ++v)
5879 else if (round == 2)
5880 for (
unsigned int v = 0; v < tria_copy.
n_vertices(); ++v)
5893 std::vector<CellData<dim>> cells;
5894 cells.reserve(tria_copy.
n_cells());
5899 data.
vertices[v] = cell->vertex_index(v);
5902 cells.push_back(data);
5910 if (round == dim - 1)
5920 if (cell->center().norm_square() > 0.4 * radius)
5921 cell->set_manifold_id(1);
5940 const double inner_radius,
5941 const double outer_radius)
5944 std::vector<CellData<3>> cells;
5946 const double irad = inner_radius /
std::sqrt(3.0);
5947 const double orad = outer_radius /
std::sqrt(3.0);
5950 static const std::array<Point<3>, 8> hexahedron = {{{-1, -1, -1},
5960 for (
unsigned int i = 0; i < 8; ++i)
5961 vertices.push_back(p + hexahedron[i] * irad);
5962 for (
unsigned int i = 0; i < 8; ++i)
5963 vertices.push_back(p + hexahedron[i] * orad);
5965 const unsigned int n_cells = 6;
5966 const int cell_vertices[
n_cells][8] = {
5967 {8, 9, 10, 11, 0, 1, 2, 3},
5968 {9, 11, 1, 3, 13, 15, 5, 7},
5969 {12, 13, 4, 5, 14, 15, 6, 7},
5970 {8, 0, 10, 2, 12, 4, 14, 6},
5971 {8, 9, 0, 1, 12, 13, 4, 5},
5972 {10, 2, 11, 3, 14, 6, 15, 7}};
5976 for (
unsigned int i = 0; i <
n_cells; ++i)
5979 cells[i].vertices[j] = cell_vertices[i][j];
5980 cells[i].material_id = 0;
5991 const double inner_radius,
5992 const double outer_radius)
5995 std::vector<CellData<3>> cells;
5997 const double irad = inner_radius /
std::sqrt(3.0);
5998 const double orad = outer_radius /
std::sqrt(3.0);
6004 static const std::array<Point<3>, 6> octahedron = {{{-1, 0, 0},
6012 static const std::array<Point<3>, 8> hexahedron = {{{-1, -1, -1},
6021 for (
unsigned int i = 0; i < 8; ++i)
6022 vertices.push_back(p + hexahedron[i] * irad);
6023 for (
unsigned int i = 0; i < 6; ++i)
6024 vertices.push_back(p + octahedron[i] * inner_radius);
6025 for (
unsigned int i = 0; i < 8; ++i)
6026 vertices.push_back(p + hexahedron[i] * orad);
6027 for (
unsigned int i = 0; i < 6; ++i)
6028 vertices.push_back(p + octahedron[i] * outer_radius);
6030 const unsigned int n_cells = 12;
6031 const unsigned int rhombi[
n_cells][4] = {{10, 4, 0, 8},
6046 for (
unsigned int i = 0; i <
n_cells; ++i)
6048 for (
unsigned int j = 0; j < 4; ++j)
6050 cells[i].vertices[j] = rhombi[i][j];
6051 cells[i].vertices[j + 4] = rhombi[i][j] + 14;
6053 cells[i].material_id = 0;
6063 const unsigned int n,
6064 const unsigned int n_refinement_steps,
6066 const double inner_radius,
6067 const double outer_radius)
6080 const unsigned int outer_radius_factor = 1 << n_refinement_steps;
6085 outer_radius_factor * outer_radius -
6086 (outer_radius_factor - 1) * inner_radius);
6091 outer_radius_factor * outer_radius -
6092 (outer_radius_factor - 1) * inner_radius);
6095 for (
unsigned int r = 0; r < n_refinement_steps; ++r)
6098 std::set<Triangulation<3>::active_cell_iterator> cells_to_remove;
6104 unsigned int n_vertices_inside = 0;
6106 if ((cell->vertex(v) - p).norm_square() <
6107 inner_radius * inner_radius * (1 + 1e-12))
6108 ++n_vertices_inside;
6109 if (n_vertices_inside < 4)
6110 cells_to_remove.insert(cell);
6114 if (r == n_refinement_steps - 1)
6124 tmp = std::move(copy);
6142 const double inner_radius,
6143 const double outer_radius,
6144 const unsigned int n_cells,
6147 Assert((inner_radius > 0) && (inner_radius < outer_radius),
6150 unsigned int n_refinement_steps = 0;
6151 unsigned int n_cells_coarsened =
n_cells;
6152 if (n_cells != 96 && n_cells > 12)
6153 while (n_cells_coarsened > 12 && n_cells_coarsened % 4 == 0)
6155 ++n_refinement_steps;
6156 n_cells_coarsened /= 4;
6158 Assert(n_cells == 0 || n_cells == 6 || n_cells == 12 || n_cells == 96 ||
6159 (n_refinement_steps > 0 &&
6160 (n_cells_coarsened == 6 || n_cells_coarsened == 12)),
6161 ExcMessage(
"Invalid number of coarse mesh cells"));
6163 const unsigned int n = n_refinement_steps > 0 ?
6164 4 * n_cells_coarsened :
6165 ((
n_cells == 0) ? 6 : n_cells);
6170 internal::hyper_shell_6(
tria, p, inner_radius, outer_radius);
6173 internal::hyper_shell_12(
tria, p, inner_radius, outer_radius);
6177 internal::hyper_shell_24_48(
6178 tria, n, n_refinement_steps, p, inner_radius, outer_radius);
6187 internal::hyper_shell_12(tmp, p, inner_radius, outer_radius);
6204 colorize_hyper_shell(
tria, p, inner_radius, outer_radius);
6214 const double inner_radius,
6215 const double outer_radius,
6216 const unsigned int ,
6219 Assert((inner_radius > 0) && (inner_radius < outer_radius),
6223 const double d = outer_radius /
std::sqrt(2.0);
6224 const double a = inner_radius /
std::sqrt(2.0);
6226 const double b = a / 2.0;
6227 const double c =
d / 2.0;
6229 const double hb = inner_radius *
std::sqrt(3.0) / 2.0;
6230 const double hc = outer_radius *
std::sqrt(3.0) / 2.0;
6252 int cell_vertices[5][8] = {{0, 1, 8, 9, 2, 3, 10, 11},
6253 {0, 2, 8, 10, 6, 4, 14, 12},
6254 {1, 7, 9, 15, 3, 5, 11, 13},
6255 {6, 4, 14, 12, 7, 5, 15, 13},
6256 {8, 10, 9, 11, 14, 12, 15, 13}};
6260 for (
unsigned int i = 0; i < 5; ++i)
6262 for (
unsigned int j = 0; j < 8; ++j)
6263 cells[i].
vertices[j] = cell_vertices[i][j];
6264 cells[i].material_id = 0;
6278 for (; cell !=
tria.
end(); ++cell)
6280 if (cell->at_boundary(i))
6281 cell->face(i)->set_all_boundary_ids(2);
6289 if (cell->at_boundary(i))
6293 const Point<3> face_center(face->center());
6295 1.e-6 * face_center.
norm())
6299 face->set_all_boundary_ids(0);
6301 face->set_all_boundary_ids(1);
6315 const double inner_radius,
6316 const double outer_radius,
6317 const unsigned int n,
6320 Assert((inner_radius > 0) && (inner_radius < outer_radius),
6322 if (n == 0 || n == 3)
6324 const double a = inner_radius *
std::sqrt(2.0) / 2e0;
6325 const double b = outer_radius *
std::sqrt(2.0) / 2e0;
6326 const double c = a *
std::sqrt(3.0) / 2e0;
6328 const double e = outer_radius / 2e0;
6329 const double h = inner_radius / 2e0;
6348 const int cell_vertices[3][8] = {
6349 {0, 1, 3, 2, 4, 5, 7, 6},
6350 {1, 8, 2, 9, 5, 10, 6, 11},
6351 {4, 5, 7, 6, 12, 10, 13, 11},
6353 std::vector<CellData<3>> cells(3);
6355 for (
unsigned int i = 0; i < 3; ++i)
6357 for (
unsigned int j = 0; j < 8; ++j)
6358 cells[i].
vertices[j] = cell_vertices[i][j];
6359 cells[i].material_id = 0;
6372 colorize_quarter_hyper_shell(
tria,
center, inner_radius, outer_radius);
6383 const double length,
6384 const double inner_radius,
6385 const double outer_radius,
6386 const unsigned int n_radial_cells,
6387 const unsigned int n_axial_cells)
6389 Assert((inner_radius > 0) && (inner_radius < outer_radius),
6403 const unsigned int N_r =
6404 (n_radial_cells == 0 ?
static_cast<unsigned int>(std::ceil(
6405 (2 * pi * (outer_radius + inner_radius) / 2) /
6406 (outer_radius - inner_radius))) :
6408 const unsigned int N_z =
6409 (n_axial_cells == 0 ?
6410 static_cast<unsigned int>(std::ceil(
6411 length / (2 * pi * (outer_radius + inner_radius) / 2 / N_r))) :
6420 std::vector<Point<2>> vertices_2d(2 * N_r);
6421 for (
unsigned int i = 0; i < N_r; ++i)
6426 vertices_2d[i + N_r] = vertices_2d[i] * (inner_radius / outer_radius);
6429 std::vector<Point<3>> vertices_3d;
6430 vertices_3d.reserve(2 * N_r * (N_z + 1));
6431 for (
unsigned int j = 0; j <= N_z; ++j)
6432 for (
unsigned int i = 0; i < 2 * N_r; ++i)
6434 const Point<3> v(vertices_2d[i][0],
6437 vertices_3d.push_back(v);
6440 std::vector<CellData<3>> cells(N_r * N_z,
CellData<3>());
6442 for (
unsigned int j = 0; j < N_z; ++j)
6443 for (
unsigned int i = 0; i < N_r; ++i)
6445 cells[i + j * N_r].vertices[0] = i + (j + 1) * 2 * N_r;
6446 cells[i + j * N_r].vertices[1] = (i + 1) % N_r + (j + 1) * 2 * N_r;
6447 cells[i + j * N_r].vertices[2] = i + j * 2 * N_r;
6448 cells[i + j * N_r].vertices[3] = (i + 1) % N_r + j * 2 * N_r;
6450 cells[i + j * N_r].vertices[4] = N_r + i + (j + 1) * 2 * N_r;
6451 cells[i + j * N_r].vertices[5] =
6452 N_r + ((i + 1) % N_r) + (j + 1) * 2 * N_r;
6453 cells[i + j * N_r].vertices[6] = N_r + i + j * 2 * N_r;
6454 cells[i + j * N_r].vertices[7] = N_r + ((i + 1) % N_r) + j * 2 * N_r;
6456 cells[i + j * N_r].material_id = 0;
6466 template <
int dim,
int spacedim>
6471 const double duplicated_vertex_tolerance,
6472 const bool copy_manifold_ids)
6474 std::vector<Point<spacedim>>
vertices;
6475 std::vector<CellData<dim>> cells;
6478 unsigned int n_accumulated_vertices = 0;
6482 ExcMessage(
"The input triangulations must be non-empty "
6483 "and must not be refined."));
6485 std::vector<Point<spacedim>> tria_vertices;
6486 std::vector<CellData<dim>> tria_cells;
6488 std::tie(tria_vertices, tria_cells, tria_subcell_data) =
6492 tria_vertices.begin(),
6493 tria_vertices.end());
6496 for (
unsigned int &vertex_n : cell_data.vertices)
6497 vertex_n += n_accumulated_vertices;
6498 cells.push_back(cell_data);
6502 if (copy_manifold_ids)
6508 for (
unsigned int &vertex_n : line_data.
vertices)
6509 vertex_n += n_accumulated_vertices;
6519 for (
unsigned int &vertex_n : quad_data.
vertices)
6520 vertex_n += n_accumulated_vertices;
6531 std::vector<unsigned int> considered_vertices;
6535 considered_vertices,
6536 duplicated_vertex_tolerance);
6540 if (std::all_of(cells.begin(), cells.end(), [](
const auto &cell) {
6541 return cell.vertices.size() ==
6542 ReferenceCells::get_hypercube<dim>().n_vertices();
6551 template <
int dim,
int spacedim>
6556 const double duplicated_vertex_tolerance,
6557 const bool copy_manifold_ids)
6560 if (triangulation_1.
n_cells() == 0)
6565 if (triangulation_2.
n_cells() == 0)
6572 duplicated_vertex_tolerance,
6601 template <
int structdim>
6605 static_assert(structdim == 1 || structdim == 2,
6606 "This function is only implemented for lines and "
6614 std::sort(std::begin(cell_data.vertices),
6615 std::end(cell_data.vertices));
6616 else if (structdim == 2)
6619 std::array<unsigned int, 4> renumbering;
6620 std::copy(std::begin(cell_data.vertices),
6621 std::end(cell_data.vertices),
6622 renumbering.begin());
6633 std::swap(renumbering[2], renumbering[3]);
6634 std::rotate(renumbering.begin(),
6635 std::min_element(renumbering.begin(),
6639 std::swap(renumbering[2], renumbering[3]);
6647 if (renumbering[1] > renumbering[2])
6648 std::swap(renumbering[1], renumbering[2]);
6649 std::copy(renumbering.begin(),
6651 std::begin(cell_data.vertices));
6658 return std::lexicographical_compare(std::begin(a.
vertices),
6660 std::begin(
b.vertices),
6661 std::end(
b.vertices));
6663 std::sort(subcell_data.begin(), subcell_data.end(), compare);
6668 auto left = subcell_data.begin();
6669 while (left != subcell_data.end())
6672 std::upper_bound(left, subcell_data.end(), *left, compare);
6675 if (left + 1 != right)
6676 for (
auto it = left; it != right; ++it)
6679 Assert(it->manifold_id == left->manifold_id,
6681 "In the process of grid generation a single "
6682 "line or quadrilateral has been assigned two "
6683 "different manifold ids. This can happen when "
6684 "a Triangulation is copied, e.g., via "
6685 "GridGenerator::replicate_triangulation() and "
6686 "not all external boundary faces have the same "
6687 "manifold id. Double check that all faces "
6688 "which you expect to be merged together have "
6689 "the same manifold id."));
6694 subcell_data.erase(std::unique(subcell_data.begin(), subcell_data.end()),
6695 subcell_data.end());
6701 template <
int dim,
int spacedim>
6704 const std::vector<unsigned int> & extents,
6709 for (
const auto &extent : extents)
6711 ExcMessage(
"The Triangulation must be copied at least one time in "
6712 "each coordinate dimension."));
6715 const auto &
min = bbox.get_boundary_points().first;
6716 const auto &
max = bbox.get_boundary_points().second;
6718 std::array<Tensor<1, spacedim>, dim> offsets;
6719 for (
unsigned int d = 0;
d < dim; ++
d)
6720 offsets[d][d] = max[d] - min[d];
6724 for (
unsigned int d = 0;
d < dim; ++
d)
6726 std::vector<Point<spacedim>> input_vertices;
6727 std::vector<CellData<dim>> input_cell_data;
6729 std::tie(input_vertices, input_cell_data, input_subcell_data) =
6731 std::vector<Point<spacedim>> output_vertices = input_vertices;
6732 std::vector<CellData<dim>> output_cell_data = input_cell_data;
6733 SubCellData output_subcell_data = input_subcell_data;
6735 for (
unsigned int k = 1; k < extents[
d]; ++k)
6737 const std::size_t vertex_offset = k * input_vertices.size();
6740 output_vertices.push_back(point +
double(k) * offsets[d]);
6744 output_cell_data.push_back(cell_data);
6745 for (
unsigned int &vertex : output_cell_data.back().vertices)
6746 vertex += vertex_offset;
6753 for (
unsigned int &vertex :
6755 vertex += vertex_offset;
6761 for (
unsigned int &vertex :
6763 vertex += vertex_offset;
6768 std::vector<unsigned int> boundary_vertices;
6772 output_subcell_data,
6793 tria_to_replicate.
clear();
6796 output_subcell_data);
6804 template <
int dim,
int spacedim>
6812 ExcMessage(
"The two input triangulations are not derived from "
6813 "the same coarse mesh as required."));
6816 &triangulation_1) ==
nullptr) &&
6819 &triangulation_2) ==
nullptr),
6820 ExcMessage(
"The source triangulations for this function must both "
6821 "be available entirely locally, and not be distributed "
6822 "triangulations."));
6839 for (
unsigned int iteration = 0; iteration < triangulation_2.
n_levels();
6845 bool any_cell_flagged =
false;
6847 if (intergrid_map[result_cell]->has_children())
6849 any_cell_flagged =
true;
6850 result_cell->set_refine_flag();
6853 if (any_cell_flagged ==
false)
6862 template <
int dim,
int spacedim>
6876 std::vector<CellData<dim>> cells;
6878 if (cells_to_remove.find(cell) == cells_to_remove.end())
6880 Assert(
static_cast<unsigned int>(cell->level()) ==
6881 input_triangulation.
n_levels() - 1,
6883 "Your input triangulation appears to have "
6884 "adaptively refined cells. This is not allowed. You can "
6885 "only call this function on a triangulation in which "
6886 "all cells are on the same refinement level."));
6890 this_cell.
vertices[v] = cell->vertex_index(v);
6892 cells.push_back(this_cell);
6898 std::vector<unsigned int> considered_vertices;
6902 considered_vertices);
6914 const unsigned int n_slices,
6915 const double height,
6917 const bool copy_manifold_ids,
6918 const std::vector<types::manifold_id> &manifold_priorities)
6922 "The input triangulation must be a coarse mesh, i.e., it must "
6923 "not have been refined."));
6925 ExcMessage(
"The output triangulation object needs to be empty."));
6927 ExcMessage(
"The given height for extrusion must be positive."));
6930 "The number of slices for extrusion must be at least 2."));
6932 const double delta_h = height / (n_slices - 1);
6933 std::vector<double> slices_z_values;
6934 for (
unsigned int i = 0; i < n_slices; ++i)
6935 slices_z_values.push_back(i * delta_h);
6937 input, slices_z_values, result, copy_manifold_ids, manifold_priorities);
6945 const unsigned int n_slices,
6946 const double height,
6948 const bool copy_manifold_ids,
6949 const std::vector<types::manifold_id> &manifold_priorities)
6955 (void)copy_manifold_ids;
6956 (void)manifold_priorities;
6960 "GridTools::extrude_triangulation() is only available "
6961 "for Triangulation<3, 3> as output triangulation."));
6969 const std::vector<double> & slice_coordinates,
6971 const bool copy_manifold_ids,
6972 const std::vector<types::manifold_id> &manifold_priorities)
6976 "The input triangulation must be a coarse mesh, i.e., it must "
6977 "not have been refined."));
6979 ExcMessage(
"The output triangulation object needs to be empty."));
6980 Assert(slice_coordinates.size() >= 2,
6982 "The number of slices for extrusion must be at least 2."));
6983 Assert(std::is_sorted(slice_coordinates.begin(), slice_coordinates.end()),
6984 ExcMessage(
"Slice z-coordinates should be in ascending order"));
6986 const auto priorities = [&]() -> std::vector<types::manifold_id> {
6990 if (0 < manifold_priorities.size())
6994 std::vector<types::manifold_id> sorted_manifold_priorities =
6995 manifold_priorities;
6996 std::sort(sorted_manifold_priorities.begin(),
6997 sorted_manifold_priorities.end());
6998 Assert(std::unique(sorted_manifold_priorities.begin(),
6999 sorted_manifold_priorities.end()) ==
7000 sorted_manifold_priorities.end(),
7002 "The given vector of manifold ids may not contain any "
7003 "duplicated entries."));
7004 std::vector<types::manifold_id> sorted_manifold_ids =
7006 std::sort(sorted_manifold_ids.begin(), sorted_manifold_ids.end());
7007 if (sorted_manifold_priorities != sorted_manifold_ids)
7009 std::ostringstream message;
7010 message <<
"The given triangulation has manifold ids {";
7012 if (manifold_id != sorted_manifold_ids.back())
7014 message << sorted_manifold_ids.back() <<
"}, but \n"
7015 <<
" the given vector of manifold ids is {";
7017 if (manifold_id != manifold_priorities.back())
7020 << manifold_priorities.back() <<
"}.\n"
7021 <<
" These vectors should contain the same elements.\n";
7022 const std::string m = message.str();
7026 return manifold_priorities;
7030 std::vector<types::manifold_id> default_priorities =
7032 const auto first_tfi_it = std::partition(
7033 default_priorities.begin(),
7034 default_priorities.end(),
7036 return dynamic_cast<const TransfiniteInterpolationManifold<2, 2> *>(
7037 &input.get_manifold(id)) == nullptr;
7039 std::sort(default_priorities.begin(), first_tfi_it);
7040 std::sort(first_tfi_it, default_priorities.end());
7042 return default_priorities;
7045 const std::size_t n_slices = slice_coordinates.size();
7046 std::vector<Point<3>> points(n_slices * input.
n_vertices());
7047 std::vector<CellData<3>> cells;
7052 for (std::size_t slice_n = 0; slice_n < n_slices; ++slice_n)
7054 for (std::size_t vertex_n = 0; vertex_n < input.
n_vertices();
7058 points[slice_n * input.
n_vertices() + vertex_n] =
7059 Point<3>(vertex[0], vertex[1], slice_coordinates[slice_n]);
7067 for (std::size_t slice_n = 0; slice_n < n_slices - 1; ++slice_n)
7070 for (
const unsigned int vertex_n :
7074 cell->vertex_index(vertex_n) + slice_n * input.
n_vertices();
7077 cell->vertex_index(vertex_n) +
7082 if (copy_manifold_ids)
7084 cells.push_back(this_cell);
7099 if (face->at_boundary())
7101 if (copy_manifold_ids)
7103 for (std::size_t slice_n = 0; slice_n < n_slices - 1; ++slice_n)
7106 face->vertex_index(0) + slice_n * input.
n_vertices();
7108 face->vertex_index(1) + slice_n * input.
n_vertices();
7110 face->vertex_index(0) + (slice_n + 1) * input.
n_vertices();
7112 face->vertex_index(1) + (slice_n + 1) * input.
n_vertices();
7113 quads.push_back(quad);
7119 if (copy_manifold_ids)
7125 for (std::size_t slice_n = 1; slice_n < n_slices - 1; ++slice_n)
7128 cell->vertex_index(0) + slice_n * input.
n_vertices();
7130 cell->vertex_index(1) + slice_n * input.
n_vertices();
7132 cell->vertex_index(2) + slice_n * input.
n_vertices();
7134 cell->vertex_index(3) + slice_n * input.
n_vertices();
7135 quads.push_back(quad);
7146 "The input triangulation to this function is using boundary "
7147 "indicators in a range that do not allow using "
7148 "max_boundary_id+1 and max_boundary_id+2 as boundary "
7149 "indicators for the bottom and top faces of the "
7150 "extruded triangulation."));
7157 quad.
vertices[0] = cell->vertex_index(0);
7158 quad.
vertices[1] = cell->vertex_index(1);
7159 quad.
vertices[2] = cell->vertex_index(2);
7160 quad.
vertices[3] = cell->vertex_index(3);
7161 if (copy_manifold_ids)
7163 quads.push_back(quad);
7166 for (
unsigned int &vertex : quad.
vertices)
7167 vertex += (n_slices - 1) * input.
n_vertices();
7168 if (copy_manifold_ids)
7170 quads.push_back(quad);
7183 for (
auto manifold_id_it = priorities.rbegin();
7184 manifold_id_it != priorities.rend();
7187 if (face->manifold_id() == *manifold_id_it)
7188 for (
unsigned int line_n = 0;
7189 line_n < GeometryInfo<3>::lines_per_face;
7191 face->line(line_n)->set_manifold_id(*manifold_id_it);
7199 const std::vector<double> & slice_coordinates,
7201 const bool copy_manifold_ids,
7202 const std::vector<types::manifold_id> &manifold_priorities)
7205 (void)slice_coordinates;
7207 (void)copy_manifold_ids;
7208 (void)manifold_priorities;
7212 "GridTools::extrude_triangulation() is only available "
7213 "for Triangulation<3, 3> as output triangulation."));
7235 const double inner_radius,
7236 const double outer_radius,
7243 Assert(inner_radius < outer_radius,
7244 ExcMessage(
"outer_radius has to be bigger than inner_radius."));
7253 std::vector<bool> treated_vertices(
triangulation.n_vertices(),
false);
7254 for (; cell != endc; ++cell)
7257 if (cell->face(f)->at_boundary())
7259 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_face;
7262 unsigned int vv = cell->face(f)->vertex_index(v);
7263 if (treated_vertices[vv] ==
false)
7265 treated_vertices[vv] =
true;
7269 cell->face(f)->vertex(v) =
7273 cell->face(f)->vertex(v) =
7277 cell->face(f)->vertex(v) =
7281 cell->face(f)->vertex(v) =
7291 double eps = 1
e-3 * outer_radius;
7293 for (; cell != endc; ++cell)
7296 if (cell->face(f)->at_boundary())
7298 double dx = cell->face(f)->center()(0) -
center(0);
7299 double dy = cell->face(f)->center()(1) -
center(1);
7303 cell->face(f)->set_boundary_id(0);
7305 cell->face(f)->set_boundary_id(1);
7307 cell->face(f)->set_boundary_id(2);
7309 cell->face(f)->set_boundary_id(3);
7312 cell->face(f)->set_boundary_id(4);
7313 cell->face(f)->set_manifold_id(0);
7318 double d = (cell->face(f)->center() -
center).
norm();
7319 if (d - inner_radius < 0)
7321 cell->face(f)->set_boundary_id(1);
7322 cell->face(f)->set_manifold_id(0);
7325 cell->face(f)->set_boundary_id(0);
7338 const double inner_radius,
7339 const double outer_radius,
7340 const unsigned int n_shells,
7341 const double skewness,
7342 const unsigned int n_cells,
7348 Assert(inner_radius < outer_radius,
7349 ExcMessage(
"outer_radius has to be bigger than inner_radius."));
7353 std::vector<double> radii;
7354 radii.push_back(inner_radius);
7355 for (
unsigned int shell_n = 1; shell_n < n_shells; ++shell_n)
7356 if (skewness == 0.0)
7358 radii.push_back(inner_radius +
7359 (outer_radius - inner_radius) *
7360 (1.0 - (1.0 -
double(shell_n) / n_shells)));
7364 (outer_radius - inner_radius) *
7365 (1.0 - std::tanh(skewness * (1.0 -
double(shell_n) / n_shells)) /
7366 std::tanh(skewness)));
7367 radii.push_back(outer_radius);
7369 double grid_vertex_tolerance = 0.0;
7370 for (
unsigned int shell_n = 0; shell_n < radii.size() - 1; ++shell_n)
7377 n_cells == 0 ? (dim == 2 ? 8 : 12) :
7382 if (grid_vertex_tolerance == 0.0)
7383 grid_vertex_tolerance =
7384 0.5 * internal::minimal_vertex_distance(current_shell);
7391 grid_vertex_tolerance);
7403 constexpr double radial_vertex_tolerance =
7404 100.0 * std::numeric_limits<double>::epsilon();
7405 auto assert_vertex_distance_within_tolerance =
7406 [
center, radial_vertex_tolerance](
7408 const double radius) {
7410 (void)radial_vertex_tolerance;
7413 for (
unsigned int vertex_n = 0;
7414 vertex_n < GeometryInfo<dim>::vertices_per_face;
7418 (
center.
norm() + radius) * radial_vertex_tolerance,
7423 for (
const auto &cell :
triangulation.active_cell_iterators())
7426 auto face = cell->face(face_n);
7427 if (face->at_boundary())
7429 if (((face->vertex(0) -
center).norm() - inner_radius) <
7430 (
center.
norm() + inner_radius) * radial_vertex_tolerance)
7433 assert_vertex_distance_within_tolerance(face, inner_radius);
7434 face->set_all_boundary_ids(0);
7439 assert_vertex_distance_within_tolerance(face, outer_radius);
7440 face->set_all_boundary_ids(1);
7451 const double inner_radius,
7452 const double outer_radius,
7454 const unsigned int Nz,
7459 Assert(inner_radius < outer_radius,
7460 ExcMessage(
"outer_radius has to be bigger than inner_radius."));
7470 std::vector<bool> treated_vertices(
triangulation.n_vertices(),
false);
7471 for (; cell != endc; ++cell)
7474 if (cell->face(f)->at_boundary())
7476 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_face;
7479 unsigned int vv = cell->face(f)->vertex_index(v);
7480 if (treated_vertices[vv] ==
false)
7482 treated_vertices[vv] =
true;
7483 for (
unsigned int i = 0; i <= Nz; ++i)
7485 double d = i * L / Nz;
7486 switch (vv - i * 16)
7489 cell->face(f)->vertex(v) =
7493 cell->face(f)->vertex(v) =
7497 cell->face(f)->vertex(v) =
7501 cell->face(f)->vertex(v) =
7512 double eps = 1
e-3 * outer_radius;
7514 for (; cell != endc; ++cell)
7517 if (cell->face(f)->at_boundary())
7519 double dx = cell->face(f)->center()(0);
7520 double dy = cell->face(f)->center()(1);
7521 double dz = cell->face(f)->center()(2);
7526 cell->face(f)->set_boundary_id(0);
7529 cell->face(f)->set_boundary_id(1);
7532 cell->face(f)->set_boundary_id(2);
7535 cell->face(f)->set_boundary_id(3);
7538 cell->face(f)->set_boundary_id(4);
7541 cell->face(f)->set_boundary_id(5);
7545 cell->face(f)->set_all_boundary_ids(6);
7546 cell->face(f)->set_all_manifold_ids(0);
7553 double d = c.
norm();
7554 if (d - inner_radius < 0)
7556 cell->face(f)->set_all_boundary_ids(1);
7557 cell->face(f)->set_all_manifold_ids(0);
7560 cell->face(f)->set_boundary_id(0);
7569 template <
int dim,
int spacedim1,
int spacedim2>
7576 &in_tria) ==
nullptr),
7578 "This function cannot be used on "
7579 "parallel::distributed::Triangulation objects as inputs."));
7581 ExcMessage(
"This function does not work for meshes that have "
7585 const unsigned int spacedim =
std::min(spacedim1, spacedim2);
7586 const std::vector<Point<spacedim1>> &in_vertices = in_tria.
get_vertices();
7590 std::vector<Point<spacedim2>> v(in_vertices.size());
7591 for (
unsigned int i = 0; i < in_vertices.size(); ++i)
7592 for (
unsigned int d = 0;
d < spacedim; ++
d)
7593 v[i][d] = in_vertices[i][d];
7598 const unsigned int id = cell->active_cell_index();
7600 cells[id].vertices.resize(cell->n_vertices());
7601 for (
const auto i : cell->vertex_indices())
7602 cells[id].vertices[i] = cell->vertex_index(i);
7603 cells[id].material_id = cell->material_id();
7604 cells[id].manifold_id = cell->manifold_id();
7618 std::vector<bool> user_flags_line;
7621 .clear_user_flags_line();
7627 if (face->at_boundary())
7631 boundary_line.
vertices.resize(face->n_vertices());
7632 for (
const auto i : face->vertex_indices())
7633 boundary_line.
vertices[i] = face->vertex_index(i);
7638 std::move(boundary_line));
7651 if ((face->user_flag_set() ==
false) &&
7656 boundary_line.
vertices.resize(face->n_vertices());
7657 for (
const auto i : face->vertex_indices())
7658 boundary_line.
vertices[i] = face->vertex_index(i);
7664 std::move(boundary_line));
7666 face->set_user_flag();
7672 .load_user_flags_line(user_flags_line);
7679 std::vector<bool> user_flags_line;
7682 .clear_user_flags_line();
7684 std::vector<bool> user_flags_quad;
7687 .clear_user_flags_quad();
7693 if (face->at_boundary())
7697 boundary_face.
vertices.resize(face->n_vertices());
7698 for (
const auto i : face->vertex_indices())
7699 boundary_face.
vertices[i] = face->vertex_index(i);
7704 std::move(boundary_face));
7711 for (
unsigned int e = 0;
e < face->n_lines(); ++
e)
7712 if (face->line(e)->user_flag_set() ==
false)
7715 spacedim1>::line_iterator
7716 edge = face->line(e);
7719 boundary_edge.
vertices.resize(edge->n_vertices());
7720 for (
const auto i : edge->vertex_indices())
7721 boundary_edge.
vertices[i] = edge->vertex_index(i);
7726 std::move(boundary_edge));
7728 edge->set_user_flag();
7746 if (face->user_flag_set() ==
false)
7752 boundary_face.
vertices.resize(face->n_vertices());
7753 for (
const auto i : face->vertex_indices())
7754 boundary_face.
vertices[i] = face->vertex_index(i);
7760 std::move(boundary_face));
7762 face->set_user_flag();
7770 for (
unsigned int e = 0;
e < face->n_lines(); ++
e)
7771 if (face->line(e)->at_boundary() ==
false)
7772 if (face->line(e)->user_flag_set() ==
false)
7775 line_iterator edge = face->line(e);
7779 for (
const auto i : edge->vertex_indices())
7780 boundary_edge.
vertices[i] = edge->vertex_index(i);
7786 std::move(boundary_edge));
7788 edge->set_user_flag();
7795 .load_user_flags_line(user_flags_line);
7797 .load_user_flags_quad(user_flags_quad);
7810 template <
int dim,
int spacedim>
7850 {{{0, 1, 12, 10}}, {{2, 3, 11, 12}}, {{7, 6, 11, 13}},
7851 {{5, 4, 13, 10}}, {{0, 2, 8, 12}}, {{4, 6, 13, 8}},
7852 {{5, 13, 7, 9}}, {{1, 9, 3, 12}}, {{0, 8, 4, 10}},
7853 {{1, 5, 9, 10}}, {{3, 7, 11, 9}}, {{2, 6, 8, 11}},
7854 {{12, 13, 10, 9}}, {{12, 13, 9, 11}}, {{12, 13, 11, 8}},
7855 {{12, 13, 8, 10}}, {{13, 8, 10, 4}}, {{13, 10, 9, 5}},
7856 {{13, 9, 11, 7}}, {{13, 11, 8, 6}}, {{10, 12, 9, 1}},
7857 {{9, 12, 11, 3}}, {{11, 12, 8, 2}}, {{8, 12, 10, 0}}}};
7865 vertex_ids_for_boundary_faces_2d = {{{{{{0, 4}}, {{4, 2}}}},
7866 {{{{1, 5}}, {{5, 3}}}},
7867 {{{{0, 6}}, {{6, 1}}}},
7868 {{{{2, 7}}, {{7, 3}}}}}};
7876 vertex_ids_for_boundary_faces_3d = {
7877 {{{{{0, 4, 8}}, {{4, 8, 6}}, {{8, 6, 2}}, {{0, 2, 8}}}},
7878 {{{{1, 3, 9}}, {{3, 9, 7}}, {{9, 7, 5}}, {{1, 9, 5}}}},
7879 {{{{0, 1, 10}}, {{1, 10, 5}}, {{10, 5, 4}}, {{0, 10, 4}}}},
7880 {{{{2, 3, 11}}, {{3, 11, 7}}, {{11, 7, 6}}, {{2, 11, 6}}}},
7881 {{{{0, 1, 12}}, {{1, 12, 3}}, {{12, 3, 2}}, {{0, 12, 2}}}},
7882 {{{{4, 5, 13}}, {{5, 13, 7}}, {{13, 7, 6}}, {{4, 13, 6}}}}}};
7903 {{{0, 12, 10}}, {{12, 1, 10}}, {{12, 1, 9}}, {{12, 3, 9}},
7904 {{12, 2, 11}}, {{12, 3, 11}}, {{12, 0, 8}}, {{12, 2, 8}},
7905 {{9, 13, 5}}, {{13, 7, 9}}, {{11, 7, 13}}, {{11, 6, 13}},
7906 {{4, 8, 13}}, {{6, 8, 13}}, {{4, 13, 10}}, {{13, 5, 10}},
7907 {{10, 9, 5}}, {{10, 9, 1}}, {{11, 9, 7}}, {{11, 9, 3}},
7908 {{8, 11, 2}}, {{8, 11, 6}}, {{8, 10, 0}}, {{8, 10, 4}},
7909 {{12, 3, 9}}, {{12, 9, 11}}, {{12, 3, 11}}, {{3, 9, 11}},
7910 {{2, 12, 8}}, {{2, 12, 11}}, {{2, 11, 8}}, {{8, 12, 11}},
7911 {{0, 12, 10}}, {{0, 12, 8}}, {{0, 8, 10}}, {{8, 10, 12}},
7912 {{12, 1, 10}}, {{12, 1, 9}}, {{1, 10, 9}}, {{10, 9, 12}},
7913 {{10, 8, 4}}, {{10, 8, 13}}, {{4, 13, 8}}, {{4, 13, 10}},
7914 {{10, 9, 13}}, {{10, 9, 5}}, {{13, 5, 10}}, {{13, 5, 9}},
7915 {{13, 7, 9}}, {{13, 7, 11}}, {{9, 11, 13}}, {{9, 11, 7}},
7916 {{8, 11, 13}}, {{8, 11, 6}}, {{6, 13, 8}}, {{6, 13, 11}},
7917 {{12, 13, 10}}, {{12, 13, 8}}, {{8, 10, 13}}, {{8, 10, 12}},
7918 {{12, 13, 10}}, {{12, 13, 9}}, {{10, 9, 13}}, {{10, 9, 12}},
7919 {{12, 13, 9}}, {{12, 13, 11}}, {{9, 11, 13}}, {{9, 11, 12}},
7920 {{12, 13, 11}}, {{12, 13, 8}}, {{8, 11, 13}}, {{8, 11, 12}}}};
7927 {{{12, 10}}, {{12, 9}}, {{12, 11}}, {{12, 8}}, {{9, 13}}, {{11, 13}},
7928 {{8, 13}}, {{10, 13}}, {{10, 9}}, {{9, 11}}, {{11, 8}}, {{8, 10}},
7929 {{12, 9}}, {{12, 11}}, {{11, 9}}, {{12, 8}}, {{12, 11}}, {{11, 8}},
7930 {{12, 8}}, {{12, 10}}, {{10, 8}}, {{12, 10}}, {{12, 9}}, {{9, 10}},
7931 {{13, 10}}, {{13, 8}}, {{8, 10}}, {{13, 10}}, {{13, 9}}, {{9, 10}},
7932 {{13, 11}}, {{13, 9}}, {{11, 9}}, {{13, 11}}, {{13, 8}}, {{11, 8}},
7933 {{12, 13}}, {{8, 10}}, {{8, 13}}, {{10, 13}}, {{8, 12}}, {{10, 12}},
7934 {{12, 13}}, {{10, 9}}, {{10, 13}}, {{9, 13}}, {{10, 12}}, {{9, 12}},
7935 {{12, 13}}, {{9, 11}}, {{9, 13}}, {{11, 13}}, {{9, 12}}, {{11, 12}},
7936 {{12, 13}}, {{11, 8}}, {{11, 13}}, {{8, 13}}, {{11, 12}}, {{8, 12}}}};
7949 vertex_ids_for_new_boundary_edges_3d = {
7950 {{{{{4, 8}}, {{6, 8}}, {{0, 8}}, {{2, 8}}}},
7951 {{{{5, 9}}, {{7, 9}}, {{1, 9}}, {{3, 9}}}},
7952 {{{{4, 10}}, {{5, 10}}, {{0, 10}}, {{1, 10}}}},
7953 {{{{6, 11}}, {{7, 11}}, {{2, 11}}, {{3, 11}}}},
7954 {{{{2, 12}}, {{3, 12}}, {{0, 12}}, {{1, 12}}}},
7955 {{{{6, 13}}, {{7, 13}}, {{4, 13}}, {{5, 13}}}}}};
7957 std::vector<Point<spacedim>>
vertices;
7958 std::vector<CellData<dim>> cells;
7963 std::vector<unsigned int> old_to_new_vertex_indices(
7965 std::vector<unsigned int> face_to_new_vertex_indices(
7975 for (
const auto &cell : ref_tria)
7979 std::array<unsigned int, dim == 2 ? 9 : 14> local_vertex_indices;
7982 for (
const auto v : cell.vertex_indices())
7984 const auto v_global = cell.vertex_index(v);
7986 if (old_to_new_vertex_indices[v_global] ==
7989 old_to_new_vertex_indices[v_global] =
vertices.size();
7990 vertices.push_back(cell.vertex(v));
7994 local_vertex_indices[v] = old_to_new_vertex_indices[v_global];
7998 for (
const auto f : cell.face_indices())
8000 const auto f_global = cell.face_index(f);
8002 if (face_to_new_vertex_indices[f_global] ==
8005 face_to_new_vertex_indices[f_global] =
vertices.size();
8007 cell.face(f)->center(
true));
8011 local_vertex_indices.size());
8012 local_vertex_indices[cell.n_vertices() + f] =
8013 face_to_new_vertex_indices[f_global];
8020 local_vertex_indices.size());
8021 local_vertex_indices[cell.n_vertices() + cell.n_faces()] =
8023 vertices.push_back(cell.center(
true));
8027 const auto add_cell = [&](
const unsigned int struct_dim,
8028 const auto & index_vertices,
8029 const unsigned int material_or_boundary_id,
8033 if (struct_dim < dim &&
8038 if (struct_dim == dim)
8050 for (
unsigned int i = 0; i < index_vertices.size(); ++i)
8053 local_vertex_indices.size());
8054 cell_data.vertices[i] =
8055 local_vertex_indices[index_vertices[i]];
8056 cell_data.material_id =
8057 material_or_boundary_id;
8058 cell_data.manifold_id =
8061 cells.push_back(cell_data);
8063 else if (dim == 2 && struct_dim == 1)
8067 boundary_line.
boundary_id = material_or_boundary_id;
8069 for (
unsigned int i = 0; i < index_vertices.size(); ++i)
8072 local_vertex_indices.size());
8074 local_vertex_indices[index_vertices[i]];
8078 else if (dim == 3 && struct_dim == 2)
8082 boundary_quad.
material_id = material_or_boundary_id;
8084 for (
unsigned int i = 0; i < index_vertices.size(); ++i)
8087 local_vertex_indices.size());
8089 local_vertex_indices[index_vertices[i]];
8093 else if (dim == 3 && struct_dim == 1)
8097 boundary_line.
boundary_id = material_or_boundary_id;
8099 for (
unsigned int i = 0; i < index_vertices.size(); ++i)
8102 local_vertex_indices.size());
8104 local_vertex_indices[index_vertices[i]];
8114 const auto material_id_cell = cell.material_id();
8120 const auto manifold_id_cell = cell.manifold_id();
8122 for (
const auto &cell_vertices : table_2D_cell)
8123 add_cell(dim, cell_vertices, material_id_cell, manifold_id_cell);
8126 for (
const auto &face_vertices : vertex_ids_for_inner_faces_2d)
8138 const auto manifold_id_cell = cell.manifold_id();
8140 for (
const auto &cell_vertices : vertex_ids_for_cells_3d)
8141 add_cell(dim, cell_vertices, material_id_cell, manifold_id_cell);
8145 for (
const auto &face_vertices : vertex_ids_for_inner_faces_3d)
8153 for (
const auto &edge_vertices : vertex_ids_for_inner_edges_3d)
8163 for (
const auto f : cell.face_indices())
8165 const auto bid = cell.face(f)->boundary_id();
8166 const auto mid = cell.face(f)->manifold_id();
8171 for (
const auto &face_vertices :
8172 vertex_ids_for_boundary_faces_2d[f])
8173 add_cell(1, face_vertices, bid, mid);
8179 for (
const auto &face_vertices :
8180 vertex_ids_for_boundary_faces_3d[f])
8181 add_cell(2, face_vertices, bid, mid);
8184 for (
const auto &edge_vertices :
8185 vertex_ids_for_new_boundary_edges_3d[f])
8186 add_cell(1, edge_vertices, bid, mid);
8196 for (
const auto e : cell.line_indices())
8198 auto edge = cell.line(e);
8204 old_to_new_vertex_indices[edge->vertex_index(0)];
8206 old_to_new_vertex_indices[edge->vertex_index(1)];
8220 template <
int spacedim>
8231 template <
template <
int,
int>
class MeshType,
int dim,
int spacedim>
8233 std::map<
typename MeshType<dim - 1, spacedim>::cell_iterator,
8234 typename MeshType<dim, spacedim>::face_iterator>
8236 typename ExtractBoundaryMesh<MeshType, dim, spacedim>::return_type
8239 MeshType<dim - 1, spacedim> & surface_mesh,
8240 const std::set<types::boundary_id> &boundary_ids)
8244 &volume_mesh.get_triangulation()) ==
nullptr),
8253 const unsigned int boundary_dim = dim - 1;
8260 std::pair<typename MeshType<dim, spacedim>::face_iterator,
unsigned int>>
8261 temporary_mapping_level0;
8266 std::vector<bool> touched(volume_mesh.get_triangulation().n_vertices(),
8270 std::vector<CellData<boundary_dim>> cells;
8272 std::vector<Point<spacedim>>
vertices;
8275 std::map<unsigned int, unsigned int> map_vert_index;
8288 for (
unsigned int i1 = 0; i1 < GeometryInfo<spacedim>::faces_per_cell; ++i1)
8290 for (
unsigned int i2 = 0; i2 <
GeometryInfo<dim - 1>::vertices_per_cell;
8292 swap_matrix[i1][i2] = i2;
8298 std::swap(swap_matrix[0][1], swap_matrix[0][2]);
8299 std::swap(swap_matrix[2][1], swap_matrix[2][2]);
8300 std::swap(swap_matrix[4][1], swap_matrix[4][2]);
8304 std::swap(swap_matrix[1][0], swap_matrix[1][1]);
8305 std::swap(swap_matrix[2][0], swap_matrix[2][1]);
8310 for (
typename MeshType<dim, spacedim>::cell_iterator cell =
8311 volume_mesh.begin(0);
8312 cell != volume_mesh.end(0);
8316 const typename MeshType<dim, spacedim>::face_iterator face =
8319 if (face->at_boundary() &&
8320 (boundary_ids.empty() ||
8321 (boundary_ids.find(face->boundary_id()) != boundary_ids.end())))
8325 for (
const unsigned int j :
8328 const unsigned int v_index = face->vertex_index(j);
8330 if (!touched[v_index])
8332 vertices.push_back(face->vertex(j));
8333 map_vert_index[v_index] =
vertices.size() - 1;
8334 touched[v_index] =
true;
8337 c_data.
vertices[swap_matrix[i][j]] = map_vert_index[v_index];
8351 for (
unsigned int e = 0;
e < 4; ++
e)
8357 bool edge_found =
false;
8360 map_vert_index[face->line(e)->vertex_index(0)]) &&
8362 map_vert_index[face->line(e)->vertex_index(
8365 map_vert_index[face->line(e)->vertex_index(1)]) &&
8367 map_vert_index[face->line(e)->vertex_index(0)])))
8374 if (edge_found ==
true)
8381 map_vert_index[face->line(e)->vertex_index(0)];
8383 map_vert_index[face->line(e)->vertex_index(1)];
8390 cells.push_back(c_data);
8391 temporary_mapping_level0.push_back(std::make_pair(face, i));
8398 surface_mesh.get_triangulation())
8404 for (
const auto &cell : surface_mesh.active_cell_iterators())
8405 for (
unsigned int vertex = 0; vertex < 2; ++vertex)
8406 if (cell->face(vertex)->at_boundary())
8407 cell->face(vertex)->set_boundary_id(0);
8415 std::vector<std::pair<
8416 const typename MeshType<dim - 1, spacedim>::cell_iterator,
8417 std::pair<typename MeshType<dim, spacedim>::face_iterator,
unsigned int>>>
8418 temporary_map_boundary_cell_face;
8419 for (
const auto &cell : surface_mesh.active_cell_iterators())
8420 temporary_map_boundary_cell_face.push_back(
8421 std::make_pair(cell, temporary_mapping_level0.at(cell->index())));
8433 unsigned int index_cells_deepest_level = 0;
8436 bool changed =
false;
8440 std::vector<unsigned int> cells_refined;
8443 for (
unsigned int cell_n = index_cells_deepest_level;
8444 cell_n < temporary_map_boundary_cell_face.size();
8449 if (temporary_map_boundary_cell_face[cell_n]
8450 .
second.first->has_children())
8454 Assert(temporary_map_boundary_cell_face[cell_n]
8455 .
second.first->refinement_case() ==
8458 temporary_map_boundary_cell_face[cell_n]
8459 .first->set_refine_flag();
8460 cells_refined.push_back(cell_n);
8471 surface_mesh.get_triangulation())
8472 .execute_coarsening_and_refinement();
8475 index_cells_deepest_level = temporary_map_boundary_cell_face.size();
8476 for (
const auto &refined_cell_n : cells_refined)
8478 const typename MeshType<dim - 1, spacedim>::cell_iterator
8480 temporary_map_boundary_cell_face[refined_cell_n].first;
8481 const typename MeshType<dim,
8482 spacedim>::face_iterator refined_face =
8483 temporary_map_boundary_cell_face[refined_cell_n].second.first;
8484 const unsigned int refined_face_number =
8485 temporary_map_boundary_cell_face[refined_cell_n]
8487 for (
unsigned int child_n = 0;
8488 child_n < refined_cell->n_children();
8493 temporary_map_boundary_cell_face.push_back(
8494 std::make_pair(refined_cell->child(
8495 swap_matrix[refined_face_number][child_n]),
8496 std::make_pair(refined_face->child(child_n),
8497 refined_face_number)));
8507 std::map<
typename MeshType<dim - 1, spacedim>::cell_iterator,
8508 typename MeshType<dim, spacedim>::face_iterator>
8509 surface_to_volume_mapping;
8510 for (
unsigned int i = 0; i < temporary_map_boundary_cell_face.size(); ++i)
8511 surface_to_volume_mapping[temporary_map_boundary_cell_face[i].
first] =
8512 temporary_map_boundary_cell_face[i].
second.first;
8514 return surface_to_volume_mapping;
8519 template <
int dim,
int spacedim>
8521 subdivided_hyper_rectangle_with_simplices(
8523 const std::vector<unsigned int> &repetitions,
8532 std::vector<Point<spacedim>>
vertices;
8533 std::vector<CellData<dim>> cells;
8539 (p2[1] - p1[1]) / repetitions[1]);
8542 for (
unsigned int j = 0; j <= repetitions[1]; ++j)
8543 for (
unsigned int i = 0; i <= repetitions[0]; ++i)
8548 for (
unsigned int j = 0; j < repetitions[1]; ++j)
8549 for (
unsigned int i = 0; i < repetitions[0]; ++i)
8552 std::array<unsigned int, 4> quad{{
8553 (j + 0) * (repetitions[0] + 1) + i + 0,
8554 (j + 0) * (repetitions[0] + 1) + i + 1,
8555 (j + 1) * (repetitions[0] + 1) + i + 0,
8556 (j + 1) * (repetitions[0] + 1) + i + 1
8562 tri.
vertices = {quad[0], quad[1], quad[2]};
8563 cells.push_back(tri);
8569 tri.
vertices = {quad[3], quad[2], quad[1]};
8570 cells.push_back(tri);
8578 (p2[1] - p1[1]) / repetitions[1],
8579 (p2[2] - p1[2]) / repetitions[2]);
8582 for (
unsigned int k = 0; k <= repetitions[2]; ++k)
8583 for (
unsigned int j = 0; j <= repetitions[1]; ++j)
8584 for (
unsigned int i = 0; i <= repetitions[0]; ++i)
8587 p1[2] + dx[2] * k));
8590 for (
unsigned int k = 0; k < repetitions[2]; ++k)
8591 for (
unsigned int j = 0; j < repetitions[1]; ++j)
8592 for (
unsigned int i = 0; i < repetitions[0]; ++i)
8595 std::array<unsigned int, 8> quad{
8596 {(k + 0) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8597 (j + 0) * (repetitions[0] + 1) + i + 0,
8598 (k + 0) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8599 (j + 0) * (repetitions[0] + 1) + i + 1,
8600 (k + 0) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8601 (j + 1) * (repetitions[0] + 1) + i + 0,
8602 (k + 0) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8603 (j + 1) * (repetitions[0] + 1) + i + 1,
8604 (k + 1) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8605 (j + 0) * (repetitions[0] + 1) + i + 0,
8606 (k + 1) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8607 (j + 0) * (repetitions[0] + 1) + i + 1,
8608 (k + 1) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8609 (j + 1) * (repetitions[0] + 1) + i + 0,
8610 (k + 1) * (repetitions[0] + 1) * (repetitions[1] + 1) +
8611 (j + 1) * (repetitions[0] + 1) + i + 1}};
8616 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
8617 cell.
vertices = {{quad[0], quad[1], quad[2], quad[4]}};
8619 cell.
vertices = {{quad[0], quad[1], quad[3], quad[5]}};
8621 cells.push_back(cell);
8627 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
8628 cell.
vertices = {{quad[2], quad[1], quad[3], quad[7]}};
8630 cell.
vertices = {{quad[0], quad[3], quad[2], quad[6]}};
8631 cells.push_back(cell);
8637 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
8638 cell.
vertices = {{quad[1], quad[4], quad[5], quad[7]}};
8640 cell.
vertices = {{quad[0], quad[4], quad[5], quad[6]}};
8641 cells.push_back(cell);
8647 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
8648 cell.
vertices = {{quad[2], quad[4], quad[7], quad[6]}};
8650 cell.
vertices = {{quad[3], quad[5], quad[7], quad[6]}};
8651 cells.push_back(cell);
8657 if (((i % 2) + (j % 2) + (k % 2)) % 2 == 0)
8658 cell.
vertices = {{quad[1], quad[2], quad[4], quad[7]}};
8660 cell.
vertices = {{quad[0], quad[3], quad[6], quad[5]}};
8661 cells.push_back(cell);
8676 template <
int dim,
int spacedim>
8679 const unsigned int repetitions,
8686 subdivided_hyper_rectangle_with_simplices(
8687 tria, {{repetitions, repetitions}}, {p1, p1}, {p2, p2},
colorize);
8691 subdivided_hyper_rectangle_with_simplices(
8693 {{repetitions, repetitions, repetitions}},
8706# 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)
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
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_NAMESPACE_CLOSE
IteratorRange< active_face_iterator > active_face_iterators() const
IteratorRange< active_cell_iterator > active_cell_iterators() const
IteratorRange< cell_iterator > cell_iterators() const
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcLowerRange(int arg1, int arg2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcIndexRange(std::size_t arg1, std::size_t arg2, std::size_t arg3)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
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)
const Mapping< dim, spacedim > & get_default_linear_mapping(const Triangulation< dim, spacedim > &triangulation)
void create_triangulation(Triangulation< dim, dim > &tria, const AdditionalData &additional_data=AdditionalData())
void parallelepiped(Triangulation< dim > &tria, const Point< dim >(&corners)[dim], const bool colorize=false)
void convert_hypercube_to_simplex_mesh(const Triangulation< 1, spacedim > &in_tria, Triangulation< 1, spacedim > &out_tria)
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_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_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 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)
void cheese(Triangulation< dim, spacedim > &tria, const std::vector< unsigned int > &holes)
Rectangular domain with rectangular pattern of holes.
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)
void create_union_triangulation(const Triangulation< dim, spacedim > &triangulation_1, const Triangulation< dim, spacedim > &triangulation_2, Triangulation< dim, spacedim > &result)
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 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 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 hyper_shell(Triangulation< dim > &tria, const Point< dim > ¢er, const double inner_radius, const double outer_radius, const unsigned int n_cells=0, 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 hyper_cube_with_cylindrical_hole(Triangulation< dim > &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 truncated_cone(Triangulation< dim > &tria, const double radius_0=1.0, const double radius_1=0.5, const double half_length=1.0)
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 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)
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 > &)
::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)
::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
constexpr Number determinant(const SymmetricTensor< 2, dim, Number > &)
constexpr Tensor< 1, dim, typename ProductType< Number1, Number2 >::type > cross_product_3d(const Tensor< 1, dim, Number1 > &src1, const Tensor< 1, dim, Number2 > &src2)
const ::Triangulation< dim, spacedim > & tria