Flow123d  release_3.0.0-1008-gca43bb7
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 {
30  mesh_->check_element_size(elem_idx);
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_ */
const Edge * edge() const
Definition: side_impl.hh:66
unsigned int * boundary_idx_
Definition: elements.h:83
NodeAccessor< 3 > node_accessor(unsigned int ni) const
Definition: accessors.hh:149
unsigned int side_idx() const
Definition: side_impl.hh:82
unsigned int edge_idx() const
Definition: side_impl.hh:62
Boundary * cond() const
Definition: side_impl.hh:71
static const unsigned int undef_idx
Definition: mesh.h:102
Definition: mesh.h:76
int n_sides
Definition: edges.h:36
vector< vector< vector< unsigned int > > > side_nodes
Definition: mesh.h:292
Definition: edges.h:26
bool valid() const
Definition: side_impl.hh:92
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
Definition: asserts.hh:346
vector< Boundary > boundary_
Definition: mesh.h:249
ElementAccessor< 3 > element() const
Definition: side_impl.hh:53
virtual ElementAccessor< 3 > element_accessor(unsigned int idx) const
Create and return ElementAccessor to element of given idx.
Definition: mesh.cc:726
bool is_external() const
Definition: side_impl.hh:43
unsigned int dim() const
Definition: elements.h:124
unsigned int elem_idx_
Index of element in Mesh::element_vec_.
Definition: sides.h:123
unsigned int dim() const
Definition: side_impl.hh:38
void check_element_size(unsigned int elem_idx) const
Check if given index is in element_vec_.
Definition: mesh.cc:1052
unsigned int edge_idx(unsigned int edg_idx) const
Return edge_idx of given index.
Definition: elements.h:139
Side()
Definition: sides.h:41
NodeAccessor< 3 > node(unsigned int i) const
Definition: side_impl.hh:47
unsigned int side_idx_
Local # of side in element (to remove it, we heve to remove calc_side_rhs)
Definition: sides.h:124
unsigned int cond_idx() const
Definition: side_impl.hh:76
const Mesh * mesh_
Pointer to Mesh to which belonged.
Definition: sides.h:122
std::vector< Edge > edges
Vector of MH edges, this should not be part of the geometrical mesh.
Definition: mesh.h:252
unsigned int elem_idx() const
Definition: side_impl.hh:87
void inc()
Definition: side_impl.hh:97
const Mesh * mesh() const
Definition: side_impl.hh:58
unsigned int n_nodes() const
Definition: side_impl.hh:34