Flow123d  jenkins-Flow123d-windows-release-multijob-285
elements.h
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2007 Technical University of Liberec. All rights reserved.
4  *
5  * Please make a following refer to Flow123d on your project site if you use the program for any purpose,
6  * especially for academic research:
7  * Flow123d, Research Centre: Advanced Remedial Technologies, Technical University of Liberec, Czech Republic
8  *
9  * This program is free software; you can redistribute it and/or modify it under the terms
10  * of the GNU General Public License version 3 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along with this program; if not,
17  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 021110-1307, USA.
18  *
19  *
20  * $Id$
21  * $Revision$
22  * $LastChangedBy$
23  * $LastChangedDate$
24  *
25  * @file
26  * @brief ???
27  *
28  */
29 
30 #ifndef ELEMENTS_H
31 #define ELEMENTS_H
32 
33 #include "mesh/nodes.hh"
34 #include "mesh/region.hh"
35 #include "mesh/bounding_box.hh"
36 
37 template <int spacedim>
38 class ElementAccessor;
39 
40 class Mesh;
41 class Side;
42 class SideIter;
43 class Neighbour;
44 
45 
46 
47 //=============================================================================
48 // STRUCTURE OF THE ELEMENT OF THE MESH
49 //=============================================================================
50 class Element
51 {
52 public:
53  Element();
54  Element(unsigned int dim, Mesh *mesh_in, RegionIdx reg);
55  void init(unsigned int dim, Mesh *mesh_in, RegionIdx reg);
56  ~Element();
57 
58 
59  inline unsigned int dim() const;
60  inline unsigned int index() const;
61  unsigned int n_sides() const; // Number of sides
62  unsigned int n_nodes() const; // Number of nodes
63 
64  ///Gets ElementAccessor of this element
66 
67  double measure() const;
68  arma::vec3 centre() const;
69  /**
70  * Quality of the element based on the smooth and scale-invariant quality measures proposed in:
71  * J. R. Schewchuk: What is a Good Linear Element?
72  *
73  * We scale the measure so that is gives value 1 for regular elements. Line 1d elements
74  * have always quality 1.
75  */
76  double quality_measure_smooth();
77 
78  unsigned int n_sides_by_dim(unsigned int side_dim);
79  inline SideIter side(const unsigned int loc_index);
80  inline const SideIter side(const unsigned int loc_index) const;
81  Region region() const;
82  inline RegionIdx region_idx() const
83  { return region_idx_; }
84 
85  unsigned int id() const;
86 
87  int pid; // Id # of mesh partition
88 
89  // Type specific data
90  Node** node; // Element's nodes
91 
92 
93  unsigned int *edge_idx_; // Edges on sides
94  unsigned int *boundary_idx_; // Possible boundaries on sides (REMOVE) all bcd assembly should be done through iterating over boundaries
95  // ?? deal.ii has this not only boundary iterators
96  /**
97  * Indices of permutations of nodes on sides.
98  * It determines, in which order to take the nodes of the side so as to obtain
99  * the same order as on the reference side (side 0 on the particular edge).
100  *
101  * Permutations are defined in RefElement::side_permutations.
102  */
103  unsigned int *permutation_idx_;
104 
105  /**
106  * Computes bounding box of element (OBSOLETE)
107  */
109 
110  /**
111  * Return bounding box of the element.
112  */
114  return BoundingBox(this->vertex_list());
115  }
116 
117  /**
118  * Return list of element vertices.
119  */
121  vector<arma::vec3> vertices(this->n_nodes());
122  for(unsigned int i=0; i<n_nodes(); i++) vertices[i]=node[i]->point();
123  return vertices;
124  }
125 
126 
127  unsigned int n_neighs_vb; // # of neighbours, V-B type (comp.)
128  // only ngh from this element to higher dimension edge
129  Neighbour **neigh_vb; // List og neighbours, V-B type (comp.)
130 
131 
132  Mesh *mesh_; // should be removed as soon as the element is also an Accessor
133 
134 
135 protected:
136  // Data readed from mesh file
138  unsigned int dim_;
139 
140  friend class GmshMeshReader;
141 
142  template<int spacedim, class Value>
143  friend class Field;
144 
145 };
146 
147 
148 
149 
150 #define FOR_ELEMENT_NODES(i,j) for((j)=0;(j)<(i)->n_nodes();(j)++)
151 #define FOR_ELEMENT_SIDES(i,j) for(unsigned int j=0; j < (i)->n_sides(); j++)
152 #define FOR_ELM_NEIGHS_VB(i,j) for((j)=0;(j)<(i)->n_neighs_vb;(j)++)
153 
154 
155 #endif
156 //-----------------------------------------------------------------------------
157 // vim: set cindent:
158 
Definition: sides.h:43
Bounding box in 3d ambient space.
Definition: bounding_box.hh:55
double measure() const
Definition: elements.cc:101
unsigned int n_nodes() const
unsigned int * boundary_idx_
Definition: elements.h:94
Definition: nodes.hh:44
Nodes of a mesh.
int pid
Definition: elements.h:87
unsigned int * permutation_idx_
Definition: elements.h:103
RegionIdx region_idx() const
Definition: elements.h:82
Class template representing a field with values dependent on: point, element, and region...
Definition: field.hh:52
unsigned int index() const
Definition: mesh.h:109
Node ** node
Definition: elements.h:90
unsigned int id() const
Definition: elements.cc:172
Element()
Definition: elements.cc:46
unsigned int dim() const
unsigned int * edge_idx_
Definition: elements.h:93
~Element()
Definition: elements.cc:92
Neighbour ** neigh_vb
Definition: elements.h:129
Region region() const
Definition: elements.cc:167
unsigned int n_sides() const
vector< arma::vec3 > vertex_list()
Definition: elements.h:120
void get_bounding_box(BoundingBox &bounding_box) const
Definition: elements.cc:208
SideIter side(const unsigned int loc_index)
unsigned int dim_
Definition: elements.h:138
void init(unsigned int dim, Mesh *mesh_in, RegionIdx reg)
Definition: elements.cc:72
Mesh * mesh_
Definition: elements.h:132
RegionIdx region_idx_
Definition: elements.h:137
arma::vec3 centre() const
Definition: elements.cc:132
unsigned int n_neighs_vb
Definition: elements.h:127
double quality_measure_smooth()
Definition: elements.cc:176
ElementAccessor< 3 > element_accessor() const
Gets ElementAccessor of this element.
Definition: elements.cc:160
unsigned int n_sides_by_dim(unsigned int side_dim)
Definition: elements.cc:149
BoundingBox bounding_box()
Definition: elements.h:113