Flow123d
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  // Basic data
46  //struct Boundary *cond; // Boundary condition - if prescribed
47 
48  // Results
49  //double flux; // Flux through side
50  //double scalar; // Scalar quantity (piez. head or pressure)
51  //double pscalar; // As scalar but in previous time step
52  //struct Edge *edge_; // Edge to which belonged
53 
54  Side()
55  : element_(NULL), el_idx_(0)
56  {}
57 
58  inline Side(const Element * ele, unsigned int set_lnum);
59  double measure() const;
60  arma::vec3 centre() const; // Centre of side
61  arma::vec3 normal() const; // Vector of (generalized) normal
62 
63  /**
64  * Returns number of nodes of the side.
65  */
66  inline unsigned int n_nodes() const;
67 
68  /**
69  * Returns dimension of the side, that is dimension of the element minus one.
70  */
71  inline unsigned int dim() const;
72 
73  // returns true for all sides either on boundary or connected to vb neigboring
74  inline bool is_external() const;
75 
76  /**
77  * Returns node for given local index @p i on the side.
78  */
79  inline const Node * node(unsigned int i) const;
80 
81  /**
82  * Returns full iterator to the element of the side.
83  */
84  inline ElementFullIter element() const;
85 
86  /**
87  * Returns pointer to the mesh.
88  */
89  inline Mesh * mesh() const;
90 
91  /**
92  * Returns global index of the edge connected to the side.
93  */
94  inline unsigned int edge_idx() const;
95 
96  /**
97  * Returns pointer to the edge connected to the side.
98  */
99  inline Edge * edge() const;
100 
101  inline Boundary * cond() const;
102  inline unsigned int cond_idx() const;
103 
104  /**
105  * Returns local index of the side on the element.
106  */
107  inline unsigned int el_idx() const;
108 
109  /**
110  * Returns true if the side has assigned element.
111  */
112  inline bool valid() const;
113 
114  /**
115  * Iterate over local sides of the element.
116  */
117  inline void inc();
118 
119  /// This is necessary by current DofHandler, should change this
120  inline void *make_ptr() const;
121 private:
122 
123  arma::vec3 normal_point() const;
124  arma::vec3 normal_line() const;
125  arma::vec3 normal_triangle() const;
126 
127  // Topology of the mesh
128 
129  const Element * element_; // Pointer to element to which belonged
130  unsigned int el_idx_; // Local # of side in element (to remove it, we heve to remove calc_side_rhs)
131 
132 };
133 
134 
135 /*
136  * Iterator to a side.
137  */
138 class SideIter {
139 public:
141  {}
142 
143  inline SideIter(const Side &side)
144  : side_(side)
145  {}
146 
147  inline bool operator==(const SideIter &other) {
148  return (side_.element() == other.side_.element() ) && ( side_.el_idx() == other.side_.el_idx() );
149  }
150 
151 
152  inline bool operator!=(const SideIter &other) {
153  return !( *this == other);
154  }
155 
156  /// * dereference operator
157  inline const Side & operator *() const
158  { return side_; }
159 
160  /// -> dereference operator
161  inline const Side * operator ->() const
162  { return &side_; }
163 
164  /// prefix increment iterate only on local element
165  inline SideIter &operator ++ () {
166  side_.inc();
167  return (*this);
168  }
169 
170 private:
172 };
173 #endif
174 //-----------------------------------------------------------------------------
175 // vim: set cindent: