-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCubicMesh.h
More file actions
225 lines (197 loc) · 6.37 KB
/
CubicMesh.h
File metadata and controls
225 lines (197 loc) · 6.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
// Copyright 2019 by Carl Ollivier-Gooch. The University of British
// Columbia disclaims all copyright interest in the software ExaMesh.//
//
// This file is part of ExaMesh.
//
// ExaMesh is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// ExaMesh is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with ExaMesh. If not, see <https://www.gnu.org/licenses/>.
/*
* CubicMesh.h
*
* Created on: Oct. 1, 2019
* Author: cfog
*/
#ifndef SRC_CUBICMESH_H_
#define SRC_CUBICMESH_H_
#include <assert.h>
#include "exa-defs.h"
#include "ExaMesh.h"
// This data structure is organized to read and write easily to/from CGNS files.
class CubicMesh: public ExaMesh {
emInt m_vert, m_tri, m_quad, m_tet, m_pyr, m_prism, m_hex;
emInt m_nVerts, m_nBdryVerts, m_nTri10, m_nQuad16, m_nTet20, m_nPyr30,
m_nPrism40, m_nHex64, m_nVertNodes;
double *m_xcoords, *m_ycoords, *m_zcoords;
emInt (*m_Tri10Conn)[10];
emInt (*m_Quad16Conn)[16];
emInt (*m_Tet20Conn)[20];
emInt (*m_Pyr30Conn)[30];
emInt (*m_Prism40Conn)[40];
emInt (*m_Hex64Conn)[64];
exa_set <TriFaceVerts> TemppartTris;;
exa_set <QuadFaceVerts> TemppartQuads;
exa_set<TriFaceVerts> partTris;
exa_set<QuadFaceVerts> partQuads;
exa_set<TriFaceVerts> refinedPartTris;
CubicMesh(const CubicMesh&);
CubicMesh& operator=(const CubicMesh&);
void readCGNSfile(const std::string CGNSBaseName);
void reorderCubicMesh();
void renumberNodes(emInt thisSize, emInt* aliasConn, emInt* newNodeInd);
void decrementVertIndices(emInt connSize, emInt* const connect);
// Confirm positive volume for all subelements
bool verifyTetValidity() const;
bool verifyPyramidValidity() const;
bool verifyPrismValidity() const;
bool verifyHexValidity() const;
// Length scales
public:
CubicMesh(const emInt nVerts, const emInt nBdryVerts, const emInt nBdryTris,
const emInt nBdryQuads, const emInt nTets, const emInt nPyramids,
const emInt nPrisms, const emInt nHexes);
#if (HAVE_CGNS == 1)
CubicMesh(const std::string CGNSBaseName);
#endif
virtual ~CubicMesh();
std::unique_ptr<UMesh>
subdivideMesh(const emInt nDivs, const emInt partID = 0) const;
// Will eventually want to create a fine CubicMesh from a coarse CubicMesh
// (for the mapping). Not urgent.
virtual emInt numVerts() const {
return m_nVerts;
}
emInt numVertsAllocated() const {
return numVerts();
}
virtual emInt numBdryVerts() const {
return m_nBdryVerts;
}
virtual emInt numBdryTris() const {
return m_nTri10;
}
virtual emInt numBdryQuads() const {
return m_nQuad16;
}
virtual emInt numTets() const {
return m_nTet20;
}
virtual emInt numPyramids() const {
return m_nPyr30;
}
virtual emInt numPrisms() const {
return m_nPrism40;
}
virtual emInt numHexes() const {
return m_nHex64;
}
virtual emInt numVolCells() const {
// This needs to be changed and having number of boundary quads and tris as well
return numTets() + numPyramids() + numPrisms() + numHexes();
}
virtual emInt numCells() const {
// This needs to be changed and having number of boundary quads and tris as well
return numBdryTris() + numBdryQuads() + numTets()
+ numPyramids() + numPrisms() + numHexes();
}
virtual emInt numVertsToCopy() const {
return m_nVertNodes;
}
emInt addVert(const double newCoords[3]);
emInt addBdryTri(const emInt verts[]);
emInt addBdryQuad(const emInt verts[]);
emInt addTet(const emInt verts[]);
emInt addPyramid(const emInt verts[]);
emInt addPrism(const emInt verts[]);
emInt addHex(const emInt verts[]);
double getX(const emInt vert) const {
assert(vert < m_nVerts);
return m_xcoords[vert];
}
double getY(const emInt vert) const {
assert(vert < m_nVerts);
return m_ycoords[vert];
}
double getZ(const emInt vert) const {
assert(vert < m_nVerts);
return m_zcoords[vert];
}
void getCoords(const emInt vert, double coords[3]) const {
assert(vert < m_nVerts);
coords[0] = m_xcoords[vert];
coords[1] = m_ycoords[vert];
coords[2] = m_zcoords[vert];
}
const emInt* getBdryTriConn(const emInt bdryTri) const {
assert(bdryTri < m_nTri10);
return m_Tri10Conn[bdryTri];
}
const emInt* getBdryQuadConn(const emInt bdryQuad) const {
assert(bdryQuad < m_nQuad16);
return m_Quad16Conn[bdryQuad];
}
const emInt* getTetConn(const emInt tet) const {
assert(tet < m_nTet20);
return m_Tet20Conn[tet];
}
const emInt* getPyrConn(const emInt pyr) const {
assert(pyr < m_nPyr30);
return m_Pyr30Conn[pyr];
}
const emInt* getPrismConn(const emInt prism) const {
assert(prism < m_nPrism40);
return m_Prism40Conn[prism];
}
const emInt* getHexConn(const emInt hex) const {
assert(hex < m_nHex64);
return m_Hex64Conn[hex];
}
Mapping::MappingType getDefaultMappingType() const {
return Mapping::Lagrange;
}
// TODO ; NOT SET FOR CUBIC MESH
// emInt getSizePartTris()const{
// return TemppartTris.size();
// }
// emInt getSizePartQuads()const{
// return TemppartQuads.size();
// }
// exa_set <QuadFaceVerts> getTempQuadPart() const{
// return TemppartQuads;
// }
// exa_set <TriFaceVerts> getTempTriPart() const {
// return TemppartTris;
// }
// exa_set<QuadFaceVerts> getQuadPart() const{
// return partQuads;
// }
// exa_set<TriFaceVerts> getTriPart() const {
// return partTris;
// }
// exa_set<TriFaceVerts> getRefinedPartTris() const{
// return refinedPartTris;
// }
std::unique_ptr<ExaMesh>
extractCoarseMeshMPI(const emInt partID, const std::vector<emInt> &partcells , const int numDivs,
const std::unordered_set<TriFaceVerts>& tris,
const std::unordered_set<QuadFaceVerts>& quads) const;
emInt getTriType() const {return CGNS_ENUMV(TRI_10);}
emInt getQuadType() const {return CGNS_ENUMV(QUAD_16);}
emInt getTetType() const {return CGNS_ENUMV(TETRA_20);}
emInt getPyrType() const {return CGNS_ENUMV(PYRA_30);}
emInt getPrismType() const {return CGNS_ENUMV(PENTA_40);}
emInt getHexType() const {return CGNS_ENUMV(HEXA_64);}
void setNVertNodes(emInt nVertNodes) {
m_nVertNodes = nVertNodes;
}
};
#endif /* SRC_CUBICMESH_H_ */