chtMultiRegionSimpleFoam.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  chtMultiRegionSimpleFoam
29 
30 Group
31  grpHeatTransferSolvers
32 
33 Description
34  Steady-state solver for buoyant, turbulent fluid flow and solid heat
35  conduction with conjugate heat transfer between solid and fluid regions.
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #include "fvCFD.H"
40 #include "rhoThermo.H"
43 #include "regionProperties.H"
44 #include "solidThermo.H"
45 #include "radiationModel.H"
46 #include "fvOptions.H"
47 #include "coordinateSystem.H"
48 #include "loopControl.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 int main(int argc, char *argv[])
53 {
54  argList::addNote
55  (
56  "Steady-state solver for buoyant, turbulent fluid flow and solid heat"
57  " conduction with conjugate heat transfer"
58  " between solid and fluid regions."
59  );
60 
61  #define NO_CONTROL
62  #define CREATE_MESH createMeshesPostProcess.H
63  #include "postProcess.H"
64 
65  #include "addCheckCaseOptions.H"
66  #include "setRootCaseLists.H"
67  #include "createTime.H"
68  #include "createMeshes.H"
69  #include "createFields.H"
70  #include "createCoupledRegions.H"
71  #include "initContinuityErrs.H"
72 
73  while (runTime.loop())
74  {
75  Info<< "Time = " << runTime.timeName() << nl << endl;
76 
78  {
79  fvMesh& mesh = fluidRegions[i];
80 
81  Info<< "\nSolving for fluid region "
82  << fluidRegions[i].name() << endl;
84  #include "setRegionFluidFields.H"
85  #include "solveFluid.H"
86  }
87 
89  {
90  fvMesh& mesh = solidRegions[i];
91 
93  #include "setRegionSolidFields.H"
94  #include "solveSolid.H"
95  }
96 
97 
98  if (coupled)
99  {
100  Info<< "\nSolving energy coupled regions" << endl;
101  fvMatrixAssemblyPtr->solve();
102  #include "correctThermos.H"
103 
104  forAll(fluidRegions, i)
105  {
106  fvMesh& mesh = fluidRegions[i];
107 
109  #include "setRegionFluidFields.H"
110  if (!frozenFlow)
111  {
112  #include "pEqn.H"
113  turb.correct();
114  }
115  }
116 
117  fvMatrixAssemblyPtr->clear();
118  }
119 
120  // Additional loops for energy solution only
121  {
122  loopControl looping(runTime, "SIMPLE", "energyCoupling");
123 
124  while (looping.loop())
125  {
126  Info<< nl << looping << nl;
127 
128  forAll(fluidRegions, i)
129  {
130  fvMesh& mesh = fluidRegions[i];
131 
132  Info<< "\nSolving for fluid region "
133  << fluidRegions[i].name() << endl;
135  #include "setRegionFluidFields.H"
136  frozenFlow = true;
137  #include "solveFluid.H"
138  }
139 
140  forAll(solidRegions, i)
141  {
142  fvMesh& mesh = solidRegions[i];
143 
144  Info<< "\nSolving for solid region "
145  << solidRegions[i].name() << endl;
147  #include "setRegionSolidFields.H"
148  #include "solveSolid.H"
149  }
150 
151  if (coupled)
152  {
153  Info<< "\nSolving energy coupled regions.. " << endl;
154  fvMatrixAssemblyPtr->solve();
155  #include "correctThermos.H"
156 
157  fvMatrixAssemblyPtr->clear();
158  }
159  }
160  }
161 
162  runTime.write();
163 
164  runTime.printExecutionTime(Info);
165  }
166 
167  Info<< "End\n" << endl;
168 
169  return 0;
170 }
171 
172 
173 // ************************************************************************* //
bool frozenFlow
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false))
compressible::turbulenceModel & turb
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
PtrList< fvMesh > solidRegions(solidNames.size())
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:414
dynamicFvMesh & mesh
autoPtr< fvMatrix< scalar > > fvMatrixAssemblyPtr
messageStream Info
Information stream (stdout output on master, null elsewhere)
PtrList< fvMesh > fluidRegions(fluidNames.size())
Execute application functionObjects to post-process existing results.
Required Classes.