VtkWriter.h 3.81 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)
36
      : dc_(dc)
37
    {
38
39
      degree_ = (*dc_)[0]->getFeSpace()->getBasisFcts()->getDegree();    
      dim_ = (*dc_)[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

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


    /** \brief
64
65
     * Writes all values of vertices and interpolation point to an output 
     * file.
66
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
67
    void writeVertexValues(std::ofstream &file, int componentNo);
68
69
70


    /** \brief
71
     * Writes the connectivity of all simplices to an output file.
72
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
73
    void writeConnectivity(std::ofstream &file);
74
75

    /** \brief
76
77
     * Writes the connectivity for the case dim = 2 and degree = 2 to
     * an output file.
78
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
79
    void writeConnectivity_dim2_degree2(std::ofstream &file);
80
81


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


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


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

  private:
    /**
111
     * List of DataCollectors, for each component of the problem one.
112
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
113
    std::vector<DataCollector*> *dc_;
114
115
116


    /** \brief
117
     * Degree of the basis function of the problem.
118
119
120
121
122
     */
    int degree_;
    

    /** \brief
123
     * Dimension of the geometry.
124
125
     */
    int dim_;
126
127
128
129
  };
}

#endif