FileWriter.h 6.58 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
57
58
59
60
    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
61
62
63
64
		  Mesh *mesh,
		  std::vector< DOFVector<T>* > vecs,
		  std::vector< std::string > componentNames = std::vector< std::string >()
		);
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

      /// Constructor for a filewriter with more than one data component.
      FileWriter(std::string name,
			  Mesh *mesh,
			  SystemVector *vecs);
      
      /// Destructor
      virtual ~FileWriter();

      /// Implementation of FileWriterInterface::writeFiles().
      virtual void writeFiles(AdaptInfo *adaptInfo, bool force,
			      int level = -1,
			      Flag traverseFlag = Mesh::CALL_LEAF_EL,
			      bool (*writeElem)(ElInfo*) = NULL);
    
      std::vector<std::pair<double, std::string> >& getParaviewAnimationFrames()
      {
	return paraviewAnimationFrames;
      }
84

85
86
87
    protected:
      /// Initialization of the filewriter.
      void initialize();
88

89
90
      /// Reads all file writer dependend parameters from the init file.
      void readParameters();
91

92
93
      /// Name of the writer.
      std::string name;
94

95
96
      /// AMDiS mesh-file extension.
      std::string amdisMeshExt;
97

98
99
      /// AMDiS solution-file extension.
      std::string amdisDataExt;
100

101
102
      /// VTK file extension.
      std::string paraviewFileExt;
Thomas Witkowski's avatar
Thomas Witkowski committed
103

104
105
      /// Parallel VTK file extension.
      std::string paraviewParallelFileExt;
106

107
108
      /// Periodic file extension.
      std::string periodicFileExt;
109

110
111
      /// 0: Don't write AMDiS files; 1: Write AMDiS files. 
      int writeAMDiSFormat;
112

113
114
      /// 0: Don't write ParaView files; 1: Write ParaView files.
      int writeParaViewFormat;
115
116
117
118
119
120
      
      /// 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;
121

122
123
      /// 0: Don't write ParaView std::vector files; 1: Write ParaView std::vector files.
      int writeParaViewVectorFormat;
124

125
126
      /// 1: extend number of component to 3, so that paraview can display the std::vector as worldstd::vector
      bool writeAs3dVector;
127
128
129
      
      /// create a subdirectory where to put the vtu file
      bool createParaViewSubDir;
130

131
132
      /// 0: Don't write ParaView animation file; 1: Write ParaView animation file.
      int writeParaViewAnimation;
133

134
135
      /// 0: Don't write periodic files; 1: Write periodic files.
      int writePeriodicFormat;
136

137
138
      /// 0: Don't write png files; 1: Write png image files.
      int writePngFormat;
139

140
141
      /// 0: Gray color picture; 1: RGB picture.
      int pngType;
142

143
144
      /// 0: Don't write Povray scripts; 1: Write Povray scripts
      int writePovrayFormat;
Thomas Witkowski's avatar
Thomas Witkowski committed
145

146
147
      /// 0: Don't write DOF files; 1: Write DOF files
      int writeDofFormat;
Thomas Witkowski's avatar
Thomas Witkowski committed
148

149
150
      /// 0: Don't write ARH files; 1: Write ARH files
      int writeArhFormat;
151

152
153
      /// 0: Don't write ARH2 files; 1: Write ARH2 files
      int writeArh2Format;
Thomas Witkowski's avatar
Thomas Witkowski committed
154

155
156
      /// camera position for povray script files
      std::string povrayCameraLocation;
Thomas Witkowski's avatar
Thomas Witkowski committed
157

158
159
      /// orientation for camera in povray script files
      std::string povrayCameraLookAt;
Thomas Witkowski's avatar
Thomas Witkowski committed
160

161
162
      /// name of the template file that will be prepended to all created *.pov files 
      std::string povrayTemplate;
163

164
165
166
      /// 0: Don't append time index to filename prefix.
      /// 1: Append time index to filename prefix.
      int appendIndex;
167

168
169
      /// Total length of appended time index.
      int indexLength;
170

171
172
      /// Number of decimals in time index.
      int indexDecimals;
173

174
175
176
177
178
179
      /// Timestep modulo: write only every tsModulo-th timestep! 
      int tsModulo;
      
      /// Time modulo: write at first iteration after lastWriteTime + timeModulo
      double timeModulo;
      double lastWriteTime;
180

181
182
183
      /// Stores a set of std::pairs of timepoint and filename to write a ParaView 
      /// animation file.
      std::vector<std::pair<double, std::string> > paraviewAnimationFrames;
184

185
186
      ///
      int timestepNumber;
187

188
189
      /// Mesh used for output.
      Mesh *mesh;
190

191
192
      /// fespace used for output.
      const FiniteElemSpace *feSpace;
193

194
195
      /// Pointers to the std::vectors which store the solution.
      std::vector<DOFVector<T>*> solutionVecs;
Praetorius, Simon's avatar
Praetorius, Simon committed
196
197
198
      
      /// Names of the DOFVectors
      std::vector<std::string> solutionNames;
Thomas Witkowski's avatar
Thomas Witkowski committed
199

200
201
202
203
204
205
206
207
208
209
210
211
212
      /** \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;
    };
213

214
215
216
217
218
219
220
221
222
223
224
225
226
    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
227
  
228
229
  typedef detail::FileWriter<double> FileWriter;
  typedef detail::FileWriter<WorldVector<double> > FileVectorWriter;
230
231
}

232
233
#include "FileWriter.hh"

234
#endif // AMDIS_FILEWRITER_H