FileWriter.h 6.64 KB
Newer Older
1
2
3
4
5
6
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
7
// ==  TU Dresden                                                            ==
8
// ==                                                                        ==
9
10
11
// ==  Institut fr Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
12
13
14
15
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
16
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
17
18
19
20
21
22
23
24
25
26
27
28
// ==                                                                        ==
// ============================================================================

/** \file FileWriter.h */

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

#ifndef AMDIS_FILEWRITER_H
#define AMDIS_FILEWRITER_H

29
#include <vector>
30
#include <string>
Thomas Witkowski's avatar
Thomas Witkowski committed
31
#include "AMDiS_fwd.h"
32
#include "Mesh.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
33
#include "DataCollector.h"
34
35
36

namespace AMDiS {

37
38
39
40
41
42
  typedef enum {
    NONE = 0,
    GZIP = 1,
    BZIP2 = 2
  } FileCompression;

43
44
45
46
47
48
49
50
51

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

Thomas Witkowski's avatar
Thomas Witkowski committed
54
    virtual ~FileWriterInterface() {}
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

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

75
76
    std::string getFilename() 
    { 
77
      return filename; 
Thomas Witkowski's avatar
Thomas Witkowski committed
78
    }
79
    
80
81
    void setFilename(std::string n) 
    { 
82
      filename = n; 
Thomas Witkowski's avatar
Thomas Witkowski committed
83
    }
84
85

  protected:
86
    /// Used filename prefix.
87
    std::string filename;
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

    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:
106
    /// Constructor for a filewriter for one data component.
Thomas Witkowski's avatar
Thomas Witkowski committed
107
    FileWriter(std::string name, Mesh *mesh, DOFVector<double> *vec);
108

109
    /// Constructor for a filewriter with more than one data component.
Thomas Witkowski's avatar
Thomas Witkowski committed
110
    FileWriter(std::string name, 
111
	       Mesh *mesh,
112
	       std::vector< DOFVector<double>* > vecs);
113

114
115
116
117
    /** \brief
     * Constructor for a filewriter, when the solution vector is a vector
     * of WorldVectors.
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
118
    FileWriter(std::string name,
119
	       Mesh *mesh,
120
121
	       DOFVector< WorldVector<double> > *vec);

122
    /// Destructor
123
    virtual ~FileWriter();
124

125
    /// Implementation of FileWriterInterface::writeFiles().
126
127
128
129
130
131
    virtual void writeFiles(AdaptInfo *adaptInfo, bool force,
			    int level = -1,
			    Flag traverseFlag = Mesh::CALL_LEAF_EL,
			    bool (*writeElem)(ElInfo*) = NULL);

  protected:
132
    /// Initialization of the filewriter.
133
134
    void initialize();

135
    /// Reads all file writer dependend parameters from the init file.
136
137
    void readParameters();

138
    /// Name of the writer.
139
    std::string name;
140

141
    /// TecPlot file extension.
142
    std::string tecplotExt;
143

144
    /// AMDiS mesh-file extension.
145
    std::string amdisMeshExt;
146

147
    /// AMDiS solution-file extension.
148
    std::string amdisDataExt;
149

150
    /// VTK file extension.
Thomas Witkowski's avatar
Thomas Witkowski committed
151
152
153
154
    std::string paraviewFileExt;

    /// Parallel VTK file extension.
    std::string paraviewParallelFileExt;
155

156
    /// Periodic file extension.
157
    std::string periodicFileExt;
158

159
    /// 0: Don't write TecPlot files; 1: Write TecPlot files. 
160
161
    int writeTecPlotFormat;

162
    /// 0: Don't write AMDiS files; 1: Write AMDiS files. 
163
164
    int writeAMDiSFormat;

165
    /// 0: Don't write ParaView files; 1: Write ParaView files.
166
167
    int writeParaViewFormat;

168
    /// 0: Don't write ParaView animation file; 1: Write ParaView animation file.
169
170
    int writeParaViewAnimation;

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

174
175
176
    /// 0: Don't write png files; 1: Write png image files.
    int writePngFormat;

177
178
179
    /// 0: Gray color picture; 1: RGB picture.
    int pngType;

Thomas Witkowski's avatar
Thomas Witkowski committed
180
181
182
183
184
185
186
187
188
189
190
191
    /// 0: Don't write Povray scripts; 1: Write Povray scripts
    int writePovrayFormat;

    /// camera position for povray script files
    std::string povrayCameraLocation;

    /// orientation for camera in povray script files
    std::string povrayCameraLookAt;

    /// name of the template file that will be prepended to all created *.pov files 
    std::string povrayTemplate;

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

198
    /// Total length of appended time index.
199
200
    int indexLength;

201
    /// Number of decimals in time index.
202
203
    int indexDecimals;

204
    /// Timestep modulo: write only every tsModulo-th timestep! 
205
206
    int tsModulo;

207
    /// Stores all writen filename to a ParaView animation file.
Thomas Witkowski's avatar
Thomas Witkowski committed
208
    std::vector< std::string > paraviewAnimationFrames;
209

210
    ///
211
212
    int timestepNumber;

213
    /// Mesh used for output.
214
215
    Mesh *mesh;

216
    /// fespace used for output.
217
218
    const FiniteElemSpace *feSpace;

219
    /// Pointers to the vectors which store the solution.
Thomas Witkowski's avatar
Thomas Witkowski committed
220
    std::vector< DOFVector<double>* > solutionVecs;
221
222
223
224
225
226

    /** \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.
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
227
    int nTmpSolutions;
Thomas Witkowski's avatar
Thomas Witkowski committed
228

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

}

#endif // AMDIS_FILEWRITER_H