Flow123d  JS_before_hm-2154-g185f171e0
duplicate_nodes.h
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 duplicate_nodes.h
15  * @brief
16  */
17 
18 #ifndef DUPLICATE_NODES_H
19 #define DUPLICATE_NODES_H
20 
21 
22 
23 
24 class MeshBase;
25 
26 /**
27  * Class representing an n-face (node, line, triangle or tetrahedron) in the mesh.
28  * Currently, the object stores information about its 1-codimensional faces
29  * and nodes.
30  *
31  * In the future we should think about complete graph, where every n-dimensional object
32  * has information only about its (n-1)-dimensional faces.
33  */
34 class MeshObject {
35 public:
36 
37  MeshObject(unsigned int dim);
39 
40  /// Indices of (dim-1)-dimensional faces within the global vector of objects with given dimension.
41  unsigned int faces[4];
42 
43  /// Indices of nodes.
44  unsigned int nodes[4];
45 
46  /// Dimension of n-face.
47  unsigned int dim_;
48 };
49 
50 
51 /**
52  * Class DuplicateNodes constructs the graph structure of elements, their faces and nodes
53  * without any other data such as coordinates or region numbers. The nodes are then
54  * duplicated where the elements are separated by fractures (elements of lower dim.).
55  * E.g.:
56  *
57  * Consider a domain containing fracture like this:
58  * +-----+-----+
59  * | | |
60  * | + |
61  * | |
62  * | |
63  * | |
64  * +-----------+
65  *
66  * with the mesh nodes numbered as follows:
67  * 0-----1-----2
68  * | | |
69  * | 3 |
70  * | |
71  * | |
72  * | |
73  * 4-----------5
74  *
75  * The class duplicates node 1 and node 3 because in these nodes FE functions can be discontinuous
76  * (schematic view):
77  * 0-6 1 7-2
78  * | \ | / |
79  * | \ 3 / |
80  * | \ / |
81  * | 8 |
82  * | |
83  * 4-----------5
84  *
85  * Now, nodes 1,6,7 have the same coordinates but belong to different groups of elements
86  * and analogously nodes 3 and 8.
87  *
88  *
89  * The structure is used in DOF handler to distribute dofs for FE spaces sharing dofs
90  * between elements.
91  *
92  * TODO: Currently we do not create faces of faces, i.e. 1d edges of tetrahedra are not
93  * available. This should be implemented if we need to distribute dofs on edges.
94  *
95  */
97 public:
98 
100 
101  // Getters (see private section for explanation).
102  MeshBase *mesh() const { return mesh_; }
103 
104  unsigned int n_nodes() const { return n_duplicated_nodes_; }
105  const std::vector<unsigned int> &node_dim() const { return node_dim_; }
106 
107  const std::vector<MeshObject> &objects(unsigned int dim) const
108  { return objects_[dim]; }
109 
110  const std::vector<unsigned int> &obj_4_el() const { return obj_4_el_; }
111  const std::vector<unsigned int> &obj_4_edg() const { return obj_4_edg_; }
112 
113 
114 private:
115 
116  /// Initialize the vector of nodes from mesh.
117  void init_nodes();
118 
119  /// Initialize objects from mesh edges.
120  void init_from_edges();
121 
122  /// Initialize objects from mesh elements.
123  void init_from_elements();
124 
125  /// Duplicate nodes that are lying on interfaces with fractures.
126  void duplicate_nodes();
127 
128 
129  /// The mesh object.
131 
132  /// Number of nodes (including duplicated ones).
133  unsigned int n_duplicated_nodes_;
134 
135  /// Vector of space dimensions of elements using the particular duplicated node.
137 
138  /// Array of n-faces by their dimension.
140 
141  /** Vector of object indices for each mesh element.
142  * For an element with index el_idx, obj_4_el_[el_idx] is the index of the corresponding object
143  * in the vector tetras_/triangles_/lines_/points_, depending on the element dimension.
144  */
146 
147  /// Vector of object indices for each mesh edge.
149 };
150 
151 
152 #endif // DUPLICATE_NODES_H
DuplicateNodes::init_nodes
void init_nodes()
Initialize the vector of nodes from mesh.
Definition: duplicate_nodes.cc:48
DuplicateNodes::init_from_elements
void init_from_elements()
Initialize objects from mesh elements.
Definition: duplicate_nodes.cc:71
DuplicateNodes::obj_4_el
const std::vector< unsigned int > & obj_4_el() const
Definition: duplicate_nodes.h:110
DuplicateNodes::mesh
MeshBase * mesh() const
Definition: duplicate_nodes.h:102
DuplicateNodes::mesh_
MeshBase * mesh_
The mesh object.
Definition: duplicate_nodes.h:130
std::vector< unsigned int >
MeshObject
Definition: duplicate_nodes.h:34
DuplicateNodes::DuplicateNodes
DuplicateNodes(MeshBase *mesh)
Definition: duplicate_nodes.cc:36
DuplicateNodes::obj_4_edg_
std::vector< unsigned int > obj_4_edg_
Vector of object indices for each mesh edge.
Definition: duplicate_nodes.h:148
DuplicateNodes::node_dim
const std::vector< unsigned int > & node_dim() const
Definition: duplicate_nodes.h:105
MeshObject::dim_
unsigned int dim_
Dimension of n-face.
Definition: duplicate_nodes.h:47
DuplicateNodes::n_nodes
unsigned int n_nodes() const
Definition: duplicate_nodes.h:104
MeshObject::faces
unsigned int faces[4]
Indices of (dim-1)-dimensional faces within the global vector of objects with given dimension.
Definition: duplicate_nodes.h:41
MeshObject::~MeshObject
~MeshObject()
Definition: duplicate_nodes.h:38
DuplicateNodes::n_duplicated_nodes_
unsigned int n_duplicated_nodes_
Number of nodes (including duplicated ones).
Definition: duplicate_nodes.h:133
DuplicateNodes::obj_4_edg
const std::vector< unsigned int > & obj_4_edg() const
Definition: duplicate_nodes.h:111
DuplicateNodes::objects
const std::vector< MeshObject > & objects(unsigned int dim) const
Definition: duplicate_nodes.h:107
DuplicateNodes::obj_4_el_
std::vector< unsigned int > obj_4_el_
Definition: duplicate_nodes.h:145
MeshBase
Base class for Mesh and BCMesh.
Definition: mesh.h:96
DuplicateNodes::node_dim_
std::vector< unsigned int > node_dim_
Vector of space dimensions of elements using the particular duplicated node.
Definition: duplicate_nodes.h:136
MeshObject::nodes
unsigned int nodes[4]
Indices of nodes.
Definition: duplicate_nodes.h:44
DuplicateNodes::objects_
std::vector< MeshObject > objects_[4]
Array of n-faces by their dimension.
Definition: duplicate_nodes.h:139
MeshObject::MeshObject
MeshObject(unsigned int dim)
Definition: duplicate_nodes.cc:31
DuplicateNodes::duplicate_nodes
void duplicate_nodes()
Duplicate nodes that are lying on interfaces with fractures.
Definition: duplicate_nodes.cc:98
DuplicateNodes::init_from_edges
void init_from_edges()
Initialize objects from mesh edges.
Definition: duplicate_nodes.cc:57
DuplicateNodes
Definition: duplicate_nodes.h:96