FreeFOAM The Cross-Platform CFD Toolkit
incompressibleI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "incompressible.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
31 (
32  const specie& sp,
33  const scalar rho
34 )
35 :
36  specie(sp),
37  rho_(rho)
38 {}
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const word& name,
46  const incompressible& ico
47 )
48 :
49  specie(name, ico),
50  rho_(ico.rho_)
51 {}
52 
55 {
56  return autoPtr<incompressible>(new incompressible(*this));
57 }
58 
61 {
63 }
64 
65 
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67 
68 inline Foam::scalar Foam::incompressible::rho(scalar p, scalar T) const
69 {
70  return rho_;
71 }
72 
73 inline Foam::scalar Foam::incompressible::psi(scalar, scalar T) const
74 {
75  return 0.0;
76 }
77 
78 inline Foam::scalar Foam::incompressible::Z(scalar, scalar) const
79 {
80  return 0.0;
81 }
82 
83 
84 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
85 
87 {
88  scalar molr1 = this->nMoles();
89 
90  specie::operator+=(ico);
91 
92  molr1 /= this->nMoles();
93  scalar molr2 = ico.nMoles()/this->nMoles();
94 
95  rho_ = molr1*rho_ + molr2*ico.rho_;
96 }
97 
99 {
100  scalar molr1 = this->nMoles();
101 
102  specie::operator-=(ico);
103 
104  molr1 /= this->nMoles();
105  scalar molr2 = ico.nMoles()/this->nMoles();
106 
107  rho_ = molr1*rho_ - molr2*ico.rho_;
108 }
109 
110 inline void Foam::incompressible::operator*=(const scalar s)
111 {
113 }
114 
115 
116 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
117 
118 inline Foam::incompressible Foam::operator+
119 (
120  const incompressible& ico1,
121  const incompressible& ico2
122 )
123 {
124  scalar nMoles = ico1.nMoles() + ico2.nMoles();
125  scalar molr1 = ico1.nMoles()/nMoles;
126  scalar molr2 = ico2.nMoles()/nMoles;
127 
128  return incompressible
129  (
130  static_cast<const specie&>(ico1)
131  + static_cast<const specie&>(ico2),
132  molr1*ico1.rho_ + molr2*ico2.rho_
133  );
134 }
135 
136 inline Foam::incompressible Foam::operator-
137 (
138  const incompressible& ico1,
139  const incompressible& ico2
140 )
141 {
142  scalar nMoles = ico1.nMoles() + ico2.nMoles();
143  scalar molr1 = ico1.nMoles()/nMoles;
144  scalar molr2 = ico2.nMoles()/nMoles;
145 
146  return incompressible
147  (
148  static_cast<const specie&>(ico1)
149  - static_cast<const specie&>(ico2),
150  molr1*ico1.rho_ - molr2*ico2.rho_
151  );
152 }
153 
154 inline Foam::incompressible Foam::operator*
155 (
156  const scalar s,
157  const incompressible& ico
158 )
159 {
160  return incompressible(s*static_cast<const specie&>(ico), ico.rho_);
161 }
162 
163 inline Foam::incompressible Foam::operator==
164 (
165  const incompressible& ico1,
166  const incompressible& ico2
167 )
168 {
169  return ico2 - ico1;
170 }
171 
172 
173 // ************************************************************************* //