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

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