Flow123d  release_2.1.0-87-gfbc1563
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 
26 #include "io/output_data_base.hh"
27 
28 #include "fields/field_values.hh"
29 #include "fields/field_set.hh"
30 
32 
33 class Mesh;
34 template<int, class Value> class Field;
35 template<class T> class MeshData;
36 
39 
40 class OutputMeshBase;
41 class OutputMesh;
43 
44 
45 /// @brief Base class for Output mesh.
46 /**
47  * Defines common members for OutputMesh classes.
48  */
49 class OutputMeshBase : public std::enable_shared_from_this<OutputMeshBase>
50 {
51 public:
52  DECLARE_EXCEPTION(ExcFieldNotScalar, << "Field '" << FieldCommon::EI_Field::qval
53  << "' is not scalar in spacedim 3.");
54 
55  /// Shortcut instead of spacedim template. We suppose only spacedim=3 at the moment.
56  static const unsigned int spacedim = 3;
57 
58  /// Constructor. Takes computational mesh as a parameter.
59  OutputMeshBase(Mesh &mesh);
60  /// Constructor. Takes computational mesh and input record as a parameters.
61  OutputMeshBase(Mesh &mesh, const Input::Record &in_rec);
62  virtual ~OutputMeshBase();
63 
64  /**
65  * @brief The specification of output mesh.
66  * @return record for output mesh
67  */
68  static const Input::Type::Record & get_input_type();
69 
70  /// Gives iterator to the FIRST element of the output mesh.
72  /// Gives iterator to the LAST element of the output mesh.
74 
75  /// Selects the error control field out of output field set according to input record.
76  void select_error_control_field(FieldSet &output_fields);
77 
78  /// Vector of element indices in the computational mesh. (Important when refining.)
79  std::shared_ptr<std::vector<unsigned int>> orig_element_indices_;
80 
81  /// Vector of node coordinates. [spacedim x n_nodes]
82  std::shared_ptr<MeshData<double>> nodes_;
83  /// Vector maps the nodes to their coordinates in vector @p nodes_.
84  std::shared_ptr<MeshData<unsigned int>> connectivity_;
85  /// Vector of offsets of node indices of elements. Maps elements to their nodes in connectivity_.
86  std::shared_ptr<MeshData<unsigned int>> offsets_;
87 
88  /// Returns number of nodes.
89  unsigned int n_nodes();
90  /// Returns number of element.
91  unsigned int n_elements();
92 
93 protected:
94  /// Input record for output mesh.
96 
97  /// Pointer to the computational mesh.
99 
100  /// Maximal level of refinement.
101  const unsigned int max_level_;
102 
103  /// Refinement error control field.
105 
106  /// Friend provides access to vectors for element accessor class.
107  friend class OutputElement;
108 };
109 
110 
111 /// @brief Class represents output mesh with continuous elements.
113 {
114 public:
115  OutputMesh(Mesh &mesh);
116  OutputMesh(Mesh &mesh, const Input::Record &in_rec);
117  ~OutputMesh();
118 
119  /// Creates the output mesh identical to the computational one.
120  void create_identical_mesh();
121 
122  /// Creates refined mesh.
123  void create_refined_mesh();
124 
125 protected:
126  bool refinement_criterion();
127 
128  /// Friend provides access to vectors for discontinous output mesh.
130 };
131 
132 
134 {
135 public:
137  OutputMeshDiscontinuous(Mesh &mesh, const Input::Record& in_rec);
139 
140  /// Creates output mesh from the given continuous one.
141  void create_mesh(std::shared_ptr<OutputMesh> output_mesh);
142 
143  /// Creates discontinuous refined mesh.
144  void create_refined_mesh();
145 
146 protected:
147  bool refinement_criterion();
148 };
149 
150 #endif // OUTPUT_MESH_HH_
151 
Class represents output mesh with continuous elements.
Definition: output_mesh.hh:112
static const unsigned int spacedim
Shortcut instead of spacedim template. We suppose only spacedim=3 at the moment.
Definition: output_mesh.hh:56
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:61
Base class for Output mesh.
Definition: output_mesh.hh:49
GeneralIterator< OutputElement > OutputElementIterator
Definition: output_mesh.hh:37
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:113
Mesh * orig_mesh_
Pointer to the computational mesh.
Definition: output_mesh.hh:98
void select_error_control_field(FieldSet &output_fields)
Selects the error control field out of output field set according to input record.
Definition: output_mesh.cc:75
Class template representing a field with values dependent on: point, element, and region...
Definition: field.hh:62
std::shared_ptr< MeshData< unsigned int > > connectivity_
Vector maps the nodes to their coordinates in vector nodes_.
Definition: output_mesh.hh:84
static const Input::Type::Record & get_input_type()
The specification of output mesh.
Definition: output_mesh.cc:26
const unsigned int max_level_
Maximal level of refinement.
Definition: output_mesh.hh:101
Definition: mesh.h:95
Template GeneralIterator serves as general template for internal iterators.
std::shared_ptr< MeshData< double > > nodes_
Vector of node coordinates. [spacedim x n_nodes].
Definition: output_mesh.hh:82
unsigned int n_nodes()
Returns number of nodes.
Definition: output_mesh.cc:119
DECLARE_EXCEPTION(ExcFieldNotScalar,<< "Field '"<< FieldCommon::EI_Field::qval<< "' is not scalar in spacedim 3.")
Accessor to the data with type Type::Record.
Definition: accessors.hh:286
virtual ~OutputMeshBase()
Definition: output_mesh.cc:59
Input::Record input_record_
Input record for output mesh.
Definition: output_mesh.hh:95
std::shared_ptr< MeshData< unsigned int > > offsets_
Vector of offsets of node indices of elements. Maps elements to their nodes in connectivity_.
Definition: output_mesh.hh:86
OutputElementIterator end()
Gives iterator to the LAST element of the output mesh.
Definition: output_mesh.cc:69
Record type proxy class.
Definition: type_record.hh:177
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:79
OutputElementIterator begin()
Gives iterator to the FIRST element of the output mesh.
Definition: output_mesh.cc:63
Field< 3, FieldValue< 3 >::Scalar > * error_control_field_
Refinement error control field.
Definition: output_mesh.hh:104
OutputMeshBase(Mesh &mesh)
Constructor. Takes computational mesh as a parameter.
Definition: output_mesh.cc:37