CFD | OpenFOAM | In parallel
Running applications in parallel
Both domain decomposition and reconstructionprocesses can only be done on a singlecore.
This section describes how to run OpenFOAM in parallel on distributed processors.
The method of parallel computing used by OpenFOAM is known asdomain decomposition, in which the geometry andassociated fields are broken into pieces and allocated to separateprocessors for solution.
The process of parallel computation involves: decomposition of mesh and fields; running the application in parallel; and, post-processing the decomposed case as described in the following sections. The parallel running uses the public domain openMPI implementation of the standard message passing interface (MPI).
Decomposition of mesh and initial field data
- The mesh and fields are decomposed using the decomposePar utility.
- The geometry and fields are broken up according to a set of
parameters specified in a dictionary named
decomposeParDictthat must be located in thesystemdirectory of the case of interest.
An example decomposeParDict dictionary can be copied
from the interFoam/damBreak/damBreak tutorial if the user
requires one; the dictionary entries within it are reproduced below:
1 | |
The user has a choice of four methods of decomposition, specified by the method keyword as described below.
simple- Simple geometric decomposition in which the domain is split into pieces by direction.
hierarchical- Hierarchical geometric decomposition which is the same as simple except the user specifies the order in which the directional split is done.
scotch- Scotch decomposition which requires no geometric input from the user
and attempts to minimise the number of processor boundaries. The user
can specify a weighting for the decomposition between processors,
through an optional processorWeights keyword which can be useful on
machines with differing performance between processors. There is also an
optional keyword entry strategy that controls the decomposition strategy
through a complex string supplied to Scotch. For more information, see
the source code file:
$FOAM_SRC/parallel/decompose/scotchDecomp/scotchDecomp.C
- Scotch decomposition which requires no geometric input from the user
and attempts to minimise the number of processor boundaries. The user
can specify a weighting for the decomposition between processors,
through an optional processorWeights keyword which can be useful on
machines with differing performance between processors. There is also an
optional keyword entry strategy that controls the decomposition strategy
through a complex string supplied to Scotch. For more information, see
the source code file:
manual- Manual decomposition, where the user directly specifies the allocation of each cell to a particular processor.
For each method there are a set of coefficients specified in a
sub-dictionary of decompositionDict, named
<method>Coeffs as shown in the dictionary
listing.
Docs and github code:
| Name | Class |
|---|---|
| none | Foam::noDecomp |
| manual | Foam::manualDecomp |
| simple | Foam::simpleGeomDecomp |
| hierarchical | Foam::hierarchGeomDecomp |
| kahip | Foam::kahipDecomp |
| metis | Foam::metisDecomp |
| scotch | Foam::scotchDecomp |
| structured | Foam::structuredDecomp |
| multiLevel | Foam::multiLevelDecomp |
If using metis,
1 | |
error,
1 | |
run.sh script
1 | |
decomposePar
The decomposePar utility is executed in the normal
manner by typing
1 | |
On completion, a set of subdirectories will have been created, one
for each processor, in the case directory. The directories are named
processorN represents a processor number and contains a
time directory, containing the decomposed field descriptions, and a
constant/polyMesh directory containing the decomposed mesh
description.
Example, motorBike
./Allrun
1 | |
and outputs are,
1 | |
Post-processing parallel processed cases
When post-processing cases that have been run in parallel the user can:
- reconstruct the mesh and field data to recreate the complete domain and fields, which can be post-processed as normal;
- post-process each segment of decomposed domain individually; or
- use ParaView via the option paraFoam -vtk and select the decomposedCase from the GUI whereby the case will be assembled internally
Reconstructing mesh and data
The reconstructPar utility performs such a
reconstruction by executing the command:
1 | |
Executing reconstructPar without any additional options
will process all stored time directories.
Issues
- OpenFOAM在并行运算结束后
能否并行reconstructPar?或者有没有其他方法能够加快reconstructPar?
- 最近跑了几个网格总数比较大的案例(大概500w~1000w),并行计算结束后,执行了reconstructPar进行重构,但是重构时间特别长。
- 试试这个
mpirun -np 2 redistributePar -reconstruct -parallel - 印象中以前看一个培训材料说分块和重构都只能单核
- openfoam的decomposePar、reconstructPar是个老大难。这个应该需要大幅度的fund他们才会解决。目前他们对这方面还没有迫切的处理需求。目前openfoam针对reconstructPar这面的处理方式是后处理也是并行来搞,paraview直接看decompose的数据,各种postProcess也都是并行来。针对decomposePar慢的问题,openfoam这面是画网格snappyHexMesh直接并行来。所以我这面尝试处理2个亿网格,从生成到计算,也还可以。但是如果是第三方生成的2个亿网格,需要decomposePar,那可就慢了