MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
GeometryRoot Class Reference

#include <geometryroot.h>

Inheritance diagram for GeometryRoot:
[legend]
Collaboration diagram for GeometryRoot:
[legend]

Public Member Functions

 GeometryRoot ()
 
 GeometryRoot (const MInt noSolvers, const MInt nDim_, const MPI_Comm comm)
 
template<MInt nDim>
void initGeometry (const MInt noSolvers)
 
MBool isPointInside (const MFloat *const point)
 
MBool isPointInsideNode (const MFloat *const point, const MInt node)
 
MBool getCellIntersectingSurfaces (const MFloat *const coords, const MFloat cellHalfLength, MBool *const *const cutInfo)
 
MBool getCellIntersectingSurfacesOfNode (const MFloat *const coords, const MFloat cellHalfLength, MBool *const cutInfo, const MInt node)
 
void boundingBox (MFloat *const bBox)
 
void boundingBoxOfNode (MFloat *const bBox, const MInt node)
 
MInt noSegmentsOfNode (const MInt node)
 
MInt noNodes ()
 
MInt nodeSurfaceType (const MInt node)
 
template<MInt nDim>
void setGeometryPointerToNode (Geometry< nDim > *&geometryPointer, const MInt node)
 
- Public Member Functions inherited from GeometryBase
 GeometryBase ()
 
 GeometryBase (const MPI_Comm comm)
 
virtual MBool isPointInside (const MFloat *const)
 
virtual MBool isPointInsideNode (const MFloat *const, const MInt)
 
virtual MBool getCellIntersectingSurfaces (const MFloat *const, const MFloat, MBool *const *const)
 
virtual MBool getCellIntersectingSurfacesOfNode (const MFloat *const, const MFloat, MBool *const, const MInt)
 

Private Attributes

MInt m_nDim
 
MInt m_noSolverSurfaces
 
MIntm_solverSurfaceType = nullptr
 
SolverSurface ** m_solverSurface
 

Additional Inherited Members

- Public Attributes inherited from GeometryBase
GeometryDistribution m_distribution
 
MPI_Comm m_mpiComm
 

Detailed Description

Definition at line 125 of file geometryroot.h.

Constructor & Destructor Documentation

◆ GeometryRoot() [1/2]

GeometryRoot::GeometryRoot ( )
inline

Definition at line 127 of file geometryroot.h.

127{};

◆ GeometryRoot() [2/2]

GeometryRoot::GeometryRoot ( const MInt  noSolvers,
const MInt  nDim_,
const MPI_Comm  comm 
)

Definition at line 205 of file geometryroot.cpp.

206 : GeometryBase(comm), m_nDim(nDim_) {
207 if(nDim_ == 2)
208 initGeometry<2>(noSolvers);
209 else
210 initGeometry<3>(noSolvers);
211}
MInt noSolvers
Definition: maiatypes.h:73

Member Function Documentation

◆ boundingBox()

void GeometryRoot::boundingBox ( MFloat *const  bBox)

Definition at line 278 of file geometryroot.cpp.

278 {
279 // init temporary bounding box
280 MFloat tmpBB[6];
281 // init bounding box
282 for(MInt dim = 0; dim < m_nDim; dim++) {
283 bBox[dim] = numeric_limits<MFloat>::max();
284 bBox[dim + m_nDim] = numeric_limits<MFloat>::lowest();
285 }
286 // check all surfaces for their extend
287 for(MInt i = 0; i < m_noSolverSurfaces; i++) {
288 // init temporary bounding box
289 for(MInt dim = 0; dim < m_nDim; dim++) {
290 tmpBB[dim] = numeric_limits<MFloat>::max();
291 tmpBB[dim + m_nDim] = numeric_limits<MFloat>::lowest();
292 }
293 // get bounding box of surface
294 m_solverSurface[i]->boundingBox(tmpBB);
295 // get extrem values
296 for(MInt dim = 0; dim < m_nDim; dim++) {
297 bBox[dim] = mMin(bBox[dim], tmpBB[dim]);
298 bBox[dim + m_nDim] = mMax(bBox[dim + m_nDim], tmpBB[dim + m_nDim]);
299 }
300 }
301}
SolverSurface ** m_solverSurface
Definition: geometryroot.h:155
MInt m_noSolverSurfaces
Definition: geometryroot.h:153
virtual void boundingBox(MFloat *const)
Definition: geometryroot.h:30
constexpr T mMin(const T &x, const T &y)
Definition: functions.h:90
constexpr T mMax(const T &x, const T &y)
Definition: functions.h:94
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52

◆ boundingBoxOfNode()

void GeometryRoot::boundingBoxOfNode ( MFloat *const  bBox,
const MInt  node 
)

Definition at line 303 of file geometryroot.cpp.

