Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
ExporterParaView_decl.hpp
1#ifndef ExporterParaView_DECL_hpp
2#define ExporterParaView_DECL_hpp
3
4#include <fstream>
5#include "feddlib/core/FEDDCore.hpp"
6#include "feddlib/core/General/DefaultTypeDefs.hpp"
7#include "feddlib/core/LinearAlgebra/MultiVector.hpp"
8#include "feddlib/core/Mesh/Mesh.hpp"
9// Trilinos
10#include <Teuchos_Array.hpp>
11
12#include <Epetra_ConfigDefs.h>
13#ifdef HAVE_MPI
14#include <mpi.h>
15#include <Epetra_MpiComm.h>
16#include <Epetra_SerialComm.h>
17#else
18#include <Epetra_SerialComm.h>
19#endif
20
21#include <Epetra_Map.h>
22#include <Epetra_MultiVector.h>
23#include <Epetra_Vector.h>
24#include <Epetra_LongLongVector.h>
25#include <Epetra_IntVector.h>
26
27#include <EpetraExt_HDF5.h>
28#include <hdf5.h>
29
41
42namespace FEDD {
43template <class SC = default_sc, class LO = default_lo, class GO = default_go, class NO = default_no>
44class ExporterParaView {
45public:
46 typedef std::vector<double> vec_dbl;
47 typedef std::vector<std::vector<double> > vec2D_dbl;
48 typedef std::vector<std::vector<int> > vec2D_int;
49 typedef std::vector<std::vector<long long> > vec2D_longlong;
50 typedef Teuchos::RCP<std::vector<int> > vec_int_ptr;
51 typedef Teuchos::RCP<std::vector<long long> > vec_longlong_ptr;
52 typedef Teuchos::RCP<vec_dbl> vec_dbl_ptr;
53 typedef Teuchos::RCP<std::vector<std::vector<double> > > vec2D_dbl_ptr;
54 typedef Teuchos::RCP<std::vector<std::vector<int> > > vec2D_int_ptr;
55 typedef Teuchos::RCP<vec2D_longlong > vec2D_longlong_ptr;
56 typedef Teuchos::RCP<Epetra_Vector> EpetraVec_ptr;
57 typedef Teuchos::RCP<Epetra_MpiComm> EpetraComm_ptr;
58 typedef Teuchos::RCP<Epetra_IntVector> EpetraVecInt_ptr;
59 typedef Teuchos::RCP<Epetra_LongLongVector> EpetraVecLongLong_ptr;
60 typedef Teuchos::RCP<Epetra_MultiVector> EpetraMVPtr_Type;
61 typedef Teuchos::RCP<Epetra_Map> EpetraMapPtr_Type;
62
63 typedef MultiVector<SC,LO,GO,NO> MultiVector_Type;
64 typedef Teuchos::RCP<MultiVector_Type> MultiVectorPtr_Type;
65 typedef Teuchos::RCP<const MultiVector_Type> MultiVectorConstPtr_Type;
66
67
68 typedef EpetraExt::HDF5 HDF5_Type;
69 typedef Teuchos::RCP<HDF5_Type> HDF5Ptr_Type;
70
71 typedef Teuchos::Comm<int> Comm_Type;
72 typedef Teuchos::RCP<const Comm_Type> CommConstPtr_Type;
73 typedef const Teuchos::RCP<const Comm_Type> CommConstPtrConst_Type;
74
75 typedef Map<LO,GO,NO> Map_Type;
76 typedef Teuchos::RCP<const Map_Type> MapConstPtr_Type;
77 typedef const MapConstPtr_Type MapConstPtrConst_Type;
78
79 typedef MultiVector<SC,LO,GO,NO> MultiVec_Type;
80 typedef Teuchos::RCP<const MultiVec_Type> MultiVecConstPtr_Type;
81 typedef const MultiVecConstPtr_Type MultiVecConstPtrConst_Type;
82
83 typedef Mesh<SC,LO,GO,NO> Mesh_Type;
84 typedef Teuchos::RCP<Mesh_Type> MeshPtr_Type;
85
86 typedef typename Mesh_Type::ElementsPtr_Type ElementsPtr_Type;
87
88 ExporterParaView();
89
90 void setup(std::string filename,
91 MeshPtr_Type mesh,
92 std::string FEType,
93 ParameterListPtr_Type parameterList=Teuchos::null);
94
95 void setup(std::string filename,
96 MeshPtr_Type mesh,
97 std::string FEType,
98 int saveTimestep,
99 ParameterListPtr_Type parameterList=Teuchos::null);
100
101// void setup(int dim,
102// GO nmbElementsGlob,
103// vec2D_int_ptr elements,
104// vec2D_dbl_ptr pointsUni,
105// MapConstPtrConst_Type& mapUnique,
106// MapConstPtrConst_Type& mapRepeated,
107// std::string FEType,
108// std::string filename,
109// CommConstPtrConst_Type &comm,
110// ParameterListPtr_Type parameterList=Teuchos::null);
111//
112// void setup(int dim,
113// GO nmbElementsGlob,
114// vec2D_int_ptr elements,
115// vec2D_dbl_ptr pointsUni,
116// MapConstPtrConst_Type& mapUnique,
117// MapConstPtrConst_Type& mapRepeated,
118// std::string FEType,
119// std::string filename,
120// int saveTimestep,
121// CommConstPtrConst_Type &comm,
122// ParameterListPtr_Type parameterList=Teuchos::null);
123
124
125 void addVariable(MultiVecConstPtr_Type &u,
126 std::string varName,
127 std::string varType,
128 int dofPerNode,
129 MapConstPtrConst_Type& mapUnique=Teuchos::null);
130
131 void save(double time);
132
133 void save(double time, double dt);
134
135 void closeExporter();
136
137 void writeVariablesHDF5();
138
139 void initHDF5();
140
141 void writeMeshElements( std::string nameConn );
142
143 void writeMeshPointsHDF5();
144
145 void writeMeshPoints(std::string nameP_X,
146 std::string nameP_Y,
147 std::string nameP_Z );
148
149 void updatePoints();
150
151
152 void initXmf();
153
154 void initXmfTimes();
155
156 void writeXmf(double time);
157
158 void writeXmfElements(std::string nameConn, double time);
159
160 void writeXmfPoints(std::string nameP_X,
161 std::string nameP_Y,
162 std::string nameP_Z);
163
164 void writeXmfVariables();
165
166 void writeXmfTime(double time, double dt);
167
168 void prepareVectorField(MultiVecConstPtr_Type &u,
169 EpetraMVPtr_Type &u_export,
170 int dof) const;
171
172 void prepareScalar(MultiVecConstPtr_Type &u,
173 EpetraMVPtr_Type &u_export) const;
174
175 void makePostfix();
176
177protected:
178
179 HDF5Ptr_Type hdf5exporter_;
180 CommConstPtr_Type comm_;
181 Teuchos::RCP<Epetra_MpiComm> commEpetra_;
182
183 std::streampos closingLinesPosition_;
184 std::streampos closingLinesPositionTimes_;
185 std::string closingLines_;
186 std::ofstream xmf_out_;
187 std::ofstream xmf_times_out_;
188 std::string filename_;
189 std::string outputFilename_;
190 std::string postfix_;
191 std::string FEType_;
192
193
194 std::vector<MultiVecConstPtr_Type> variables_;
195 std::vector<EpetraMapPtr_Type > uniqueMaps_;
196 std::vector<std::string> varNames_;
197 std::vector<std::string> varTypes_;
198 std::vector<int> varDofPerNode_;
199 EpetraMVPtr_Type pointsHDF_;
200 EpetraVecInt_ptr elementsHDF_;
201
202 UN dim_;
203 GO nmbElementsGlob_;
204 GO nmbPointsGlob_;
205 GO nmbExportValuesGlob_;
206 int nmbPointsPerElement_;
207 int timeIndex_;
208 bool writeDt_;
209 int saveTimestep_;
210 bool verbose_;
211 ParameterListPtr_Type parameterList_;
212 vec2D_dbl_ptr pointsUnique_;
213
214 bool redo_ = false;
215 MeshPtr_Type mesh_;
216 MapConstPtr_Type mapUniqueVariables_;
217
218 };
219}
220
221#endif
Definition Map_decl.hpp:36
Definition Mesh_decl.hpp:25
Definition MultiVector_decl.hpp:36
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5