Flow123d  DF_patch_fe_mechanics-a6ba684
elements.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 elements.h
15  * @brief
16 */
17 
18 #ifndef ELEMENTS_H
19 #define ELEMENTS_H
20 
21 #include <ext/alloc_traits.h> // for __alloc_traits<>::valu...
22 #include <string.h> // for memcpy
23 #include <new> // for operator new[]
24 #include <ostream> // for operator<<
25 #include <string> // for operator<<
26 #include <vector> // for vector
27 #include <armadillo>
28 #include "system/index_types.hh"
29 #include "mesh/region.hh" // for RegionIdx, Region
30 #include "system/asserts.hh" // for Assert, ASSERT
31 
32 class Mesh;
33 class Neighbour;
34 
35 
36 
37 //=============================================================================
38 // STRUCTURE OF THE ELEMENT OF THE MESH
39 //=============================================================================
40 class Element
41 {
42 public:
43  Element();
44  Element(unsigned int dim, RegionIdx reg);
45  void init(unsigned int dim, RegionIdx reg);
46  ~Element();
47 
48 
49  inline unsigned int dim() const;
50  inline unsigned int n_sides() const; // Number of sides
51  inline unsigned int n_nodes() const; // Number of nodes
52 
53  inline RegionIdx region_idx() const
54  { return region_idx_; }
55 
56  /// Return edge_idx of given index
57  inline unsigned int edge_idx(unsigned int edg_idx) const;
58 
59  /// Return Id of mesh partition
60  inline int pid() const {
61  return pid_;
62  }
63 
64  /// Return number of neighbours
65  inline unsigned int n_neighs_vb() const {
66  return n_neighs_vb_;
67  }
68 
69  /// Return index (in Mesh::node_vec) of ni-th node.
70  inline unsigned int node_idx(unsigned int ni) const {
71  ASSERT(ni < n_nodes()).error("Node index is out of bound!");
72  ASSERT(nodes_[ni] != undef_idx);
73  return nodes_[ni];
74  }
75 
76 
77  // TODO move data members to protected part, add access trough getters or use direct access of friend class Mesh
78 
79  unsigned int *boundary_idx_; // Possible boundaries on sides (REMOVE) all bcd assembly should be done through iterating over boundaries
80  // ?? deal.ii has this not only boundary iterators
81  // TODO remove direct access in balance, side and transport
82 
83  Neighbour **neigh_vb; // List og neighbours, V-B type (comp.)
84  // TODO remove direct access in DarcyFlow, MhDofHandler, Mesh? Partitioning and Trabsport
85 
86 
87  /// Inverted permutation of element nodes, negative Jacobian.
88  bool inverted;
89 
90  /// Index of permutation of input nodes.
91  // TODO: Output full mesh after optimizations and drop this and global node and element permutatitons
93 
94 protected:
95  int pid_; ///< Id # of mesh partition
96  std::vector<unsigned int> edge_idx_; ///< Edges on sides
97  mutable unsigned int n_neighs_vb_; ///< # of neighbours, V-B type (comp.)
98  // only ngh from this element to higher dimension edge
99  // TODO fix and remove mutable directive
100 
101 
102 
103  // Data readed from mesh file
105  unsigned int dim_;
106 
107  /// indices to element's nodes
108  std::array<unsigned int, 4> nodes_;
109 
110  friend class MeshBase;
111  friend class Mesh;
112  friend class BCMesh;
113 
114  template<int spacedim, class Value>
115  friend class Field;
116 
117 };
118 
119 
120 inline unsigned int Element::dim() const {
121  return dim_;
122 }
123 
124 
125 inline unsigned int Element::n_nodes() const {
126  return dim()+1;
127 }
128 
129 
130 
131 inline unsigned int Element::n_sides() const {
132  return dim() == 0 ? 0 : dim()+1;
133 }
134 
135 inline unsigned int Element::edge_idx(unsigned int edg_idx) const {
136  ASSERT(edg_idx<edge_idx_.size())(edg_idx)(edge_idx_.size()).error("Index of Edge is out of bound!");
137  return edge_idx_[edg_idx];
138 }
139 
140 
141 
142 #endif
143 //-----------------------------------------------------------------------------
144 // vim: set cindent:
Definitions of ASSERTS.
#define ASSERT(expr)
Definition: asserts.hh:351
Class represents boundary part of mesh.
Definition: bc_mesh.hh:37
unsigned int node_idx(unsigned int ni) const
Return index (in Mesh::node_vec) of ni-th node.
Definition: elements.h:70
~Element()
Definition: elements.cc:70
unsigned int * boundary_idx_
Definition: elements.h:79
RegionIdx region_idx() const
Definition: elements.h:53
unsigned int edge_idx(unsigned int edg_idx) const
Return edge_idx of given index.
Definition: elements.h:135
unsigned int dim_
Definition: elements.h:105
int pid_
Id # of mesh partition.
Definition: elements.h:95
Neighbour ** neigh_vb
Definition: elements.h:83
unsigned int n_neighs_vb() const
Return number of neighbours.
Definition: elements.h:65
bool inverted
Inverted permutation of element nodes, negative Jacobian.
Definition: elements.h:88
unsigned int n_neighs_vb_
Definition: elements.h:97
void init(unsigned int dim, RegionIdx reg)
Definition: elements.cc:53
std::array< unsigned int, 4 > nodes_
indices to element's nodes
Definition: elements.h:108
uint permutation_
Index of permutation of input nodes.
Definition: elements.h:92
RegionIdx region_idx_
Definition: elements.h:104
Element()
Definition: elements.cc:35
int pid() const
Return Id of mesh partition.
Definition: elements.h:60
unsigned int n_sides() const
Definition: elements.h:131
unsigned int dim() const
Definition: elements.h:120
std::vector< unsigned int > edge_idx_
Edges on sides.
Definition: elements.h:96
unsigned int n_nodes() const
Definition: elements.h:125
Class template representing a field with values dependent on: point, element, and region.
Definition: field.hh:92
Base class for Mesh and BCMesh.
Definition: mesh.h:96
Definition: mesh.h:362
const unsigned int undef_idx
Definition: index_types.hh:32
unsigned int uint