3.6-git
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
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
// vi: set et ts=4 sw=4 sts=4:
3
/*****************************************************************************
4
* See the file COPYING for full copying permissions. *
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
*****************************************************************************/
24
#ifndef DUMUX_GEOMETRY_NORMAL_HH
25
#define DUMUX_GEOMETRY_NORMAL_HH
26
27
#include <algorithm>
28
#include <dune/common/float_cmp.hh>
29
30
namespace
Dumux
{
31
37
template
<
class
Vector>
38
inline
Vector
normal
(
const
Vector& v)
39
{
40
static_assert
(Vector::size() > 1,
"normal expects a coordinate dimension > 1"
);
41
42
if
constexpr
(Vector::size() == 2)
43
return
Vector({-v[1], v[0]});
44
45
const
auto
it = std::find_if(v.begin(), v.end(), [](
const
auto
& x) { return Dune::FloatCmp::ne(x, 0.0); });
46
const
auto
index = std::distance(v.begin(), it);
47
if
(index != Vector::size()-1)
48
{
49
Vector
normal
(0.0);
50
normal
[index] = -v[index+1];
51
normal
[index+1] = v[index];
52
return
normal
;
53
}
54
else
55
{
56
Vector
normal
(0.0);
57
normal
[index-1] = -v[index];
58
normal
[index] = v[index-1];
59
return
normal
;
60
61
}
62
}
63
69
template
<
class
Vector>
70
inline
Vector
unitNormal
(
const
Vector& v)
71
{
72
auto
normal
=
Dumux::normal
(v);
73
normal
/=
normal
.two_norm();
74
return
normal
;
75
}
76
77
}
// end namespace Dumux
78
79
#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:38
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:70
Dumux
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition
adapt.hh:29
Generated by
1.16.1