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