Flow123d  release_1.8.2-1603-g0109a2b
output_vtk.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file output_vtk.h
15  * @brief Header: The functions for VTK outputs.
16  */
17 
18 #ifndef OUTPUT_VTK_HH_
19 #define OUTPUT_VTK_HH_
20 
22 
23 #include "output_data_base.hh"
24 #include "output_time.hh"
25 
26 #include <ostream>
27 
28 using namespace std;
29 
30 /**
31  * \brief This class is used for output data to VTK file format
32  */
33 class OutputVTK : public OutputTime {
34 
35 public:
37 
38  /**
39  * \brief The constructor of this class. The head of file is written, when
40  * constructor is called
41  */
42  OutputVTK(const Input::Record &in_rec);
43 
44  /**
45  * \brief The constructor of this class. The head of file is written, when
46  * constructor is called
47  */
48  OutputVTK();
49 
50  /**
51  * \brief The destructor of this class. It writes tail of the file too.
52  */
53  ~OutputVTK();
54 
55  /**
56  * \brief The definition of input record for vtk file format
57  */
58  static const Input::Type::Record & get_input_type();
59 
60  /**
61  * \brief The definition of input record for selection of variant of file format
62  */
63  static const Input::Type::Selection & get_input_type_variant();
64 
65  /**
66  * \brief The definition of input record for selection of compression type
67  */
68  static const Input::Type::Selection & get_input_type_compression();
69 
70  /**
71  * \brief This function write data to VTK (.pvd) file format
72  * for curent time
73  */
74  int write_data(void);
75 
76  /**
77  * \brief This function writes header of VTK (.pvd) file format
78  */
79  int write_head(void);
80 
81  /**
82  * \brief This function writes tail of VTK (.pvd) file format
83  */
84  int write_tail(void);
85 
86 protected:
87 
88  /**
89  * \brief The declaration enumeration used for variant of file VTK format
90  */
91  typedef enum Variant {
92  VARIANT_ASCII = 1,
93  VARIANT_BINARY = 2
94  } Variant;
95 
96  /**
97  * \brief The declaration of enumeration used for type of compression
98  * used in file format
99  */
100  typedef enum Compression {
101  COMPRESSION_NONE = 1,
102  COMPRESSION_GZIP = 2
103  } Compression;
104 
105  // VTK Element types
106  typedef enum {
107  VTK_VERTEX = 1,
108  VTK_POLY_VERTEX = 2,
109  VTK_LINE = 3,
110  VTK_POLY_LINE = 4,
111  VTK_TRIANGLE = 5,
112  VTK_TRIANGLE_STRIP = 6,
113  VTK_POLYGON = 7,
114  VTK_PIXEL = 8,
115  VTK_QUAD = 9,
116  VTK_TETRA = 10,
117  VTK_VOXEL = 11,
118  VTK_HEXAHEDRON = 12,
119  VTK_WEDGE = 13,
120  VTK_PYRAMID = 14,
121  VTK_QUADRIC_EDGE = 21,
122  VTK_QUADRIC_TRIANGLE = 22,
123  VTK_QUADRIC_QUAD = 23,
124  VTK_QUADRIC_TETRA = 24,
125  VTK_QUADRIC_HEXAHEDRON = 25
126  } VTKElemType;
127 
128  // VTK Element size (number of nodes)
129  typedef enum {
130  VTK_LINE_SIZE = 2,
131  VTK_TRIANGLE_SIZE = 3,
132  VTK_TETRA_SIZE = 4
133  } VTKElemSize;
134 
135  /// Registrar of class to factory
136  static const int registrar;
137 
138  /**
139  * \brief Write header of VTK file (.vtu)
140  */
141  void write_vtk_vtu_head(void);
142 
143  /**
144  * \brief Write geometry (position of nodes) to the VTK file (.vtu)
145  */
146  void write_vtk_geometry(void);
147 
148  /**
149  * \brief Write topology (connection of nodes) to the VTK file (.vtu)
150  */
151  void write_vtk_topology(void);
152 
153  /**
154  * \brief Write geometry (position of nodes) to the VTK file (.vtu)
155  *
156  * This method is used, when discontinuous data are saved to the .vtu file
157  */
158  void write_vtk_discont_geometry(void);
159 
160  /**
161  * \brief Write topology (connection of nodes) to the VTK file (.vtu)
162  *
163  * This method is used, when discontinuous data are saved to the .vtu file
164  */
165  void write_vtk_discont_topology(void);
166 
167  /**
168  * Write registered data to output stream using ascii format
169  */
170  void write_vtk_data_ascii(OutputDataFieldVec &output_data_map);
171 
172  /**
173  * \brief Write names of data sets in @p output_data vector that have value type equal to @p type.
174  * Output is done into stream @p file.
175  */
176  void write_vtk_data_names(ofstream &file,
177  OutputDataFieldVec &output_data_map);
178 
179  /**
180  * \brief Write data on nodes to the VTK file (.vtu)
181  */
182  void write_vtk_node_data(void);
183 
184  /**
185  * \brief Write data on elements to the VTK file (.vtu)
186  */
187  void write_vtk_element_data(void);
188 
189  /**
190  * \brief Write tail of VTK file (.vtu)
191  */
192  void write_vtk_vtu_tail(void);
193 
194  /**
195  * \brief This function write all scalar and vector data on nodes and elements
196  * to the VTK file (.vtu)
197  */
198  void write_vtk_vtu(void);
199 
200  /**
201  * Set appropriate file path substrings.
202  * Make subdirectory for VTU time frames.
203  */
204  void make_subdirectory();
205 
206 
207  /**
208  * Data output stream (could be same as base_file)
209  */
210  ofstream _data_file;
211 
212  /**
213  * Path to time frame VTU data subdirectory
214  */
215  string subdir_name_;
216 
218 
220 };
221 
222 #endif /* OUTPUT_VTK_HH_ */
string subdir_name_
Definition: output_vtk.hh:215
static const int registrar
Registrar of class to factory.
Definition: output_vtk.hh:136
string main_output_basename_
Definition: output_vtk.hh:217
string main_output_dir_
Definition: output_vtk.hh:219
OutputTime FactoryBaseType
Definition: output_vtk.hh:36
ofstream _data_file
Definition: output_vtk.hh:210
Accessor to the data with type Type::Record.
Definition: accessors.hh:277
This class is used for output data to VTK file format.
Definition: output_vtk.hh:33
The class for outputting data during time.
Definition: output_time.hh:42
Variant
The declaration enumeration used for variant of file VTK format.
Definition: output_vtk.hh:91
Record type proxy class.
Definition: type_record.hh:171
Compression
The declaration of enumeration used for type of compression used in file format.
Definition: output_vtk.hh:100
Template for classes storing finite set of named values.