303 {
304 // init temporary bounding box
305 MFloat tmpBB[6];
306 // init bounding box
307 for(MInt dim = 0; dim < m_nDim; dim++) {
308 bBox[dim] = numeric_limits<MFloat>::max();
309 bBox[dim + m_nDim] = numeric_limits<MFloat>::lowest();
310 }
311 // check all surfaces for their extend
312 for(MInt i = 0; i < m_distribution.noSurfacesPerNode[node]; i++) {
313 const MInt srfcId = m_distribution.nodeSurfaceIds[node][i];
314 // init temporary bounding box
315 for(MInt dim = 0; dim < m_nDim; dim++) {
316 tmpBB[dim] = numeric_limits<MFloat>::max();
317 tmpBB[dim + m_nDim] = numeric_limits<MFloat>::lowest();
318 }
319 // get bounding box of surface
320 m_solverSurface[srfcId]->boundingBox(tmpBB);
321 // get extrem values
322 for(MInt dim = 0; dim < m_nDim; dim++) {
323 bBox[dim] = mMin(bBox[dim], tmpBB[dim]);
324 bBox[dim + m_nDim] = mMax(bBox[dim + m_nDim], tmpBB[dim + m_nDim]);
325 }
326 }
327}
GeometryDistribution m_distribution
Definition: geometryroot.h:119

◆ getCellIntersectingSurfaces()

MBool GeometryRoot::getCellIntersectingSurfaces ( const MFloat *const  coords,
const MFloat  cellHalfLength,
MBool *const *const  cutInfo 
)
virtual

Reimplemented from GeometryBase.

Definition at line 367 of file geometryroot.cpp.

368 {
369 MBool retVal = false;
370 for(MInt node = 0; node < m_distribution.noNodes; node++) {
371 const MBool newCut = getCellIntersectingSurfacesOfNode(coords, cellHalfLength, cutInfo[node], node);
372 retVal = retVal || newCut;
373 }
374
375 return retVal;
376}
MBool getCellIntersectingSurfacesOfNode(const MFloat *const coords, const MFloat cellHalfLength, MBool *const cutInfo, const MInt node)
bool MBool
Definition: maiatypes.h:58

◆ getCellIntersectingSurfacesOfNode()

MBool GeometryRoot::getCellIntersectingSurfacesOfNode ( const MFloat *const  coords,
const MFloat  cellHalfLength,
MBool *const  cutInfo,
const MInt  node 
)
virtual

Reimplemented from GeometryBase.

Definition at line 378 of file geometryroot.cpp.

379 {
380 MBool retVal = false;
381 for(MInt i = 0; i < m_distribution.noSurfacesPerNode[node]; i++) {
382 const MInt srfcId = m_distribution.nodeSurfaceIds[node][i];
383 const MInt cutOffset = 0; // needs to be set for the m_solverSurface to know where to set intersections
384 // but this depends on the concept: How many elements, i.e., different STL surfaces,
385 // can an adt contain?
386 retVal =
387 retVal || m_solverSurface[srfcId]->getCellIntersectingElements(coords, cellHalfLength, cutInfo + cutOffset);
388 }
389
390 return retVal;
391}
virtual MBool getCellIntersectingElements(const MFloat *const, const MFloat, MBool *const)
Definition: geometryroot.h:21

◆ initGeometry()

template<MInt nDim>
template void GeometryRoot::initGeometry< 3 > ( const MInt  noSolvers)

Definition at line 214 of file geometryroot.cpp.

214 {
215 // how are the surfaces distributed among the nodes
216 // right now, every node has one surface
218 mAlloc(m_distribution.noSurfacesPerNode, m_distribution.noNodes, AT_, 1, "noSurfacesPerSolver");
220 "noSurfacesPerNode");
222 for(MInt node = 0; node < m_distribution.noNodes; node++) {
223 for(MInt srfc = 0; srfc < m_distribution.noSurfacesPerNode[node]; srfc++) {
224 m_distribution.nodeSurfaceIds[node][srfc] = node;
226 }
227 }
228
229 // what kind of geometry/surface to expect
230 mAlloc(m_solverSurfaceType, m_noSolverSurfaces, AT_, 0, "solverSurfaceType");
231 for(MInt node = 0; node < m_distribution.noNodes; node++) {
232 for(MInt srfc = 0; srfc < m_distribution.noSurfacesPerNode[node]; srfc++) {
233 const MInt srfcId = m_distribution.nodeSurfaceIds[node][srfc];
234 MString surfaceType = "STL";
235 surfaceType = Context::getSolverProperty<MString>("solverSurfaceType", node, AT_, &surfaceType, srfc);
236 m_solverSurfaceType[srfcId] = string2enum(surfaceType);
237 }
238 }
239
240 // init
242 for(MInt i = 0; i < m_noSolverSurfaces; i++) {
243 switch(m_solverSurfaceType[i]) {
244 case STL: {
246 break;
247 }
248 case ANALYTIC_BOX: {
249 // here we hardcode the box, just a usefull example
250 MFloat bbox[2 * nDim];
251 for(MInt dir = 0; dir < 2 * nDim; dir++) {
252 bbox[dir] = Context::getSolverProperty<MFloat>("analyticSolverBoundingBox", i, AT_, dir);
253 }
255 break;
256 }
257 case ANALYTIC_SPHERE: {
258 // here we hardcode the sphere, just a usefull example
259 MFloat center[nDim];
260 for(MInt dir = 0; dir < nDim; dir++) {
261 center[dir] = Context::getSolverProperty<MFloat>("analyticSolverBoundingSphere", i, AT_, dir);
262 }
263 const MFloat radius = Context::getSolverProperty<MFloat>("analyticSolverBoundingSphere", i, AT_, nDim);
264 m_solverSurface[i] = new SolverAnalyticSphereSurface<nDim>(center, radius);
265 break;
266 }
267 default: {
268 mTerm(1, AT_, "unknown surface type");
269 }
270 }
271 }
272}
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
MPI_Comm m_mpiComm
Definition: geometryroot.h:122
MInt * m_solverSurfaceType
Definition: geometryroot.h:154
MInt string2enum(MString theString)
This global function translates strings in their corresponding enum values (integer values)....
Definition: enums.cpp:20
@ STL
Definition: enums.h:365
@ ANALYTIC_BOX
Definition: enums.h:365
@ ANALYTIC_SPHERE
Definition: enums.h:365
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29
std::basic_string< char > MString
Definition: maiatypes.h:55

