FileWriter.h 6.48 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
      /// Name of the writer.
      std::string name;
108

109
110
      /// AMDiS mesh-file extension.
      std::string amdisMeshExt;
111

112
113
      /// AMDiS solution-file extension.
      std::string amdisDataExt;
114

115
116
      /// VTK file extension.
      std::string paraviewFileExt;
Thomas Witkowski's avatar
Thomas Witkowski committed
117

118
119
      /// Parallel VTK file extension.
      std::string paraviewParallelFileExt;
120

121
122
      /// Periodic file extension.
      std::string periodicFileExt;
123

124
125
      /// 0: Don't write AMDiS files; 1: Write AMDiS files. 
      int writeAMDiSFormat;
126

127
128
      /// 0: Don't write ParaView files; 1: Write ParaView files.
      int writeParaViewFormat;
129
130
131
132
133
134
      
      /// 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;
135

136
137
      /// 0: Don't write ParaView std::vector files; 1: Write ParaView std::vector files.
      int writeParaViewVectorFormat;
138

139
140
      /// 1: extend number of component to 3, so that paraview can display the std::vector as worldstd::vector
      bool writeAs3dVector;
141

142
143
      /// 0: Don't write ParaView animation file; 1: Write ParaView animation file.
      int writeParaViewAnimation;
144

145
146
      /// 0: Don't write periodic files; 1: Write periodic files.
      int writePeriodicFormat;
147

148
149
      /// 0: Don't write png files; 1: Write png image files.
      int writePngFormat;
150

151
152
      /// 0: Gray color picture; 1: RGB picture.
      int pngType;
153

154
155
      /// 0: Don't write Povray scripts; 1: Write Povray scripts
      int writePovrayFormat;
Thomas Witkowski's avatar
Thomas Witkowski committed
156

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

Siqi Ling's avatar
Siqi Ling committed
160
      /// if write latest ARH files
161
      int writeArhFormat;
162

Siqi Ling's avatar
Siqi Ling committed
163
164
165
166
167
168
169
170
      /// 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
171

172
173
      /// camera position for povray script files
      std::string povrayCameraLocation;
Thomas Witkowski's avatar
Thomas Witkowski committed
174

175
176
      /// orientation for camera in povray script files
      std::string povrayCameraLookAt;
Thomas Witkowski's avatar
Thomas Witkowski committed
177

178
179
      /// name of the template file that will be prepended to all created *.pov files 
      std::string povrayTemplate;
180

181

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

186
187
      ///
      int timestepNumber;
188

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

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

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

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

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

233
234
#include "FileWriter.hh"

235
#endif // AMDIS_FILEWRITER_H