ECOGEN 6.0
Evolutive, Compressible, Open, Genuine, Easy, N-phase
Loading...
Searching...
No Matches
Output.h
Go to the documentation of this file.
1//
2// ,---. ,--, .---. ,--, ,---. .-. .-.
3// | .-' .' .') / .-. ) .' .' | .-' | \| |
4// | `-. | |(_) | | |(_) | | __ | `-. | | |
5// | .-' \ \ | | | | \ \ ( _) | .-' | |\ |
6// | `--. \ `-. \ `-' / \ `-) ) | `--. | | |)|
7// /( __.' \____\ )---' )\____/ /( __.' /( (_)
8// (__) (_) (__) (__) (__)
9// Official webSite: https://code-mphi.github.io/ECOGEN/
10//
11// This file is part of ECOGEN.
12//
13// ECOGEN is the legal property of its developers, whose names
14// are listed in the copyright file included with this source
15// distribution.
16//
17// ECOGEN is free software: you can redistribute it and/or modify
18// it under the terms of the GNU General Public License as published
19// by the Free Software Foundation, either version 3 of the License,
20// or (at your option) any later version.
21//
22// ECOGEN is distributed in the hope that it will be useful,
23// but WITHOUT ANY WARRANTY; without even the implied warranty of
24// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25// GNU General Public License for more details.
26//
27// You should have received a copy of the GNU General Public License
28// along with ECOGEN (file LICENSE).
29// If not, see <http://www.gnu.org/licenses/>.
30
31#ifndef OUTPUT_H
32#define OUTPUT_H
33
34//Macro for system interactions (creation/destruction of folders)
35#ifdef WIN32
36 #include <direct.h>
37#else
38 #include <sys/types.h>
39 #include <sys/stat.h>
40#endif
41
42#include <fstream>
44#include "../Errors.h"
46#include "../Order1/Cell.h"
47#include "IO.h"
48
49class Output;
50
51#include "Input.h"
52
53class Output
54{
55 public:
57 Output();
58
65 Output(std::string casTest, std::string nameRun, tinyxml2::XMLElement* element, std::string fileName, Input* entree);
66
71 Output(std::string nameRun, int fileNumberRestartMeshMapping, Input* input);
72
76
77 virtual ~Output();
78
79 virtual void probeDisplacement(const double& /*dt*/) { throw ErrorECOGEN("probeDisplacement not available for requested output format"); };
80
81 virtual void locateProbeInMesh(const TypeMeshContainer<Cell*>& /*cells*/, const int& /*nbCells*/, bool /*localSeeking*/ = false)
82 {
83 try {
84 throw ErrorECOGEN("locateProbeInMesh not available for requested output format");
85 }
86 catch (ErrorECOGEN&) {
87 throw;
88 }
89 };
90 virtual Cell* locateProbeInAMRSubMesh(std::vector<Cell*>* /*cells*/, const int& /*nbCells*/)
91 {
92 try {
93 throw ErrorECOGEN("locateProbeInMesh not available for requested output format");
94 }
95 catch (ErrorECOGEN&) {
96 throw;
97 }
98 return 0;
99 };
100
101 void copyInputFiles() const;
102 void initializeOutput(const Cell& cell);
103 void initializeOutput(std::vector<CellInterface*>* cellInterfacesLvl);
104 void initializeOutputMeshMapping(const Cell& cell);
105 virtual void initializeOutputInfos();
106 virtual void writeResults(Mesh* /*mesh*/, std::vector<Cell*>* /*cellsLvl*/)
107 {
108 try {
109 throw ErrorECOGEN("writeResults not available for requested output format");
110 }
111 catch (ErrorECOGEN&) {
112 throw;
113 }
114 };
115 virtual void writeResults(std::vector<CellInterface*>* /*cellInterfacesLvl*/)
116 {
117 try {
118 throw ErrorECOGEN("writeResults not available for requested output format");
119 }
120 catch (ErrorECOGEN&) {
121 throw;
122 }
123 };
124
130 virtual void printTree(Mesh* mesh, const std::vector<Cell*>* cellsLvl, int m_resumeAMRsaveFreq) const;
131 virtual void writeInfos();
132 virtual void writeProgress();
133
135 {
136 try {
137 throw ErrorECOGEN("initializeSpecificOutput not available for requested output format");
138 }
139 catch (ErrorECOGEN&) {
140 throw;
141 }
142 };
143 virtual void initializeSpecificOutput(std::vector<CellInterface*>* /*cellInterfacesLvl*/)
144 {
145 try {
146 throw ErrorECOGEN("initializeSpecificOutput not available for requested output format");
147 }
148 catch (ErrorECOGEN&) {
149 throw;
150 }
151 };
152
155 void readInfos();
157 int readNbCpu();
164 virtual void readResults(Mesh* /*mesh*/, std::vector<Cell*>* /*cellsLvl*/, int /*cpu*/ = -1)
165 {
166 try {
167 throw ErrorECOGEN("readResults not available for requested output format");
168 }
169 catch (ErrorECOGEN&) {
170 throw;
171 }
172 };
173 void readDomainDecompostion(Mesh* mesh);
174
183 virtual void readTree(Mesh* mesh,
184 TypeMeshContainer<Cell*>* cellsLvl,
185 TypeMeshContainer<Cell*>* cellsLvlGhost,
186 TypeMeshContainer<CellInterface*>* cellInterfacesLvl,
187 const std::vector<AddPhys*>& addPhys,
188 int& nbCellsTotalAMR);
189
190 virtual void prepareErrorFiles() const;
191 virtual void writeErrorInFile(std::vector<Errors>& v, const int& ErrorType, const int& iteration, bool& warn) const;
192
201 void readTree_common(Mesh* mesh,
202 TypeMeshContainer<Cell*>* cellsLvl,
203 TypeMeshContainer<Cell*>* cellsLvlGhost,
204 TypeMeshContainer<CellInterface*>* cellInterfacesLvl,
205 const std::vector<AddPhys*>& addPhys,
206 int& lvl);
207
208 //Accessor
209 int getNumFile() const { return m_numFile; };
210 virtual double getNextTime()
211 {
212 try {
213 throw ErrorECOGEN("getNextTime not available for requested output format");
214 }
215 catch (ErrorECOGEN&) {
216 throw;
217 }
218 return 0.;
219 }
220 virtual bool possesses()
221 {
222 try {
223 throw ErrorECOGEN("possesses not available for requested output format");
224 }
225 catch (ErrorECOGEN&) {
226 throw;
227 }
228 return false;
229 };
230
231 virtual const void* getTransferMode() const
232 {
233 try {
234 throw ErrorECOGEN("getTransferMode not available for requested output format");
235 }
236 catch (ErrorECOGEN&) {
237 throw;
238 }
239 return nullptr;
240 }
241
242 const std::string& getFolderOutput() { return m_folderOutput; }
243 const TypeOutput& getType() const { return m_type; };
244 bool getReducedOutput() const { return m_reducedOutput; };
245
246 std::string outputPhaseName(int phase, std::string phaseName, std::string& eosName) const
247 {
248 return "F" + std::to_string(phase) + "_" + phaseName + eosName;
249 }
250
251 protected:
252 //General data
253 void printWritingInfo() const;
254 void saveInfos() const;
255 std::string createFilename(const char* name, int lvl = -1, int proc = -1, int numFichier = -1) const;
256
257 void writeDataset(std::vector<double> dataset, std::ofstream& fileStream, TypeData typeData) const;
258 void getDataset(std::istringstream& data, std::vector<double>& dataset) const;
259
263
264 //Attributes names file/folder
265 std::string m_simulationName;
266 std::string m_infoCalcul;
267 std::string m_treeStructure;
269 std::string m_fileNameResults;
273 std::string m_folderOutput;
274 std::string m_folderSavesInput;
275 std::string m_folderDatasets;
276 std::string m_folderInfoMesh;
277 std::string m_folderCuts;
278 std::string m_folderProbes;
280 std::string m_folderBoundaries;
284
285 //Attributes of print parameters
290
292 std::string m_endianMode;
294
295 //Useful to print cell data
297};
298
299#endif //OUTPUT_H
TypeOutput
Enumeration for the type of output (GNU, VTK, VTKDF).
Definition Tools.h:57
TypeData
Enumeration for the type of data (FLOAT, DOUBLE, INT, CHAR).
Definition Tools.h:73
std::vector< Type > TypeMeshContainer
Template for the type of the mesh container (std::list for now, but may change to something else if w...
Definition Tools.h:194
Base class for a mesh cell.
Definition Cell.h:59
Definition Errors.h:120
Definition Input.h:55
Abstract class for a mesh.
Definition Mesh.h:55
Definition Output.h:54
virtual void readTree(Mesh *mesh, TypeMeshContainer< Cell * > *cellsLvl, TypeMeshContainer< Cell * > *cellsLvlGhost, TypeMeshContainer< CellInterface * > *cellInterfacesLvl, const std::vector< AddPhys * > &addPhys, int &nbCellsTotalAMR)
Read 'meshInfo' file that stores for each cell its subdivision status (1 if subdivided,...
Definition Output.cpp:311
virtual void prepareErrorFiles() const
Definition Output.cpp:686
std::string m_folderOutput
Folder to store results.
Definition Output.h:273
virtual Cell * locateProbeInAMRSubMesh(std::vector< Cell * > *, const int &)
Definition Output.h:90
std::string m_folderBoundaries
Boundaries flux results folder location.
Definition Output.h:280
const std::string & getFolderOutput()
Definition Output.h:242
const TypeOutput & getType() const
Definition Output.h:243
void writeDataset(std::vector< double > dataset, std::ofstream &fileStream, TypeData typeData) const
Definition Output.cpp:404
virtual void probeDisplacement(const double &)
Definition Output.h:79
int m_precision
Output files precision (number of digits) for GNU and VTK outputs //default: 6.
Definition Output.h:288
virtual double getNextTime()
Definition Output.h:210
std::string m_fileNameResults
Filename of result file.
Definition Output.h:269
void readDomainDecompostion(Mesh *mesh)
Definition Output.cpp:294
std::string m_infoCalcul
Filename to save useful info of computation.
Definition Output.h:266
int m_numFile
Definition Output.h:291
virtual void printTree(Mesh *mesh, const std::vector< Cell * > *cellsLvl, int m_resumeAMRsaveFreq) const
Write 'meshInfo' file that stores for each cell its subdivision status (1 if subdivided,...
Definition Output.cpp:261
std::string m_fileCollectionParaview
Chemin du file collection regroupant les fichiers resultats (for Paraview).
Definition Output.h:281
Output()
Default constructor for specific output without specific needs.
Definition Output.cpp:40
Cell m_cellRef
Reference cell to extract variables name.
Definition Output.h:296
std::string m_treeStructure
Filename for tree structure backup.
Definition Output.h:267
std::string m_filenameCollectionParaview
Name of the collection containing the results files (for Paraview).
Definition Output.h:270
void printWritingInfo() const
Definition Output.cpp:524
std::string m_endianMode
Definition Output.h:292
void saveInfos() const
Definition Output.cpp:538
virtual ~Output()
Definition Output.cpp:162
virtual void initializeSpecificOutput(std::vector< CellInterface * > *)
Definition Output.h:143
virtual void initializeSpecificOutput()
Definition Output.h:134
virtual void writeProgress()
Definition Output.cpp:391
Run * m_run
Pointer to run.
Definition Output.h:261
int getNumFile() const
Definition Output.h:209
virtual void readResults(Mesh *, std::vector< Cell * > *, int=-1)
Read results of a previous simulation to resume from it.
Definition Output.h:164
void initializeOutputMeshMapping(const Cell &cell)
To initialize output for Mesh Mapping Restart.
Definition Output.cpp:226
bool getReducedOutput() const
Definition Output.h:244
TypeOutput m_type
Type of output.
Definition Output.h:262
std::string m_filenameVTKHDFTimeseries
Name of the timeseries file containing the list of result files at vtkhdf format (for Paraview).
Definition Output.h:272
void readTree_common(Mesh *mesh, TypeMeshContainer< Cell * > *cellsLvl, TypeMeshContainer< Cell * > *cellsLvlGhost, TypeMeshContainer< CellInterface * > *cellInterfacesLvl, const std::vector< AddPhys * > &addPhys, int &lvl)
Refine ghost cells, update of persistent communications of cells lvl + 1, reconstruct arrays of cells...
Definition Output.cpp:347
bool m_writeBinary
Choice to write binary/ASCII (available for GNU and VTK outputs, GNU format only supports ASCII).
Definition Output.h:286
virtual void writeErrorInFile(std::vector< Errors > &v, const int &ErrorType, const int &iteration, bool &warn) const
Definition Output.cpp:701
std::string outputPhaseName(int phase, std::string phaseName, std::string &eosName) const
Definition Output.h:246
std::string m_folderCuts
Cuts results folder location.
Definition Output.h:277
void copyInputFiles() const
Definition Output.cpp:166
std::string m_folderDatasets
Folder to save the datasets.
Definition Output.h:275
std::string createFilename(const char *name, int lvl=-1, int proc=-1, int numFichier=-1) const
Definition Output.cpp:669
virtual void writeResults(Mesh *, std::vector< Cell * > *)
Definition Output.h:106
std::string m_folderGlobalQuantities
Global quantity (e.g. mass) results folder location.
Definition Output.h:279
virtual bool possesses()
Definition Output.h:220
Input * m_input
Pointer to input.
Definition Output.h:260
void initializeOutput(const Cell &cell)
Definition Output.cpp:183
std::string m_filenameCollectionVisIt
Name of the collection containing the results files (for VisIt).
Definition Output.h:271
virtual void locateProbeInMesh(const TypeMeshContainer< Cell * > &, const int &, bool=false)
Definition Output.h:81
std::string m_domainDecomposition
Filename for domain decomposition backup.
Definition Output.h:268
virtual const void * getTransferMode() const
Get m_transfer_mode field. For OutputVTKHDF derived class only.
Definition Output.h:231
int readNbCpu()
Read and return the number of cpu from the infoCalcul file of a performed simulation.
Definition Output.cpp:646
int m_nbCpusRestarted
Number of CPUs of the simulation to be restarted.
Definition Output.h:293
virtual void initializeOutputInfos()
Definition Output.cpp:244
std::string m_simulationName
Test case name (defined in "main.xml").
Definition Output.h:265
std::string m_folderErrorsAndWarnings
File path for errors and warnings.
Definition Output.h:283
std::string m_folderSavesInput
Folder to store a copy of input files.
Definition Output.h:274
std::string m_folderProbes
Probes results folder location.
Definition Output.h:278
void readInfos()
Currently only used for OutputBoundaryMassflowGNU.
Definition Output.cpp:579
bool m_reducedOutput
Choice of reduced number of output variables when possible (depends on the model).
Definition Output.h:289
bool m_splitData
Choice print data in separate files.
Definition Output.h:287
std::string m_folderInfoMesh
Folder to store mesh info.
Definition Output.h:276
virtual void writeResults(std::vector< CellInterface * > *)
Definition Output.h:115
void getDataset(std::istringstream &data, std::vector< double > &dataset) const
Definition Output.cpp:468
std::string m_fileCollectionVisIt
Chemin du file collection regroupant les fichiers resultats (for VisIt).
Definition Output.h:282
virtual void writeInfos()
Definition Output.cpp:382
Class regrouping all information for a simulation.
Definition Run.h:63
Definition tinyxml2.h:1148