Professional Documents
Culture Documents
chtMultiRegionFoam in OpenFOAM
2.0.0
Arpit Singhal
University of Luxembourg
March 3, 2014
The OpenFOAM-solver chtMultiRegionFoam is meant to be used for heattransfer 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
Contents
Contents
1 Introduction
2 Basic Workflow
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
4
4
5
5
6
7
8
9
15
18
5 Using scripting
18
6 Appendice
21
tutorial
1 Introduction
1 Introduction
What is meant by multiregion multi physics modeling? It is inherently-coupled physics
on disparate continua (e.g. fluid, solid, different solids). In multiregion multi physics
separate governing equations for each continuum/region are solved, as shown in 1.1
seperate governing equations will be solved for Region 1 and Region 2 depending upon
their phase and represents a region interface. A region can be defined as coherent
continum of the same phase.
tutorial
2 Basic Workflow
2 Basic Workflow
The basic work flow for a case setup is explained in fig. 2.1.
Run case
tutorial
Air2_to_Air1
maxY
minX
maxX
Air1_to_Solid1
Air1_to_Solid2
minY
y
Solid1_to_Solid2
tutorial
Air2_to_Solid2
3.2
Type
Air1
Solid1
Air2
Solid2
fluid
solid
fluid
solid
Every region has several patches for which boundary or coupling conditions have to
be specified. Thus, a patch can be of the following two types:
boundary patch
tutorial
3.2
coupling patch
A boundary patch is a regular type patch for which the user may define any possible
boundary condition available in OpenFOAM. Coupling patches are those patches where
the solutions of the different regions are coupled. A coupling patch belongs to a socalled coupled patch pair. Such a pair consists of coinciding patches, one associated with
each region. Table 3.2 lists all patches, the region they belong to and their type for the
presented case.
Table 3.2: Table of patches
Patch
minX
maxX
minY
maxY
minZ
maxZ
Solid1 to Solid2
Air1 to Solid1
Air1 to Solid2
Air1 to Air2
Air2 to Solid2
Regions
Type
Air1, Solid1
boundary patch
Air2, Solid2
boundary patch
Solid1, Solid2
boundary patch
Air1, Air2
boundary patch
Air1, Air2, Solid1, Solid2 boundary patch
Air1, Air2, Solid1, Solid2 boundary patch
Solid1, Solid2
coupling patch
Solid1, Air1
coupling patch
Air1, Solid2
coupling patch
Air1, Air2
coupling patch
Air2, Solid2
coupling patch
tutorial
3.3
$ s e t S e t batch m a k e C e l l S e t s . 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 S o l i d 1 new boxToCell ( 0 0 0 ) ( 1 0 0 . 3 1 )
c e l l Z o n e S e t S o l i d 1 new s e t T o C e l l Z o n e S o l i d 1
c e l l S e t S o l i d 2 new boxToCell ( 10 0 0 ) ( 2 0 0 . 5 1 )
5 c e l l Z o n e S e t S o l i d 2 new s e t T o C e l l Z o n e S o l i d 2
c e l l S e t Air1 new boxToCell ( 0 0 . 3 0 ) ( 1 0 1 1 )
c e l l Z o n e S e t Air1 new s e t T o C e l l Z o n e Air1
10
S o l i d 1 new boxToCell ( 0 0 0 ) ( 1 0 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 boxToCellfunction: 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 l Z o n e S e t S o l i d 1 new s e t T o C e l l Z o n e S o l i d 1
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.
tutorial
3.4
Then in paraview, *.OpenFoam file should be loaded and can be visualized. The splitted
mesh is shown in fig. 3.4.
tutorial
3.4
tutorial
3.4
Figure 3.5: Final case structure of a multiregion case before running the solver
tutorial
10
3.4
11
Figure 3.6: Case structure as prepared by the user before running scripts
tutorial
3.4
12
created by splitMesh:
For each region a folder
is created inside the
0 folder and all originally
eld les from the 0
folder are copied into the
region folders
modied by changeDict:
boundary, initial and
coupling conditions for all
elds are modied according
to the changeDictionaryDict
le of the region
created by changeDict:
This le denes all the
patches of a particular
region.
created by splitMesh:
3.4
13
//
fluidRegionNames ( a i r 1 a i r 2 ) ;
solidRegionNames ( 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 chtMultiRegionFoam 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
{
specie
{
nMoles
molWeight
}
thermodynamics
{
tutorial
1;
28.9;
3.4
14
1000;
0;
1 . 8 e 05;
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
constSolidThermoCoeffs
{
// thermo p r o p e r t i e s
rho rho [ 1 3 0 0 0 0 0 ] 8 0 0 0 ;
Cp Cp [ 0 2 2 1 0 0 0 ] 4 5 0 ;
K
K
[ 1 1 3 1 0 0 0 ] 8 0 ;
// 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;
emissivity emissivity [0 0 0 0 0 0 0] 0;
// c h e m i c a l p r o p e r t i e s
Hf Hf [ 0 2 2 0 0 0 0 ] 0 ;
}
.
.
.
......
..
}
tutorial
3.4
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. Afterwards 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. Furtheron 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/ folders 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
for i in solid1 solid2
do
rm f 0/ $ i /{mut , a l ph a t , e p s i l o n , k , p , U, p r g h }
tutorial
3.4
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
for i in air1 air2
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:
$ c h a n g e D i c t i o n a r y r e g i o n Air1 > l o g . c h a n g e D i c t i o n a r y . 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 domain 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
{
internalField
boundaryField
{
.
{
type
}
uniform 3 0 0 ;
zeroGradient ;
a i r 1 t o .
{
type c o m p r e s s i b l e : : t u r b u l e n t T e m p e r a t u r e C o u p l e d B a f f l e M i x e d ;
neighbourFieldName T;
...
}
tutorial
3.4
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
compressible::turbulentTemperatureCoupledBaffleMixed).
The keyword neighbourFieldName indicates that the T field of air1 is coupled to the
T field of the other regions.
Similarly for all other regions, the initial, boundary and coupling conditions must be
taken care of.
In each of the region folders a file called cellToRegion is created during execution of
the changeDictionaryDict command. The content of these files are like any other
field file but not associated to a specific field. The BC type is either zeroGradient or
calculated. Possibly other parameters would work as well, but only these have been
tested. In any case every coupling patches to other regions have to be defined of type
calculated whereas boundary patches (to outside of domain) are of type zeroGradient.
for Air1 the entry used is shown by listing 6
Listing 6: Extract from cellToRegion
boundaryField
{
maxY
{
type
}
minX
{
type
}
minZ
{
type
}
maxZ
tutorial
zeroGradient ;
zeroGradient ;
zeroGradient ;
18
{
type
}
air1 to air2
{
type
value
}
air1 to solid2
{
type
value
}
air1 to solid1
{
type
value
}
zeroGradient ;
calculated ;
uniform 0 ;
calculated ;
uniform 0 ;
calculated ;
uniform 0 ;
constant directory: In the constant folder, the splitMesh utility creates a seperate
mesh for each region. This can be seen in the fig. 3.7
5 Using scripting
An Allrun can be explained as a script file which contains all the commands used to
execute the case, for example in this case the Allrun used can be seen as in Listing
tutorial
5 Using scripting
19
shown in 5.1. So just executing the Allrun will now run the case, instead of typing each
command seperately in the terminal.
tutorial
5 Using scripting
20
6 Appendice
21
6 Appendice
Listing 7: Extract from Allrun
#!/ b i n / sh
cd ${0%/} | | e x i t 1
# run from t h i s d i r e c t o r y
RUNPAR=YES ;
# So urc e t u t o r i a l run f u n c t i o n s
. $WM PROJECT DIR/ b i n / t o o l s / RunFunctions
# (B) C r e a t i n g th e r e g i o n s i n two s t e p s :
#
1) d e f i n i n g c e l l S e t s
#
2 ) c r e a t i n g c e l l Z o n e s which d e f i n e th e r e g i o n s
r u n A p p l i c a t i o n s e t S e t batch m a k e C e l l S e t s . s e t S e t
# (C) S p l i t t i n g th e mesh a c c o r d i n g t o th e d e f i n e d r e g i o n s
r u n A p p l i c a t i o n s p l i t M e s h R e g i o n s c e l l Z o n e s o v e r w r i t e
exit
# (D) Remove u n n e c e s s a r y f i e l d f i l e s from r e g i o n s
#
# (D. 1 ) 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
for i in solid1 solid2
do
rm f 0/ $ i /{mut , a l ph a t , e p s i l o n , k , p , U, p r g h }
done
tutorial
6 Appendice
# (D. 2 ) 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
for i in air1 air2
do
rm f 0/ $ i /{ Ychar ,Ypmma}
done
# (F) RUN c a s e
# c h o o s e between PARALLEL o r SEQUENTIAL RUN
i f [ $RUNPAR = YES ] ;
then
echo Running i n p a r a l l e l mode ;
# Decompose
for i in air1 air2 solid1 solid2
do
decomposePar r e g i o n $ i > l o g . decomposePar . $ i 2>&1
done
# Run
mpirun . openmpi np 4 chtMultiRegionFoam p a r a l l e l > l o g
# Reconstruct
for i in air1 air2 solid1 solid2
tutorial
22
6 Appendice
do
r e c o n s t r u c t P a r r e g i o n $ i > l o g . r e c o n s t r u c t P a r . $ i 2 >&1
done
else
echo Running i n s e q u e n t i a l mode ;
# Run on s i n g l e p r o c e s s o r
chtMultiRegionFoam > l o g
fi
echo
echo c r e a t i n g f i l e s f o r paraview postp r o c e s s i n g
echo
for i in solid1 solid2 air1 air2
do
paraFoam touch r e g i o n $ i
done
# endof f i l e
tutorial
23