Flow123d  release_1.8.2-1603-g0109a2b
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 "mesh/nodes.hh"
22 #include "mesh/region.hh"
23 #include "mesh/bounding_box.hh"
24 
25 template <int spacedim>
26 class ElementAccessor;
27 
28 class Mesh;
29 class Side;
30 class SideIter;
31 class Neighbour;
32 
33 
34 
35 //=============================================================================
36 // STRUCTURE OF THE ELEMENT OF THE MESH
37 //=============================================================================
38 class Element
39 {
40 public:
41  Element();
42  Element(unsigned int dim, Mesh *mesh_in, RegionIdx reg);
43  void init(unsigned int dim, Mesh *mesh_in, RegionIdx reg);
44  ~Element();
45 
46 
47  inline unsigned int dim() const;
48  inline unsigned int index() const;
49  unsigned int n_sides() const; // Number of sides
50  unsigned int n_nodes() const; // Number of nodes
51 
52  ///Gets ElementAccessor of this element
54 
55  double measure() const;
56  arma::vec3 centre() const;
57  /**
58  * Quality of the element based on the smooth and scale-invariant quality measures proposed in:
59  * J. R. Schewchuk: What is a Good Linear Element?
60  *
61  * We scale the measure so that is gives value 1 for regular elements. Line 1d elements
62  * have always quality 1.
63  */
64  double quality_measure_smooth();
65 
66  unsigned int n_sides_by_dim(unsigned int side_dim);
67  inline SideIter side(const unsigned int loc_index);
68  inline const SideIter side(const unsigned int loc_index) const;
69  Region region() const;
70  inline RegionIdx region_idx() const
71  { return region_idx_; }
72 
73  unsigned int id() const;
74 
75  int pid; // Id # of mesh partition
76 
77  // Type specific data
78  Node** node; // Element's nodes
79 
80 
81  unsigned int *edge_idx_; // Edges on sides
82  unsigned int *boundary_idx_; // Possible boundaries on sides (REMOVE) all bcd assembly should be done through iterating over boundaries
83  // ?? deal.ii has this not only boundary iterators
84  /**
85  * Indices of permutations of nodes on sides.
86  * It determines, in which order to take the nodes of the side so as to obtain
87  * the same order as on the reference side (side 0 on the particular edge).
88  *
89  * Permutations are defined in RefElement::side_permutations.
90  */
91  unsigned int *permutation_idx_;
92 
93  /**
94  * Computes bounding box of element (OBSOLETE)
95  */
97 
98  /**
99  * Return bounding box of the element.
100  */
102  return BoundingBox(this->vertex_list());
103  }
104 
105  /**
106  * Return list of element vertices.
107  */
109  vector<arma::vec3> vertices(this->n_nodes());
110  for(unsigned int i=0; i<n_nodes(); i++) vertices[i]=node[i]->point();
111  return vertices;
112  }
113 
114 
115  unsigned int n_neighs_vb; // # of neighbours, V-B type (comp.)
116  // only ngh from this element to higher dimension edge
117  Neighbour **neigh_vb; // List og neighbours, V-B type (comp.)
118 
119 
120  Mesh *mesh_; // should be removed as soon as the element is also an Accessor
121 
122 
123 protected:
124  // Data readed from mesh file
126  unsigned int dim_;
127 
128  friend class GmshMeshReader;
129  friend class Mesh;
130 
131  template<int spacedim, class Value>
132  friend class Field;
133 
134 };
135 
136 
137 
138 
139 #define FOR_ELEMENT_NODES(i,j) for((j)=0;(j)<(i)->n_nodes();(j)++)
140 #define FOR_ELEMENT_SIDES(i,j) for(unsigned int j=0; j < (i)->n_sides(); j++)
141 #define FOR_ELM_NEIGHS_VB(i,j) for((j)=0;(j)<(i)->n_neighs_vb;(j)++)
142 
143 
144 #endif
145 //-----------------------------------------------------------------------------
146 // vim: set cindent:
147 
Definition: sides.h:31
Bounding box in 3d ambient space.
Definition: bounding_box.hh:45
double measure() const
Definition: elements.cc:89
unsigned int n_nodes() const
unsigned int * boundary_idx_
Definition: elements.h:82
Definition: nodes.hh:32
Nodes of a mesh.
int pid
Definition: elements.h:75
unsigned int * permutation_idx_
Definition: elements.h:91
RegionIdx region_idx() const
Definition: elements.h:70
Class template representing a field with values dependent on: point, element, and region...
Definition: field.hh:62
unsigned int index() const
Definition: mesh.h:99
Node ** node
Definition: elements.h:78
unsigned int id() const
Definition: elements.cc:160
Element()
Definition: elements.cc:34
unsigned int dim() const
unsigned int * edge_idx_
Definition: elements.h:81
~Element()
Definition: elements.cc:80
Neighbour ** neigh_vb
Definition: elements.h:117
Region region() const
Definition: elements.cc:155
unsigned int n_sides() const
vector< arma::vec3 > vertex_list()
Definition: elements.h:108
void get_bounding_box(BoundingBox &bounding_box) const
Definition: elements.cc:196
SideIter side(const unsigned int loc_index)
unsigned int dim_
Definition: elements.h:126
void init(unsigned int dim, Mesh *mesh_in, RegionIdx reg)
Definition: elements.cc:60
Mesh * mesh_
Definition: elements.h:120
RegionIdx region_idx_
Definition: elements.h:125
arma::vec3 centre() const
Definition: elements.cc:120
unsigned int n_neighs_vb
Definition: elements.h:115
double quality_measure_smooth()
Definition: elements.cc:164
ElementAccessor< 3 > element_accessor() const
Gets ElementAccessor of this element.
Definition: elements.cc:148
unsigned int n_sides_by_dim(unsigned int side_dim)
Definition: elements.cc:137
BoundingBox bounding_box()
Definition: elements.h:101