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