OpenFOAM: API Guide
v2012
The open source CFD toolbox
CatmullRomSpline.H
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | www.openfoam.com
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
Copyright (C) 2011-2016 OpenFOAM Foundation
9
Copyright (C) 2020 OpenCFD Ltd.
10
-------------------------------------------------------------------------------
11
License
12
This file is part of OpenFOAM.
13
14
OpenFOAM is free software: you can redistribute it and/or modify it
15
under the terms of the GNU General Public License as published by
16
the Free Software Foundation, either version 3 of the License, or
17
(at your option) any later version.
18
19
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22
for more details.
23
24
You should have received a copy of the GNU General Public License
25
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27
Class
28
Foam::CatmullRomSpline
29
30
Description
31
An implementation of Catmull-Rom splines
32
(sometimes known as Overhauser splines).
33
34
In this implementation, the end tangents are created automatically
35
by reflection.
36
37
In matrix form, the \e local interpolation on the interval t=[0..1] is
38
described as follows:
39
\verbatim
40
P(t) = 1/2 * [ t^3 t^2 t 1 ] * [ -1 3 -3 1 ] * [ P-1 ]
41
[ 2 -5 4 -1 ] [ P0 ]
42
[ -1 0 1 0 ] [ P1 ]
43
[ 0 2 0 0 ] [ P2 ]
44
\endverbatim
45
46
Where P-1 and P2 represent the neighbouring points or the extrapolated
47
end points. Simple reflection is used to automatically create the end
48
points.
49
50
The spline is discretized based on the chord length of the individual
51
segments. In rare cases (sections with very high curvatures), the
52
resulting distribution may be sub-optimal.
53
54
A future implementation could also handle closed splines.
55
56
See also
57
http://www.algorithmist.net/catmullrom.html provides a nice
58
introduction
59
60
SourceFiles
61
CatmullRomSpline.C
62
63
\*---------------------------------------------------------------------------*/
64
65
#ifndef CatmullRomSpline_H
66
#define CatmullRomSpline_H
67
68
#include "
polyLine.H
"
69
70
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71
72
namespace
Foam
73
{
74
75
/*---------------------------------------------------------------------------*\
76
Class CatmullRomSpline Declaration
77
\*---------------------------------------------------------------------------*/
78
79
class
CatmullRomSpline
80
:
81
public
polyLine
82
{
83
public
:
84
85
// Constructors
86
87
//- Construct from components
88
explicit
CatmullRomSpline
89
(
90
const
pointField
& knots,
91
const
bool
notImplementedClosed =
false
92
);
93
94
95
// Member Functions
96
97
//- The point position corresponding to the curve parameter
98
// 0 <= lambda <= 1
99
point
position
(
const
scalar
lambda
)
const
;
100
101
//- The point position corresponding to the local parameter
102
// 0 <= lambda <= 1 on the given segment
103
point
position
(
const
label
segment
,
const
scalar
lambda
)
const
;
104
105
//- The length of the curve
106
// \note NotImplemented
107
scalar
length
()
const
;
108
};
109
110
111
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112
113
}
// End namespace Foam
114
115
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116
117
#endif
118
119
// ************************************************************************* //
Foam::polyLine
A series of straight line segments, which can also be interpreted as a series of control points for s...
Definition:
polyLine.H:55
polyLine.H
Foam::CatmullRomSpline
An implementation of Catmull-Rom splines (sometimes known as Overhauser splines).
Definition:
CatmullRomSpline.H:78
Foam::CatmullRomSpline::position
point position(const scalar lambda) const
The point position corresponding to the curve parameter.
Definition:
CatmullRomSpline.C:44
Foam::Field< vector >
lambda
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
Foam::CatmullRomSpline::CatmullRomSpline
CatmullRomSpline(const pointField &knots, const bool notImplementedClosed=false)
Construct from components.
Definition:
CatmullRomSpline.C:33
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:33
Foam::Pair
An ordered pair of two objects of type <T> with first() and second() elements.
Definition:
Pair.H:54
Foam::Vector< scalar >
Foam::CatmullRomSpline::length
scalar length() const
The length of the curve.
Definition:
CatmullRomSpline.C:134
src
mesh
blockMesh
blockEdges
splineEdge
CatmullRomSpline.H
Generated by
1.8.17
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.