新写的程序单核计算无问题,但无法并行计算?



  • CFD的大佬们:

    最近我基于interFOAM和sixDof模块写了一个关于动网格的程序,并将动网格计算的结果作为pimple外循环的判据,这个程序在单核的情况下运行没问题,结果也正确,但是无法并行,只要一并行就会出现类似这样的错误:

    [1] --> FOAM FATAL IO ERROR: 
    [1] incorrect first token, expected '(', found on line 0 the punctuation token ':'
    [1] 
    [1] file: IOstream at line 0.
    [1] 
    [1]     From function Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::List<T>&) [with T = Foam::Field<Foam::Vector<double> >]
    [1]     in file /home/wdx/OpenFOAM-6/src/OpenFOAM/lnInclude/ListIO.C at line 131.
    [1] 
    FOAM parallel run exiting
    

    或者这样类似的:

    [1] --> FOAM FATAL IO ERROR: 
    [1] incorrect first token, expected <int> or '(', found on line 0 the word 'g'
    [1] 
    [1] file: IOstream at line 0.
    [1] 
    [1]     From function Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::List<T>&) [with T = Foam::Field<Foam::Vector<double> >]
    [1]     in file /home/wdx/OpenFOAM-6/src/OpenFOAM/lnInclude/ListIO.C at line 148.
    [1] 
    FOAM parallel run exiting
    [1] 
    [32] 
    [32] 
    [32] --> FOAM FATAL IO ERROR: 
    [32] error in IOstream "IOstream" for operation operator>>(Istream&, List<T>&) : reading first token
    [32] 
    [32] file: IOstream at line 0.
    [32] 
    [32]     From function void Foam::IOstream::fatalCheck(const char*) const
    [32]     in file db/IOstreams/IOstreams/IOstream.C at line 109.
    [32] 
    FOAM parallel run exiting
    [32] 
    [8] 
    [8] 
    [8] --> FOAM FATAL IO ERROR: 
    [8] error in IOstream "IOstream" for operation operator>>(Istream&, List<T>&) : reading first token
    [8] 
    [8] file: IOstream at line 0.
    [8] 
    [8]     From function void Foam::IOstream::fatalCheck(const char*) const
    [8]     in file db/IOstreams/IOstreams/IOstream.C at line 109.
    [8] 
    FOAM parallel run exiting
    

    我看了一下提示,发现是输入流的问题,具体错误我也定位出来了,是在计算库朗数时(CourantNo.H):

    scalarField sumPhi
        (
            fvc::surfaceSum(mag(phi))().primitiveField()
        );
    

    我觉得这个错误的原因就是我将pimple.loop()改为了其他的判据,但是我看了pimple.loop()执行的内容,也尝试自己在程序中添加类似的内容,没有效果。

    总的来说,目前的程序是单核运行没问题,但是并行会出错,并且一旦外循环的次数超过字典文件中指定的次数,错误就发生了(由于算法的前两个时间步要用到pimple 外循环所以pimpleOuterLoop这个数字还是要给定的,我给的是5)。

    我最疑惑的地方就是为什么我单核的时候计算完全没问题,一并行就出现问题?对并行的机制不是很懂,求大神帮帮忙,不胜感激!



  • 经过研究我发现不是当外循环数超过指定值时就会出错,而是当pimple外循环根据我设置的判据停止时就会出错。似乎应该是在pimple.loop()这个函数中有某些操作没有被我发现,这个对于并行很重要对于单核运行却无关紧要。


Log in to reply