Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
HPCAPPs
OpenFOAM-GPU-v2.0
Commits
ea17556c
Commit
ea17556c
authored
Mar 07, 2024
by
shunbo
Browse files
Initial commit
parents
Changes
798
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1240 additions
and
0 deletions
+1240
-0
applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C
...olvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C
+96
-0
applications/solvers/heatTransfer/buoyantSimpleFoam/createFieldRefs.H
.../solvers/heatTransfer/buoyantSimpleFoam/createFieldRefs.H
+1
-0
applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H
...ons/solvers/heatTransfer/buoyantSimpleFoam/createFields.H
+95
-0
applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H
applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H
+84
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files
...ations/solvers/heatTransfer/chtMultiRegionFoam/Make/files
+5
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options
...ions/solvers/heatTransfer/chtMultiRegionFoam/Make/options
+42
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C
...vers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C
+214
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/files
...er/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/files
+3
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options
.../chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options
+39
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/chtMultiRegionSimpleFoam.C
...nFoam/chtMultiRegionSimpleFoam/chtMultiRegionSimpleFoam.C
+162
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/EEqn.H
.../chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/EEqn.H
+39
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/UEqn.H
.../chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/UEqn.H
+34
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/compressibleContinuityErrors.H
...ultiRegionSimpleFoam/fluid/compressibleContinuityErrors.H
+21
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/compressibleMultiRegionCourantNo.H
...RegionSimpleFoam/fluid/compressibleMultiRegionCourantNo.H
+15
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/createFluidFields.H
...onFoam/chtMultiRegionSimpleFoam/fluid/createFluidFields.H
+234
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/createFluidMeshes.H
...onFoam/chtMultiRegionSimpleFoam/fluid/createFluidMeshes.H
+24
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/initContinuityErrs.H
...nFoam/chtMultiRegionSimpleFoam/fluid/initContinuityErrs.H
+1
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H
.../chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H
+87
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H
...gionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H
+7
-0
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H
...oam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H
+37
-0
No files found.
Too many changes to show.
To preserve performance only
798 of 798+
files are displayed.
Plain diff
Email patch
applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C
0 → 100644
View file @
ea17556c
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
buoyantSimpleFoam
Group
grpHeatTransferSolvers
Description
Steady-state solver for buoyant, turbulent flow of compressible fluids,
including radiation, for ventilation and heat-transfer.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "rhoThermo.H"
#include "turbulentFluidThermoModel.H"
#include "radiationModel.H"
#include "simpleControl.H"
#include "fvOptions.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
addNote
(
"Steady-state solver for buoyant, turbulent fluid flow"
" of compressible fluids, including radiation."
);
#include "postProcess.H"
#include "addCheckCaseOptions.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createMesh.H"
#include "createControl.H"
#include "createFields.H"
#include "createFieldRefs.H"
#include "initContinuityErrs.H"
turbulence
->
validate
();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info
<<
"
\n
Starting time loop
\n
"
<<
endl
;
while
(
simple
.
loop
())
{
Info
<<
"Time = "
<<
runTime
.
timeName
()
<<
nl
<<
endl
;
// Pressure-velocity SIMPLE corrector
{
#include "UEqn.H"
#include "EEqn.H"
#include "pEqn.H"
}
turbulence
->
correct
();
runTime
.
write
();
runTime
.
printExecutionTime
(
Info
);
}
Info
<<
"End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
applications/solvers/heatTransfer/buoyantSimpleFoam/createFieldRefs.H
0 → 100644
View file @
ea17556c
const
volScalarField
&
psi
=
thermo
.
psi
();
applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H
0 → 100644
View file @
ea17556c
Info
<<
"Reading thermophysical properties
\n
"
<<
endl
;
autoPtr
<
rhoThermo
>
pThermo
(
rhoThermo
::
New
(
mesh
));
rhoThermo
&
thermo
=
pThermo
();
thermo
.
validate
(
args
.
executable
(),
"h"
,
"e"
);
volScalarField
rho
(
IOobject
(
"rho"
,
runTime
.
timeName
(),
mesh
,
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
),
thermo
.
rho
()
);
volScalarField
&
p
=
thermo
.
p
();
Info
<<
"Reading field U
\n
"
<<
endl
;
volVectorField
U
(
IOobject
(
"U"
,
runTime
.
timeName
(),
mesh
,
IOobject
::
MUST_READ
,
IOobject
::
AUTO_WRITE
),
mesh
);
#include "compressibleCreatePhi.H"
Info
<<
"Creating turbulence model
\n
"
<<
endl
;
autoPtr
<
compressible
::
turbulenceModel
>
turbulence
(
compressible
::
turbulenceModel
::
New
(
rho
,
U
,
phi
,
thermo
)
);
#include "readGravitationalAcceleration.H"
#include "readhRef.H"
#include "gh.H"
Info
<<
"Reading field p_rgh
\n
"
<<
endl
;
volScalarField
p_rgh
(
IOobject
(
"p_rgh"
,
runTime
.
timeName
(),
mesh
,
IOobject
::
MUST_READ
,
IOobject
::
AUTO_WRITE
),
mesh
);
// Force p_rgh to be consistent with p
p_rgh
=
p
-
rho
*
gh
;
label
pRefCell
=
0
;
scalar
pRefValue
=
0
.
0
;
setRefCell
(
p
,
p_rgh
,
simple
.
dict
(),
pRefCell
,
pRefValue
);
mesh
.
setFluxRequired
(
p_rgh
.
name
());
dimensionedScalar
initialMass
=
fvc
::
domainIntegrate
(
rho
);
dimensionedScalar
totalVolume
=
sum
(
mesh
.
V
());
#include "createMRF.H"
#include "createRadiationModel.H"
const
dimensionedScalar
rhoMax
(
"rhoMax"
,
dimDensity
,
GREAT
,
simple
.
dict
());
const
dimensionedScalar
rhoMin
(
"rhoMin"
,
dimDensity
,
Zero
,
simple
.
dict
());
#include "createFvOptions.H"
applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H
0 → 100644
View file @
ea17556c
{
volScalarField
rAU
(
"rAU"
,
1
.
0
/
UEqn
.
A
());
surfaceScalarField
rhorAUf
(
"rhorAUf"
,
fvc
::
interpolate
(
rho
*
rAU
));
volVectorField
HbyA
(
constrainHbyA
(
rAU
*
UEqn
.
H
(),
U
,
p_rgh
));
tUEqn
.
clear
();
surfaceScalarField
phig
(
-
rhorAUf
*
ghf
*
fvc
::
snGrad
(
rho
)
*
mesh
.
magSf
());
surfaceScalarField
phiHbyA
(
"phiHbyA"
,
fvc
::
flux
(
rho
*
HbyA
)
);
MRF
.
makeRelative
(
fvc
::
interpolate
(
rho
),
phiHbyA
);
bool
closedVolume
=
adjustPhi
(
phiHbyA
,
U
,
p_rgh
);
phiHbyA
+=
phig
;
// Update the pressure BCs to ensure flux consistency
constrainPressure
(
p_rgh
,
rho
,
U
,
phiHbyA
,
rhorAUf
,
MRF
);
dimensionedScalar
compressibility
=
fvc
::
domainIntegrate
(
psi
);
bool
compressible
=
(
compressibility
.
value
()
>
SMALL
);
while
(
simple
.
correctNonOrthogonal
())
{
fvScalarMatrix
p_rghEqn
(
fvm
::
laplacian
(
rhorAUf
,
p_rgh
)
==
fvc
::
div
(
phiHbyA
)
);
p_rghEqn
.
setReference
(
pRefCell
,
getRefCellValue
(
p_rgh
,
pRefCell
));
p_rghEqn
.
solve
();
if
(
simple
.
finalNonOrthogonalIter
())
{
// Calculate the conservative fluxes
phi
=
phiHbyA
-
p_rghEqn
.
flux
();
// Explicitly relax pressure for momentum corrector
p_rgh
.
relax
();
// Correct the momentum source with the pressure gradient flux
// calculated from the relaxed pressure
U
=
HbyA
+
rAU
*
fvc
::
reconstruct
((
phig
-
p_rghEqn
.
flux
())
/
rhorAUf
);
U
.
correctBoundaryConditions
();
fvOptions
.
correct
(
U
);
}
}
p
=
p_rgh
+
rho
*
gh
;
#include "continuityErrs.H"
// For closed-volume cases adjust the pressure level
// to obey overall mass continuity
if
(
closedVolume
)
{
if
(
!
compressible
)
{
p
+=
dimensionedScalar
(
"p"
,
p
.
dimensions
(),
pRefValue
-
getRefCellValue
(
p
,
pRefCell
)
);
}
else
{
p
+=
(
initialMass
-
fvc
::
domainIntegrate
(
psi
*
p
))
/
fvc
::
domainIntegrate
(
psi
);
}
p_rgh
=
p
-
rho
*
gh
;
}
rho
=
thermo
.
rho
();
rho
.
relax
();
Info
<<
"rho min/max : "
<<
min
(
rho
).
value
()
<<
" "
<<
max
(
rho
).
value
()
<<
endl
;
}
applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files
0 → 100644
View file @
ea17556c
fluid/compressibleCourantNo.C
solid/solidRegionDiffNo.C
chtMultiRegionFoam.C
EXE = $(FOAM_APPBIN)/chtMultiRegionFoam
applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options
0 → 100644
View file @
ea17556c
EXE_INC = \
-I./fluid \
-I./solid \
-I./porousFluid \
-I./porousSolid \
-I./include \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \
-I$(LIB_SRC)/ODE/lnInclude \
-I$(LIB_SRC)/combustionModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionFaModels\lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lmeshTools \
-lsampling \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lspecie \
-lreactionThermophysicalModels \
-lsolidThermo \
-lchemistryModel \
-lODE \
-lcombustionModels \
-lturbulenceModels \
-lcompressibleTurbulenceModels \
-lradiationModels \
-lregionModels \
-lregionFaModels
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C
0 → 100644
View file @
ea17556c
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
chtMultiRegionFoam
Group
grpHeatTransferSolvers
Description
Transient solver for buoyant, turbulent fluid flow and solid heat
conduction with conjugate heat transfer between solid and fluid regions.
It handles secondary fluid or solid circuits which can be coupled
thermally with the main fluid region. i.e radiators, etc.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "turbulentFluidThermoModel.H"
#include "rhoReactionThermo.H"
#include "CombustionModel.H"
#include "fixedGradientFvPatchFields.H"
#include "regionProperties.H"
#include "compressibleCourantNo.H"
#include "solidRegionDiffNo.H"
#include "solidThermo.H"
#include "radiationModel.H"
#include "fvOptions.H"
#include "coordinateSystem.H"
#include "loopControl.H"
#include "pressureControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
addNote
(
"Transient solver for buoyant, turbulent fluid flow and solid heat"
" conduction with conjugate heat transfer"
" between solid and fluid regions."
);
#define NO_CONTROL
#define CREATE_MESH createMeshesPostProcess.H
#include "postProcess.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createMeshes.H"
#include "createFields.H"
#include "initContinuityErrs.H"
#include "createTimeControls.H"
#include "readSolidTimeControls.H"
#include "compressibleMultiRegionCourantNo.H"
#include "solidRegionDiffusionNo.H"
#include "setInitialMultiRegionDeltaT.H"
#include "createCoupledRegions.H"
while
(
runTime
.
run
())
{
#include "readTimeControls.H"
#include "readSolidTimeControls.H"
#include "readPIMPLEControls.H"
#include "compressibleMultiRegionCourantNo.H"
#include "solidRegionDiffusionNo.H"
#include "setMultiRegionDeltaT.H"
++
runTime
;
Info
<<
"Time = "
<<
runTime
.
timeName
()
<<
nl
<<
endl
;
if
(
nOuterCorr
!=
1
)
{
forAll
(
fluidRegions
,
i
)
{
#include "storeOldFluidFields.H"
}
}
// --- PIMPLE loop
for
(
int
oCorr
=
0
;
oCorr
<
nOuterCorr
;
++
oCorr
)
{
const
bool
finalIter
=
(
oCorr
==
nOuterCorr
-
1
);
forAll
(
fluidRegions
,
i
)
{
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionPIMPLEControls.H"
#include "solveFluid.H"
}
forAll
(
solidRegions
,
i
)
{
#include "setRegionSolidFields.H"
#include "readSolidMultiRegionPIMPLEControls.H"
#include "solveSolid.H"
}
if
(
coupled
)
{
Info
<<
"
\n
Solving energy coupled regions "
<<
endl
;
fvMatrixAssemblyPtr
->
solve
();
#include "correctThermos.H"
forAll
(
fluidRegions
,
i
)
{
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionPIMPLEControls.H"
if
(
!
frozenFlow
)
{
Info
<<
"
\n
Solving for fluid region "
<<
fluidRegions
[
i
].
name
()
<<
endl
;
// --- PISO loop
for
(
int
corr
=
0
;
corr
<
nCorr
;
corr
++
)
{
#include "pEqn.H"
}
turbulence
.
correct
();
}
rho
=
thermo
.
rho
();
Info
<<
"Min/max T:"
<<
min
(
thermo
.
T
()).
value
()
<<
' '
<<
max
(
thermo
.
T
()).
value
()
<<
endl
;
}
fvMatrixAssemblyPtr
->
clear
();
}
// Additional loops for energy solution only
if
(
!
oCorr
&&
nOuterCorr
>
1
)
{
loopControl
looping
(
runTime
,
pimple
,
"energyCoupling"
);
while
(
looping
.
loop
())
{
Info
<<
nl
<<
looping
<<
nl
;
forAll
(
fluidRegions
,
i
)
{
Info
<<
"
\n
Solving for fluid region "
<<
fluidRegions
[
i
].
name
()
<<
endl
;
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionPIMPLEControls.H"
frozenFlow
=
true
;
#include "solveFluid.H"
}
forAll
(
solidRegions
,
i
)
{
Info
<<
"
\n
Solving for solid region "
<<
solidRegions
[
i
].
name
()
<<
endl
;
#include "setRegionSolidFields.H"
#include "readSolidMultiRegionPIMPLEControls.H"
#include "solveSolid.H"
}
if
(
coupled
)
{
Info
<<
"
\n
Solving energy coupled regions "
<<
endl
;
fvMatrixAssemblyPtr
->
solve
();
#include "correctThermos.H"
forAll
(
fluidRegions
,
i
)
{
#include "setRegionFluidFields.H"
rho
=
thermo
.
rho
();
}
fvMatrixAssemblyPtr
->
clear
();
}
}
}
}
runTime
.
write
();
runTime
.
printExecutionTime
(
Info
);
}
Info
<<
"End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/files
0 → 100644
View file @
ea17556c
chtMultiRegionSimpleFoam.C
EXE = $(FOAM_APPBIN)/chtMultiRegionSimpleFoam
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options
0 → 100644
View file @
ea17556c
EXE_INC = \
-I.. \
-I./fluid \
-I./solid \
-I../solid \
-I./../include \
-I$(LIB_SRC)/finiteVolume/cfdTools \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionFaModels/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lmeshTools \
-lsampling \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lsolidThermo \
-lspecie \
-lturbulenceModels \
-lcompressibleTurbulenceModels \
-lradiationModels \
-lfvOptions \
-lfaOptions \
-lregionModels \
-lsampling \
-lregionFaModels
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/chtMultiRegionSimpleFoam.C
0 → 100644
View file @
ea17556c
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
chtMultiRegionSimpleFoam
Group
grpHeatTransferSolvers
Description
Steady-state solver for buoyant, turbulent fluid flow and solid heat
conduction with conjugate heat transfer between solid and fluid regions.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "rhoThermo.H"
#include "turbulentFluidThermoModel.H"
#include "fixedGradientFvPatchFields.H"
#include "regionProperties.H"
#include "solidThermo.H"
#include "radiationModel.H"
#include "fvOptions.H"
#include "coordinateSystem.H"
#include "loopControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
addNote
(
"Steady-state solver for buoyant, turbulent fluid flow and solid heat"
" conduction with conjugate heat transfer"
" between solid and fluid regions."
);
#define NO_CONTROL
#define CREATE_MESH createMeshesPostProcess.H
#include "postProcess.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createMeshes.H"
#include "createFields.H"
#include "createCoupledRegions.H"
#include "initContinuityErrs.H"
while
(
runTime
.
loop
())
{
Info
<<
"Time = "
<<
runTime
.
timeName
()
<<
nl
<<
endl
;
forAll
(
fluidRegions
,
i
)
{
Info
<<
"
\n
Solving for fluid region "
<<
fluidRegions
[
i
].
name
()
<<
endl
;
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionSIMPLEControls.H"
#include "solveFluid.H"
}
forAll
(
solidRegions
,
i
)
{
#include "setRegionSolidFields.H"
#include "readSolidMultiRegionSIMPLEControls.H"
#include "solveSolid.H"
}
if
(
coupled
)
{
Info
<<
"
\n
Solving energy coupled regions"
<<
endl
;
fvMatrixAssemblyPtr
->
solve
();
#include "correctThermos.H"
forAll
(
fluidRegions
,
i
)
{
#include "setRegionFluidFields.H"
#include "readSolidMultiRegionSIMPLEControls.H"
if
(
!
frozenFlow
)
{
#include "pEqn.H"
turb
.
correct
();
}
}
fvMatrixAssemblyPtr
->
clear
();
}
// Additional loops for energy solution only
{
loopControl
looping
(
runTime
,
"SIMPLE"
,
"energyCoupling"
);
while
(
looping
.
loop
())
{
Info
<<
nl
<<
looping
<<
nl
;
forAll
(
fluidRegions
,
i
)
{
Info
<<
"
\n
Solving for fluid region "
<<
fluidRegions
[
i
].
name
()
<<
endl
;
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionSIMPLEControls.H"
frozenFlow
=
true
;
#include "solveFluid.H"
}
forAll
(
solidRegions
,
i
)
{
Info
<<
"
\n
Solving for solid region "
<<
solidRegions
[
i
].
name
()
<<
endl
;
#include "setRegionSolidFields.H"
#include "readSolidMultiRegionSIMPLEControls.H"
#include "solveSolid.H"
}
if
(
coupled
)
{
Info
<<
"
\n
Solving energy coupled regions.. "
<<
endl
;
fvMatrixAssemblyPtr
->
solve
();
#include "correctThermos.H"
fvMatrixAssemblyPtr
->
clear
();
}
}
}
runTime
.
write
();
runTime
.
printExecutionTime
(
Info
);
}
Info
<<
"End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/EEqn.H
0 → 100644
View file @
ea17556c
{
volScalarField
&
he
=
thermo
.
he
();
fvScalarMatrix
EEqn
(
fvm
::
div
(
phi
,
he
)
+
(
he
.
name
()
==
"e"
?
fvc
::
div
(
phi
,
volScalarField
(
"Ekp"
,
0
.
5
*
magSqr
(
U
)
+
p
/
rho
))
:
fvc
::
div
(
phi
,
volScalarField
(
"K"
,
0
.
5
*
magSqr
(
U
)))
)
-
fvm
::
laplacian
(
turb
.
alphaEff
(),
he
)
==
rho
*
(
U
&
g
)
+
rad
.
Sh
(
thermo
,
he
)
+
fvOptions
(
rho
,
he
)
);
EEqn
.
relax
();
fvOptions
.
constrain
(
EEqn
);
if
(
coupled
)
{
fvMatrixAssemblyPtr
->
addFvMatrix
(
EEqn
);
}
else
{
EEqn
.
solve
();
fvOptions
.
correct
(
he
);
thermo
.
correct
();
rad
.
correct
();
Info
<<
"Min/max T:"
<<
min
(
thermo
.
T
()).
value
()
<<
' '
<<
max
(
thermo
.
T
()).
value
()
<<
endl
;
}
}
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/UEqn.H
0 → 100644
View file @
ea17556c
// Solve the Momentum equation
MRF
.
correctBoundaryVelocity
(
U
);
UEqn
=
(
fvm
::
div
(
phi
,
U
)
+
MRF
.
DDt
(
rho
,
U
)
+
turb
.
divDevRhoReff
(
U
)
==
fvOptions
(
rho
,
U
)
);
UEqn
.
relax
();
fvOptions
.
constrain
(
UEqn
);
if
(
momentumPredictor
)
{
solve
(
UEqn
==
fvc
::
reconstruct
(
(
-
ghf
*
fvc
::
snGrad
(
rho
)
-
fvc
::
snGrad
(
p_rgh
)
)
*
mesh
.
magSf
()
)
);
fvOptions
.
correct
(
U
);
}
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/compressibleContinuityErrors.H
0 → 100644
View file @
ea17556c
{
dimensionedScalar
totalMass
=
fvc
::
domainIntegrate
(
rho
);
scalar
sumLocalContErr
=
(
fvc
::
domainIntegrate
(
mag
(
rho
-
thermo
.
rho
()))
/
totalMass
).
value
();
scalar
globalContErr
=
(
fvc
::
domainIntegrate
(
rho
-
thermo
.
rho
())
/
totalMass
).
value
();
cumulativeContErr
[
i
]
+=
globalContErr
;
Info
<<
"time step continuity errors ("
<<
mesh
.
name
()
<<
")"
<<
": sum local = "
<<
sumLocalContErr
<<
", global = "
<<
globalContErr
<<
", cumulative = "
<<
cumulativeContErr
[
i
]
<<
endl
;
}
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/compressibleMultiRegionCourantNo.H
0 → 100644
View file @
ea17556c
scalar
CoNum
=
-
GREAT
;
forAll
(
fluidRegions
,
regionI
)
{
CoNum
=
max
(
compressibleCourantNo
(
fluidRegions
[
regionI
],
runTime
,
rhoFluid
[
regionI
],
phiFluid
[
regionI
]
),
CoNum
);
}
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/createFluidFields.H
0 → 100644
View file @
ea17556c
// Initialise fluid field pointer lists
PtrList
<
rhoThermo
>
thermoFluid
(
fluidRegions
.
size
());
PtrList
<
volScalarField
>
rhoFluid
(
fluidRegions
.
size
());
PtrList
<
volVectorField
>
UFluid
(
fluidRegions
.
size
());
PtrList
<
surfaceScalarField
>
phiFluid
(
fluidRegions
.
size
());
PtrList
<
uniformDimensionedScalarField
>
hRefFluid
(
fluidRegions
.
size
());
PtrList
<
volScalarField
>
ghFluid
(
fluidRegions
.
size
());
PtrList
<
surfaceScalarField
>
ghfFluid
(
fluidRegions
.
size
());
PtrList
<
compressible
::
turbulenceModel
>
turbulence
(
fluidRegions
.
size
());
PtrList
<
volScalarField
>
p_rghFluid
(
fluidRegions
.
size
());
PtrList
<
radiation
::
radiationModel
>
radiation
(
fluidRegions
.
size
());
List
<
scalar
>
initialMassFluid
(
fluidRegions
.
size
());
List
<
label
>
pRefCellFluid
(
fluidRegions
.
size
(),
-
1
);
List
<
scalar
>
pRefValueFluid
(
fluidRegions
.
size
(),
Zero
);
List
<
bool
>
frozenFlowFluid
(
fluidRegions
.
size
(),
false
);
PtrList
<
dimensionedScalar
>
rhoMax
(
fluidRegions
.
size
());
PtrList
<
dimensionedScalar
>
rhoMin
(
fluidRegions
.
size
());
PtrList
<
IOMRFZoneList
>
MRFfluid
(
fluidRegions
.
size
());
PtrList
<
fv
::
options
>
fluidFvOptions
(
fluidRegions
.
size
());
PtrList
<
fvVectorMatrix
>
UEqFluid
(
fluidRegions
.
size
());
const
uniformDimensionedVectorField
&
g
=
meshObjects
::
gravity
::
New
(
runTime
);
// Populate fluid field pointer lists
forAll
(
fluidRegions
,
i
)
{
Info
<<
"*** Reading fluid mesh thermophysical properties for region "
<<
fluidRegions
[
i
].
name
()
<<
nl
<<
endl
;
Info
<<
" Adding to thermoFluid
\n
"
<<
endl
;
thermoFluid
.
set
(
i
,
rhoThermo
::
New
(
fluidRegions
[
i
]).
ptr
()
);
Info
<<
" Adding to rhoFluid
\n
"
<<
endl
;
rhoFluid
.
set
(
i
,
new
volScalarField
(
IOobject
(
"rho"
,
runTime
.
timeName
(),
fluidRegions
[
i
],
IOobject
::
NO_READ
,
IOobject
::
AUTO_WRITE
),
thermoFluid
[
i
].
rho
()
)
);
Info
<<
" Adding to UFluid
\n
"
<<
endl
;
UFluid
.
set
(
i
,
new
volVectorField
(
IOobject
(
"U"
,
runTime
.
timeName
(),
fluidRegions
[
i
],
IOobject
::
MUST_READ
,
IOobject
::
AUTO_WRITE
),
fluidRegions
[
i
]
)
);
Info
<<
" Adding to phiFluid
\n
"
<<
endl
;
phiFluid
.
set
(
i
,
new
surfaceScalarField
(
IOobject
(
"phi"
,
runTime
.
timeName
(),
fluidRegions
[
i
],
IOobject
::
READ_IF_PRESENT
,
IOobject
::
AUTO_WRITE
),
linearInterpolate
(
rhoFluid
[
i
]
*
UFluid
[
i
])
&
fluidRegions
[
i
].
Sf
()
)
);
Info
<<
" Adding to hRefFluid
\n
"
<<
endl
;
hRefFluid
.
set
(
i
,
new
uniformDimensionedScalarField
(
IOobject
(
"hRef"
,
runTime
.
constant
(),
fluidRegions
[
i
],
IOobject
::
READ_IF_PRESENT
,
IOobject
::
NO_WRITE
),
dimensionedScalar
(
"hRef"
,
dimLength
,
Zero
)
// uses name
)
);
dimensionedScalar
ghRef
(
mag
(
g
.
value
())
>
SMALL
?
g
&
(
cmptMag
(
g
.
value
())
/
mag
(
g
.
value
()))
*
hRefFluid
[
i
]
:
dimensionedScalar
(
"ghRef"
,
g
.
dimensions
()
*
dimLength
,
0
)
);
Info
<<
" Adding to ghFluid
\n
"
<<
endl
;
ghFluid
.
set
(
i
,
new
volScalarField
(
"gh"
,
(
g
&
fluidRegions
[
i
].
C
())
-
ghRef
)
);
Info
<<
" Adding to ghfFluid
\n
"
<<
endl
;
ghfFluid
.
set
(
i
,
new
surfaceScalarField
(
"ghf"
,
(
g
&
fluidRegions
[
i
].
Cf
())
-
ghRef
)
);
Info
<<
" Adding to turbulence
\n
"
<<
endl
;
turbulence
.
set
(
i
,
compressible
::
turbulenceModel
::
New
(
rhoFluid
[
i
],
UFluid
[
i
],
phiFluid
[
i
],
thermoFluid
[
i
]
).
ptr
()
);
p_rghFluid
.
set
(
i
,
new
volScalarField
(
IOobject
(
"p_rgh"
,
runTime
.
timeName
(),
fluidRegions
[
i
],
IOobject
::
MUST_READ
,
IOobject
::
AUTO_WRITE
),
fluidRegions
[
i
]
)
);
// Force p_rgh to be consistent with p
p_rghFluid
[
i
]
=
thermoFluid
[
i
].
p
()
-
rhoFluid
[
i
]
*
ghFluid
[
i
];
fluidRegions
[
i
].
setFluxRequired
(
p_rghFluid
[
i
].
name
());
radiation
.
set
(
i
,
radiation
::
radiationModel
::
New
(
thermoFluid
[
i
].
T
())
);
initialMassFluid
[
i
]
=
fvc
::
domainIntegrate
(
rhoFluid
[
i
]).
value
();
const
dictionary
&
simpleDict
=
fluidRegions
[
i
].
solutionDict
().
subDict
(
"SIMPLE"
);
setRefCell
(
thermoFluid
[
i
].
p
(),
p_rghFluid
[
i
],
simpleDict
,
pRefCellFluid
[
i
],
pRefValueFluid
[
i
]
);
simpleDict
.
readIfPresent
(
"frozenFlow"
,
frozenFlowFluid
[
i
]);
rhoMax
.
set
(
i
,
new
dimensionedScalar
(
"rhoMax"
,
dimDensity
,
GREAT
,
simpleDict
)
);
rhoMin
.
set
(
i
,
new
dimensionedScalar
(
"rhoMin"
,
dimDensity
,
Zero
,
simpleDict
)
);
Info
<<
" Adding MRF
\n
"
<<
endl
;
MRFfluid
.
set
(
i
,
new
IOMRFZoneList
(
fluidRegions
[
i
])
);
Info
<<
" Adding fvOptions
\n
"
<<
endl
;
fluidFvOptions
.
set
(
i
,
new
fv
::
options
(
fluidRegions
[
i
])
);
UEqFluid
.
set
(
i
,
new
fvVectorMatrix
(
UFluid
[
i
],
dimForce
)
);
turbulence
[
i
].
validate
();
}
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/createFluidMeshes.H
0 → 100644
View file @
ea17556c
const
wordList
fluidNames
(
rp
[
"fluid"
]);
PtrList
<
fvMesh
>
fluidRegions
(
fluidNames
.
size
());
forAll
(
fluidNames
,
i
)
{
Info
<<
"Create fluid mesh for region "
<<
fluidNames
[
i
]
<<
" for time = "
<<
runTime
.
timeName
()
<<
nl
<<
endl
;
fluidRegions
.
set
(
i
,
new
fvMesh
(
IOobject
(
fluidNames
[
i
],
runTime
.
timeName
(),
runTime
,
IOobject
::
MUST_READ
)
)
);
}
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/initContinuityErrs.H
0 → 100644
View file @
ea17556c
scalar
cumulativeContErr
=
0
;
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H
0 → 100644
View file @
ea17556c
{
volScalarField
rAU
(
"rAU"
,
1
.
0
/
UEqn
.
A
());
surfaceScalarField
rhorAUf
(
"rhorAUf"
,
fvc
::
interpolate
(
rho
*
rAU
));
volVectorField
HbyA
(
constrainHbyA
(
rAU
*
UEqn
.
H
(),
U
,
p_rgh
));
//tUEqn.clear();
surfaceScalarField
phig
(
-
rhorAUf
*
ghf
*
fvc
::
snGrad
(
rho
)
*
mesh
.
magSf
());
surfaceScalarField
phiHbyA
(
"phiHbyA"
,
fvc
::
flux
(
rho
*
HbyA
)
);
MRF
.
makeRelative
(
fvc
::
interpolate
(
rho
),
phiHbyA
);
bool
closedVolume
=
adjustPhi
(
phiHbyA
,
U
,
p_rgh
);
phiHbyA
+=
phig
;
// Update the pressure BCs to ensure flux consistency
constrainPressure
(
p_rgh
,
rho
,
U
,
phiHbyA
,
rhorAUf
,
MRF
);
dimensionedScalar
compressibility
=
fvc
::
domainIntegrate
(
psi
);
bool
compressible
=
(
compressibility
.
value
()
>
SMALL
);
// Solve pressure
for
(
int
nonOrth
=
0
;
nonOrth
<=
nNonOrthCorr
;
nonOrth
++
)
{
fvScalarMatrix
p_rghEqn
(
fvm
::
laplacian
(
rhorAUf
,
p_rgh
)
==
fvc
::
div
(
phiHbyA
)
);
p_rghEqn
.
setReference
(
pRefCell
,
getRefCellValue
(
p_rgh
,
pRefCell
));
p_rghEqn
.
solve
();
if
(
nonOrth
==
nNonOrthCorr
)
{
// Calculate the conservative fluxes
phi
=
phiHbyA
-
p_rghEqn
.
flux
();
// Explicitly relax pressure for momentum corrector
p_rgh
.
relax
();
// Correct the momentum source with the pressure gradient flux
// calculated from the relaxed pressure
U
=
HbyA
+
rAU
*
fvc
::
reconstruct
((
phig
-
p_rghEqn
.
flux
())
/
rhorAUf
);
U
.
correctBoundaryConditions
();
fvOptions
.
correct
(
U
);
}
}
p
=
p_rgh
+
rho
*
gh
;
#include "continuityErrs.H"
// For closed-volume cases adjust the pressure level
// to obey overall mass continuity
if
(
closedVolume
)
{
if
(
!
compressible
)
{
p
+=
dimensionedScalar
(
"p"
,
p
.
dimensions
(),
pRefValue
-
getRefCellValue
(
p
,
pRefCell
)
);
}
else
{
p
+=
(
initialMass
-
fvc
::
domainIntegrate
(
psi
*
p
))
/
compressibility
;
}
p_rgh
=
p
-
rho
*
gh
;
}
rho
=
thermo
.
rho
();
rho
=
max
(
rho
,
rhoMin
[
i
]);
rho
=
min
(
rho
,
rhoMax
[
i
]);
rho
.
relax
();
Info
<<
"Min/max rho:"
<<
min
(
rho
).
value
()
<<
' '
<<
max
(
rho
).
value
()
<<
endl
;
}
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H
0 → 100644
View file @
ea17556c
const
dictionary
&
simple
=
fluidRegions
[
i
].
solutionDict
().
subDict
(
"SIMPLE"
);
const
int
nNonOrthCorr
=
simple
.
getOrDefault
<
int
>
(
"nNonOrthogonalCorrectors"
,
0
);
const
bool
momentumPredictor
=
simple
.
getOrDefault
(
"momentumPredictor"
,
true
);
applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H
0 → 100644
View file @
ea17556c
const
fvMesh
&
mesh
=
fluidRegions
[
i
];
rhoThermo
&
thermo
=
thermoFluid
[
i
];
thermo
.
validate
(
args
.
executable
(),
"h"
,
"e"
);
volScalarField
&
rho
=
rhoFluid
[
i
];
volVectorField
&
U
=
UFluid
[
i
];
surfaceScalarField
&
phi
=
phiFluid
[
i
];
compressible
::
turbulenceModel
&
turb
=
turbulence
[
i
];
volScalarField
&
p
=
thermo
.
p
();
const
volScalarField
&
psi
=
thermo
.
psi
();
volScalarField
&
p_rgh
=
p_rghFluid
[
i
];
const
volScalarField
&
gh
=
ghFluid
[
i
];
const
surfaceScalarField
&
ghf
=
ghfFluid
[
i
];
radiation
::
radiationModel
&
rad
=
radiation
[
i
];
IOMRFZoneList
&
MRF
=
MRFfluid
[
i
];
fv
::
options
&
fvOptions
=
fluidFvOptions
[
i
];
fvVectorMatrix
&
UEqn
=
UEqFluid
[
i
];
const
dimensionedScalar
initialMass
(
"initialMass"
,
dimMass
,
initialMassFluid
[
i
]
);
bool
frozenFlow
=
frozenFlowFluid
[
i
];
const
label
pRefCell
=
pRefCellFluid
[
i
];
const
scalar
pRefValue
=
pRefValueFluid
[
i
];
Prev
1
…
16
17
18
19
20
21
22
23
24
…
40
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment