v0.16.3
Loading...
Searching...
No Matches
cgal_remeshing.cpp
Go to the documentation of this file.
1/** \file cgal_remeshing.cpp
2 * \brief Local remeshing, internal sheet topology and MOAB level isolation.
3 */
4#include <MoFEM.hpp>
5#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
6#include <CGAL/squared_distance_3.h>
7#include <cmath>
8#include <filesystem>
9#include <limits>
10#include <map>
11#include <numeric>
12#include <set>
13using namespace MoFEM;
14
15namespace {
16MoFEMErrorCode require(bool condition, const char *message) {
18 if (!condition)
19 SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID, "%s", message);
21}
22
23TetMeshData grid() {
25 const int n = 4;
26 auto node = [](int i, int j, int k) { return i + 5 * (j + 5 * k); };
27 for (int k = 0; k <= n; ++k)
28 for (int j = 0; j <= n; ++j)
29 for (int i = 0; i <= n; ++i) {
30 mesh.points.push_back({-1. + .5 * i, -1. + .5 * j, -1. + .5 * k});
31 mesh.vertexIds.push_back(mesh.points.size());
32 }
33 for (int k = 0; k < n; ++k)
34 for (int j = 0; j < n; ++j)
35 for (int i = 0; i < n; ++i) {
36 std::array<int, 3> permutation{0, 1, 2};
37 do {
38 std::array<int, 3> x{i, j, k};
39 std::array<int, 4> cell{node(i, j, k), 0, 0,
40 node(i + 1, j + 1, k + 1)};
41 ++x[permutation[0]];
42 cell[1] = node(x[0], x[1], x[2]);
43 ++x[permutation[1]];
44 cell[2] = node(x[0], x[1], x[2]);
45 mesh.cells.push_back(cell);
46 } while (std::next_permutation(permutation.begin(), permutation.end()));
47 }
48 std::set<std::array<int, 3>> faces;
49 for (const auto &cell : mesh.cells)
50 for (int opposite = 0; opposite != 4; ++opposite) {
51 std::array<int, 3> f;
52 int d = 0;
53 for (int i = 0; i != 4; ++i)
54 if (i != opposite)
55 f[d++] = cell[i];
56 if (std::all_of(f.begin(), f.end(), [&](int v) {
57 return mesh.points[v][2] == 0 && mesh.points[v][0] < .01;
58 })) {
59 std::sort(f.begin(), f.end());
60 faces.insert(f);
61 }
62 }
63 mesh.boundary.assign(faces.begin(), faces.end());
64 mesh.surfaceLabels.assign(faces.size(), 7);
65 for (int j = 0; j != n; ++j) {
66 mesh.featureEdges.push_back({node(2, j, 2), node(2, j + 1, 2)});
67 mesh.edgeLabels.push_back(9);
68 }
69 mesh.fixedVertices.push_back(node(2, 2, 2));
70 return mesh;
71}
72
73TetMeshData domainFixture(bool cavity) {
74 auto mesh = grid();
75 auto centre = [&](const auto &cell) {
76 std::array<double, 3> x{};
77 for (int v : cell)
78 for (int d = 0; d != 3; ++d)
79 x[d] += mesh.points[v][d] / 4;
80 return x;
81 };
82 mesh.cells.erase(std::remove_if(mesh.cells.begin(), mesh.cells.end(),
83 [&](const auto &cell) {
84 const auto x = centre(cell);
85 return cavity ? (x[0] > 0 && x[0] < .5 &&
86 x[1] > 0 && x[1] < .5 &&
87 x[2] > 0 && x[2] < .5)
88 : (x[0] > 0 && x[1] > 0);
89 }),
90 mesh.cells.end());
91 std::set<int> used;
92 for (const auto &cell : mesh.cells)
93 used.insert(cell.begin(), cell.end());
94 std::map<int, int> indices;
96 for (int i : used) {
97 indices[i] = result.points.size();
98 result.points.push_back(mesh.points[i]);
99 result.vertexIds.push_back(mesh.vertexIds[i]);
100 }
101 for (auto cell : mesh.cells) {
102 for (auto &v : cell)
103 v = indices.at(v);
104 result.cells.push_back(cell);
105 }
106 for (size_t i = 0; i != mesh.boundary.size(); ++i) {
107 auto face = mesh.boundary[i];
108 if (!std::all_of(face.begin(), face.end(),
109 [&](int v) { return used.count(v); }))
110 continue;
111 for (auto &v : face)
112 v = indices.at(v);
113 result.boundary.push_back(face);
114 result.surfaceLabels.push_back(mesh.surfaceLabels[i]);
115 }
116 for (size_t i = 0; i != mesh.featureEdges.size(); ++i) {
117 auto edge = mesh.featureEdges[i];
118 for (auto &v : edge)
119 v = indices.at(v);
120 result.featureEdges.push_back(edge);
121 result.edgeLabels.push_back(mesh.edgeLabels[i]);
122 }
123 for (int i : mesh.fixedVertices)
124 result.fixedVertices.push_back(indices.at(i));
125 return result;
126}
127
128MoFEMErrorCode recoveryOnly(CGALTools &tools) {
130 using K = CGAL::Exact_predicates_inexact_constructions_kernel;
131 TetMeshData source, output;
132 source.points = {
133 {-1, 0, 0}, {1, 0, 0}, {0, 1, 0}, {.1, .25, 1}, {.2, .3, -1}};
134 source.vertexIds = {11, 23, 47, 59, 97};
135 source.cells = {{0, 1, 3, 4}, {1, 2, 3, 4}, {2, 0, 3, 4}};
136 source.boundary = {{0, 3, 4}};
137 source.surfaceLabels = {7};
138 source.featureEdges = {{3, 4}};
139 source.edgeLabels = {9};
140 std::vector<int> selected{0, 1, 2};
143 settings.minimumQuality = 1; // Recovery has no quality-improvement gate.
144 settings.relativeSurfaceTolerance = 1e-30;
146 auto messages = boost::make_shared<std::ostringstream>();
147 auto sink = LogManager::createSink(messages, "CGALTools");
148 logging::core::get()->add_sink(sink);
150 logging::core::get()->remove_sink(sink);
151 CHKERR require(
152 messages->str().find("[CGALTools]") != std::string::npos &&
153 messages->str().find("exceeds surface geometry tolerance") !=
154 std::string::npos,
155 "Surface tolerance did not produce a tagged warning");
156 CHKERR require(
157 report.insertedVertices > 0 && report.removedVertices == 0 &&
158 report.movedVertices == 0 &&
159 output.points.size() ==
160 source.points.size() + report.insertedVertices,
161 "Recovery did not preserve source vertices and add Steiner points");
162 std::map<int, std::array<double, 3>> original;
163 for (size_t i = 0; i != source.points.size(); ++i)
164 original.emplace(source.vertexIds[i], source.points[i]);
165 auto point = [](const auto &x) { return K::Point_3(x[0], x[1], x[2]); };
166 // Only exterior and supplied internal facets are constraints in this case.
167 std::map<std::array<int, 3>, int> incidence;
168 for (const auto &cell : source.cells)
169 for (int d = 0; d != 4; ++d) {
170 std::array<int, 3> face;
171 int n = 0;
172 for (int j = 0; j != 4; ++j)
173 if (j != d)
174 face[n++] = cell[j];
175 std::sort(face.begin(), face.end());
176 ++incidence[face];
177 }
178 std::vector<K::Triangle_3> constraints;
179 for (const auto &[face, count] : incidence)
180 if (count == 1 || face == source.boundary.front())
181 constraints.emplace_back(point(source.points[face[0]]),
182 point(source.points[face[1]]),
183 point(source.points[face[2]]));
184 std::set<int> seen;
185 for (size_t i = 0; i != output.points.size(); ++i) {
186 const int id = output.vertexIds[i];
187 CHKERR require(id > 0 && seen.insert(id).second,
188 "Invalid recovery vertex ID");
189 const auto found = original.find(id);
190 if (found != original.end())
191 CHKERR require(found->second == output.points[i],
192 "Recovery moved a source vertex");
193 else {
194 CHKERR require(id > 97,
195 "Recovery reused a source ID for a Steiner point");
196 const auto p = point(output.points[i]);
197 CHKERR require(
198 std::any_of(constraints.begin(), constraints.end(),
199 [&](const auto &triangle) {
200 return CGAL::squared_distance(p, triangle) < 1e-24;
201 }),
202 "Recovery added a point away from its constraint surfaces");
203 }
204 }
205 for (int id : source.vertexIds)
206 CHKERR require(seen.count(id), "Recovery dropped a source vertex ID");
207 double volume = 0;
208 for (const auto &cell : output.cells) {
209 const double v = CGAL::to_double(CGAL::volume(
210 point(output.points[cell[0]]), point(output.points[cell[1]]),
211 point(output.points[cell[2]]), point(output.points[cell[3]])));
212 CHKERR require(v > 0, "Recovery produced a nonpositive tetrahedron");
213 volume += v;
214 }
215 CHKERR require(
216 std::abs(volume - 2. / 3.) < 1e-12 &&
217 std::find(output.surfaceLabels.begin(), output.surfaceLabels.end(),
218 7) != output.surfaceLabels.end() &&
219 std::set<int>(output.edgeLabels.begin(), output.edgeLabels.end()) ==
220 std::set<int>{9},
221 "Recovery changed the volume or lost a protected classification");
223}
224
225MoFEMErrorCode nearbyCurves(CGALTools &tools) {
227 TetMeshData source, output;
228 const std::array<std::array<int, 4>, 6> cells{{{0, 1, 3, 7},
229 {0, 1, 5, 7},
230 {0, 2, 3, 7},
231 {0, 2, 6, 7},
232 {0, 4, 5, 7},
233 {0, 4, 6, 7}}};
234 for (int body = 0; body != 2; ++body) {
235 for (int i = 0; i != 8; ++i) {
236 source.points.push_back({double(i & 1) + body * (1 + 1e-4),
237 double((i >> 1) & 1), double((i >> 2) & 1)});
238 source.vertexIds.push_back(source.points.size());
239 }
240 for (auto cell : cells) {
241 for (auto &v : cell)
242 v += 8 * body;
243 source.cells.push_back(cell);
244 }
245 }
246 source.featureEdges = {{1, 3}, {8, 10}};
247 source.edgeLabels = {11, 12};
248 std::vector<int> selected(source.cells.size());
249 std::iota(selected.begin(), selected.end(), 0);
252 // Separation is smaller than the allowed geometric approximation, while
253 // curve identity must still use only coordinate round-off tolerance.
254 settings.relativeSurfaceTolerance = 1e-3;
255 settings.remeshSurfaces =
256 false; // Isolate curve identity from surface smoothing.
259 CHKERR require(
260 std::set<int>(output.edgeLabels.begin(), output.edgeLabels.end()) ==
261 std::set<int>{11, 12},
262 "Nearby independent curves lost their labels");
264}
265
266MoFEMErrorCode rejectedCandidates(CGALTools &tools,
269 auto reject = [&](TetMeshData source, std::vector<int> selected,
271 bool strict_quality = false) {
273 TetMeshData output;
274 output.points.push_back({9, 8, 7});
277 bool rejected = false;
278 try {
279 tools.remesh(output, source, selected, options, report);
280 } catch (const std::exception &) {
281 rejected = true;
282 }
283 const bool unchanged =
284 output.points == std::vector<std::array<double, 3>>{{9, 8, 7}} &&
285 output.cells.empty() && report.minQualityAfter == 42;
286 CHKERR require(rejected
287 ? unchanged
288 : strict_quality && !output.cells.empty() &&
289 report.minQualityBefore > 0 &&
290 report.minQualityAfter >= report.minQualityBefore,
291 "Candidate violated rejection or strict-quality contract");
293 };
294 auto input = grid();
295 CHKERR reject(input, {-1}, settings);
296 auto invalid_settings = settings;
297 invalid_settings.targetEdgeLength = -1;
298 CHKERR reject(input, {0}, invalid_settings);
299 invalid_settings = settings;
300 invalid_settings.minimumQuality = 1;
301 std::vector<int> all(input.cells.size());
302 std::iota(all.begin(), all.end(), 0);
303 CHKERR reject(input, all, invalid_settings, true);
304 invalid_settings.minimumQuality = 2;
305 CHKERR reject(input, all, invalid_settings);
306 input.cells.push_back(input.cells.front());
307 CHKERR reject(input, {0}, settings);
308 input = grid();
309 input.cells[0][1] = input.cells[0][0];
310 CHKERR reject(input, {0}, settings);
311 input = grid();
312 input.points[0] = input.points[1];
313 CHKERR reject(input, {0}, settings);
314 input = grid();
315 input.fixedVertices.push_back(input.points.size());
316 CHKERR reject(input, {0}, settings);
317 input = grid();
318 input.featureEdges.push_back({-1, 0});
319 input.edgeLabels.push_back(2);
320 CHKERR reject(input, {0}, settings);
322}
323
324MoFEMErrorCode preserveFront(CGALTools &tools,
327 using K = CGAL::Exact_predicates_inexact_constructions_kernel;
328 auto source = grid();
329 source.boundary.clear();
330 source.surfaceLabels.clear();
331 source.featureEdges.clear();
332 source.edgeLabels.clear();
333 source.fixedVertices.clear();
334 std::set<std::array<int, 3>> sheet;
335 for (const auto &cell : source.cells)
336 for (int opposite = 0; opposite != 4; ++opposite) {
337 std::array<int, 3> face;
338 int n = 0;
339 for (int i = 0; i != 4; ++i)
340 if (i != opposite)
341 face[n++] = cell[i];
342 if (std::all_of(face.begin(), face.end(), [&](int v) {
343 const auto &x = source.points[v];
344 return x[2] == 0 && x[0] <= -.5;
345 })) {
346 std::sort(face.begin(), face.end());
347 sheet.insert(face);
348 }
349 }
350 source.boundary.assign(sheet.begin(), sheet.end());
351 source.surfaceLabels.assign(sheet.size(), 7);
352 const auto front = [](const TetMeshData &mesh) {
353 std::map<std::array<int, 2>, int> counts;
354 for (size_t i = 0; i != mesh.boundary.size(); ++i)
355 if (mesh.surfaceLabels[i] == 7)
356 for (int d = 0; d != 3; ++d) {
357 std::array<int, 2> edge{mesh.boundary[i][d],
358 mesh.boundary[i][(d + 1) % 3]};
359 std::sort(edge.begin(), edge.end());
360 ++counts[edge];
361 }
362 std::vector<std::array<int, 2>> edges;
363 for (const auto &[edge, count] : counts)
364 if (count == 1)
365 edges.push_back(edge);
366 return edges;
367 };
368 const auto point = [](const auto &x) { return K::Point_3(x[0], x[1], x[2]); };
369 std::map<int, std::array<double, 3>> original;
370 std::vector<K::Segment_3> segments;
371 for (const auto &edge : front(source)) {
372 segments.emplace_back(point(source.points[edge[0]]),
373 point(source.points[edge[1]]));
374 for (int v : edge)
375 original.emplace(source.vertexIds[v], source.points[v]);
376 }
377 TetMeshData output;
379 std::vector<int> selected(source.cells.size());
380 std::iota(selected.begin(), selected.end(), 0);
382 std::map<int, std::array<double, 3>> retained;
383 for (const auto &edge : front(output)) {
384 const auto a = point(output.points[edge[0]]),
385 b = point(output.points[edge[1]]);
386 CHKERR require(
387 std::any_of(segments.begin(), segments.end(),
388 [&](const auto &segment) {
389 return CGAL::squared_distance(a, segment) < 1e-24 &&
390 CGAL::squared_distance(b, segment) < 1e-24;
391 }),
392 "Coarsening changed the internal surface front polyline");
393 for (int v : edge)
394 retained.emplace(output.vertexIds[v], output.points[v]);
395 }
396 for (const auto &[id, x] : original)
397 CHKERR require(retained.count(id) && retained.at(id) == x,
398 "Coarsening removed or moved an original front vertex");
399 CHKERR require(report.removedVertices > 0 &&
400 output.cells.size() < source.cells.size(),
401 "Front preservation disabled volume coarsening");
403}
404
405MoFEMErrorCode surfaceFlip(CGALTools &tools,
408 TetMeshData mesh, output;
409 const int n = 5;
410 for (int j = 0; j <= n; ++j)
411 for (int i = 0; i <= n; ++i)
412 mesh.points.push_back({-1. + 2. * i / n, -1. + 2. * j / n, 0});
413 const int upper = mesh.points.size(), lower = upper + 1;
414 mesh.points.push_back({0, 0, 2});
415 mesh.points.push_back({0, 0, -2});
416 for (int j = 0; j != n; ++j)
417 for (int i = 0; i != n; ++i) {
418 const int a = i + (n + 1) * j, b = a + 1, d = a + n + 1, c = d + 1;
419 // One reversed central diagonal introduces a surface-valence defect.
420 const std::array<std::array<int, 3>, 2> faces =
421 i == 2 && j == 2
422 ? std::array<std::array<int, 3>, 2>{{{a, b, d}, {b, c, d}}}
423 : std::array<std::array<int, 3>, 2>{{{a, b, c}, {a, c, d}}};
424 for (const auto &f : faces) {
425 mesh.boundary.push_back(f);
426 mesh.surfaceLabels.push_back(7);
427 mesh.cells.push_back({f[0], f[1], f[2], upper});
428 mesh.cells.push_back({f[0], f[1], f[2], lower});
429 }
430 }
431 for (size_t i = 0; i != mesh.points.size(); ++i) {
432 mesh.vertexIds.push_back(i + 1);
433 mesh.fixedVertices.push_back(i);
434 }
435 std::vector<int> selected(mesh.cells.size());
436 std::iota(selected.begin(), selected.end(), 0);
437 settings.targetEdgeLength = 100;
440 auto keys = [](const TetMeshData &data) {
441 std::set<std::array<int, 3>> faces;
442 for (size_t i = 0; i != data.boundary.size(); ++i)
443 if (data.surfaceLabels[i] == 7) {
444 auto f = data.boundary[i];
445 for (auto &v : f)
446 v = data.vertexIds[v];
447 std::sort(f.begin(), f.end());
448 faces.insert(f);
449 }
450 return faces;
451 };
452 const auto before = keys(mesh), after = keys(output);
453 CHKERR require(!after.empty(), "Remeshing removed the tested internal sheet");
454 CHKERR require(report.removedVertices == 0 && report.movedVertices == 0,
455 "Constrained surface remeshing changed fixed source vertices");
456 CHKERR require(before != after,
457 "Constrained surface remeshing did not change connectivity");
458 CHKERR require(output.points.size() ==
459 mesh.points.size() + report.insertedVertices,
460 "Inserted-vertex report does not match the fixed mesh");
461 double area = 0;
462 std::set<int> used;
463 std::map<std::array<int, 2>, int> edges;
464 size_t faces = 0;
465 for (size_t i = 0; i != output.boundary.size(); ++i) {
466 if (output.surfaceLabels[i] != 7)
467 continue;
468 const auto &face = output.boundary[i];
469 ++faces;
470 std::array<double, 3> a, b;
471 for (int d = 0; d != 3; ++d) {
472 a[d] = output.points[face[1]][d] - output.points[face[0]][d];
473 b[d] = output.points[face[2]][d] - output.points[face[0]][d];
474 }
475 area += .5 * std::abs(a[0] * b[1] - a[1] * b[0]);
476 for (int d = 0; d != 3; ++d) {
477 used.insert(face[d]);
478 CHKERR require(std::abs(output.points[face[d]][2]) < 1e-12,
479 "Remeshed sheet left its reference plane");
480 std::array<int, 2> edge{face[d], face[(d + 1) % 3]};
481 std::sort(edge.begin(), edge.end());
482 CHKERR require(++edges[edge] <= 2, "Nonmanifold remeshed sheet edge");
483 }
484 }
485 CHKERR require(std::abs(area - 4) < 1e-10 &&
486 static_cast<long>(used.size()) - edges.size() + faces == 1,
487 "Remeshing changed the area or topology of the sheet");
489}
490
491// Exercise the public bridge with curved mid-nodes left in MOAB throughout.
492MoFEMErrorCode higherOrderInput(MoFEM::Interface &m_field) {
494 auto &mb = m_field.get_moab();
495 auto bridge = m_field.getInterface<CGALInterface>();
497 mesh.points = {
498 {-1, 0, 0}, {1, 0, 0}, {0, 1, 0}, {.1, .25, .4}, {.1, .25, -.4}};
499 mesh.vertexIds = {1, 2, 3, 4, 5};
500 mesh.cells = {{0, 1, 2, 3}, {0, 1, 2, 4}};
502 EntityHandle volume, surface, quadratic;
503 CHKERR bridge->importMesh(mesh, BitRefLevel().set(0), source, volume,
504 surface);
505 const auto cells = source.subset_by_type(MBTET);
506 const auto simplices = subtract(source, source.subset_by_type(MBVERTEX));
507 CHKERR mb.create_meshset(MESHSET_SET, quadratic);
508 CHKERR mb.add_entities(quadratic, simplices);
509 CHKERR mb.convert_entities(quadratic, true, false, false);
510 CHKERR mb.delete_entities(&quadratic, 1);
511 Range nodes;
512 CHKERR mb.get_connectivity(simplices, nodes, false);
513 for (auto node : subtract(nodes, source.subset_by_type(MBVERTEX))) {
514 double x[3];
515 CHKERR mb.get_coords(&node, 1, x);
516 x[0] += .25;
517 CHKERR mb.set_coords(&node, 1, x);
518 }
519 std::map<EntityHandle, std::vector<EntityHandle>> original_connectivity;
520 for (auto entity : simplices) {
521 const EntityHandle *conn;
522 int count;
523 CHKERR mb.get_connectivity(entity, conn, count, false);
524 if (mb.type_from_handle(entity) == MBTET)
525 CHKERR require(count == 10, "Expected higher-order source cells");
526 original_connectivity[entity] =
527 std::vector<EntityHandle>(conn, conn + count);
528 }
529 std::vector<double> original_coordinates(3 * nodes.size());
530 CHKERR mb.get_coords(nodes, original_coordinates.data());
531 auto unchanged = [&]() {
533 for (const auto &[entity, original] : original_connectivity) {
534 const EntityHandle *conn;
535 int count;
536 CHKERR mb.get_connectivity(entity, conn, count, false);
537 CHKERR require(std::vector<EntityHandle>(conn, conn + count) == original,
538 "CGAL changed higher-order source connectivity");
539 }
540 std::vector<double> coordinates(original_coordinates.size());
541 CHKERR mb.get_coords(nodes, coordinates.data());
542 CHKERR require(coordinates == original_coordinates,
543 "CGAL removed or moved higher-order source nodes");
545 };
546 TetMeshData exported;
547 CHKERR bridge->exportMesh(cells, exported);
548 CHKERR require(exported.points.size() == mesh.points.size(),
549 "CGAL export included non-topological nodes");
550 Range reconstructed;
551 CHKERR bridge->reconstructDelaunay(cells, BitRefLevel().set(1),
552 reconstructed);
553 CHKERR require(reconstructed.num_of_type(MBTET) == 3,
554 "Higher-order source reconstruction did not flip cells");
555 CHKERR unchanged();
559 Range remeshed;
560 CHKERR bridge->remesh(cells, Range(), BitRefLevel().set(2), remeshed,
562 CHKERR require(remeshed.subset_by_type(MBTET) == cells,
563 "Empty selection should reuse higher-order cells");
564 CHKERR unchanged();
566}
567
571 auto bridge = m_field.getInterface<CGALInterface>();
572 auto &mb = m_field.get_moab();
574 CHKERR PetscOptionsGetReal(nullptr, nullptr, "-remesh_target_length",
575 &settings.targetEdgeLength, nullptr);
576 CHKERR PetscOptionsGetReal(nullptr, nullptr, "-remesh_surface_tolerance",
577 &settings.relativeSurfaceTolerance, nullptr);
578 CHKERR PetscOptionsGetReal(nullptr, nullptr, "-remesh_minimum_quality",
579 &settings.minimumQuality, nullptr);
580 char case_name[64] = "local", file_name[PETSC_MAX_PATH_LEN] = "";
581 CHKERR PetscOptionsGetString(nullptr, nullptr, "-remesh_test_case", case_name,
582 sizeof(case_name), nullptr);
583 CHKERR PetscOptionsGetString(nullptr, nullptr, "-file_name", file_name,
584 sizeof(file_name), nullptr);
585 const std::string test = case_name;
586 PetscBool auto_size = PETSC_FALSE;
587 CHKERR PetscOptionsGetBool(nullptr, nullptr, "-remesh_auto_size", &auto_size,
588 nullptr);
589 if (test == "recovery") {
590 CHKERR recoveryOnly(bridge->getTools());
592 }
593 if (test == "near_curves") {
594 CHKERR nearbyCurves(bridge->getTools());
596 }
597 if (test == "quadratic") {
598 CHKERR higherOrderInput(m_field);
600 }
601 if (test == "reject") {
602 CHKERR rejectedCandidates(bridge->getTools(), settings);
604 }
605 if (test == "surface") {
606 CHKERR surfaceFlip(bridge->getTools(), settings);
608 }
609 if (test == "front") {
610 CHKERR preserveFront(bridge->getTools(), settings);
612 }
613 Range cells, source, input_vertices;
614 auto sets = m_field.getInterface<MeshsetsManager>();
615 auto centreOf = [&](EntityHandle cell, double *centre) {
617 const EntityHandle *conn;
618 int count;
619 CHKERR mb.get_connectivity(cell, conn, count, true);
620 std::vector<double> coords(3 * count);
621 CHKERR mb.get_coords(conn, count, coords.data());
622 for (int d = 0; d != 3; ++d) {
623 centre[d] = 0;
624 for (int i = 0; i != count; ++i)
625 centre[d] += coords[3 * i + d] / count;
626 }
628 };
629 if (file_name[0]) {
630 CHKERR mb.load_file(file_name);
632 CHKERR sets->setMeshsetFromFile();
633 CHKERR mb.get_entities_by_type(0, MBTET, cells);
634 CHKERR mb.get_connectivity(cells, input_vertices, true);
635 Range database_vertices, missing_ids;
636 CHKERR mb.get_entities_by_type(0, MBVERTEX, database_vertices);
637 std::set<int> vertex_ids;
638 int max_id = 0;
639 for (auto v : database_vertices) {
640 int id;
641 CHKERR mb.tag_get_data(mb.globalId_tag(), &v, 1, &id);
642 if (id <= 0)
643 missing_ids.insert(v);
644 else {
645 CHKERR require(vertex_ids.insert(id).second,
646 "Duplicate source vertex GLOBAL_ID");
647 max_id = std::max(max_id, id);
648 }
649 }
650 for (auto v : missing_ids) {
651 CHKERR require(max_id < std::numeric_limits<int>::max(),
652 "Source vertex IDs exhausted");
653 const int id = ++max_id;
654 CHKERR mb.tag_set_data(mb.globalId_tag(), &v, 1, &id);
655 }
656 CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevel(
657 cells, BitRefLevel().set(0), false);
658 source =
659 cells; // Registered patch/curve memberships are read by the bridge.
660 } else {
661 const auto mesh = test == "nonconvex" || test == "cavity"
662 ? domainFixture(test == "cavity")
663 : grid();
664 Range imported;
665 EntityHandle volume, surface;
666 CHKERR bridge->importMesh(mesh, BitRefLevel().set(0), imported, volume,
667 surface);
668 cells = imported.subset_by_type(MBTET);
669 input_vertices = imported.subset_by_type(MBVERTEX);
670 source = cells;
671 Range sheet;
672 CHKERR mb.get_entities_by_dimension(surface, 2, sheet);
673 source.merge(sheet);
674 CHKERR sets->addMeshset(BLOCKSET, 1, "MATERIAL");
675 CHKERR sets->addEntitiesToMeshset(BLOCKSET, 1, cells);
676 CHKERR sets->addMeshset(BLOCKSET, 2, "CRACK");
677 CHKERR sets->addEntitiesToMeshset(BLOCKSET, 2, sheet);
678 if (test == "surface_closure") {
679 Range closure, edges;
680 CHKERR mb.get_connectivity(sheet, closure, true);
681 CHKERR mb.get_adjacencies(sheet, 1, false, edges, moab::Interface::UNION);
682 closure.merge(edges);
683 CHKERR sets->addEntitiesToMeshset(BLOCKSET, 2, closure);
684 }
685 CHKERR sets->setAttributes(BLOCKSET, 2, {4.25});
686 Range half;
687 for (auto cell : cells) {
688 double centre[3];
689 CHKERR centreOf(cell, centre);
690 if (centre[0] > .01)
691 half.insert(cell);
692 }
693 CHKERR sets->addMeshset(BLOCKSET, 3, "SECOND_REGION");
694 CHKERR sets->addEntitiesToMeshset(BLOCKSET, 3, half);
695 Range front;
696 for (const auto &edge : mesh.featureEdges) {
697 const EntityHandle conn[] = {input_vertices[edge[0]],
698 input_vertices[edge[1]]};
699 Range segment;
700 CHKERR mb.get_adjacencies(conn, 2, 1, false, segment,
701 moab::Interface::INTERSECT);
702 front.merge(segment);
703 }
704 CHKERR sets->addMeshset(BLOCKSET, 4, "FRONT");
705 CHKERR sets->addEntitiesToMeshset(BLOCKSET, 4, front);
706 CHKERR sets->addMeshset(BLOCKSET, 6, "FRONT_START");
707 CHKERR sets->addEntitiesToMeshset(BLOCKSET, 6,
708 Range(front.front(), front.front()));
709 source.merge(front);
710 const EntityHandle anchor = input_vertices[mesh.fixedVertices.front()];
711 CHKERR sets->addMeshset(NODESET, 5, "ANCHOR");
712 CHKERR sets->addEntitiesToMeshset(NODESET, 5, Range(anchor, anchor));
713 source.insert(anchor);
714 }
715 using Geometry = CGAL::Exact_predicates_inexact_constructions_kernel;
716 std::vector<Geometry::Triangle_3> source_exterior;
717 if (!file_name[0]) {
718 Range source_faces;
719 CHKERR mb.get_adjacencies(cells, 2, false, source_faces,
720 moab::Interface::UNION);
721 for (auto face : source_faces) {
722 Range incident;
723 CHKERR mb.get_adjacencies(&face, 1, 3, false, incident);
724 if (intersect(incident, cells).size() != 1)
725 continue;
726 const EntityHandle *conn;
727 int n;
728 std::array<std::array<double, 3>, 3> x;
729 CHKERR mb.get_connectivity(face, conn, n, true);
730 CHKERR mb.get_coords(conn, 3, x[0].data());
731 source_exterior.emplace_back(
732 Geometry::Point_3(x[0][0], x[0][1], x[0][2]),
733 Geometry::Point_3(x[1][0], x[1][1], x[1][2]),
734 Geometry::Point_3(x[2][0], x[2][1], x[2][2]));
735 }
736 }
737 std::vector<double> old_coords(3 * input_vertices.size());
738 CHKERR mb.get_coords(input_vertices, old_coords.data());
739 if (auto_size) {
740 CHKERR require(!cells.empty() && !input_vertices.empty(),
741 "No tetrahedra to size");
742 std::array<double, 3> lo{old_coords[0], old_coords[1], old_coords[2]},
743 hi = lo;
744 for (size_t i = 0; i != input_vertices.size(); ++i)
745 for (int d = 0; d != 3; ++d) {
746 lo[d] = std::min(lo[d], old_coords[3 * i + d]);
747 hi[d] = std::max(hi[d], old_coords[3 * i + d]);
748 }
749 settings.targetEdgeLength =
750 1.5 * std::cbrt((hi[0] - lo[0]) * (hi[1] - lo[1]) * (hi[2] - lo[2]) /
751 cells.size());
752 }
753 Range front_cells;
754 if (file_name[0] && test == "local") {
755 Range crack;
756 for (auto set : sets->getCubitMeshsetPtr(std::regex("CRACK(.*)")))
757 CHKERR mb.get_entities_by_dimension(set->getMeshset(), 2, crack, true);
758 if (!crack.empty()) {
759 Range front, vertices;
760 Skinner skin(&mb);
761 CHKERR skin.find_skin(0, crack, false, front);
762 CHKERR mb.get_connectivity(front, vertices, true);
763 CHKERR mb.get_adjacencies(vertices, 3, false, front_cells,
764 moab::Interface::UNION);
765 front_cells = intersect(front_cells, cells);
766 }
767 }
769 for (auto cell : cells) {
770 double centre[3];
771 CHKERR centreOf(cell, centre);
772 if (test == "whole" || test == "coarse" ||
773 (file_name[0] && (front_cells.empty() ||
774 front_cells.find(cell) != front_cells.end())) ||
775 (!file_name[0] && test != "empty" && std::abs(centre[0]) < .51 &&
776 std::abs(centre[2]) < .51))
777 selected.insert(cell);
778 }
779 settings.remeshSurfaces = test != "fixed";
780 if (test == "coarse")
781 settings.targetEdgeLength = .9;
783 Range output;
784 if (file_name[0]) {
785 const auto path = "cgal_remesh_" + test + "_source.h5m";
786 CHKERR mb.write_file(path.c_str());
787 }
788 if (test == "rollback") {
789 Range faces;
790 CHKERR mb.get_adjacencies(cells, 2, false, faces, moab::Interface::UNION);
791 EntityHandle duplicate = 0;
792 for (auto face : faces) {
793 Range adjacent;
794 CHKERR mb.get_adjacencies(&face, 1, 3, false, adjacent);
795 if (intersect(adjacent, cells).size() == 1) {
796 duplicate = face;
797 break;
798 }
799 }
800 CHKERR require(duplicate != 0, "Missing exterior rollback fixture face");
801 const EntityHandle *conn;
802 int count;
803 CHKERR mb.get_connectivity(duplicate, conn, count, true);
804 const std::array<EntityHandle, 3> copied{conn[0], conn[1], conn[2]};
805 ReadUtilIface *reader;
806 CHKERR mb.query_interface(reader);
807 EntityHandle start, *new_conn;
808 CHKERR reader->get_element_connect(1, 3, MBTRI, 0, start, new_conn);
809 std::copy(copied.begin(), copied.end(), new_conn);
810 CHKERR reader->update_adjacencies(start, 1, 3, new_conn);
811 Range before, after;
812 CHKERR mb.get_entities_by_handle(0, before);
813 output.insert(cells.front());
814 const auto sentinel = output;
815 report.minQualityAfter = 42;
816 CHKERR PetscPushErrorHandler(PetscReturnErrorHandler, nullptr);
817 const auto error = bridge->remesh(source, selected, BitRefLevel().set(1),
818 output, settings, report);
819 CHKERR PetscPopErrorHandler();
820 CHKERR mb.get_entities_by_handle(0, after);
821 CHKERR require(error && before == after && output == sentinel &&
822 report.minQualityAfter == 42,
823 "Failed publication was not rolled back");
824 Range published;
825 CHKERR m_field.getInterface<BitRefManager>()->getEntitiesByRefLevel(
826 BitRefLevel().set(1), BitRefLevel().set(), published);
827 CHKERR require(published.empty(), "Failed publication left an output bit");
828 std::vector<double> restored(old_coords.size());
829 CHKERR mb.get_coords(input_vertices, restored.data());
830 CHKERR require(restored == old_coords,
831 "Failed publication moved the source mesh");
833 }
834 CHKERR bridge->remesh(source, selected, BitRefLevel().set(1), output,
836 std::vector<double> current_coords(old_coords.size());
837 CHKERR mb.get_coords(input_vertices, current_coords.data());
838 CHKERR require(current_coords == old_coords,
839 "Remeshing moved source-level vertices");
840 Range old_level;
841 CHKERR m_field.getInterface<BitRefManager>()->getEntitiesByRefLevel(
842 BitRefLevel().set(0), BitRefLevel().set(), old_level);
843 CHKERR require(subtract(cells, old_level).empty(),
844 "Remeshing lost source-level cells");
845 if (test == "empty")
846 CHKERR require(output.subset_by_type(MBTET) == cells &&
847 report.changedCells.empty(),
848 "Empty selection changed connectivity");
849 else
850 CHKERR require(!report.changedCells.empty(),
851 "Remeshing did not exercise connectivity changes");
852 if (test == "coarse")
853 CHKERR require(report.removedVertices > 0,
854 "Coarse target did not exercise collapse");
855 if (test == "whole")
856 CHKERR require(report.insertedVertices > 0,
857 "Fine target did not exercise splitting");
858 if (test == "whole" && !file_name[0]) {
859 const auto first_vertices = output.subset_by_type(MBVERTEX);
860 std::vector<double> before(3 * first_vertices.size()), after(before.size());
861 CHKERR mb.get_coords(first_vertices, before.data());
862 Range repeated;
863 CGALTools::RemeshReport second_report;
864 CHKERR bridge->remesh(output.subset_by_type(MBTET),
865 output.subset_by_type(MBTET), BitRefLevel().set(2),
866 repeated, settings, second_report);
867 CHKERR mb.get_coords(first_vertices, after.data());
868 CHKERR require(before == after && !repeated.subset_by_type(MBTET).empty(),
869 "Repeated remeshing changed its source level");
870 }
871 // Independent incidence check restricted to the active output cells.
872 Range faces;
873 const auto output_cells = output.subset_by_type(MBTET);
874 auto signedVolume = [&](const Range &region, double &total) {
876 total = 0;
877 for (auto cell : region) {
878 const EntityHandle *conn;
879 int count;
880 std::array<std::array<double, 3>, 4> x;
881 CHKERR mb.get_connectivity(cell, conn, count, true);
882 CHKERR mb.get_coords(conn, 4, x[0].data());
883 for (int i = 1; i != 4; ++i)
884 for (int d = 0; d != 3; ++d)
885 x[i][d] -= x[0][d];
886 const double det = x[1][0] * (x[2][1] * x[3][2] - x[2][2] * x[3][1]) -
887 x[1][1] * (x[2][0] * x[3][2] - x[2][2] * x[3][0]) +
888 x[1][2] * (x[2][0] * x[3][1] - x[2][1] * x[3][0]);
889 CHKERR require(det > 0, "Nonpositive remeshing cell volume");
890 total += det / 6;
891 }
893 };
894 double output_volume;
895 CHKERR signedVolume(output_cells, output_volume);
896 if (!file_name[0]) {
897 double input_volume;
898 CHKERR signedVolume(cells, input_volume);
900 ->checkValue<TestType::SCALAR>("Remeshing physical volume",
901 output_volume, input_volume,
902 {1e-8, 1e-10});
903 Range support;
904 CHKERR mb.get_connectivity(subtract(cells, selected), support, true);
905 CHKERR require(subtract(support, output).empty(),
906 "Remeshing removed an unselected source support vertex");
907 Range material, anchor;
908 CHKERR mb.get_entities_by_type(
909 sets->getCubitMeshsetPtr(1, BLOCKSET)->getMeshset(), MBTET, material);
910 CHKERR require(intersect(material, output) == output_cells,
911 "Remeshing changed material membership");
912 CHKERR mb.get_entities_by_type(
913 sets->getCubitMeshsetPtr(5, NODESET)->getMeshset(), MBVERTEX, anchor);
914 CHKERR require(anchor.size() == 1 && intersect(anchor, output) == anchor,
915 "Remeshing lost its fixed anchor");
916 }
917 if (test == "nonconvex" || test == "cavity") {
918 auto volume = [&](const Range &cells, bool check_void, double &total) {
920 total = 0;
921 for (auto cell : cells) {
922 const EntityHandle *conn;
923 int n;
924 std::array<std::array<double, 3>, 4> x;
925 CHKERR mb.get_connectivity(cell, conn, n, true);
926 CHKERR mb.get_coords(conn, 4, x[0].data());
927 std::array<double, 3> centre{};
928 for (const auto &p : x)
929 for (int d = 0; d != 3; ++d)
930 centre[d] += p[d] / 4;
931 if (check_void) {
932 const bool inside_void = test == "cavity"
933 ? centre[0] > 0 && centre[0] < .5 &&
934 centre[1] > 0 && centre[1] < .5 &&
935 centre[2] > 0 && centre[2] < .5
936 : centre[0] > 0 && centre[1] > 0;
937 CHKERR require(!inside_void,
938 "Constrained remeshing filled the excluded region");
939 }
940 for (int i = 1; i != 4; ++i)
941 for (int d = 0; d != 3; ++d)
942 x[i][d] -= x[0][d];
943 const double det = x[1][0] * (x[2][1] * x[3][2] - x[2][2] * x[3][1]) -
944 x[1][1] * (x[2][0] * x[3][2] - x[2][2] * x[3][0]) +
945 x[1][2] * (x[2][0] * x[3][1] - x[2][1] * x[3][0]);
946 CHKERR require(det > 0, "Nonpositive constrained-domain cell");
947 total += det / 6;
948 }
950 };
951 double before, after;
952 CHKERR volume(cells, false, before);
953 CHKERR volume(output_cells, true, after);
954 CHKERR require(std::abs(before - after) < 1e-8 * before,
955 "Constrained remeshing changed physical volume");
956 }
957
958 CHKERR mb.get_adjacencies(output_cells, 2, false, faces,
959 moab::Interface::UNION);
960 for (auto face : faces) {
961 Range incident;
962 CHKERR mb.get_adjacencies(&face, 1, 3, false, incident);
963 incident = intersect(incident, output_cells);
964 const auto count = incident.size();
965 CHKERR require(count == 1 || count == 2, "Invalid output facet incidence");
966 if (count == 1) {
967 int side, sense, offset;
968 CHKERR mb.side_number(incident.front(), face, side, sense, offset);
969 CHKERR require(sense == 1, "Remeshing reversed an output skin face");
970 }
971 if (count == 1 && !file_name[0]) {
972 const EntityHandle *conn;
973 int n;
974 CHKERR mb.get_connectivity(face, conn, n, true);
975 std::array<double, 9> coords;
976 CHKERR mb.get_coords(conn, 3, coords.data());
977 for (int i = 0; i != 3; ++i) {
978 const Geometry::Point_3 point(coords[3 * i], coords[3 * i + 1],
979 coords[3 * i + 2]);
980 const bool exterior = std::any_of(
981 source_exterior.begin(), source_exterior.end(),
982 [&](const auto &triangle) {
983 return CGAL::squared_distance(point, triangle) < 1e-16;
984 });
985 CHKERR require(exterior, "Output contains an unmatched internal face");
986 }
987 }
988 }
989 if (!file_name[0]) {
990 Range crack;
991 CHKERR mb.get_entities_by_dimension(
992 sets->getCubitMeshsetPtr(2, BLOCKSET)->getMeshset(), 2, crack);
993 crack = intersect(crack, output);
994 CHKERR require(!crack.empty(), "Remeshing lost the CRACK meshset");
995 for (auto face : crack) {
996 Range incident;
997 CHKERR mb.get_adjacencies(&face, 1, 3, false, incident);
998 CHKERR require(intersect(incident, output_cells).size() == 2,
999 "Crack ceased to be an internal sheet");
1000 }
1001 if (test == "surface_closure") {
1002 const auto group = sets->getCubitMeshsetPtr(2, BLOCKSET)->getMeshset();
1003 Range expected_edges, expected_nodes, edges, nodes;
1004 CHKERR mb.get_adjacencies(crack, 1, false, expected_edges,
1005 moab::Interface::UNION);
1006 CHKERR mb.get_connectivity(crack, expected_nodes, true);
1007 CHKERR mb.get_entities_by_type(group, MBEDGE, edges);
1008 CHKERR mb.get_entities_by_type(group, MBVERTEX, nodes);
1009 CHKERR require(intersect(edges, output) == expected_edges &&
1010 intersect(nodes, output) == expected_nodes,
1011 "Surface closure did not follow the reconstructed faces");
1012 }
1013 Range front;
1014 CHKERR mb.get_entities_by_dimension(
1015 sets->getCubitMeshsetPtr(4, BLOCKSET)->getMeshset(), 1, front);
1016 CHKERR require(!intersect(front, output).empty(),
1017 "Remeshing lost the FRONT meshset");
1018 }
1019 const std::string path = "cgal_remesh_" + test + ".h5m";
1020 EntityHandle saved;
1021 CHKERR mb.create_meshset(MESHSET_SET, saved);
1022 CHKERR mb.add_entities(saved, output);
1023 std::vector<EntityHandle> written_sets{saved};
1024 for (auto it = sets->getBegin(); it != sets->getEnd(); ++it)
1025 written_sets.push_back(it->getMeshset());
1026 std::map<EntityHandle, Range> memberships;
1027 for (size_t i = 1; i < written_sets.size(); ++i) {
1028 const auto set = written_sets[i];
1029 if (memberships.count(set))
1030 continue;
1031 Range members;
1032 CHKERR mb.get_entities_by_handle(set, members, false);
1033 memberships.emplace(set, members);
1034 const auto children = members.subset_by_type(MBENTITYSET);
1035 written_sets.insert(written_sets.end(), children.begin(), children.end());
1036 }
1037 // Write only active geometry while retaining block/sideset metadata. Restore
1038 // all memberships afterwards so this also exercises source-level isolation.
1039 for (const auto &[set, members] : memberships) {
1040 CHKERR mb.clear_meshset(&set, 1);
1041 const auto active =
1042 unite(intersect(members, output), members.subset_by_type(MBENTITYSET));
1043 CHKERR mb.add_entities(set, active);
1044 }
1045 const auto write_error = mb.write_file(
1046 path.c_str(), "MOAB", nullptr, written_sets.data(), written_sets.size());
1047 for (const auto &[set, members] : memberships) {
1048 CHKERR mb.clear_meshset(&set, 1);
1049 CHKERR mb.add_entities(set, members);
1050 }
1051 CHKERR write_error;
1052 moab::Core reload;
1053 CHKERR reload.load_file(path.c_str());
1054 Range reloaded;
1055 CHKERR reload.get_entities_by_type(0, MBTET, reloaded);
1056 CHKERR require(reloaded.size() == output_cells.size(),
1057 "H5M round trip changed output cells");
1058 MoFEM::CoreTmp<-1> reload_core(reload);
1059 auto reload_sets = reload_core.getInterface<MeshsetsManager>();
1060 CHKERR reload_sets->setMeshsetFromFile();
1061 Range expected_crack, saved_crack;
1062 for (auto set : sets->getCubitMeshsetPtr(std::regex("CRACK(.*)"))) {
1063 Range faces;
1064 CHKERR mb.get_entities_by_dimension(set->getMeshset(), 2, faces, true);
1065 expected_crack.merge(intersect(faces, output));
1066 }
1067 for (auto set : reload_sets->getCubitMeshsetPtr(std::regex("CRACK(.*)")))
1068 CHKERR reload.get_entities_by_dimension(set->getMeshset(), 2, saved_crack,
1069 true);
1070 CHKERR require(saved_crack.size() == expected_crack.size(),
1071 "H5M round trip lost the CRACK classification");
1072 if (!file_name[0])
1073 std::filesystem::remove(path);
1074 MOFEM_LOG("WORLD", Sev::inform)
1075 << "Remeshed " << cells.size() << " -> " << output_cells.size()
1076 << " cells; selected " << selected.size() << "; changed "
1077 << report.changedCells.size() << "; vertices inserted/removed/moved "
1078 << report.insertedVertices << '/' << report.removedVertices << '/'
1079 << report.movedVertices << "; minimum quality " << report.minQualityBefore
1080 << " -> " << report.minQualityAfter;
1082}
1083} // namespace
1084
1085int main(int argc, char *argv[]) {
1086 MoFEM::Core::Initialize(&argc, &argv, nullptr,
1087 "Tetrahedral remeshing checks\n");
1088 try {
1089 moab::Core mb;
1090 MoFEM::Core core(mb);
1091 CHKERR run(core);
1092 }
1095 return 0;
1096}
CGALTools & tools
std::vector< std::array< EntityHandle, 3 > > faces
Sorted keys.
TetMeshData result
bool selected
Definition CGALTools.cpp:97
Report & report
FaceSet skin
std::vector< int > source
const Settings & settings
int boundary
const std::vector< Vec > * points
FaceSet crack
std::vector< int > size
WorkMesh mesh
std::vector< int > vertices
bool closure
The face (f0, f1, w) closes a corner at f0 or f1.
std::unordered_map< int, NodeConstraint > constraints
std::vector< Cell > cells
bool active
moab::Interface & mb
std::vector< double > empty
One value per component.
std::vector< std::array< double, 3 > > coordinates
It it
Definition Schur.cpp:2568
It end
Definition Schur.cpp:2568
int main()
constexpr double a
@ QUIET
#define CATCH_ERRORS
Catch errors.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ NODESET
@ BLOCKSET
@ MOFEM_ATOM_TEST_INVALID
Definition definitions.h:40
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MOFEM_LOG(channel, severity)
Log.
FTensor::Index< 'i', SPACE_DIM > i
const double c
speed of light (cm/ns)
PetscBool output_volume
const double v
phase velocity of light in medium (cm/ns)
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
PetscErrorCode PetscOptionsGetReal(PetscOptions *, const char pre[], const char name[], PetscReal *dval, PetscBool *set)
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
MoFEMErrorCode TestingInterface::checkValue< TestType::SCALAR >(const std::string &check_name, PetscReal actual, PetscReal expected, Tolerance tolerance, Sev error_severity, Sev success_severity) const
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
float offset
Definition sdf_python.py:3
MoFEMErrorCode run(MoFEM::Interface &m_field)
Definition sdf_python.cpp:7
Managing BitRefLevels.
unsigned iterations
Used only for a positive target length.
Definition CGALTools.hpp:34
double targetEdgeLength
Zero: constraint recovery only.
Definition CGALTools.hpp:33
void remesh(TetMeshData &result, const TetMeshData &source, const std::vector< int > &selected_cells, const RemeshSettings &settings, RemeshReport &report) const
virtual moab::Interface & get_moab()=0
virtual MoFEMErrorCode rebuild_database(int verb=DEFAULT_VERBOSITY)=0
Clear database and initialize it once again.
Core (interface) class.
Definition Core.hpp:83
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition Core.cpp:68
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition Core.cpp:123
Deprecated interface functions.
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode setMeshsetFromFile(const string file_name, const bool clean_file_options=true)
add blocksets reading config file
std::vector< std::array< int, 3 > > boundary
Definition CGALTools.hpp:20
std::vector< std::array< int, 2 > > featureEdges
Definition CGALTools.hpp:23
std::vector< int > edgeLabels
Definition CGALTools.hpp:24
std::vector< std::array< int, 4 > > cells
Zero-based point indices.
Definition CGALTools.hpp:19
std::vector< std::array< double, 3 > > points
Definition CGALTools.hpp:17
std::vector< int > vertexIds
Definition CGALTools.hpp:18
std::vector< int > surfaceLabels
Definition CGALTools.hpp:21
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.