|
|
|
bufferedAccumulator.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) 2008-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::bufferedAccumulator 00027 00028 Description 00029 00030 SourceFiles 00031 bufferedAccumulatorI.H 00032 bufferedAccumulator.C 00033 bufferedAccumulatorIO.C 00034 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #ifndef bufferedAccumulator_H 00038 #define bufferedAccumulator_H 00039 00040 #include "Field.H" 00041 00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00043 00044 namespace Foam 00045 { 00046 00047 template<class Type> 00048 class bufferedAccumulator; 00049 00050 template<class Type> 00051 Ostream& operator<< 00052 ( 00053 Ostream&, 00054 const bufferedAccumulator<Type>& 00055 ); 00056 00057 /*---------------------------------------------------------------------------*\ 00058 Class bufferedAccumulator Declaration 00059 \*---------------------------------------------------------------------------*/ 00060 00061 template<class Type> 00062 class bufferedAccumulator 00063 : 00064 public List< Field<Type> > 00065 { 00066 // Private data 00067 00068 label averagesTaken_; 00069 00070 List<label> bufferOffsets_; 00071 00072 00073 // Private Member Functions 00074 00075 inline Field<Type>& accumulationBuffer(); 00076 00077 inline const Field<Type>& accumulationBuffer() const; 00078 00079 void accumulateAndResetBuffer(const label b); 00080 00081 00082 public: 00083 00084 //- Component type 00085 typedef typename pTraits<Type>::cmptType cmptType; 00086 00087 00088 // Static data members 00089 00090 static const char* const typeName; 00091 00092 00093 // Constructors 00094 00095 //- Construct null 00096 bufferedAccumulator(); 00097 00098 //- Construct from components 00099 bufferedAccumulator 00100 ( 00101 const label nBuffers, 00102 const label bufferLength, 00103 const label bufferingInterval 00104 ); 00105 00106 //- Construct as copy 00107 bufferedAccumulator(const bufferedAccumulator<Type>&); 00108 00109 00110 // Destructor 00111 00112 ~bufferedAccumulator(); 00113 00114 00115 // Member Functions 00116 00117 label addToBuffers(const List<Type>& valuesToAdd); 00118 00119 Field<Type> averaged() const; 00120 00121 void resetAveraging(); 00122 00123 00124 // Access 00125 00126 inline label averagesTaken() const; 00127 00128 inline label nBuffers() const; 00129 00130 inline label bufferLength() const; 00131 00132 inline const List<label>& bufferOffsets() const; 00133 00134 00135 // Edit 00136 00137 void setSizes 00138 ( 00139 const label nBuffers, 00140 const label bufferLength, 00141 const label bufferingInterval 00142 ); 00143 00144 00145 // Member Operators 00146 00147 void operator=(const bufferedAccumulator<Type>&); 00148 00149 00150 // IOstream Operators 00151 00152 friend Ostream& operator<< <Type> 00153 ( 00154 Ostream&, 00155 const bufferedAccumulator<Type>& 00156 ); 00157 }; 00158 00159 00160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00161 00162 } // End namespace Foam 00163 00164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00165 00166 #include "bufferedAccumulatorI.H" 00167 00168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00169 00170 #ifdef NoRepository 00171 # include "bufferedAccumulator.C" 00172 #endif 00173 00174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00175 00176 #endif 00177 00178 // ************************************************************************* // |