在集群上并行运行OpenFOAM

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dsfsdffgfd/article/details/81584990

使用cavity算例举例,在集群上运行的命令如下:

mpirun --hostfile machines -np 40 icoFoam -parallel > log &

其中machines文件中指定了计算的节点,假设集群上有三个节点aaa、bbb、ccc,每个节点都有15个核,那么machines文件的内容为(可以看到15+15+10=40为计算所用的总的核心数):

aaa cpu = 15
bbb cpu = 15
ccc cpu = 10

当然,在并行运行之前,还需准别好decomposeParDict,内容为:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  dev                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

numberOfSubdomains 40;

method          scotch;

simpleCoeffs
{
    n               (2 2 1);
    delta           0.001;
}

hierarchicalCoeffs
{
    n               (1 1 1);
    delta           0.001;
    order           xyz;
}

manualCoeffs
{
    dataFile        "";
}

distributed     no;

roots           ( );


// ************************************************************************* //

在这里使用的是scotch方法进行自动分区,指定scotch方法后,每次只用更改numberOfSubdomains即可。注意,每次并行运行算例之前, 一定要确保numberOfSubdomains的核数、machines中的核数及-np后的核数相对应。

设置好decomposeParDict字典文件,使用decomposePar工具即可进行分区。然后便可输入最上面的命令并行运行算例啦。

猜你喜欢

转载自blog.csdn.net/dsfsdffgfd/article/details/81584990