Flow123d
side_impl.hh
Go to the documentation of this file.
1 /*
2  * side_impl.hh
3  *
4  * Created on: Jun 17, 2012
5  * Author: jb
6  */
7 
8 #ifndef SIDE_IMPL_HH_
9 #define SIDE_IMPL_HH_
10 
11 #include "mesh/mesh.h"
12 #include "mesh/edges.h"
13 
14 
15 inline Side::Side(const Element * ele, unsigned int set_lnum)
16 : element_(ele), el_idx_(set_lnum)
17 {
18  ASSERT(mesh()->element.full_iter( const_cast<Element *>(element_) ), "Wrong initialization of the Side.\n");
19 }
20 
21 
22  inline unsigned int Side::n_nodes() const {
23  return dim()+1;
24  }
25 
26  inline unsigned int Side::dim() const {
27  return element_->dim()-1;
28  }
29 
30  // returns true for all sides either on boundary or connected to vb neigboring
31  inline bool Side::is_external() const {
32  return edge()->n_sides == 1;
33  }
34 
35  inline const Node * Side::node(unsigned int i) const {
36  // cout << "sn dim: " << dim() << "side: " << lnum << "node: "<< i << endl;
37  int i_n = mesh()->side_nodes[dim()][el_idx_][i];
38  // cout << "el node: "<< i_n << "nn: " << element->n_nodes << endl;
39 
40  return element_->node[ i_n ];
41  }
42 
43  inline ElementFullIter Side::element() const {
44  ASSERT( valid(), "Wrong use of uninitialized accessor.\n");
45  return mesh()->element.full_iter( const_cast<Element *>(element_) );
46  }
47 
48  inline Mesh * Side::mesh() const {
49  return element_->mesh_;
50  }
51 
52  inline unsigned int Side::edge_idx() const {
53  return element_->edge_idx_[el_idx()];
54  }
55 
56  inline Edge * Side::edge() const {
57  if (edge_idx() == Mesh::undef_idx) return NULL;
58  else return &( mesh()->edges[ edge_idx() ] );
59  }
60 
61  inline Boundary * Side::cond() const {
62  if (cond_idx() == Mesh::undef_idx) return NULL;
63  else return &( mesh()->boundary_[ cond_idx() ] );
64  }
65 
66  inline unsigned int Side::cond_idx() const {
67  if (element_->boundary_idx_ == NULL) return Mesh::undef_idx;
68  else return element_->boundary_idx_[el_idx()];
69  }
70 
71 
72  inline unsigned int Side::el_idx() const {
73  return el_idx_;
74  }
75 
76 
77  inline bool Side::valid() const {
78  return element_!= NULL;
79  }
80 
81 
82  inline void Side::inc() {
83  el_idx_++;
84  }
85 
86 
87  inline void *Side::make_ptr() const {
88  return (void *)((long int) element_ << (2 + el_idx_) );
89  }
90 #endif /* SIDE_IMPL_HH_ */