15using Vec = std::array<double, 3>;
16using Edge = std::array<int, 2>;
17using Face = std::array<int, 3>;
19Vec sub(
const Vec &
a,
const Vec &b) {
20 return {
a[0] - b[0],
a[1] - b[1],
a[2] - b[2]};
22double dot(
const Vec &
a,
const Vec &b) {
23 return a[0] * b[0] +
a[1] * b[1] +
a[2] * b[2];
26 return {
a[1] * b[2] -
a[2] * b[1],
a[2] * b[0] -
a[0] * b[2],
27 a[0] * b[1] -
a[1] * b[0]};
29double norm(
const Vec &
a) {
return std::sqrt(dot(
a,
a)); }
30Vec unit(
const Vec &
a) {
31 const double l = norm(
a);
32 return {
a[0] /
l,
a[1] /
l,
a[2] /
l};
35 const auto &p =
mesh.points;
36 return dot(sub(p[
c[1]], p[
c[0]]),
37 cross(sub(p[
c[2]], p[
c[0]]), sub(p[
c[3]], p[
c[0]])));
39Edge edgeKey(
int a,
int b) {
return a < b ? Edge{
a, b} : Edge{b,
a}; }
40Face faceKey(
int a,
int b,
int c) {
42 std::sort(
f.begin(),
f.end());
45std::vector<Face> cellFaces(
const std::array<int, 4> &
c) {
46 return {faceKey(
c[1],
c[2],
c[3]), faceKey(
c[0],
c[2],
c[3]),
47 faceKey(
c[0],
c[1],
c[3]), faceKey(
c[0],
c[1],
c[2])};
49std::vector<Edge> cellEdges(
const std::array<int, 4> &
c) {
50 return {edgeKey(
c[0],
c[1]), edgeKey(
c[0],
c[2]), edgeKey(
c[0],
c[3]),
51 edgeKey(
c[1],
c[2]), edgeKey(
c[1],
c[3]), edgeKey(
c[2],
c[3])};
55 std::vector<std::array<double, 2>>
points;
56 std::vector<std::array<int, 3>>
triangles;
57 std::vector<char>
crack;
62 std::vector<int>
crack;
65 int node(
int level,
int i)
const {
return level * planar +
i; }
71Model extrude(
const Plane2D &plane,
const std::vector<double> &levels,
74 model.planar = plane.points.size();
75 auto &
mesh = model.mesh;
76 for (
double z : levels)
77 for (const auto &p : plane.
points)
79 for (
int l = 0;
l + 1 <
static_cast<int>(levels.size()); ++
l)
81 std::sort(tri.begin(), tri.end());
82 const int b0 = model.node(
l, tri[0]), b1 = model.node(
l, tri[1]),
83 b2 = model.node(
l, tri[2]);
84 const int t0 = model.node(
l + 1, tri[0]), t1 = model.node(
l + 1, tri[1]),
85 t2 = model.node(
l + 1, tri[2]);
86 for (std::array<int, 4> cell : {std::array<int, 4>{b0, b1, b2, t2},
87 std::array<int, 4>{b0, b1, t1, t2},
88 std::array<int, 4>{b0, t0, t1, t2}}) {
89 if (det(
mesh, cell) < 0)
90 std::swap(cell[2], cell[3]);
91 mesh.cells.push_back(cell);
94 std::map<Face, int> count;
96 for (const auto &face : cellFaces(cell))
98 for (
const auto &[face,
n] : count)
101 for (std::size_t
t = 0;
t != plane.triangles.size(); ++
t)
102 if (plane.crack[
t]) {
103 const auto &tri = plane.triangles[
t];
104 mesh.boundary.push_back({model.node(crack_level, tri[0]),
105 model.node(crack_level, tri[1]),
106 model.node(crack_level, tri[2])});
107 model.crack.push_back(
mesh.boundary.size() - 1);
110 Vec lo =
mesh.points.front(), hi = lo;
112 for (
int i = 0;
i != 3; ++
i) {
113 lo[
i] = std::min(lo[
i], p[
i]);
114 hi[
i] = std::max(hi[
i], p[
i]);
116 const auto planes = [&](
int v) {
118 for (
int i = 0;
i != 3; ++
i) {
119 mask |= (
mesh.points[
v][
i] == lo[
i]) << (2 *
i);
120 mask |= (
mesh.points[
v][
i] == hi[
i]) << (2 *
i + 1);
124 std::set<Edge> edges;
126 for (const auto &edge : cellEdges(cell))
128 for (
const auto &edge : edges)
129 if (__builtin_popcount(planes(edge[0]) & planes(edge[1])) >= 2)
130 mesh.featureEdges.push_back(edge);
132 model.volume += det(
mesh, cell) / 6;
138Plane2D grid(
int nx,
int ny,
int crack_x) {
140 for (
int j = 0;
j <= ny; ++
j)
141 for (
int i = 0;
i <= nx; ++
i)
142 plane.points.push_back({double(i), double(j)});
143 const auto id = [nx](
int i,
int j) {
return j * (nx + 1) +
i; };
144 for (
int j = 0;
j != ny; ++
j)
145 for (
int i = 0;
i != nx; ++
i) {
146 plane.triangles.push_back({id(
i,
j), id(
i + 1,
j), id(
i + 1,
j + 1)});
147 plane.triangles.push_back({id(
i,
j), id(
i + 1,
j + 1), id(
i,
j + 1)});
148 plane.crack.push_back(
i < crack_x);
149 plane.crack.push_back(
i < crack_x);
160 plane.points = {{0, 0}, {1, -1}, {1, 1}, {1.6, 0}, {-1, -2}, {1, -2},
161 {2.6, -2}, {2.6, 0}, {2.6, 2}, {1, 2}, {-1, 2}, {-1, 0}};
162 plane.triangles = {{4, 5, 1}, {4, 1, 0}, {4, 0, 11}, {11, 0, 10}, {10, 0, 2},
163 {10, 2, 9}, {0, 1, 3}, {0, 3, 2}, {1, 5, 6}, {1, 6, 3},
164 {3, 6, 7}, {3, 7, 8}, {3, 8, 2}, {2, 8, 9}};
165 plane.crack = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0};
169std::vector<char> crackNodes(
const Model &model) {
170 std::vector<char> nodes(model.mesh.points.size(), 0);
178std::vector<Edge> frontEdges(
const Model &model) {
179 std::map<Edge, int> crack_count;
181 std::vector<char> is_crack(model.mesh.boundary.size(), 0);
184 for (std::size_t
i = 0;
i != model.mesh.boundary.size(); ++
i) {
185 const auto &
f = model.mesh.boundary[
i];
186 for (
const auto &edge :
187 {edgeKey(
f[0],
f[1]), edgeKey(
f[1],
f[2]), edgeKey(
f[0],
f[2])}) {
194 std::vector<Edge> front;
195 for (
const auto &[edge,
n] : crack_count)
196 if (
n == 1 && !
skin.count(edge))
197 front.push_back(edge);
198 const auto &p = model.mesh.points;
199 std::sort(front.begin(), front.end(), [&](
const Edge &
a,
const Edge &b) {
200 const Vec ma{p[a[0]][0] + p[a[1]][0], p[a[0]][1] + p[a[1]][1],
201 p[a[0]][2] + p[a[1]][2]};
202 const Vec mb{p[b[0]][0] + p[b[1]][0], p[b[0]][1] + p[b[1]][1],
203 p[b[0]][2] + p[b[1]][2]};
211Vec direction(
const Model &model,
const Edge &edge,
double angle) {
212 const auto &p = model.mesh.points;
214 for (
int i : model.
crack) {
215 const auto &
f = model.mesh.boundary[
i];
216 if (std::count(
f.begin(),
f.end(), edge[0]) &&
217 std::count(
f.begin(),
f.end(), edge[1]))
219 if (
v != edge[0] &&
v != edge[1])
222 const auto t = unit(sub(p[edge[1]], p[edge[0]]));
223 auto d = unit(
cross(
t, Vec{0, 0, 1}));
224 const Vec mid{(p[edge[0]][0] + p[edge[1]][0]) / 2,
225 (p[edge[0]][1] + p[edge[1]][1]) / 2,
226 (p[edge[0]][2] + p[edge[1]][2]) / 2};
227 if (dot(sub(p[apex], mid),
d) > 0)
228 d = {-
d[0], -
d[1], -
d[2]};
230 const double a =
angle * M_PI / 180;
231 return {std::cos(
a) *
d[0] + std::sin(
a) * b[0],
232 std::cos(
a) *
d[1] + std::sin(
a) * b[1],
233 std::cos(
a) *
d[2] + std::sin(
a) * b[2]};
238 const std::string &
name) {
240 const auto &
mesh = model.mesh;
241 int inverted = 0, overfull = 0;
243 std::map<Face, int> count;
245 const double v = det(
mesh, cell) / 6;
246 inverted += !(
v > 0);
248 for (
const auto &face : cellFaces(cell))
251 for (
const auto &[face,
n] : count)
254 for (
const auto &[face,
n] : count)
257 inverted, 0, {0, 0});
259 overfull, 0, {0, 0});
261 model.volume, {0, 1e-12});
265 skin += count.count(faceKey(face[0], face[1], face[2])) &&
266 count.at(faceKey(face[0], face[1], face[2])) == 1;
272static char help[] =
"Crack extension candidate search checks\n";
274void logReport(
const std::string &
name,
277 <<
name <<
": tried " <<
r.candidatesTried <<
", accepted " <<
r.accepted
278 <<
", rejected behind/angle/move " <<
r.rejectedBehind <<
'/'
279 <<
r.rejectedAngle <<
'/' <<
r.rejectedMove <<
", inversion/quality "
280 <<
r.rejectedInversion <<
'/' <<
r.rejectedQuality
281 <<
", bridging/pocket/fixed/topology " <<
r.rejectedBridging <<
'/'
282 <<
r.rejectedPocket <<
'/' <<
r.rejectedFixed <<
'/' <<
r.rejectedTopology
283 <<
", audited " <<
r.auditedOperations;
288int bridgingEdges(
const Model &model,
const std::vector<char> &
crack,
290 std::set<Edge> existing;
291 for (
const auto &cell : model.
mesh.
cells)
292 for (const auto &edge : cellEdges(cell))
293 existing.insert(edge);
295 for (const auto &edge :
296 {edgeKey(
f[0],
f[1]), edgeKey(
f[1],
f[2]), edgeKey(
f[0],
f[2])})
297 existing.insert(edge);
299 for (
const auto &cell :
candidate.createdCells)
300 for (const auto &edge : cellEdges(cell))
301 if (!existing.count(edge) &&
crack[edge[0]] &&
crack[edge[1]])
319 auto model = extrude(grid(6, 4, 3), {-2, -1, 0, 1, 2}, 2);
320 const auto settings = auditSettings();
321 int steps = 0, wrong_class = 0, out_of_plane = 0,
closures = 0, open = 0;
322 double max_move = 0, max_angle = 0;
323 for (
int step = 0; step != 6; ++step) {
325 for (
const auto &edge : frontEdges(model)) {
328 model.mesh, model.crack, edge, direction(model, edge, 0),
settings,
330 if (!candidates.empty()) {
331 chosen = candidates.front();
336 MOFEM_LOG(
"WORLD", Sev::error) <<
"No front edge has a candidate";
342 max_move = std::max(max_move, norm(chosen.
displacement));
346 const auto nodes = crackNodes(model);
347 for (std::size_t
v = 0;
v != nodes.size(); ++
v)
348 out_of_plane += nodes[
v] && model.mesh.points[
v][2] != 0;
352 << open <<
" corners left open";
353 CHKERR testing.checkValue<TestType::SCALAR>(
"Flat extension steps", steps, 6,
355 CHKERR testing.checkValue<TestType::SCALAR>(
"Flat non-class-1 steps",
356 wrong_class, 0, {0, 0});
357 CHKERR testing.checkValue<TestType::SCALAR>(
"Flat node move", max_move, 0,
359 CHKERR testing.checkValue<TestType::SCALAR>(
"Flat angle deviation", max_angle,
361 CHKERR testing.checkValue<TestType::SCALAR>(
"Flat crack nodes off plane",
362 out_of_plane, 0, {0, 0});
370 auto model = extrude(grid(6, 4, 3), {-2, -1, 0, 1, 2}, 2);
371 const auto settings = auditSettings();
372 const auto front = frontEdges(model);
373 const auto edge = front[1];
374 const auto d = direction(model, edge, 30);
378 CHKERR testing.checkValue<TestType::SCALAR>(
"Kinked candidates found",
379 !candidates.empty(), 1, {0, 0});
380 const auto c = candidates.front();
381 CHKERR testing.checkValue<TestType::SCALAR>(
"Kinked class is a move",
382 c.candidateClass >= 2, 1, {0, 0});
384 "Kinked audited operations",
report.auditedOperations > 0, 1, {0, 0});
387 const auto &p = model.mesh.points;
388 const auto t = unit(sub(p[edge[1]], p[edge[0]]));
390 const auto face_normal = unit(
cross(sub(p[
c.newFace[1]], p[
c.newFace[0]]),
391 sub(p[
c.newFace[2]], p[
c.newFace[0]])));
393 std::asin(std::min(1., norm(
cross(face_normal,
n)))) * 180 / M_PI;
395 "Kinked face within tolerance",
angle <=
settings.angleToleranceDegrees,
398 "Kinked reported angle",
c.angleDeviationDegrees,
angle, {1e-9, 0});
406 auto model = extrude(notch(), {-2, -1, 0, 1, 2}, 2);
408 const int b = model.node(2, 0), s1 = model.node(2, 1), s2 = model.node(2, 2),
409 x = model.node(2, 3);
410 const auto crack = crackNodes(model);
411 const auto front = frontEdges(model);
412 CHKERR testing.checkValue<TestType::SCALAR>(
"Notch front edges", front.size(),
416 const auto side = edgeKey(b, s1);
419 model.mesh, model.crack, side, direction(model, side, 0),
settings);
420 CHKERR testing.checkValue<TestType::SCALAR>(
"Notch side candidates found",
421 !candidates.empty(), 1, {0, 0});
422 const auto &
c = candidates.front();
423 CHKERR testing.checkValue<TestType::SCALAR>(
"Notch side class",
424 c.candidateClass, 1, {0, 0});
425 CHKERR testing.checkValue<TestType::SCALAR>(
"Notch side free node",
426 c.freeNode, x, {0, 0});
432 for (
const auto &
f :
c.closureFaces)
433 closed |= faceKey(
f[0],
f[1],
f[2]) == faceKey(b, x, s2);
434 CHKERR testing.checkValue<TestType::SCALAR>(
"Notch closed by (b, x, s2)",
437 auto applied = model;
440 const auto front_after = frontEdges(applied);
442 for (
const auto &e : front_after)
443 at_bottom += e[0] == b || e[1] == b;
445 "Notch bottom has no front edge", at_bottom, 0, {0, 0});
451 int candidates_seen = 0,
bridging = 0, notch_face = 0, flipped = 0;
453 std::array<int, 4> classes{0, 0, 0, 0};
454 for (
const auto &edge : front)
457 model.mesh, model.crack, edge, direction(model, edge,
angle),
459 for (
const auto &
c : candidates) {
462 flipped +=
c.operations > 0;
463 ++classes[
c.candidateClass];
465 for (
const auto &cell :
c.createdCells)
466 for (const auto &face : cellFaces(cell))
467 notch_face += face == faceKey(b, s1, s2);
468 notch_face += faceKey(
c.newFace[0],
c.newFace[1],
c.newFace[2]) ==
472 CHKERR testing.checkValue<TestType::SCALAR>(
"Notch candidates found",
473 candidates_seen > 0, 1, {0, 0});
476 CHKERR testing.checkValue<TestType::SCALAR>(
"Notch filling face", notch_face,
478 CHKERR testing.checkValue<TestType::SCALAR>(
"Notch candidates with flips",
479 flipped > 0, 1, {0, 0});
481 "Notch bridging rule exercised",
report.rejectedBridging > 0, 1, {0, 0});
483 <<
"Notch sweep: tried " <<
report.candidatesTried <<
", accepted "
484 <<
report.accepted <<
", bridging rejections " <<
report.rejectedBridging
485 <<
", pocket rejections " <<
report.rejectedPocket <<
"; closure faces "
486 <<
closures <<
"; candidates with flips " << flipped <<
", by class "
487 << classes[1] <<
'/' << classes[2] <<
'/' << classes[3];
488 logReport(
"Notch sweep",
report);
497 auto model = extrude(grid(6, 4, 3), {-2, -1, 0, 1, 2}, 2);
498 constexpr int curve = 1 * 7 + 4;
499 std::set<int> curve_nodes;
500 for (
int l = 0;
l != 4; ++
l) {
501 model.mesh.featureEdges.push_back(
502 {model.node(
l, curve), model.node(
l + 1, curve)});
503 curve_nodes.insert(model.node(
l, curve));
507 const auto &p = model.mesh.points;
508 Vec lo = p.front(), hi = lo;
509 for (
const auto &x : p)
510 for (
int i = 0;
i != 3; ++
i) {
511 lo[
i] = std::min(lo[
i], x[
i]);
512 hi[
i] = std::max(hi[
i], x[
i]);
514 int moved_skin = 0, moved_curve = 0, left_plane = 0,
moved = 0;
515 int moved_line = 0, left_line = 0;
516 for (
const auto &edge : frontEdges(model))
519 model.mesh, model.crack, edge, direction(model, edge,
angle),
521 for (
const auto &
c : candidates) {
522 if (norm(
c.displacement) == 0)
525 const auto &x = p[
c.freeNode];
527 for (
int i = 0;
i != 3; ++
i)
528 for (
double bound : {lo[
i], hi[
i]})
531 left_plane += std::abs(x[
i] +
c.displacement[
i] - bound) > 1e-12;
533 moved_skin += planes == 1;
534 moved_curve += planes >= 2;
535 if (curve_nodes.count(
c.freeNode)) {
537 left_line +=
c.displacement[0] != 0 ||
c.displacement[1] != 0 ||
538 std::abs(
c.displacement[2]) >= 1;
542 CHKERR testing.checkValue<TestType::SCALAR>(
"Boundary moved candidates",
543 moved > 0, 1, {0, 0});
544 CHKERR testing.checkValue<TestType::SCALAR>(
"Boundary moved skin nodes",
545 moved_skin > 0, 1, {0, 0});
546 CHKERR testing.checkValue<TestType::SCALAR>(
"Boundary nodes leaving skin",
547 left_plane, 0, {0, 0});
548 CHKERR testing.checkValue<TestType::SCALAR>(
"Boundary moved curve nodes",
549 moved_line > 0, 1, {0, 0});
550 CHKERR testing.checkValue<TestType::SCALAR>(
"Boundary nodes leaving curve",
551 left_line, 0, {0, 0});
553 <<
"Boundary sweep: moved " <<
moved <<
", on one skin plane "
554 << moved_skin <<
", on a box edge " << moved_curve
555 <<
", on the interior curve " << moved_line;
562 const auto model = extrude(grid(6, 4, 3), {-2, -1, 0, 1, 2}, 2);
565 const auto edge = frontEdges(model)[1];
568 model.mesh, model.crack, edge, direction(model, edge, 30),
settings,
570 CHKERR testing.checkValue<TestType::SCALAR>(
"Failure candidates",
571 candidates.size(), 0, {0, 0});
573 "Failure move rejections",
report.rejectedMove > 0, 1, {0, 0});
576 const auto d = direction(model, edge, 180);
583 "Failure backward direction rejected", threw, 1, {0, 0});
587 {model.node(2, 0), model.node(2, 1)},
588 {1, 0, 0}, auditSettings());
592 CHKERR testing.checkValue<TestType::SCALAR>(
"Failure skin edge rejected",
597 auto inverted = extrude(grid(6, 4, 3), {-2, -1, 0, 1, 2}, 2);
598 const auto front = frontEdges(inverted)[1];
600 if (
std::count(cell.begin(), cell.
end(), front[0])) {
601 std::swap(cell[2], cell[3]);
607 direction(inverted, front, 0),
613 "Failure inverted cell rejected",
614 what.find(
"Inverted cell in the crack extension region") !=
621 auto stale = extrude(grid(6, 4, 3), {-2, -1, 0, 1, 2}, 2);
622 auto all_classes = auditSettings();
623 all_classes.stopAtFirstClass =
false;
624 const auto front = frontEdges(stale)[1];
626 stale.mesh, stale.crack, front, direction(stale, front, 30),
628 CHKERR testing.checkValue<TestType::SCALAR>(
"Failure several candidates",
629 all.size() >= 2, 1, {0, 0});
631 const auto points = stale.mesh.points;
632 const auto cells = stale.mesh.cells;
640 "Failure stale candidate rejected", threw, 1, {0, 0});
642 "Failure stale candidate left patch unchanged",
643 stale.mesh.points ==
points && stale.mesh.cells ==
cells, 1, {0, 0});
648 auto fresh = extrude(grid(6, 4, 3), {-2, -1, 0, 1, 2}, 2);
649 const auto front = frontEdges(fresh)[1];
651 fresh.mesh, fresh.crack, front, direction(fresh, front, 30),
653 auto c = candidates.front();
655 "Failure tampered candidate moves", norm(
c.displacement) > 0, 1,
657 for (
auto &x :
c.displacement)
659 const auto points = fresh.mesh.points;
660 const auto crack = fresh.crack;
668 "Failure inverting candidate rejected", threw, 1, {0, 0});
670 "Failure inverting candidate left patch unchanged",
671 fresh.mesh.points ==
points && fresh.crack ==
crack, 1, {0, 0});
675 fresh.mesh.cellLabels.assign(fresh.mesh.cells.size() - 1, 0);
683 "Failure changed labels rejected", threw, 1, {0, 0});
694 auto plane = grid(6, 4, 5);
696 plane.crack[2 * (1 * 6 + 3)] = plane.crack[2 * (1 * 6 + 3) + 1] = 0;
697 auto model = extrude(plane, {-2, -1, 0, 1, 2}, 2);
698 const auto id = [&](
int i,
int j) {
return model.node(2,
j * 7 +
i); };
699 const auto hole_a = faceKey(
id(3, 1),
id(4, 1),
id(4, 2));
700 const auto hole_b = faceKey(
id(3, 1),
id(4, 2),
id(3, 2));
704 const auto key = faceKey(
f[0],
f[1],
f[2]);
705 filled +=
key == hole_a ||
key == hole_b;
707 CHKERR testing.checkValue<TestType::SCALAR>(
"Hole closed by the fill", filled,
710 const auto edge = edgeKey(
id(3, 1),
id(3, 2));
712 model.mesh, model.crack, edge, direction(model, edge, 0),
714 CHKERR testing.checkValue<TestType::SCALAR>(
"Hole edge has a candidate",
715 !candidates.empty(), 1, {0, 0});
716 const auto &
c = candidates.front();
717 std::set<Face>
faces{faceKey(
c.newFace[0],
c.newFace[1],
c.newFace[2])};
718 for (
const auto &
f :
c.closureFaces)
719 faces.insert(faceKey(
f[0],
f[1],
f[2]));
721 "Hole closed by one candidate",
722 faces.count(hole_a) &&
faces.count(hole_b), 1, {0, 0});
723 CHKERR testing.checkValue<TestType::SCALAR>(
"Hole closure without flips",
724 c.operations, 0, {0, 0});
725 CHKERR testing.checkValue<TestType::SCALAR>(
"Hole closure without a move",
726 norm(
c.displacement), 0, {0, 0});
730 for (
const auto &e : frontEdges(model))
733 v == id(3, 1) ||
v == id(4, 1) ||
v == id(4, 2) ||
v == id(3, 2);
734 CHKERR testing.checkValue<TestType::SCALAR>(
"Hole leaves no front edge",
745 auto model = extrude(grid(6, 4, 3), {-2, -1, 0, 1, 2}, 2);
746 auto &p = model.mesh.points;
747 Vec lo = p.front(), hi = lo;
748 for (
const auto &x : p)
749 for (
int i = 0;
i != 3; ++
i) {
750 lo[
i] = std::min(lo[
i], x[
i]);
751 hi[
i] = std::max(hi[
i], x[
i]);
753 std::uint64_t
state = 2463534242u;
754 const auto random = [&
state]() {
761 bool fixed = x[2] == 0;
762 for (
int i = 0;
i != 3; ++
i)
765 for (
int i = 0;
i != 3; ++
i)
766 x[
i] += 0.2 * random();
769 for (
const auto &cell : model.
mesh.
cells)
770 model.volume += det(model.
mesh, cell) / 6;
772 for (
const auto &cell : model.
mesh.
cells)
773 inverted += !(det(model.
mesh, cell) > 0);
774 CHKERR testing.checkValue<TestType::SCALAR>(
"Jitter input inverted cells",
775 inverted, 0, {0, 0});
780 const std::array<double, 6> angles{20, -25, 10, -15, 30, 0};
781 for (
double angle : angles) {
783 for (
const auto &edge : frontEdges(model)) {
785 model.mesh, model.crack, edge, direction(model, edge,
angle),
787 if (!candidates.empty()) {
788 chosen = candidates.front();
794 bridging += bridgingEdges(model, crackNodes(model), chosen);
799 logReport(
"Jitter",
report);
800 CHKERR testing.checkValue<TestType::SCALAR>(
"Jitter extension steps", steps,
801 angles.size(), {0, 0});
813 auto model = extrude(grid(6, 4, 3), {-2, -1, 0, 1, 2}, 2);
814 auto &p = model.mesh.points;
815 std::set<int> bumped;
816 for (
int v = 0;
v !=
static_cast<int>(p.size()); ++
v) {
818 const bool cracked = x[2] == 0 && x[0] <= 3;
819 if (x[1] == 0 && x[0] > 0 && x[0] < 6 && std::abs(x[2]) < 2 && !cracked) {
820 x[1] = -0.1 * (1 + (
static_cast<int>(x[0] + x[2] + 4) % 2));
825 for (
const auto &cell : model.
mesh.
cells)
826 model.volume += det(model.
mesh, cell) / 6;
827 std::map<Face, int> count;
828 for (
const auto &cell : model.
mesh.
cells)
829 for (const auto &face : cellFaces(cell))
831 std::map<int, std::set<int>> skin_neighbours;
832 for (
const auto &[face,
n] : count)
834 for (
int i = 0;
i != 3; ++
i)
835 for (
int j = 0;
j != 3; ++
j)
837 skin_neighbours[face[
i]].insert(face[
j]);
839 const auto on_skin_edge = [&](
int v,
const Vec &displacement) {
840 for (
int u : skin_neighbours[
v]) {
841 const auto e = sub(p[u], p[
v]);
842 const double alpha = dot(displacement, e) / dot(e, e);
843 if (norm(
cross(displacement, e)) <= 1e-12 * norm(e) * norm(e) &&
844 alpha >= -0.1 - 1e-12 && alpha < 1)
851 int moved = 0, off_skin = 0;
853 for (
const auto &edge : frontEdges(model))
855 for (
const auto &
c :
tools.crackExtensionCandidates(
858 if (norm(
c.displacement) == 0 || !bumped.count(
c.freeNode))
861 off_skin += !on_skin_edge(
c.freeNode,
c.displacement);
866 <<
"Curved skin: " <<
moved <<
" candidates move a node of the "
868 CHKERR testing.checkValue<TestType::SCALAR>(
"Curved skin moved nodes",
869 moved > 0, 1, {0, 0});
870 CHKERR testing.checkValue<TestType::SCALAR>(
"Curved skin nodes off edges",
871 off_skin, 0, {0, 0});
875 auto moved_mesh = model.mesh;
876 for (
int i = 0;
i != 3; ++
i)
878 for (
const auto &cell : model.
mesh.
cells)
879 if (
std::count(cell.begin(), cell.
end(),
w))
880 model.volume += (det(moved_mesh, cell) - det(model.
mesh, cell)) / 6;
889 std::vector<EntityHandle> &
vertices,
891 Range &protected_faces) {
896 CHKERR mb.create_vertex(point.data(),
v);
899 std::vector<int> ids(
vertices.size());
900 std::iota(ids.begin(), ids.end(), 1);
904 for (
const auto &cell : model.
mesh.
cells) {
905 EntityHandle conn[4];
906 for (
int n = 0;
n != 4; ++
n)
909 CHKERR mb.create_element(MBTET, conn, 4,
t);
913 for (
int dim : {0, 1, 2}) {
915 CHKERR mb.get_adjacencies(tets, dim,
true,
closure, moab::Interface::UNION);
918 for (
int i : model.
crack) {
919 EntityHandle conn[3];
920 for (
int n = 0;
n != 3; ++
n)
923 CHKERR mb.get_adjacencies(conn, 3, 2,
false, face,
924 moab::Interface::INTERSECT);
925 crack_faces.merge(face);
933 for (std::size_t
i = 0;
i != model.mesh.boundary.size(); ++
i) {
934 if (std::find(model.crack.begin(), model.crack.end(),
935 static_cast<int>(
i)) != model.crack.end())
937 EntityHandle conn[3];
938 for (
int n = 0;
n != 3; ++
n)
941 CHKERR mb.get_adjacencies(conn, 3, 2,
false, face,
942 moab::Interface::INTERSECT);
943 protected_faces.merge(face);
953 auto plane = grid(6, 4, 3);
954 for (
int j = 0;
j != 4; ++
j)
955 for (
int i = 0;
i != 6; ++
i)
956 for (
int k = 0;
k != 2; ++
k)
957 plane.crack[2 * (
j * 6 +
i) +
k] =
i < 3 || (
i < 5 &&
j != 1);
958 auto model = extrude(plane, {-2, -1, 0, 1, 2}, 2);
959 const auto points = model.mesh.points;
962 for (
const auto &
j : joins) {
964 model.mesh.boundary.push_back(
j.face);
965 model.crack.push_back(model.mesh.boundary.size() - 1);
967 MOFEM_LOG(
"WORLD", Sev::inform) <<
"Join: " << joins.size() <<
" faces, "
968 <<
closing <<
" closing onto the front";
969 std::map<Edge, int> count;
971 for (
int i : model.
crack) {
972 const auto &
f = model.mesh.boundary[
i];
976 {edgeKey(
f[0],
f[1]), edgeKey(
f[1],
f[2]), edgeKey(
f[0],
f[2])})
979 int non_manifold = 0;
980 for (
const auto &[e,
n] : count)
981 non_manifold +=
n > 2;
982 CHKERR testing.checkValue<TestType::SCALAR>(
"Join closes the slit",
983 joins.size(), 4, {0, 0});
984 CHKERR testing.checkValue<TestType::SCALAR>(
"Join faces close onto the front",
986 CHKERR testing.checkValue<TestType::SCALAR>(
"Join crack faces",
987 model.crack.size(), 40, {0, 0});
988 CHKERR testing.checkValue<TestType::SCALAR>(
"Join faces in the slit",
989 off_plane, 0, {0, 0});
990 CHKERR testing.checkValue<TestType::SCALAR>(
"Join crack manifold",
991 non_manifold, 0, {0, 0});
993 "Join moves no node", model.mesh.points ==
points, 1, {0, 0});
997 "Join is idempotent",
1011 constexpr int nx = 6;
1012 auto plane = grid(nx, 4, 3);
1013 const auto id = [](
int i,
int j) {
return j * (nx + 1) +
i; };
1016 const int square = 2 * 3;
1017 plane.triangles[square] = {id(3, 0), id(4, 0), id(3, 1)};
1018 plane.triangles[square + 1] = {id(4, 0), id(4, 1), id(3, 1)};
1019 plane.crack[square + 1] = 1;
1020 plane.crack[2 * 2] = 0;
1021 auto model = extrude(plane, {-2, -1, 0, 1, 2}, 2);
1023 std::set<Face>{faceKey(model.node(2,
id(2, 0)), model.node(2,
id(3, 0)),
1024 model.node(2,
id(3, 1))),
1025 faceKey(model.node(2,
id(3, 0)), model.node(2,
id(4, 0)),
1026 model.node(2,
id(3, 1)))};
1028 std::vector<int> categories;
1030 for (
const auto &
j : joins) {
1031 categories.push_back(
j.category);
1032 in_corner += corner.count(faceKey(
j.face[0],
j.face[1],
j.face[2]));
1033 model.mesh.boundary.push_back(
j.face);
1034 model.crack.push_back(model.mesh.boundary.size() - 1);
1036 std::map<Edge, int> count;
1037 for (
int i : model.
crack) {
1038 const auto &
f = model.mesh.boundary[
i];
1039 for (
const auto &e :
1040 {edgeKey(
f[0],
f[1]), edgeKey(
f[1],
f[2]), edgeKey(
f[0],
f[2])})
1043 int non_manifold = 0;
1044 for (
const auto &[e,
n] : count)
1045 non_manifold +=
n > 2;
1047 <<
"Skin corner: " << joins.size() <<
" join faces, " << in_corner
1048 <<
" in the corner";
1050 "Skin corner opened along the skin",
1051 categories.size() >= 2 &&
1055 CHKERR testing.checkValue<TestType::SCALAR>(
"Skin corner faces", in_corner, 2,
1057 CHKERR testing.checkValue<TestType::SCALAR>(
"Skin corner crack manifold",
1058 non_manifold, 0, {0, 0});
1067 const auto euler = [](
const Model &model) {
1069 std::set<Edge> edges;
1070 for (
int i : model.
crack) {
1071 const auto &
f = model.mesh.boundary[
i];
1074 {edgeKey(
f[0],
f[1]), edgeKey(
f[1],
f[2]), edgeKey(
f[0],
f[2])})
1077 return static_cast<int>(
vertices.size()) -
static_cast<int>(edges.size()) +
1078 static_cast<int>(model.crack.size());
1080 for (
const auto &[separate, depth] :
1081 std::vector<
std::pair<
bool,
int>>{{
false, 2}, {
false, 5}, {
true, 2}}) {
1082 const int ny = depth + 2;
1083 auto plane = grid(4, ny, 4);
1084 for (
int j = 0;
j != ny; ++
j)
1085 for (
int i = 0;
i != 4; ++
i)
1086 for (
int k = 0;
k != 2; ++
k)
1087 plane.crack[2 * (
j * 4 +
i) +
k] =
1088 separate ?
i != 2 : !(
i == 2 &&
j < depth);
1089 auto model = extrude(plane, {-2, -1, 0, 1, 2}, 2);
1090 const auto node = [&](
int i,
int j) {
return model.node(2,
j * 5 +
i); };
1091 const auto target = faceKey(node(2, 1), node(3, 1), node(3, 2));
1094 for (std::size_t
t = 0;
t != plane.triangles.size(); ++
t)
1095 if (!plane.crack[
t]) {
1096 const auto &
f = plane.triangles[
t];
1097 const auto face = faceKey(model.node(2,
f[0]), model.node(2,
f[1]),
1098 model.node(2,
f[2]));
1100 model.mesh.boundary.push_back(face);
1103 separate ? std::string(
"Separate components")
1104 :
std::string(depth == 2 ?
"Open notch" :
"Long open notch");
1106 tag +
" initial Euler characteristic", euler(model), separate ? 2 : 1,
1108 model.mesh.featureEdges.push_back(edgeKey(node(2, 1), node(3, 1)));
1110 tag +
" accepted feature fills",
1116 std::vector<EntityHandle>
vertices;
1117 Range tets, crack_faces, protected_faces;
1120 const Edge edge = edgeKey(node(3, 1), node(3, 2));
1123 CHKERR mb.get_adjacencies(conn, 2, 1,
false, handles,
1124 moab::Interface::INTERSECT);
1125 auto local_settings = auditSettings();
1126 local_settings.ringLimit = 1;
1128 EntityHandle face = 0;
1131 protected_faces, {{handles.front(), direction(model, edge, 0)}},
1132 local_settings,
result, face);
1134 tag +
" local bridge keeps remote crack connectivity", face != 0,
1138 auto recovery_settings = auditSettings();
1139 const auto recovery_edge = edgeKey(node(3, 1), node(3, 2));
1141 model.mesh, model.crack, recovery_edge,
1142 direction(model, recovery_edge, 0), recovery_settings);
1143 const bool accepts_target = std::any_of(
1144 recoverable.begin(), recoverable.end(),
1146 return faceKey(c.newFace[0], c.newFace[1], c.newFace[2]) == target;
1149 tag +
" recovery preserves hole guard", accepts_target, separate,
1152 tag +
" accepted joins", joins.size(), separate ? 1 : 0, {0, 0});
1153 for (
const auto &join : joins) {
1155 tag +
" target face",
1156 faceKey(join.face[0], join.face[1], join.face[2]) ==
target, 1,
1158 model.mesh.boundary.push_back(join.face);
1159 model.crack.push_back(model.mesh.boundary.size() - 1);
1162 tag +
" final Euler characteristic", euler(model), 1, {0, 0});
1170 std::uint64_t
state = 2463534242u;
1172 if (point[0] > 0 && point[0] < 6 && point[1] > 0 && point[1] < 4 &&
1173 point[2] != 0 &&
std::abs(point[2]) < 2)
1174 for (
double &coordinate : point) {
1178 coordinate += 0.2 * (
double(
state % 2001) / 1000. - 1.);
1181 irregular.mesh.vertexIds.resize(irregular.mesh.points.size());
1182 std::iota(irregular.mesh.vertexIds.begin(), irregular.mesh.vertexIds.end(),
1185 irregular.mesh = std::move(reconstructed);
1186 irregular.crack.clear();
1187 irregular.mesh.boundary.clear();
1188 irregular.mesh.surfaceLabels.clear();
1189 std::map<Face, int> incidence;
1190 irregular.volume = 0;
1191 for (
const auto &cell : irregular.
mesh.
cells) {
1192 irregular.volume += det(irregular.mesh, cell) / 6;
1193 for (
const auto &face : cellFaces(cell))
1196 for (
const auto &[face, count] : incidence) {
1197 bool crack_face = count == 2;
1201 if (count == 1 || crack_face) {
1203 irregular.crack.push_back(irregular.mesh.boundary.size());
1204 irregular.mesh.boundary.push_back(face);
1213 auto model = extrude(grid(6, 4, 3), {-2, -1, 0, 1, 2}, 2);
1217 const auto points = model.mesh.points;
1218 const auto cells = model.mesh.cells;
1219 const auto boundary = model.mesh.boundary;
1220 const auto crack = model.crack;
1221 int feasible = 0, alternatives = 0, trials = 0;
1222 for (
const auto &edge : frontEdges(model)) {
1223 for (
double angle : {0., 8., 20.}) {
1226 model.mesh, model.crack, edge, direction(model, edge,
angle),
1228 feasible +=
report.lookAheadFeasible;
1229 alternatives +=
report.alternativeTriangulations;
1230 trials +=
report.lookAheadTrials;
1232 <<
"Look-ahead edge " << edge[0] <<
' ' << edge[1] <<
" angle "
1233 <<
angle <<
": candidates " << candidates.size() <<
", trials "
1234 <<
report.lookAheadTrials <<
", feasible " <<
report.lookAheadFeasible
1235 <<
", alternatives " <<
report.alternativeTriangulations;
1236 for (
const auto &
c : candidates)
1238 <<
"Preview node " <<
c.freeNode <<
", state " <<
c.continuation
1239 <<
", score " <<
c.score <<
", operations " <<
c.
operations;
1241 "Look-ahead bounded trials",
report.lookAheadTrials <= 4, 1, {0, 0});
1242 if (!candidates.empty()) {
1245 candidates.front());
1250 CHKERR testing.checkValue<TestType::SCALAR>(
"Look-ahead evaluated candidates",
1251 trials > 0, 1, {0, 0});
1253 "Look-ahead feasible continuation", feasible > 0, 1, {0, 0});
1255 "Look-ahead source unchanged",
1256 model.mesh.points ==
points && model.mesh.cells ==
cells &&
1259 auto irregular = irregularModel(
tools, model);
1260 int promoted = 0, unknown = 0;
1261 for (
const auto &edge : frontEdges(irregular))
1265 irregular.mesh, irregular.crack, edge,
1267 alternatives +=
report.alternativeTriangulations;
1269 <<
"Irregular edge " << edge[0] <<
' ' << edge[1] <<
" angle "
1270 <<
angle <<
": candidates " << candidates.size() <<
", feasible "
1271 <<
report.lookAheadFeasible <<
", alternatives "
1272 <<
report.alternativeTriangulations;
1273 for (
const auto &
c : candidates)
1275 <<
"Irregular node " <<
c.freeNode <<
", state " <<
c.continuation
1276 <<
", score " <<
c.score <<
", operations " <<
c.
operations
1277 <<
", open corners " <<
c.openCorners;
1278 if (!candidates.empty()) {
1279 const auto &chosen = candidates.front();
1280 for (
const auto &
c : candidates) {
1292 candidates.front());
1296 const auto target_normal =
cross(sub(irregular.mesh.points[edge[1]],
1297 irregular.mesh.points[edge[0]]),
1298 direction(irregular, edge,
angle));
1299 std::set<Edge> affected;
1302 for (
const auto &face :
faces)
1303 for (const auto &e :
1304 {edgeKey(face[0], face[1]), edgeKey(face[1], face[2]),
1305 edgeKey(face[0], face[2])})
1307 bool continued =
false;
1309 next_settings.lookAheadCandidates = 0;
1310 next_settings.stopAtFirstClass =
false;
1311 for (
const auto &next : frontEdges(
result)) {
1312 if (!affected.count(next))
1316 if (!(norm(
d) > 1e-8))
1321 if (!std::count(face.begin(), face.end(), next[0]) ||
1322 !std::count(face.begin(), face.end(), next[1]))
1325 if (
v != next[0] &&
v != next[1] &&
1331 if (dot(
d, direction(irregular, edge,
angle)) <= 1e-8)
1335 for (
const auto &
c : following)
1336 if (
c.angleDeviationDegrees <=
settings.angleToleranceDegrees) {
1339 "Look-ahead actual second step");
1347 "Look-ahead prediction can be applied", continued, 1, {0, 0});
1352 "Look-ahead alternative triangulations", alternatives > 0, 1, {0, 0});
1354 "Look-ahead promotes a continuable extension", promoted > 0, 1, {0, 0});
1355 CHKERR testing.checkValue<TestType::SCALAR>(
"Look-ahead cut patch is unknown",
1356 unknown > 0, 1, {0, 0});
1365 auto slit = grid(6, 4, 3);
1366 for (
int j = 0;
j != 4; ++
j)
1367 for (
int i = 0;
i != 6; ++
i)
1368 for (
int k = 0;
k != 2; ++
k)
1369 slit.crack[2 * (
j * 6 +
i) +
k] =
i < 3 || (
i < 5 &&
j != 1);
1370 std::vector<Model> models{extrude(grid(6, 4, 3), {-2, -1, 0, 1, 2}, 2),
1371 extrude(notch(), {-2, -1, 0, 1, 2}, 2),
1372 extrude(slit, {-2, -1, 0, 1, 2}, 2)};
1375 models.push_back(irregularModel(
tools, models.front()));
1379 "Join filter fixture has eligible faces", !available.empty(), 1, {0, 0});
1380 const Edge join_edge{available.front().face[0], available.front().face[1]};
1381 const auto filtered =
1383 [](
const Face &) {
return false; });
1385 "Join direction filter can exclude faces", filtered.empty(), 1, {0, 0});
1386 for (
const auto &model : models)
1387 for (const auto &edge : frontEdges(model))
1389 const auto points = model.mesh.points;
1390 const auto cells = model.mesh.cells;
1391 const auto boundary = model.mesh.boundary;
1392 const auto crack = model.crack;
1395 model.mesh, model.crack, edge, direction(model, edge,
angle),
1398 "Closure preview leaves source untouched",
1399 points == model.mesh.points &&
cells == model.mesh.cells &&
1402 for (
const auto &chosen : candidates) {
1407 "Join or closure follows target direction",
1415 const auto next = edgeKey(face[0], face[1]);
1416 const auto target_normal =
1417 cross(sub(model.mesh.points[edge[1]], model.mesh.points[edge[0]]),
1418 direction(model, edge,
angle));
1425 bool applied =
false;
1429 return faceKey(f[0], f[1], f[2]) ==
1430 faceKey(face[0], face[1], face[2]);
1439 future_settings.lookAheadCandidates = 0;
1442 for (
const auto &
c : recovered)
1444 faceKey(face[0], face[1], face[2])) {
1452 future_settings.lookAheadCandidates = 0;
1453 future_settings.stopAtFirstClass =
false;
1456 const auto gap = std::find_if(
1457 following.begin(), following.end(), [&](
const Candidate &
c) {
1458 return faceKey(c.newFace[0], c.newFace[1], c.newFace[2]) ==
1459 faceKey(face[0], face[1], face[2]);
1461 standalone += gap != following.end();
1462 if (gap == following.end())
1465 for (
const auto &
c : following)
1467 faceKey(face[0], face[1], face[2])) {
1473 future_settings.joinGapsOnly =
true;
1476 for (
const auto &
c : recovered)
1478 faceKey(face[0], face[1], face[2])) {
1486 "Predicted join or closure can be applied", applied, 1, {0, 0});
1489 if (!candidates.empty())
1490 for (
const auto &other : candidates) {
1491 const auto &
best = candidates.front();
1493 best.openCorners == other.openCorners &&
1494 best.continuation == other.continuation &&
1495 best.continuationKind > other.continuationKind &&
1496 best.score < other.score;
1500 <<
"Join preview: joins " << joins <<
", closures " <<
closures
1501 <<
", standalone " << standalone <<
", promoted " <<
preferred;
1502 CHKERR testing.checkValue<TestType::SCALAR>(
"Existing joins previewed",
1503 joins > 0, 1, {0, 0});
1504 CHKERR testing.checkValue<TestType::SCALAR>(
"Gap closures previewed",
1507 "Join or closure preference changes selection",
preferred > 0, 1, {0, 0});
1516 for (
bool gap : {
true,
false}) {
1517 auto plane = grid(6, 4, 3);
1518 for (
int j = 0;
j != 4; ++
j)
1519 for (
int i = 0;
i != 6; ++
i)
1520 for (
int k = 0;
k != 2; ++
k)
1521 plane.crack[2 * (
j * 6 +
i) +
k] =
1522 gap ? (
i < 3 || (
i < 5 &&
j != 1)) :
i != 3;
1523 auto model = extrude(plane, {-2, -1, 0, 1, 2}, 2);
1525 const auto initial_front = frontEdges(model);
1527 std::vector<int> incident;
1528 std::array<int, 2> apex{};
1529 bool prepared =
false;
1530 for (
const auto &join : joins) {
1532 bool on_front =
false;
1533 for (
const auto &edge : {edgeKey(join.face[0], join.face[1]),
1534 edgeKey(join.face[1], join.face[2]),
1535 edgeKey(join.face[0], join.face[2])})
1536 if (std::find(initial_front.begin(), initial_front.end(), edge) !=
1537 initial_front.end()) {
1546 target = faceKey(join.face[0], join.face[1], join.face[2]);
1548 for (std::size_t
c = 0;
c != model.mesh.cells.size(); ++
c) {
1549 const auto faces = cellFaces(model.mesh.cells[
c]);
1551 incident.push_back(
c);
1553 if (incident.size() != 2)
1555 for (
int n = 0;
n != 2; ++
n)
1559 bool interior =
true;
1560 for (
int v : apex) {
1561 const auto &point = model.mesh.points[
v];
1562 interior &= point[0] > 0 && point[0] < 6 && point[1] > 0 &&
1563 point[1] < 4 && std::abs(point[2]) < 2;
1570 for (
int d = 0;
d != 3; ++
d)
1571 centre[
d] += model.mesh.points[
v][
d] / 3.;
1573 for (
int d = 0;
d != 2; ++
d)
1574 trial.mesh.points[
v][
d] =
1575 0.9 * trial.mesh.points[
v][
d] + 0.1 * centre[
d];
1577 for (
const auto &cell : trial.
mesh.
cells)
1578 valid &= det(trial.
mesh, cell) > 0;
1579 std::vector<std::array<int, 4>>
cells;
1580 for (std::size_t
c = 0;
c != trial.mesh.cells.size(); ++
c)
1581 if (
c !=
static_cast<std::size_t
>(incident[0]) &&
1582 c !=
static_cast<std::size_t
>(incident[1]))
1583 cells.push_back(trial.mesh.cells[
c]);
1584 for (
int n = 0;
n != 3; ++
n) {
1585 std::array<int, 4> cell{apex[0], apex[1],
target[
n],
1587 if (det(trial.mesh, cell) < 0)
1588 std::swap(cell[2], cell[3]);
1589 valid &= det(trial.mesh, cell) > 0;
1590 cells.push_back(cell);
1594 trial.mesh.cells = std::move(
cells);
1595 model = std::move(trial);
1597 for (
int v : join.face)
1603 CHKERR testing.checkValue<TestType::SCALAR>(
"Missing joining face fixture",
1604 prepared, 1, {0, 0});
1606 int target_cells = 0;
1607 for (
const auto &cell : model.
mesh.
cells)
1608 for (const auto &face : cellFaces(cell))
1609 target_cells += face ==
key;
1611 "Joining face is initially absent", target_cells, 0, {0, 0});
1616 model.mesh, model.crack, edge, direction(model, edge, 0),
settings);
1617 const auto selected = std::find_if(
1618 candidates.begin(), candidates.end(), [&](
const Candidate &
c) {
1619 return faceKey(c.newFace[0], c.newFace[1], c.newFace[2]) == key;
1622 "Missing join recovered",
selected != candidates.end(), 1, {0, 0});
1624 "Join recovery uses flips",
selected->operations > 0, 1, {0, 0});
1625 CHKERR testing.checkValue<TestType::SCALAR>(
"Join recovery moves no vertex",
1628 auto applied = model;
1630 CHKERR checkMesh(
testing, applied,
"Recovered gap or join");
1635 std::vector<EntityHandle>
vertices;
1636 Range tets, crack_faces, protected_faces;
1637 CHKERR createCrackFixture(core, model,
vertices, tets, crack_faces,
1642 CHKERR mb.get_adjacencies(conn, 2, 1,
false, edges,
1643 moab::Interface::INTERSECT);
1645 EntityHandle face = 0;
1646 Candidate published;
1649 protected_faces, {{edges.front(), direction(model, edge, 0)}},
settings,
1650 result, face, &published);
1651 CHKERR testing.checkValue<TestType::SCALAR>(
"Flipped join published",
1652 face != 0, 1, {0, 0});
1654 "Published join has no move", norm(published.displacement), 0, {0, 0});
1656 CHKERR bits->getEntitiesByTypeAndRefLevel(
1658 CHKERR testing.checkValue<TestType::SCALAR>(
"Join keeps source cells",
1659 source == tets, 1, {0, 0});
1669 moab::Core mb_instance;
1670 moab::Interface &moab = mb_instance;
1678 "", 2,
"kinked", [&]() {
return kinked(*
testing,
tools); });
1680 "", 3,
"notch", [&]() {
return notchTest(*
testing,
tools); });
1684 "", 5,
"failure", [&]() {
return failure(*
testing,
tools); });
1686 "", 6,
"jitter", [&]() {
return jitter(*
testing,
tools); });
1692 "", 9,
"curved_skin", [&]() {
return curvedSkin(*
testing,
tools); });
1694 "", 10,
"skin_corner", [&]() {
return skinCorner(*
testing,
tools); });
1696 "", 11,
"no_hole_join", [&]() {
return noHoleJoin(*
testing,
tools); });
1698 "", 12,
"look_ahead", [&]() {
return lookAhead(*
testing,
tools); });
1699 CHKERR testing->addTestCommandLine(
"", 13,
"look_ahead_closure", [&]() {
1702 CHKERR testing->addTestCommandLine(
"", 14,
"join_recovery", [&]() {
CGALInterfaceImpl & owner
std::vector< std::array< EntityHandle, 3 > > faces
Sorted keys.
CGALTools::CrackExtensionCandidate candidate
std::vector< int > source
const Settings & settings
const std::vector< Vec > * points
std::vector< Face > closures
Faces closing non-convex front corners.
bool angle
Radians between candidate face and target plane.
std::vector< int > vertices
Vec t
Removal: the ring edge.
bool closure
The face (f0, f1, w) closes a corner at f0 or f1.
Edge closing
Its edge allowed to join two crack nodes.
std::vector< Cell > cells
#define CATCH_ERRORS
Catch errors.
#define MYPCOMM_INDEX
default communicator number PCOMM
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
MoFEMErrorCode setBitRefLevel(const Range &ents, const BitRefLevel bit, const bool only_tets=true, int verb=0, Range *adj_ents_ptr=nullptr) const
Add entities to database and set bit ref level.
#define MOFEM_LOG(channel, severity)
Log.
SeverityLevel
Severity levels.
FTensor::Index< 'i', SPACE_DIM > i
const double c
speed of light (cm/ns)
const double v
phase velocity of light in medium (cm/ns)
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
const FTensor::Tensor2< T, Dim, Dim > Vec
auto cross(const Tensor1_Expr< A, T, 3, i > &a, const Tensor1_Expr< B, U, 3, j > &b, const Index< k, 3 > &)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
implementation of Data Operators for Forces and Sources
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
const char * what() const
std::vector< std::array< int, 3 > > boundary
std::vector< std::array< double, 3 > > points
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.