3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
Loading...
Searching...
No Matches
dumux
geometry
normal.hh
Go to the documentation of this file.
1
/*****************************************************************************
2
* See the file COPYING for full copying permissions. *
3
* *
4
* This program is free software: you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation, either version 3 of the License, or *
7
* (at your option) any later version. *
8
* *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
13
* *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
16
*****************************************************************************/
22
#ifndef DUMUX_GEOMETRY_NORMAL_HH
23
#define DUMUX_GEOMETRY_NORMAL_HH
24
25
#include <algorithm>
26
#include <dune/common/float_cmp.hh>
27
28
namespace
Dumux
{
29
35
template
<
class
Vector>
36
inline
Vector
normal
(
const
Vector& v)
37
{
38
static_assert
(Vector::size() > 1,
"normal expects a coordinate dimension > 1"
);
39
40
if
constexpr
(Vector::size() == 2)
41
return
Vector({-v[1], v[0]});
42
43
const
auto
it = std::find_if(v.begin(), v.end(), [](
const
auto
& x) { return Dune::FloatCmp::ne(x, 0.0); });
44
const
auto
index = std::distance(v.begin(), it);
45
if
(index != Vector::size()-1)
46
{
47
Vector
normal
(0.0);
48
normal
[index] = -v[index+1];
49
normal
[index+1] = v[index];
50
return
normal
;
51
}
52
else
53
{
54
Vector
normal
(0.0);
55
normal
[index-1] = -v[index];
56
normal
[index] = v[index-1];
57
return
normal
;
58
59
}
60
}
61
67
template
<
class
Vector>
68
inline
Vector
unitNormal
(
const
Vector& v)
69
{
70
auto
normal
=
Dumux::normal
(v);
71
normal
/=
normal
.two_norm();
72
return
normal
;
73
}
74
75
}
// end namespace Dumux
76
77
#endif
Dumux::normal
Vector normal(const Vector &v)
Create a vector normal to the given one (v is expected to be non-zero).
Definition
normal.hh:36
Dumux::unitNormal
Vector unitNormal(const Vector &v)
Create a vector normal to the given one (v is expected to be non-zero).
Definition
normal.hh:68
Dumux
Definition
adapt.hh:29
Generated by
1.16.1