Flow123d  last_with_con_2.0.0-4-g42e6930
output_mesh_data.cc
Go to the documentation of this file.
1 /*
2  * output_mesh_data.cc
3  *
4  * Created on: Jul 8, 2016
5  * Author: jb
6  */
7 
8 #include "io/output_mesh_data.hh"
9 
10 
11 /// Constructor. @p name is the possible name of the output vector.
12 template <class T>
13 MeshData<T>::MeshData(std::string name, NumCompValueType n_elem)
14 {
15  output_field_name = name;
16  n_elem_ = n_elem;
17 }
18 
19 template <class T>
21 {};
22 
23 /// Prints @p idx element of data vector into stream.
24 template <class T>
25 void MeshData<T>::print(std::ostream& out_stream, unsigned int idx)
26 {
27  ASSERT_LE(idx, this->n_values);
28  out_stream << data_[idx] ;
29 }
30 
31 /// Prints the whole data vector into stream.
32 template <class T>
33 void MeshData<T>::print_all(std::ostream& out_stream)
34 {
35  for(auto &d : data_)
36  out_stream << d << " ";
37 }
38 
39 
40 /// Prints the whole data vector into stream.
41 template <class T>
42 void MeshData<T>::print_all_yaml(std::ostream& out_stream, unsigned int precision)
43 {
44  ASSERT(false).error("Unsupported output of the mesh data to YAML format.");
45 }
46 
47 
48 /// Access i-th element in the data vector.
49 template <class T>
50 T& MeshData<T>::operator[](unsigned int i)
51 {
52  ASSERT(i < data_.size());
53  return data_[i];
54 }
55 
56 template class MeshData<unsigned int>;
57 template class MeshData<double>;
58 
void print_all(std::ostream &out_stream) override
Prints the whole data vector into stream.
#define ASSERT_LE(a, b)
Definition of comparative assert macro (Less or Equal)
Definition: asserts.hh:304
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
Definition: asserts.hh:347
MeshData(std::string name, NumCompValueType n_elem=N_SCALAR)
Constructor. name is the possible name of the output vector.
T & operator[](unsigned int i)
Access i-th element in the data vector.
void print(std::ostream &out_stream, unsigned int idx) override
Prints idx element of data vector into stream.
~MeshData() override
void print_all_yaml(std::ostream &out_stream, unsigned int precision) override
Prints the whole data vector into stream. UNSUPPORTED.