Flow123d  release_3.0.0-968-gc87a28e79
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/accessors.hh"
22 #include "mesh/node_accessor.hh"
23 #include "mesh/mesh.h"
24 #include "mesh/edges.h"
25 
26 
27 inline Side::Side(const Mesh * mesh, unsigned int elem_idx, unsigned int set_lnum)
28 : mesh_(mesh), elem_idx_(elem_idx), side_idx_(set_lnum)
29 {
31 }
32 
33 
34  inline unsigned int Side::n_nodes() const {
35  return dim()+1;
36  }
37 
38  inline unsigned int Side::dim() const {
39  return element()->dim()-1;
40  }
41 
42  // returns true for all sides either on boundary or connected to vb neigboring
43  inline bool Side::is_external() const {
44  return edge()->n_sides == 1;
45  }
46 
47  inline NodeAccessor<3> Side::node(unsigned int i) const {
48  int i_n = mesh_->side_nodes[dim()][side_idx_][i];
49 
50  return element().node_accessor( i_n );
51  }
52 
54  ASSERT( valid() ).error("Wrong use of uninitialized accessor.\n");
55  return mesh_->element_accessor( elem_idx_ );
56  }
57 
58  inline const Mesh * Side::mesh() const {
59  return this->mesh_;
60  }
61 
62  inline unsigned int Side::edge_idx() const {
63  return element()->edge_idx(side_idx_);
64  }
65 
66  inline const Edge * Side::edge() const {
67  if (edge_idx() == Mesh::undef_idx) return NULL;
68  else return &( mesh_->edges[ edge_idx() ] );
69  }
70 
71  inline Boundary * Side::cond() const {
72  if (cond_idx() == Mesh::undef_idx) return NULL;
73  else return &( mesh_->boundary_[ cond_idx() ] );
74  }
75 
76  inline unsigned int Side::cond_idx() const {
77  if (element()->boundary_idx_ == NULL) return Mesh::undef_idx;
78  else return element()->boundary_idx_[side_idx_];
79  }
80 
81 
82  inline unsigned int Side::side_idx() const {
83  return side_idx_;
84  }
85 
86 
87  inline unsigned int Side::elem_idx() const {
88  return elem_idx_;
89  }
90 
91 
92  inline bool Side::valid() const {
93  return mesh_!= NULL;
94  }
95 
96 
97  inline void Side::inc() {
98  side_idx_++;
99  }
100 
101 
102  //inline void *Side::make_ptr() const {
103  // return (void *)((long int) element() << (2 + side_idx_) );
104  //}
105 #endif /* SIDE_IMPL_HH_ */
Side::side_idx_
unsigned int side_idx_
Local # of side in element (to remove it, we heve to remove calc_side_rhs)
Definition: sides.h:123
Boundary
Definition: boundaries.h:48
Mesh::boundary_
vector< Boundary > boundary_
Definition: mesh.h:258
Side::elem_idx_
unsigned int elem_idx_
Index of element in Mesh::element_vec_.
Definition: sides.h:122
Side::is_external
bool is_external() const
Definition: side_impl.hh:43
Mesh::undef_idx
static const unsigned int undef_idx
Definition: mesh.h:106
Side::Side
Side()
Definition: sides.h:41
ASSERT
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
Definition: asserts.hh:346
Element::dim
unsigned int dim() const
Definition: elements.h:124
Side::mesh_
const Mesh * mesh_
Pointer to Mesh to which belonged.
Definition: sides.h:121
Side::dim
unsigned int dim() const
Definition: side_impl.hh:38
ElementAccessor< 3 >
Side::edge
const Edge * edge() const
Definition: side_impl.hh:66
Side::elem_idx
unsigned int elem_idx() const
Definition: side_impl.hh:87
Side::cond
Boundary * cond() const
Definition: side_impl.hh:71
Side::edge_idx
unsigned int edge_idx() const
Definition: side_impl.hh:62
accessors.hh
Side::cond_idx
unsigned int cond_idx() const
Definition: side_impl.hh:76
Side::valid
bool valid() const
Definition: side_impl.hh:92
Edge::n_sides
int n_sides
Definition: edges.h:36
Side::mesh
const Mesh * mesh() const
Definition: side_impl.hh:58
Mesh::side_nodes
vector< vector< vector< unsigned int > > > side_nodes
Definition: mesh.h:301
Side::inc
void inc()
Definition: side_impl.hh:97
Side::element
ElementAccessor< 3 > element() const
Definition: side_impl.hh:53
mesh.h
Side::n_nodes
unsigned int n_nodes() const
Definition: side_impl.hh:34
Mesh::check_element_size
void check_element_size(unsigned int elem_idx) const
Check if given index is in element_vec_.
Definition: mesh.cc:1128
Side::side_idx
unsigned int side_idx() const
Definition: side_impl.hh:82
Mesh::edges
std::vector< Edge > edges
Vector of MH edges, this should not be part of the geometrical mesh.
Definition: mesh.h:261
ElementAccessor::node_accessor
NodeAccessor< 3 > node_accessor(unsigned int ni) const
Definition: accessors.hh:149
Element::edge_idx
unsigned int edge_idx(unsigned int edg_idx) const
Return edge_idx of given index.
Definition: elements.h:139
Mesh
Definition: mesh.h:80
Edge
Definition: edges.h:26
NodeAccessor
Definition: mesh.h:54
edges.h
Side::node
NodeAccessor< 3 > node(unsigned int i) const
Definition: side_impl.hh:47
Mesh::element_accessor
virtual ElementAccessor< 3 > element_accessor(unsigned int idx) const
Create and return ElementAccessor to element of given idx.
Definition: mesh.cc:802
Element::boundary_idx_
unsigned int * boundary_idx_
Definition: elements.h:83
node_accessor.hh