FileWriter.h 6.39 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
86
    std::string getFilename() 
    { 
87
      return filename; 
Thomas Witkowski's avatar
Thomas Witkowski committed
88
    }
89
    
90
91
    void setFilename(std::string n) 
    { 
92
      filename = n; 
Thomas Witkowski's avatar
Thomas Witkowski committed
93
    }
94
95

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

186
187
188
    /// 0: Gray color picture; 1: RGB picture.
    int pngType;

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

195
    /// Total length of appended time index.
196
197
    int indexLength;

198
    /// Number of decimals in time index.
199
200
    int indexDecimals;

201
    /// Timestep modulo: write only every tsModulo-th timestep! 
202
203
    int tsModulo;

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

207
    ///
208
209
    int timestepNumber;

210
    /// Mesh used for output.
211
212
    Mesh *mesh;

213
    /// fespace used for output.
214
215
    const FiniteElemSpace *feSpace;

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

    /** \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
225

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

}

#endif // AMDIS_FILEWRITER_H