MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
geometry3d.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 GEOMETRY3D_H
8#define GEOMETRY3D_H
9
10#include "geometry.h"
11
15class Geometry3D : public Geometry<3> {
16 public:
17 Geometry3D(const MInt solverId_, const MPI_Comm comm);
18 Geometry3D(const MInt solverId_, const MString& filename, const MPI_Comm comm);
20 MInt getIntersectionElements(MFloat* targetRegion, std::vector<MInt>& nodeList, MFloat cellHalfLength,
21 const MFloat* const cell_coords) override;
22 MInt getIntersectionElements(MFloat* targetRegion, std::vector<MInt>& nodeList) override;
23 virtual MInt getIntersectionElementsTetraeder(MFloat* targetRegion, std::vector<MInt>& nodeList);
24 MInt getLineIntersectionElementsOld2(MFloat* targetRegion, MInt* spaceDirection,
25 std::vector<MInt>& nodeList) override;
26 MInt getLineIntersectionElements(MFloat* targetRegion, std::vector<MInt>& nodeList) override;
27 MInt getLineIntersectionElements(MFloat* targetRegion) override;
28 MBool getClosestLineIntersectionLength(MInt bndCndId, const std::vector<MInt>& nodeList, MFloat* targetRegion,
29 MFloat* dist) override;
30
32 MFloat* trianglePoint2,
33 MFloat* trianglePoint3,
34 MFloat* edgePoint1,
35 MFloat* edgePoint2) override;
37 MFloat* trianglePoint2,
38 MFloat* trianglePoint3,
39 MFloat* edgePoint1,
40 MFloat* edgePoint2) override;
41
44 MFloat* dist) override;
45 MBool getLineTriangleIntersection(const MFloat* const p1, const MFloat* const p2, const MFloat radius,
46 const MFloat* const v1, const MFloat* const v2, const MFloat* const v3,
47 MFloat* intersection, MFloat* normal, MFloat* lambda2, MFloat* dist) override;
48
49 // moving boundary
50 MInt getIntersectionMBElements(MFloat* targetRegion, std::vector<MInt>& nodeList) override;
51 MInt getLineIntersectionMBElements(MFloat* targetRegion, std::vector<MInt>& nodeList) override;
52 MInt getLineIntersectionMBElements2(MFloat* targetRegion, MInt* spaceDirection, std::vector<MInt>& nodeList,
53 MInt bcIc) override;
54 MInt getSphereIntersectionMBElements(MFloat* P, MFloat radius, std::vector<MInt>& nodeList) override;
55 void MoveAllMBElementVertex(MFloat* dx) override;
56 void MoveMBElementVertex(MInt e, MInt v, MFloat* dx) override;
57 void ReplaceMBElementVertex(MInt e, MInt v, MFloat* np) override;
58 void UpdateMBNormalVector(MInt e) override;
59 void UpdateMBBoundingBox() override;
60 void UpdateADT() override;
61
62 void writeSTL(const char* fileName) override;
63 void writeSTLMB(const char* fileName, MInt& noNodes, MInt*& nodeList) override;
64 void writeADTAndSTLToNetCDF(const char* fileName) override;
65 void readSTLNetCDF(const char* fileName) override;
66
67 void logStatistics() override;
68
69 MFloat** GetBoundaryVertices(MInt segmentId, MFloat* tri_vx, MInt* keepOffsets, MInt size, MInt* num) override;
70 virtual inline std::vector<std::pair<MFloat*, MFloat*>> GetUniqueSegmentEdgesParGeom(MFloat* tri_vx,
71 MInt* keepOffsets, MInt size);
72 virtual inline std::vector<std::pair<MFloat*, MFloat*>> GetUniqueSegmentEdges(MInt segmentId);
73 inline MBool isEdgeAlreadyInCollection(std::vector<std::pair<MFloat*, MFloat*>> tmp_edges, MFloat* p1, MFloat* p2,
74 MInt* pos) override;
75 MFloat GetBoundarySize(MInt segmentId) override;
76 MFloat GetBoundarySize(MFloat* vertices, MInt* keepOffset, MInt size) override;
77 void determineSegmentOwnership(MInt segmentId, MInt* own, MInt* sumowners, MInt* firstOwner, MInt* owners) override;
78 MFloat getBndMaxRadius(MFloat** vertices, MInt num) override;
79
80 protected:
81 void readSegments() override;
82 virtual void correctVertexCoordinates();
83 virtual inline void swap4BytesToBE(char* buf);
84 virtual MInt is_big_endian();
85
88 virtual inline void countSegmentTrianglesASCII(MString fileName, MInt* noElements);
89 virtual inline void countSegmentTrianglesBINARY(MString fileName, MInt* noElements);
90 virtual inline void countSegmentTrianglesNETCDF(MString fileName, MInt* noElements, const MPI_Comm comm);
91 virtual inline void readSegmentTrianglesASCII(MString fileName, Collector<element<3>>* elemCollector, MInt bndCndId,
92 MInt segmentId, MInt* offset);
93 virtual inline void readSegmentTrianglesBINARY_BE(MString fileName, Collector<element<3>>* elemCollector,
94 MInt bndCndId, MInt segmentId, MInt* offset);
95 virtual inline void readSegmentTrianglesBINARY_LE(MString fileName, Collector<element<3>>* elemCollector,
96 MInt bndCndId, MInt segmentId, MInt* offset);
97 virtual inline void readSegmentTrianglesNETCDF(MString fileName, Collector<element<3>>* elemCollector, MInt bndCndId,
98 MInt segmentId, MInt* offset, const MPI_Comm comm);
99
100 void rebuildAdtTree() override;
101 void calculateBoundingBox() override;
102 void writeParallelGeometryVTK(MString filename) override;
103
104 void printMemoryUsage();
105 void collectGlobalMemoryUsage() override;
106 void addElement(MFloat* tri) override;
107 void copyElement(MInt from, MInt to) override;
108 void copyElement(MInt from, MInt to, element<3>* fromPtr, element<3>* toPtr);
109 void resizeCollector(MInt new_size) override;
110
112
118
120
124
131 static constexpr const MInt nDim = 3;
132
134
135 // TIMERS
136 private:
140};
141
142template <>
143struct GeometryXD<3> {
145};
146
147#endif
virtual Collector< element< 3 > > * readSegmentsParallel()
void writeSTLMB(const char *fileName, MInt &noNodes, MInt *&nodeList) override
MBool m_GFieldInitFromSTL
Definition: geometry3d.h:113
virtual void readSegmentTrianglesBINARY_BE(MString fileName, Collector< element< 3 > > *elemCollector, MInt bndCndId, MInt segmentId, MInt *offset)
reads triangles from a BINARY file and swaps to big endian
Definition: geometry3d.cpp:631
virtual void readSegmentTrianglesBINARY_LE(MString fileName, Collector< element< 3 > > *elemCollector, MInt bndCndId, MInt segmentId, MInt *offset)
reads triangles from a BINARY file and swaps to little endian
Definition: geometry3d.cpp:717
MBool edgeTriangleIntersectionLB(MFloat *trianglePoint1, MFloat *trianglePoint2, MFloat *trianglePoint3, MFloat *edgePoint1, MFloat *edgePoint2) override
Determine intersection between an edge and a triangle.
MInt getLineIntersectionElements(MFloat *targetRegion, std::vector< MInt > &nodeList) override
Returns the ids of all elements, cut by a ray by using the perp-dot operator.
MBool m_communicateSegmentsSerial
Definition: geometry3d.h:133
void rebuildAdtTree() override
Rebuilds the ADT tree.
Definition: geometry3d.cpp:313
virtual Collector< element< 3 > > * readSegmentsSerial()
reads the segments in serial
Definition: geometry3d.cpp:855
MFloat GetBoundarySize(MInt segmentId) override
Returns the area of a segment.
virtual void countSegmentTrianglesBINARY(MString fileName, MInt *noElements)
counts the number of triangles in a BINARY STL file
Definition: geometry3d.cpp:457
void MoveAllMBElementVertex(MFloat *dx) override
virtual std::vector< std::pair< MFloat *, MFloat * > > GetUniqueSegmentEdges(MInt segmentId)
Returns unique edges of a given set segment id.
static constexpr const MInt nDim
Definition: geometry3d.h:131
MFloat ** GetBoundaryVertices(MInt segmentId, MFloat *tri_vx, MInt *keepOffsets, MInt size, MInt *num) override
This function gets all boundary vertices of an element<3> in a circular order.
void UpdateMBNormalVector(MInt e) override
Geometry3D(const MInt solverId_, const MPI_Comm comm)
MInt m_noAllTriangles
Definition: geometry3d.h:123
virtual MInt is_big_endian()
determines the CPU type big or little endian
Definition: geometry3d.cpp:608
void collectGlobalMemoryUsage() override
Definition: geometry3d.cpp:341
MInt getIETCallCounter
Definition: geometry3d.h:129
MBool edgeTriangleIntersection(MFloat *trianglePoint1, MFloat *trianglePoint2, MFloat *trianglePoint3, MFloat *edgePoint1, MFloat *edgePoint2) override
Determine intersection between an edge and a triangle.
void writeADTAndSTLToNetCDF(const char *fileName) override
MInt getIECallCounter
Definition: geometry3d.h:127
MInt m_t_geometryAll
Definition: geometry3d.h:138
MBool m_forceBoundingBox
Definition: geometry3d.h:117
virtual void correctVertexCoordinates()
MInt getLineIntersectionMBElements2(MFloat *targetRegion, MInt *spaceDirection, std::vector< MInt > &nodeList, MInt bcIc) override
MBool getLineTriangleIntersection(const MFloat *const p1, const MFloat *const p2, const MFloat radius, const MFloat *const v1, const MFloat *const v2, const MFloat *const v3, MFloat *intersection, MFloat *normal, MFloat *lambda2, MFloat *dist) override
This function determines if a line crosses a triangle.
void copyElement(MInt from, MInt to) override
Copies an element<3> from one poistion to another.
MBool getLineTriangleIntersectionSimple(MFloat *p1, MFloat *p2, MFloat *v1, MFloat *v2, MFloat *v3) override
This function determines if a line crosses a triangle.
void printMemoryUsage()
prints the current memory usage of this object
Definition: geometry3d.cpp:328
MInt getLineIntersectionElementsOld2(MFloat *targetRegion, MInt *spaceDirection, std::vector< MInt > &nodeList) override
Returns the ids of all elements, cut by a orthogonal line (or rectangular region)
MInt getIntersectionElements(MFloat *targetRegion, std::vector< MInt > &nodeList, MFloat cellHalfLength, const MFloat *const cell_coords) override
Determines all elements that are inside or intersect the target region with the separating axis theor...
virtual std::vector< std::pair< MFloat *, MFloat * > > GetUniqueSegmentEdgesParGeom(MFloat *tri_vx, MInt *keepOffsets, MInt size)
Returns unique edges of a given set segment id for parallel geometry.
MInt m_tg_geometry
Definition: geometry3d.h:137
MString m_gridFileName
Definition: geometry3d.h:122
MString m_gridCutTest
Definition: geometry3d.h:119
MInt getSphereIntersectionMBElements(MFloat *P, MFloat radius, std::vector< MInt > &nodeList) override
MBool isEdgeAlreadyInCollection(std::vector< std::pair< MFloat *, MFloat * > > tmp_edges, MFloat *p1, MFloat *p2, MInt *pos) override
Checks if an edge given by two points is in a vector.
MInt getLIE2CommCounter
Definition: geometry3d.h:126
void addElement(MFloat *tri) override
Adds an element<3> to the collector.
void logStatistics() override
virtual void countSegmentTrianglesNETCDF(MString fileName, MInt *noElements, const MPI_Comm comm)
counts the number of triangles in a NETCDF STL file
Definition: geometry3d.cpp:485
virtual void countSegmentTrianglesASCII(MString fileName, MInt *noElements)
counts the number of triangles in an ASCII STL file
Definition: geometry3d.cpp:418
MInt m_getLIE2CallCounter
Definition: geometry3d.h:125
MInt m_levelSetIntfBndId
Definition: geometry3d.h:114
void resizeCollector(MInt new_size) override
deletes the current element<3> collector and reinitializes
virtual void readSegmentTrianglesNETCDF(MString fileName, Collector< element< 3 > > *elemCollector, MInt bndCndId, MInt segmentId, MInt *offset, const MPI_Comm comm)
reads triangles from a BINARY file
Definition: geometry3d.cpp:783
void readSTLNetCDF(const char *fileName) override
void writeParallelGeometryVTK(MString filename) override
Write the current geometry to a VTK file for parallel computation.
virtual void readSegmentTrianglesASCII(MString fileName, Collector< element< 3 > > *elemCollector, MInt bndCndId, MInt segmentId, MInt *offset)
reads triangles from an ASCII file
Definition: geometry3d.cpp:509
void calculateBoundingBox() override
Calculates the global bounding box of the geometry.
virtual MInt getIntersectionElementsTetraeder(MFloat *targetRegion, std::vector< MInt > &nodeList)
Determines all elements that are inside or intersect the target region.
void ReplaceMBElementVertex(MInt e, MInt v, MFloat *np) override
MInt m_noLevelSetIntfBndIds
Definition: geometry3d.h:116
void UpdateMBBoundingBox() override
MString m_geomFileType
Definition: geometry3d.h:121
MInt edgeTICallCounter
Definition: geometry3d.h:130
MBool getClosestLineIntersectionLength(MInt bndCndId, const std::vector< MInt > &nodeList, MFloat *targetRegion, MFloat *dist) override
MInt getIntersectionMBElements(MFloat *targetRegion, std::vector< MInt > &nodeList) override
MInt * m_levelSetIntfBndIds
Definition: geometry3d.h:115
MFloat getBndMaxRadius(MFloat **vertices, MInt num) override
This function gets the maximal radius for a boundary segment.
void UpdateADT() override
MInt getLineIntersectionMBElements(MFloat *targetRegion, std::vector< MInt > &nodeList) override
void readSegments() override
reads the STL segments from file
MBool getLineTriangleIntersectionSimpleDistance(MFloat *p1, MFloat *p2, MFloat *v1, MFloat *v2, MFloat *v3, MFloat *dist) override
This function determines if a line crosses a triangle.
virtual void swap4BytesToBE(char *buf)
swaps 4 bytes from little to big endian
Definition: geometry3d.cpp:592
MInt getIECommCounter
Definition: geometry3d.h:128
void MoveMBElementVertex(MInt e, MInt v, MFloat *dx) override
void determineSegmentOwnership(MInt segmentId, MInt *own, MInt *sumowners, MInt *firstOwner, MInt *owners) override
Determines the ownership of a segment.
MInt m_t_readGeometry
Definition: geometry3d.h:139
void writeSTL(const char *fileName) override
MInt otherCalls
Definition: geometry3d.h:111
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
MFloat dist(const Point< DIM > &p, const Point< DIM > &q)
Definition: pointbox.h:54