FileWriter.h 6.69 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;
      }
86

87
88
89
90
91
92
93
94
95
96
97
      bool getWriteParaViewFormat() const 
      { 
	return writeParaViewFormat;
      }
      
      std::string getParaViewFilename(AdaptInfo* info) const;
      
      const std::vector<std::string>& getSolutionNames() const 
      { 
	return solutionNames; 
      }
98

99
100
101
    protected:
      /// Initialization of the filewriter.
      void initialize();
102

103
      /// Reads all file writer dependend parameters from the init file.
104
      virtual void readParameters(std::string name) override;
105
106
107
      
      /// Multi mesh flag
      bool multiMesh;
108

109
110
      /// Name of the writer.
      std::string name;
111

112
113
      /// AMDiS mesh-file extension.
      std::string amdisMeshExt;
114

115
116
      /// AMDiS solution-file extension.
      std::string amdisDataExt;
117

118
119
      /// VTK file extension.
      std::string paraviewFileExt;
Thomas Witkowski's avatar
Thomas Witkowski committed
120

121
122
      /// Parallel VTK file extension.
      std::string paraviewParallelFileExt;
123
124
125
126
127
128
      
      /// Parallel ARH file extension.
      std::string arhParallelFileExt;
      
      /// Time ARH file extension.
      std::string arhTimeFileExt;
129

130
131
      /// Periodic file extension.
      std::string periodicFileExt;
132

133
134
      /// 0: Don't write AMDiS files; 1: Write AMDiS files. 
      int writeAMDiSFormat;
135

136
137
      /// 0: Don't write ParaView files; 1: Write ParaView files.
      int writeParaViewFormat;
138
139
140
141
142
143
      
      /// 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;
144

145
146
      /// 0: Don't write ParaView std::vector files; 1: Write ParaView std::vector files.
      int writeParaViewVectorFormat;
147

148
149
      /// 1: extend number of component to 3, so that paraview can display the std::vector as worldstd::vector
      bool writeAs3dVector;
150

151
152
      /// 0: Don't write ParaView animation file; 1: Write ParaView animation file.
      int writeParaViewAnimation;
153

154
155
      /// 0: Don't write periodic files; 1: Write periodic files.
      int writePeriodicFormat;
156

157
158
      /// 0: Don't write png files; 1: Write png image files.
      int writePngFormat;
159

160
161
      /// 0: Gray color picture; 1: RGB picture.
      int pngType;
162

163
164
      /// 0: Don't write Povray scripts; 1: Write Povray scripts
      int writePovrayFormat;
Thomas Witkowski's avatar
Thomas Witkowski committed
165

166
167
      /// 0: Don't write DOF files; 1: Write DOF files
      int writeDofFormat;
Thomas Witkowski's avatar
Thomas Witkowski committed
168

Siqi Ling's avatar
Siqi Ling committed
169
      /// if write latest ARH files
170
      int writeArhFormat;
171

Siqi Ling's avatar
Siqi Ling committed
172
173
174
175
176
177
178
179
      /// 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;
Thomas Witkowski's avatar
Thomas Witkowski committed
180

181
182
      /// camera position for povray script files
      std::string povrayCameraLocation;
Thomas Witkowski's avatar
Thomas Witkowski committed
183

184
185
      /// orientation for camera in povray script files
      std::string povrayCameraLookAt;
Thomas Witkowski's avatar
Thomas Witkowski committed
186

187
188
      /// name of the template file that will be prepended to all created *.pov files 
      std::string povrayTemplate;
189

190

191
192
193
      /// Stores a set of std::pairs of timepoint and filename to write a ParaView 
      /// animation file.
      std::vector<std::pair<double, std::string> > paraviewAnimationFrames;
194

195
196
      ///
      int timestepNumber;
197

198
199
      /// Mesh used for output.
      Mesh *mesh;
200

201
202
      /// fespace used for output.
      const FiniteElemSpace *feSpace;
203

204
205
      /// Pointers to the std::vectors which store the solution.
      std::vector<DOFVector<T>*> solutionVecs;
Praetorius, Simon's avatar
Praetorius, Simon committed
206
207
208
      
      /// Names of the DOFVectors
      std::vector<std::string> solutionNames;
Thomas Witkowski's avatar
Thomas Witkowski committed
209

210
211
212
213
214
215
216
217
218
219
220
221
222
      /** \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;
    };
223

224
225
226
227
228
229
230
231
232
233
234
235
236
    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
237
  
238
239
  typedef detail::FileWriter<double> FileWriter;
  typedef detail::FileWriter<WorldVector<double> > FileVectorWriter;
240
241
}

242
243
#include "FileWriter.hh"

244
#endif // AMDIS_FILEWRITER_H