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