FileWriter.h 7.13 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
89
90
91
92
93
94
95
96
97
98
99
100
101
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
129
130
131
#include <string>
#include "MemoryManager.h"
#include "MatrixVector.h"
#include "Mesh.h"

namespace AMDiS {

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

  template<typename T> class DOFVector;

  // ============================================================================
  // ===== 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;
    };

    ::std::string getFilename() { 
      return filename; 
    };
    
    void setFilename(::std::string n) { 
      filename = n; 
    };

  protected:
    /** \brief
     * Used filename prefix.
     */
    ::std::string filename;

    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.
     */
    FileWriter(const ::std::string& name_, 
	       Mesh *mesh_,
	       DOFVector<double> *vec);

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

132
133
134
135
136
137
138
139
    /** \brief
     * Constructor for a filewriter, when the solution vector is a vector
     * of WorldVectors.
     */
    FileWriter(const ::std::string &name_, 
	       Mesh *mesh_,
	       DOFVector< WorldVector<double> > *vec);

140
141
142
    /** \brief
     * Destructor.
     */
143
    virtual ~FileWriter();
144
145
146
147
148
149
150
151
152
153

    /** \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:
154
155
156
157
158
    /** \brief
     * Initialization of the filewriter.
     */
    void initialize();

159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
    /** \brief
     *  Reads all file writer dependend parameters from the init file.
     */
    void readParameters();

    /** \brief
     * Name of the writer.
     */
    ::std::string name;

    /** \brief
     * TecPlot file extension.
     */
    ::std::string tecplotExt;

    /** \brief
     * AMDiS mesh-file extension.
     */
    ::std::string amdisMeshExt;

    /** \brief
     * AMDiS solution-file extension.
     */
    ::std::string amdisDataExt;

    /** \brief
     * VTK file extension.
     */
    ::std::string paraViewFileExt;

    /** \brief
     * Periodic file extension.
     */
    ::std::string periodicFileExt;

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

212
213
214
215
216
217
    /** \brief
     * 0: Don't write ParaView animation file.
     * 1: Write ParaView animation file.
     */
    int writeParaViewAnimation;

218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
    /** \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;

245
246
247
248
249
    /** \brief
     * Stores all writen filename to a ParaView animation file.
     */
    ::std::vector< ::std::string > paraViewAnimationFrames_;

250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
    /**
     */
    int timestepNumber;

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

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

    /** \brief
265
     * Pointers to the vectors which store the solution.
266
267
     */
    ::std::vector< DOFVector<double>* > solutionVecs_;
268
269
270
271
272
273
274

    /** \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_;
275
276
277
278
279
  };

}

#endif // AMDIS_FILEWRITER_H