1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "incompressible.H"
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 inline Foam::incompressible::incompressible
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 inline Foam::incompressible::incompressible
46 const incompressible& ico
53 inline Foam::autoPtr<Foam::incompressible>
54 Foam::incompressible::clone() const
56 return autoPtr<incompressible>(new incompressible(*this));
59 inline Foam::autoPtr<Foam::incompressible>
60 Foam::incompressible::New(Istream& is)
62 return autoPtr<incompressible>(new incompressible(is));
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68 inline Foam::scalar Foam::incompressible::rho(scalar p, scalar T) const
73 inline Foam::scalar Foam::incompressible::psi(scalar, scalar T) const
78 inline Foam::scalar Foam::incompressible::Z(scalar, scalar) const
84 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
86 inline void Foam::incompressible::operator+=(const incompressible& ico)
88 scalar molr1 = this->nMoles();
90 specie::operator+=(ico);
92 molr1 /= this->nMoles();
93 scalar molr2 = ico.nMoles()/this->nMoles();
95 rho_ = molr1*rho_ + molr2*ico.rho_;
98 inline void Foam::incompressible::operator-=(const incompressible& ico)
100 scalar molr1 = this->nMoles();
102 specie::operator-=(ico);
104 molr1 /= this->nMoles();
105 scalar molr2 = ico.nMoles()/this->nMoles();
107 rho_ = molr1*rho_ - molr2*ico.rho_;
110 inline void Foam::incompressible::operator*=(const scalar s)
112 specie::operator*=(s);
116 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
118 inline Foam::incompressible Foam::operator+
120 const incompressible& ico1,
121 const incompressible& ico2
124 scalar nMoles = ico1.nMoles() + ico2.nMoles();
125 scalar molr1 = ico1.nMoles()/nMoles;
126 scalar molr2 = ico2.nMoles()/nMoles;
128 return incompressible
130 static_cast<const specie&>(ico1)
131 + static_cast<const specie&>(ico2),
132 molr1*ico1.rho_ + molr2*ico2.rho_
136 inline Foam::incompressible Foam::operator-
138 const incompressible& ico1,
139 const incompressible& ico2
142 scalar nMoles = ico1.nMoles() + ico2.nMoles();
143 scalar molr1 = ico1.nMoles()/nMoles;
144 scalar molr2 = ico2.nMoles()/nMoles;
146 return incompressible
148 static_cast<const specie&>(ico1)
149 - static_cast<const specie&>(ico2),
150 molr1*ico1.rho_ - molr2*ico2.rho_
154 inline Foam::incompressible Foam::operator*
157 const incompressible& ico
160 return incompressible(s*static_cast<const specie&>(ico), ico.rho_);
163 inline Foam::incompressible Foam::operator==
165 const incompressible& ico1,
166 const incompressible& ico2
173 // ************************************************************************* //