VtkWriter.h 4 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
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file VtkWriter.h */

#ifndef AMDIS_VTKWRITER_H
#define AMDIS_VTKWRITER_H

25
26
#include <fstream>

27
#include "BasisFunction.h"
28
29
30
31
32
33
34
#include "DataCollector.h"

namespace AMDiS {

  class VtkWriter
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
35
    VtkWriter(std::vector<DataCollector*> *dc)
Thomas Witkowski's avatar
Thomas Witkowski committed
36
      : dataCollector(dc)
37
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
38
39
      degree = (*dataCollector)[0]->getFeSpace()->getBasisFcts()->getDegree();    
      dim = (*dataCollector)[0]->getMesh()->getDim();
40
41
42
    };  


43
44
45
    /** \brief
     * Writes a ParaView-VTK file.
     */
46
47
    int writeFile(const char *name);

48
49
50
51
52
    /** \brief
     * May be used to simply write ParaView files.
     */
    static void writeFile(DOFVector<double> *values,
			  const char *filename);
53
54
55
56

    /** \brief
     * Adds a new entry to a ParaView animation file.
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
57
58
    int updateAnimationFile(std::string valueFilename,
			    std::vector< std::string > *paraViewAnimationFrames,
59
60
61
			    const char *animationFilename);
  protected:
    /** \brief
62
63
     * Writes all coordinates of vertices and interpolation points to an
     * output file.
64
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
65
    void writeVertexCoords(std::ofstream &file);
66
67
68


    /** \brief
69
70
     * Writes all values of vertices and interpolation point to an output 
     * file.
71
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
72
    void writeVertexValues(std::ofstream &file, int componentNo);
73
74
75


    /** \brief
76
     * Writes the connectivity of all simplices to an output file.
77
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
78
    void writeConnectivity(std::ofstream &file);
79
80

    /** \brief
81
82
     * Writes the connectivity for the case dim = 2 and degree = 2 to
     * an output file.
83
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
84
    void writeConnectivity_dim2_degree2(std::ofstream &file);
85
86


87
    /** \brief
88
89
     * Writes the connectivity for the case dim = 2 and degree = 3 to
     * an output file.
90
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
91
    void writeConnectivity_dim2_degree3(std::ofstream &file);
92
93
94


    /** \brief
95
96
     * Writes the connectivity for the case dim = 2 and degree = 4 to
     * an output file.
97
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
98
    void writeConnectivity_dim2_degree4(std::ofstream &file);
99
100


101
    /** \brief
102
     * Writes a world coordinate to a given file.
103
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
104
    inline void writeCoord(std::ofstream &file, WorldVector<double> coord) {
105
      for (int i = 0; i < Global::getGeo(WORLD); i++) {
Thomas Witkowski's avatar
Thomas Witkowski committed
106
	file << " " << std::scientific << coord[i];
107
108
109
110
      }
      for (int i = Global::getGeo(WORLD); i < 3; i++) {
	file << " 0.0";
      }
Thomas Witkowski's avatar
Thomas Witkowski committed
111
      file << "\n";
112
113
114
115
    }

  private:
    /**
116
     * List of DataCollectors, for each component of the problem one.
117
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
118
    std::vector<DataCollector*> *dataCollector;
119
120
121


    /** \brief
122
     * Degree of the basis function of the problem.
123
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
124
    int degree;
125
126
127
    

    /** \brief
128
     * Dimension of the geometry.
129
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
130
    int dim;
131
132
133
134
  };
}

#endif