Flow123d  JS_before_hm-1-ge159291
output_msh.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_msh.h
15  * @brief Header: The functions for MSH (GMSH) outputs.
16  */
17 
18 #ifndef OUTPUT_MSH_HH_
19 #define OUTPUT_MSH_HH_
20 
21 #include <vector> // for vector
22 #include "output_time.hh" // for OutputTime::OutputDataPtr, OutputTime, Out...
23 namespace Input { namespace Type { class Record; } }
24 namespace flow { template <class T> class VectorId; }
25 
26 
27 /**
28  * \brief This class is used for output data to VTK file format
29  */
30 class OutputMSH : public OutputTime {
31 public:
33 
34  /**
35  * \brief The constructor of this class.
36  * We open the output file in first call of write_data
37  */
38  OutputMSH();
39 
40  /**
41  * \brief The destructor of this class
42  */
43  ~OutputMSH();
44 
45  /**
46  * \brief The definition of input record for gmsh file format
47  */
48  static const Input::Type::Record & get_input_type();
49 
50  /**
51  * \brief This method writes head of GMSH (.msh) file format
52  *
53  * \return This function returns 1
54  */
55  int write_head(void);
56 
57  /**
58  * \brief This method writes data to GMSH (.msh) file format for current time
59  *
60  * \return This function returns 1
61  */
62  int write_data(void);
63 
64  /**
65  * \brief This method should write tail of GMSH (.msh) file format
66  *
67  * It is stupid file format. It doesn't write anything special at the end of
68  * the file
69  *
70  * \return This function returns 1
71  */
72  int write_tail(void);
73 
74  /// Complete information about dummy fields that are not in output_data_list_.
75  void add_dummy_fields() override;
76 
77  /**
78  * Set shared pointers of output data caches.
79  */
80  void set_output_data_caches(std::shared_ptr<OutputMeshBase> mesh_ptr) override;
81 
82 private:
83 
84  /// Registrar of class to factory
85  static const int registrar;
86 
88 
89  /**
90  * EquationOutput force output of all output fields at the time zero.
91  * We keep this list to perform single elemnent/node output in order to have correct behavior in GMSH.
92  */
94 
95  /**
96  * \brief This function write header of GMSH (.msh) file format
97  */
98  void write_msh_header(void);
99 
100  /**
101  * \brief This function writes geometry (position of nodes) to GMSH (.msh) file
102  * format
103  */
104  void write_msh_geometry(void);
105 
106  /**
107  * \brief This function writes topology (connection of nodes) to the GMSH (.msh)
108  * file format
109  */
110  void write_msh_topology(void);
111 
112  /**
113  * \brief This function writes ascii data to GMSH (.msh) output file.
114  *
115  * \param[in] id_cache Data cache of node or element ids.
116  * \param[in] output_data The pointer at structure storing pointer at own data.
117  * \param[in] discont Flag determines continuous or discontinuous mesh.
118  */
119  void write_msh_ascii_data(std::shared_ptr<ElementDataCache<unsigned int>> id_cache, OutputDataPtr output_data, bool discont = false);
120 
121  /**
122  * \brief This function write all data on nodes to output file. This function
123  * is used for static and dynamic data
124  *
125  * \param[in] time The time from start
126  * \param[in] step The number of steps from start
127  */
128  void write_node_data(OutputDataPtr output_data);
129  /**
130  * \brief writes ElementNode data ascii GMSH (.msh) output file.
131  *
132  */
133  void write_corner_data(OutputDataPtr output_data);
134 
135 
136  /**
137  * \brief This function write all data on elements to output file. This
138  * function is used for static and dynamic data
139  *
140  * \param[in] time The time from start
141  * \param[in] step The number of steps from start
142  */
143  void write_elem_data(OutputDataPtr output_data);
144 
145  /**
146  * \brief This method add right suffix to .msh GMSH file
147  */
148  void fix_base_file_name(void);
149 
150  /// Vector gets ids of nodes.
151  std::shared_ptr<ElementDataCache<unsigned int>> node_ids_;
152  /// Vector gets ids of elements.
153  std::shared_ptr<ElementDataCache<unsigned int>> elem_ids_;
154  /// Vector gets ids of regions.
155  std::shared_ptr<ElementDataCache<unsigned int>> region_ids_;
156  /// Vector gets partitions of elements.
157  std::shared_ptr<ElementDataCache<int>> partitions_;
158 };
159 
160 #endif /* OUTPUT_MSH_HH_ */
std::vector< std::vector< OutputDataPtr > > dummy_data_list_
Definition: output_msh.hh:93
static const int registrar
Registrar of class to factory.
Definition: output_msh.hh:85
Abstract linear system class.
Definition: balance.hh:37
OutputTime FactoryBaseType
Definition: output_msh.hh:32
Small extension of Vector<T> container with support to Id numbers.
Definition: output_msh.hh:24
std::shared_ptr< ElementDataCacheBase > OutputDataPtr
Definition: output_time.hh:122
std::shared_ptr< ElementDataCache< unsigned int > > node_ids_
Vector gets ids of nodes.
Definition: output_msh.hh:151
std::shared_ptr< ElementDataCache< int > > partitions_
Vector gets partitions of elements.
Definition: output_msh.hh:157
bool header_written
Definition: output_msh.hh:87
The class for outputting data during time.
Definition: output_time.hh:50
Record type proxy class.
Definition: type_record.hh:182
std::shared_ptr< ElementDataCache< unsigned int > > elem_ids_
Vector gets ids of elements.
Definition: output_msh.hh:153
This class is used for output data to VTK file format.
Definition: output_msh.hh:30
std::shared_ptr< ElementDataCache< unsigned int > > region_ids_
Vector gets ids of regions.
Definition: output_msh.hh:155