VtkWriter.h 3.28 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
28
29
30
31
32
33
#include "DataCollector.h"

namespace AMDiS {

  class VtkWriter
  {
  public:
34
35
36
37
38
39
40
41
42
43
    VtkWriter(::std::vector<DataCollector*> *dc,
	      int level = -1,
	      Flag traverseFlag = Mesh::CALL_LEAF_EL)
      : dc_(dc),
        level_(level),
        traverseFlag_(traverseFlag)
    {
    };  


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

49
50
51
52

    /** \brief
     * Adds a new entry to a ParaView animation file.
     */
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
    int updateAnimationFile(::std::string valueFilename,
			    ::std::vector< ::std::string > *paraViewAnimationFrames,
			    const char *animationFilename);
  protected:
    /** \brief
     * 
     */
    void writeVertexCoords(::std::ofstream &file);


    /** \brief
     * 
     */
    void writeVertexCoords_dim2_degree2(::std::ofstream &file);


    /** \brief
     * 
     */
    void writeVertexValues(::std::ofstream &file, int componentNo);


    /** \brief
     * 
     */
    void writeVertexValues_dim2_degree2(::std::ofstream &file, int componentNo);


    /** \brief
     * 
     */
    void writeConnectivity(::std::ofstream &file);

    /** \brief
     *
     */
    void writeConnectivity_dim2_degree2(::std::ofstream &file);


    /** \brief
     *
     */
    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:
    /**
     *
     */
    ::std::vector<DataCollector*> *dc_;


    /** \brief
     * Level information for traversing the mesh.
     */
    int level_;


    /** \brief
     * Flags for traversing the mesh.
     */
    Flag traverseFlag_;

   
124
125
126
127
  };
}

#endif