OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

polySplineEdge.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "polySplineEdge.H"
00028 #include "BSpline.H"
00029 #include "addToRunTimeSelectionTable.H"
00030 
00031 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035     defineTypeNameAndDebug(polySplineEdge, 0);
00036 
00037     // Add the curvedEdge constructor functions to the hash tables
00038     addToRunTimeSelectionTable(curvedEdge, polySplineEdge, Istream);
00039 }
00040 
00041 
00042 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00043 
00044 // intervening : returns a list of the points making up the polyLineEdge
00045 // which describes the spline. nbetweenKnots is the number of points
00046 // placed between each knot : this ensures that the knot locations
00047 // are retained as a subset of the polyLine points.
00048 
00049 // note that the points are evenly spaced in the parameter mu, not
00050 // in real space
00051 
00052 Foam::pointField Foam::polySplineEdge::intervening
00053 (
00054     const pointField& otherknots,
00055     const label nbetweenKnots,
00056     const vector& fstend,
00057     const vector& sndend
00058 )
00059 {
00060     BSpline spl(knotlist(points_, start_, end_, otherknots), fstend, sndend);
00061 
00062     label nSize(nsize(otherknots.size(), nbetweenKnots));
00063 
00064     pointField ans(nSize);
00065 
00066     label N = spl.nKnots();
00067     scalar init = 1.0/(N - 1);
00068     scalar interval = (N - scalar(3))/N;
00069     interval /= otherknots.size() + 1;
00070     interval /= nbetweenKnots + 1;
00071 
00072     ans[0] = points_[start_];
00073 
00074     register scalar index(init);
00075     for (register label i=1; i<nSize-1; i++)
00076     {
00077         index += interval;
00078         ans[i] = spl.realPosition(index);
00079     }
00080 
00081     ans[nSize-1] = points_[end_];
00082 
00083     return ans;
00084 }
00085 
00086 
00087 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00088 
00089 Foam::polySplineEdge::polySplineEdge
00090 (
00091     const pointField& points,
00092     const label start,
00093     const label end,
00094     const pointField& otherknots,
00095     const label nInterKnots
00096 )
00097 :
00098     curvedEdge(points, start, end),
00099     polyLine
00100     (
00101         intervening
00102         (
00103             otherknots,
00104             nInterKnots,
00105             vector::zero,
00106             vector::zero
00107         )
00108     ),
00109     otherKnots_(otherknots)
00110 {}
00111 
00112 
00113 Foam::polySplineEdge::polySplineEdge
00114 (
00115     const pointField& points,
00116     Istream& is
00117 )
00118 :
00119     curvedEdge(points, is),
00120     polyLine(pointField(0)),
00121     otherKnots_(is)
00122 {
00123     label nInterKnots(20);
00124     vector fstend(is);
00125     vector sndend(is);
00126 
00127     controlPoints_.setSize(nsize(otherKnots_.size(), nInterKnots));
00128     distances_.setSize(controlPoints_.size());
00129 
00130     controlPoints_ = intervening(otherKnots_, nInterKnots, fstend, sndend);
00131     calcDistances();
00132     Info<< polyLine::controlPoints_ << endl;
00133 }
00134 
00135 
00136 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00137 
00138 Foam::vector Foam::polySplineEdge::position(const scalar mu) const
00139 {
00140     return polyLine::position(mu);
00141 }
00142 
00143 
00144 Foam::scalar Foam::polySplineEdge::length() const
00145 {
00146     return polyLine::length();
00147 }
00148 
00149 
00150 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd