Line |
Branch |
Exec |
Source |
1 |
|
|
// ______ ______ _ _ _____ ______ |
2 |
|
|
// | ____| ____| | (_)/ ____| | ____| |
3 |
|
|
// | |__ | |__ | | _| (___ ___| |__ |
4 |
|
|
// | __| | __| | | | |\___ \ / __| __| |
5 |
|
|
// | | | |____| |____| |____) | (__| |____ |
6 |
|
|
// |_| |______|______|_|_____/ \___|______| |
7 |
|
|
// Finite Elements for Life Sciences and Engineering |
8 |
|
|
// |
9 |
|
|
// License: LGL2.1 License |
10 |
|
|
// FELiScE default license: LICENSE in root folder |
11 |
|
|
// |
12 |
|
|
// Main authors: J.Castelneau & J.Foulon |
13 |
|
|
// |
14 |
|
|
|
15 |
|
|
#ifndef IO_HPP |
16 |
|
|
#define IO_HPP |
17 |
|
|
|
18 |
|
|
// System includes |
19 |
|
|
|
20 |
|
|
// External includes |
21 |
|
|
|
22 |
|
|
// Project includes |
23 |
|
|
#include "Geometry/geometricMeshRegion.hpp" |
24 |
|
|
#include "InputOutput/medit.hpp" |
25 |
|
|
#include "InputOutput/ensight.hpp" |
26 |
|
|
|
27 |
|
|
namespace felisce |
28 |
|
|
{ |
29 |
|
|
|
30 |
|
|
enum class MeditVersion {DEV = 0, STABLE = 1}; |
31 |
|
|
|
32 |
|
|
/** |
33 |
|
|
* @class IO |
34 |
|
|
* @authors J.Castelneau & J.Foulon |
35 |
|
|
* @date 13/05/2010 |
36 |
|
|
* @brief Class managing Input and output format (Ensight, Medit, ..) |
37 |
|
|
*/ |
38 |
|
|
class IO |
39 |
|
|
{ |
40 |
|
|
private: |
41 |
|
|
std::string m_inputDirectory; |
42 |
|
|
std::string m_inputFile; //! input data file |
43 |
|
|
std::string m_inputMesh; |
44 |
|
|
std::string m_outputMesh; |
45 |
|
|
std::string m_meshDir; |
46 |
|
|
std::string m_resultDir; |
47 |
|
|
std::string m_prefixName; |
48 |
|
|
//!<Ensight object to read/write mesh with ensight format |
49 |
|
|
Ensight m_ens; |
50 |
|
|
//!<Medit object to read/write mesh with medit format |
51 |
|
|
Medit m_med; |
52 |
|
|
public: |
53 |
|
|
/// Pointer definition of IO |
54 |
|
|
FELISCE_CLASS_POINTER_DEFINITION(IO); |
55 |
|
|
|
56 |
|
|
/// Assigning stable version |
57 |
|
|
static constexpr MeditVersion MEDIT_VERSION = MeditVersion::STABLE; |
58 |
|
|
|
59 |
|
|
int typeInput; // 0 : medit, 1: ensight |
60 |
|
|
int typeOutput; // 0 : medit 1: ensight |
61 |
|
|
IO(); |
62 |
|
|
IO(const std::string& inputDirectory, const std::string& inputFile, const std::string& inputMesh, |
63 |
|
|
const std::string& outputMesh, const std::string& meshDir, const std::string& resultDir, const std::string& prefixName); |
64 |
|
1055 |
~IO() = default; |
65 |
|
|
|
66 |
|
|
//! Copy constructor, to avoid warning due to user-declared destructor. |
67 |
|
|
IO(const IO&) = default; |
68 |
|
|
|
69 |
|
|
void initialize(const std::string& inputDirectory, const std::string& inputFile, const std::string& inputMesh, |
70 |
|
|
const std::string& outputMesh, const std::string& meshDir, const std::string& resultDir, const std::string& prefixName); |
71 |
|
|
void initializeOutput(); |
72 |
|
|
//!<read mesh |
73 |
|
|
void readMesh(GeometricMeshRegion& mesh, double spaceUnit); |
74 |
|
|
//!<write mesh |
75 |
|
|
void writeMesh(GeometricMeshRegion& mesh, std::string nameOfGeoFile=""); |
76 |
|
|
//!<write local mesh localize in the rank-th processor |
77 |
|
|
void writeOutput(GeometricMeshRegion& mesh, int rank); |
78 |
|
|
|
79 |
|
|
void addVariable(const EnsightVariable::TypeVar& type, const std::string nameVariable, |
80 |
|
|
const double* solution, const felInt size, bool manageMemory=false); |
81 |
|
|
|
82 |
|
✗ |
Ensight& ensight() { |
83 |
|
✗ |
return m_ens; |
84 |
|
|
} |
85 |
|
|
Medit& medit() { |
86 |
|
|
return m_med; |
87 |
|
|
} |
88 |
|
|
|
89 |
|
|
void readInputFile(); |
90 |
|
|
void readVariable(int idVariable, double time, |
91 |
|
|
double* valueOfVariable, felInt size); |
92 |
|
|
void postProcess(double& time, int flagMultipleCase=false); |
93 |
|
|
|
94 |
|
|
// write a file which contains solution in Medit or Ensight format (actually), Jeremie 03/08/2012 |
95 |
|
|
void writeSolution(int rankProc, double& time, int iteration, const int & typeVariable, const std::string& nameVariable, const double* solution, |
96 |
|
|
felInt size, int dimension, bool manageMemory=false); |
97 |
|
|
|
98 |
|
|
|
99 |
|
|
}; |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
#endif |
103 |
|
|
|