Flow123d  release_1.8.2-1603-g0109a2b
side_impl.hh
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 side_impl.hh
15  * @brief
16  */
17 
18 #ifndef SIDE_IMPL_HH_
19 #define SIDE_IMPL_HH_
20 
21 #include "mesh/mesh.h"
22 #include "mesh/edges.h"
23 
24 
25 inline Side::Side(const Element * ele, unsigned int set_lnum)
26 : element_(ele), el_idx_(set_lnum)
27 {
28  OLD_ASSERT(mesh()->element.full_iter( const_cast<Element *>(element_) ), "Wrong initialization of the Side.\n");
29 }
30 
31 
32  inline unsigned int Side::n_nodes() const {
33  return dim()+1;
34  }
35 
36  inline unsigned int Side::dim() const {
37  return element_->dim()-1;
38  }
39 
40  // returns true for all sides either on boundary or connected to vb neigboring
41  inline bool Side::is_external() const {
42  return edge()->n_sides == 1;
43  }
44 
45  inline const Node * Side::node(unsigned int i) const {
46  int i_n = mesh()->side_nodes[dim()][el_idx_][i];
47 
48  return element_->node[ i_n ];
49  }
50 
51  inline ElementFullIter Side::element() const {
52  OLD_ASSERT( valid(), "Wrong use of uninitialized accessor.\n");
53  return mesh()->element.full_iter( const_cast<Element *>(element_) );
54  }
55 
56  inline Mesh * Side::mesh() const {
57  return element_->mesh_;
58  }
59 
60  inline unsigned int Side::edge_idx() const {
61  return element_->edge_idx_[el_idx()];
62  }
63 
64  inline Edge * Side::edge() const {
65  if (edge_idx() == Mesh::undef_idx) return NULL;
66  else return &( mesh()->edges[ edge_idx() ] );
67  }
68 
69  inline Boundary * Side::cond() const {
70  if (cond_idx() == Mesh::undef_idx) return NULL;
71  else return &( mesh()->boundary_[ cond_idx() ] );
72  }
73 
74  inline unsigned int Side::cond_idx() const {
75  if (element_->boundary_idx_ == NULL) return Mesh::undef_idx;
76  else return element_->boundary_idx_[el_idx()];
77  }
78 
79 
80  inline unsigned int Side::el_idx() const {
81  return el_idx_;
82  }
83 
84 
85  inline bool Side::valid() const {
86  return element_!= NULL;
87  }
88 
89 
90  inline void Side::inc() {
91  el_idx_++;
92  }
93 
94 
95  inline void *Side::make_ptr() const {
96  return (void *)((long int) element_ << (2 + el_idx_) );
97  }
98 #endif /* SIDE_IMPL_HH_ */
unsigned int * boundary_idx_
Definition: elements.h:82
Definition: nodes.hh:32
unsigned int edge_idx() const
Definition: side_impl.hh:60
Boundary * cond() const
Definition: side_impl.hh:69
static const unsigned int undef_idx
Definition: mesh.h:112
Definition: mesh.h:99
Node ** node
Definition: elements.h:78
int n_sides
Definition: edges.h:36
vector< vector< vector< unsigned int > > > side_nodes
Definition: mesh.h:274
Definition: edges.h:26
bool valid() const
Definition: side_impl.hh:85
vector< Boundary > boundary_
Definition: mesh.h:229
Edge * edge() const
Definition: side_impl.hh:64
bool is_external() const
Definition: side_impl.hh:41
unsigned int dim() const
#define OLD_ASSERT(...)
Definition: global_defs.h:128
unsigned int * edge_idx_
Definition: elements.h:81
unsigned int dim() const
Definition: side_impl.hh:36
void * make_ptr() const
This is necessary by current DofHandler, should change this.
Definition: side_impl.hh:95
Side()
Definition: sides.h:33
Mesh * mesh_
Definition: elements.h:120
unsigned int cond_idx() const
Definition: side_impl.hh:74
ElementFullIter element() const
Definition: side_impl.hh:51
std::vector< Edge > edges
Vector of MH edges, this should not be part of the geometrical mesh.
Definition: mesh.h:236
FullIter full_iter(Iter it)
Definition: sys_vector.hh:428
unsigned int el_idx_
Definition: sides.h:109
unsigned int el_idx() const
Definition: side_impl.hh:80
const Element * element_
Definition: sides.h:108
void inc()
Definition: side_impl.hh:90
const Node * node(unsigned int i) const
Definition: side_impl.hh:45
Mesh * mesh() const
Definition: side_impl.hh:56
ElementVector element
Vector of elements of the mesh.
Definition: mesh.h:225
unsigned int n_nodes() const
Definition: side_impl.hh:32