version 3.8.0
Loading...
Searching...
No Matches
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
// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5
// SPDX-License-Identifier: GPL-3.0-or-later
6
//
12
#ifndef DUMUX_GEOMETRY_NORMAL_HH
13
#define DUMUX_GEOMETRY_NORMAL_HH
14
15
#include <algorithm>
16
#include <dune/common/float_cmp.hh>
17
18
namespace
Dumux
{
19
25
template
<
class
Vector>
26
inline
Vector
normal
(
const
Vector& v)
27
{
28
static_assert
(Vector::size() > 1,
"normal expects a coordinate dimension > 1"
);
29
30
if
constexpr
(Vector::size() == 2)
31
return
Vector({-v[1], v[0]});
32
33
const
auto
it = std::find_if(v.begin(), v.end(), [](
const
auto
& x) { return Dune::FloatCmp::ne(x, 0.0); });
34
const
auto
index = std::distance(v.begin(), it);
35
if
(index != Vector::size()-1)
36
{
37
Vector
normal
(0.0);
38
normal
[index] = -v[index+1];
39
normal
[index+1] = v[index];
40
return
normal
;
41
}
42
else
43
{
44
Vector
normal
(0.0);
45
normal
[index-1] = -v[index];
46
normal
[index] = v[index-1];
47
return
normal
;
48
49
}
50
}
51
57
template
<
class
Vector>
58
inline
Vector
unitNormal
(
const
Vector& v)
59
{
60
auto
normal
=
Dumux::normal
(v);
61
normal
/=
normal
.two_norm();
62
return
normal
;
63
}
64
65
}
// end namespace Dumux
66
67
#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:26
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:58
Dumux
Definition
adapt.hh:17
dumux
geometry
normal.hh
© Copyright 2010-
DuMux project contributors
(doc pages:
CC-BY 4.0
/ code examples:
GPLv3 or later
)
3.8.0 Generated by
1.9.8