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

incompressibleI.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 \*---------------------------------------------------------------------------*/
00025 
00026 #include "incompressible.H"
00027 
00028 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00029 
00030 inline Foam::incompressible::incompressible
00031 (
00032     const specie& sp,
00033     const scalar rho
00034 )
00035 :
00036     specie(sp),
00037     rho_(rho)
00038 {}
00039 
00040 
00041 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00042 
00043 inline Foam::incompressible::incompressible
00044 (
00045     const word& name,
00046     const incompressible& ico
00047 )
00048 :
00049     specie(name, ico),
00050     rho_(ico.rho_)
00051 {}
00052 
00053 inline Foam::autoPtr<Foam::incompressible>
00054 Foam::incompressible::clone() const
00055 {
00056     return autoPtr<incompressible>(new incompressible(*this));
00057 }
00058 
00059 inline Foam::autoPtr<Foam::incompressible>
00060 Foam::incompressible::New(Istream& is)
00061 {
00062     return autoPtr<incompressible>(new incompressible(is));
00063 }
00064 
00065 
00066 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00067 
00068 inline Foam::scalar Foam::incompressible::rho(scalar p, scalar T) const
00069 {
00070     return rho_;
00071 }
00072 
00073 inline Foam::scalar Foam::incompressible::psi(scalar, scalar T) const
00074 {
00075     return 0.0;
00076 }
00077 
00078 inline Foam::scalar Foam::incompressible::Z(scalar, scalar) const
00079 {
00080     return 0.0;
00081 }
00082 
00083 
00084 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00085 
00086 inline void Foam::incompressible::operator+=(const incompressible& ico)
00087 {
00088     scalar molr1 = this->nMoles();
00089 
00090     specie::operator+=(ico);
00091 
00092     molr1 /= this->nMoles();
00093     scalar molr2 = ico.nMoles()/this->nMoles();
00094 
00095     rho_ = molr1*rho_ + molr2*ico.rho_;
00096 }
00097 
00098 inline void Foam::incompressible::operator-=(const incompressible& ico)
00099 {
00100     scalar molr1 = this->nMoles();
00101 
00102     specie::operator-=(ico);
00103 
00104     molr1 /= this->nMoles();
00105     scalar molr2 = ico.nMoles()/this->nMoles();
00106 
00107     rho_ = molr1*rho_ - molr2*ico.rho_;
00108 }
00109 
00110 inline void Foam::incompressible::operator*=(const scalar s)
00111 {
00112     specie::operator*=(s);
00113 }
00114 
00115 
00116 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00117 
00118 inline Foam::incompressible Foam::operator+
00119 (
00120     const incompressible& ico1,
00121     const incompressible& ico2
00122 )
00123 {
00124     scalar nMoles = ico1.nMoles() + ico2.nMoles();
00125     scalar molr1 = ico1.nMoles()/nMoles;
00126     scalar molr2 = ico2.nMoles()/nMoles;
00127 
00128     return incompressible
00129     (
00130         static_cast<const specie&>(ico1)
00131       + static_cast<const specie&>(ico2),
00132         molr1*ico1.rho_ + molr2*ico2.rho_
00133     );
00134 }
00135 
00136 inline Foam::incompressible Foam::operator-
00137 (
00138     const incompressible& ico1,
00139     const incompressible& ico2
00140 )
00141 {
00142     scalar nMoles = ico1.nMoles() + ico2.nMoles();
00143     scalar molr1 = ico1.nMoles()/nMoles;
00144     scalar molr2 = ico2.nMoles()/nMoles;
00145 
00146     return incompressible
00147     (
00148         static_cast<const specie&>(ico1)
00149       - static_cast<const specie&>(ico2),
00150         molr1*ico1.rho_ - molr2*ico2.rho_
00151     );
00152 }
00153 
00154 inline Foam::incompressible Foam::operator*
00155 (
00156     const scalar s,
00157     const incompressible& ico
00158 )
00159 {
00160     return incompressible(s*static_cast<const specie&>(ico), ico.rho_);
00161 }
00162 
00163 inline Foam::incompressible Foam::operator==
00164 (
00165     const incompressible& ico1,
00166     const incompressible& ico2
00167 )
00168 {
00169     return ico2 - ico1;
00170 }
00171 
00172 
00173 // ************************************************************************* //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines