Flow123d  last_with_con_2.0.0-663-gd0e2296
output_data_base.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_data_base.hh
15  * @brief
16  */
17 
18 #ifndef OUTPUT_DATA_BASE_HH_
19 #define OUTPUT_DATA_BASE_HH_
20 
21 
22 
23 #include <ostream>
24 #include <string>
25 #include <typeinfo>
26 
27 #include "fields/unit_si.hh"
28 #include "system/global_defs.h"
29 
30 using namespace std;
31 
32 /**
33  * \brief Common parent class for templated OutputData.
34  *
35  * Provides virtual method for output of stored data.
36  *
37  */
39 public:
40 
41  /**
42  * Number of components of element data stored in the database.
43  */
45  N_SCALAR = 1,
46  N_VECTOR = 3,
47  N_TENSOR = 9
48  };
49 
50  /// Types of VTK value
51  typedef enum { VTK_INT8, VTK_UINT8, VTK_INT16, VTK_UINT16, VTK_INT32, VTK_UINT32,
52  VTK_FLOAT32, VTK_FLOAT64
53  } VTKValueType;
54 
55  /**
56  * Destructor of OutputDataBase
57  */
58  virtual ~OutputDataBase() {};
59 
60  /**
61  * Print one value at given index in ascii format
62  */
63  virtual void print_ascii(ostream &out_stream, unsigned int idx) = 0;
64 
65  /**
66  * Print all data in ascii format at once stored in database
67  */
68  virtual void print_ascii_all(ostream &out_stream) = 0;
69 
70  /**
71  * Print all data in binary format at once stored in database
72  */
73  virtual void print_binary_all(ostream &out_stream) = 0;
74 
75  /**
76  * Print stored values in the YAML format (using JSON like arrays).
77  * Used for output of observe values.
78  */
79  virtual void print_all_yaml(ostream &out_stream, unsigned int precision) = 0;
80 
81  /**
82  * Find minimal and maximal range of stored data
83  */
84  virtual void get_min_max_range(double &min, double &max) = 0;
85 
86  /**
87  * Data copied from Field.
88  */
89  std::string output_field_name;
90  std::string field_name;
92 
93  /**
94  * Number of data values.
95  */
96  unsigned int n_values;
97 
98  /**
99  * Number of data elements per data value.
100  */
102 
103  /// Type of stored data
104  VTKValueType vtk_type_;
105 
106 protected:
107  template <class T>
108  void set_vtk_type() {
110  vtk_type_ = VTK_FLOAT64;
112  vtk_type_ = VTK_UINT32;
113  } else if ( std::is_same<T, int>::value ) {
114  vtk_type_ = VTK_INT32;
115  } else {
116  ASSERT(false).error("Unsupported VTK type");
117  }
118  }
119 
120 };
121 
122 
123 
124 
125 #endif /* OUTPUT_DATA_BASE_HH_ */
Common parent class for templated OutputData.
std::string output_field_name
VTKValueType vtk_type_
Type of stored data.
virtual ~OutputDataBase()
unsigned int n_values
NumCompValueType n_elem_
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
Definition: asserts.hh:347
static constexpr bool value
Definition: json.hpp:87
Global macros to enhance readability and debugging, general constants.
VTKValueType
Types of VTK value.
std::string field_name
Class for representation SI units of Fields.
Definition: unit_si.hh:40