hePsiThermo.C
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-2020 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 #include "hePsiThermo.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class BasicPsiThermo, class MixtureType>
32 {
33  const scalarField& hCells = this->he_;
34  const scalarField& pCells = this->p_;
35 
36  scalarField& TCells = this->T_.primitiveFieldRef();
37  scalarField& CpCells = this->Cp_.primitiveFieldRef();
38  scalarField& CvCells = this->Cv_.primitiveFieldRef();
39  scalarField& psiCells = this->psi_.primitiveFieldRef();
40  scalarField& muCells = this->mu_.primitiveFieldRef();
41  scalarField& alphaCells = this->alpha_.primitiveFieldRef();
42 
43  forAll(TCells, celli)
44  {
45  const typename MixtureType::thermoMixtureType& thermoMixture =
46  this->cellThermoMixture(celli);
47 
48  const typename MixtureType::transportMixtureType& transportMixture =
49  this->cellTransportMixture(celli, thermoMixture);
50 
51  TCells[celli] = thermoMixture.THE
52  (
53  hCells[celli],
54  pCells[celli],
55  TCells[celli]
56  );
57 
58  CpCells[celli] = thermoMixture.Cp(pCells[celli], TCells[celli]);
59  CvCells[celli] = thermoMixture.Cv(pCells[celli], TCells[celli]);
60  psiCells[celli] = thermoMixture.psi(pCells[celli], TCells[celli]);
61 
62  muCells[celli] = transportMixture.mu(pCells[celli], TCells[celli]);
63  alphaCells[celli] =
64  transportMixture.kappa(pCells[celli], TCells[celli])
65  /thermoMixture.Cp(pCells[celli], TCells[celli]);
66  }
67 
68  volScalarField::Boundary& pBf =
69  this->p_.boundaryFieldRef();
70 
71  volScalarField::Boundary& TBf =
72  this->T_.boundaryFieldRef();
73 
74  volScalarField::Boundary& CpBf =
75  this->Cp_.boundaryFieldRef();
76 
77  volScalarField::Boundary& CvBf =
78  this->Cv_.boundaryFieldRef();
79 
80  volScalarField::Boundary& psiBf =
81  this->psi_.boundaryFieldRef();
82 
83  volScalarField::Boundary& heBf =
84  this->he().boundaryFieldRef();
85 
86  volScalarField::Boundary& muBf =
87  this->mu_.boundaryFieldRef();
88 
89  volScalarField::Boundary& alphaBf =
90  this->alpha_.boundaryFieldRef();
91 
92  forAll(this->T_.boundaryField(), patchi)
93  {
94  fvPatchScalarField& pp = pBf[patchi];
95  fvPatchScalarField& pT = TBf[patchi];
96  fvPatchScalarField& pCp = CpBf[patchi];
97  fvPatchScalarField& pCv = CvBf[patchi];
98  fvPatchScalarField& ppsi = psiBf[patchi];
99  fvPatchScalarField& phe = heBf[patchi];
100  fvPatchScalarField& pmu = muBf[patchi];
101  fvPatchScalarField& palpha = alphaBf[patchi];
102 
103  if (pT.fixesValue())
104  {
105  forAll(pT, facei)
106  {
107  const typename MixtureType::thermoMixtureType&
108  thermoMixture = this->patchFaceThermoMixture(patchi, facei);
109 
110  const typename MixtureType::transportMixtureType&
111  transportMixture =
112  this->patchFaceTransportMixture
113  (patchi, facei, thermoMixture);
114 
115  phe[facei] = thermoMixture.HE(pp[facei], pT[facei]);
116 
117  pCp[facei] = thermoMixture.Cp(pp[facei], pT[facei]);
118  pCv[facei] = thermoMixture.Cv(pp[facei], pT[facei]);
119  ppsi[facei] = thermoMixture.psi(pp[facei], pT[facei]);
120 
121  pmu[facei] = transportMixture.mu(pp[facei], pT[facei]);
122  palpha[facei] =
123  transportMixture.kappa(pp[facei], pT[facei])
124  /thermoMixture.Cp(pp[facei], pT[facei]);
125  }
126  }
127  else
128  {
129  forAll(pT, facei)
130  {
131  const typename MixtureType::thermoMixtureType& thermoMixture =
132  this->patchFaceThermoMixture(patchi, facei);
133 
134  const typename MixtureType::transportMixtureType&
135  transportMixture =
136  this->patchFaceTransportMixture
137  (patchi, facei, thermoMixture);
138 
139  pT[facei] = thermoMixture.THE(phe[facei], pp[facei], pT[facei]);
140 
141  pCp[facei] = thermoMixture.Cp(pp[facei], pT[facei]);
142  pCv[facei] = thermoMixture.Cv(pp[facei], pT[facei]);
143  ppsi[facei] = thermoMixture.psi(pp[facei], pT[facei]);
144 
145  pmu[facei] = transportMixture.mu(pp[facei], pT[facei]);
146  palpha[facei] =
147  transportMixture.kappa(pp[facei], pT[facei])
148  /thermoMixture.Cp(pp[facei], pT[facei]);
149  }
150  }
151  }
152 }
153 
154 
155 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
156 
157 template<class BasicPsiThermo, class MixtureType>
159 (
160  const fvMesh& mesh,
161  const word& phaseName
162 )
163 :
165 {
166  calculate();
167 
168  // Switch on saving old time
169  this->psi_.oldTime();
170 }
171 
172 
173 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
174 
175 template<class BasicPsiThermo, class MixtureType>
177 {}
178 
179 
180 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
181 
182 template<class BasicPsiThermo, class MixtureType>
184 {
185  if (debug)
186  {
187  InfoInFunction << endl;
188  }
189 
190  // force the saving of the old-time values
191  this->psi_.oldTime();
192 
193  calculate();
194 
195  if (debug)
196  {
197  Info<< " Finished" << endl;
198  }
199 }
200 
201 
202 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
dynamicFvMesh & mesh
fvPatchField< scalar > fvPatchScalarField
A class for handling words, derived from string.
Definition: word.H:59
volScalarField scalarField(fieldObject, mesh)
hePsiThermo(const fvMesh &, const word &phaseName)
Construct from mesh and phase name.
Definition: hePsiThermo.C:159
virtual ~hePsiThermo()
Destructor.
Definition: hePsiThermo.C:176
thermo he()
label patchi
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Energy for a mixture based on compressibility.
Definition: hePsiThermo.H:50
messageStream Info
virtual void correct()
Update properties.
Definition: hePsiThermo.C:183
#define InfoInFunction
Report an information message using Foam::Info.