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-2022 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& kappaCells = this->kappa_.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  kappaCells[celli] =
64  transportMixture.kappa(pCells[celli], TCells[celli]);
65  }
66 
67  volScalarField::Boundary& pBf =
68  this->p_.boundaryFieldRef();
69 
70  volScalarField::Boundary& TBf =
71  this->T_.boundaryFieldRef();
72 
73  volScalarField::Boundary& CpBf =
74  this->Cp_.boundaryFieldRef();
75 
76  volScalarField::Boundary& CvBf =
77  this->Cv_.boundaryFieldRef();
78 
79  volScalarField::Boundary& psiBf =
80  this->psi_.boundaryFieldRef();
81 
82  volScalarField::Boundary& heBf =
83  this->he().boundaryFieldRef();
84 
85  volScalarField::Boundary& muBf =
86  this->mu_.boundaryFieldRef();
87 
88  volScalarField::Boundary& kappaBf =
89  this->kappa_.boundaryFieldRef();
90 
91  forAll(this->T_.boundaryField(), patchi)
92  {
93  fvPatchScalarField& pp = pBf[patchi];
94  fvPatchScalarField& pT = TBf[patchi];
95  fvPatchScalarField& pCp = CpBf[patchi];
96  fvPatchScalarField& pCv = CvBf[patchi];
97  fvPatchScalarField& ppsi = psiBf[patchi];
98  fvPatchScalarField& phe = heBf[patchi];
99  fvPatchScalarField& pmu = muBf[patchi];
100  fvPatchScalarField& pkappa = kappaBf[patchi];
101 
102  if (pT.fixesValue())
103  {
104  forAll(pT, facei)
105  {
106  const typename MixtureType::thermoMixtureType&
107  thermoMixture = this->patchFaceThermoMixture(patchi, facei);
108 
109  const typename MixtureType::transportMixtureType&
110  transportMixture =
111  this->patchFaceTransportMixture
112  (patchi, facei, thermoMixture);
113 
114  phe[facei] = thermoMixture.HE(pp[facei], pT[facei]);
115 
116  pCp[facei] = thermoMixture.Cp(pp[facei], pT[facei]);
117  pCv[facei] = thermoMixture.Cv(pp[facei], pT[facei]);
118  ppsi[facei] = thermoMixture.psi(pp[facei], pT[facei]);
119 
120  pmu[facei] = transportMixture.mu(pp[facei], pT[facei]);
121  pkappa[facei] = transportMixture.kappa(pp[facei], pT[facei]);
122  }
123  }
124  else
125  {
126  forAll(pT, facei)
127  {
128  const typename MixtureType::thermoMixtureType& thermoMixture =
129  this->patchFaceThermoMixture(patchi, facei);
130 
131  const typename MixtureType::transportMixtureType&
132  transportMixture =
133  this->patchFaceTransportMixture
134  (patchi, facei, thermoMixture);
135 
136  pT[facei] = thermoMixture.THE(phe[facei], pp[facei], pT[facei]);
137 
138  pCp[facei] = thermoMixture.Cp(pp[facei], pT[facei]);
139  pCv[facei] = thermoMixture.Cv(pp[facei], pT[facei]);
140  ppsi[facei] = thermoMixture.psi(pp[facei], pT[facei]);
141 
142  pmu[facei] = transportMixture.mu(pp[facei], pT[facei]);
143  pkappa[facei] = transportMixture.kappa(pp[facei], pT[facei]);
144  }
145  }
146  }
147 }
148 
149 
150 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
151 
152 template<class BasicPsiThermo, class MixtureType>
154 (
155  const fvMesh& mesh,
156  const word& phaseName
157 )
158 :
160 {
161  calculate();
162 
163  // Switch on saving old time
164  this->psi_.oldTime();
165 }
166 
167 
168 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
169 
170 template<class BasicPsiThermo, class MixtureType>
172 {}
173 
174 
175 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
176 
177 template<class BasicPsiThermo, class MixtureType>
179 {
180  if (debug)
181  {
182  InfoInFunction << endl;
183  }
184 
185  // force the saving of the old-time values
186  this->psi_.oldTime();
187 
188  calculate();
189 
190  if (debug)
191  {
192  Info<< " Finished" << endl;
193  }
194 }
195 
196 
197 // ************************************************************************* //
#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
fvMesh & mesh
label calculate(const fvMesh &mesh, const labelHashSet &patchIDs, const scalar minFaceFraction, GeometricField< scalar, PatchField, GeoMesh > &distance)
Calculate distance data from patches.
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:154
virtual ~hePsiThermo()
Destructor.
Definition: hePsiThermo.C:171
thermo he()
label patchi
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
Energy for a mixture based on compressibility.
Definition: hePsiThermo.H:50
messageStream Info
virtual void correct()
Update properties.
Definition: hePsiThermo.C:178
#define InfoInFunction
Report an information message using Foam::Info.