FreeFOAM The Cross-Platform CFD Toolkit
icoPolynomialI.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) 2008-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 "icoPolynomial.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<int PolySize>
32 (
33  const specie& sp,
34  const Polynomial<PolySize>& rhoPoly
35 )
36 :
37  specie(sp),
38  rhoPolynomial_(rhoPoly)
39 {}
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
44 template<int PolySize>
46 (
47  const icoPolynomial<PolySize>& ip
48 )
49 :
50  specie(ip),
51  rhoPolynomial_(ip.rhoPolynomial_)
52 {}
53 
54 
55 template<int PolySize>
57 (
58  const word& name,
59  const icoPolynomial<PolySize>& ip
60 )
61 :
62  specie(name, ip),
63  rhoPolynomial_(ip.rhoPolynomial_)
64 {}
65 
66 
67 template<int PolySize>
70 {
72  (
73  new icoPolynomial<PolySize>(*this)
74  );
75 }
76 
77 
78 template<int PolySize>
81 {
83 }
84 
85 
86 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87 
88 template<int PolySize>
89 inline Foam::scalar Foam::icoPolynomial<PolySize>::rho(scalar, scalar T) const
90 {
91  return rhoPolynomial_.evaluate(T)/this->W();
92 }
93 
94 
95 template<int PolySize>
96 inline Foam::scalar Foam::icoPolynomial<PolySize>::psi(scalar, scalar) const
97 {
98  return 0.0;
99 }
100 
101 
102 template<int PolySize>
103 inline Foam::scalar Foam::icoPolynomial<PolySize>::Z(scalar, scalar) const
104 {
105  return 0.0;
106 }
107 
108 
109 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
110 
111 template<int PolySize>
113 (
114  const icoPolynomial<PolySize>& ip
115 )
116 {
117  specie::operator=(ip);
118 
119  rhoPolynomial_ = ip.rhoPolynomial_;
120 
121  return *this;
122 }
123 
124 
125 template<int PolySize>
126 inline void Foam::icoPolynomial<PolySize>::operator+=
127 (
128  const icoPolynomial<PolySize>& ip
129 )
130 {
131  scalar molr1 = this->nMoles();
132 
133  specie::operator+=(ip);
134 
135  molr1 /= this->nMoles();
136  scalar molr2 = ip.nMoles()/this->nMoles();
137 
138  rhoPolynomial_ = molr1*rhoPolynomial_ + molr2*ip.rhoPolynomial_;
139 }
140 
141 
142 template<int PolySize>
143 inline void Foam::icoPolynomial<PolySize>::operator-=
144 (
145  const icoPolynomial<PolySize>& ip
146 )
147 {
148  scalar molr1 = this->nMoles();
149 
150  specie::operator-=(ip);
151 
152  molr1 /= this->nMoles();
153  scalar molr2 = ip.nMoles()/this->nMoles();
154 
155  rhoPolynomial_ = molr1*rhoPolynomial_ - molr2*ip.rhoPolynomial_;
156 }
157 
158 
159 template<int PolySize>
160 inline void Foam::icoPolynomial<PolySize>::operator*=(const scalar s)
161 {
163 }
164 
165 
166 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
167 
168 template<int PolySize>
169 Foam::icoPolynomial<PolySize> Foam::operator+
170 (
171  const icoPolynomial<PolySize>& ip1,
172  const icoPolynomial<PolySize>& ip2
173 )
174 {
175  scalar nMoles = ip1.nMoles() + ip2.nMoles();
176  scalar molr1 = ip1.nMoles()/nMoles;
177  scalar molr2 = ip2.nMoles()/nMoles;
178 
180  (
181  static_cast<const specie&>(ip1)
182  + static_cast<const specie&>(ip2),
183  molr1*ip1.rhoPolynomial_ + molr2*ip2.rhoPolynomial_
184  );
185 }
186 
187 
188 template<int PolySize>
189 Foam::icoPolynomial<PolySize> Foam::operator-
190 (
191  const icoPolynomial<PolySize>& ip1,
192  const icoPolynomial<PolySize>& ip2
193 )
194 {
195  scalar nMoles = ip1.nMoles() + ip2.nMoles();
196  scalar molr1 = ip1.nMoles()/nMoles;
197  scalar molr2 = ip2.nMoles()/nMoles;
198 
200  (
201  static_cast<const specie&>(ip1)
202  - static_cast<const specie&>(ip2),
203  molr1*ip1.rhoPolynomial_ - molr2*ip2.rhoPolynomial_
204  );
205 }
206 
207 
208 template<int PolySize>
209 Foam::icoPolynomial<PolySize> Foam::operator*
210 (
211  const scalar s,
212  const icoPolynomial<PolySize>& ip
213 )
214 {
216  (
217  s*static_cast<const specie&>(ip),
218  ip.rhoPolynomial_
219  );
220 }
221 
222 
223 template<int PolySize>
224 Foam::icoPolynomial<PolySize> Foam::operator==
225 (
226  const icoPolynomial<PolySize>& ip1,
227  const icoPolynomial<PolySize>& ip2
228 )
229 {
230  return ip2 - ip1;
231 }
232 
233 
234 // ************************ vim: set sw=4 sts=4 et: ************************ //