Tutorial to set up a case for chtMultiRegionFoam in OpenFOAM 2.0.0 Arpit Singhal University of Luxembourg March 3, 2014 The OpenFOAM-solver chtMultiRegionFoam is meant to be used for heat- transfer between a solid and a fluid originally. As it does work with different regions of different properties, the setup is therefore different from the other OpenFOAM cases. This tutorial is written for setting up a basic case for chtMultiRegionFoam (cMRF) in an Openfoam. tutorial
24
Embed
Tutorial to set up a case for chtMultiRegionFoam in OpenFOAM 2.0.0
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Tutorial to set up a case for
chtMultiRegionFoam in OpenFOAM
2.0.0
Arpit Singhal
University of Luxembourg
March 3, 2014
The OpenFOAM-solver chtMultiRegionFoam is meant to be used for heat-
transfer between a solid and a fluid originally. As it does work with different
regions of different properties, the setup is therefore different from the other
OpenFOAM cases.
This tutorial is written for setting up a basic case for chtMultiRegionFoam
Solid1 to Solid2 Solid1, Solid2 coupling patchAir1 to Solid1 Solid1, Air1 coupling patchAir1 to Solid2 Air1, Solid2 coupling patchAir1 to Air2 Air1, Air2 coupling patch
Air2 to Solid2 Air2, Solid2 coupling patch
3.2.2 Defining the Region by Zones
In the presented case the following regions must be created: Air1, Air2, Solid1 and
Solid2. In order to create these regions the domain is divided into zones. To do so a
subset of cells within the domain is selected to form a so-called cellSet. A cellSet is a
random selection of cells from the domain, whereas a zone is a coherent subset of cells
which finally can be used to define a region. According to the cellSets four zones are
defined which mark the different regions.
In order to define cellSets and cellZones a OpenFOAM commandline utility called setSet
(topoSet in newer versions of OpenFOAM) is used. This tool requires a dictionary-file as
input. Thus, within the case folder a file ending with .setSet must exist, which contains
the settings used to define the different cellSets/cellZones/regions in the domain. The
following command starts the utility with the dictionary file that contains the commands
to be executed.
tutorial
3.3 Splitting the Mesh 7
$ s e t S e t −batch makeCel lSets . s e t S e t
An example of the dictionary file of the presented case is attached for simplicity (Listing
1).
Listing 1: Extract from makeCellSets.setSet
1 c e l l S e t So l i d1 new boxToCell (0 0 0 ) (10 0 .3 1)
c e l lZoneSe t So l i d1 new setToCel lZone So l id1
c e l l S e t So l id2 new boxToCell (10 0 0 ) (20 0 .5 1)
5 c e l lZoneSe t So l id2 new setToCel lZone So l i d2
c e l l S e t Air1 new boxToCell (0 0 .3 0 ) (10 1 1)
c e l lZoneSe t Air1 new setToCel lZone Air1
10 c e l l S e t Air2 new boxToCell (10 0 .5 0 ) (20 1 1)
c e l lZoneSe t Air2 new setToCel lZone Air2
The first two lines used in the .setSet file are briefly explained as:
c e l l S e t So l i d1 new boxToCell (0 0 0) (10 0 .3 1)
This creates a new cellSet from a selection of cells. The new action shows it will
be a new set. The name of the cellSet is Solid1 and the source for the cellSet-function
is the boxToCell function. The numbers in brackets are parameters to the boxToCell-
function: All cells contained within the rectangular box spanning between the points
with coordinates (0 0 0) and (10 0.3 1) are selected for the cellSet Solid1. The line
c e l lZoneSe t So l i d1 new setToCel lZone So l id1
builds a cellZoneSet from an existing cellSet (here using Solid1). Thus, within the
original domain a new zone has been created as depicted in fig.3.3.
This can be repeated in order to define the desired zones representing regions within
the domain.
3.3 Splitting the Mesh
After the user has defined all necessary regions by creating zones for them as described in
the previous section the mesh of the domain has to be split into several disjoint meshes.
Note that the originally created mesh of the full domain will be used within the regions.
tutorial
3.4 Necessary Files and Folders 8
Figure 3.3: Zone created by cellZone from the entire domain
Thus, proper grid resolution for the regional meshes must already be accounted for when
creating the mesh of the full domain.
$ sp l i tMeshRegions −c e l l Z o n e s −ove rwr i t e
The splitted mesh can be checked/visualized in paraview using the command as shown
in the listing3.3 for Air1
$ paraFoam −touch −r eg i on Air1
Then in paraview, *.OpenFoam file should be loaded and can be visualized. The splitted
mesh is shown in fig. 3.4.
3.4 Necessary Files and Folders
A typical OpenFOAM case directory consists of the following three folders:
• 0
• constant
• system
This general case structure is also kept for multiregion cases. The final correct setup of
a multiregion case is shown in fig.3.5. Note that for each region a subdirectory containing
tutorial
3.4 Necessary Files and Folders 9
Figure 3.4: Splitted mesh
the information for the particular region exists. Some of the files are manually created
by the user while others are created by the OpenFOAM utilities. It is explained in the
further sections in detail.
In the following sections details about the individual directories will be given.
3.4.1 Files setup by the user
When starting a new multiregion case the directories and their content highlighted in
fig. 3.6 must be created manually by the user according to the problem definition.
0 directory: First, manually bring in the necessary field files as usual. For a chtMulti-
RegionFoam case it is necessary to have files for:epsilon, k, p, p rgh, T, U, Ychar and Ypmma.
These files are identical to what one would find in any other chtMultiRegionFoam case
/0-directory.
For the solid regions:T, Ychar and Ypmma are necessary, whereas for the fluid regions:epsilon, g, k, p, p rgh, T and U
are the required files.
constant directory: As is any standard OpenFOAM case, the constant folder must
contain a standard polymesh directory, including a standard blockMeshDict-file, which
tutorial
3.4 Necessary Files and Folders 10
Figure 3.5: Final case structure of a multiregion case before running the solver
tutorial
3.4 Necessary Files and Folders 11
Files for all desired fieldshave to be created inside0 directory by the user.
Folders for each region mustbe created by the user. Theyshould contain default files for any fluid and solid.
Defines the geometry and mesh the full domain.
Defines desired regions and their property.
Folders for each region mustbe created by the user. Theyshould contain default filesfor any fluid and solid. Theuser must add and edit thechangeDictionaryDict
Figure 3.6: Case structure as prepared by the user before running scripts
tutorial
3.4 Necessary Files and Folders 12
created by splitMesh:For each region a folderis created inside the0 folder and all originally field files from the 0folder are copied into theregion folders
created by splitMesh:The mesh is splitted intothe different regions andfor every region a separate mesh is defined.
created by changeDict:This file defines all thepatches of a particularregion.
modified by changeDict:boundary, initial andcoupling conditions for allfields are modified accordingto the changeDictionaryDict file of the region
Figure 3.7: Files and directories created by OpenFOAM utilities
tutorial
3.4 Necessary Files and Folders 13
defines the full domain and its mesh.
In contrast to a standard case, the files defining the other properties have to go into the
different regional folders, i.e. transportProperties and thermophysicalProperties
within the folders for fluid regions and solidThermophysicalProperties within the
folders for the solid regions as shown in listing3 and listing4 .
Within the constant-folder it is necessary to produce all the region folders. Addition-
ally within the constant folder it also is necessary to build (or copy from elsewhere) a
file called regionProperties. This file assigns the physical phase to each region: Either
fluid or solid. An example for this file can be seen in the listing 2.
Listing 2: Extract from regionProperties
// ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //
fluidRegionNames ( a i r 1 a i r 2 ) ;
sol idRegionNames ( s o l i d 1 s o l i d 2 ) ;
// ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ //
Inside the solver fluidRegions and solidRegions are treated differently by solving
different governing equations for each phase.
For the fluid regions the default constant files should be included from any chtMulti-
RegionFoam case/constant file. For the fluid regions, the fluid region should contain a
thermophysicalProperties file containing the properties of the fluid in the fluid region.
Like the Air1 thermophysicalProperties file contains:
Listing 3: Extract from Air1 thermophysicalProperties file
mixture
{s p e c i e
{nMoles 1 ;
molWeight 2 8 . 9 ;
}thermodynamics
{
tutorial
3.4 Necessary Files and Folders 14
Cp 1000 ;
Hf 0 ;
}t r anspo r t
{mu 1.8 e−05;
Pr 0 . 7 ;
}}
Similarly for solid regions a solidThermophysicalProperties must exist with the
folder of the region, an example of such a solidThermophysicalProperties is given
for Solid1:
Listing 4: Extract from Solid1 solidThermophysicalProperties file
constSol idThermoCoef f s
{//− thermo p r o p e r t i e s
rho rho [ 1 −3 0 0 0 0 0 ] 8000 ;
Cp Cp [ 0 2 −2 −1 0 0 0 ] 450 ;
K K [ 1 1 −3 −1 0 0 0 ] 80 ;
//− r a d i a t i o n p r o p e r t i e s
kappa kappa [ 0 −1 0 0 0 0 0 ] 0 ;
sigmaS sigmaS [ 0 −1 0 0 0 0 0 ] 0 ;
e m i s s i v i t y e m i s s i v i t y [ 0 0 0 0 0 0 0 ] 0 ;
//− chemica l p r o p e r t i e s
Hf Hf [ 0 2 −2 0 0 0 0 ] 0 ;
}.
.
.
. . . . . .
. .
}
tutorial
3.4 Necessary Files and Folders 15
system directory: In the system directory, once again set up the folders for the regions.
In each region folder there should be a changeDictionaryDict file, which contains
details about the necessary fields in the region like T, U, etc.
Get a working controlDict file, for example from any tutorial into this folder. Af-
terwards get a dummy fvSchemes file. This one is the same as any other fvSchemes,
except for the different functions containing no values between the curly brackets. Fur-
theron one has to get a fvSolution which only defines the outer correctors into this
folder. It is optional to get a decomposeParDict file in case one opts for running parallel
computations. For all of the different regional folders: Get a decomposeParDict file
and get full fvSchemes and fvSolution files into the folders. For the latter ones, keep
in mind that they will be different for the fluids and for the solids.
3.4.2 Files setup by OpenFOAM utilities
Most of the necessary case files and folder (This is highlighted in 3.7 for the different
regions are created by automated generation using scripts and OpenFOAM utilities.
The most important OpenFOAM utilities for a multiregion case are:
splitMesh creates the polyMesh directories and their content within the constant/regionXYZ/
folders;
additionally it creates 0/regionXYZ/ directories for all regions and copies all the
field files existing in the 0 directory into the 0/regionXYZ/ directories
changeDictionary uses changeDictionaryDict files located in system/regionXYZ/ fold-
ers to create initial, boundary and coupling conditions for all fields existing in
0/regionXYZ/ directory for all regions
0 directory: During execution of splitMesh the user created field files are copied to
the region subdirectories. As a next step unnecessary fields are removed for some regions
(see extract given in Listing 5) and only those being part of the governing equations are
kept (for example solids are assumed to be stationary, thus no velocity field is required).
Listing 5: Extract from Allrun script
# remove f l u i d f i e l d s from s o l i d r e g i o n s
f o r i in s o l i d 1 s o l i d 2
do
rm −f 0∗/ $ i /{mut , alphat , ep s i l on , k , p ,U, p rgh}
tutorial
3.4 Necessary Files and Folders 16
done
# remove s o l i d f i e l d s from f l u i d r e g i o n s
f o r i in a i r 1 a i r 2
do
rm −f 0∗/ $ i /{Ychar ,Ypmma}done
Now the initial, boundary and coupling conditions for all fields in every region have to
be specified appropriately. In order to do so the commandline utility changeDictionary
is used. For example for the region Air1 the following line must be executed:
$ changeDict ionary −r eg i on Air1 > l og . changeDict ionary . Air1 2>&1
The utility expects a file called changeDictionaryDict to exist within the folder system/Air/.
Initial and coupling condition of the regions are defined with in changeDictionaryDict.
Boundary conditions for the boundaries on the outside of the complete simulation do-
main and boundary conditions or so-called coupling conditions for any of the coupling
patches between the regions are built using the following scheme: For example for region
Air1 in the changeDictionaryDict file contains the following code for the T field:
T
{i n t e r n a l F i e l d uniform 300 ;
boundaryField
{” .∗”
{type zeroGradient ;
}
” a i r 1 t o .∗”
{type compres s ib l e : : turbulentTemperatureCoupledBaff leMixed ;
neighbourFieldName T;
. . .
}
tutorial
3.4 Necessary Files and Folders 17
}}
In this example the boundary patches are all treated the same (using a wildcard ".*")
and are given the boundary conditions of type zeroGradient. For the coupling patch
there is special kind of boundary condition required (here