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