|
|
|
spline.CGo 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 Description 00026 spline class : define a basic spline on nKnots knots - this 00027 does not go anywhere near these knots (will act as a base type for 00028 various splines that will have real uses) 00029 00030 \*---------------------------------------------------------------------------*/ 00031 00032 #include "spline.H" 00033 00034 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00035 00036 namespace Foam 00037 { 00038 00039 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 00040 00041 // Construct from components 00042 spline::spline(const pointField& a) 00043 : 00044 knots_(a) 00045 {} 00046 00047 00048 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 00049 00050 // function B : this is the blending function for constructing the 00051 // spline 00052 00053 scalar spline::B(const scalar& tau) const 00054 { 00055 scalar value = 0.0; 00056 00057 if (tau>=2.0 || tau<=-2.0) 00058 { 00059 value = 0.0; 00060 } 00061 else if (tau<=-1.0) 00062 { 00063 value = pow((2.0 + tau),3.0)/6.0; 00064 } 00065 else if (tau<=0.0) 00066 { 00067 value = (4.0 - 6.0*tau*tau - 3.0*tau*tau*tau)/6.0; 00068 } 00069 else if (tau<=1.0) 00070 { 00071 value = (4.0 - 6.0*tau*tau + 3.0*tau*tau*tau)/6.0; 00072 } 00073 else if (tau<=2.0) 00074 { 00075 value = pow((2.0 - tau),3.0)/6.0; 00076 } 00077 else 00078 { 00079 FatalErrorIn("spline::B(const scalar&)") 00080 << "How the hell did we get here???, " 00081 << "tau = " << tau 00082 << abort(FatalError); 00083 } 00084 00085 return value; 00086 } 00087 00088 00089 // position : returns the position along the spline corresponding to the 00090 // variable mu1 00091 00092 vector spline::position(const scalar mu1) const 00093 { 00094 vector tmp(vector::zero); 00095 00096 for (register label i=0; i<knots_.size(); i++) 00097 { 00098 tmp += B((knots_.size() - 1)*mu1 - i)*knots_[i]; 00099 } 00100 00101 return tmp; 00102 } 00103 00104 00105 //- Return the length of the spline curve 00106 scalar spline::length() const 00107 { 00108 notImplemented("spline::length() const"); 00109 return 1.0; 00110 } 00111 00112 00113 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00114 00115 } // End namespace Foam 00116 00117 // ************************************************************************* // |