Flow123d  release_2.1.2-337-g6b7a56b
sides.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 sides.h
15  * @brief
16  */
17 
18 #ifndef SIDES_H
19 #define SIDES_H
20 
21 
22 #include <armadillo>
23 #include "mesh/mesh_types.hh"
24 
25 //=============================================================================
26 // STRUCTURE OF THE SIDE OF THE MESH
27 //=============================================================================
28 
29 class Mesh;
30 
31 class Side {
32 public:
33  Side()
34  : element_(NULL), el_idx_(0)
35  {}
36 
37  inline Side(const Element * ele, unsigned int set_lnum);
38  double measure() const;
39  arma::vec3 centre() const; // Centre of side
40  arma::vec3 normal() const; // Vector of (generalized) normal
41 
42  /**
43  * Returns number of nodes of the side.
44  */
45  inline unsigned int n_nodes() const;
46 
47  /**
48  * Returns dimension of the side, that is dimension of the element minus one.
49  */
50  inline unsigned int dim() const;
51 
52  // returns true for all sides either on boundary or connected to vb neigboring
53  inline bool is_external() const;
54 
55  /**
56  * Returns node for given local index @p i on the side.
57  */
58  inline const Node * node(unsigned int i) const;
59 
60  /**
61  * Returns full iterator to the element of the side.
62  */
63  inline ElementFullIter element() const;
64 
65  /**
66  * Returns pointer to the mesh.
67  */
68  inline Mesh * mesh() const;
69 
70  /**
71  * Returns global index of the edge connected to the side.
72  */
73  inline unsigned int edge_idx() const;
74 
75  /**
76  * Returns pointer to the edge connected to the side.
77  */
78  inline Edge * edge() const;
79 
80  inline Boundary * cond() const;
81  inline unsigned int cond_idx() const;
82 
83  /**
84  * Returns local index of the side on the element.
85  */
86  inline unsigned int el_idx() const;
87 
88  /**
89  * Returns true if the side has assigned element.
90  */
91  inline bool valid() const;
92 
93  /**
94  * Iterate over local sides of the element.
95  */
96  inline void inc();
97 
98  /// This is necessary by current DofHandler, should change this
99  inline void *make_ptr() const;
100 private:
101 
102  arma::vec3 normal_point() const;
103  arma::vec3 normal_line() const;
104  arma::vec3 normal_triangle() const;
105 
106  // Topology of the mesh
107 
108  const Element * element_; // Pointer to element to which belonged
109  unsigned int el_idx_; // Local # of side in element (to remove it, we heve to remove calc_side_rhs)
110 
111 };
112 
113 
114 /*
115  * Iterator to a side.
116  */
117 class SideIter {
118 public:
120  {}
121 
122  inline SideIter(const Side &side)
123  : side_(side)
124  {}
125 
126  inline bool operator==(const SideIter &other) {
127  return (side_.element() == other.side_.element() ) && ( side_.el_idx() == other.side_.el_idx() );
128  }
129 
130 
131  inline bool operator!=(const SideIter &other) {
132  return !( *this == other);
133  }
134 
135  /// * dereference operator
136  inline const Side & operator *() const
137  { return side_; }
138 
139  /// -> dereference operator
140  inline const Side * operator ->() const
141  { return &side_; }
142 
143  /// prefix increment iterate only on local element
144  inline SideIter &operator ++ () {
145  side_.inc();
146  return (*this);
147  }
148 
149 private:
151 };
152 #endif
153 //-----------------------------------------------------------------------------
154 // vim: set cindent:
Definition: sides.h:31
Definition: nodes.hh:32
unsigned int edge_idx() const
Definition: side_impl.hh:61
Boundary * cond() const
Definition: side_impl.hh:70
arma::vec3 normal_line() const
Definition: sides.cc:84
arma::vec3 centre() const
Definition: sides.cc:122
Definition: mesh.h:97
Definition: edges.h:26
bool valid() const
Definition: side_impl.hh:86
Edge * edge() const
Definition: side_impl.hh:65
arma::vec3 normal_point() const
Definition: sides.cc:68
Side side_
Definition: sides.h:150
UnitSI operator*(const UnitSI &a, const UnitSI &b)
Product of two units.
Definition: unit_si.cc:235
bool is_external() const
Definition: side_impl.hh:42
unsigned int dim() const
Definition: side_impl.hh:37
arma::vec3 normal_triangle() const
Definition: sides.cc:105
void * make_ptr() const
This is necessary by current DofHandler, should change this.
Definition: side_impl.hh:96
SideIter()
Definition: sides.h:119
bool operator!=(const SideIter &other)
Definition: sides.h:131
Side()
Definition: sides.h:33
double measure() const
Definition: sides.cc:29
unsigned int cond_idx() const
Definition: side_impl.hh:75
ElementFullIter element() const
Definition: side_impl.hh:52
arma::vec3 normal() const
Definition: sides.cc:52
unsigned int el_idx_
Definition: sides.h:109
unsigned int el_idx() const
Definition: side_impl.hh:81
const Element * element_
Definition: sides.h:108
void inc()
Definition: side_impl.hh:91
bool operator==(const SideIter &other)
Definition: sides.h:126
const Node * node(unsigned int i) const
Definition: side_impl.hh:46
Mesh * mesh() const
Definition: side_impl.hh:57
unsigned int n_nodes() const
Definition: side_impl.hh:33
SideIter(const Side &side)
Definition: sides.h:122