◆ isPointInside()

MBool GeometryRoot::isPointInside ( const MFloat *const  point)
virtual

Reimplemented from GeometryBase.

Definition at line 329 of file geometryroot.cpp.

329 {
330 for(MInt node = 0; node < m_distribution.noNodes; node++) {
331 if(isPointInsideNode(point, node)) {
332 return true;
333 }
334 }
335 return false;
336}
MBool isPointInsideNode(const MFloat *const point, const MInt node)

◆ isPointInsideNode()

MBool GeometryRoot::isPointInsideNode ( const MFloat *const  point,
const MInt  node 
)
virtual

Reimplemented from GeometryBase.

Definition at line 338 of file geometryroot.cpp.

338 {
339 MFloat bbox[2 * MAX_SPACE_DIMENSIONS];
340 MFloat line[2 * MAX_SPACE_DIMENSIONS];
341 MFloat bbExtend[MAX_SPACE_DIMENSIONS];
342
343 boundingBoxOfNode(bbox, node);
344
345 for(MInt dim = 0; dim < m_nDim; dim++) {
346 line[dim] = point[dim];
347 bbExtend[dim] = bbox[dim + m_nDim] - bbox[dim];
348 }
349
350 MBool retVal = true;
351 for(MInt rayDim = 0; rayDim < m_nDim; rayDim++) { // why in all dimensions?
352 for(MInt dim = 0; dim < m_nDim; dim++) {
353 line[dim + m_nDim] = point[dim];
354 }
355 line[rayDim + m_nDim] += 2 * bbExtend[rayDim];
356 MInt noIntersec = 0;
357 for(MInt i = 0; i < m_distribution.noSurfacesPerNode[node]; i++) {
358 MInt srfcId = m_distribution.nodeSurfaceIds[node][i];
359 noIntersec += m_solverSurface[srfcId]->countLineIntersectingElements(line);
360 }
361 retVal = retVal && ((noIntersec % 2) == 1);
362 if(!retVal) return false;
363 }
364 return true;
365}
void boundingBoxOfNode(MFloat *const bBox, const MInt node)
virtual MInt countLineIntersectingElements(const MFloat *const)
Definition: geometryroot.h:26

◆ nodeSurfaceType()

MInt GeometryRoot::nodeSurfaceType ( const MInt  node)
inline

Definition at line 144 of file geometryroot.h.

144{ return m_solverSurfaceType[node]; };

◆ noNodes()

MInt GeometryRoot::noNodes ( )
inline

Definition at line 143 of file geometryroot.h.

143{ return m_distribution.noNodes; };

◆ noSegmentsOfNode()

MInt GeometryRoot::noSegmentsOfNode ( const MInt  node)

Definition at line 274 of file geometryroot.cpp.

274 {
275 return m_solverSurface[node]->noSegments(); // temporary since there wil be several surfaces per node
276}
virtual MInt noSegments()
Definition: geometryroot.h:31

◆ setGeometryPointerToNode()

template<MInt nDim>
template void GeometryRoot::setGeometryPointerToNode< 3 > ( Geometry< nDim > *&  geometryPointer,
const MInt  node 
)

Definition at line 394 of file geometryroot.cpp.

394 {
395 m_solverSurface[node]->setGeometryPointer(geometryPointer);
396}
virtual void setGeometryPointer(Geometry< 2 > *&)
Definition: geometryroot.h:37

Member Data Documentation

◆ m_nDim

MInt GeometryRoot::m_nDim
private

Definition at line 151 of file geometryroot.h.

◆ m_noSolverSurfaces

MInt GeometryRoot::m_noSolverSurfaces
private

Definition at line 153 of file geometryroot.h.

◆ m_solverSurface

SolverSurface** GeometryRoot::m_solverSurface
private

Definition at line 155 of file geometryroot.h.

◆ m_solverSurfaceType

MInt* GeometryRoot::m_solverSurfaceType = nullptr
private

Definition at line 154 of file geometryroot.h.


The documentation for this class was generated from the following files: