FEMTIC
MeshData.h
Go to the documentation of this file.
1 //-------------------------------------------------------------------------------------------------------
2 // The MIT License (MIT)
3 //
4 // Copyright (c) 2021 Yoshiya Usui
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in all
14 // copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23 //-------------------------------------------------------------------------------------------------------
24 #ifndef DBLDEF_MESHDATA
25 #define DBLDEF_MESHDATA
26 
27 #include <vector>
28 #include "CommonParameters.h"
29 
30 // Class of FEM mesh for brick element
31 class MeshData{
32 
33 public:
34 
36  YZMinus = 0,
42  };
43 
44  enum MeshType{
45  HEXA = 0,
48  };
49 
51  double X;
52  double Y;
53  double Z;
54  };
55 
57  double X;
58  double Y;
59  };
60 
61  // Constructer
62  MeshData();
63 
64  // Destructer
65  virtual ~MeshData();
66 
67  // Input mesh data from "mesh.dat"
68  virtual void inputMeshData() = 0;
69 
70  // Get tolal number of elements
71  int getNumElemTotal() const;
72 
73  // Get tolal number of nodes
74  int getNumNodeTotal() const;
75 
76  // Get total number of elements belonging to the boundary planes
77  int getNumElemOnBoundaryPlanes( const int iPlane ) const;
78 
79  // Get X coordinates of node
80  double getXCoordinatesOfNodes( const int iNode ) const;
81 
82  // Get Y coordinates of node
83  double getYCoordinatesOfNodes( const int iNode ) const;
84 
85  // Get Z coordinates of node
86  double getZCoordinatesOfNodes( const int iNode ) const;
87 
88  // Get ID of the Node composing specified element
89  int getNodesOfElements( const int iElem, const int iNode ) const;
90 
91  // Get ID of the element belonging to the boundary planes
92  int getElemBoundaryPlanes( const int iPlane, const int iElem ) const;
93 
94  // Get ID of neighbor Elements
95  int getIDOfNeighborElement( const int iElem, const int num ) const;
96 
97  // Get number of neighbor elements of one element
98  int getNumNeighborElement() const;
99 
100  // Get mesh type
101  virtual int getMeshType() const = 0;
102 
103  // Calculate distance of two nodes
104  double calcDistanceOfTwoNodes( const int nodeID0, const int nodeID1 ) const;
105 
106  // Calculate horizontal distance of two nodes
107  double calcHorizontalDistanceOfTwoNodes( const int nodeID0, const int nodeID1 ) const;
108 
109  // Calculate distance of two nodes along X direction
110  double caldDiffXOfTwoNodes( const int nodeID0, const int nodeID1 ) const;
111 
112  // Calculate distance of two nodes along Y direction
113  double caldDiffYOfTwoNodes( const int nodeID0, const int nodeID1 ) const;
114 
115  // Calculate distance of two nodes along Z direction
116  double caldDiffZOfTwoNodes( const int nodeID0, const int nodeID1 ) const;
117 
118  // Decide whether specified elements share same nodes
119  virtual bool shareSameNodes( const int elemID1, const int elemID2 ) const;
120 
121  // Calculate coordinate of the center of a specified element
122  virtual CommonParameters::locationXYZ getCenterCoord( const int iElem ) const;
123 
124  // Calculate difference of the centers of the specified two element
125  CommonParameters::locationXYZ calDiffOfCenters( const int iElem1, const int iElem2 ) const;
126 
127  // Decide whether specified elements share same edges
128  virtual bool shareSameEdges( const int elemID1, const int elemID2 ) const = 0;
129 
130  // Get ID of the nodes of elements belonging to the boundary planes
131  virtual int getNodesOfElementsBoundaryPlanes( const int iPlane, const int iElem, const int iNode ) const = 0;
132 
133  // Calculate volume of a specified element
134  virtual double calcVolume( const int elemID ) const = 0;
135 
136  // Output mesh data to VTK file
137  virtual void outputMeshDataToVTK() const = 0;
138 
139  // Output mesh data to binary file
140  virtual void outputMeshDataToBinary() const = 0;
141 
142  // Calculate area of face
143  virtual double calcAreaOfFace( const int iElem, const int iFace ) const = 0;
144 
145  // Calculate area of face at bottom of mesh
146  virtual double calcAreaOfFaceAtBottomOfMesh( const int iElem ) const = 0;
147 
148 protected:
149 
150  // Copy constructer
151  MeshData(const MeshData& rhs);
152 
153  // Copy assignment operator
154  MeshData& operator=(const MeshData& rhs);
155 
156  // Total number of elements
158 
159  // Total number of nodes
161 
162  // Number of nodes belonging to one element
164 
165  // Number of edges belonging to one element
167 
168  // Number of nodes on a face of one element
170 
171  // Number of neighbor elements of one element
173 
174  // Total number of elements belonging to the boundary planes
176 
177  // Array of the X coordinates of nodes
179 
180  // Array of the Y coordinates of nodes
182 
183  // Array of the Z coordinates of nodes
185 
186  // Array of IDs of neighbor Elements
188 
189  // Array of nodes composing each element
191 
192  // Array of elements belonging to the boundary planes
193  // m_elemBoundaryPlane[0] : Y-Z Plane ( Minus Side )
194  // m_elemBoundaryPlane[1] : Y-Z Plane ( Plus Side )
195  // m_elemBoundaryPlane[2] : Z-X Plane ( Minus Side )
196  // m_elemBoundaryPlane[3] : Z-X Plane ( Plus Side )
197  // m_elemBoundaryPlane[4] : X-Y Plane ( Minus Side )
198  // m_elemBoundaryPlane[5] : X-Y Plane ( Plus Side )
200 
201  // Calculate distanceof two points
202  double calcDistance( const CommonParameters::locationXY& point0, const CommonParameters::locationXY& point1 ) const;
203 
204  // Function determine if the 1st segment contains the 2nd segment
205  bool does1stSegmentContain2ndSegment( const CommonParameters::locationXY& startPointOf1stSegment, const CommonParameters::locationXY& endPointOf1stSegment,
206  const CommonParameters::locationXY& startPointOf2ndSegment, const CommonParameters::locationXY& endPointOf2ndSegment ) const;
207 
208  // Function determine if two segments intersect or not
209  bool intersectTwoSegments( const CommonParameters::locationXY& startPointOf1stSegment, const CommonParameters::locationXY& endPointOf1stSegment,
210  const CommonParameters::locationXY& startPointOf2ndSegment, const CommonParameters::locationXY& endPointOf2ndSegment ) const;
211 
212  // Function determine if two lines overlap or not
213  bool overlapTwoLines( const CommonParameters::locationXY& coord1stLine1, const CommonParameters::locationXY& coord1stLine2,
214  const CommonParameters::locationXY& coord2ndLine1, const CommonParameters::locationXY& coord2ndLine2 ) const;
215 
216  // Function determine if two segments overlap or not
217  bool overlapTwoSegments( const CommonParameters::locationXY& startPointOf1stSegment, const CommonParameters::locationXY& endPointOf1stSegment,
218  const CommonParameters::locationXY& startPointOf2ndSegment, const CommonParameters::locationXY& endPointOf2ndSegment ) const;
219 
220  // Calculate inner product of two vectors
221  double calcInnerProduct2D( const CommonParameters::locationXY& startCoordOf1stVec, const CommonParameters::locationXY& endCoordOf1stVec,
222  const CommonParameters::locationXY& startCoordOf2ndVec, const CommonParameters::locationXY& endCoordOf2ndVec) const;
223 
224  // Calculate coordinates of intersection point of two lines
226  const CommonParameters::locationXY& coord2ndLine1, const CommonParameters::locationXY& coord2ndLine2, CommonParameters::locationXY& coordIntersectionPoint) const;
227 
228 };
229 
230 #endif
Definition: MeshData.h:31
BoundaryPlanes
Definition: MeshData.h:35
@ YZMinus
Definition: MeshData.h:36
@ ZXPlus
Definition: MeshData.h:39
@ ZXMinus
Definition: MeshData.h:38
@ XYMinus
Definition: MeshData.h:40
@ YZPlus
Definition: MeshData.h:37
@ XYPlus
Definition: MeshData.h:41
int m_numEdgeOneElement
Definition: MeshData.h:166
double * m_xCoordinatesOfNodes
Definition: MeshData.h:178
virtual bool shareSameEdges(const int elemID1, const int elemID2) const =0
double calcDistanceOfTwoNodes(const int nodeID0, const int nodeID1) const
Definition: MeshData.cpp:239
virtual int getMeshType() const =0
double calcHorizontalDistanceOfTwoNodes(const int nodeID0, const int nodeID1) const
Definition: MeshData.cpp:250
int getNumElemTotal() const
Definition: MeshData.cpp:113
virtual CommonParameters::locationXYZ getCenterCoord(const int iElem) const
Definition: MeshData.cpp:316
virtual bool shareSameNodes(const int elemID1, const int elemID2) const
Definition: MeshData.cpp:281
virtual void outputMeshDataToBinary() const =0
bool overlapTwoSegments(const CommonParameters::locationXY &startPointOf1stSegment, const CommonParameters::locationXY &endPointOf1stSegment, const CommonParameters::locationXY &startPointOf2ndSegment, const CommonParameters::locationXY &endPointOf2ndSegment) const
Definition: MeshData.cpp:454
int getNumNodeTotal() const
Definition: MeshData.cpp:118
double * m_yCoordinatesOfNodes
Definition: MeshData.h:181
bool intersectTwoSegments(const CommonParameters::locationXY &startPointOf1stSegment, const CommonParameters::locationXY &endPointOf1stSegment, const CommonParameters::locationXY &startPointOf2ndSegment, const CommonParameters::locationXY &endPointOf2ndSegment) const
Definition: MeshData.cpp:377
double getZCoordinatesOfNodes(const int iNode) const
Definition: MeshData.cpp:163
virtual double calcAreaOfFaceAtBottomOfMesh(const int iElem) const =0
double getYCoordinatesOfNodes(const int iNode) const
Definition: MeshData.cpp:150
bool does1stSegmentContain2ndSegment(const CommonParameters::locationXY &startPointOf1stSegment, const CommonParameters::locationXY &endPointOf1stSegment, const CommonParameters::locationXY &startPointOf2ndSegment, const CommonParameters::locationXY &endPointOf2ndSegment) const
Definition: MeshData.cpp:351
double * m_zCoordinatesOfNodes
Definition: MeshData.h:184
int getNumElemOnBoundaryPlanes(const int iPlane) const
Definition: MeshData.cpp:123
double caldDiffYOfTwoNodes(const int nodeID0, const int nodeID1) const
Definition: MeshData.cpp:267
int m_numNodeOnFaceOneElement
Definition: MeshData.h:169
double getXCoordinatesOfNodes(const int iNode) const
Definition: MeshData.cpp:136
virtual ~MeshData()
Definition: MeshData.cpp:64
MeshType
Definition: MeshData.h:44
@ NONCONFORMING_HEXA
Definition: MeshData.h:47
@ TETRA
Definition: MeshData.h:46
@ HEXA
Definition: MeshData.h:45
int getElemBoundaryPlanes(const int iPlane, const int iElem) const
Definition: MeshData.cpp:197
int m_numNeighborElement
Definition: MeshData.h:172
int getIDOfNeighborElement(const int iElem, const int num) const
Definition: MeshData.cpp:211
double caldDiffXOfTwoNodes(const int nodeID0, const int nodeID1) const
Definition: MeshData.cpp:260
int m_numElemTotal
Definition: MeshData.h:157
int * m_neighborElements
Definition: MeshData.h:187
virtual void outputMeshDataToVTK() const =0
virtual double calcVolume(const int elemID) const =0
double calcInnerProduct2D(const CommonParameters::locationXY &startCoordOf1stVec, const CommonParameters::locationXY &endCoordOf1stVec, const CommonParameters::locationXY &startCoordOf2ndVec, const CommonParameters::locationXY &endCoordOf2ndVec) const
Definition: MeshData.cpp:475
virtual void inputMeshData()=0
int m_numNodeOneElement
Definition: MeshData.h:163
int * m_elemBoundaryPlanes[6]
Definition: MeshData.h:199
virtual int getNodesOfElementsBoundaryPlanes(const int iPlane, const int iElem, const int iNode) const =0
void calcCoordOfIntersectionPointOfTwoLines(const CommonParameters::locationXY &coord1stLine1, const CommonParameters::locationXY &coord1stLine2, const CommonParameters::locationXY &coord2ndLine1, const CommonParameters::locationXY &coord2ndLine2, CommonParameters::locationXY &coordIntersectionPoint) const
Definition: MeshData.cpp:486
int m_numElemOnBoundaryPlanes[6]
Definition: MeshData.h:175
MeshData & operator=(const MeshData &rhs)
Definition: MeshData.cpp:107
int getNumNeighborElement() const
Definition: MeshData.cpp:232
int m_numNodeTotal
Definition: MeshData.h:160
double caldDiffZOfTwoNodes(const int nodeID0, const int nodeID1) const
Definition: MeshData.cpp:274
bool overlapTwoLines(const CommonParameters::locationXY &coord1stLine1, const CommonParameters::locationXY &coord1stLine2, const CommonParameters::locationXY &coord2ndLine1, const CommonParameters::locationXY &coord2ndLine2) const
Definition: MeshData.cpp:411
MeshData()
Definition: MeshData.cpp:39
double calcDistance(const CommonParameters::locationXY &point0, const CommonParameters::locationXY &point1) const
Definition: MeshData.cpp:344
int * m_nodesOfElements
Definition: MeshData.h:190
virtual double calcAreaOfFace(const int iElem, const int iFace) const =0
CommonParameters::locationXYZ calDiffOfCenters(const int iElem1, const int iElem2) const
Definition: MeshData.cpp:336
int getNodesOfElements(const int iElem, const int iNode) const
Definition: MeshData.cpp:176
Definition: CommonParameters.h:53
Definition: CommonParameters.h:38
Definition: MeshData.h:56
double Y
Definition: MeshData.h:58
double X
Definition: MeshData.h:57
Definition: MeshData.h:50
double X
Definition: MeshData.h:51
double Z
Definition: MeshData.h:53
double Y
Definition: MeshData.h:52