MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
geometryintersection.h
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#ifndef GEOMETRYINTERSECTION_H
8#define GEOMETRYINTERSECTION_H
9
10//#define CutCell_DEBUG
11
12#include <cmath>
13#include <stack>
14#include <type_traits>
15#include <typeinfo>
16#include "COMM/mpioverride.h"
17#include "GRID/cartesiangrid.h"
19#include "UTIL/timer.h"
20#include "geometry.h"
21#include "geometrycontext.h"
24
25// Additional declaration needed?
26template <MInt nDim>
27class CutCell;
28
29template <MInt nDim>
30class CutCandidate;
31
32template <MInt nDim>
34
35// \brief Helper function to initialize std::array at compile time.
36template <typename T, std::size_t n>
37constexpr std::array<T, n> make_array(const T v) {
38 std::array<T, n> a{};
39 a.fill(v);
40 return a;
41}
42
43// \brief Helper function to initialize 2D std::array at compile time.
44template <typename T, std::size_t n, std::size_t m>
45constexpr std::array<std::array<T, m>, n> make_array(const T v) {
46 std::array<std::array<T, m>, n> a{};
47 for(std::size_t i = 0; i < n; i++) {
48 for(std::size_t j = 0; j < m; j++) {
49 a[i][j] = v;
50 }
51 }
52 return a;
53}
54
55template <MInt nDim_>
57 private:
58 static constexpr MInt nDim = nDim_;
59 static constexpr MInt m_noDirs = 2 * nDim;
60 static constexpr MInt m_noCorners = IPOW2(nDim);
61 static constexpr MInt m_maxNoChilds = IPOW2(nDim);
62 static constexpr MInt m_noEdges = 2 * nDim * (nDim - 1);
63 // static constexpr MInt m_revDir[6] = {1,0,3,2,5,4};
64
67
69 MFloat& a_coordinate(const MInt cellId, const MInt dir) {
70 // FIXME labels:GEOM avoid pointer-access to the grid-raw-coordinate!!!
71 if(!m_scaledCutCell) {
72 const MInt gridCellId = grid().tree().solver2grid(cellId);
73 return grid().raw().a_coordinate(gridCellId, dir);
74 }
75
76 return m_scaledCoordinate[0];
77 }
78
80 MFloat a_cellLengthAtCell(const MInt cellId) const {
81 if(!m_scaledCutCell) {
82 return grid().cellLengthAtCell(cellId);
83 }
84 return 2;
85 }
86
88 MFloat a_gridCellVolume(const MInt cellId) const {
89 if(!m_scaledCutCell) {
90 return grid().gridCellVolume(grid().tree().level(cellId));
91 }
92 return 8;
93 }
94
95 public:
96 GeometryIntersection(GridProxy* gridProxy_, Geom* geometry_)
97 : m_eps(std::numeric_limits<MFloat>::epsilon()), m_gridProxy(gridProxy_), m_geometry(geometry_) {
99 if(geometryContext().propertyExists("bodyFaceJoinMode", 0)) { // TODO labels:GEOM simplify
100 m_bodyFaceJoinMode = *(geometryContext().getProperty("bodyFaceJoinMode", 0)->asInt(0));
101 }
102
104 if(geometryContext().propertyExists("bodyFaceJoinCriterion", 0)) {
105 m_bodyFaceJoinCriterion = *(geometryContext().getProperty("bodyFaceJoinCriterion", 0)->asFloat(0));
106 }
107
108 m_gridCutTest = "SAT";
109 if(geometryContext().propertyExists("gridCutTest", 0)) { // TODO labels:GEOM simplify
110 m_gridCutTest = *(geometryContext().getProperty("gridCutTest", 0)->asString(0));
111 }
112
113 m_multiCutCell = false;
114 if(geometryContext().propertyExists("multiCutCell", 0)) { // TODO labels:GEOM simplify
115 m_multiCutCell = (MBool) * (geometryContext().getProperty("multiCutCell", 0)->asInt(0));
116 }
117
118 if(!m_multiCutCell) {
119 m_scaledCutCell = false;
120 } else {
121 m_scaledCutCell = true;
122 }
123
124 m_bndryLvlJumps = false;
125 if(geometryContext().propertyExists("allowBndryLvlJumps", 0)) { // TODO labels:GEOM simplify
126 m_bndryLvlJumps = (MBool) * (geometryContext().getProperty("allowBndryLvlJumps", 0)->asInt(0));
127 }
128
129#ifdef CutCell_DEBUG
130 mAlloc(m_caseCheckList, 256, "m_caseCheckList", 0, AT_);
131#endif
132
133 mAlloc(m_scaledCoordinate, 3, "m_scaledCoordinate", F0, AT_);
134 }
135
139 };
140
141 const std::vector<CutCell<nDim>>& cutCellData_() { return m_cutCellData; }
142 const std::vector<CutCandidate<nDim>>& cutCandidates_() { return m_cutCandidates; }
143
144
145 // move to private later --->
146 // void designateCutCellCandidates( std::vector< CutCell<nDim> >& cutCellData ); //ditch
147
148 // general 3D
149 void computeCutFaces(std::vector<CutCell<nDim>>& cutCellData, const MInt maxNoSurfaces, const MInt tCutGroup);
150 void fillCutCellData(std::vector<CutCandidate<nDim>>& candidates,
151 std::vector<CutCell<nDim>>& cutCellData,
152 std::vector<MInt>
153 cutCellIdMapping);
154
155 // scalarField based:
156 void computeCutPoints(std::vector<CutCandidate<nDim>>& candidates, const MInt* candidateIds,
157 std::vector<MInt>& candidatesOrder);
158 void computeNodalValues(std::vector<CutCandidate<nDim>>& candidates, MInt* candidateIds, const MFloat* scalarField,
159 const MInt* bodyIdField, const MBool* const gapPropertyField, const MBool gapClosure);
160 void exchangeNodalValues(const MInt** maxLevelWindowCells, const MInt* noMaxLevelWindowCells,
161 const MInt** maxLevelHaloCells, std::vector<CutCandidate<nDim>>& candidates,
162 MInt* candidateIds);
163
164 // stl-based:
165 void computeCutPointsFromSTL(std::vector<CutCandidate<nDim>>& candidates);
166
167 void clearCutCellData() { std::vector<CutCell<nDim>>().swap(m_cutCellData); }
168 void resetCutCellData() { std::vector<CutCell<nDim>>().swap(m_cutCellData); }
170#ifdef CutCell_DEBUG_
171
172 MPI_Allreduce(MPI_IN_PLACE, &m_caseCheckList[0], 256, MPI_INT, MPI_MAX, grid().mpiComm());
173
174 if(grid().domainId() == 0) {
175 std::cerr << "Tested cases: " << std::endl;
176 for(MInt i = 0; i < 256; i++) {
177 std::cerr << i << " " << m_caseCheckList[i] << std::endl;
178 }
179 }
180#endif
181 }
182
183 // move to private later
186 // MBool m_createCoarseLevelCutCells = false;
189 // MInt m_noBodyBndryCndIds;
190 // MInt* m_bodyBndryCndIds;
192 // MInt m_bodyToSetMode;
195
199
200
201 private:
202 GridProxy& grid() { return *m_gridProxy; }
203 const GridProxy& grid() const { return *m_gridProxy; }
205
206 Geom& geometry() { return *m_geometry; }
207 const Geom& geometry() const { return *m_geometry; }
209
211
212 // general 3D function:
214
215 inline void crossProduct(MFloat* c, const MFloat* a, const MFloat* b) {
216 c[0] = a[1] * b[2] - a[2] * b[1];
217 c[1] = a[2] * b[0] - a[0] * b[2];
218 c[2] = a[0] * b[1] - a[1] * b[0];
219 }
220
221 // stencil
222 // template <class T=MInt>
223 // typename std::enable_if< nDim_==2, T >::type
224 // print2() {return a_coordinate(0,1);}
225 // template <class T=MInt>
226 // typename std::enable_if< nDim_==3, T >::type
227 // print3() {return a_coordinate(0,2);}
228 //---
229
230
231 std::vector<CutCell<nDim>> m_cutCellData;
232 std::vector<CutCandidate<nDim>> m_cutCandidates;
233
237
239
241
242 std::vector<lvlJumpCandidates<nDim>> m_cutLvlJumpCandidates;
243
244 void correctNodalValuesAtLevelJump(std::vector<CutCandidate<nDim>>& candidates, const MInt*);
245
246 void getNeighborNodes(const MInt, const MInt, MInt, MInt*, MInt*);
247
248 //======================================
249 //=== multi-cut-cell data structures ===
250 //======================================
251
252 class surfBase {
253 public:
256 std::array<MFloat, nDim> normal{};
257 std::array<MFloat, nDim> center{};
258 surfBase() = default;
259 explicit surfBase(MInt _bodyId) : bodyId(_bodyId) {}
260 };
261
263 public:
264 std::array<MFloat, nDim> coordinates{};
267 // 1: cut points;
268 // 2: additional polyhedron clipping vertex
269 // 3: additional MC vertex;
271 std::vector<MInt> edges; // corresponding edges
272 std::vector<MInt> faceIds; // corresponding faces
273 std::set<MInt> surfaceIdentificators;
274 polyVertex(MInt pId, MInt pType) : pointId(pId), pointType(pType), cartSrfcId(-1) {}
275 polyVertex(std::array<MFloat, nDim> coords, MInt pId, MInt pType) : polyVertex(pId, pType) { coordinates = coords; }
276 };
277
279 public:
282 // 0: Cartesian uncut, 1: Cartesian cut, 2: cut line on face, 3: cut line in cell
284 // for edgeType 0/1: Cartesian edge, for edgeType 2/3: cartesian face or -1 if pure body line
285 polyEdgeBase(MInt v0, MInt v1, MInt eId, MInt eType) : vertices{v0, v1}, edgeType(eType), edgeId(eId) {}
286 };
287 class polyEdge2D : public surfBase, public polyEdgeBase {
288 public:
291 polyEdge2D(MInt v0, MInt v1, MInt eId, MInt eType, MInt _bodyId)
292 : surfBase(_bodyId), polyEdgeBase(v0, v1, eId, eType), cutCell(-1) {}
293 };
294 class polyEdge3D : public polyEdgeBase {
295 public:
297 polyEdge3D(MInt v0, MInt v1, MInt eId, MInt eType) : polyEdgeBase(v0, v1, eId, eType), face{-1, -1} {}
298 };
299 typedef typename std::conditional<nDim_ == 3, polyEdge3D, polyEdge2D>::type polyEdge;
300
301 class polyFace : public surfBase {
302 public:
303 std::vector<std::pair<MInt, MInt>> edges;
304 // contains 1. the edge and 2. the direction of the edge (1: as is, -1: reversed)
305 std::vector<MInt> vertices;
306 // contains the vertexIds of the face
309 MInt faceType = -1; // 0: cartesian face; 1: body face
311 // for cartesian faces:
312 // this is the coordinate at which the face is positioned in normal-direction!
315 polyFace(MInt fId, MInt fType, MInt _bodyId)
316 : surfBase(_bodyId), cutCell(-1), faceId(fId), faceType(fType), tmpSetIndex(-1), isLine(false) {}
317
318 private:
319 polyFace() : surfBase(-1), cutCell(-1), tmpSetIndex(-1), isLine(false) {}
320 };
321
322 // class polyMultiEdge: public surfBase{
323 // public:
324 // std::vector<MInt> edges;
325 // };
326
327 class polyMultiFace : public surfBase {
328 public:
329 std::vector<MInt> faces;
330 std::list<std::pair<MInt, MInt>> edges;
331 // contains 1. the edge and 2. the direction of the edge
332 // direction can be 1/-1 (1: as is, -1: reversed)
333 // and
334 };
335
337 public:
341 polyCutCellBase(MInt cartCell, const MFloat* _center) : cartesianCell(cartCell) {
342 std::copy(_center, _center + nDim, center);
343 }
344 };
346 public:
347 std::vector<MInt> edges;
348 polyCutCell2D(MInt cartCell, const MFloat* _center) : polyCutCellBase(cartCell, _center) {}
349 };
351 public:
352 std::vector<MInt> faces;
353 polyCutCell3D(MInt cartCell, const MFloat* _center) : polyCutCellBase(cartCell, _center) {}
354 };
355 typedef typename std::conditional<nDim_ == 3, polyCutCell3D, polyCutCell2D>::type polyCutCell;
356
358 public:
360 std::vector<MInt> srfcIds;
361 explicit splitCartesianFace(MInt dir) : direction(dir) {}
362 };
363
365 public:
367 std::vector<splitCartesianFace> splitFaces;
368 explicit cellWithSplitFace(MInt id) : cellId(id) {}
369 };
370
371
372 void addPoint(const std::vector<polyVertex>*, const MInt*, const MInt, std::array<MFloat, nDim>);
373 void compVolumeIntegrals_pyraBased3(std::vector<polyCutCell>*, std::vector<polyFace>*,
374 const std::vector<polyVertex>*);
375 void compFaceIntegrals_pyraBased3(polyFace* face, const std::vector<polyVertex>* vertices, MFloat* MC, MFloat* VC,
376 MFloat* XC);
377
378 void writeVTKFileOfCell(MInt cellId, std::vector<polyFace>* faces, const std::vector<polyVertex>* vertices, MInt set);
379 void writeInfo(std::vector<CutCell<nDim>>& cutCellData, MUint, MInt);
380
381
386 template <class T = void>
387 inline typename std::enable_if<nDim_ == 2, T>::type // 2D
388 computeNormal(const std::array<MFloat, nDim> p0, const std::array<MFloat, nDim> p1, std::array<MFloat, nDim> res,
389 MFloat& w) {
390 const MFloat dx = p1[0] - p0[0], dy = p1[1] - p0[1];
391 res[0] = -dy;
392 res[1] = dx;
393 const MFloat abs = sqrt(res[0] * res[0] + res[1] * res[1]);
394 res[0] /= abs;
395 res[1] /= abs;
396 w = -res[0] * p0[0] - res[1] * p0[1];
397 return;
398 }
399 template <class T = MFloat>
400 inline typename std::enable_if<nDim_ == 3, T>::type // 3D
401 computeNormal(const std::array<MFloat, nDim> p0, const std::array<MFloat, nDim> p1, const std::array<MFloat, nDim> p2,
402 std::array<MFloat, nDim>& res, MFloat& w) {
403 const MFloat a0 = p1[0] - p0[0], a1 = p1[1] - p0[1], a2 = p1[2] - p0[2], b0 = p2[0] - p0[0], b1 = p2[1] - p0[1],
404 b2 = p2[2] - p0[2];
405 res[0] = a1 * b2 - a2 * b1;
406 res[1] = a2 * b0 - a0 * b2;
407 res[2] = a0 * b1 - a1 * b0;
408 const MFloat abs = sqrt(res[0] * res[0] + res[1] * res[1] + res[2] * res[2]);
409 res[0] /= abs;
410 res[1] /= abs;
411 res[2] /= abs;
412 w = -res[0] * p0[0] - res[1] * p0[1] - res[2] * p0[2];
413 return abs;
414 }
415
416 //-----------------------------------------------
417 // ----------- Csg-classes:
418 //-----------------------------------------------
419 class CsgVector {
420 public:
421 std::array<MFloat, nDim> xx = make_array<MFloat, nDim>(0.0);
422
423 CsgVector() = default;
424 explicit CsgVector(const std::array<MFloat, nDim> X) { xx = X; }
425 CsgVector(const CsgVector& Y) { xx = Y.xx; }
426 CsgVector(CsgVector&&) = default;
427 CsgVector& operator=(const CsgVector&) = default;
429
430 inline CsgVector clone() const {
431 CsgVector tmp(xx);
432 return tmp;
433 }
434 inline CsgVector plus(const CsgVector& a) const {
435 CsgVector tmp(xx);
436 for(MInt i = 0; i < nDim; i++)
437 tmp.xx[i] = this->xx[i] + a.xx[i];
438 return tmp;
439 }
440 inline CsgVector minus(const CsgVector& a) const {
441 CsgVector tmp(xx);
442 for(MInt i = 0; i < nDim; i++)
443 tmp.xx[i] = this->xx[i] - a.xx[i];
444 return tmp;
445 }
446 inline CsgVector times(const MFloat a) const {
447 CsgVector tmp(xx);
448 for(MInt i = 0; i < nDim; i++)
449 tmp.xx[i] = this->xx[i] * a;
450 return tmp;
451 }
452 inline CsgVector dividedBy(const MFloat a) const {
453 CsgVector tmp(xx);
454 for(MInt i = 0; i < nDim; i++)
455 tmp.xx[i] = this->xx[i] / a;
456 return tmp;
457 }
458 inline MFloat dot(const CsgVector& a) const {
459 MFloat dotp = F0;
460 for(MInt i = 0; i < nDim; i++)
461 dotp += this->xx[i] * a.xx[i];
462 return dotp;
463 }
464 inline CsgVector lerp(const CsgVector& a, const MFloat t) const { return this->plus((a.minus(*this)).times(t)); }
465 inline MFloat length() const { return sqrt(this->dot(*this)); }
466 inline CsgVector unit() const { return this->dividedBy(this->length()); }
467 template <class T = CsgVector>
468 typename std::enable_if<nDim_ == 3, T>::type // 3D
469 cross(const CsgVector a) const {
470 ASSERT(nDim == 3, "");
471 CsgVector tmp;
472 tmp.xx[0] = this->xx[1] * a.xx[2] - this->xx[2] * a.xx[1];
473 tmp.xx[1] = this->xx[2] * a.xx[0] - this->xx[0] * a.xx[2];
474 tmp.xx[2] = this->xx[0] * a.xx[1] - this->xx[1] * a.xx[0];
475 return tmp;
476 }
477 inline void negate() {
478 for(MInt i = 0; i < nDim; i++)
479 this->xx[i] = -this->xx[i];
480 }
481 };
482
483
484 class CsgVertex {
485 public:
489 CsgVertex(CsgVector _pos, MInt _vertexId, MInt _setIndex) : pos(_pos) {
490 vertexId = _vertexId;
491 setIndex = _setIndex;
492 }
493 CsgVertex clone() const {
494 CsgVertex tmp(this->pos.clone(), vertexId, setIndex);
495 return tmp;
496 }
497 CsgVertex interpolate(CsgVertex* other, MFloat t) const { return CsgVertex(this->pos.lerp(other->pos, t), -1, -1); }
498 };
499
500 class CsgPolygon;
501
502 class CsgPlane {
503 public:
504 static constexpr MFloat eps = (nDim == 3) ? 10000 * MFloatEps : 1000 * MFloatEps;
505 // tolerance used by splitPolygon() to decide if a point is on the plane or not!
508
509 CsgPlane() = default;
510 CsgPlane(CsgVector _normal, MFloat _w) : normal(_normal) { w = _w; }
511 template <class T = CsgVector>
512 typename std::enable_if<nDim_ == 2, T>::type // 2D
514 CsgVector tmp = abc[1].minus(abc[0]).unit();
515 return tmp;
516 }
517 template <class T = CsgVector>
518 typename std::enable_if<nDim_ == 3, T>::type // 3D
520 CsgVector tmp = abc[1].minus(abc[0]).cross(abc[2].minus(abc[0])).unit();
521 return tmp;
522 }
523 explicit CsgPlane(CsgVector abc[nDim]) {
524 CsgVector tmp = initPlane(abc);
525 IF_CONSTEXPR(nDim == 3) { normal = tmp; }
526 else IF_CONSTEXPR(nDim == 2) {
527 normal.xx[0] = -tmp.xx[1];
528 normal.xx[1] = tmp.xx[0];
529 }
530 w = normal.dot(abc[0]);
531 }
532 ~CsgPlane() = default;
534 CsgPlane tmp(this->normal, this->w);
535 return tmp;
536 }
537 void flip() {
538 this->normal.negate();
539 this->w = -this->w;
540 }
541 template <class T = void>
542 typename std::enable_if<nDim_ == 2, T>::type // 2D
544 std::vector<CsgPolygon>* coplanarFront,
545 std::vector<CsgPolygon>* coplanarBack,
546 std::vector<CsgPolygon>* front,
547 std::vector<CsgPolygon>* back) {
548 const MInt COPLANAR = 0;
549 const MInt FRONT = 1;
550 const MInt BACK = 2;
551 const MInt SPANNING = 3;
552
553 MInt polygonType = 0;
554 std::vector<MInt> types;
555
556 for(MInt i = 0; (unsigned)i < polygon->vertices.size(); i++) {
557 MFloat t = this->normal.dot((polygon->vertices[i].pos)) - this->w;
558 MInt type = (t < -eps) ? BACK : (t > eps) ? FRONT : COPLANAR;
559 polygonType |= type;
560 types.push_back(type);
561 }
562
563 switch(polygonType) {
564 case COPLANAR:
565 (this->normal.dot((polygon->plane.normal)) > F0 ? coplanarFront : coplanarBack)->push_back(*polygon);
566 break;
567 case FRONT:
568 front->push_back(*polygon);
569 break;
570 case BACK:
571 back->push_back(*polygon);
572 break;
573 case SPANNING: {
574 std::vector<CsgVertex> f;
575 std::vector<CsgVertex> b;
576 MInt i = 0;
577 MInt j = 1;
578 MInt ti = types[i], tj = types[j];
579 CsgVertex vi = polygon->vertices[i];
580 CsgVertex vj = polygon->vertices[j];
581 if(ti != BACK) f.push_back(vi);
582 if(ti != FRONT) b.push_back(ti != BACK ? vi.clone() : vi);
583 if((ti | tj) == SPANNING) {
584 MFloat t = (this->w - this->normal.dot((vi.pos))) / this->normal.dot(vj.pos.minus((vi.pos)));
585 CsgVertex v = vi.interpolate(&vj, t);
586 f.push_back(v);
587 b.push_back(v.clone());
588 }
589 if(tj != BACK) f.push_back(vj);
590 if(tj != FRONT) b.push_back(tj != BACK ? vj.clone() : vj);
591 if(f.size() >= 2)
592 front->push_back(
593 CsgPolygon(f, polygon->setIndex, polygon->faceId, polygon->faceType, polygon->bodyId, polygon->plane));
594 if(b.size() >= 2)
595 back->push_back(
596 CsgPolygon(b, polygon->setIndex, polygon->faceId, polygon->faceType, polygon->bodyId, polygon->plane));
597 } break;
598 default:
599 break;
600 }
601 }
602 template <class T = void>
603 typename std::enable_if<nDim_ == 3, T>::type // 3D
605 std::vector<CsgPolygon>* coplanarFront,
606 std::vector<CsgPolygon>* coplanarBack,
607 std::vector<CsgPolygon>* front,
608 std::vector<CsgPolygon>* back) {
609 const MInt COPLANAR = 0;
610 const MInt FRONT = 1;
611 const MInt BACK = 2;
612 const MInt SPANNING = 3;
613
614 MInt polygonType = 0;
615 std::vector<MInt> types;
616
617 // test normals for equivalence
618 MBool normalsEqual = false;
619 if(std::abs(std::abs(this->normal.xx[0]) - std::abs(polygon->plane.normal.xx[0])) < MFloatEps
620 && std::abs(std::abs(this->normal.xx[1]) - std::abs(polygon->plane.normal.xx[1])) < MFloatEps
621 && std::abs(std::abs(this->normal.xx[2]) - std::abs(polygon->plane.normal.xx[2])) < MFloatEps)
622 normalsEqual = true;
623
624 MBool coplanarVertex = false;
625 for(MInt i = 0; (unsigned)i < polygon->vertices.size(); i++) {
626 MFloat t = this->normal.dot((polygon->vertices[i].pos)) - this->w;
627 MInt type = (t < -eps) ? BACK : (t > eps) ? FRONT : COPLANAR;
628 polygonType |= type;
629 types.push_back(type);
630 if(type == 0) coplanarVertex = true;
631 }
632 ASSERT(!(std::isnan(polygon->plane.normal.xx[0])), "");
633
634 if(normalsEqual && coplanarVertex) polygonType = COPLANAR;
635
636 switch(polygonType) {
637 case COPLANAR:
638 (this->normal.dot((polygon->plane.normal)) > F0 ? coplanarFront : coplanarBack)->push_back(*polygon);
639 break;
640 case FRONT:
641 front->push_back(*polygon);
642 break;
643 case BACK:
644 back->push_back(*polygon);
645 break;
646 case SPANNING: {
647 std::vector<CsgVertex> f;
648 std::vector<CsgVertex> b;
649 for(MInt i = 0; (unsigned)i < polygon->vertices.size(); i++) {
650 MInt j = (i + 1) % polygon->vertices.size();
651 MInt ti = types[i], tj = types[j];
652 CsgVertex vi = polygon->vertices[i];
653 CsgVertex vj = polygon->vertices[j];
654 if(ti != BACK) f.push_back(vi);
655 if(ti != FRONT) b.push_back(ti != BACK ? vi.clone() : vi);
656 if((ti | tj) == SPANNING) {
657 MFloat t = (this->w - this->normal.dot((vi.pos))) / this->normal.dot(vj.pos.minus((vi.pos)));
658 CsgVertex v = vi.interpolate(&vj, t);
659 f.push_back(v);
660 b.push_back(v.clone());
661 }
662 }
663 if(f.size() >= 3)
664 front->push_back(
665 CsgPolygon(f, polygon->setIndex, polygon->faceId, polygon->faceType, polygon->bodyId, polygon->plane));
666 if(b.size() >= 3)
667 back->push_back(
668 CsgPolygon(b, polygon->setIndex, polygon->faceId, polygon->faceType, polygon->bodyId, polygon->plane));
669 } break;
670 default:
671 break;
672 }
673 }
674
676 std::vector<CsgPolygon>* coplanarFront,
677 std::vector<CsgPolygon>* coplanarBack) {
678 ASSERT(!(std::isnan(polygon->plane.normal.xx[0])), "");
679 (this->normal.dot((polygon->plane.normal)) > F0 ? coplanarFront : coplanarBack)->push_back(*polygon);
680 }
681 };
682
684 public:
685 std::vector<CsgVertex> vertices;
686 // helpers: edgeType[0] corresponds to edge between vertices[0] and vertices[1],...
691 MInt faceType{}; // 0: cartesian face; 1: body face
692
693 CsgPolygon(std::vector<CsgVertex> _vertices, MInt _setIndex, MInt _faceId, MInt _faceType, MInt _bodyId) {
694 for(MInt i = 0; (unsigned)i < _vertices.size(); i++) {
695 vertices.push_back(_vertices[i].clone());
696 }
697 setIndex = _setIndex;
698 faceId = _faceId;
699 faceType = _faceType;
700 bodyId = _bodyId;
701 CsgVector abc[nDim];
702 for(MInt i = 0; i < nDim; i++) {
703 abc[i] = vertices[i].pos;
704 }
705 plane = CsgPlane(abc);
706 }
707
708 CsgPolygon(std::vector<CsgVertex> _vertices, MInt _setIndex, MInt _faceId, MInt _faceType, MInt _bodyId,
709 CsgPlane _plane) {
710 for(MInt i = 0; (unsigned)i < _vertices.size(); i++) {
711 vertices.push_back(_vertices[i].clone());
712 }
713 setIndex = _setIndex;
714 faceId = _faceId;
715 faceType = _faceType;
716 bodyId = _bodyId;
717 plane = _plane.clone();
718 }
719
720 ~CsgPolygon() = default;
721
724 return tmp;
725 }
726
727 void flip() {
728 this->plane.flip();
729 std::vector<CsgVertex> tmp;
730 for(auto rit = vertices.rbegin(); rit != vertices.rend(); ++rit) {
731 tmp.push_back((*rit));
732 }
733 vertices.swap(tmp);
734 }
735
736 private:
737 CsgPolygon() = default;
738 };
739
740 class CsgNode {
741 public:
746 std::vector<CsgPolygon> polygons;
747
748 explicit CsgNode(std::vector<CsgPolygon> _polygons) {
749 planeValid = false;
750 front = nullptr;
751 back = nullptr;
752 polygons.clear();
753 this->build(_polygons);
754 }
755
757 planeValid = false;
758 front = nullptr;
759 back = nullptr;
760 polygons.clear();
761 }
762
764 this->polygons.clear();
765 delete this->front;
766 delete this->back;
767 }
768
769 void invert() {
770 for(MInt i = 0; (unsigned)i < this->polygons.size(); i++) {
771 this->polygons[i].flip();
772 }
773 this->plane.flip();
774 if(this->front) this->front->invert();
775 if(this->back) this->back->invert();
776 CsgNode* temp = this->front;
777 this->front = this->back;
778 this->back = temp;
779 }
780
781 std::vector<CsgPolygon> clipPolygons(std::vector<CsgPolygon> _polygons) {
782 if(!planeValid) {
783 return _polygons;
784 }
785 std::vector<CsgPolygon> _front;
786 std::vector<CsgPolygon> _back;
787 for(MInt i = 0; (unsigned)i < _polygons.size(); i++) {
788 this->plane.splitPolygon(&_polygons[i], &_front, &_back, &_front, &_back);
789 }
790 if(this->front) _front = this->front->clipPolygons(_front);
791 if(this->back)
792 _back = this->back->clipPolygons(_back);
793 else
794 _back.clear();
795 for(MInt i = 0; (unsigned)i < _back.size(); i++)
796 _front.push_back(_back[i]);
797 return _front;
798 }
799
800 void clipTo(CsgNode& bsp) {
801 this->polygons = bsp.clipPolygons(this->polygons);
802 if(this->front) this->front->clipTo(bsp);
803 if(this->back) this->back->clipTo(bsp);
804 }
805
806 std::vector<CsgPolygon> allPolygons() {
807 std::vector<CsgPolygon> _polygons(this->polygons);
808 if(this->front) {
809 std::vector<CsgPolygon> _polygons_front = this->front->allPolygons();
810 for(MInt i = 0; (unsigned)i < _polygons_front.size(); i++)
811 _polygons.push_back(_polygons_front[i]);
812 }
813 if(this->back) {
814 std::vector<CsgPolygon> _polygons_back = this->back->allPolygons();
815 for(MInt i = 0; (unsigned)i < _polygons_back.size(); i++)
816 _polygons.push_back(_polygons_back[i]);
817 }
818 return _polygons;
819 }
820
821 // void build(std::vector<CsgPolygon> _polygons);
822
823 template <class T = void>
824 typename std::enable_if<nDim_ == 2, T>::type build(std::vector<CsgPolygon> _polygons) {
825 if(_polygons.empty()) return;
826 if(!planeValid) {
827 this->plane = _polygons[0].plane.clone();
828 planeValid = true;
829 }
830 std::vector<CsgPolygon> _front;
831 std::vector<CsgPolygon> _back;
832 this->plane.insertCoplanarPolygon(&_polygons[0], &this->polygons, &this->polygons);
833 for(MInt i = 1; (unsigned)i < _polygons.size(); i++) {
834 this->plane.splitPolygon(&_polygons[i], &this->polygons, &this->polygons, &_front, &_back);
835 }
836 if(!_front.empty()) {
837 if(!this->front) this->front = new CsgNode();
838 this->front->build(_front);
839 }
840 if(!_back.empty()) {
841 if(!this->back) this->back = new CsgNode();
842 this->back->build(_back);
843 }
844 }
845 template <class T = void>
846 typename std::enable_if<nDim_ == 3, T>::type build(std::vector<CsgPolygon> _polygons) {
847 if(_polygons.empty()) return;
848 std::vector<CsgPolygon> _front;
849 std::vector<CsgPolygon> _back;
850 MInt polygonStartIndex = 0;
851 if(!planeValid) {
852 this->plane = _polygons[0].plane.clone();
853 planeValid = true;
854 this->polygons.push_back(_polygons[0]);
855 polygonStartIndex = 1;
856 }
857 for(MInt i = polygonStartIndex; (unsigned)i < _polygons.size(); i++) {
858 this->plane.splitPolygon(&_polygons[i], &this->polygons, &this->polygons, &_front, &_back);
859 }
860 if(!_front.empty()) {
861 if(!this->front) this->front = new CsgNode();
862 this->front->build(_front);
863 }
864 if(!_back.empty()) {
865 if(!this->back) this->back = new CsgNode();
866 this->back->build(_back);
867 }
868 }
869 };
870
871 class Csg {
872 public:
873 std::vector<CsgPolygon> polygons;
874
875 Csg() { polygons.clear(); }
876
877 explicit Csg(std::vector<CsgPolygon> _polygons) {
878 for(MInt i = 0; (unsigned)i < _polygons.size(); i++) {
879 polygons.push_back(_polygons[i].clone());
880 }
881 }
882
883 ~Csg() = default;
884
885 std::vector<CsgPolygon> toPolygons() {
886 std::vector<CsgPolygon> _polygons(this->polygons);
887 return _polygons;
888 }
889
890
891 std::vector<CsgPolygon> intersect(Csg csg) {
892 CsgNode a(this->polygons);
893 CsgNode b(csg.polygons);
894
895 b.invert();
896 b.clipTo(a);
897 b.invert();
898 a.clipTo(b);
899 b.clipTo(a);
900 a.build(b.allPolygons());
901
902 return a.allPolygons();
903 }
904
905 /*
906 //untested!!!!!!!!!!!!!!!!!!!!!!!
907 //for concave boundaries!!
908 std::vector<CsgPolygon> merge(Csg csg){
909 CsgNode a(this->polygons);
910 CsgNode b(csg.polygons);
911
912 a.clipTo(b);
913 b.clipTo(a);
914 b.invert();
915 b.clipTo(a);
916 b.invert();
917
918 a.build(b.allPolygons());
919
920 return a.allPolygons();
921 }*/
922
923 void inverse() {
924 for(MInt i = 0; (unsigned)i < this->polygons.size(); i++)
925 this->polygons[i].flip();
926 }
927 };
928};
929
930// template class GeometryIntersection<2>;
931// template class GeometryIntersection<3>;
932
933
934// ------------------------------------------------------------------------
935// ------------------------------------------------------------------------
936// ------------------------------------------------------------------------
937// ---------------------- ADDITIONAL HELPER CLASSES -----------------------
938// ------------------------------------------------------------------------
939// ------------------------------------------------------------------------
940// ------------------------------------------------------------------------
941
942template <MInt nDim>
944 public:
945 static constexpr MInt maxNoJumps = nDim == 2 ? 3 : 7;
946
948
949 // parent info
952
954 std::array<MInt, maxNoJumps> dirs = make_array<MInt, maxNoJumps>(-1);
955 std::array<MInt, maxNoJumps> diagonalDirs = make_array<MInt, maxNoJumps>(-1);
956
957 // 0: direct level-jump
958 // 1: 2D-diagonal level-jump
959 // 2: 3D-diagonal level-jump
960 std::array<MInt, maxNoJumps> neighborType = make_array<MInt, maxNoJumps>(-1);
961};
962
963template <MInt nDim>
964class CutCell {
965 public:
966 static constexpr MInt maxNoSets = 12;
967 static constexpr MInt noFaces = 2 * nDim;
968 static constexpr MInt noEdges = 2 * nDim * (nDim - 1);
969 static constexpr MInt noCorners = IPOW2(nDim);
970 static constexpr MInt maxNoCutPoints = 4 * noEdges;
971 static constexpr MInt maxNoCartesianSurfaces = 2 * noFaces;
974 static constexpr MInt maxNoFaceVertices = 4 * IPOW2(nDim - 1) + 4;
975 static constexpr MInt maxNoAdditionalVertices = 4 * noFaces;
976 static constexpr MInt maxSplitCells = noFaces;
977 static constexpr MInt no3dFaces = (nDim == 3) ? noFaces : 1;
978
979 // make private if transition complete
980 // private:
981
983
985 std::array<MFloat, nDim> volumetricCentroid = make_array<MFloat, nDim>(0.0);
986
988 std::array<std::array<MFloat, nDim>, maxNoCutPoints> cutPoints = [] {
989 std::array<std::array<MFloat, nDim>, maxNoCutPoints> a;
990 std::array<MFloat, nDim> b = make_array<MFloat, nDim>(0.0);
991 a.fill(b);
992 return a;
993 }();
994 std::array<MInt, maxNoCutPoints> cutBodyIds = make_array<MInt, maxNoCutPoints>(-1);
995 std::array<MInt, maxNoCutPoints> cutEdges = make_array<MInt, maxNoCutPoints>(-1);
996
997 std::array<std::array<MBool, no3dFaces>, maxNoSets> faceCentroidIsInsideGeometry = [] {
998 std::array<std::array<MBool, no3dFaces>, maxNoSets> a;
999 std::array<MBool, no3dFaces> b = make_array<MBool, no3dFaces>(0.0);
1000 a.fill(b);
1001 return a;
1002 }();
1003 std::array<std::array<MBool, noCorners>, maxNoSets> cornerIsInsideGeometry = [] {
1004 std::array<std::array<MBool, noCorners>, maxNoSets> a;
1005 std::array<MBool, noCorners> b = make_array<MBool, noCorners>(false);
1006 a.fill(b);
1007 return a;
1008 }();
1009 std::array<MInt, maxNoSets> associatedBodyIds = make_array<MInt, maxNoSets>(-1);
1010
1011 std::array<MInt, noFaces> noFacesPerCartesianDir = make_array<MInt, noFaces>(0);
1012 std::array<MBool, noFaces> externalFaces = make_array<MBool, noFaces>(false);
1013
1015 MInt splitParentId = -1; // link to original cell for split cells
1016 MInt noSplitChilds = 0; // number of distinct parts this cell is split into
1017 std::array<MInt, maxSplitCells> splitChildIds = make_array<MInt, maxSplitCells>(-1);
1018
1020 std::array<std::array<MFloat, nDim>, maxNoCartesianSurfaces> cartFaceCentroid = [] {
1021 std::array<std::array<MFloat, nDim>, maxNoCartesianSurfaces> a;
1022 std::array<MFloat, nDim> b = make_array<MFloat, nDim>(0.0);
1023 a.fill(b);
1024 return a;
1025 }();
1026 std::array<MFloat, maxNoCartesianSurfaces> cartFaceArea = make_array<MFloat, maxNoCartesianSurfaces>(0.0);
1027 std::array<MInt, maxNoCartesianSurfaces> cartFaceDir = make_array<MInt, maxNoCartesianSurfaces>(-1);
1028
1030 std::array<std::array<MFloat, nDim>, maxNoBoundarySurfaces> boundarySurfaceCentroid = [] {
1031 std::array<std::array<MFloat, nDim>, maxNoBoundarySurfaces> a;
1032 std::array<MFloat, nDim> b = make_array<MFloat, nDim>(0.0);
1033 a.fill(b);
1034 return a;
1035 }();
1036 std::array<std::array<MFloat, nDim>, maxNoBoundarySurfaces> boundarySurfaceNormal = [] {
1037 std::array<std::array<MFloat, nDim>, maxNoBoundarySurfaces> a;
1038 std::array<MFloat, nDim> b = make_array<MFloat, nDim>(0.0);
1039 a.fill(b);
1040 return a;
1041 }();
1042 std::array<MFloat, maxNoBoundarySurfaces> boundarySurfaceArea = make_array<MFloat, maxNoBoundarySurfaces>(0.0);
1043 std::array<MInt, maxNoBoundarySurfaces> boundarySurfaceBodyId = make_array<MInt, maxNoBoundarySurfaces>(-1);
1044 std::array<MInt, maxNoBoundarySurfaces> boundarySurfaceBndryCndId = make_array<MInt, maxNoBoundarySurfaces>(-1);
1045
1047 std::array<MInt, maxNoTotalSurfaces> allFacesBodyId = make_array<MInt, maxNoTotalSurfaces>(-1); // rather bndSrfId ???
1048 std::array<MInt, maxNoTotalSurfaces> allFacesNoPoints =
1049 make_array<MInt, maxNoTotalSurfaces>(0); // rather bndSrfId ???
1050 std::array<std::array<MInt, maxNoFaceVertices>, maxNoTotalSurfaces> allFacesPointIds = [] {
1051 std::array<std::array<MInt, maxNoFaceVertices>, maxNoTotalSurfaces> a;
1052 std::array<MInt, maxNoFaceVertices> b = make_array<MInt, maxNoFaceVertices>(-1);
1053 a.fill(b);
1054 return a;
1055 }();
1056
1057 MInt noAdditionalVertices = 0; // additional vertices due to multi-cuts, polyhedron clipping
1058 // their coords
1059 std::array<std::array<MFloat, nDim>, maxNoAdditionalVertices> additionalVertices = [] {
1060 std::array<std::array<MFloat, nDim>, maxNoAdditionalVertices> a;
1061 std::array<MFloat, nDim> b = make_array<MFloat, nDim>(0.0);
1062 a.fill(b);
1063 return a;
1064 }();
1065};
1066
1067// TODO labels:GEOM move the entire class to private and update/only hold information in the gridIntersetion!
1068template <MInt nDim>
1070 public:
1071 static constexpr MInt maxNoSets = 12;
1072 static constexpr MInt noEdges = 2 * nDim * (nDim - 1);
1073 static constexpr MInt noCorners = IPOW2(nDim);
1074 static constexpr MInt maxNoCutPoints = 4 * noEdges;
1075
1076 // make private if transition complete
1077 // private:
1078
1079 // properties set in determineBndryCandidates
1081
1082 // properties set in computeNodalValues
1084 std::array<std::array<MFloat, noCorners>, maxNoSets> nodalValues = [] {
1085 std::array<std::array<MFloat, noCorners>, maxNoSets> a{};
1086 std::array<MFloat, noCorners> b = make_array<MFloat, noCorners>(-1.0);
1087 a.fill(b);
1088 return a;
1089 }();
1090
1091 std::array<MBool, noCorners> nodeValueSet = make_array<MBool, noCorners>(false);
1092 std::array<MInt, maxNoSets> associatedBodyIds = make_array<MInt, maxNoSets>(-1);
1093
1094 // properties set in computeCutPoints
1096 std::array<std::array<MFloat, nDim>, maxNoCutPoints> cutPoints = [] {
1097 std::array<std::array<MFloat, nDim>, maxNoCutPoints> a{};
1098 std::array<MFloat, nDim> b = make_array<MFloat, nDim>(0.0);
1099 a.fill(b);
1100 return a;
1101 }();
1102 std::array<MInt, noEdges> noCutPointsOnEdge = make_array<MInt, noEdges>(0);
1103 std::array<MInt, maxNoCutPoints> cutBodyIds = make_array<MInt, maxNoCutPoints>(-1);
1104 std::array<MInt, maxNoCutPoints> cutEdges = make_array<MInt, maxNoCutPoints>(-1);
1105 std::array<MBool, noEdges> edgeChecked = make_array<MBool, noEdges>(false);
1106
1107 // properties related to bndryLvlJump
1109};
1110
1111#endif
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
Definition: alloc.h:173
static constexpr MInt maxNoCutPoints
static constexpr MInt noCorners
std::array< MInt, maxNoSets > associatedBodyIds
static constexpr MInt maxNoSets
std::array< MInt, noEdges > noCutPointsOnEdge
std::array< MBool, noCorners > nodeValueSet
std::array< MBool, noEdges > edgeChecked
std::array< std::array< MFloat, noCorners >, maxNoSets > nodalValues
static constexpr MInt noEdges
std::array< std::array< MFloat, nDim >, maxNoCutPoints > cutPoints
std::array< MInt, maxNoCutPoints > cutEdges
std::array< MInt, maxNoCutPoints > cutBodyIds
std::array< MInt, maxNoCutPoints > cutBodyIds
std::array< std::array< MFloat, nDim >, maxNoAdditionalVertices > additionalVertices
std::array< MInt, maxSplitCells > splitChildIds
static constexpr MInt maxNoTotalSurfaces
std::array< MFloat, maxNoCartesianSurfaces > cartFaceArea
std::array< std::array< MBool, no3dFaces >, maxNoSets > faceCentroidIsInsideGeometry
static constexpr MInt maxNoBoundarySurfaces
std::array< std::array< MInt, maxNoFaceVertices >, maxNoTotalSurfaces > allFacesPointIds
std::array< MInt, noFaces > noFacesPerCartesianDir
std::array< MInt, maxNoTotalSurfaces > allFacesNoPoints
static constexpr MInt noFaces
std::array< MInt, maxNoCutPoints > cutEdges
std::array< MInt, maxNoBoundarySurfaces > boundarySurfaceBodyId
std::array< MFloat, nDim > volumetricCentroid
std::array< MBool, noFaces > externalFaces
std::array< MInt, maxNoBoundarySurfaces > boundarySurfaceBndryCndId
static constexpr MInt maxNoSets
static constexpr MInt noCorners
std::array< std::array< MFloat, nDim >, maxNoBoundarySurfaces > boundarySurfaceCentroid
static constexpr MInt maxNoAdditionalVertices
std::array< std::array< MFloat, nDim >, maxNoBoundarySurfaces > boundarySurfaceNormal
static constexpr MInt maxNoFaceVertices
std::array< std::array< MFloat, nDim >, maxNoCartesianSurfaces > cartFaceCentroid
std::array< MInt, maxNoCartesianSurfaces > cartFaceDir
static constexpr MInt no3dFaces
static constexpr MInt maxSplitCells
static constexpr MInt maxNoCartesianSurfaces
std::array< MFloat, maxNoBoundarySurfaces > boundarySurfaceArea
std::array< std::array< MBool, noCorners >, maxNoSets > cornerIsInsideGeometry
static constexpr MInt noEdges
static constexpr MInt maxNoCutPoints
std::array< MInt, maxNoSets > associatedBodyIds
std::array< MInt, maxNoTotalSurfaces > allFacesBodyId
std::array< std::array< MFloat, nDim >, maxNoCutPoints > cutPoints
MBool propertyExists(MString name, MInt solver)
GeometryProperty * getProperty(const MString &name, MInt segment)
GeometryContext & geometryContext()
Definition: geometry.h:48
std::vector< CsgPolygon > intersect(Csg csg)
std::vector< CsgPolygon > toPolygons()
Csg(std::vector< CsgPolygon > _polygons)
std::vector< CsgPolygon > polygons
std::enable_if< nDim_==2, T >::type build(std::vector< CsgPolygon > _polygons)
std::vector< CsgPolygon > allPolygons()
std::vector< CsgPolygon > polygons
CsgNode(std::vector< CsgPolygon > _polygons)
std::vector< CsgPolygon > clipPolygons(std::vector< CsgPolygon > _polygons)
std::enable_if< nDim_==3, T >::type build(std::vector< CsgPolygon > _polygons)
std::enable_if< nDim_==3, T >::type splitPolygon(CsgPolygon *polygon, std::vector< CsgPolygon > *coplanarFront, std::vector< CsgPolygon > *coplanarBack, std::vector< CsgPolygon > *front, std::vector< CsgPolygon > *back)
std::enable_if< nDim_==2, T >::type initPlane(CsgVector abc[nDim]) const
std::enable_if< nDim_==2, T >::type splitPolygon(CsgPolygon *polygon, std::vector< CsgPolygon > *coplanarFront, std::vector< CsgPolygon > *coplanarBack, std::vector< CsgPolygon > *front, std::vector< CsgPolygon > *back)
std::enable_if< nDim_==3, T >::type initPlane(CsgVector abc[nDim]) const
CsgPlane(CsgVector _normal, MFloat _w)
void insertCoplanarPolygon(CsgPolygon *polygon, std::vector< CsgPolygon > *coplanarFront, std::vector< CsgPolygon > *coplanarBack)
CsgPolygon(std::vector< CsgVertex > _vertices, MInt _setIndex, MInt _faceId, MInt _faceType, MInt _bodyId, CsgPlane _plane)
CsgPolygon(std::vector< CsgVertex > _vertices, MInt _setIndex, MInt _faceId, MInt _faceType, MInt _bodyId)
CsgVector(CsgVector &&)=default
CsgVector(const std::array< MFloat, nDim > X)
CsgVector lerp(const CsgVector &a, const MFloat t) const
std::array< MFloat, nDim > xx
CsgVector dividedBy(const MFloat a) const
std::enable_if< nDim_==3, T >::type cross(const CsgVector a) const
CsgVector & operator=(const CsgVector &)=default
CsgVector plus(const CsgVector &a) const
CsgVector minus(const CsgVector &a) const
MFloat dot(const CsgVector &a) const
CsgVector & operator=(CsgVector &&)=default
CsgVector times(const MFloat a) const
CsgVertex(CsgVector _pos, MInt _vertexId, MInt _setIndex)
CsgVertex interpolate(CsgVertex *other, MFloat t) const
std::vector< splitCartesianFace > splitFaces
polyCutCell2D(MInt cartCell, const MFloat *_center)
polyCutCell3D(MInt cartCell, const MFloat *_center)
polyCutCellBase(MInt cartCell, const MFloat *_center)
polyEdge2D(MInt v0, MInt v1, MInt eId, MInt eType, MInt _bodyId)
polyEdge3D(MInt v0, MInt v1, MInt eId, MInt eType)
polyEdgeBase(MInt v0, MInt v1, MInt eId, MInt eType)
std::vector< std::pair< MInt, MInt > > edges
polyFace(MInt fId, MInt fType, MInt _bodyId)
std::list< std::pair< MInt, MInt > > edges
polyVertex(std::array< MFloat, nDim > coords, MInt pId, MInt pType)
std::array< MFloat, nDim > coordinates
std::array< MFloat, nDim > center
std::array< MFloat, nDim > normal
static constexpr MInt m_noCorners
GridProxy *const m_gridProxy
static constexpr MInt m_noEdges
const std::vector< CutCell< nDim > > & cutCellData_()
std::vector< CutCell< nDim > > m_cutCellData
const GridProxy & grid() const
static constexpr MInt nDim
std::enable_if< nDim_==3, T >::type computeNormal(const std::array< MFloat, nDim > p0, const std::array< MFloat, nDim > p1, const std::array< MFloat, nDim > p2, std::array< MFloat, nDim > &res, MFloat &w)
void compVolumeIntegrals_pyraBased3(std::vector< polyCutCell > *, std::vector< polyFace > *, const std::vector< polyVertex > *)
void writeVTKFileOfCell(MInt cellId, std::vector< polyFace > *faces, const std::vector< polyVertex > *vertices, MInt set)
GeometryIntersection(GridProxy *gridProxy_, Geom *geometry_)
MFloat & a_coordinate(const MInt cellId, const MInt dir)
Returns the coordinate of the cell cellId for dimension dir.
void addPoint(const std::vector< polyVertex > *, const MInt *, const MInt, std::array< MFloat, nDim >)
adds an additional MC point in the cell sums up all n points passed in indices. points have to be sto...
std::vector< lvlJumpCandidates< nDim > > m_cutLvlJumpCandidates
void writeInfo(std::vector< CutCell< nDim > > &cutCellData, MUint, MInt)
void computeCutFaces(std::vector< CutCell< nDim > > &cutCellData, const MInt maxNoSurfaces, const MInt tCutGroup)
GeometryContext & geometryContext()
const Geom & geometry() const
std::vector< CutCandidate< nDim > > m_cutCandidates
void exchangeNodalValues(const MInt **maxLevelWindowCells, const MInt *noMaxLevelWindowCells, const MInt **maxLevelHaloCells, std::vector< CutCandidate< nDim > > &candidates, MInt *candidateIds)
halo cell - window cell exchange of nodal scalar field data
void crossProduct(MFloat *c, const MFloat *a, const MFloat *b)
void fillCutCellData(std::vector< CutCandidate< nDim > > &candidates, std::vector< CutCell< nDim > > &cutCellData, std::vector< MInt > cutCellIdMapping)
typename maia::grid::Proxy< nDim > GridProxy
void getNeighborNodes(const MInt, const MInt, MInt, MInt *, MInt *)
gets all neighbor cellIds and matching nodes for a given cell and node
MFloat a_gridCellVolume(const MInt cellId) const
Returns the volume of the cell cellId.
static constexpr MInt m_noDirs
void computeNodalValues(std::vector< CutCandidate< nDim > > &candidates, MInt *candidateIds, const MFloat *scalarField, const MInt *bodyIdField, const MBool *const gapPropertyField, const MBool gapClosure)
1) add cutCandidates based on the solver m_bndryCandidates 2) set cutCandidate information 3) set the...
const std::vector< CutCandidate< nDim > > & cutCandidates_()
void compFaceIntegrals_pyraBased3(polyFace *face, const std::vector< polyVertex > *vertices, MFloat *MC, MFloat *VC, MFloat *XC)
void correctNodalValuesAtLevelJump(std::vector< CutCandidate< nDim > > &candidates, const MInt *)
corrects the nodal values at bndry level jumps for ls-based geometries
std::enable_if< nDim_==2, T >::type computeNormal(const std::array< MFloat, nDim > p0, const std::array< MFloat, nDim > p1, std::array< MFloat, nDim > res, MFloat &w)
returns the normal corresponding to the triangle abc and returns the result in res
std::conditional< nDim_==3, polyEdge3D, polyEdge2D >::type polyEdge
std::conditional< nDim_==3, polyCutCell3D, polyCutCell2D >::type polyCutCell
void computeCutPointsFromSTL(std::vector< CutCandidate< nDim > > &candidates)
computes cut points where candidate intersects with the geometry note: can not handle bndryRefinement...
MFloat a_cellLengthAtCell(const MInt cellId) const
Returns the cellLength of the cell cellId.
void computeCutPoints(std::vector< CutCandidate< nDim > > &candidates, const MInt *candidateIds, std::vector< MInt > &candidatesOrder)
Computes cutpoints for the scalar-Field with grid edges and updates cutPoint-Info in the cutCandidate...
static constexpr MInt m_maxNoChilds
MBool computeCutFaceSimple(CutCell< nDim > &cutCell)
std::array< MInt, maxNoJumps > neighborType
static constexpr MInt maxNoJumps
std::array< MInt, maxNoJumps > diagonalDirs
std::array< MInt, maxNoJumps > dirs
constexpr std::array< T, n > make_array(const T v)
constexpr MLong IPOW2(MInt x)
int32_t MInt
Definition: maiatypes.h:62
uint32_t MUint
Definition: maiatypes.h:63
std::basic_string< char > MString
Definition: maiatypes.h:55
double MFloat
Definition: maiatypes.h:52
bool MBool
Definition: maiatypes.h:58
MInt id
Definition: maiatypes.h:71
int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Allreduce
Definition: contexttypes.h:19