heRhoThermo.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 "heRhoThermo.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class BasicRhoThermo, 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& rhoCells = this->rho_.primitiveFieldRef();
41  scalarField& muCells = this->mu_.primitiveFieldRef();
42  scalarField& kappaCells = this->kappa_.primitiveFieldRef();
43 
44  forAll(TCells, celli)
45  {
46  const typename MixtureType::thermoMixtureType& thermoMixture =
47  this->cellThermoMixture(celli);
48 
49  const typename MixtureType::transportMixtureType& transportMixture =
50  this->cellTransportMixture(celli, thermoMixture);
51 
52  TCells[celli] = thermoMixture.THE
53  (
54  hCells[celli],
55  pCells[celli],
56  TCells[celli]
57  );
58 
59  CpCells[celli] = thermoMixture.Cp(pCells[celli], TCells[celli]);
60  CvCells[celli] = thermoMixture.Cv(pCells[celli], TCells[celli]);
61  psiCells[celli] = thermoMixture.psi(pCells[celli], TCells[celli]);
62  rhoCells[celli] = thermoMixture.rho(pCells[celli], TCells[celli]);
63 
64  muCells[celli] = transportMixture.mu(pCells[celli], TCells[celli]);
65  kappaCells[celli] =
66  transportMixture.kappa(pCells[celli], TCells[celli]);
67  }
68 
69  volScalarField::Boundary& pBf =
70  this->p_.boundaryFieldRef();
71 
72  volScalarField::Boundary& TBf =
73  this->T_.boundaryFieldRef();
74 
75  volScalarField::Boundary& CpBf =
76  this->Cp_.boundaryFieldRef();
77 
78  volScalarField::Boundary& CvBf =
79  this->Cv_.boundaryFieldRef();
80 
81  volScalarField::Boundary& psiBf =
82  this->psi_.boundaryFieldRef();
83 
84  volScalarField::Boundary& rhoBf =
85  this->rho_.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& prho = rhoBf[patchi];
104  fvPatchScalarField& phe = heBf[patchi];
105  fvPatchScalarField& pmu = muBf[patchi];
106  fvPatchScalarField& pkappa = kappaBf[patchi];
107 
108  if (pT.fixesValue())
109  {
110  forAll(pT, facei)
111  {
112  const typename MixtureType::thermoMixtureType& thermoMixture =
113  this->patchFaceThermoMixture(patchi, facei);
114 
115  const typename MixtureType::transportMixtureType&
116  transportMixture =
117  this->patchFaceTransportMixture
118  (patchi, facei, thermoMixture);
119 
120  phe[facei] = thermoMixture.HE(pp[facei], pT[facei]);
121 
122  pCp[facei] = thermoMixture.Cp(pp[facei], pT[facei]);
123  pCv[facei] = thermoMixture.Cv(pp[facei], pT[facei]);
124  ppsi[facei] = thermoMixture.psi(pp[facei], pT[facei]);
125  prho[facei] = thermoMixture.rho(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  const typename MixtureType::thermoMixtureType& thermoMixture =
136  this->patchFaceThermoMixture(patchi, facei);
137 
138  const typename MixtureType::transportMixtureType&
139  transportMixture =
140  this->patchFaceTransportMixture
141  (patchi, facei, thermoMixture);
142 
143  pT[facei] = thermoMixture.THE(phe[facei], pp[facei], pT[facei]);
144 
145  pCp[facei] = thermoMixture.Cp(pp[facei], pT[facei]);
146  pCv[facei] = thermoMixture.Cv(pp[facei], pT[facei]);
147  ppsi[facei] = thermoMixture.psi(pp[facei], pT[facei]);
148  prho[facei] = thermoMixture.rho(pp[facei], pT[facei]);
149 
150  pmu[facei] = transportMixture.mu(pp[facei], pT[facei]);
151  pkappa[facei] = transportMixture.kappa(pp[facei], pT[facei]);
152  }
153  }
154  }
155 }
156 
157 
158 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
159 
160 template<class BasicRhoThermo, class MixtureType>
162 (
163  const fvMesh& mesh,
164  const word& phaseName
165 )
166 :
168 {
169  calculate();
170 }
171 
172 
173 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
174 
175 template<class BasicRhoThermo, class MixtureType>
177 {}
178 
179 
180 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
181 
182 template<class BasicRhoThermo, class MixtureType>
184 {
185  if (debug)
186  {
187  InfoInFunction << endl;
188  }
189 
190  calculate();
191 
192  if (debug)
193  {
194  Info<< " Finished" << endl;
195  }
196 }
197 
198 
199 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
heRhoThermo(const fvMesh &, const word &phaseName)
Construct from mesh and phase name.
Definition: heRhoThermo.C:162
virtual ~heRhoThermo()
Destructor.
Definition: heRhoThermo.C:176
virtual void correct()
Update properties.
Definition: heRhoThermo.C:183
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)
thermo he()
label patchi
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
Energy for a mixture based on density.
Definition: heRhoThermo.H:50
messageStream Info
#define InfoInFunction
Report an information message using Foam::Info.