This commit is made on behalf of Mark Olesen.
[OpenFOAM-1.6.x.git] / applications / utilities / mesh / generation / blockMesh / curvedEdges / CatmullRomSpline.H
blobd412bba0165c490623f5fe42b6b02fd10fd839ee
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2009-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::CatmullRomSpline
28 Description
29     An implementation of Catmull-Rom splines
30     (sometimes known as Overhauser splines).
32     In this implementation, the end tangents are created automatically
33     by reflection.
35     In matrix form, the @e local interpolation on the interval t=[0..1] is
36     described as follows:
37     @verbatim
38     P(t) = 1/2 * [ t^3 t^2 t 1 ] * [ -1  3 -3  1 ] * [ P-1 ]
39                                    [  2 -5  4 -1 ]   [ P0 ]
40                                    [ -1  0  1  0 ]   [ P1 ]
41                                    [  0  2  0  0 ]   [ P2 ]
42     @endverbatim
44     Where P-1 and P2 represent the neighbouring points or the extrapolated
45     end points. Simple reflection is used to automatically create the end
46     points.
48     The spline is discretized based on the chord length of the individual
49     segments. In rare cases (sections with very high curvatures), the
50     resulting distribution may be sub-optimal.
52 SeeAlso
53     http://www.algorithmist.net/catmullrom.html provides a nice
54     introduction
56 ToDo
57     A future implementation could also handle closed splines.
59 SourceFiles
60     CatmullRomSpline.C
62 \*---------------------------------------------------------------------------*/
64 #ifndef CatmullRomSpline_H
65 #define CatmullRomSpline_H
67 #include "polyLine.H"
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 namespace Foam
74 /*---------------------------------------------------------------------------*\
75                       Class CatmullRomSpline Declaration
76 \*---------------------------------------------------------------------------*/
78 class CatmullRomSpline
80     public polyLine
82     // Private Member Functions
84         //- Disallow default bitwise copy construct
85         CatmullRomSpline(const CatmullRomSpline&);
87         //- Disallow default bitwise assignment
88         void operator=(const CatmullRomSpline&);
91 public:
93     // Constructors
95         //- Construct from components
96         CatmullRomSpline
97         (
98             const pointField& knots,
99             const bool notImplementedClosed = false
100         );
103     // Member Functions
105         //- Return the point position corresponding to the curve parameter
106         //  0 <= lambda <= 1
107         point position(const scalar lambda) const;
109         //- Return the point position corresponding to the local parameter
110         //  0 <= lambda <= 1 on the given segment
111         point position(const label segment, const scalar lambda) const;
113         //- Return the length of the curve - not implemented
114         scalar length() const;
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 } // End namespace Foam
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 #endif
126 // ************************************************************************* //