thermalBaffle.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2020-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "thermalBaffle.H"
30 #include "fvm.H"
31 #include "fvcDiv.H"
34 #include "fvMatrices.H"
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 namespace regionModels
42 {
43 namespace thermalBaffleModels
44 {
45 
46 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
47 
49 
52 
53 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
54 
56 {
57  this->solution().readEntry("nNonOrthCorr", nNonOrthCorr_);
58  return regionModel1D::read();
59 }
60 
61 
63 {
64  this->solution().readEntry("nNonOrthCorr", nNonOrthCorr_);
65  return regionModel1D::read(dict);
66 }
67 
68 
70 {
72 
73  const polyBoundaryMesh& rbm = regionMesh().boundaryMesh();
74 
76  (
77  new volScalarField
78  (
79  IOobject
80  (
81  "tQ",
82  regionMesh().time().timeName(),
83  regionMesh().thisDb(),
87  ),
88  regionMesh(),
90  )
91  );
92 
93  volScalarField& Q = tQ.ref();
94 
95  volScalarField rho("rho", thermo_->rho());
96  volScalarField alpha("alpha", thermo_->alpha());
97 
98 
99  // If region is one-dimension variable thickness
100  if (oneD_ && !constantThickness_)
101  {
102  // Scale K and rhoCp and fill Q in the internal baffle region.
103  const label patchi = intCoupledPatchIDs_[0];
104  const polyPatch& ppCoupled = rbm[patchi];
105 
106  forAll(ppCoupled, localFacei)
107  {
108  const labelList& cells = boundaryFaceCells_[localFacei];
109  forAll(cells, i)
110  {
111  const label cellId = cells[i];
112 
113  Q[cellId] =
114  qs_.boundaryField()[patchi][localFacei]
115  /thickness_[localFacei];
116 
117  rho[cellId] *= delta_.value()/thickness_[localFacei];
118 
119  alpha[cellId] *= delta_.value()/thickness_[localFacei];
120  }
121  }
122  }
123  else
124  {
125  Q = Q_;
126  }
127 
128  fvScalarMatrix hEqn
129  (
130  fvm::ddt(rho, h_)
132  ==
133  Q
134  );
135 
136  if (moveMesh_)
137  {
138  surfaceScalarField phiMesh
139  (
141  );
142 
143  hEqn -= fvc::div(phiMesh);
144  }
145 
146  hEqn.relax();
147  hEqn.solve();
148 
149  thermo_->correct();
150 
151  Info<< "T min/max = " << min(thermo_->T()) << ", "
152  << max(thermo_->T()) << endl;
153 }
154 
155 
156 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
157 
158 thermalBaffle::thermalBaffle
159 (
160  const word& modelType,
161  const fvMesh& mesh,
162  const dictionary& dict
163 )
164 :
165  thermalBaffleModel(modelType, mesh, dict),
166  nNonOrthCorr_(solution().get<label>("nNonOrthCorr")),
167  thermo_(solidThermo::New(regionMesh(), dict)),
168  h_(thermo_->he()),
169  qs_
170  (
171  IOobject
172  (
173  "qs",
174  regionMesh().time().timeName(),
175  regionMesh().thisDb(),
176  IOobject::READ_IF_PRESENT,
177  IOobject::NO_WRITE
178  ),
179  regionMesh(),
181  ),
182  Q_
183  (
184  IOobject
185  (
186  "Q",
187  regionMesh().time().timeName(),
188  regionMesh().thisDb(),
189  IOobject::READ_IF_PRESENT,
190  IOobject::AUTO_WRITE
191  ),
192  regionMesh(),
194  ),
195  radiation_
196  (
198  (
199  dict.subDict("radiation"),
200  thermo_->T()
201  )
202  )
203 {
204  init();
205  thermo_->correct();
206 }
207 
208 
209 thermalBaffle::thermalBaffle
210 (
211  const word& modelType,
212  const fvMesh& mesh
213 )
214 :
215  thermalBaffleModel(modelType, mesh),
216  nNonOrthCorr_(solution().get<label>("nNonOrthCorr")),
217  thermo_(solidThermo::New(regionMesh())),
218  h_(thermo_->he()),
219  qs_
220  (
221  IOobject
222  (
223  "qs",
224  regionMesh().time().timeName(),
225  regionMesh().thisDb(),
226  IOobject::READ_IF_PRESENT,
227  IOobject::NO_WRITE
228  ),
229  regionMesh(),
231  ),
232  Q_
233  (
234  IOobject
235  (
236  "Q",
237  regionMesh().time().timeName(),
238  regionMesh().thisDb(),
239  IOobject::READ_IF_PRESENT,
240  IOobject::NO_WRITE
241  ),
242  regionMesh(),
244  ),
245  radiation_
246  (
248  (
249  thermo_->T()
250  )
251  )
252 {
253  init();
254  thermo_->correct();
255 }
256 
257 
258 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
259 
261 {}
262 
263 
264 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
265 
266 void thermalBaffle::init()
267 {
268  if (oneD_ && !constantThickness_)
269  {
270  label patchi = intCoupledPatchIDs_[0];
271  const label qsb = qs_.boundaryField()[patchi].size();
272 
273  if (qsb!= thickness_.size())
274  {
276  << "the boundary field of qs is "
277  << qsb << " and " << nl
278  << "the field 'thickness' is " << thickness_.size() << nl
279  << exit(FatalError);
280  }
281  }
282 }
283 
284 
286 {}
287 
288 
290 {
291  for (int nonOrth=0; nonOrth<=nNonOrthCorr_; nonOrth++)
292  {
293  solveEnergy();
294  }
295 }
296 
299 {
300  return thermo_->Cp();
301 }
302 
305 {
306  return radiation_->absorptionEmission().a();
307 }
308 
310 const volScalarField& thermalBaffle::rho() const
311 {
312  return thermo_->rho();
313 }
314 
317 {
318  return thermo_->kappa();
319 }
320 
322 const volScalarField& thermalBaffle::T() const
323 {
324  return thermo_->T();
325 }
326 
328 const solidThermo& thermalBaffle::thermo() const
329 {
330  return *thermo_;
331 }
332 
333 
334 void thermalBaffle::info()
335 {
336  const labelList& coupledPatches = intCoupledPatchIDs();
337 
338  forAll(coupledPatches, i)
339  {
340  const label patchi = coupledPatches[i];
341  const fvPatchScalarField& ph = h_.boundaryField()[patchi];
342  const word patchName = regionMesh().boundary()[patchi].name();
343  Info<< indent << "Q : " << patchName << indent <<
344  gSum
345  (
346  mag(regionMesh().Sf().boundaryField()[patchi])
347  * ph.snGrad()
348  * thermo_->alpha().boundaryField()[patchi]
349  ) << endl;
350  }
351 }
352 
353 
354 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
355 
356 } // End namespace thermalBaffleModels
357 } // End namespace regionModels
358 } // End namespace Foam
359 
360 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
volScalarField & he
Definition: YEEqn.H:52
autoPtr< solidThermo > thermo_
Solid thermo.
Definition: thermalBaffle.H:95
const Type & value() const noexcept
Return const reference to value.
dictionary dict
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:37
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:493
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: fvPatchField.C:213
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
label nNonOrthCorr_
Number of non orthogonal correctors.
Definition: thermalBaffle.H:87
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:42
virtual const solidThermo & thermo() const
Return const reference to the solidThermo.
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Ignore writing from objectRegistry::writeObject()
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
const labelList & intCoupledPatchIDs() const noexcept
List of patch IDs internally coupled with the primary region.
Definition: regionModelI.H:97
volScalarField & h_
Enthalpy/internal energy.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
Switch moveMesh_
Flag to allow mesh movement.
word timeName
Definition: getTimeIndex.H:3
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
virtual void evolveRegion()
Evolve the thermal baffle.
dynamicFvMesh & mesh
Type gSum(const FieldField< Field, Type > &f)
const cellShapeList & cells
virtual const volScalarField & kappaRad() const
Return solid absortivity [1/m].
virtual void preEvolveRegion()
Pre-evolve thermal baffle.
volScalarField Q_
Volumetric energy source / [J/m3/s].
addToRunTimeSelectionTable(thermalBaffleModel, noThermo, mesh)
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition: polyMesh.H:608
A class for handling words, derived from Foam::string.
Definition: word.H:63
#define DebugInFunction
Report an information message using Foam::Info.
labelListList boundaryFaceCells_
Global cell IDs.
Definition: regionModel1D.H:91
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:106
const dictionary & solution() const
Return the solution dictionary.
Definition: regionModelI.H:55
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvmDdt.C:41
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:26
Top level model for radiation modelling.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
virtual const tmp< volScalarField > Cp() const
Return the film specific heat capacity [J/kg/K].
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
Calculate the divergence of the given field.
virtual bool read()
Read control parameters IO dictionary.
Definition: thermalBaffle.C:48
Fundamental solid thermodynamic properties.
Definition: solidThermo.H:48
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const dimensionSet dimEnergy
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:41
virtual bool read()
Read control parameters from dictionary.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
label cellId
autoPtr< radiation::radiationModel > radiation_
Pointer to radiation model.
Nothing to be read.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
virtual const volScalarField & T() const
Return temperature [K].
A special matrix type and solver, designed for finite volume solutions of scalar equations.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Internal & ref(const bool updateAccessTime=true)
Same as internalFieldRef()
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Definition: fvMesh.H:395
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:92
labelList intCoupledPatchIDs_
List of patch IDs internally coupled with the primary region.
Definition: regionModel.H:135
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual const volScalarField & kappa() const
Return thermal conductivity [W/m/K].
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
virtual void info()
Provide some feedback.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
virtual const volScalarField & rho() const
Return density [Kg/m3].
Do not request registration (bool: false)
const Time & time() const noexcept
Return the reference to the time database.
Definition: regionModel.H:244
autoPtr< radiation::radiationModel > radiation(radiation::radiationModel::New(T))
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
Namespace for OpenFOAM.
volScalarField qs_
Surface energy source / [J/m2/s].
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127