FileWriter.h 7.37 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
  // ============================================================================
  // ===== class FileWriterInterface ============================================
  // ============================================================================

  class FileWriterInterface
  {
  public:
    FileWriterInterface()
      : filename(""),
	traverseLevel(-1),
	traverseFlag(Mesh::CALL_LEAF_EL),
	writeElement(NULL)
    {};

    virtual ~FileWriterInterface() {};

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

89
    std::string getFilename() { 
90
91
92
      return filename; 
    };
    
93
    void setFilename(std::string n) { 
94
95
96
97
98
99
100
      filename = n; 
    };

  protected:
    /** \brief
     * Used filename prefix.
     */
101
    std::string filename;
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

    int traverseLevel;

    Flag traverseFlag;

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

  // ============================================================================
  // ===== class FileWriter =====================================================
  // ============================================================================

  /**  
   * \ingroup Output
   *
   * \brief
   * Base class of FileWriterScal and FileWriterVec. Manages the file output
   * of solution vectors.
   */
  class FileWriter : public FileWriterInterface
  {
  public:
    MEMORY_MANAGED(FileWriter);

    /** \brief
     * Constructor for a filewriter for one data component.
     */
129
    FileWriter(const std::string& name_, 
130
131
132
133
134
135
	       Mesh *mesh_,
	       DOFVector<double> *vec);

    /** \brief
     * Constructor for a filewriter with more than one data component.
     */
136
    FileWriter(const std::string& name_,
137
	       Mesh *mesh_,
138
	       std::vector< DOFVector<double>* > vecs);
139

140
141
142
143
    /** \brief
     * Constructor for a filewriter, when the solution vector is a vector
     * of WorldVectors.
     */
144
    FileWriter(const std::string &name_, 
145
146
147
	       Mesh *mesh_,
	       DOFVector< WorldVector<double> > *vec);

148
149
150
    /** \brief
     * Destructor.
     */
151
    virtual ~FileWriter();
152
153
154
155
156
157
158
159
160
161

    /** \brief
     * Implementation of FileWriterInterface::writeFiles().
     */
    virtual void writeFiles(AdaptInfo *adaptInfo, bool force,
			    int level = -1,
			    Flag traverseFlag = Mesh::CALL_LEAF_EL,
			    bool (*writeElem)(ElInfo*) = NULL);

  protected:
162
163
164
165
166
    /** \brief
     * Initialization of the filewriter.
     */
    void initialize();

167
168
169
170
171
172
173
174
    /** \brief
     *  Reads all file writer dependend parameters from the init file.
     */
    void readParameters();

    /** \brief
     * Name of the writer.
     */
175
    std::string name;
176
177
178
179

    /** \brief
     * TecPlot file extension.
     */
180
    std::string tecplotExt;
181
182
183
184

    /** \brief
     * AMDiS mesh-file extension.
     */
185
    std::string amdisMeshExt;
186
187
188
189

    /** \brief
     * AMDiS solution-file extension.
     */
190
    std::string amdisDataExt;
191
192
193
194

    /** \brief
     * VTK file extension.
     */
195
    std::string paraViewFileExt;
196
197
198
199

    /** \brief
     * Periodic file extension.
     */
200
    std::string periodicFileExt;
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219

    /** \brief
     * 0: Don't write TecPlot files.
     * 1: Write TecPlot files. 
     */
    int writeTecPlotFormat;

    /** \brief
     * 0: Don't write AMDiS files.
     * 1: Write AMDiS files. 
     */
    int writeAMDiSFormat;

    /** \brief
     * 0: Don't write ParaView files.
     * 1: Write ParaView files.
     */
    int writeParaViewFormat;

220
221
222
223
224
225
    /** \brief
     * 0: Don't write ParaView animation file.
     * 1: Write ParaView animation file.
     */
    int writeParaViewAnimation;

226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
    /** \brief
     * 0: Don't write periodic files.
     * 1: Write periodic files.
     */
    int writePeriodicFormat;

    /** \brief
     * 0: Don't append time index to filename prefix.
     * 1: Append time index to filename prefix.
     */
    int appendIndex;

    /** \brief
     * Total length of appended time index.
     */
    int indexLength;

    /** \brief
     * Number of decimals in time index.
     */
    int indexDecimals;

    /** \brief
     * Timestep modulo: write only every tsModulo-th timestep! 
     */
    int tsModulo;

253
254
255
    /** \brief
     * Stores all writen filename to a ParaView animation file.
     */
256
    std::vector< std::string > paraViewAnimationFrames_;
257

258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
    /**
     */
    int timestepNumber;

    /** \brief
     * Mesh used for output.
     */
    Mesh *mesh;

    /** \brief
     * fespace used for output.
     */
    const FiniteElemSpace *feSpace;

    /** \brief
273
     * Pointers to the vectors which store the solution.
274
     */
275
    std::vector< DOFVector<double>* > solutionVecs_;
276
277
278
279
280
281
282

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

284
285
286
287
288
    /** \brief
     * Defines if, and with what kind of compression, the file should be compressed
     * during writing.
     */
    FileCompression compression;
289
290
291
292
293
  };

}

#endif // AMDIS_FILEWRITER_H