FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

bufferedAccumulator.H

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