Flow123d  release_2.2.0-37-g336ee74
output_mesh.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_mesh.hh
15  * @brief Classes for auxiliary output mesh.
16  */
17 
18 #ifndef OUTPUT_MESH_HH_
19 #define OUTPUT_MESH_HH_
20 
21 #include <string>
22 
23 #include "system/sys_profiler.hh"
24 #include "input/accessors.hh"
25 
27 
28 class Mesh;
29 template<class T> class ElementDataCache;
30 
33 
34 class OutputMeshBase;
35 class OutputMesh;
37 
38 
39 /**
40  * @brief Base class for Output mesh.
41  *
42  * Defines common members for Output mesh classes:
43  * - OutputMesh represents output mesh with continuous elements
44  * - OutputMeshDiscontinuous represents output mesh with discontinuous elements
45  *
46  * Making of output meshes and calling of their initialization methods must be execute in correct order, see example:
47 @code
48  // Create or get Mesh object
49  Mesh * my_mesh = ...
50 
51  // Construct mesh with continuous elements
52  std::make_shared<OutputMesh> output_mesh = std::make_shared<OutputMesh>(*my_mesh);
53  // Creates the mesh identical to the computational one.
54  output_mesh->create_identical_mesh();
55 
56  // Construct mesh with discontinuous elements
57  std::make_shared<OutputMeshDiscontinuous> output_mesh_discont = std::make_shared<OutputMeshDiscontinuous>(*my_mesh);
58  // Creates mesh from the given continuous one.
59  output_mesh_discont->create_mesh(output_mesh);
60 @endcode
61  */
62 class OutputMeshBase : public std::enable_shared_from_this<OutputMeshBase>
63 {
64 public:
65  /// Shortcut instead of spacedim template. We suppose only spacedim=3 at the moment.
66  static const unsigned int spacedim = 3;
67 
68  /// Constructor. Takes computational mesh as a parameter.
69  OutputMeshBase(Mesh &mesh);
70  /// Constructor. Takes computational mesh and input record as a parameters.
71  OutputMeshBase(Mesh &mesh, const Input::Record &in_rec);
72  virtual ~OutputMeshBase();
73 
74  /**
75  * @brief The specification of output mesh.
76  * @return record for output mesh
77  */
78  static const Input::Type::Record & get_input_type();
79 
80  /// Gives iterator to the FIRST element of the output mesh.
82  /// Gives iterator to the LAST element of the output mesh.
84 
85  /// Creates refined mesh.
86  virtual void create_refined_mesh()=0;
87 
88  /// Returns \p error_control_field_name_
89  inline std::string error_control_field_name() {
91  }
92 
93  /// Vector of element indices in the computational mesh. (Important when refining.)
94  std::shared_ptr<std::vector<unsigned int>> orig_element_indices_;
95 
96  /// Vector of node coordinates. [spacedim x n_nodes]
97  std::shared_ptr<ElementDataCache<double>> nodes_;
98  /// Vector maps the nodes to their coordinates in vector @p nodes_.
99  std::shared_ptr<ElementDataCache<unsigned int>> connectivity_;
100  /// Vector of offsets of node indices of elements. Maps elements to their nodes in connectivity_.
101  std::shared_ptr<ElementDataCache<unsigned int>> offsets_;
102 
103  /// Returns number of nodes.
104  unsigned int n_nodes();
105  /// Returns number of element.
106  unsigned int n_elements();
107 
108 protected:
109  /// Input record for output mesh.
111 
112  /// Pointer to the computational mesh.
114 
115  /// Maximal level of refinement.
116  const unsigned int max_level_;
117 
118  /// Refinement error control field name.
120 
121  /// Friend provides access to vectors for element accessor class.
122  friend class OutputElement;
123 };
124 
125 
126 /// @brief Class represents output mesh with continuous elements.
128 {
129 public:
130  OutputMesh(Mesh &mesh);
131  OutputMesh(Mesh &mesh, const Input::Record &in_rec);
132  ~OutputMesh();
133 
134  /// Creates the output mesh identical to the computational one.
135  void create_identical_mesh();
136 
137  /// Creates refined mesh.
138  void create_refined_mesh() override;
139 
140 protected:
141  bool refinement_criterion();
142 
143  /// Friend provides access to vectors for discontinous output mesh.
145 };
146 
147 
148 /// @brief Class represents output mesh with discontinuous elements.
150 {
151 public:
153  OutputMeshDiscontinuous(Mesh &mesh, const Input::Record& in_rec);
155 
156  /// Creates output mesh from the given continuous one.
157  void create_mesh(std::shared_ptr<OutputMesh> output_mesh);
158 
159  /// Creates discontinuous refined mesh.
160  void create_refined_mesh() override;
161 
162 protected:
163  bool refinement_criterion();
164 };
165 
166 #endif // OUTPUT_MESH_HH_
167 
Class represents output mesh with continuous elements.
Definition: output_mesh.hh:127
static const unsigned int spacedim
Shortcut instead of spacedim template. We suppose only spacedim=3 at the moment.
Definition: output_mesh.hh:66
std::string error_control_field_name()
Returns error_control_field_name_.
Definition: output_mesh.hh:89
Base class for Output mesh.
Definition: output_mesh.hh:62
GeneralIterator< OutputElement > OutputElementIterator
Definition: output_mesh.hh:31
Represents an element of the output mesh. Provides element access on the data of the output mesh (nod...
unsigned int n_elements()
Returns number of element.
Definition: output_mesh.cc:81
Mesh * orig_mesh_
Pointer to the computational mesh.
Definition: output_mesh.hh:113
static const Input::Type::Record & get_input_type()
The specification of output mesh.
Definition: output_mesh.cc:24
const unsigned int max_level_
Maximal level of refinement.
Definition: output_mesh.hh:116
Definition: mesh.h:97
Template GeneralIterator serves as general template for internal iterators.
std::shared_ptr< ElementDataCache< unsigned int > > connectivity_
Vector maps the nodes to their coordinates in vector nodes_.
Definition: output_mesh.hh:99
std::shared_ptr< ElementDataCache< unsigned int > > offsets_
Vector of offsets of node indices of elements. Maps elements to their nodes in connectivity_.
Definition: output_mesh.hh:101
unsigned int n_nodes()
Returns number of nodes.
Definition: output_mesh.cc:87
std::shared_ptr< ElementDataCache< double > > nodes_
Vector of node coordinates. [spacedim x n_nodes].
Definition: output_mesh.hh:97
Class represents output mesh with discontinuous elements.
Definition: output_mesh.hh:149
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
virtual void create_refined_mesh()=0
Creates refined mesh.
std::string error_control_field_name_
Refinement error control field name.
Definition: output_mesh.hh:119
virtual ~OutputMeshBase()
Definition: output_mesh.cc:65
Input::Record input_record_
Input record for output mesh.
Definition: output_mesh.hh:110
OutputElementIterator end()
Gives iterator to the LAST element of the output mesh.
Definition: output_mesh.cc:75
Record type proxy class.
Definition: type_record.hh:182
General iterator template. Provides iterator over objects in some container.
std::shared_ptr< std::vector< unsigned int > > orig_element_indices_
Vector of element indices in the computational mesh. (Important when refining.)
Definition: output_mesh.hh:94
OutputElementIterator begin()
Gives iterator to the FIRST element of the output mesh.
Definition: output_mesh.cc:69
OutputMeshBase(Mesh &mesh)
Constructor. Takes computational mesh as a parameter.
Definition: output_mesh.cc:35