ECOGEN 4.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>
43#include "../libTierces/tinyxml2.h"
44#include "../Errors.h"
45#include "../Meshes/HeaderMesh.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 locateProbeInMesh(const TypeMeshContainer<Cell*>& /*cells*/, const int& /*nbCells*/, bool /*localSeeking*/ = false) { try { throw ErrorECOGEN("locateProbeInMesh not available for requested output format"); } catch (ErrorECOGEN&) { throw; } };
80 virtual Cell* locateProbeInAMRSubMesh(std::vector<Cell*>* /*cells*/, const int& /*nbCells*/) { try { throw ErrorECOGEN("locateProbeInMesh not available for requested output format"); } catch (ErrorECOGEN&) { throw; } return 0; };
81
82 void copyInputFiles() const;
83 void initializeOutput(const Cell& cell);
84 void initializeOutput(std::vector<CellInterface*>* cellInterfacesLvl);
85 void initializeOutputMeshMapping(const Cell& cell);
86 virtual void initializeOutputInfos();
87 virtual void writeResults(Mesh* /*mesh*/, std::vector<Cell*>* /*cellsLvl*/) { try { throw ErrorECOGEN("writeResults not available for requested output format"); } catch (ErrorECOGEN&) { throw; }};
88 virtual void writeResults(std::vector<CellInterface*>* /*cellInterfacesLvl*/) { try { throw ErrorECOGEN("writeResults not available for requested output format"); } catch (ErrorECOGEN&) { throw; } };
89 void printTree(Mesh* mesh, std::vector<Cell*>* cellsLvl, int m_restartAMRsaveFreq);
90 virtual void writeInfos();
91 virtual void writeProgress();
92 void saveInfoCells() const;
93
94 virtual void initializeSpecificOutput() { try { throw ErrorECOGEN("initializeSpecificOutput not available for requested output format"); } catch (ErrorECOGEN&) { throw; } };
95 virtual void initializeSpecificOutput(std::vector<CellInterface*>* /*cellInterfacesLvl*/) { try { throw ErrorECOGEN("initializeSpecificOutput not available for requested output format"); } catch (ErrorECOGEN&) { throw; } };
96
99 void readInfos();
101 int readNbCpu();
106 virtual void readResults(Mesh* /*mesh*/, std::vector<Cell*>* /*cellsLvl*/) { try { throw ErrorECOGEN("readResults not available for requested output format"); } catch (ErrorECOGEN&) { throw; } };
112 virtual void readResultsCpu(Mesh* /*mesh*/, std::vector<Cell*>* /*cellsLvl*/, int /*cpu*/) { try { throw ErrorECOGEN("readResultsCpu not available for requested output format"); } catch (ErrorECOGEN&) { throw; } };
113 void readDomainDecompostion(Mesh* mesh);
114 void readTree(Mesh *mesh, TypeMeshContainer<Cell*>* cellsLvl, TypeMeshContainer<Cell*>* cellsLvlGhost, TypeMeshContainer<CellInterface*>* cellInterfacesLvl,
115 const std::vector<AddPhys*>& addPhys, int& nbCellsTotalAMR);
116
117 //Accessor
118 int getNumFile() const { return m_numFichier; };
119 virtual double getNextTime() { try { throw ErrorECOGEN("getNextTime not available for requested output format"); } catch (ErrorECOGEN&) { throw; } return 0.; }
120 virtual bool possesses() { try { throw ErrorECOGEN("possesses not available for requested output format"); } catch (ErrorECOGEN&) { throw; } return false; };
121 const std::string& getFolderOutput(){ return m_folderOutput;}
122 const TypeOutput& getType() const { return m_type; };
123 bool getReducedOutput() const { return m_reducedOutput; };
124
125 protected:
126
127 //General data
128 void printWritingInfo() const;
129 void saveInfos() const;
130 std::string createFilename(const char* name, int lvl = -1, int proc = -1, int numFichier = -1) const;
131
132 void writeDataset(std::vector<double> dataset, std::ofstream& fileStream, TypeData typeData);
133 void getDataset(std::istringstream& data, std::vector<double>& dataset);
134
138
139 //Attributes names file/folder
140 std::string m_simulationName;
141 std::string m_infoCalcul;
142 std::string m_infoMesh;
143 std::string m_treeStructure;
145 std::string m_fileNameResults;
148 std::string m_folderOutput;
149 std::string m_folderSavesInput;
150 std::string m_folderDatasets;
151 std::string m_folderInfoMesh;
152 std::string m_folderCuts;
153 std::string m_folderProbes;
155 std::string m_folderBoundaries;
159
160 //Attributes of print parameters
165
167 std::string m_endianMode;
169
170 //Useful to print cell data
172};
173
174#endif //OUTPUT_H
TypeOutput
Enumeration for the type of output (GNU, XML)
Definition Tools.h:45
TypeData
Enumeration for the type of data (FLOAT, DOUBLE, INT, CHAR)
Definition Tools.h:51
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:83
Base class for a mesh cell.
Definition Cell.h:59
Definition Errors.h:114
Definition Input.h:55
Abstract class for a mesh.
Definition Mesh.h:53
Definition Output.h:54
void readTree(Mesh *mesh, TypeMeshContainer< Cell * > *cellsLvl, TypeMeshContainer< Cell * > *cellsLvlGhost, TypeMeshContainer< CellInterface * > *cellInterfacesLvl, const std::vector< AddPhys * > &addPhys, int &nbCellsTotalAMR)
Definition Output.cpp:290
std::string m_folderOutput
Folder to store results.
Definition Output.h:148
virtual Cell * locateProbeInAMRSubMesh(std::vector< Cell * > *, const int &)
Definition Output.h:80
std::string m_folderBoundaries
Boundaries flux results folder location.
Definition Output.h:155
const std::string & getFolderOutput()
Definition Output.h:121
const TypeOutput & getType() const
Definition Output.h:122
void saveInfoCells() const
Definition Output.cpp:358
int m_precision
Output files precision (number of digits) //default: 0.
Definition Output.h:163
virtual double getNextTime()
Definition Output.h:119
std::string m_fileNameResults
Filename of result file.
Definition Output.h:145
void readDomainDecompostion(Mesh *mesh)
Definition Output.cpp:275
std::string m_infoCalcul
Filename to save useful info of computation.
Definition Output.h:141
void writeDataset(std::vector< double > dataset, std::ofstream &fileStream, TypeData typeData)
Definition Output.cpp:372
std::string m_fileCollectionParaview
Chemin du file collection regroupant les fichiers resultats (for Paraview)
Definition Output.h:156
Output()
Default constructor for specific output without specific needs.
Definition Output.cpp:39
virtual void readResults(Mesh *, std::vector< Cell * > *)
Read results of a previous simulation to restart from it.
Definition Output.h:106
Cell m_cellRef
Reference cell to extract variables name.
Definition Output.h:171
std::string m_treeStructure
Filename for tree structure backup.
Definition Output.h:143
std::string m_filenameCollectionParaview
Name of the collection containing the results files (for Paraview)
Definition Output.h:146
void printWritingInfo() const
Definition Output.cpp:480
std::string m_infoMesh
Filename of mesh info file.
Definition Output.h:142
std::string m_endianMode
Definition Output.h:167
void saveInfos() const
Definition Output.cpp:491
virtual ~Output()
Definition Output.cpp:159
virtual void initializeSpecificOutput(std::vector< CellInterface * > *)
Definition Output.h:95
virtual void readResultsCpu(Mesh *, std::vector< Cell * > *, int)
Read results of a single partition of a previous simulation to restart from it.
Definition Output.h:112
virtual void initializeSpecificOutput()
Definition Output.h:94
virtual void writeProgress()
Definition Output.cpp:346
Run * m_run
Pointer to run.
Definition Output.h:136
int getNumFile() const
Definition Output.h:118
void initializeOutputMeshMapping(const Cell &cell)
To initialize output for Mesh Mapping Restart.
Definition Output.cpp:211
bool getReducedOutput() const
Definition Output.h:123
TypeOutput m_type
Type of output.
Definition Output.h:137
bool m_writeBinary
Choice to write binary/ASCII.
Definition Output.h:161
std::string m_folderCuts
Cuts results folder location.
Definition Output.h:152
void copyInputFiles() const
Definition Output.cpp:163
std::string m_folderDatasets
Folder to save the datasets.
Definition Output.h:150
std::string createFilename(const char *name, int lvl=-1, int proc=-1, int numFichier=-1) const
Definition Output.cpp:588
virtual void writeResults(Mesh *, std::vector< Cell * > *)
Definition Output.h:87
std::string m_folderGlobalQuantities
Global quantity (e.g. mass) results folder location.
Definition Output.h:154
virtual bool possesses()
Definition Output.h:120
Input * m_input
Pointer to input.
Definition Output.h:135
int m_numFichier
Definition Output.h:166
void initializeOutput(const Cell &cell)
Definition Output.cpp:176
std::string m_filenameCollectionVisIt
Name of the collection containing the results files (for VisIt)
Definition Output.h:147
virtual void locateProbeInMesh(const TypeMeshContainer< Cell * > &, const int &, bool=false)
Definition Output.h:79
std::string m_domainDecomposition
Filename for domain decomposition backup.
Definition Output.h:144
int readNbCpu()
Read and return the number of cpu from the infoCalcul file of a performed simulation.
Definition Output.cpp:573
int m_nbCpusRestarted
Number of CPUs of the simulation to be restarted.
Definition Output.h:168
virtual void initializeOutputInfos()
Definition Output.cpp:225
std::string m_simulationName
Test case name (defined in "main.xml")
Definition Output.h:140
std::string m_folderErrorsAndWarnings
File path for errors and warnings.
Definition Output.h:158
std::string m_folderSavesInput
Folder to store a copy of input files.
Definition Output.h:149
std::string m_folderProbes
Probes results folder location.
Definition Output.h:153
void readInfos()
Currently only used for OutputBoundaryMassflowGNU.
Definition Output.cpp:524
bool m_reducedOutput
Choice of reduced number of output variables when possible (depends on the model)
Definition Output.h:164
bool m_splitData
Choice print data in separate files.
Definition Output.h:162
std::string m_folderInfoMesh
Folder to store mesh info.
Definition Output.h:151
virtual void writeResults(std::vector< CellInterface * > *)
Definition Output.h:88
void printTree(Mesh *mesh, std::vector< Cell * > *cellsLvl, int m_restartAMRsaveFreq)
Definition Output.cpp:244
void getDataset(std::istringstream &data, std::vector< double > &dataset)
Definition Output.cpp:426
std::string m_fileCollectionVisIt
Chemin du file collection regroupant les fichiers resultats (for VisIt)
Definition Output.h:157
virtual void writeInfos()
Definition Output.cpp:335
Class regrouping all information for a simulation.
Definition Run.h:63
Definition tinyxml2.h:1149