chtMultiRegionFoam.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) 2017-2019,2022 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 Application
28  chtMultiRegionFoam
29 
30 Group
31  grpHeatTransferSolvers
32 
33 Description
34  Transient solver for buoyant, turbulent fluid flow and solid heat
35  conduction with conjugate heat transfer between solid and fluid regions.
36 
37  It handles secondary fluid or solid circuits which can be coupled
38  thermally with the main fluid region. i.e radiators, etc.
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #include "fvCFD.H"
44 #include "rhoReactionThermo.H"
45 #include "CombustionModel.H"
47 #include "regionProperties.H"
48 #include "compressibleCourantNo.H"
49 #include "solidRegionDiffNo.H"
50 #include "solidThermo.H"
51 #include "radiationModel.H"
52 #include "fvOptions.H"
53 #include "loopControl.H"
54 #include "pressureControl.H"
55 
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 int main(int argc, char *argv[])
60 {
61  argList::addNote
62  (
63  "Transient solver for buoyant, turbulent fluid flow and solid heat"
64  " conduction with conjugate heat transfer"
65  " between solid and fluid regions."
66  );
67 
68  #define NO_CONTROL
69  #define CREATE_MESH createMeshesPostProcess.H
70  #include "postProcess.H"
71 
72  #include "addCheckCaseOptions.H"
73  #include "setRootCaseLists.H"
74  #include "createTime.H"
75  #include "createMeshes.H"
76  #include "createFields.H"
77  #include "initContinuityErrs.H"
78  #include "createTimeControls.H"
79  #include "readSolidTimeControls.H"
80  #include "compressibleMultiRegionCourantNo.H"
81  #include "solidRegionDiffusionNo.H"
83 
84  #include "createCoupledRegions.H"
85 
86  while (runTime.run())
87  {
88  #include "readTimeControls.H"
89  #include "readSolidTimeControls.H"
90  #include "readPIMPLEControls.H"
91 
92  #include "compressibleMultiRegionCourantNo.H"
93  #include "solidRegionDiffusionNo.H"
94  #include "setMultiRegionDeltaT.H"
95 
96  ++runTime;
97 
98  Info<< "Time = " << runTime.timeName() << nl << endl;
99 
100  if (nOuterCorr != 1)
101  {
102  forAll(fluidRegions, i)
103  {
104  #include "storeOldFluidFields.H"
105  }
106  }
107 
108  // --- PIMPLE loop
109  for (int oCorr=0; oCorr<nOuterCorr; ++oCorr)
110  {
111  const bool finalIter = (oCorr == nOuterCorr-1);
112 
113  forAll(fluidRegions, i)
114  {
115  fvMesh& mesh = fluidRegions[i];
116 
117  #include "readFluidMultiRegionPIMPLEControls.H"
118  #include "setRegionFluidFields.H"
119  #include "solveFluid.H"
120  }
121 
122  forAll(solidRegions, i)
123  {
124  fvMesh& mesh = solidRegions[i];
125 
127  #include "setRegionSolidFields.H"
128  #include "solveSolid.H"
129  }
130 
131  if (coupled)
132  {
133  Info<< "\nSolving energy coupled regions " << endl;
134  fvMatrixAssemblyPtr->solve();
135  #include "correctThermos.H"
136 
137  forAll(fluidRegions, i)
138  {
139  fvMesh& mesh = fluidRegions[i];
140 
141  #include "readFluidMultiRegionPIMPLEControls.H"
142  #include "setRegionFluidFields.H"
143  if (!frozenFlow)
144  {
145  Info<< "\nSolving for fluid region "
146  << fluidRegions[i].name() << endl;
147  // --- PISO loop
148  for (int corr=0; corr<nCorr; corr++)
149  {
150  #include "pEqn.H"
151  }
152  turbulence.correct();
153  }
154 
155  rho = thermo.rho();
156  Info<< "Min/max T:" << min(thermo.T()).value() << ' '
157  << max(thermo.T()).value() << endl;
158  }
159 
160  fvMatrixAssemblyPtr->clear();
161  }
162 
163  // Additional loops for energy solution only
164  if (!oCorr && nOuterCorr > 1)
165  {
166  loopControl looping(runTime, pimple, "energyCoupling");
167 
168  while (looping.loop())
169  {
170  Info<< nl << looping << nl;
171 
172  forAll(fluidRegions, i)
173  {
174  fvMesh& mesh = fluidRegions[i];
175 
176  #include "readFluidMultiRegionPIMPLEControls.H"
177  #include "setRegionFluidFields.H"
178  frozenFlow = true;
179  #include "solveFluid.H"
180  }
181 
182  forAll(solidRegions, i)
183  {
184  fvMesh& mesh = solidRegions[i];
185 
186  Info<< "\nSolving for solid region "
187  << solidRegions[i].name() << endl;
189  #include "setRegionSolidFields.H"
190  #include "solveSolid.H"
191  }
192 
193  if (coupled)
194  {
195  Info<< "\nSolving energy coupled regions " << endl;
196  fvMatrixAssemblyPtr->solve();
197  #include "correctThermos.H"
198 
199  forAll(fluidRegions, i)
200  {
201  #include "setRegionFluidFields.H"
202  rho = thermo.rho();
203  }
204 
205  fvMatrixAssemblyPtr->clear();
206  }
207  }
208  }
209  }
210 
211  runTime.write();
212 
213  runTime.printExecutionTime(Info);
214  }
215 
216  Info<< "End\n" << endl;
217 
218  return 0;
219 }
220 
221 
222 // ************************************************************************* //
bool frozenFlow
Set the initial timestep for the CHT MultiRegion solver.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:518
PtrList< fvMesh > solidRegions(solidNames.size())
Read the control parameters used by setDeltaT.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:400
psiReactionThermo & thermo
Definition: createFields.H:28
dynamicFvMesh & mesh
const int nOuterCorr
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
pimpleControl & pimple
Info<< "Reading field U\"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);volScalarField rho(IOobject("rho", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), thermo.rho());volVectorField rhoU(IOobject("rhoU", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *U);volScalarField rhoE(IOobject("rhoE", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *(e+0.5 *magSqr(U)));surfaceScalarField pos(IOobject("pos", runTime.timeName(), mesh), mesh, dimensionedScalar("pos", dimless, 1.0));surfaceScalarField neg(IOobject("neg", runTime.timeName(), mesh), mesh, dimensionedScalar("neg", dimless, -1.0));surfaceScalarField phi("phi", fvc::flux(rhoU));Info<< "Creating turbulence model\"<< endl;autoPtr< compressible::turbulenceModel > turbulence(compressible::turbulenceModel::New(rho, U, phi, thermo))
Definition: createFields.H:94
autoPtr< fvMatrix< scalar > > fvMatrixAssemblyPtr
Read the control parameters used in the solid.
messageStream Info
Information stream (stdout output on master, null elsewhere)
PtrList< fvMesh > fluidRegions(fluidNames.size())
bool coupled
Execute application functionObjects to post-process existing results.
Required Classes.
Read the control parameters used by setDeltaT.