FileWriter.h 6.81 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
88
89
      bool getWriteParaViewFormat() const { return writeParaViewFormat; }
      std::string getParaViewFilename(AdaptInfo* info) const ;
      const std::vector< std::string >& getSolutionNames() const 
      { return solutionNames; }

90
91
92
    protected:
      /// Initialization of the filewriter.
      void initialize();
93

94
95
      /// Reads all file writer dependend parameters from the init file.
      void readParameters();
96

97
98
      /// Name of the writer.
      std::string name;
99

100
101
      /// AMDiS mesh-file extension.
      std::string amdisMeshExt;
102

103
104
      /// AMDiS solution-file extension.
      std::string amdisDataExt;
105

106
107
      /// VTK file extension.
      std::string paraviewFileExt;
Thomas Witkowski's avatar
Thomas Witkowski committed
108

109
110
      /// Parallel VTK file extension.
      std::string paraviewParallelFileExt;
111

112
113
      /// Periodic file extension.
      std::string periodicFileExt;
114

115
116
      /// 0: Don't write AMDiS files; 1: Write AMDiS files. 
      int writeAMDiSFormat;
117

118
119
      /// 0: Don't write ParaView files; 1: Write ParaView files.
      int writeParaViewFormat;
120
121
122
123
124
125
      
      /// 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;
126

127
128
      /// 0: Don't write ParaView std::vector files; 1: Write ParaView std::vector files.
      int writeParaViewVectorFormat;
129

130
131
      /// 1: extend number of component to 3, so that paraview can display the std::vector as worldstd::vector
      bool writeAs3dVector;
132
133
134
      
      /// create a subdirectory where to put the vtu file
      bool createParaViewSubDir;
135

136
137
      /// 0: Don't write ParaView animation file; 1: Write ParaView animation file.
      int writeParaViewAnimation;
138

139
140
      /// 0: Don't write periodic files; 1: Write periodic files.
      int writePeriodicFormat;
141

142
143
      /// 0: Don't write png files; 1: Write png image files.
      int writePngFormat;
144

145
146
      /// 0: Gray color picture; 1: RGB picture.
      int pngType;
147

148
149
      /// 0: Don't write Povray scripts; 1: Write Povray scripts
      int writePovrayFormat;
Thomas Witkowski's avatar
Thomas Witkowski committed
150

151
152
      /// 0: Don't write DOF files; 1: Write DOF files
      int writeDofFormat;
Thomas Witkowski's avatar
Thomas Witkowski committed
153

154
155
      /// 0: Don't write ARH files; 1: Write ARH files
      int writeArhFormat;
156

157
158
      /// 0: Don't write ARH2 files; 1: Write ARH2 files
      int writeArh2Format;
Thomas Witkowski's avatar
Thomas Witkowski committed
159

160
161
      /// camera position for povray script files
      std::string povrayCameraLocation;
Thomas Witkowski's avatar
Thomas Witkowski committed
162

163
164
      /// orientation for camera in povray script files
      std::string povrayCameraLookAt;
Thomas Witkowski's avatar
Thomas Witkowski committed
165

166
167
      /// name of the template file that will be prepended to all created *.pov files 
      std::string povrayTemplate;
168

169
170
171
      /// 0: Don't append time index to filename prefix.
      /// 1: Append time index to filename prefix.
      int appendIndex;
172

173
174
      /// Total length of appended time index.
      int indexLength;
175

176
177
      /// Number of decimals in time index.
      int indexDecimals;
178

179
180
181
182
183
184
      /// Timestep modulo: write only every tsModulo-th timestep! 
      int tsModulo;
      
      /// Time modulo: write at first iteration after lastWriteTime + timeModulo
      double timeModulo;
      double lastWriteTime;
185

186
187
188
      /// Stores a set of std::pairs of timepoint and filename to write a ParaView 
      /// animation file.
      std::vector<std::pair<double, std::string> > paraviewAnimationFrames;
189

190
191
      ///
      int timestepNumber;
192

193
194
      /// Mesh used for output.
      Mesh *mesh;
195

196
197
      /// fespace used for output.
      const FiniteElemSpace *feSpace;
198

199
200
      /// Pointers to the std::vectors which store the solution.
      std::vector<DOFVector<T>*> solutionVecs;
Praetorius, Simon's avatar
Praetorius, Simon committed
201
202
203
      
      /// Names of the DOFVectors
      std::vector<std::string> solutionNames;
Thomas Witkowski's avatar
Thomas Witkowski committed
204

205
206
207
208
209
210
211
212
213
214
215
216
217
      /** \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;
    };
218

219
220
221
222
223
224
225
226
227
228
229
230
231
    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
232
  
233
234
  typedef detail::FileWriter<double> FileWriter;
  typedef detail::FileWriter<WorldVector<double> > FileVectorWriter;
235
236
}

237
238
#include "FileWriter.hh"

239
#endif // AMDIS_FILEWRITER_H