最近写了一个inlet boundary condition的code, 并行计算的时候一直报错。具体问题是:
我在0文件下定义了:
inlet
{
type DSRFGVelocity;
M 600;
N 100;
uref 22.5091;
alpha 0.1538;
zref 1.3860;
inflowPar pkqomega;
value uniform (0 0 0);
}
如果单核计算没有问题,但是等到并行计算renumberMesh的时候 会报错。我是这么做的,当mesh都处理好以后:
decomposepar
mpirun -np xx renumberMesh -overwrite -parallel
mpirun -np xx pisoFoam -parallel.
报错信息是:
--> FOAM FATAL IO ERROR:
[0] compound has already been transferred from token
on line 33 the empty compound of type List<vector>
[0]
[0] file: /ddnA/work/xuwang/DSRFGinflow/processor0/0/U.boundaryField.inlet.value at line 33.
[0]
[0] From function Foam::token::compound& Foam::token::transferCompoundToken(const Foam::Istream&)
[0] in file lnInclude/token.C at line 99.
[0]
FOAM parallel run aborting
然后打开processor0/0/U 文件后,那个inlet是这样的:
inlet
{
type DSRFGVelocity;
M 600;
N 100;
zref 1.386;
alpha 0.1538;
uref 22.5091;
inflowPar pkqomega;
value nonuniform List<vector>
1372
(
(27.414161 3.7652743 -1.313935)
我能感觉到的就是,在0文件下U的value被定义成了uniform (0 0 0),但是程序一旦运算,就把inlet 上的速度值给重新计算了一次,导致变成了nonuniform。但是of6中自带的turbulentInlet算例,也是这样做的,不知道为什么我这里出了问题。我自己写的inflow的updateCoeffs()函数如下:
void Foam::DSRFGVelocityFvPatchVectorField::updateCoeffs()
{
if (this->updated())
{
return;
}
if (curTimeIndex_ != this->db().time().timeIndex())
{
scalar time = this->db().time().value();
vectorField Uavg(patch().size(),vector::zero);
vectorField Uprim(patch().size(),vector::zero);
vectorField Utotal(patch().size(),vector::zero);
xxxxxxx 省略中间一些繁琐的步骤
this->operator==(Utotal);
curTimeIndex_ = this->db().time().timeIndex();
}
fixedValueFvPatchVectorField::updateCoeffs();
}
请各位高人指点!