VtkWriter.h 3.84 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:
35
36
    VtkWriter(::std::vector<DataCollector*> *dc)
      : 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.
     */
52
53
54
55
56
    int updateAnimationFile(::std::string valueFilename,
			    ::std::vector< ::std::string > *paraViewAnimationFrames,
			    const char *animationFilename);
  protected:
    /** \brief
57
58
     * Writes all coordinates of vertices and interpolation points to an
     * output file.
59
60
61
62
63
     */
    void writeVertexCoords(::std::ofstream &file);


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


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

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


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


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


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

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


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