OpenFOAM postprocessing and advanced running options
OpenFOAM postprocessing and advanced running options
OpenFOAM postprocessing and advanced running options
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
POLITECNICO DI MILANO CHALMERS<br />
<strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong><br />
<strong>running</strong> <strong>options</strong><br />
Gianluca Montenegro<br />
Department of Energy<br />
Politecnico di Milano<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
The post processing tool: paraFoam<br />
The main post-processing tool provided with <strong>OpenFOAM</strong> is the reader module to run<br />
with ParaView, an open-source, visualization application<br />
The module is compiled into 2 libraries, PVFoamReader <strong>and</strong> vtkFoam, using version<br />
2.4.4 of ParaView supplied with the <strong>OpenFOAM</strong> release<br />
ParaView uses the Visualization Toolkit (VTK) as its data processing <strong>and</strong> rendering<br />
engine <strong>and</strong> can therefore read any data in VTK format<br />
<strong>OpenFOAM</strong> includes the foamToVTK utility to convert data from its native format to<br />
VTK format, which means that any VTK-based graphics tools can be used to<br />
post-process <strong>OpenFOAM</strong> cases. This provides an alternative means for using<br />
ParaView with <strong>OpenFOAM</strong><br />
paraFoam is strictly a script that launches ParaView using the reader module supplied<br />
with <strong>OpenFOAM</strong><br />
It is executed like any of the <strong>OpenFOAM</strong> utilities with the root directory path <strong>and</strong> the<br />
case directory name as arguments:<br />
paraFoam <br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Before starting<br />
Before starting with the user should copy two tutorials in his own run folder:<br />
cp -r $FOAM_TUTORIALS/simpleFoam/pitzDaily/ $FOAM_RUN/<br />
cp -r $FOAM_TUTORIALS/dieselFoam/aachenBomb $FOAM_RUN/<br />
SimpleFoam is an incompressible steady-state flow solver, while dieselFoam is<br />
dedicated to combustion process with spray injection<br />
The two cases should also be executed<br />
run<br />
blockMesh . pitzDaily<br />
simpleFoam . pitzDaily<br />
blockMesh . aachenBomb<br />
dieselFoam . aachenBomb<br />
The user should care about reducing the endTime <strong>and</strong> the writeInterval to have<br />
immediately some calculations to post process for the pitzDaily case<br />
For the aachenBomb case the user should switch off the chemistry to reduce the<br />
computational time<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing the mesh<br />
The mesh can be viewed only in paraFoam since there is no pre-processing tool to<br />
view the mesh<br />
We shall start with the pitzDaily case of the simpleFoam tutorial:<br />
paraFoam $FOAM RUN/ pitzDaily<br />
Click the Accept button which will bring up an image of the case geometry in the image<br />
display window.<br />
In the parameters panel it is possible to choose what you can visualize:<br />
the time step<br />
the region<br />
the vol field<br />
the point field if exists<br />
To visualize the mesh make sure that all the regions are toggled on<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
The post processing tool: paraFoam<br />
When paraView is launched the case is controlled from the left panel, which contains<br />
the following:<br />
Selection Window lists the modules opened in ParaView, where the selected<br />
modules are highlighted in yellow <strong>and</strong> the graphics for the given module can be<br />
enabled/disabled by clicking the eye button alongside<br />
Parameters panel contains the input selections for the case, such as times,<br />
regions <strong>and</strong> fields<br />
Display panel controls the visual representation of the selected module, e.g.<br />
colors<br />
Information panel gives case statistics such as mesh geometry <strong>and</strong> size<br />
ParaView operates a tree-based structure in which data can be filtered from the toplevel<br />
case module to create sets of sub-modules<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing the mesh<br />
Select property <strong>and</strong> wireframe of surface to visualize the mesh. Play wit the<br />
actor color menu to select the color you prefer<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing the mesh<br />
To improve the quality of the mesh Visualization it is possible to overlap the surface of<br />
your mesh<br />
Select the extract parts from the filter menu <strong>and</strong> then select surface<br />
visualization of the mesh. Play with the color option to create the desired contrast<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing fields: display panel<br />
The Display panel contains the settings for visualizing the data/fields for a given case<br />
module. The following points are particularly important:<br />
the data range is not automatically updated to the max/min limits of a field, so the<br />
user should take care to select Edit Color Map <strong>and</strong> Reset range at appropriate<br />
intervals, in particular after loading the initial case module<br />
the style of legend, e.g. font, for the color bar is controlled by in the Scalar Bar<br />
panel of the Edit Color Map window<br />
the underlying mesh can be represented by selecting Wireframe in the<br />
Representation menu<br />
the geometry, e.g. a mesh (if Wireframe is selected), can be visualized as a single<br />
color by selecting Property from the Color by menu <strong>and</strong> specifying the Actor color<br />
the image can be made translucent by editing the value in Opacity (1 = solid, 0 =<br />
invisible)<br />
the activated field can be translated, scaled, rotated with respect the other ones<br />
In the color windows it is possible to select the field that the user wants to plot<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing fields: vectorFields (U)<br />
Selecting the velocity field from the color window in the display panel, two <strong>options</strong> are<br />
available:<br />
point volPointInterpolate, the velocity field is defined on the grid vertex <strong>and</strong><br />
interpolated from the cell centers<br />
cell U the velocity field is displayed in the cell center<br />
It is possible to visualize only the magnitude of velocity, without any information about<br />
the direction of the velocity vector:<br />
magU . pitzDaily<br />
Time = 50<br />
Reading U<br />
Calculating magU<br />
mag(U): max: 10.619 min: 0.12244<br />
Then select the magU filed in the color window<br />
If you run the magU utility after having launched paraFoam you will need to change the<br />
time step or to update the GUI to visualize the new field<br />
Alternatively the user may use the calculator filter. Keep in mind that it works only for<br />
the selected time step<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing fields: vectorFields (U)<br />
To visualize the velocity filed as a field of vectors you must act on filters once again:<br />
The user must first create a filter to select the quantities in the cell centers<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing fields: vectorFields (U)<br />
Starting from the cell center filtered field, the user must select the Glyphs filter <strong>and</strong><br />
then accept<br />
The vector field will be displayed in the window on the right<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing fields: glyphs (U)<br />
The filter reads an Input <strong>and</strong> offers a range of Glyphs for which the Arrow0 provides a<br />
clear vector plot images<br />
In the Orient/Scale window, the most common <strong>options</strong> for Scale Mode are: Vector<br />
Magnitude, where the glyph length is proportional to the vector magnitude, whereas<br />
selecting Data Scaling Off each glyph is the same length<br />
An additional Scale Factor parameter controls the base length of the glyphs<br />
It is possible to select the maximum number of Glyphs to be displayed. Putting a<br />
number lower than the cell number can speed up the visualization<br />
Other option rather than arrows are available: cones, cubes, lines, spheres <strong>and</strong><br />
arrow2d<br />
It is possible to select the glyphs filter directly from the ParaView toolbar:<br />
Glyphs button<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing fields: contour plots<br />
A contour plot is created by selecting Contour from the Filter menu at the top menu bar<br />
Iso−surface button<br />
The filter acts on a given module so that, if the module is the 3D case module itself, the<br />
contours will be a set of 2D surfaces that represent a constant value, i.e. isosurfaces<br />
The Parameters panel for contours contains the list of constant values, that the user<br />
can edit, most conveniently by the Generate range of values window. The Input <strong>and</strong><br />
Scalars menus present the module <strong>and</strong> fields, respectively, that are read by the filter<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing fields: streamlines<br />
Streamlines are created by first creating an append attributes filter<br />
Streamlines are created selecting the tracer lines using the Stream Tracer filter<br />
The tracer Seed window specifies a distribution of tracer points over a Line or Point<br />
Cloud<br />
The distance the tracer travels <strong>and</strong> the length of steps the tracer takes are specified in<br />
the text boxes below<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing fields: probes<br />
To plot a graph in ParaView, the users must first extract the internal mesh using the<br />
Extract Parts filter<br />
The user can then plot a graph by selecting Probe from the Filter menu<br />
In the Probe Object window, the user should select Line <strong>and</strong> position the line vertically<br />
up the center of the domain with a resolution of 50<br />
The fields that are plotted are selected in the Point scalars window of the Probe panel<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing fields: probes<br />
The user can select the probe filter directly by clicking onto the probes button on the<br />
toolbar<br />
Sample button<br />
It is possible to write the selected sampled fields onto a csv file. The output will be a<br />
comma separated file as follows:<br />
volPointInterpolate(p),0.200097,5.12835,8.24178,10.3533,...<br />
volPointInterpolate(magU),8.63369,8.13691,7.70859,7.37819,....<br />
volPointInterpolate(epsilon),48.1914,52.6348,59.0361,67.6491,7,...<br />
volPointInterpolate(k),1.08187,1.13229,1.19894,1.28333,1.3918,...<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing fields: Data analysis<br />
To plot field values in a certain point (cell, vertex, line) as a function of time (plotted<br />
time steps) the user can select the filter Data analysis form the filter menu or by<br />
clicking onto the Data Analysis button on the toolbar:<br />
Data analysis<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing fields: probes<br />
Pick the cell you want to select by positioning the pointer onto it <strong>and</strong> pressing the p key<br />
(pick)<br />
The user can pick the cell by means of different query methods: cell, point<br />
(interpolated), line, cell ID, point ID<br />
Plotted fields can be activated or deactivated<br />
The time period can be selected by acting on the slide bar in the<br />
temporal parameters window<br />
Once again the plotted fields can be written onto a csv file by clicking the<br />
save as CSV button<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Cut planes<br />
To create a contour plot across a plane rather than producing isosurfaces, the user<br />
must first use the Cut filter to create the cutting plane, on which the contours can be<br />
plotted<br />
The Cut filter allows the user to specify a<br />
cutting Plane or Sphere in the Cut Function<br />
menu by a center <strong>and</strong> normal/radius<br />
respectively<br />
The user can then run the Contour filter<br />
on the cut plane to generate contour<br />
lines<br />
Multiple cut planes can be generated<br />
using the Add value or the Generate<br />
range of values sub panel<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Clip filter<br />
The Clip filter works similarly to the Cut one, but keeps the mesh <strong>and</strong> field<br />
information on one side of the cutting plane<br />
The Clip filter allows the user to specify<br />
a cutting Plane, Sphere, Box or on the<br />
basis of a value for a scalar field<br />
The clip selection can be inverted by<br />
activating the Inside out option<br />
The visibility option allows the user to<br />
activate or deactivate the visibility of the<br />
cutting plane, sphere or box<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Threshold<br />
The Threshold filter allows to visualize only the cells having the values of the<br />
selected field within a specified range<br />
The range can be specified by means of moving the Upper threshold <strong>and</strong> lower<br />
threshold bars<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Visualizing Lagrangian<br />
To visualize the Lagrangian particle tracking the case must be converted into paraview<br />
format<br />
The user should run the application foamToVTK on the case containing the Lagrangian<br />
particle tracking (in our case the aachenBomb tutorial for the dieselFoam application)<br />
foamToVTK . aachenBomb<br />
This comm<strong>and</strong> will generate an additional folder named VTK inside the case directory<br />
The user must start paraview typing the following comm<strong>and</strong>:<br />
paraview<br />
The case can be opened clicking on the file menu, open, <strong>and</strong> selecting the VTK<br />
directory. By clicking on the *.vtk file the case will be opened<br />
The user may load all the time steps by clicking on the timesteps button <strong>and</strong> selecting<br />
the Add all choice on the new window<br />
The use must then open the files contained in the lagrangian directory inside the VTK<br />
folder<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Visualizing Lagrangian<br />
To display the particles the user must filter the lagrangian field with the Glyphs filter<br />
Then the scalar option must be selected in the scale mode window along with the<br />
spheres as glyphs<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
The 3D view button<br />
There are settings controlling the 3D view Properties, selected from the View menu, or<br />
alternatively by clicking the small 3D View toggle button at the top left of the image<br />
display window<br />
The General panel includes the following items which are often worth setting at startup<br />
the background color, where white is often a preferred choice for printed material<br />
Use parallel projection which is the usual choice for CFD, especially for 2D cases<br />
the level of detail (LOD) which controls the rendering of the image while it is being<br />
manipulated, e.g. translated, resized, rotated; lowering the levels set by the<br />
sliders, allows cases with large numbers of cells to be re-rendered quickly during<br />
manipulation<br />
The Annotate panel includes <strong>options</strong> for including annotations in the image<br />
The Display Orientation Axes feature is particularly useful.<br />
The Camera panel includes buttons of St<strong>and</strong>ard Views, settings for Camera Controls<br />
<strong>and</strong> the <strong>options</strong> for detailed Camera Orientation<br />
The user can store up to 6 camera positions by clicking on a given button using the<br />
right mouse button, for subsequent retrieval using the left mouse button<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing sets with paraview<br />
The user may create sets (pintSet, faceSet <strong>and</strong> cellSet) to perform certain additional<br />
operation over the fields, i.e. moving certain points or applying a source term only in a<br />
certain area<br />
A set, i.e. a cellSet, can be created in <strong>OpenFOAM</strong> using the comm<strong>and</strong> cellSet<br />
$FOAM_APP/utilities/mesh/manipulation/cellSet<br />
This application creates a list of cells on the base of data read from the cellSetDict<br />
file<br />
The user shall try to create a new cellSet in the pitzDaily tutorial case<br />
run<br />
cp -r $FOAM_TUTORIAL/simpleFoam/pitzDaily<br />
cd pitzDaily/system<br />
cp $FOAM_UTILITIES/mesh/manipulation/cellSet/cellSetDict .<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing sets with paraview<br />
The user must modify the cellSetDict file in the following way:<br />
// Name of set to operate on<br />
name myCellSet;<br />
// One of clear/new/invert/add/delete|subset/list<br />
action new;<br />
topoSetSources<br />
(<br />
// Cells with cell centre within box<br />
boxToCell<br />
{<br />
box (-0.05 -0.25 -0.001) (0.1 0.25 0.001);<br />
}<br />
);<br />
To create the cell set the user must run the cellSet application<br />
cellSet . pitzDaily<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Viewing sets with paraview<br />
Once the cellSet has been created run the foamToVTK comm<strong>and</strong> on the pitzDaily<br />
case using the cellSet option:<br />
foamToVTK . pitzDaily -cellSet myCellSet<br />
To know all the available option of the foamToVTK application type foamToVTK <strong>and</strong><br />
press enter. It will be displayed the usage of that application<br />
Usage: foamToVTK [-surfaceFields] [-ascii]<br />
[-faceSet faceSet name] [-mesh mesh name] [-nearCellValue]<br />
[-pointSet pointSet name] [-excludePatches patches to exclude]<br />
[-allPatches] [-cellSet cellSet name] [-parallel] [-fields fields]<br />
[-constant] [-noPointValues] [-latestTime] [-noInternal] [-time time]<br />
To visualize the cellSet the user must open the VTK folder (it works also form a already<br />
opened paraFoam windows) in the pitzDaily directory <strong>and</strong> select the file with the name<br />
of the cellSet: myCellSet_*.*<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Data manipulation<br />
It possible to rely on data manipulation utilities which OpanFOAM provides inside its<br />
utilities folder<br />
<strong>OpenFOAM</strong> utilities can also be copied <strong>and</strong> customized to create user defined utilities<br />
An example could be the ptot utilities which calculates the total pressure starting from<br />
the velocity <strong>and</strong> pressure field<br />
$FOAM_UTILITIES/postProcessing/miscellaneous/ptot<br />
It is also possible to export data to be visualized with other post-processing tools<br />
>cd $FOAM_UTILITIES/postProcessing/dataConversion<br />
>ls<br />
foamDataToFluent foamToFieldview9 foamToVTK<br />
foamToEnsight foamToGMV smapToFoam<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Running in parallel<br />
The method of parallel computing used by <strong>OpenFOAM</strong> is known as domain<br />
decomposition, in which the geometry <strong>and</strong> associated fields are broken into pieces <strong>and</strong><br />
allocated to separate processors for solution<br />
The first step is to decompose the domain using the decomposePar utility<br />
The user must edit the dictionary associated with decomposePar named<br />
decomposeParDict which is located in the system directory of the case<br />
The first entry is numberOfSubdomains which specifies the number of sub-domains<br />
into which the case will be decomposed, usually corresponding to the number of<br />
processors available for the case<br />
The parallel <strong>running</strong> uses the public domain openMPI implementation of the st<strong>and</strong>ard<br />
message passing interface (MPI)<br />
The process of parallel computation involves: decomposition of mesh <strong>and</strong> fields;<br />
<strong>running</strong> the application in parallel; <strong>and</strong>, post-processing the decomposed case<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Running in parallel<br />
We shall use the pitzDaily case for the simpleFoam application tutorial<br />
tut<br />
cd simpleFoam<br />
cd pitzDaily<br />
We can copy the pitzDaily case to the pitzDailyParallel<br />
cp -r pitzDaily pitzDailyParallel<br />
And copy into the system directory the directory the decomposeParDict file available in<br />
the pitzdailtExptInlet case<br />
cp pitzDailyExptInlet/system/decomposeParDict pitzDailyParallel/system<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Running in parallel: domain decomposition<br />
The mesh <strong>and</strong> fields are decomposed using the decomposePar utility<br />
The underlying aim is to break up the domain with minimal effort but in such a way to<br />
guarantee a fairly economic solution<br />
The geometry <strong>and</strong> fields are broken up according to a set of parameters specified in a<br />
dictionary named decomposeParDict that must be located in the system directory<br />
of the case of interest<br />
In the decomposeParDict file the user must set the number of domains which the<br />
case should be decomposed into: usually it corresponds to the number of cores<br />
available for the calculation<br />
numberOfSubdomains 2;<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Running in parallel: domain decomposition<br />
The user has a choice of four methods of decomposition, specified by the method<br />
keyword<br />
For each method there are a set of coefficients specified in a sub-dictionary of<br />
decompositionDict, named Coeffs, used to instruct the decomposition<br />
process<br />
method simple/hierarchical/metis/manual;<br />
simple: simple geometric decomposition in which the domain is split into pieces<br />
by direction, e.g. 2 pieces in the x direction, 1 in y etc.<br />
hierarchical: Hierarchical geometric decomposition which is the same as simple<br />
except the user specifies the order in which the directional split is done, e.g. first in<br />
the y-direction, then the x-direction etc<br />
metis: METIS decomposition which requires no geometric input from the user <strong>and</strong><br />
attempts to minimize the number of processor boundaries. The user can specify a<br />
weighting for the decomposition between processors which can be useful on<br />
machines with differing performance between processors<br />
manual: Manual decomposition, where the user directly specifies the allocation of<br />
each cell to a particular processor<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Running in parallel: domain decomposition<br />
The coefficients sub-dictionary for the simple method are set as follows:<br />
simpleCoeffs<br />
{<br />
n (2 1 1);<br />
delta 0.001;<br />
}<br />
Where n is the number of sub-domains in the x, y, z directions (nx ny nz) <strong>and</strong> delta is<br />
the cell skew factor, typically 10 −3<br />
The coefficients sub-dictionary for the hierarchical method are set as follows:<br />
hierarchicalCoeffs<br />
{<br />
n (2 2 1);<br />
delta 0.001;<br />
order xyz;<br />
}<br />
Where n is the number of sub-domains in the x, y, z directions, delta is the cell skew<br />
factor <strong>and</strong> order is the order of decomposition xyz/xzy/yxz...<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Running in parallel: domain decomposition<br />
The coefficients sub-dictionary for the metis method are set as follows:<br />
metisCoeffs<br />
{<br />
processorWeights<br />
(<br />
1<br />
...<br />
1<br />
);<br />
}<br />
It is the list of weighting factors for allocation of cells to processors: is the<br />
weighting factor for processor 1, etc.<br />
The coefficients sub-dictionary for the manual method contains the reference to a file<br />
manualCoeffs<br />
{<br />
dataFile "";<br />
}<br />
It is the name of file containing data of allocation of cells to processors<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Running in parallel: domain decomposition<br />
Data files may need to be distributed if only local disks are used in order to improve<br />
performance<br />
The root path to the case directory may differ between machines. The paths must then<br />
be specified in the decomposeParDict dictionary using distributed <strong>and</strong> roots<br />
keywords<br />
The distributed entry should read<br />
distributed yes;<br />
<strong>and</strong> the roots entry is a list of root paths, , , . . . , for each node<br />
roots<br />
<br />
(<br />
""<br />
""<br />
...<br />
);<br />
where is the number of roots<br />
Each of the processorN directories should be placed in the case directory at each of<br />
the root paths specified in the decomposeParDict dictionary<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Running in parallel: domain decomposition<br />
The decomposePar utility is executed in the normal manner by typing<br />
decomposePar <br />
The output will look like:<br />
Calculating distribution of cells<br />
Selecting decompositionMethod metis<br />
...<br />
Processor 0<br />
Number of cells = 6199<br />
Number of faces shared with processor 1 = 71<br />
Number of processor patches = 1<br />
Number of processor faces = 71<br />
Number of boundary faces = 12667<br />
Processor 1<br />
Number of cells = 6026<br />
Number of faces shared with processor 0 = 71<br />
Number of processor patches = 1<br />
Number of processor faces = 71<br />
Number of boundary faces = 12343<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Running in parallel: domain decomposition<br />
On completion, a set of subdirectories will have been created, one for each processor,<br />
in the case directory<br />
The directories are named processorN where N = 0, 1, ... represents a processor<br />
number <strong>and</strong> contains a time directory, containing the decomposed field descriptions,<br />
<strong>and</strong> a constant/polyMesh directory containing the decomposed mesh description.<br />
pitzDailyParallel<br />
|------> 0<br />
|------> constant<br />
|------> processor0<br />
|------> processor1<br />
|------> system<br />
openMPI can be run on a local multiprocessor machine very simply but when <strong>running</strong><br />
on machines across a network, a file must be created that contains the host names of<br />
the machines. The file can be given any name <strong>and</strong> located at any path<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Running in parallel: execution<br />
An application is run in parallel using the mpirun comm<strong>and</strong>:<br />
mpirun --hostfile -np <br />
-parallel > log<br />
where: is the number of processors; is the executable, e.g.<br />
simpleFoam; <strong>and</strong>, the output is redirected to a file named log.<br />
The file contains the names of the machines listed, one machine per line<br />
The names must correspond to a fully resolved hostname in the /etc/hosts file of the<br />
machine on which the openMPI is run. The file would contain:<br />
hostname1<br />
hostname2 cpu=2<br />
hostname3<br />
In our case it becomes:<br />
mpirun -np 2 simpleFoam . pitzDailyParallel -parallel > log &<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Running in parallel: post-processing<br />
When post-processing cases that have been run in parallel the user has two <strong>options</strong>:<br />
reconstruction of the mesh <strong>and</strong> field data to recreate the complete domain <strong>and</strong><br />
fields, which can be post-processed as normal;<br />
post-processing each segment of decomposed domain individually<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Running in parallel: post-processing<br />
After a case has been run in parallel, it can be reconstructed for post-processing by<br />
merging the sets of time directories from each processorN directory into a single set of<br />
time directories<br />
The reconstructPar utility performs such a reconstruction by executing the comm<strong>and</strong>:<br />
reconstructPar <br />
In our case it will become:<br />
reconstructPar . pitzDailyParallel<br />
Time = 0<br />
Reconstructing FV fields<br />
Reconstructing volScalarFields<br />
p<br />
.....<br />
Reconstructing volVectorFields<br />
U<br />
Reconstructing volTensorFields<br />
R<br />
No point fields<br />
No lagrangian fields<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
The sample utility<br />
<strong>OpenFOAM</strong> provides the sample utility to sample field data for plotting on graphs<br />
The sampling locations are specified for a case through a sampleDict dictionary<br />
located in the case system directory<br />
The data can be written in a range of formats including well-known graphing packages<br />
such as Grace/xmgr, gnuplot <strong>and</strong> jPlot<br />
The sampling can be executed by <strong>running</strong> the utility application sample according to<br />
the application syntax<br />
sample . pitzDaily<br />
The sampleDict dictionary can be generated with the st<strong>and</strong>ard set of keyword entries<br />
using FoamX, or by copying a detailed sampleDict from a the sample utility folder:<br />
$FOAM_UTILITIES/postProcessing/miscellaneous/sample<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
The sampleDict file<br />
The sampleDict contains entries to be set according to the user needs<br />
interpolationScheme cellPoint;<br />
The choice for the interpolationScheme can be one of the following:<br />
cell : use cell-centre value only, constant over cells, no interpolation at all<br />
cellPoint : use cell-centre <strong>and</strong> vertex values<br />
cellPointFace : use cell-centre, vertex <strong>and</strong> face values<br />
Vertex values are determined from neighboring cell-centre values whereas face values<br />
determined using the current face interpolation scheme for the field (linear, gamma,<br />
etc.)<br />
writeFormat raw;<br />
The choice for the write format depends on the application used to plot the series. The<br />
user can choose one of the following:<br />
xmgr<br />
jplot<br />
gnuplot<br />
raw<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
The sampleDict file<br />
The sampleDict file contains a sampleSet subdictionary which defines where the<br />
fields should be sampled<br />
sampleSets<br />
(<br />
uniform<br />
{<br />
name data;<br />
axis x;<br />
start (-0.0206 0 0);<br />
end (0.29 0 0);<br />
nPoints 1000;<br />
}<br />
)<br />
In this subdictionary the user can specify the type of sampling method, the name of<br />
samples <strong>and</strong> how to write point coordinate plus other parameters depending on the<br />
method chosen<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
The sampleDict file<br />
The user may choose one of the following sampling methods:<br />
uniform: evenly distributed points on line<br />
face: one point per face intersection<br />
midPoint: one point per cell, in between two face intersections<br />
midPointAndFace: combination of face <strong>and</strong> midPoint<br />
curve: specified points, not necessary on line, uses tracking<br />
cloud: specified points, uses findCell<br />
name lineX1;<br />
The name entry is typically a filename. After <strong>running</strong> the sample application the user<br />
will find a new folder in the case directory named sample<br />
Each data file is given a name containing the field name, the sample set name, <strong>and</strong> an<br />
extension relating to the output format, including .xy for raw data, .agr for Grace/xmgr<br />
<strong>and</strong> .dat for jPlot<br />
axis distance;<br />
Specifies how to write point coordinates, <strong>options</strong> are:<br />
x/y/z: x/y/z coordinate only<br />
xyz: three columns<br />
distance: distance from start of sampling line (if uses line) or distance from first<br />
specified sampling point<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
There are also some type specific <strong>options</strong>:<br />
The sampleDict file<br />
start <strong>and</strong> end coordinate for uniform, face, midPoint <strong>and</strong> midPointAndFace<br />
nPoints number of sampling points for uniform<br />
list of coordinates for curve <strong>and</strong> cloud<br />
The fields list contains the fields that the user wishes to sample<br />
fields<br />
(<br />
p<br />
mag(U)<br />
U.component(1)<br />
R.component(0)<br />
);<br />
The sample utility can parse the following restricted set of functions to enable the user<br />
to manipulate vector <strong>and</strong> tensor fields<br />
U.component(n) writes the nth component of the vector/tensor<br />
mag(U) writes the magnitude of the vector/tensor<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Probes<br />
To plot values of fields as functions of the time the user can rely on the new<br />
functionObject class<br />
This is a modular plugin that evaluates at every time step the specified field at the<br />
specified location<br />
Function objects are created adding them to a function subdict in the controlDict file<br />
The user may find an example of how to modify the controlDict file in<br />
$FOAM_TUTORIAL/oodles/pitzDaily/ case<br />
This function cannot parse the set of functions as the sample utility does, however in<br />
the case of the Ux component extraction the user can easily do that for the U probed<br />
field<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
Probes<br />
functions<br />
(<br />
probes1<br />
{<br />
type probes; // Type of functionObject<br />
// Where to load it from (if not already in solver)<br />
functionObjectLibs ("libsampling.so");<br />
probeLocations // Locations to be probed. runTime modifiable!<br />
(<br />
(0.1778 0.0253 0.0)<br />
);<br />
// Fields to be probed. runTime modifiable!<br />
fields<br />
(<br />
p<br />
);<br />
}<br />
);<br />
During the job run it will be created, inside the case directory, a folder named probes<br />
containing the probed values<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
foamLog<br />
There are limitations to monitoring a job by reading the log file, in particular it is difficult<br />
to extract trends over a long period of time<br />
The foamLog script is therefore provided to extract data of residuals, iterations, Courant<br />
number etc. from a log file <strong>and</strong> present it in a set of files that can be plotted graphically<br />
The user must run the application in the following manner:<br />
simpleFoam . pitzDaily > log<br />
Where the log file can be named arbitrarily<br />
The script is executed by<br />
foamLog <br />
The files are stored in a subdirectory of the case directory named logs<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>
POLITECNICO DI MILANO CHALMERS<br />
foamLog<br />
Once the log file has been created the foamLog must be executed to generate the<br />
required statistics<br />
foamLog <br />
The files are stored in a subdirectory of the case directory named logs<br />
Each file has the name where is the name of the variable<br />
specified in the log file <strong>and</strong> is the iteration number within the time step<br />
Those variables that are solved for, the initial residual takes the variable name <br />
<strong>and</strong> final residual takes ¡var¿FinalRes. By default, the files are presented in<br />
two-column format of time <strong>and</strong> the extracted values<br />
>cd pitzDaily<br />
>ls<br />
contCumulative_0 epsilonIters_0 kIters_0 Time_0 UyFinalRes_0<br />
contGlobal_0 executionTime_0 p_0 Ux_0 UyIters_0<br />
contLocal_0 foamLog.awk pFinalRes_0 UxFinalRes_0<br />
epsilon_0 k_0 pIters_0 UxIters_0<br />
epsilonFinalRes_0 kFinalRes_0 Separator_0 Uy_0<br />
Gianluca Montenegro/ <strong>OpenFOAM</strong> <strong>postprocessing</strong> <strong>and</strong> <strong>advanced</strong> <strong>running</strong> <strong>options</strong>