constTransportI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
27 
28 template<class Thermo>
30 (
31  const Thermo& t,
32  const scalar mu,
33  const bool constPr,
34  const scalar rPr,
35  const scalar kappa
36 )
37 :
38  Thermo(t),
39  mu_(mu),
40  constPr_(constPr),
41  rPr_(rPr),
42  kappa_(kappa)
43 {}
44 
45 
46 template<class Thermo>
48 (
49  const word& name,
50  const constTransport& ct
51 )
52 :
53  Thermo(name, ct),
54  mu_(ct.mu_),
55  constPr_(ct.constPr_),
56  rPr_(ct.rPr_),
57  kappa_(ct.kappa_)
58 {}
59 
60 
61 template<class Thermo>
64 {
66  (
67  new constTransport<Thermo>(*this)
68  );
69 }
70 
71 
72 template<class Thermo>
75 (
76  const dictionary& dict
77 )
78 {
80  (
82  );
83 }
84 
85 
86 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87 
88 template<class Thermo>
89 inline Foam::scalar Foam::constTransport<Thermo>::mu
90 (
91  const scalar p,
92  const scalar T
93 ) const
94 {
95  return mu_;
96 }
97 
98 
99 template<class Thermo>
100 inline Foam::scalar Foam::constTransport<Thermo>::kappa
101 (
102  const scalar p,
103  const scalar T
104 ) const
105 {
106  return constPr_ ? this->Cp(p, T)*mu(p, T)*rPr_ : kappa_;
107 }
108 
109 
110 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
111 
112 template<class Thermo>
113 inline void Foam::constTransport<Thermo>::operator+=
114 (
115  const constTransport<Thermo>& st
116 )
117 {
118  scalar Y1 = this->Y();
119 
120  Thermo::operator+=(st);
121 
122  if (mag(this->Y()) > small)
123  {
124  if
125  (
127  && (constPr_ != st.constPr_)
128  )
129  {
131  << "Constant " << (constPr_ ? "Pr" : "kappa") << " for "
132  << (this->name().size() ? this->name() : "others") << " but "
133  << "constant " << (st.constPr_ ? "Pr" : "kappa") << " for "
134  << (st.name().size() ? st.name() : "others")
135  << exit(FatalError);
136  }
137 
138  Y1 /= this->Y();
139  scalar Y2 = st.Y()/this->Y();
140 
141  mu_ = Y1*mu_ + Y2*st.mu_;
142  rPr_ = constPr_ ? 1/(Y1/rPr_ + Y2/st.rPr_) : NaN;
143  kappa_ = constPr_ ? NaN : Y1*kappa_ + Y2*st.kappa_;
144  }
145 }
146 
147 
148 template<class Thermo>
149 inline void Foam::constTransport<Thermo>::operator*=
150 (
151  const scalar s
152 )
153 {
154  Thermo::operator*=(s);
155 }
156 
157 
158 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
159 
160 template<class Thermo>
161 inline Foam::constTransport<Thermo> Foam::operator+
162 (
163  const constTransport<Thermo>& ct1,
164  const constTransport<Thermo>& ct2
165 )
166 {
167  Thermo t
168  (
169  static_cast<const Thermo&>(ct1) + static_cast<const Thermo&>(ct2)
170  );
171 
172  if (mag(t.Y()) < small)
173  {
175  (
176  t,
177  0,
178  ct1.constPr_,
179  ct1.rPr_,
180  0
181  );
182  }
183  else
184  {
185  scalar Y1 = ct1.Y()/t.Y();
186  scalar Y2 = ct2.Y()/t.Y();
187 
188  if
189  (
191  && (ct1.constPr_ != ct2.constPr_)
192  )
193  {
195  << "Constant " << (ct1.constPr_ ? "Pr" : "kappa") << " for "
196  << (ct1.name().size() ? ct1.name() : "others") << " but "
197  << "constant " << (ct2.constPr_ ? "Pr" : "kappa") << " for "
198  << (ct2.name().size() ? ct2.name() : "others")
199  << exit(FatalError);
200  }
201 
203  (
204  t,
205  Y1*ct1.mu_ + Y2*ct2.mu_,
206  ct1.constPr_,
207  ct1.constPr_ ? 1/(Y1/ct1.rPr_ + Y2/ct2.rPr_) : NaN,
208  ct1.constPr_ ? NaN : Y1*ct1.kappa_ + Y2*ct2.kappa_
209  );
210  }
211 }
212 
213 
214 template<class Thermo>
215 inline Foam::constTransport<Thermo> Foam::operator*
216 (
217  const scalar s,
218  const constTransport<Thermo>& ct
219 )
220 {
222  (
223  s*static_cast<const Thermo&>(ct),
224  ct.mu_,
225  ct.constPr_,
226  ct.rPr_,
227  ct.kappa_
228  );
229 }
230 
231 
232 // ************************************************************************* //
dictionary dict
scalar kappa(const scalar p, const scalar T) const
Thermal conductivity [W/m/K].
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
Transport package with constant properties.
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A class for handling words, derived from string.
Definition: word.H:59
autoPtr< constTransport > clone() const
Construct and return a clone.
const dimensionedScalar mu
Atomic mass unit.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
PtrList< volScalarField > & Y
scalar Cp(const scalar p, const scalar T) const
Definition: EtoHthermo.H:2
dimensioned< scalar > mag(const dimensioned< Type > &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
static autoPtr< constTransport > New(const dictionary &dict)
scalar mu(const scalar p, const scalar T) const
Dynamic viscosity [kg/m/s].