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

fieldAverageItem.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) 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::fieldAverageItem
00027 
00028 Description
00029     Helper class to describe what form of averaging to apply. A set will be
00030     applied to each base field in Foam::fieldAverage, of the form:
00031 
00032     @verbatim
00033         {
00034             mean            on;
00035             prime2Mean      on;
00036             base            time; // iteration
00037         }
00038     @endverbatim
00039 
00040 SourceFiles
00041     fieldAverageItem.C
00042     fieldAverageItemIO.C
00043 
00044 \*---------------------------------------------------------------------------*/
00045 
00046 #ifndef fieldAverageItem_H
00047 #define fieldAverageItem_H
00048 
00049 #include "NamedEnum.H"
00050 #include "Switch.H"
00051 
00052 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00053 
00054 namespace Foam
00055 {
00056 
00057 // Forward declaration of classes
00058 class Istream;
00059 class Ostream;
00060 
00061 // Forward declaration of friend functions and operators
00062 class fieldAverageItem;
00063 Istream& operator>>(Istream&, fieldAverageItem&);
00064 Ostream& operator<<(Ostream&, const fieldAverageItem&);
00065 
00066 
00067 /*---------------------------------------------------------------------------*\
00068                       Class fieldAverageItem Declaration
00069 \*---------------------------------------------------------------------------*/
00070 
00071 class fieldAverageItem
00072 {
00073 public:
00074 
00075     // Public data
00076 
00077         //- Enumeration defining the averaging base type
00078         enum baseType
00079         {
00080             ITER,
00081             TIME
00082         };
00083 
00084 
00085 private:
00086 
00087     // Private data
00088 
00089         //- Field name
00090         word fieldName_;
00091 
00092         //- Compute mean flag
00093         Switch mean_;
00094 
00095         //- Compute prime-squared mean flag
00096         Switch prime2Mean_;
00097 
00098         //- Averaging base type names
00099         static const NamedEnum<baseType, 2> baseTypeNames_;
00100 
00101         //- Averaging base type
00102         baseType base_;
00103 
00104 
00105 public:
00106 
00107     // Constructors
00108 
00109         //- Construct null
00110         fieldAverageItem();
00111 
00112         //- Construct from Istream
00113         fieldAverageItem(Istream&);
00114 
00115         //- Construct as copy
00116         fieldAverageItem(const fieldAverageItem&);
00117 
00118 
00119     // Destructor
00120 
00121         ~fieldAverageItem();
00122 
00123 
00124     // Member Functions
00125 
00126         // Access
00127 
00128             //- Return const access to the field name
00129             const word& fieldName() const
00130             {
00131                 return fieldName_;
00132             }
00133 
00134             //- Return const access to the mean flag
00135             const Switch& mean() const
00136             {
00137                 return mean_;
00138             }
00139 
00140             //- Return const access to the prime-squared mean flag
00141             const Switch& prime2Mean() const
00142             {
00143                 return prime2Mean_;
00144             }
00145 
00146             //- Return averaging base type name
00147             const word base() const
00148             {
00149                 return baseTypeNames_[base_];
00150             }
00151 
00152             //- Return true if base is ITER
00153             Switch ITERBase() const
00154             {
00155                 return base_ == ITER;
00156             }
00157 
00158             //- Return true if base is time
00159             Switch timeBase() const
00160             {
00161                 return base_ == TIME;
00162             }
00163 
00164 
00165     // Member Operators
00166 
00167         void operator=(const fieldAverageItem&);
00168 
00169     // Friend Operators
00170 
00171         friend bool operator==
00172         (
00173             const fieldAverageItem& a,
00174             const fieldAverageItem& b
00175         )
00176         {
00177             return
00178                 a.fieldName_ == b.fieldName_
00179              && a.mean_ == b.mean_
00180              && a.prime2Mean_ == b.prime2Mean_
00181              && a.base_ == b.base_;
00182         }
00183 
00184         friend bool operator!=
00185         (
00186             const fieldAverageItem& a,
00187             const fieldAverageItem& b
00188         )
00189         {
00190             return !(a == b);
00191         }
00192 
00193     // IOstream Operators
00194 
00195         friend Istream& operator>>(Istream&, fieldAverageItem&);
00196         friend Ostream& operator<<(Ostream&, const fieldAverageItem&);
00197 };
00198 
00199 
00200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00201 
00202 } // End namespace Foam
00203 
00204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00205 
00206 #endif
00207 
00208 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd