MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
geometry.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 GEOMETRY_H
8#define GEOMETRY_H
9
10#include <array>
11#include <set>
12#include <vector>
13#include "COMM/mpioverride.h"
15#include "geometrycontext.h"
17
18template <MInt nDim>
19class GeometryAdt;
20template <MInt nDim>
21class GeometryElement;
22template <class T>
23class Collector;
24
25// Auxiliary type traits to support selecting the correct geometry class, instantiated in
26// geometry2/3d.h
27template <MInt nDim>
28struct GeometryXD {};
29
30template <MInt nDim>
35template <MInt nDim>
36class Geometry {
37 public:
38 template <MInt nDim_>
39 friend class GeometryAdt;
40 Geometry(const MInt solverId_, const MPI_Comm comm);
41
42 virtual ~Geometry() = default;
43
44 MInt solverId() const { return m_solverId; }
45 MPI_Comm mpiComm() const { return m_mpiComm; }
46 MInt domainId() const { return m_domainId; }
47 MInt noDomains() const { return m_noDomains; }
49 void getBoundingBox(MFloat* const bBox) const;
50 const MFloat* boundingBox() const { return &m_minMax[0]; }
53 MBool isOnGeometry(const MFloat, const MFloat*, MString);
54
55 // for all dimensions
57 MFloat calcCircumference(MFloat** bndVs, MInt num);
58
59 virtual MInt boundaryCheck(MFloat* /*targetRegion*/, MFloat /*cellHalfLength*/, MFloat* /*cell_coords*/,
60 MInt* /*bndIds*/) {
61 return false;
62 };
63 virtual MInt getIntersectionElements(MFloat* /*targetRegion*/, std::vector<MInt>& /*nodeList*/) { return 0; };
64 virtual MInt getIntersectionElements(MFloat* /*targetRegion*/, std::vector<MInt>& /*nodeList*/,
65 MFloat /*cellHalfLength*/, const MFloat* const /*cell_coords*/) {
66 return 0;
67 };
68 virtual MInt getLineIntersectionElementsOld1(MFloat* /*targetRegion*/, std::vector<MInt>& /*nodeList*/) { return 0; };
69 virtual MInt getLineIntersectionElementsOld2(MFloat* /*targetRegion*/, MInt* /*spaceDirection*/,
70 std::vector<MInt>& /*nodeList*/) {
71 return 0;
72 };
73 virtual MInt getLineIntersectionElements(MFloat* /*targetRegion*/, std::vector<MInt>& /*nodeList*/) { return 0; };
74 virtual MInt getLineIntersectionElements(MFloat* /*targetRegion*/) { return 0; };
75 virtual MBool getClosestLineIntersectionLength(MInt /*bndCndId*/, const std::vector<MInt>& /*nodeList*/,
76 MFloat* /*targetRegion*/, MFloat* /*dist*/) {
77 return false;
78 };
79
80 void getLineIntersectingElementsBcIds(const MFloat* const line, std::set<MInt>& bcIds);
81
82 virtual MBool edgeTriangleIntersection(MFloat* /*trianglePoint1*/,
83 MFloat* /*trianglePoint2*/,
84 MFloat* /*trianglePoint3*/,
85 MFloat* /*edgePoint1*/,
86 MFloat* /*edgePoint2*/) {
87 return 0;
88 };
89 virtual MBool edgeTriangleIntersectionLB(MFloat* /*trianglePoint1*/,
90 MFloat* /*trianglePoint2*/,
91 MFloat* /*trianglePoint3*/,
92 MFloat* /*edgePoint1*/,
93 MFloat* /*edgePoint2*/) {
94 return 0;
95 };
96
97 virtual MBool getLineTriangleIntersectionSimple(MFloat* /*p1*/, MFloat* /*p2*/, MFloat* /*v1*/, MFloat* /*v2*/,
98 MFloat* /*v3*/) {
99 return false;
100 };
102 MFloat* /*v2*/, MFloat* /*v3*/, MFloat* /*dist*/) {
103 return false;
104 };
105 virtual MBool getLineTriangleIntersection(const MFloat* const /*p1*/,
106 const MFloat* const /*p2*/,
107 const MFloat /*radius*/,
108 const MFloat* const /*v1*/,
109 const MFloat* const /*v2*/,
110 const MFloat* const /*v3*/,
111 MFloat* /*intersection*/,
112 MFloat* /*normal*/,
113 MFloat* /*lambda2*/,
114 MFloat* /*dist*/) {
115 return false;
116 };
117 // moving boundary
118 void getBoundingBoxMB(MFloat* const bBox) const;
119 virtual MInt getIntersectionMBElements(MFloat* /*targetRegion*/, std::vector<MInt>& /*nodeList*/) { return 0; }
120 virtual MInt getLineIntersectionMBElements(MFloat* /*targetRegion*/, std::vector<MInt>& /*nodeList*/) { return 0; }
121 virtual MInt getLineIntersectionMBElements2(MFloat* /*targetRegion*/, MInt* /*spaceDirection*/,
122 std::vector<MInt>& /*nodeList*/, MInt /*bcId*/) {
123 return 0;
124 }
125 virtual MInt getSphereIntersectionMBElements(MFloat* /* P*/, MFloat /*radius*/, std::vector<MInt>& /*nodeList*/) {
126 return 0;
127 };
128 virtual void MoveAllMBElementVertex(MFloat* /*dx*/){};
129 virtual void MoveMBElementVertex(MInt /*e*/, MInt /*v*/, MFloat* /*dx*/){};
130 virtual void ReplaceMBElementVertex(MInt /*e*/, MInt /*v*/, MFloat* /*np*/){};
131 virtual void UpdateMBNormalVector(MInt /*e*/){};
132 virtual void UpdateMBBoundingBox(){};
133 virtual void UpdateADT(){};
134 virtual void collectGlobalMemoryUsage(){};
135
136
137 virtual void writeSTL(const MChar* /*fileName*/){};
138 virtual void writeADTAndSTLToNetCDF(const MChar* /*fileName*/){};
139 virtual void writeSTLMB(const MChar* /*fileName*/, MInt& /*noNodes*/, MInt*& /*nodeList*/){};
140 virtual void readSTLNetCDF(const MChar* /*fileName*/){};
141
142 virtual void logStatistics(){};
143
144 virtual MInt GetNoElements() { return m_noElements; };
145 virtual MInt GetNoSegments() { return m_noSegments; };
146 virtual MInt* GetBoundaryIds(MInt* noAllBcs) {
147 *noAllBcs = m_noAllBCs;
148 return m_allBCs;
149 };
150
151 virtual MFloat** GetBoundaryVertices(MInt /*segmentId*/, MFloat* /*tri_vx*/, MInt* /*keepOffsets*/, MInt /*size*/,
152 MInt* /*num*/) {
153 return nullptr;
154 };
155 virtual inline MBool isEdgeAlreadyInCollection(std::vector<std::pair<MFloat*, MFloat*>> /*tmp_edges*/, MFloat* /*p1*/,
156 MFloat* /*p2*/, MInt* /*pos*/) {
157 return false;
158 };
159 virtual MFloat GetBoundarySize(MInt /*segmentId*/) { return F0; };
160 virtual MFloat GetBoundarySize(MFloat* /*vertices*/, MInt* /*keepOffset*/, MInt /*size*/) { return F0; };
161 virtual void determineSegmentOwnership(MInt /*segmentId*/, MInt* /*own*/, MInt* /*sumowners*/, MInt* /*firstOwner*/,
162 MInt* /*owners*/){};
163 virtual MFloat getBndMaxRadius(MFloat** /*vertices*/, MInt /*num*/) { return F0; };
164
165 virtual void rebuildAdtTree(){};
166 virtual void calculateBoundingBox(){};
167 virtual void writeParallelGeometryVTK(MString /*filename*/){};
168 virtual void addElement(MFloat* /*tri*/){};
169 virtual void copyElement(MInt /*from*/, MInt /*to*/){};
170 virtual void resizeCollector(MInt /*new_size*/){};
171
172 // Methods migrated from CartesianGrid
173 MBool pointIsInside(const MFloat* const coordinates);
174 MBool pointIsInside(const MFloat* const coordinates, MInt* numcutsperdir);
175 MBool pointIsInside2(const MFloat* const coordinates, MInt* numcutsperdir = nullptr);
176 MBool pointIsInsideMBElements(const MFloat* const coordinates, MInt*, MInt*, MInt);
177 MBool pointIsInsideMBElements2(const MFloat* const coordinates, MInt*, MInt*, MInt);
178 void determineRayIntersectedElements(const MFloat* const coordinates, std::vector<std::vector<MInt>>* resultnodes);
179
180 protected:
181 virtual void readSegments(){};
182 virtual void writeSegmentsToDX();
183
184 protected:
186
187 std::array<MFloat, 2 * nDim> m_minMax{};
188
190
194
198 MInt* m_allBCs = nullptr;
200
202
203 private:
205 const MPI_Comm m_mpiComm;
210
211 public:
212 std::vector<MInt> m_segmentOffsets;
213 std::vector<MInt> m_segmentOffsetsWithoutMB;
219 std::array<MFloat, 2 * nDim> m_mbminMax{};
223 std::set<MInt> m_uniqueOriginalTriId;
226
227 // Parallel geometry
231};
232
233
234#endif
MInt m_haloElementOffset
Definition: geometry.h:209
virtual MBool getLineTriangleIntersectionSimpleDistance(MFloat *, MFloat *, MFloat *, MFloat *, MFloat *, MFloat *)
Definition: geometry.h:101
MBool isOnGeometry(const MFloat, const MFloat *, MString)
Definition: geometry.cpp:748
virtual void ReplaceMBElementVertex(MInt, MInt, MFloat *)
Definition: geometry.h:130
virtual MInt getLineIntersectionElementsOld2(MFloat *, MInt *, std::vector< MInt > &)
Definition: geometry.h:69
MInt m_noBoundaryIds
Definition: geometry.h:196
virtual void writeSTL(const MChar *)
Definition: geometry.h:137
virtual MInt * GetBoundaryIds(MInt *noAllBcs)
Definition: geometry.h:146
virtual ~Geometry()=default
MInt noDomains() const
Definition: geometry.h:47
const MFloat * boundingBox() const
Definition: geometry.h:50
virtual MBool getClosestLineIntersectionLength(MInt, const std::vector< MInt > &, MFloat *, MFloat *)
Definition: geometry.h:75
GeometryContext m_geometryContext
Definition: geometry.h:208
virtual MInt getSphereIntersectionMBElements(MFloat *, MFloat, std::vector< MInt > &)
Definition: geometry.h:125
void getBoundingBox(MFloat *const bBox) const
Returns the bounding box for the geometry.
Definition: geometry.cpp:84
MFloat calcCircumference(MFloat **bndVs, MInt num)
Returns the circumference of a segment.
Definition: geometry.cpp:133
virtual MInt getIntersectionMBElements(MFloat *, std::vector< MInt > &)
Definition: geometry.h:119
MString m_inOutTest
Definition: geometry.h:225
virtual void collectGlobalMemoryUsage()
Definition: geometry.h:134
MBool * m_ownSegmentId
Definition: geometry.h:222
virtual MFloat GetBoundarySize(MInt)
Definition: geometry.h:159
MBool pointIsInsideMBElements2(const MFloat *const coordinates, MInt *, MInt *, MInt)
Definition: geometry.cpp:442
virtual MInt GetNoSegments()
Definition: geometry.h:145
virtual MBool edgeTriangleIntersection(MFloat *, MFloat *, MFloat *, MFloat *, MFloat *)
Definition: geometry.h:82
MInt solverId() const
Definition: geometry.h:44
MInt m_noAllBCs
Definition: geometry.h:199
MBool pointIsInsideMBElements(const MFloat *const coordinates, MInt *, MInt *, MInt)
Definition: geometry.cpp:326
virtual MInt boundaryCheck(MFloat *, MFloat, MFloat *, MInt *)
Definition: geometry.h:59
MBool m_flowSolver
Definition: geometry.h:201
MString m_parallelGeomFileName
Definition: geometry.h:230
virtual MInt getLineIntersectionElementsOld1(MFloat *, std::vector< MInt > &)
Definition: geometry.h:68
void getLineIntersectingElementsBcIds(const MFloat *const line, std::set< MInt > &bcIds)
Return the set of boundary condition ids of the elements cut by the given line.
Definition: geometry.cpp:733
virtual MInt getLineIntersectionMBElements2(MFloat *, MInt *, std::vector< MInt > &, MInt)
Definition: geometry.h:121
MInt m_domainId
Definition: geometry.h:206
std::array< MFloat, 2 *nDim > m_minMax
Definition: geometry.h:187
std::vector< MInt > m_segmentOffsets
Definition: geometry.h:212
virtual void UpdateMBNormalVector(MInt)
Definition: geometry.h:131
MInt m_noSegments
Definition: geometry.h:185
bodyMap m_bodyMap
Definition: geometry.h:192
MInt * m_boundaryIds
Definition: geometry.h:197
const MPI_Comm m_mpiComm
Definition: geometry.h:205
virtual void MoveMBElementVertex(MInt, MInt, MFloat *)
Definition: geometry.h:129
virtual MFloat getBndMaxRadius(MFloat **, MInt)
Definition: geometry.h:163
virtual void writeParallelGeometryVTK(MString)
Definition: geometry.h:167
virtual void readSegments()
Definition: geometry.h:181
Collector< element< nDim > > * m_elements
Definition: geometry.h:214
MPI_Comm mpiComm() const
Definition: geometry.h:45
MFloat m_parGeomMemFactor
Definition: geometry.h:224
virtual MBool getLineTriangleIntersection(const MFloat *const, const MFloat *const, const MFloat, const MFloat *const, const MFloat *const, const MFloat *const, MFloat *, MFloat *, MFloat *, MFloat *)
Definition: geometry.h:105
virtual MBool getLineTriangleIntersectionSimple(MFloat *, MFloat *, MFloat *, MFloat *, MFloat *)
Definition: geometry.h:97
MInt m_noDomains
Definition: geometry.h:207
virtual MInt getLineIntersectionElements(MFloat *, std::vector< MInt > &)
Definition: geometry.h:73
virtual void addElement(MFloat *)
Definition: geometry.h:168
MFloat m_mbMidPnt[3]
Definition: geometry.h:220
virtual void resizeCollector(MInt)
Definition: geometry.h:170
virtual void writeSegmentsToDX()
Definition: geometry.cpp:99
MBool pointIsInside2(const MFloat *const coordinates, MInt *numcutsperdir=nullptr)
Determines if a point is in or outside the geometry.
Definition: geometry.cpp:213
element< nDim > * elements
Definition: geometry.h:215
element< nDim > * mbelements
Definition: geometry.h:218
virtual void copyElement(MInt, MInt)
Definition: geometry.h:169
virtual MInt getLineIntersectionElements(MFloat *)
Definition: geometry.h:74
MString m_segmentBaseName
Definition: geometry.h:191
std::vector< MInt > m_segmentOffsetsWithoutMB
Definition: geometry.h:213
virtual void calculateBoundingBox()
Definition: geometry.h:166
MInt m_noMBElements
Definition: geometry.h:195
void getBoundingBoxMB(MFloat *const bBox) const
Definition: geometry.cpp:92
virtual void logStatistics()
Definition: geometry.h:142
Geometry(const MInt solverId_, const MPI_Comm comm)
void determineRayIntersectedElements(const MFloat *const coordinates, std::vector< std::vector< MInt > > *resultnodes)
returns the geometry elements that have a cut with rays originating in the provided coordinates
Definition: geometry.cpp:696
virtual void UpdateADT()
Definition: geometry.h:133
virtual MInt getIntersectionElements(MFloat *, std::vector< MInt > &)
Definition: geometry.h:63
const MInt m_solverId
Definition: geometry.h:204
virtual MBool isEdgeAlreadyInCollection(std::vector< std::pair< MFloat *, MFloat * > >, MFloat *, MFloat *, MInt *)
Definition: geometry.h:155
MInt domainId() const
Definition: geometry.h:46
void setHaloElementOffset(MInt off)
Definition: geometry.h:51
MInt * m_allBCs
Definition: geometry.h:198
bodyIterator m_bodyIt
Definition: geometry.h:193
MBool vectorsEqual(MFloat *a, MFloat *b)
Compares two vectors entry by entry.
Definition: geometry.cpp:114
virtual MInt GetNoElements()
Definition: geometry.h:144
virtual MFloat GetBoundarySize(MFloat *, MInt *, MInt)
Definition: geometry.h:160
virtual void readSTLNetCDF(const MChar *)
Definition: geometry.h:140
GeometryContext & geometryContext()
Definition: geometry.h:48
virtual MBool edgeTriangleIntersectionLB(MFloat *, MFloat *, MFloat *, MFloat *, MFloat *)
Definition: geometry.h:89
virtual MFloat ** GetBoundaryVertices(MInt, MFloat *, MInt *, MInt, MInt *)
Definition: geometry.h:151
virtual void writeSTLMB(const MChar *, MInt &, MInt *&)
Definition: geometry.h:139
MInt m_noElements
Definition: geometry.h:189
std::set< MInt > m_uniqueOriginalTriId
Definition: geometry.h:223
Collector< element< nDim > > * m_mbelements
Definition: geometry.h:217
MBool pointIsInside(const MFloat *const coordinates)
Determines if a point is inside of the geometry.
Definition: geometry.cpp:158
std::array< MFloat, 2 *nDim > m_mbminMax
Definition: geometry.h:219
MInt noBoundaryIds()
Definition: geometry.h:221
virtual MInt getIntersectionElements(MFloat *, std::vector< MInt > &, MFloat, const MFloat *const)
Definition: geometry.h:64
virtual void writeADTAndSTLToNetCDF(const MChar *)
Definition: geometry.h:138
virtual void rebuildAdtTree()
Definition: geometry.h:165
virtual void determineSegmentOwnership(MInt, MInt *, MInt *, MInt *, MInt *)
Definition: geometry.h:161
virtual MInt getLineIntersectionMBElements(MFloat *, std::vector< MInt > &)
Definition: geometry.h:120
GeometryAdt< nDim > * m_adt
Definition: geometry.h:216
virtual void UpdateMBBoundingBox()
Definition: geometry.h:132
MBool m_parallelGeometry
Definition: geometry.h:228
MBool m_debugParGeom
Definition: geometry.h:229
virtual void MoveAllMBElementVertex(MFloat *)
Definition: geometry.h:128
MInt getHaloElementOffset() const
Definition: geometry.h:52
std::map< MString, Body * > bodyMap
bodyMap::const_iterator bodyIterator
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55
double MFloat
Definition: maiatypes.h:52
bool MBool
Definition: maiatypes.h:58
char MChar
Definition: maiatypes.h:56
Definition: contexttypes.h:19