NiHu  2.0
location_normal.hpp
Go to the documentation of this file.
1 // This file is a part of NiHu, a C++ BEM template library.
2 //
3 // Copyright (C) 2012-2014 Peter Fiala <fiala@hit.bme.hu>
4 // Copyright (C) 2012-2014 Peter Rucz <rucz@hit.bme.hu>
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
25 #ifndef LOCATION_NORMAL_HPP_INCLUDED
26 #define LOCATION_NORMAL_HPP_INCLUDED
27 
28 #include "../core/element.hpp"
29 
30 namespace NiHu
31 {
32 
36 template <class Space>
38 {
39 public:
41  typedef Space space_t;
43  typedef typename space_t::location_t x_t;
45  typedef typename space_t::scalar_t scalar_t;
46 
51  template <class elem_t>
52  location_input(elem_t const &elem, typename elem_t::xi_t const &xi) :
53  m_x(elem.get_x(xi))
54  {
55  }
56 
59  location_input(x_t const &x)
60  : m_x(x)
61  {
62  }
63 
65  x_t const &get_x(void) const
66  {
67  return m_x;
68  }
69 
70 private:
71  x_t m_x;
72 };
73 
74 
78 template <class Space>
80  : public location_input<Space>
81 {
82 public:
84  typedef Space space_t;
86  typedef typename space_t::location_t x_t;
88  typedef typename space_t::scalar_t scalar_t;
89 
94  template <class elem_t>
95  location_normal_jacobian_input(elem_t const &elem, typename elem_t::xi_t const &xi)
96  : location_input<Space>(elem, xi)
97  , m_jac_vector(elem.get_normal(xi))
98  , m_jac(m_jac_vector.norm())
99  , m_unit_normal(m_jac_vector / m_jac)
100  {
101  }
102 
107  location_normal_jacobian_input(x_t const &x, x_t const &jac_vector)
108  : location_input<Space>(x)
109  , m_jac_vector(jac_vector)
110  , m_jac(m_jac_vector.norm())
111  , m_unit_normal(m_jac_vector / m_jac)
112  {
113  }
114 
116  x_t const &get_unit_normal(void) const
117  {
118  return m_unit_normal;
119  }
120 
122  scalar_t const &get_jacobian(void) const
123  {
124  return m_jac;
125  }
126 
129  x_t const &get_jacobian_vector() const
130  {
131  return m_jac_vector;
132  }
133 
134 private:
135  x_t m_jac_vector;
136  scalar_t m_jac;
137  x_t m_unit_normal;
138 };
139 
140 
144 template <class Space>
146  : public location_input<Space>
147 {
148 public:
150  typedef Space space_t;
152  typedef typename space_t::scalar_t scalar_t;
153 
154  typedef typename space_t::location_t location_t;
155 
160  template <class elem_t>
161  location_volume_jacobian_input(elem_t const &elem, typename elem_t::xi_t const &xi) :
162  location_input<Space>(elem, xi),
163  m_jac(elem.get_dx(xi).determinant())
164  {
165  }
166 
170  location_volume_jacobian_input(location_t const &x, scalar_t const &jac) :
171  location_input<Space>(x),
172  m_jac(jac)
173  {
174  }
175 
177  scalar_t const &get_jacobian(void) const
178  {
179  return m_jac;
180  }
181 
182 private:
183  scalar_t m_jac;
184 };
185 
186 
187 typedef location_input<space_1d<> > location_input_1d;
188 typedef location_input<space_2d<> > location_input_2d;
189 typedef location_input<space_3d<> > location_input_3d;
190 
191 typedef location_normal_jacobian_input<space_2d<> > location_normal_input_2d;
192 typedef location_normal_jacobian_input<space_3d<> > location_normal_input_3d;
193 
194 
195 } // end of namespace NiHu
196 
197 #endif // LOCATION_NORMAL_HPP_INCLUDED
198 
NiHu::location_normal_jacobian_input::scalar_t
space_t::scalar_t scalar_t
the scalar type
Definition: location_normal.hpp:88
NiHu::volume_element
class describing a volume element that has no normal vector
Definition: element.hpp:455
NiHu::location_volume_jacobian_input
a class representing a Jacobian input used for volume elements
Definition: location_normal.hpp:145
NiHu::location_normal_jacobian_input::location_normal_jacobian_input
location_normal_jacobian_input(elem_t const &elem, typename elem_t::xi_t const &xi)
constructor
Definition: location_normal.hpp:95
NiHu::location_normal_jacobian_input::space_t
Space space_t
template parameter as nested type
Definition: location_normal.hpp:84
NiHu::location_input::x_t
space_t::location_t x_t
the location type
Definition: location_normal.hpp:43
NiHu::location_normal_jacobian_input
a class representing a normal + Jacobian input
Definition: location_normal.hpp:79
NiHu::location_volume_jacobian_input::space_t
Space space_t
template parameter as nested type
Definition: location_normal.hpp:150
NiHu::location_normal_jacobian_input::get_jacobian
const scalar_t & get_jacobian(void) const
return the Jacobian
Definition: location_normal.hpp:122
NiHu::location_input::space_t
Space space_t
template parameter as nested type
Definition: location_normal.hpp:41
NiHu::location_input::scalar_t
space_t::scalar_t scalar_t
the scalar type
Definition: location_normal.hpp:45
NiHu::location_input::location_input
location_input(x_t const &x)
constructor from location
Definition: location_normal.hpp:59
NiHu::location_volume_jacobian_input::location_volume_jacobian_input
location_volume_jacobian_input(location_t const &x, scalar_t const &jac)
constructor
Definition: location_normal.hpp:170
NiHu::location_volume_jacobian_input::location_volume_jacobian_input
location_volume_jacobian_input(elem_t const &elem, typename elem_t::xi_t const &xi)
constructor
Definition: location_normal.hpp:161
NiHu::location_volume_jacobian_input::scalar_t
space_t::scalar_t scalar_t
the scalar type
Definition: location_normal.hpp:152
NiHu::location_input::get_x
const x_t & get_x(void) const
return the location
Definition: location_normal.hpp:65
NiHu::location_normal_jacobian_input::get_jacobian_vector
const x_t & get_jacobian_vector() const
return the jacobian
Definition: location_normal.hpp:129
NiHu::location_normal_jacobian_input::location_normal_jacobian_input
location_normal_jacobian_input(x_t const &x, x_t const &jac_vector)
constructor from location and jacobian vector
Definition: location_normal.hpp:107
NiHu::volume_element::xi_t
domain_t::xi_t xi_t
type of the shape functions' independent variable
Definition: element.hpp:210
NiHu::location_normal_jacobian_input::x_t
space_t::location_t x_t
the location type
Definition: location_normal.hpp:86
NiHu::location_input::location_input
location_input(elem_t const &elem, typename elem_t::xi_t const &xi)
constructor
Definition: location_normal.hpp:52
NiHu::location_volume_jacobian_input::get_jacobian
const scalar_t & get_jacobian(void) const
return the Jacobian
Definition: location_normal.hpp:177
NiHu::location_input
a class representing a simple location
Definition: location_normal.hpp:37
NiHu::location_normal_jacobian_input::get_unit_normal
const x_t & get_unit_normal(void) const
return the unit normal vector
Definition: location_normal.hpp:116