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);