-
Notifications
You must be signed in to change notification settings - Fork 7
/
InputOutput.h
274 lines (209 loc) · 9.21 KB
/
InputOutput.h
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
/*
Copyright (c) 2015-2017 Lester Hedges <[email protected]>
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _INPUTOUTPUT_H
#define _INPUTOUTPUT_H
#include <sstream>
#include <string>
/*! \file InputOutput.h
\brief A class for reading and writing data.
*/
namespace slsm
{
// FORWARD DECLARATIONS
class Boundary;
class LevelSet;
class Mesh;
//! A class for reading and writing data.
class InputOutput
{
public:
//! Constructor.
InputOutput();
//! Save the level set function as a ParaView VTK file.
/*! \param datapoint
The datapoint of the current optimisation trajectory.
\param levelSet
A reference to the level set object.
\param isVelocity
Whether to write velocity information to file (optional).
\param isGradient
Whether to write gradient information to file (optional).
\param outputDirectory
The output directory path (optional).
*/
void saveLevelSetVTK(const unsigned int&, const LevelSet&, bool isVelocity = false,
bool isGradient = false, const std::string& outputDirectory = "") const;
//! Save the level set function as a ParaView VTK file.
/*! \param fileName
The name of the data file.
\param levelSet
A reference to the level set object.
\param isVelocity
Whether to write velocity information to file (optional).
\param isGradient
Whether to write gradient information to file (optional).
*/
void saveLevelSetVTK(const std::string&, const LevelSet&,
bool isVelocity = false, bool isGradient = false) const;
//! Save the level set function as a plain text file.
/*! \param datapoint
The datapoint of the current optimisation trajectory.
\param levelSet
A reference to the level set object.
\param outputDirectory
The output directory path (optional).
\param isXY
Whether to also output the nodal x/y coordinates (optional).
*/
void saveLevelSetTXT(const unsigned int&, const LevelSet&,
const std::string& outputDirectory = "", bool isXY = false) const;
//! Save the level-set signed distance function as a binary file.
/*! \param datapoint
The datapoint of the current optimisation trajectory.
\param levelSet
A reference to the level set object.
\param outputDirectory
The output directory path (optional).
*/
void saveLevelSetBIN(const unsigned int&, const LevelSet&,
const std::string& outputDirectory = "") const;
//! Save the level set function as a plain text file.
/*! \param fileName
The name of the data file.
\param levelSet
A reference to the level set object.
\param isXY
Whether to also output the nodal x/y coordinates (optional).
*/
void saveLevelSetTXT(const std::string&, const LevelSet&, bool isXY = false) const;
//! Save the level-set signed distance function as a binary file.
/*! \param fileName
The name of the data file.
\param levelSet
A reference to the level set object.
*/
void saveLevelSetBIN(const std::string&, const LevelSet&) const;
//! Load the level-set signed distance function from a plain text file.
/*! \param datapoint
The datapoint of the current optimisation trajectory.
\param levelSet
A reference to the level set object.
\param inputDirectory
The input directory path (optional).
\param isXY
Whether the data file also contains nodal x/y coordinates (optional).
*/
void loadLevelSetTXT(const unsigned int&, LevelSet&,
const std::string& inputDirectory = "", bool isXY = false) const;
//! Load the level-set signed distance function from a binary file.
/*! \param datapoint
The datapoint of the current optimisation trajectory.
\param levelSet
A reference to the level set object.
\param inputDirectory
The input directory path (optional).
*/
void loadLevelSetBIN(const unsigned int&, LevelSet&,
const std::string& inputDirectory = "") const;
//! Load the level set function from a plain text file.
/*! \param fileName
The name of the data file.
\param levelSet
A reference to the level set object.
\param isXY
Whether the data file also contains nodal x/y coordinates (optional).
*/
void loadLevelSetTXT(const std::string&, LevelSet&, bool isXY = false) const;
//! Load the level-set signed distance function from a binary file.
/*! \param fileName
The name of the data file.
\param levelSet
A reference to the level set object.
*/
void loadLevelSetBIN(const std::string&, LevelSet&) const;
//! Save boundary points as a plain text file.
/*! \param datapoint
The datapoint of the current optimisation trajectory.
\param boundary
A reference to the boundary object.
\param outputDirectory
The output directory path (optional).
*/
void saveBoundaryPointsTXT(const unsigned int&, const Boundary&,
const std::string& outputDirectory = "") const;
//! Save boundary points as a plain text file.
/*! \param fileName
The name of the data file.
\param boundary
A reference to the boundary object.
*/
void saveBoundaryPointsTXT(const std::string&, const Boundary&) const;
//! Save boundary segments as a plain text file.
/*! \param datapoint
The datapoint of the current optimisation trajectory.
\param boundary
A reference to the boundary object.
\param outputDirectory
The output directory path (optional).
*/
void saveBoundarySegmentsTXT(const unsigned int&,
const Boundary&, const std::string& outputDirectory = "") const;
//! Save boundary segments as a plain text file.
/*! \param fileName
The name of the data file.
\param boundary
A reference to the boundary object.
*/
void saveBoundarySegmentsTXT(const std::string&, const Boundary&) const;
//! Save the element area fractions as a ParaView VTK file.
/*! \param datapoint
The datapoint of the current optimisation trajectory.
\param mesh
A reference to the level set mesh.
\param outputDirectory
The output directory path (optional).
*/
void saveAreaFractionsVTK(const unsigned int&, const Mesh&,
const std::string& outputDirectory = "") const;
//! Save the element area fractions as a ParaView VTK file.
/*! \param fileName
The name of the data file.
\param mesh
A reference to the level set mesh.
*/
void saveAreaFractionsVTK(const std::string&, const Mesh&) const;
//! Save element area fractions as a plain text file.
/*! \param datapoint
The datapoint of the current optimisation trajectory.
\param mesh
A reference to the level set mesh.
\param outputDirectory
The output directory path (optional).
\param isXY
Whether to also output the element x/y coordinates (optional).
*/
void saveAreaFractionsTXT(const unsigned int&, const Mesh&,
const std::string& outputDirectory = "", bool isXY = false) const;
//! Save element area fractions as a plain text file.
/*! \param fileName
The name of the data file.
\param mesh
A reference to the level set mesh.
\param isXY
Whether to also output the element x/y coordinates (optional).
*/
void saveAreaFractionsTXT(const std::string&, const Mesh&, bool isXY = false) const;
};
}
#endif /* _INPUTOUTPUT_H */