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
33
#include <string>
#include "MemoryManager.h"
#include "MatrixVector.h"
#include "Mesh.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
34
#include "DataCollector.h"
35
36
37
38
39
40
41
42
43
44
45
46

namespace AMDiS {

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

  template<typename T> class DOFVector;

47
48
49
50
51
52
53

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

54
55
56
57
58
59
60
61
62

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

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

    /** \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
84
    }
85

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

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

    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:
    MEMORY_MANAGED(FileWriter);

117
118
119
    /// Constructor for a filewriter for one data component.
    FileWriter(const std::string& name,
	       Mesh *mesh,
120
121
	       DOFVector<double> *vec);

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

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

135
    /// Destructor
136
    virtual ~FileWriter();
137

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

  protected:
145
    /// Initialization of the filewriter.
146
147
    void initialize();

148
    /// Reads all file writer dependend parameters from the init file.
149
150
    void readParameters();

151
    /// Name of the writer.
152
    std::string name;
153

154
    /// TecPlot file extension.
155
    std::string tecplotExt;
156

157
    /// AMDiS mesh-file extension.
158
    std::string amdisMeshExt;
159

160
    /// AMDiS solution-file extension.
161
    std::string amdisDataExt;
162

163
    /// VTK file extension.
164
    std::string paraViewFileExt;
165

166
    /// Periodic file extension.
167
    std::string periodicFileExt;
168

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

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

175
    /// 0: Don't write ParaView files; 1: Write ParaView files.
176
177
    int writeParaViewFormat;

178
    /// 0: Don't write ParaView animation file; 1: Write ParaView animation file.
179
180
    int writeParaViewAnimation;

181
    /// 0: Don't write periodic files; 1: Write periodic files.
182
183
    int writePeriodicFormat;

184
185
186
    /// 0: Don't write png files; 1: Write png image files.
    int writePngFormat;

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