|
|
|
interpolationTable.HGo 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 Class 00026 Foam::interpolationTable 00027 00028 Description 00029 A list of times and values. 00030 The time values must be positive and monotonically increasing. 00031 00032 The handling of out-of-bounds values depends on the current setting 00033 of @a outOfBounds. 00034 00035 If @a REPEAT is chosen for the out-of-bounds handling, the final time 00036 value is treated as being equivalent to time=0 for the following periods. 00037 00038 Note 00039 - Accessing an empty list results in an error. 00040 - Accessing a list with a single element always returns the same value. 00041 00042 SourceFiles 00043 interpolationTable.C 00044 00045 \*---------------------------------------------------------------------------*/ 00046 00047 #ifndef interpolationTable_H 00048 #define interpolationTable_H 00049 00050 #include "List.H" 00051 #include "Tuple2.H" 00052 00053 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00054 00055 namespace Foam 00056 { 00057 00058 /*---------------------------------------------------------------------------*\ 00059 Class interpolationTable Declaration 00060 \*---------------------------------------------------------------------------*/ 00061 00062 template<class Type> 00063 class interpolationTable 00064 : 00065 public List<Tuple2<scalar, Type> > 00066 { 00067 public: 00068 00069 // Public data types 00070 00071 //- Enumeration for handling out-of-bound values 00072 enum boundsHandling 00073 { 00074 ERROR, 00075 WARN, 00076 CLAMP, 00077 REPEAT 00078 }; 00079 00080 00081 private: 00082 00083 // Private data 00084 00085 //- Enumeration for handling out-of-bound values 00086 boundsHandling boundsHandling_; 00087 00088 //- File name 00089 fileName fileName_; 00090 00091 00092 // Private Member Functions 00093 00094 //- Read the table of data from file 00095 void readTable(); 00096 00097 00098 public: 00099 00100 // Constructors 00101 00102 //- Construct null 00103 interpolationTable(); 00104 00105 //- Construct from components 00106 interpolationTable 00107 ( 00108 const List<Tuple2<scalar, Type> >& values, 00109 const boundsHandling bounds, 00110 const fileName& fName 00111 ); 00112 00113 //- Construct given the name of the file containing the table of data 00114 interpolationTable(const fileName& fName); 00115 00116 //- Construct by reading the fileName and boundsHandling from dictionary 00117 // and read the table from that file. 00118 // This is a specialised constructor used by patchFields 00119 interpolationTable(const dictionary& dict); 00120 00121 //- Construct copy 00122 interpolationTable(const interpolationTable& interpTable); 00123 00124 00125 // Member Functions 00126 00127 //- Return the out-of-bounds handling as a word 00128 word boundsHandlingToWord(const boundsHandling& bound) const; 00129 00130 //- Return the out-of-bounds handling as an enumeration 00131 boundsHandling wordToBoundsHandling(const word& bound) const; 00132 00133 //- Set the out-of-bounds handling from enum, return previous setting 00134 boundsHandling outOfBounds(const boundsHandling& bound); 00135 00136 //- Check that list is monotonically increasing 00137 // Exit with a FatalError if there is a problem 00138 void check() const; 00139 00140 //- Write 00141 void write(Ostream& os) const; 00142 00143 00144 // Member Operators 00145 00146 //- Return an element of constant Tuple2<scalar, Type> 00147 const Tuple2<scalar, Type>& operator[](const label) const; 00148 00149 //- Return an interpolated value 00150 Type operator()(const scalar) const; 00151 }; 00152 00153 00154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00155 00156 } // End namespace Foam 00157 00158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00159 00160 #ifdef NoRepository 00161 # include "interpolationTable.C" 00162 #endif 00163 00164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00165 00166 #endif 00167 00168 // ************************************************************************* // |