SolidThermo.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-2024 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 "SolidThermo.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class BaseThermo>
32 {
33  const bool isotropic = this->isotropic();
34 
35  const scalarField& hCells = this->he_;
36  const auto& pCells = this->p_;
37 
38  scalarField& TCells = this->T_.primitiveFieldRef();
39  scalarField& CpCells = this->Cp_.primitiveFieldRef();
40  scalarField& CvCells = this->Cv_.primitiveFieldRef();
41  scalarField& rhoCells = this->rho_.primitiveFieldRef();
42  scalarField& kappaCells = this->kappa_.primitiveFieldRef();
43  vectorField& KappaCells = this->Kappa_.primitiveFieldRef();
44 
45  auto Yslicer = this->Yslicer();
46 
47  forAll(TCells, celli)
48  {
49  auto composition = this->cellComposition(Yslicer, celli);
50 
51  const typename BaseThermo::mixtureType::thermoMixtureType&
52  thermoMixture = this->thermoMixture(composition);
53 
54  const typename BaseThermo::mixtureType::transportMixtureType&
55  transportMixture =
56  this->transportMixture(composition, thermoMixture);
57 
58  TCells[celli] = thermoMixture.The
59  (
60  hCells[celli],
61  pCells[celli],
62  TCells[celli]
63  );
64 
65  CpCells[celli] = thermoMixture.Cp(pCells[celli], TCells[celli]);
66  CvCells[celli] = thermoMixture.Cv(pCells[celli], TCells[celli]);
67  rhoCells[celli] = thermoMixture.rho(pCells[celli], TCells[celli]);
68 
69  if (isotropic)
70  {
71  kappaCells[celli] =
72  transportMixture.kappa(pCells[celli], TCells[celli]);
73  }
74  else
75  {
76  KappaCells[celli] =
77  transportMixture.Kappa(pCells[celli], TCells[celli]);
78  }
79  }
80 
81 
83  this->he().boundaryFieldRef();
84 
85  const auto& pBf = this->p_.boundaryField();
86 
88  this->T_.boundaryFieldRef();
89 
91  this->Cp_.boundaryFieldRef();
92 
94  this->Cv_.boundaryFieldRef();
95 
97  this->rho_.boundaryFieldRef();
98 
99  volScalarField::Boundary& kappaBf =
100  this->kappa_.boundaryFieldRef();
101 
102  volVectorField::Boundary& KappaBf =
103  this->Kappa_.boundaryFieldRef();
104 
105  forAll(this->T_.boundaryField(), patchi)
106  {
107  fvPatchScalarField& phe = heBf[patchi];
108  const auto& pp = pBf[patchi];
109  fvPatchScalarField& pT = TBf[patchi];
110  fvPatchScalarField& pCp = CpBf[patchi];
111  fvPatchScalarField& pCv = CvBf[patchi];
112  fvPatchScalarField& prho = rhoBf[patchi];
113  fvPatchScalarField& pkappa = kappaBf[patchi];
114  fvPatchVectorField& pKappa = KappaBf[patchi];
115 
116  if (pT.fixesValue())
117  {
118  forAll(pT, facei)
119  {
120  auto composition =
121  this->patchFaceComposition(Yslicer, patchi, facei);
122 
123  const typename BaseThermo::mixtureType::thermoMixtureType&
124  thermoMixture = this->thermoMixture(composition);
125 
126  const typename BaseThermo::mixtureType::transportMixtureType&
127  transportMixture =
128  this->transportMixture(composition, thermoMixture);
129 
130  phe[facei] = thermoMixture.he(pp[facei], pT[facei]);
131 
132  prho[facei] = thermoMixture.rho(pp[facei], pT[facei]);
133  pCp[facei] = thermoMixture.Cp(pp[facei], pT[facei]);
134  pCv[facei] = thermoMixture.Cv(pp[facei], pT[facei]);
135 
136  if (isotropic)
137  {
138  pkappa[facei] =
139  transportMixture.kappa(pp[facei], pT[facei]);
140  }
141  else
142  {
143  pKappa[facei] =
144  transportMixture.Kappa(pp[facei], pT[facei]);
145  }
146  }
147  }
148  else
149  {
150  forAll(pT, facei)
151  {
152  auto composition =
153  this->patchFaceComposition(Yslicer, patchi, facei);
154 
155  const typename BaseThermo::mixtureType::thermoMixtureType&
156  thermoMixture = this->thermoMixture(composition);
157 
158  const typename BaseThermo::mixtureType::transportMixtureType&
159  transportMixture =
160  this->transportMixture(composition, thermoMixture);
161 
162  pT[facei] = thermoMixture.The(phe[facei], pp[facei] ,pT[facei]);
163 
164  prho[facei] = thermoMixture.rho(pp[facei], pT[facei]);
165  pCp[facei] = thermoMixture.Cp(pp[facei], pT[facei]);
166  pCv[facei] = thermoMixture.Cv(pp[facei], pT[facei]);
167 
168  if (isotropic)
169  {
170  pkappa[facei] =
171  transportMixture.kappa(pp[facei], pT[facei]);
172  }
173  else
174  {
175  pKappa[facei] =
176  transportMixture.Kappa(pp[facei], pT[facei]);
177  }
178  }
179  }
180  }
181 }
182 
183 
184 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
185 
186 template<class BaseThermo>
188 (
189  const fvMesh& mesh,
190  const word& phaseName
191 )
192 :
193  BaseThermo(mesh, phaseName),
194  Kappa_
195  (
196  IOobject
197  (
198  BaseThermo::phasePropertyName("Kappa", phaseName),
199  mesh.time().name(),
200  mesh,
201  IOobject::NO_READ,
202  IOobject::NO_WRITE
203  ),
204  mesh,
206  )
207 {
208  calculate();
209 }
210 
211 
212 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
213 
214 template<class BaseThermo>
216 {}
217 
218 
219 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
220 
221 template<class BaseThermo>
223 {
224  if (BaseThermo::debug)
225  {
226  InfoInFunction << endl;
227  }
228 
229  calculate();
230 
231  if (BaseThermo::debug)
232  {
233  Info<< " Finished" << endl;
234  }
235 }
236 
237 
238 template<class BaseThermo>
241 {
242  return Kappa_;
243 }
244 
245 
246 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Generic GeometricBoundaryField class.
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
virtual void correct()
Update properties.
Definition: SolidThermo.C:222
virtual ~SolidThermo()
Destructor.
Definition: SolidThermo.C:215
SolidThermo(const fvMesh &, const word &phaseName)
Construct from mesh and phase name.
Definition: SolidThermo.C:188
virtual const volVectorField & Kappa() const
Anisotropic thermal conductivity [W/m/K].
Definition: SolidThermo.C:240
void calculate()
Calculate the thermo variables.
Definition: SolidThermo.C:31
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
virtual bool fixesValue() const
Return true if this patch field fixes a value.
Definition: fvPatchField.H:315
A class for handling words, derived from string.
Definition: word.H:62
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.
static const zero Zero
Definition: zero.H:97
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
messageStream Info
const dimensionSet dimThermalConductivity
thermo he()