FileWriter.h 6.38 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file FileWriter.h */

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

#ifndef AMDIS_FILEWRITER_H
#define AMDIS_FILEWRITER_H

29
#include <vector>
30
31
32
#include <string>
#include "MatrixVector.h"
#include "Mesh.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
33
#include "DataCollector.h"
34
35
36
37
38
39
40
41
42
43
44
45

namespace AMDiS {

  class ProblemScal;
  class ProblemInstat;
  class Mesh;
  class SystemVector;
  class FiniteElemSpace;
  class AdaptInfo;

  template<typename T> class DOFVector;

46
47
48
49
50
51
52

  typedef enum {
    NONE = 0,
    GZIP = 1,
    BZIP2 = 2
  } FileCompression;

53
54
55
56
57
58
59
60
61

  class FileWriterInterface
  {
  public:
    FileWriterInterface()
      : filename(""),
	traverseLevel(-1),
	traverseFlag(Mesh::CALL_LEAF_EL),
	writeElement(NULL)
Thomas Witkowski's avatar
Thomas Witkowski committed
62
    {}
63

Thomas Witkowski's avatar
Thomas Witkowski committed
64
    virtual ~FileWriterInterface() {}
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82

    /** \brief
     * Interface. Must be overridden in subclasses.
     * \param time time index of solution vector.
     * \param force enforces the output operation for the last timestep.
     */
    virtual void writeFiles(AdaptInfo *adaptInfo, bool force,
			    int level = -1,
			    Flag traverseFlag = Mesh::CALL_LEAF_EL,
			    bool (*writeElem)(ElInfo*) = NULL) = 0;

    void setTraverseProperties(int level, 
			       Flag flag,
			       bool (*writeElem)(ElInfo*))
    {
      traverseLevel = level;
      traverseFlag |= flag;
      writeElement = writeElem;
Thomas Witkowski's avatar
Thomas Witkowski committed
83
    }
84

85
    std::string getFilename() { 
86
      return filename; 
Thomas Witkowski's avatar
Thomas Witkowski committed
87
    }
88
    
89
    void setFilename(std::string n) { 
90
      filename = n; 
Thomas Witkowski's avatar
Thomas Witkowski committed
91
    }
92
93

  protected:
94
    /// Used filename prefix.
95
    std::string filename;
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113

    int traverseLevel;

    Flag traverseFlag;

    bool (*writeElement)(ElInfo*);  
  };

  /**  
   * \ingroup Output
   *
   * \brief
   * Base class of FileWriterScal and FileWriterVec. Manages the file output
   * of solution vectors.
   */
  class FileWriter : public FileWriterInterface
  {
  public:
114
115
116
    /// Constructor for a filewriter for one data component.
    FileWriter(const std::string& name,
	       Mesh *mesh,
117
118
	       DOFVector<double> *vec);

119
120
121
    /// Constructor for a filewriter with more than one data component.
    FileWriter(const std::string& name,
	       Mesh *mesh,
122
	       std::vector< DOFVector<double>* > vecs);
123

124
125
126
127
    /** \brief
     * Constructor for a filewriter, when the solution vector is a vector
     * of WorldVectors.
     */
128
129
    FileWriter(const std::string &name,
	       Mesh *mesh,
130
131
	       DOFVector< WorldVector<double> > *vec);

132
    /// Destructor
133
    virtual ~FileWriter();
134

135
    /// Implementation of FileWriterInterface::writeFiles().
136
137
138
139
140
141
    virtual void writeFiles(AdaptInfo *adaptInfo, bool force,
			    int level = -1,
			    Flag traverseFlag = Mesh::CALL_LEAF_EL,
			    bool (*writeElem)(ElInfo*) = NULL);

  protected:
142
    /// Initialization of the filewriter.
143
144
    void initialize();

145
    /// Reads all file writer dependend parameters from the init file.
146
147
    void readParameters();

148
    /// Name of the writer.
149
    std::string name;
150

151
    /// TecPlot file extension.
152
    std::string tecplotExt;
153

154
    /// AMDiS mesh-file extension.
155
    std::string amdisMeshExt;
156

157
    /// AMDiS solution-file extension.
158
    std::string amdisDataExt;
159

160
    /// VTK file extension.
161
    std::string paraViewFileExt;
162

163
    /// Periodic file extension.
164
    std::string periodicFileExt;
165

166
    /// 0: Don't write TecPlot files; 1: Write TecPlot files. 
167
168
    int writeTecPlotFormat;

169
    /// 0: Don't write AMDiS files; 1: Write AMDiS files. 
170
171
    int writeAMDiSFormat;

172
    /// 0: Don't write ParaView files; 1: Write ParaView files.
173
174
    int writeParaViewFormat;

175
    /// 0: Don't write ParaView animation file; 1: Write ParaView animation file.
176
177
    int writeParaViewAnimation;

178
    /// 0: Don't write periodic files; 1: Write periodic files.
179
180
    int writePeriodicFormat;

181
182
183
    /// 0: Don't write png files; 1: Write png image files.
    int writePngFormat;

184
185
186
    /// 0: Gray color picture; 1: RGB picture.
    int pngType;

187
188
189
190
191
192
    /** \brief
     * 0: Don't append time index to filename prefix.
     * 1: Append time index to filename prefix.
     */
    int appendIndex;

193
    /// Total length of appended time index.
194
195
    int indexLength;

196
    /// Number of decimals in time index.
197
198
    int indexDecimals;

199
    /// Timestep modulo: write only every tsModulo-th timestep! 
200
201
    int tsModulo;

202
    /// Stores all writen filename to a ParaView animation file.
203
    std::vector< std::string > paraViewAnimationFrames_;
204

205
    ///
206
207
    int timestepNumber;

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

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

214
    /// Pointers to the vectors which store the solution.
215
    std::vector< DOFVector<double>* > solutionVecs_;
216
217
218
219
220
221
222

    /** \brief
     * Stores the number of temporal solutions vectors, which have been created
     * in the constructor. If this number is greater than zero, the vectors
     * stored in solutionVecs_ must be deleted in the destructor.
     */
    int nTmpSolutions_;
Thomas Witkowski's avatar
Thomas Witkowski committed
223

224
225
226
227
228
    /** \brief
     * Defines if, and with what kind of compression, the file should be compressed
     * during writing.
     */
    FileCompression compression;
229
230
231
232
233
  };

}

#endif // AMDIS_FILEWRITER_H