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

phaseProperties.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-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::phaseProperties
00027 
00028 Description
00029     Helper class to manage multi-component phase properties
00030 
00031 SourceFiles
00032     phaseProperties.C
00033     phasePropertiesIO.C
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef phaseProperties_H
00038 #define phaseProperties_H
00039 
00040 #include "NamedEnum.H"
00041 #include "Tuple2.H"
00042 #include "PtrList.H"
00043 #include "volFields.H"
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 /*---------------------------------------------------------------------------*\
00051                       Class phaseProperties Declaration
00052 \*---------------------------------------------------------------------------*/
00053 
00054 class phaseProperties
00055 {
00056 public:
00057 
00058     // Public data
00059 
00060         //- Phase type enumeration
00061         enum phaseType
00062         {
00063             GAS,
00064             LIQUID,
00065             SOLID,
00066             UNKNOWN
00067         };
00068 
00069         //- Corresponding word representations for phase type enumerations
00070         static const NamedEnum<phaseType, 4> phaseTypeNames_;
00071 
00072 
00073 private:
00074 
00075    // Private data
00076 
00077         //- Phase type
00078         phaseType phase_;
00079 
00080         //- State label (s), (l), (g) etc.
00081         word stateLabel_;
00082 
00083         //- List of component names
00084         List<word> names_;
00085 
00086         //- List of component mass fractions
00087         scalarField Y_;
00088 
00089         //- Global ids
00090         labelList globalIds_;
00091 
00092         //- Map to carrier global id
00093         labelList globalCarrierIds_;
00094 
00095 
00096     // Private member functions
00097 
00098         //- Set global ids
00099         void setGlobalIds(const wordList& globalNames);
00100 
00101         //- Set global carrier ids - attempts to map component names to global
00102         //  carrier species
00103         void setGlobalCarrierIds(const wordList& carrierNames);
00104 
00105         //- Check the total mass fraction
00106         void checkTotalMassFraction() const;
00107 
00108         //- Set the state label
00109         word phaseToStateLabel(const phaseType pt) const;
00110 
00111 
00112 public:
00113 
00114     // Constructors
00115 
00116         //- Null constructor
00117         phaseProperties();
00118 
00119         //- Construct from Istream
00120         phaseProperties(Istream&);
00121 
00122         //- Construct as copy
00123         phaseProperties(const phaseProperties&);
00124 
00125 
00126     //- Destructor
00127     ~phaseProperties();
00128 
00129 
00130     // Public member functions
00131 
00132         //- Initialise the global ids
00133         void initialiseGlobalIds
00134         (
00135             const wordList& gasNames,
00136             const wordList& liquidNames,
00137             const wordList& solidNames
00138         );
00139 
00140 
00141         // Access
00142 
00143             //- Return const access to the phase type
00144             phaseType phase() const;
00145 
00146             //- Return const access to the phase state label
00147             const word& stateLabel() const;
00148 
00149             //- Return word representation of the phase type
00150             word phaseTypeName() const;
00151 
00152             //- Return the list of component names
00153             const List<word>& names() const;
00154 
00155             //- Return const access to a component name
00156             const word& name(const label cmptI) const;
00157 
00158             //- Return const access to all component mass fractions
00159             const scalarField& Y() const;
00160 
00161             //- Return non-const access to a component mass fraction
00162             scalar& Y(const label cmptI);
00163 
00164             //- Return const access to the global ids
00165             const labelList& globalIds() const;
00166 
00167             //- Return const access to the map to the carrier global ids
00168             const labelList& globalCarrierIds() const;
00169 
00170             //- Return the global id of a component in the local list by name
00171             //  Returns -1 if not found
00172             label globalId(const word& cmptName) const;
00173 
00174             //- Return the id of a component in the local list by name
00175             //  Returns -1 if not found
00176             label id(const word& cmptName) const;
00177 
00178 
00179     // IOstream Operators
00180 
00181         friend Istream& operator>>(Istream&, phaseProperties&);
00182         friend Ostream& operator<<(Ostream&, const phaseProperties&);
00183 };
00184 
00185 
00186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00187 
00188 } // End namespace Foam
00189 
00190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00191 
00192 #endif
00193 
00194 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd