FileWriter.h 7.02 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
 * Authors: 
 * Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 *
 * This file is part of AMDiS
 *
 * See also license.opensource.txt in the distribution.
 * 
 ******************************************************************************/
20
21


22
23
24
25
26
27
28
29
30
31

/** \file FileWriter.h */

/** \defgroup Output Output module
 * @{ <img src="output.png"> @}
 */

#ifndef AMDIS_FILEWRITER_H
#define AMDIS_FILEWRITER_H

32
#include <vector>
33
#include <string>
Thomas Witkowski's avatar
Thomas Witkowski committed
34
#include "AMDiS_fwd.h"
35
#include "FileWriterInterface.h"
36
#include "Mesh.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
37
#include "DataCollector.h"
38
#include "FileCompression.h"
39
40

namespace AMDiS {
41
42
  
  namespace detail
43
  {
44
45
46
47
48
49
50
51
52
53

    /**  
    * \ingroup Output
    *
    * \brief
    * Base class of FileWriterScal and FileWriterVec. Manages the file
    * output of solution vectors.
    */
    template<typename T>
    class FileWriter : public ::AMDiS::FileWriterInterface
54
    {
55
56
    typedef ::AMDiS::FileWriterInterface super;
    
57
58
59
60
61
62
    public:
      /// Constructor for a filewriter for one data component.
      FileWriter(std::string name, Mesh *mesh, DOFVector<T> *vec);

      /// Constructor for a filewriter with more than one data component.
      FileWriter(std::string name,
Praetorius, Simon's avatar
Praetorius, Simon committed
63
64
65
66
		  Mesh *mesh,
		  std::vector< DOFVector<T>* > vecs,
		  std::vector< std::string > componentNames = std::vector< std::string >()
		);
67
68
69

      /// Constructor for a filewriter with more than one data component.
      FileWriter(std::string name,
70
71
		 Mesh *mesh,
		 SystemVector *vecs);
72
73
74
75
76
77
78
79
      
      /// Destructor
      virtual ~FileWriter();

      /// Implementation of FileWriterInterface::writeFiles().
      virtual void writeFiles(AdaptInfo *adaptInfo, bool force,
			      int level = -1,
			      Flag traverseFlag = Mesh::CALL_LEAF_EL,
80
			      bool (*writeElem)(ElInfo*) = NULL) override;
81
82
83
84
85
    
      std::vector<std::pair<double, std::string> >& getParaviewAnimationFrames()
      {
	return paraviewAnimationFrames;
      }
Siqi Ling's avatar
Siqi Ling committed
86
87
88
89
90
      
      std::vector<double>& getArhAnimationFrames()
      {
	return arhAnimationFrames;
      }
91

92
93
94
95
96
97
98
99
100
101
102
      bool getWriteParaViewFormat() const 
      { 
	return writeParaViewFormat;
      }
      
      std::string getParaViewFilename(AdaptInfo* info) const;
      
      const std::vector<std::string>& getSolutionNames() const 
      { 
	return solutionNames; 
      }
103

104
105
106
    protected:
      /// Initialization of the filewriter.
      void initialize();
107

108
      /// Reads all file writer dependend parameters from the init file.
109
      virtual void readParameters(std::string name) override;
110
111
112
      
      /// Multi mesh flag
      bool multiMesh;
113

114
115
      /// Name of the writer.
      std::string name;
116

117
118
      /// AMDiS mesh-file extension.
      std::string amdisMeshExt;
119

120
121
      /// AMDiS solution-file extension.
      std::string amdisDataExt;
122

123
124
      /// VTK file extension.
      std::string paraviewFileExt;
Thomas Witkowski's avatar
Thomas Witkowski committed
125

126
127
      /// Parallel VTK file extension.
      std::string paraviewParallelFileExt;
128
129
130
131
132
133
      
      /// Parallel ARH file extension.
      std::string arhParallelFileExt;
      
      /// Time ARH file extension.
      std::string arhTimeFileExt;
134

135
136
      /// Periodic file extension.
      std::string periodicFileExt;
137

138
139
      /// 0: Don't write AMDiS files; 1: Write AMDiS files. 
      int writeAMDiSFormat;
140

141
142
      /// 0: Don't write ParaView files; 1: Write ParaView files.
      int writeParaViewFormat;
143
144
145
146
147
148
      
      /// 0: ASCII mode; 1: Appended mode; 2:Appended_compressed mode.
      int paraViewMode;
      
      /// 0: FLOAT32 precision; 1: FLOAT64 precision. Only works in appended and appended_compressed mode.
      int paraViewPrecision;
149

150
151
      /// 0: Don't write ParaView std::vector files; 1: Write ParaView std::vector files.
      int writeParaViewVectorFormat;
152

153
154
      /// 1: extend number of component to 3, so that paraview can display the std::vector as worldstd::vector
      bool writeAs3dVector;
155

156
157
      /// 0: Don't write ParaView animation file; 1: Write ParaView animation file.
      int writeParaViewAnimation;
158

159
160
      /// 0: Don't write periodic files; 1: Write periodic files.
      int writePeriodicFormat;
161

162
163
      /// 0: Don't write png files; 1: Write png image files.
      int writePngFormat;
164

165
166
      /// 0: Gray color picture; 1: RGB picture.
      int pngType;
167

168
169
      /// 0: Don't write Povray scripts; 1: Write Povray scripts
      int writePovrayFormat;
Thomas Witkowski's avatar
Thomas Witkowski committed
170

171
172
      /// 0: Don't write DOF files; 1: Write DOF files
      int writeDofFormat;
Thomas Witkowski's avatar
Thomas Witkowski committed
173

Siqi Ling's avatar
Siqi Ling committed
174
      /// if write latest ARH files
175
      int writeArhFormat;
176

Siqi Ling's avatar
Siqi Ling committed
177
178
179
180
181
182
183
184
      /// write Arh2, prior to writeArhFormat
      int writeArh1;
      
      /// write Arh2 version 2.1,  prior to writeArhFormat
      int writeArh2;
      
      /// write Arh2 version 3.0,  prior to writeArhFormat
      int writeArh3;
Siqi Ling's avatar
Siqi Ling committed
185
186
187
      
      /// 0: Don't write Arh animation file; 1: Write Arh animation file.
      int writeArhAnimation;
Thomas Witkowski's avatar
Thomas Witkowski committed
188

189
190
      /// camera position for povray script files
      std::string povrayCameraLocation;
Thomas Witkowski's avatar
Thomas Witkowski committed
191

192
193
      /// orientation for camera in povray script files
      std::string povrayCameraLookAt;
Thomas Witkowski's avatar
Thomas Witkowski committed
194

195
196
      /// name of the template file that will be prepended to all created *.pov files 
      std::string povrayTemplate;
197

198

199
200
201
      /// Stores a set of std::pairs of timepoint and filename to write a ParaView 
      /// animation file.
      std::vector<std::pair<double, std::string> > paraviewAnimationFrames;
Siqi Ling's avatar
Siqi Ling committed
202
203
204
      
      /// Stores a set of timepoint to write a ParaView animation file.
      std::vector<double> arhAnimationFrames;
205

206
207
      ///
      int timestepNumber;
208

209
210
      /// Mesh used for output.
      Mesh *mesh;
211

212
213
      /// fespace used for output.
      const FiniteElemSpace *feSpace;
214

215
216
      /// Pointers to the std::vectors which store the solution.
      std::vector<DOFVector<T>*> solutionVecs;
Praetorius, Simon's avatar
Praetorius, Simon committed
217
218
219
      
      /// Names of the DOFVectors
      std::vector<std::string> solutionNames;
Thomas Witkowski's avatar
Thomas Witkowski committed
220

221
222
223
224
225
226
227
228
229
230
231
232
233
      /** \brief
      * Stores the number of temporal solutions std::vectors, which have been created
      * in the constructor. If this number is greater than zero, the std::vectors
      * stored in solutionVecs_ must be deleted in the destructor.
      */
      int nTmpSolutions;

      /** \brief
      * Defines if, and with what kind of compression, the file should be compressed
      * during writing.
      */
      FileCompression compression;
    };
234

235
236
237
238
239
240
241
242
243
244
245
246
247
    template<>
    FileWriter<double>::FileWriter(std::string name_,
			  Mesh *mesh_,
			  SystemVector *vecs);

    template<>
    void FileWriter<double>::writeFiles(AdaptInfo *adaptInfo,
				bool force,
				int level,
				Flag flag,
				bool (*writeElem)(ElInfo*));
    
  } // end namespace detail
Praetorius, Simon's avatar
Praetorius, Simon committed
248
  
249
250
  typedef detail::FileWriter<double> FileWriter;
  typedef detail::FileWriter<WorldVector<double> > FileVectorWriter;
251
252
}

253
254
#include "FileWriter.hh"

255
#endif // AMDIS_FILEWRITER_H