heSolidThermo.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2017-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "heSolidThermo.H"
30 #include "volFields.H"
31 
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 
34 template<class BasicSolidThermo, class MixtureType>
36 {
37  scalarField& TCells = this->T_.primitiveFieldRef();
38 
39  const scalarField& hCells = this->he_;
40  const scalarField& pCells = this->p_;
41  scalarField& rhoCells = this->rho_.primitiveFieldRef();
42  //scalarField& psiCells = this->psi_.primitiveFieldRef();
43  //scalarField& muCells = this->mu_.primitiveFieldRef();
44  scalarField& alphaCells = this->alpha_.primitiveFieldRef();
45 
46  forAll(TCells, celli)
47  {
48  const typename MixtureType::thermoType& mixture_ =
49  this->cellMixture(celli);
50 
51  const typename MixtureType::thermoType& volMixture_ =
52  this->cellVolMixture(pCells[celli], TCells[celli], celli);
53 
54  if (this->updateT())
55  {
56  TCells[celli] = mixture_.THE
57  (
58  hCells[celli],
59  pCells[celli],
60  TCells[celli]
61  );
62  }
63 
64  rhoCells[celli] = volMixture_.rho(pCells[celli], TCells[celli]);
65  //psiCells[celli] = volMixture_.psi(pCells[celli], TCells[celli]);
66  //muCells[celli] = volMixture_.mu(pCells[celli], TCells[celli]);
67 
68  alphaCells[celli] =
69  volMixture_.kappa(pCells[celli], TCells[celli])
70  /
71  mixture_.Cpv(pCells[celli], TCells[celli]);
72  }
73 
74  volScalarField::Boundary& pBf = this->p_.boundaryFieldRef();
75  volScalarField::Boundary& TBf = this->T_.boundaryFieldRef();
76  volScalarField::Boundary& rhoBf = this->rho_.boundaryFieldRef();
77  //volScalarField::Boundary& psiBf = this->psi_.boundaryFieldRef();
78  //volScalarField::Boundary& muBf = this->mu_.boundaryFieldRef();
79  volScalarField::Boundary& heBf = this->he().boundaryFieldRef();
80  volScalarField::Boundary& alphaBf = this->alpha_.boundaryFieldRef();
81 
82  forAll(this->T_.boundaryField(), patchi)
83  {
84  fvPatchScalarField& pp = pBf[patchi];
85  fvPatchScalarField& pT = TBf[patchi];
86  fvPatchScalarField& prho = rhoBf[patchi];
87  //fvPatchScalarField& ppsi = psiBf[patchi];
88  //fvPatchScalarField& pmu = muBf[patchi];
89  fvPatchScalarField& phe = heBf[patchi];
90  fvPatchScalarField& palpha = alphaBf[patchi];
91 
92  if (pT.fixesValue())
93  {
94  forAll(pT, facei)
95  {
96  const typename MixtureType::thermoType& mixture_ =
97  this->patchFaceMixture(patchi, facei);
98 
99  const typename MixtureType::thermoType& volMixture_ =
100  this->patchFaceVolMixture
101  (
102  pp[facei],
103  pT[facei],
104  patchi,
105  facei
106  );
107 
108 
109  phe[facei] = mixture_.HE(pp[facei], pT[facei]);
110  prho[facei] = volMixture_.rho(pp[facei], pT[facei]);
111  //ppsi[facei] = volMixture_.psi(pp[facei], pT[facei]);
112  //pmu[facei] = volMixture_.mu(pp[facei], pT[facei]);
113 
114  palpha[facei] =
115  volMixture_.kappa(pp[facei], pT[facei])
116  / mixture_.Cpv(pp[facei], pT[facei]);
117  }
118  }
119  else
120  {
121  forAll(pT, facei)
122  {
123  const typename MixtureType::thermoType& mixture_ =
124  this->patchFaceMixture(patchi, facei);
125 
126  const typename MixtureType::thermoType& volMixture_ =
127  this->patchFaceVolMixture
128  (
129  pp[facei],
130  pT[facei],
131  patchi,
132  facei
133  );
134 
135  if (this->updateT())
136  {
137  pT[facei] = mixture_.THE(phe[facei], pp[facei] ,pT[facei]);
138  }
139 
140  prho[facei] = volMixture_.rho(pp[facei], pT[facei]);
141  //ppsi[facei] = volMixture_.psi(pp[facei], pT[facei]);
142  //pmu[facei] = volMixture_.mu(pp[facei], pT[facei]);
143 
144  palpha[facei] =
145  volMixture_.kappa(pp[facei], pT[facei])
146  / mixture_.Cpv(pp[facei], pT[facei]);
147  }
148  }
149  }
150 
151  this->alpha_.correctBoundaryConditions();
152 }
153 
154 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
155 
156 template<class BasicSolidThermo, class MixtureType>
159 (
160  const fvMesh& mesh,
161  const word& phaseName
162 )
163 :
165 {
166  calculate();
167  this->mu_ == dimensionedScalar(this->mu_.dimensions(), Zero);
168  this->psi_ == dimensionedScalar(this->psi_.dimensions(), Zero);
169 }
170 
171 
172 template<class BasicSolidThermo, class MixtureType>
175 (
176  const fvMesh& mesh,
177  const dictionary& dict,
178  const word& phaseName
179 )
180 :
182 {
183  calculate();
184  this->mu_ == dimensionedScalar(this->mu_.dimensions(), Zero);
185  this->psi_ == dimensionedScalar(this->psi_.dimensions(), Zero);
186 }
187 
188 
189 template<class BasicSolidThermo, class MixtureType>
192 (
193  const fvMesh& mesh,
194  const word& phaseName,
195  const word& dictName
196 )
197 :
199 {
200  calculate();
201 
202  // TBD. initialise psi, mu (at heThermo level) since these do not
203  // get initialised. Move to heThermo constructor?
204  this->mu_ == dimensionedScalar(this->mu_.dimensions(), Zero);
205  this->psi_ == dimensionedScalar(this->psi_.dimensions(), Zero);
206 }
207 
208 
209 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
210 
211 template<class BasicSolidThermo, class MixtureType>
213 {}
214 
215 
216 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
217 
218 template<class BasicSolidThermo, class MixtureType>
220 {
221  DebugInFunction << nl;
222 
223  calculate();
224 
225  DebugInfo << " Finished" << endl;
226 }
227 
228 
229 template<class BasicSolidThermo, class MixtureType>
232 {
233  const fvMesh& mesh = this->T_.mesh();
234 
235  tmp<volVectorField> tKappa
236  (
237  new volVectorField
238  (
239  IOobject
240  (
241  "Kappa",
242  mesh.time().timeName(),
243  mesh,
244  IOobject::NO_READ,
245  IOobject::NO_WRITE
246  ),
247  mesh,
249  )
250  );
251 
252  volVectorField& Kappa = tKappa.ref();
253  vectorField& KappaCells = Kappa.primitiveFieldRef();
254  const scalarField& TCells = this->T_;
255  const scalarField& pCells = this->p_;
256 
257  forAll(KappaCells, celli)
258  {
259  Kappa[celli] =
260  this->cellVolMixture
261  (
262  pCells[celli],
263  TCells[celli],
264  celli
265  ).Kappa(pCells[celli], TCells[celli]);
266  }
267 
268  volVectorField::Boundary& KappaBf = Kappa.boundaryFieldRef();
269 
270  forAll(KappaBf, patchi)
271  {
272  vectorField& Kappap = KappaBf[patchi];
273  const scalarField& pT = this->T_.boundaryField()[patchi];
274  const scalarField& pp = this->p_.boundaryField()[patchi];
275 
276  forAll(Kappap, facei)
277  {
278  Kappap[facei] =
279  this->patchFaceVolMixture
280  (
281  pp[facei],
282  pT[facei],
283  patchi,
284  facei
285  ).Kappa(pp[facei], pT[facei]);
286  }
287  }
288 
289  return tKappa;
290 }
291 
292 
293 template<class BasicSolidThermo, class MixtureType>
296 (
297  const label patchi
298 ) const
299 {
300  const scalarField& pp = this->p_.boundaryField()[patchi];
301  const scalarField& Tp = this->T_.boundaryField()[patchi];
302  tmp<vectorField> tKappa(new vectorField(pp.size()));
303 
304  vectorField& Kappap = tKappa.ref();
305 
306  forAll(Tp, facei)
307  {
308  Kappap[facei] =
309  this->patchFaceVolMixture
310  (
311  pp[facei],
312  Tp[facei],
313  patchi,
314  facei
315  ).Kappa(pp[facei], Tp[facei]);
316  }
317 
318  return tKappa;
319 }
320 
321 
322 // ************************************************************************* //
Foam::fvPatchScalarField
fvPatchField< scalar > fvPatchScalarField
Definition: fvPatchFieldsFwd.H:40
volFields.H
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::heThermo< BasicSolidThermo, MixtureType >
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::dimEnergy
const dimensionSet dimEnergy
Foam::heSolidThermo::correct
virtual void correct()
Update properties.
Definition: heSolidThermo.C:219
dictName
const word dictName("blockMeshDict")
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:54
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:228
Foam::Field< vector >
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:365
Foam::heSolidThermo::~heSolidThermo
virtual ~heSolidThermo()
Destructor.
Definition: heSolidThermo.C:212
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:43
Foam::heSolidThermo::Kappa
virtual tmp< volVectorField > Kappa() const
Anisotropic thermal conductivity [W/m/K].
Definition: heSolidThermo.C:231
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::heSolidThermo
Energy for a solid mixture.
Definition: heSolidThermo.H:52
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
heSolidThermo.H
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:359
he
volScalarField & he
Definition: YEEqn.H:52
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::GeometricField::ref
Internal & ref(const bool updateAccessTime=true)
Return a reference to the dimensioned internal field.
Definition: GeometricField.C:749
Foam::dimTemperature
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:55
Foam::dimensioned::dimensions
const dimensionSet & dimensions() const
Return const reference to dimensions.
Definition: dimensionedType.C:420
Foam::GeometricField< vector, fvPatchField, volMesh >