diff --git a/applications/test/spline/splineTest.C b/applications/test/spline/splineTest.C index 4c793c2136195f879b209682eb892ccf855c239d..3d92a7dd241357d2a840cfa456d4503953c84607 100644 --- a/applications/test/spline/splineTest.C +++ b/applications/test/spline/splineTest.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,11 +29,17 @@ License #include "IFstream.H" #include "BSpline.H" -#include "BSpline2.H" #include "CatmullRomSpline.H" using namespace Foam; +inline Ostream& printPoint(Ostream& os, const point& p) +{ + os << p.x() << ' ' << p.y() << ' ' << p.z() << nl; + return os; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: @@ -41,8 +47,7 @@ int main(int argc, char *argv[]) { argList::noParallel(); argList::validArgs.insert("file .. fileN"); - argList::addBoolOption("Bold", "B-Spline implementation OLD"); - argList::addBoolOption("Bnew", "B-Spline implementation NEW"); + argList::addBoolOption("B", "B-Spline implementation"); argList::addBoolOption("CMR", "catmull-rom spline (default)"); argList::addOption ( @@ -58,12 +63,11 @@ int main(int argc, char *argv[]) args.printUsage(); } - bool useBSplineOld = args.optionFound("Bold"); - bool useBSplineNew = args.optionFound("Bnew"); + bool useBSpline = args.optionFound("B"); bool useCatmullRom = args.optionFound("CMR"); label nSeg = args.optionLookupOrDefault<label>("n", 20); - if (!useCatmullRom && !useBSplineOld && !useBSplineNew) + if (!useCatmullRom && !useBSpline) { Info<<"defaulting to Catmull-Rom spline" << endl; useCatmullRom = true; @@ -77,55 +81,50 @@ int main(int argc, char *argv[]) List<pointField> pointFields(ifs); + forAll(pointFields, splineI) { - Info<<"\noriginal points: " << pointFields[splineI] << nl; + Info<<"\n# points:" << endl; + forAll(pointFields[splineI], ptI) + { + printPoint(Info, pointFields[splineI][ptI]); + } - if (useBSplineOld) + if (useBSpline) { BSpline spl(pointFields[splineI]); - Info<< nl - << "B-Spline interpolation: OLD" << nl - << "----------------------" << endl; + Info<< nl << "# B-Spline" << endl; for (label segI = 0; segI <= nSeg; ++segI) { scalar lambda = scalar(segI)/scalar(nSeg); - Info<< spl.position(lambda) << " // " << lambda << endl; + printPoint(Info, spl.position(lambda)); } } - if (useBSplineNew) + if (useCatmullRom) { - BSpline2 spl(pointFields[splineI]); + CatmullRomSpline spl(pointFields[splineI]); - Info<< nl - << "B-Spline interpolation: NEW" << nl - << "----------------------" << endl; + Info<< nl <<"# Catmull-Rom" << endl; for (label segI = 0; segI <= nSeg; ++segI) { scalar lambda = scalar(segI)/scalar(nSeg); - Info<< spl.position(lambda) << " // " << lambda << endl; + printPoint(Info, spl.position(lambda)); } } - if (useCatmullRom) { - CatmullRomSpline spl - ( - pointFields[splineI] - ); + polyLine pl(pointFields[splineI]); - Info<< nl - <<"Catmull-Rom interpolation:" << nl - << "-------------------------" << endl; + Info<< nl <<"# polyList" << endl; for (label segI = 0; segI <= nSeg; ++segI) { scalar lambda = scalar(segI)/scalar(nSeg); - Info<< spl.position(lambda) << " // " << lambda << endl; + printPoint(Info, pl.position(lambda)); } } } diff --git a/applications/test/spline/test-splines b/applications/test/spline/test-splines index f5c3a46ae4bd0c2d308801293e9f768f2458d092..63f7bd17dd1cf34c86d3f7ad039fe36ec0dc9cfa 100644 --- a/applications/test/spline/test-splines +++ b/applications/test/spline/test-splines @@ -6,64 +6,41 @@ | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ ( - // Upper body longitudinal splines. + // Upper body longitudinal splines ( - (-0.22685 -0.01125166 0) // 7 - (-0.21685 -0.01340204 0) - (-0.20685 -0.01529684 0) - (-0.19685 -0.01694748 0) - (-0.18685 -0.01836538 0) - (-0.17685 -0.01956197 0) - (-0.16685 -0.02054868 0) - (-0.15685 -0.02133693 0) - (-0.14685 -0.02193816 0) - (-0.13685 -0.02236377 0) - (-0.12685 -0.02262521 0) - (-0.11685 -0.02273389 0) // 2 + (0.22685 0.01125166 0) // 7 + (0.21685 0.01340204 0) + (0.20685 0.01529684 0) + (0.19685 0.01694748 0) + (0.18685 0.01836538 0) + (0.17685 0.01956197 0) + (0.16685 0.02054868 0) + (0.15685 0.02133693 0) + (0.14685 0.02193816 0) + (0.13685 0.02236377 0) + (0.12685 0.02262521 0) + (0.11685 0.02273389 0) // 2 ) + // sine function ( - (-0.22685 0 0.01125166) // 8 - (-0.21685 0 0.01340204) - (-0.20685 0 0.01529684) - (-0.19685 0 0.01694748) - (-0.18685 0 0.01836538) - (-0.17685 0 0.01956197) - (-0.16685 0 0.02054868) - (-0.15685 0 0.02133693) - (-0.14685 0 0.02193816) - (-0.13685 0 0.02236377) - (-0.12685 0 0.02262521) - (-0.11685 0 0.02273389) // 3 + (0 0 0) + (45 0.70707 0) + (90 1 0) + (135 0.70707 0) + (180 0 0) + (225 -0.70707 0) + (270 -1 0) + (315 -0.70707 0) + (360 0 0) ) + // cosine function, but with extremely few points ( - (-0.22685 0.01125166 0) // 9 - (-0.21685 0.01340204 0) - (-0.20685 0.01529684 0) - (-0.19685 0.01694748 0) - (-0.18685 0.01836538 0) - (-0.17685 0.01956197 0) - (-0.16685 0.02054868 0) - (-0.15685 0.02133693 0) - (-0.14685 0.02193816 0) - (-0.13685 0.02236377 0) - (-0.12685 0.02262521 0) - (-0.11685 0.02273389 0) // 4 + (0 1 0) + (180 -1 0) + (360 1 0) ) - ( - (-0.22685 0 -0.01125166) // 6 - (-0.21685 0 -0.01340204) - (-0.20685 0 -0.01529684) - (-0.19685 0 -0.01694748) - (-0.18685 0 -0.01836538) - (-0.17685 0 -0.01956197) - (-0.16685 0 -0.02054868) - (-0.15685 0 -0.02133693) - (-0.14685 0 -0.02193816) - (-0.13685 0 -0.02236377) - (-0.12685 0 -0.02262521) - (-0.11685 0 -0.02273389) // 1 - ) + ); diff --git a/src/mesh/blockMesh/Make/files b/src/mesh/blockMesh/Make/files index 3b08f6062bc46e2ca15168e43734fb25fce10288..cda173e1f6f78c2137123dae3c92dae1ec7f1170 100644 --- a/src/mesh/blockMesh/Make/files +++ b/src/mesh/blockMesh/Make/files @@ -1,4 +1,4 @@ -curvedEdges/BSpline2.C +curvedEdges/BSpline.C curvedEdges/CatmullRomSpline.C curvedEdges/polyLine.C @@ -9,11 +9,6 @@ curvedEdges/polyLineEdge.C curvedEdges/lineDivide.C curvedEdges/splineEdge.C -curvedEdges/legacy/spline.C -curvedEdges/legacy/BSpline.C -curvedEdges/legacy/simpleSplineEdge.C -curvedEdges/legacy/polySplineEdge.C - blockDescriptor/blockDescriptor.C blockDescriptor/blockDescriptorEdges.C diff --git a/src/mesh/blockMesh/curvedEdges/BSpline2.C b/src/mesh/blockMesh/curvedEdges/BSpline.C similarity index 82% rename from src/mesh/blockMesh/curvedEdges/BSpline2.C rename to src/mesh/blockMesh/curvedEdges/BSpline.C index 8208a59700211f4145673b4e4215f3a08183e141..811101c154349e5bea0312b9ac9e9017a2d96460 100644 --- a/src/mesh/blockMesh/curvedEdges/BSpline2.C +++ b/src/mesh/blockMesh/curvedEdges/BSpline.C @@ -25,24 +25,23 @@ License \*---------------------------------------------------------------------------*/ #include "error.H" -#include "BSpline2.H" +#include "BSpline.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::BSpline2::BSpline2 +Foam::BSpline::BSpline ( - const pointField& Knots, - const vector&, - const vector& + const pointField& knots, + const bool closed ) : - polyLine(Knots) + polyLine(knots, closed) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::point Foam::BSpline2::position(const scalar mu) const +Foam::point Foam::BSpline::position(const scalar mu) const { // endpoints if (mu < SMALL) @@ -60,25 +59,36 @@ Foam::point Foam::BSpline2::position(const scalar mu) const } -Foam::point Foam::BSpline2::position +Foam::point Foam::BSpline::position ( const label segment, const scalar mu ) const { + // out-of-bounds + if (segment < 0) + { + return points().first(); + } + else if (segment > nSegments()) + { + return points().last(); + } + const point& p0 = points()[segment]; const point& p1 = points()[segment+1]; // special cases - no calculation needed - if (segment < 0 || mu < 0.0) + if (mu <= 0.0) { return p0; } - else if (segment > nSegments() || mu >= 1.0) + else if (mu >= 1.0) { return p1; } + // determine the end points point e0; point e1; @@ -86,7 +96,7 @@ Foam::point Foam::BSpline2::position if (segment == 0) { // end: simple reflection - e0 = 2.0 * p0 - p1; + e0 = 2*p0 - p1; } else { @@ -96,7 +106,7 @@ Foam::point Foam::BSpline2::position if (segment+1 == nSegments()) { // end: simple reflection - e1 = 2.0 * p1 - p0; + e1 = 2*p1 - p0; } else { @@ -121,9 +131,9 @@ Foam::point Foam::BSpline2::position } -Foam::scalar Foam::BSpline2::length() const +Foam::scalar Foam::BSpline::length() const { - notImplemented("BSpline2::length() const"); + notImplemented("BSpline::length() const"); return 1.0; } diff --git a/src/mesh/blockMesh/curvedEdges/BSpline2.H b/src/mesh/blockMesh/curvedEdges/BSpline.H similarity index 76% rename from src/mesh/blockMesh/curvedEdges/BSpline2.H rename to src/mesh/blockMesh/curvedEdges/BSpline.H index 9aa5d1760e27ee80d9e555f25fa5ad4c8eb3e9d0..b26c6887049cbb79ed67aaf2264fd8094cf0b8e0 100644 --- a/src/mesh/blockMesh/curvedEdges/BSpline2.H +++ b/src/mesh/blockMesh/curvedEdges/BSpline.H @@ -23,13 +23,13 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::BSpline2 + Foam::BSpline Description An implementation of B-splines. - In this implementation, the end tangents are created - automatically by reflection. + In this implementation, the end tangents are created automatically + by reflection. In matrix form, the @e local interpolation on the interval t=[0..1] is described as follows: @@ -40,28 +40,27 @@ Description [ 1 4 1 0 ] [ P2 ] @endverbatim - Where P-1 and P2 represent the neighbouring points or the - extrapolated end points. Simple reflection is used to - automatically create the end points. + Where P-1 and P2 represent the neighbouring points or the extrapolated + end points. Simple reflection is used to automatically create the end + points. - The spline is discretized based on the chord length of the - individual segments. In rare cases (sections with very high - curvatures), the resulting distribution may be sub-optimal. + The spline is discretized based on the chord length of the individual + segments. In rare cases (sections with very high curvatures), the + resulting distribution may be sub-optimal. SeeAlso CatmullRomSpline ToDo - A future implementation could also handle closed splines - either - when the start/end points are identically or when specified. + A future implementation could also handle closed splines. SourceFiles - BSpline2.C + BSpline.C \*---------------------------------------------------------------------------*/ -#ifndef BSpline2_H -#define BSpline2_H +#ifndef BSpline_H +#define BSpline_H #include "polyLine.H" @@ -71,20 +70,20 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class BSpline2 Declaration + Class BSpline Declaration \*---------------------------------------------------------------------------*/ -class BSpline2 +class BSpline : public polyLine { // Private Member Functions //- Disallow default bitwise copy construct - BSpline2(const BSpline2&); + BSpline(const BSpline&); //- Disallow default bitwise assignment - void operator=(const BSpline2&); + void operator=(const BSpline&); public: @@ -92,11 +91,10 @@ public: // Constructors //- Construct from components - BSpline2 + BSpline ( const pointField& knots, - const vector& begTangentNotImplemented = vector::zero, - const vector& endTangentNotImplemented = vector::zero + const bool notImplementedClosed = false ); diff --git a/src/mesh/blockMesh/curvedEdges/CatmullRomSpline.C b/src/mesh/blockMesh/curvedEdges/CatmullRomSpline.C index 74dbe69f85ad8a01d5663cbadc75cb976753b645..7b4fd684d24ab3be727bdd2645c4eeb1c40066a3 100644 --- a/src/mesh/blockMesh/curvedEdges/CatmullRomSpline.C +++ b/src/mesh/blockMesh/curvedEdges/CatmullRomSpline.C @@ -31,12 +31,11 @@ License Foam::CatmullRomSpline::CatmullRomSpline ( - const pointField& Knots, - const vector&, - const vector& + const pointField& knots, + const bool closed ) : - polyLine(Knots) + polyLine(knots, closed) {} @@ -66,19 +65,30 @@ Foam::point Foam::CatmullRomSpline::position const scalar mu ) const { + // out-of-bounds + if (segment < 0) + { + return points().first(); + } + else if (segment > nSegments()) + { + return points().last(); + } + const point& p0 = points()[segment]; const point& p1 = points()[segment+1]; // special cases - no calculation needed - if (segment < 0 || mu < 0.0) + if (mu <= 0.0) { return p0; } - else if (segment > nSegments() || mu >= 1.0) + else if (mu >= 1.0) { return p1; } + // determine the end points point e0; point e1; @@ -86,7 +96,7 @@ Foam::point Foam::CatmullRomSpline::position if (segment == 0) { // end: simple reflection - e0 = 2.0 * p0 - p1; + e0 = 2*p0 - p1; } else { @@ -96,7 +106,7 @@ Foam::point Foam::CatmullRomSpline::position if (segment+1 == nSegments()) { // end: simple reflection - e1 = 2.0 * p1 - p0; + e1 = 2*p1 - p0; } else { diff --git a/src/mesh/blockMesh/curvedEdges/CatmullRomSpline.H b/src/mesh/blockMesh/curvedEdges/CatmullRomSpline.H index 6f1851a7a65821af8c7986c38c0a17d7504429e0..032180a2caf4d2f1a859ced3581aa4e231c13ed1 100644 --- a/src/mesh/blockMesh/curvedEdges/CatmullRomSpline.H +++ b/src/mesh/blockMesh/curvedEdges/CatmullRomSpline.H @@ -26,36 +26,35 @@ Class Foam::CatmullRomSpline Description - An implementation of Catmull-Rom splines (sometime as known as - Overhauser splines). + An implementation of Catmull-Rom splines + (sometimes known as Overhauser splines). - In this implementation, the end tangents are created - automatically by reflection. + In this implementation, the end tangents are created automatically + by reflection. In matrix form, the @e local interpolation on the interval t=[0..1] is described as follows: @verbatim - P(t) = 0.5 * [ t^3 t^2 t 1 ] * [ -1 3 -3 1 ] * [ P-1 ] + P(t) = 1/2 * [ t^3 t^2 t 1 ] * [ -1 3 -3 1 ] * [ P-1 ] [ 2 -5 4 -1 ] [ P0 ] [ -1 0 1 0 ] [ P1 ] [ 0 2 0 0 ] [ P2 ] @endverbatim - Where P-1 and P2 represent the neighbouring points or the - extrapolated end points. Simple reflection is used to - automatically create the end points. + Where P-1 and P2 represent the neighbouring points or the extrapolated + end points. Simple reflection is used to automatically create the end + points. - The spline is discretized based on the chord length of the - individual segments. In rare cases (sections with very high - curvatures), the resulting distribution may be sub-optimal. + The spline is discretized based on the chord length of the individual + segments. In rare cases (sections with very high curvatures), the + resulting distribution may be sub-optimal. SeeAlso http://www.algorithmist.net/catmullrom.html provides a nice introduction ToDo - A future implementation could also handle closed splines - either - when the start/end points are identically or when specified. + A future implementation could also handle closed splines. SourceFiles CatmullRomSpline.C @@ -97,8 +96,7 @@ public: CatmullRomSpline ( const pointField& knots, - const vector& begTangentNotImplemented = vector::zero, - const vector& endTangentNotImplemented = vector::zero + const bool notImplementedClosed = false ); diff --git a/src/mesh/blockMesh/curvedEdges/legacy/BSpline.C b/src/mesh/blockMesh/curvedEdges/legacy/BSpline.C deleted file mode 100644 index cd7ee90ca1e195e9270034943ac06a819038816d..0000000000000000000000000000000000000000 --- a/src/mesh/blockMesh/curvedEdges/legacy/BSpline.C +++ /dev/null @@ -1,137 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "error.H" - -#include "BSpline.H" -#include "simpleMatrix.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -Foam::pointField Foam::BSpline::findKnots -( - const pointField& allknots, - const vector& fstend, - const vector& sndend -) -{ - const label NKnots = allknots.size(); - - // set up 1/6 and 2/3 which are the matrix elements throughout most - // of the matrix - - register const scalar oneSixth = 1.0/6.0; - register const scalar twoThird = 2.0/3.0; - - simpleMatrix<vector> M(NKnots+2, 0, vector::zero); - - // set up the matrix - M[0][0] = -0.5*scalar(NKnots - 1); - M[0][2] = 0.5*scalar(NKnots - 1); - - for (register label i = 1; i <= NKnots; i++) - { - M[i][i-1] = oneSixth; - M[i][i] = twoThird; - M[i][i+1] = oneSixth; - } - - M[NKnots+1][NKnots-1] = -0.5*scalar(NKnots - 1); - M[NKnots+1][NKnots+1] = 0.5*scalar(NKnots - 1); - - // set up the vector - for (register label i = 1; i <= NKnots; i++) - { - M.source()[i] = allknots[i-1]; - } - - // set the gradients at the ends: - - if (mag(fstend) < 1e-8) - { - // default : forward differences on the end knots - M.source()[0] = allknots[1] - allknots[0]; - M.source()[0] /= mag(M.source()[0]); - } - else - { - // use the gradient vector provided - M.source()[0] = fstend/mag(fstend); - } - - if (mag(sndend)<1e-8) - { - // default : forward differences on the end knots - M.source()[NKnots+1] = M.source()[NKnots-1] - M.source()[NKnots]; - M.source()[NKnots+1] /= mag(M.source()[NKnots+1]); - } - else - { - // use the gradient vector provided - M.source()[NKnots+1] = sndend/mag(sndend); - } - - - // invert the equation to find the control knots - return M.solve(); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::BSpline::BSpline -( - const pointField& Knots, - const vector& fstend, - const vector& sndend -) -: - spline(findKnots(Knots, fstend, sndend)) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::point Foam::BSpline::realPosition(const scalar mu) const -{ - return spline::position(mu); -} - - -Foam::point Foam::BSpline::position(const scalar mu) const -{ - return spline::position((1.0/(nKnots() - 1))*(1.0 + mu*(nKnots() - 3))); -} - - -Foam::scalar Foam::BSpline::length() const -{ - notImplemented("BSpline::length() const"); - return 1.0; -} - - -// ************************************************************************* // diff --git a/src/mesh/blockMesh/curvedEdges/legacy/BSpline.H b/src/mesh/blockMesh/curvedEdges/legacy/BSpline.H deleted file mode 100644 index 5ba6423ea12d4a6cdee287e9dd1803d6b13166c7..0000000000000000000000000000000000000000 --- a/src/mesh/blockMesh/curvedEdges/legacy/BSpline.H +++ /dev/null @@ -1,106 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Class - Foam::BSpline - -Description - A cubic spline going through all the knots - -SourceFiles - BSpline.C - -\*---------------------------------------------------------------------------*/ - -#ifndef BSpline_H -#define BSpline_H - -#include "spline.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class BSpline Declaration -\*---------------------------------------------------------------------------*/ - -class BSpline -: - public spline -{ - // Private Member Functions - - pointField findKnots - ( - const pointField&, - const vector& fstend, - const vector& sndend - ); - - //- Disallow default bitwise copy construct - BSpline(const BSpline&); - - //- Disallow default bitwise assignment - void operator=(const BSpline&); - - -public: - - // Constructors - - //- Construct from components - BSpline - ( - const pointField& knots, - const vector& fstend = vector::zero, - const vector& sndend = vector::zero - ); - - - // Member Functions - - //- Return the real point position corresponding to the curve parameter - // 0 <= lambda <= 1 - point realPosition(const scalar lambda) const; - - //- Return the point position corresponding to the curve parameter - // 0 <= lambda <= 1 - point position(const scalar lambda) const; - - //- Return the length of the curve - scalar length() const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/mesh/blockMesh/curvedEdges/legacy/polySplineEdge.C b/src/mesh/blockMesh/curvedEdges/legacy/polySplineEdge.C deleted file mode 100644 index bf370cd7d3fe0fee5ebb1f554fd430a032b836a3..0000000000000000000000000000000000000000 --- a/src/mesh/blockMesh/curvedEdges/legacy/polySplineEdge.C +++ /dev/null @@ -1,150 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "polySplineEdge.H" -#include "BSpline.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(polySplineEdge, 0); - addToRunTimeSelectionTable(curvedEdge, polySplineEdge, Istream); -} - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -// intervening : returns a list of the points making up the polyLineEdge -// which describes the spline. nBetweenKnots is the number of points -// placed between each knot : this ensures that the knot locations -// are retained as a subset of the polyLine points. - -// note that the points are evenly spaced in the parameter mu, not -// in real space - -Foam::pointField Foam::polySplineEdge::intervening -( - const pointField& otherknots, - const label nBetweenKnots, - const vector& fstend, - const vector& sndend -) -{ - BSpline spl - ( - appendEndPoints(curvedEdge::points_, start_, end_, otherknots), - fstend, - sndend - ); - - const label nSize - ( - otherknots.size() * (1 + nBetweenKnots) + nBetweenKnots + 2 - ); - - const label NKnots = spl.nKnots(); - const scalar init = 1.0/(NKnots - 1); - scalar interval = (NKnots - scalar(3.0))/NKnots; - interval /= otherknots.size() + 1; - interval /= nBetweenKnots + 1; - - pointField ans(nSize); - ans[0] = curvedEdge::points_[start_]; - - register scalar index(init); - for (register label i=1; i<nSize-1; i++) - { - index += interval; - ans[i] = spl.realPosition(index); - } - - ans[nSize-1] = curvedEdge::points_[end_]; - - return ans; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::polySplineEdge::polySplineEdge -( - const pointField& points, - const label start, - const label end, - const pointField& otherknots, - const label nInterKnots -) -: - curvedEdge(points, start, end), - polyLine - ( - intervening - ( - otherknots, - nInterKnots, - vector::zero, - vector::zero - ) - ), - otherKnots_(otherknots) -{} - - -Foam::polySplineEdge::polySplineEdge -( - const pointField& points, - Istream& is -) -: - curvedEdge(points, is), - polyLine(pointField(0)), - otherKnots_(is) -{ - label nInterKnots(20); - vector fstend(is); - vector sndend(is); - - polyLine::points_ = intervening(otherKnots_, nInterKnots, fstend, sndend); - calcParam(); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::point Foam::polySplineEdge::position(const scalar mu) const -{ - return polyLine::position(mu); -} - - -Foam::scalar Foam::polySplineEdge::length() const -{ - return polyLine::length(); -} - - -// ************************************************************************* // diff --git a/src/mesh/blockMesh/curvedEdges/legacy/polySplineEdge.H b/src/mesh/blockMesh/curvedEdges/legacy/polySplineEdge.H deleted file mode 100644 index dcb5fc2dfe97da62bbbf423196dc84a7839b86cb..0000000000000000000000000000000000000000 --- a/src/mesh/blockMesh/curvedEdges/legacy/polySplineEdge.H +++ /dev/null @@ -1,117 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Class - Foam::polySplineEdge - -Description - A curvedEdge interface for B-splines. - -SourceFiles - polySplineEdge.C - -\*---------------------------------------------------------------------------*/ - -#ifndef polySplineEdge_H -#define polySplineEdge_H - -#include "curvedEdge.H" -#include "polyLine.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class polySplineEdge Declaration -\*---------------------------------------------------------------------------*/ - -class polySplineEdge -: - public curvedEdge, - public polyLine -{ - // Private data - - pointField otherKnots_; - - - // Private member functions - - pointField intervening - ( - const pointField& otherKnots, - const label nBetweenKnots, - const vector&, - const vector& - ); - -public: - - //- Runtime type information - TypeName("polySpline"); - - - // Constructors - - //- Construct from components - polySplineEdge - ( - const pointField&, - const label start, - const label end, - const pointField& otherKnots, - const label nInterKnots = 20 - ); - - //- Construct from Istream setting pointsList - polySplineEdge(const pointField&, Istream&); - - - //- Destructor - virtual ~polySplineEdge() - {} - - - // Member Functions - - //- Return the point position corresponding to the curve parameter - // 0 <= lambda <= 1 - point position(const scalar mu) const; - - //- Return the length of the curve - scalar length() const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/mesh/blockMesh/curvedEdges/legacy/simpleSplineEdge.C b/src/mesh/blockMesh/curvedEdges/legacy/simpleSplineEdge.C deleted file mode 100644 index c5dc9e6d9c866015c02c0914640413a5b72f3bc0..0000000000000000000000000000000000000000 --- a/src/mesh/blockMesh/curvedEdges/legacy/simpleSplineEdge.C +++ /dev/null @@ -1,92 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "simpleSplineEdge.H" -#include "addToRunTimeSelectionTable.H" - - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(simpleSplineEdge, 0); - addToRunTimeSelectionTable(curvedEdge, simpleSplineEdge, Istream); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::simpleSplineEdge::simpleSplineEdge -( - const pointField& points, - const label start, - const label end, - const pointField& otherknots -) -: - curvedEdge(points, start, end), - BSpline(appendEndPoints(points, start, end, otherknots)) -{} - - -Foam::simpleSplineEdge::simpleSplineEdge -( - const pointField& points, - const label start, - const label end, - const pointField& otherknots, - const vector& fstend, - const vector& sndend -) -: - curvedEdge(points, start, end), - BSpline(appendEndPoints(points, start, end, otherknots), fstend, sndend) -{} - - -Foam::simpleSplineEdge::simpleSplineEdge(const pointField& points, Istream& is) -: - curvedEdge(points, is), - BSpline(appendEndPoints(points, start_, end_, pointField(is))) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::point Foam::simpleSplineEdge::position(const scalar mu) const -{ - return BSpline::position(mu); -} - - -Foam::scalar Foam::simpleSplineEdge::length() const -{ - notImplemented("simpleSplineEdge::length() const"); - return 1.0; -} - - -// ************************************************************************* // diff --git a/src/mesh/blockMesh/curvedEdges/legacy/simpleSplineEdge.H b/src/mesh/blockMesh/curvedEdges/legacy/simpleSplineEdge.H deleted file mode 100644 index 91acf6fdee535928dd7589b8c50b3bcc017bba73..0000000000000000000000000000000000000000 --- a/src/mesh/blockMesh/curvedEdges/legacy/simpleSplineEdge.H +++ /dev/null @@ -1,122 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Class - Foam::simpleSplineEdge - -Description - A curvedEdge interface for B-splines. - -SourceFiles - simpleSplineEdge.C - -\*---------------------------------------------------------------------------*/ - -#ifndef simpleSplineEdge_H -#define simpleSplineEdge_H - -#include "curvedEdge.H" -#include "BSpline.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class simpleSplineEdge Declaration -\*---------------------------------------------------------------------------*/ - -class simpleSplineEdge -: - public curvedEdge, - public BSpline -{ - // Private Member Functions - - //- Disallow default bitwise copy construct - simpleSplineEdge(const simpleSplineEdge&); - - //- Disallow default bitwise assignment - void operator=(const simpleSplineEdge&); - - -public: - - //- Runtime type information - TypeName("simpleSpline"); - - - // Constructors - - //- Construct from components - simpleSplineEdge - ( - const pointField&, - const label start, - const label end, - const pointField& otherKnots - ); - - //- Construct from components - simpleSplineEdge - ( - const pointField&, - const label start, - const label end, - const pointField& otherKnots, - const vector& fstend, - const vector& sndend - ); - - //- Construct from Istream setting pointsList - simpleSplineEdge(const pointField&, Istream&); - - - // Destructor - - virtual ~simpleSplineEdge() - {} - - - // Member Functions - - //- Return the point position corresponding to the curve parameter - // 0 <= lambda <= 1 - point position(const scalar) const; - - //- Return the length of the simple spline curve - scalar length() const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/mesh/blockMesh/curvedEdges/legacy/spline.C b/src/mesh/blockMesh/curvedEdges/legacy/spline.C deleted file mode 100644 index 4f7ab8e195e33f12144a2ba90bc264fb5e13bb67..0000000000000000000000000000000000000000 --- a/src/mesh/blockMesh/curvedEdges/legacy/spline.C +++ /dev/null @@ -1,95 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "spline.H" - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -Foam::scalar Foam::spline::B(const scalar tau) -{ - if (tau <= -2.0 || tau >= 2.0) - { - return 0.0; - } - else if (tau <= -1.0) - { - return pow((2.0 + tau), 3.0)/6.0; - } - else if (tau <= 0.0) - { - return (4.0 - 6.0*tau*tau - 3.0*tau*tau*tau)/6.0; - } - else if (tau <= 1.0) - { - return (4.0 - 6.0*tau*tau + 3.0*tau*tau*tau)/6.0; - } - else if (tau <= 2.0) - { - return pow((2.0 - tau), 3.0)/6.0; - } - else - { - FatalErrorIn("spline::B(const scalar)") - << "Programming error???, " - << "tau = " << tau - << abort(FatalError); - } - - return 0.0; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::spline::spline(const pointField& knotPoints) -: - knots_(knotPoints) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::point Foam::spline::position(const scalar mu) const -{ - point loc(point::zero); - - for (register label i=0; i < knots_.size(); i++) - { - loc += B((knots_.size() - 1)*mu - i)*knots_[i]; - } - - return loc; -} - - -Foam::scalar Foam::spline::length() const -{ - notImplemented("spline::length() const"); - return 1.0; -} - - -// ************************************************************************* // diff --git a/src/mesh/blockMesh/curvedEdges/legacy/spline.H b/src/mesh/blockMesh/curvedEdges/legacy/spline.H deleted file mode 100644 index 1055690933919980b3b5fa9e1959210dba04d165..0000000000000000000000000000000000000000 --- a/src/mesh/blockMesh/curvedEdges/legacy/spline.H +++ /dev/null @@ -1,115 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Class - Foam::spline - -Description - Define a basic spline on nKnots knots. - - The spline does not go anywhere near these knots - (will act as a base type for various splines that will have real uses) - -SourceFiles - spline.C - -\*---------------------------------------------------------------------------*/ - -#ifndef spline_H -#define spline_H - -#include "pointField.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class spline Declaration -\*---------------------------------------------------------------------------*/ - -class spline -{ - // Private data - - //- The knots defining the spline - pointField knots_; - - // Private Member Functions - - //- Blending function for constructing spline - static scalar B(const scalar); - - //- Disallow default bitwise copy construct - spline(const spline&); - - //- Disallow default bitwise assignment - void operator=(const spline&); - - -public: - - // Constructors - - //- Construct from components - spline(const pointField&); - - - // Member Functions - - // Access - - //- Return the knot points in the spline - const pointField& knotPoints() const - { - return knots_; - } - - - //- Return the number of knots in the spline - label nKnots() const - { - return knots_.size(); - } - - - //- Return the point position corresponding to the curve parameter - // 0 <= lambda <= 1 - point position(const scalar) const; - - //- Return the length of the spline curve - scalar length() const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/mesh/blockMesh/curvedEdges/polyLine.C b/src/mesh/blockMesh/curvedEdges/polyLine.C index 08083041f2d5c7c82bb8b0fb86af14f3120d1468..183aa1a2b80588c7d1956787569d89fd65df5efd 100644 --- a/src/mesh/blockMesh/curvedEdges/polyLine.C +++ b/src/mesh/blockMesh/curvedEdges/polyLine.C @@ -60,7 +60,7 @@ void Foam::polyLine::calcParam() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::polyLine::polyLine(const pointField& ps) +Foam::polyLine::polyLine(const pointField& ps, const bool) : points_(ps), lineLength_(0.0), @@ -86,15 +86,6 @@ Foam::label Foam::polyLine::nSegments() const Foam::label Foam::polyLine::localParameter(scalar& lambda) const { - // check range of lambda - if (lambda < 0 || lambda > 1) - { - FatalErrorIn("polyLine::localParameter(scalar&)") - << "Parameter out-of-range, " - << "lambda = " << lambda - << abort(FatalError); - } - // check endpoints if (lambda < SMALL) { @@ -128,47 +119,58 @@ Foam::label Foam::polyLine::localParameter(scalar& lambda) const } -Foam::point Foam::polyLine::position(const scalar lambda) const +Foam::point Foam::polyLine::position(const scalar mu) const { - // check range of lambda - if (lambda < 0 || lambda > 1) - { - FatalErrorIn("polyLine::position(const scalar)") - << "Parameter out of range, " - << "lambda = " << lambda - << abort(FatalError); - } - // check endpoints - if (lambda < SMALL) + if (mu < SMALL) { - return points_[0]; + return points_.first(); } - else if (lambda > 1 - SMALL) + else if (mu > 1 - SMALL) { return points_.last(); } - // search table of cumulative distances to find which line-segment - // we are on. Check the upper bound. + scalar lambda = mu; + label segment = localParameter(lambda); + return position(segment, lambda); +} - label segmentI = 1; - while (param_[segmentI] < lambda) + +Foam::point Foam::polyLine::position +( + const label segment, + const scalar mu +) const +{ + // out-of-bounds + if (segment < 0) + { + return points_.first(); + } + else if (segment > nSegments()) { - ++segmentI; + return points_.last(); } - --segmentI; // we now want the lower bound + const point& p0 = points()[segment]; + const point& p1 = points()[segment+1]; - // linear interpolation - return - ( - points_[segmentI] - + ( points_[segmentI+1] - points_[segmentI] ) - * ( lambda - param_[segmentI] ) - / ( param_[segmentI+1] - param_[segmentI] ) - ); + // special cases - no calculation needed + if (mu <= 0.0) + { + return p0; + } + else if (mu >= 1.0) + { + return p1; + } + else + { + // linear interpolation + return points_[segment] + mu * (p1 - p0); + } } diff --git a/src/mesh/blockMesh/curvedEdges/polyLine.H b/src/mesh/blockMesh/curvedEdges/polyLine.H index ea8c59e389bf08cfa5a6d28c1cd5d1503342e107..4834eb590d0ac3685a29b3f03dd6c65f32ef05d2 100644 --- a/src/mesh/blockMesh/curvedEdges/polyLine.H +++ b/src/mesh/blockMesh/curvedEdges/polyLine.H @@ -29,6 +29,9 @@ Description A series of straight line segments, which can also be interpreted as a series of control points for splines, etc. +ToDo + A future implementation could also handle a closed polyLine. + SourceFiles polyLine.C @@ -89,7 +92,11 @@ public: // Constructors //- Construct from components - polyLine(const pointField&); + polyLine + ( + const pointField&, + const bool notImplementedClosed = false + ); // Member Functions @@ -104,6 +111,10 @@ public: // 0 <= lambda <= 1 point position(const scalar) const; + //- Return the point position corresponding to the local parameter + // 0 <= lambda <= 1 on the given segment + point position(const label segment, const scalar) const; + //- Return the length of the curve scalar length() const; }; diff --git a/src/mesh/blockMesh/curvedEdges/splineEdge.C b/src/mesh/blockMesh/curvedEdges/splineEdge.C index 810cd7dc9b87c912bc092c3ab5921e48505f1fde..23d8835b84fb8d6561b4e914354926c775aa71f5 100644 --- a/src/mesh/blockMesh/curvedEdges/splineEdge.C +++ b/src/mesh/blockMesh/curvedEdges/splineEdge.C @@ -33,7 +33,32 @@ License namespace Foam { defineTypeNameAndDebug(splineEdge, 0); - addToRunTimeSelectionTable(curvedEdge, splineEdge, Istream); + + addToRunTimeSelectionTable + ( + curvedEdge, + splineEdge, + Istream + ); + + // compatibility with old names + addNamedToRunTimeSelectionTable + ( + curvedEdge, + splineEdge, + Istream, + simpleSpline + ); + + // compatibility with old names + addNamedToRunTimeSelectionTable + ( + curvedEdge, + splineEdge, + Istream, + polySpline + ); + } @@ -44,11 +69,11 @@ Foam::splineEdge::splineEdge const pointField& points, const label start, const label end, - const pointField& otherknots + const pointField& internalPoints ) : curvedEdge(points, start, end), - CatmullRomSpline(appendEndPoints(points, start, end, otherknots)) + CatmullRomSpline(appendEndPoints(points, start, end, internalPoints)) {} @@ -60,15 +85,21 @@ Foam::splineEdge::splineEdge(const pointField& points, Istream& is) token t(is); is.putBack(t); - // might have start/end tangents that we currently ignore + // compatibility - might also have start/end tangents - discard them if (t == token::BEGIN_LIST) { - vector fstend(is); - vector sndend(is); + vector tangent0Ignored(is); + vector tangent1Ignored(is); } } +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::splineEdge::~splineEdge() +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::point Foam::splineEdge::position(const scalar mu) const diff --git a/src/mesh/blockMesh/curvedEdges/splineEdge.H b/src/mesh/blockMesh/curvedEdges/splineEdge.H index ba9501c20447b13857f7295724f8f18490f59e18..70638121fa23933f40bd44092e542f0d0636c4b9 100644 --- a/src/mesh/blockMesh/curvedEdges/splineEdge.H +++ b/src/mesh/blockMesh/curvedEdges/splineEdge.H @@ -28,6 +28,10 @@ Class Description A curvedEdge interface for Catmull-Rom splines. +Note + For compatibility, also accepts the type names 'polySpline' and + 'simpleSpline'. + SourceFiles splineEdge.C @@ -76,17 +80,15 @@ public: const pointField&, const label start, const label end, - const pointField& otherKnots + const pointField& internalPoints ); - //- Construct from Istream setting pointsList + //- Construct from Istream, setting pointsList splineEdge(const pointField&, Istream&); - // Destructor - - virtual ~splineEdge() - {} + //- Destructor + virtual ~splineEdge(); // Member Functions @@ -95,7 +97,7 @@ public: // 0 <= lambda <= 1 virtual point position(const scalar) const; - //- Return the length of the simple spline curve + //- Return the length of the spline curve (not implemented) virtual scalar length() const; };