BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
How to chtmultiregionfoam
1. How to set up a basic case for
chtMultiRegionFoam
Bernhard Linseisen
July 21, 2011
Abstract
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 a little different from
the other OF-cases.
This HowTo is written for setting up a very basic case for chtMultiRegion-
Foam (cMRF) in an OF-2 installation. It might work for earlier versions
as well, but it might fail as well.
This HowTo is a first version and it worked on my personal machine for
the particular testcase I set up. If there are any bugs or errors in it, please
drop me an email.
1 The Case built in this Test
The case for this HowTo is a simple step with warm solid parts, which is subected
to an airflow. A visualization (not true to size and relation!) can be seen in 1
For the length 20 units have been chosen, height and depth are 1 unit each.
The main setup files (blockMeshDict and howtocase.setSet) can be seen in the
attachment.
2 Construction of the Case
The main time factor for setting up a case for chtMultiRegionFoam is the basic
construction of the case. The preparation and the running later on are merely
a question of few minutes.
2.1 The Basic Directory Structure
The very basic structure of the case is identical to any other cases within OF.
So at first build a structure like that in a directory for the case at hand (in this
HowTo named ¡case¿ for simplicity):
bernhard.linseisen@cern.ch
1
2. Air1
Solid1
Air2
Solid2
Figure 1: Visualization of the Case
cd case
mkdir 0
mkdir constant
mkdir system
2.2 The .setSet-File
Within the case folder you have to make a file with the ending “.setSet” which
gives the different regions in the process later. The sample file for this case is
attached for simplicity.
The basic idea behind this file is one of different “sets” of cells, faces or points.
The sets constructed with help of the .setSet-file later become the regions for cht-
MultiRegionFoam. One can see this file as a kind of dictionary-file for the setSet-command
within OF. While the different options for this file are described within
setSet.C within the path /applications/utilities/mesh/manipulation/setSet/ of
your OF2-installation, the commands used in this HowTo are briefly explained
with the first two lines of the file 4 as examples: The line
cellSet Solid1 new boxToCell (0 0 0) (10 0.3 1)
does build a “set” from a “cell” with the name “Solid1”. The “new” action shows
it will be a new set. The source for the cellSet-function is the “boxToCell”-
function, which is used in other parts of the code as well. The numbers in
brackets are parameters for the boxToCell-function, here building a cell from a
rectangular box spanning between the points with coordinates (0 0 0) and (10
0.3 1).
The line
cellZoneSet Solid1 new setToCellZone Solid1
does build a “zoneset” from another cellset. The basics are identical to above.
Only the source has changed, being the setToCellZone-function with the input
parameter Solid1, which was established in the line above. So basically the
structure within the .setSet-file is as follows:
2
3. function setName action source
The further available functions and actions can be found within setSet.C .
2.3 Setup of the 0 Directory
Bring in the necessary parameter files as usual. For chtMultiRegionFoam 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 ¡case¿/0-directory. There
is one major exception: The description for “boundaryField” has to look as
follows:
boundaryField
{
.*
{
type calculated;
value uniform standardvalue;
}
}
In Addition, for each of the regions planned there has to be a folder within the
0 directory, so in this case it would be:
cd case/0
mkdir Air1
mkdir Air2
mkdir Solid1
mkdir Solid2
Within each of these directories further files have to be made: For the solid
regions: T, Ychar and Ypmma. For the fluid regions: epsilon, g, k, p, p rgh, T
and U. These files are to be set up like any other standard parameter file. In
addition to the boundaries on the outside of the complete simulation domain it
is necessary to enter additional boundary conditions for any of the boundaries
between the regions. These are built according to following scheme:
{
regionname1_to_regionname2
{
...
}
}
While testing the BC “calculated” did not work for these, “zeroGradient” was
working well at least from the numeric side.
Furtheron each of the “regional” folders has to contain a file called “cellToRe-gion”.
This file is built like any other BC-definition-file, with the type either
being “zeroGradient” or “calculated”, the latter one with “value uniform 0;”.
Possibly other parameters would work as well, but only these have been tested.
In any case every boundary to another cell has to be described, ideally outside
BC is zeroGradient while inside BC is calculated.
3
4. 2.4 Setup of the constant Directory
Within the constant-folder it is necessary again to produce all the regional
folders:
cd case/constant
mkdir Air1
mkdir Air2
mkdir Solid1
mkdir Solid2
Within this folder it also is necessary to build (or copy from elsewhere) a file
called “regionProperties”. This file tells which solvers will have to be applied
to the different regions, either the ones for a fluid or the ones for a solid. An
example for this file can be seen in the Attachment 4.
As is standard for the other cases, also here it is necessary to set up a standard
“polymesh”-directory, including a standard “blockMeshDict”-file.
In contrast to a standard case, the files defining the other Properties have to
go into the different regional folders, i.e. “transportProperties” and “thermo-physicalProperties”
within the folders for fluid regions and “solidThermophysi-calProperties”
within the folders for the solid regions.
2.5 Setup of the system Directory
Fo into the system directory and once again set up the folders for the regions:
cd case/system
mkdir Air1
mkdir ...
Get a working controlDict-file, for example from the tutorials into this folder.
Afterwards get (or produce) 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 for the case one opts for do-ing
parallel computations. For all of the different regional folders: Get a
decomposeParDict-file and get full fvSchemes and fvSolution files into the fold-ers.
For the latter ones, keep in mind that they will be different for the fluids
and for the solids!
3 Final Preparations and Running of the Case
The last part mainly should work without any further problems. For the prepa-ration,
do
cd case
blockMesh
setSet -batch file.setSet
splitMeshRegions -cellZones -overwrite
4
5. Furtheron you have to remove the solid fields from the fluid regions and the
fluid fields from the solid regions. It is advisable to simply use that part of the
“Allrun” script.
Unfortunately, part of the commands before seems to overwrite the data in the
¡case¿/0/¡region¿/* files, so now it is necessary to set these values in the follow-ing
way: Change the values within the newly added boundaries at the region-connections
to something different from 0. Change the type of the boundary
conditions for U, T and p rgh to something different from calculated. After this
is done you can start the simulation like usual with
chtMultiRegionFoam
4 Reminder
If you find any errors, please do inform me! Else: Have fun with chtMultiRe-gionFoam!
5
6. Attachment
howToCase.setSet
cellSet Solid1 new boxToCell (0 0 0) (10 0.3 1)
cellZoneSet Solid1 new setToCellZone Solid1
cellSet Solid2 new boxToCell (10 0 0) (20 0.5 1)
cellZoneSet Solid2 new setToCellZone Solid2
cellSet Air1 new boxToCell (0 0.3 0) (10 1 1)
cellZoneSet Air1 new setToCellZone Air1
cellSet Air2 new boxToCell (10 0.5 0) (20 1 1)
cellZoneSet Air2 new setToCellZone Air2
Figure 2: howToCase.setSet
6