-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathGMGW_FileWrapper.hxx
More file actions
173 lines (141 loc) · 3.21 KB
/
GMGW_FileWrapper.hxx
File metadata and controls
173 lines (141 loc) · 3.21 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
/*
* GMGW_FileWrapper.hxx
*
* Created on: Jan 27, 2017
* Author: cfog
*/
/*
Copyright (C) The University of British Columbia, 2018.
This file is part of UnstructuredMeshAnalyzer.
UnstructuredMeshAnalyzer is free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
UnstructuredMeshAnalyzer 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with UnstructuredMeshAnalyzer. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef GMGW_FILEWRAPPER_HXX_
#define GMGW_FILEWRAPPER_HXX_
#include "config.h"
#include <cstdio>
#include <assert.h>
class FileWrapper {
protected:
FILE* input;
size_t coordsStart, connectStart;
GMGW_int nVerts, nCells, nBdryTris, nBdryQuads, nTets, nPyrs, nPrisms, nHexes,
nBdryVerts;
char* m_cellTypes;
bool *m_isBdryFace, *m_isBdryVert;
public:
FileWrapper();
virtual
~FileWrapper();
static FileWrapper*
factory(const char baseName[], const char type[], const char ugridInfix[]);
void
writeMeshSizeInfo();
virtual void
scanFile() = 0;
char
getCellType(GMGW_int i) const
{
assert(i < nCells);
return m_cellTypes[i];
}
bool
isBdryFace(GMGW_int i) const
{
assert(i < nCells);
return m_isBdryFace[i];
}
bool
isBdryVert(GMGW_int i) const
{
assert(i < nVerts);
return m_isBdryVert[i];
}
void
setBdryVert(GMGW_int i) const
{
assert(i < nVerts);
m_isBdryVert[i] = true;
}
void
clearBdryVert(GMGW_int i) const
{
assert(i < nVerts);
m_isBdryVert[i] = false;
}
GMGW_int
getNumBdryQuads() const
{
return nBdryQuads;
}
GMGW_int
getNumBdryTris() const
{
return nBdryTris;
}
GMGW_int
getNumBdryVerts() const
{
return nBdryVerts;
}
GMGW_int
getNumCells() const
{
return nCells;
}
GMGW_int
getNumVerts() const
{
return nVerts;
}
GMGW_int
getNumTris() const
{
assert(nBdryTris % 2 == 0);
return (4 * nTets + 4 * nPyrs + 2 * nPrisms + nBdryTris) / 2;
}
GMGW_int
getNumQuads() const
{
assert((nBdryQuads + nPyrs + 3 * nPrisms) % 2 == 0);
return (nBdryQuads + nPyrs + 3 * nPrisms + 6 * nHexes) / 2;
}
GMGW_int
getNumFaces() const
{
return getNumTris() + getNumQuads();
}
virtual void
seekStartOfConnectivity() const;
virtual void
getNextCellConnectivity(GMGW_int& nConn, GMGW_int connect[]) const = 0;
virtual void // needs to be virtual to enable reading from streams instead of FILEs (jww)
seekStartOfCoords() const;
virtual void
getNextVertexCoords(double& x, double& y, double &z) const = 0;
GMGW_int getNumHexes() const {
return nHexes;
}
GMGW_int getNumPrisms() const {
return nPrisms;
}
GMGW_int getNumPyramids() const {
return nPyrs;
}
GMGW_int getNumTets() const {
return nTets;
}
protected:
void
identifyBdryVerts();
};
#endif /* GMGW_FILEWRAPPER_HXX_ */