CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Why my program cannot ran in parallel???

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 24, 2019, 03:21
Question Why my program cannot ran in parallel???
  #1
Member
 
Dongxu Wang
Join Date: Sep 2018
Location: China
Posts: 33
Rep Power: 7
wdx_cfd is on a distinguished road
Hi FOAMers,

I am doing some modifications on interFOAM, OpenFOAM v6. It is something about the dynamic mesh and I have changed the functions "pimple.loop()" to another one which is developed by myself. My new program runs good with the single core but will crash if I run it parallel. Here is the error information:

Code:
[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
and another similar case:
Code:
[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
I find that this error happens at the moment of (CourantNo.H):
Code:
    
scalarField sumPhi
    (
        fvc::surfaceSum(mag(phi))().primitiveField()
    );
What's more, this error will occur after the pimple outer loop is stopped by my newly added criterion (i.e. entering into the next time step and calculating the courantNo as mentioned above). It seems that there is something important in the function of "pimple.loop()" for parallel running but not ciritical for serial running. I have read "pimple.loop()" but I think I did not find anything useful about this parallel running problem.

I don't know much about the parallel running, but I am very confused why this happens? Could anyone give me some suggestions?

Thanks a lot!

WDX

Last edited by wdx_cfd; February 24, 2019 at 21:36.
wdx_cfd is offline   Reply With Quote

Old   February 24, 2019, 15:51
Default
  #2
Senior Member
 
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 12
massive_turbulence is on a distinguished road
Quote:
Originally Posted by wdx_cfd View Post
Hi FOAMers,

I am doing some modifications on interFOAM, OpenFOAM v6. It is something about the dynamic mesh and I have changed the functions "pimple.loop()" to another one which is developed by myself. My new program runs good with the single core but will crash if I run it parallel. Here is the error information:

Code:
[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
and another similar case:
Code:
[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
I find that this error happens at the moment of (CourantNo.H):
Code:
    
scalarField sumPhi
    (
        fvc::surfaceSum(mag(phi))().primitiveField()
    );
What's more, this error will occur once the number of the current pimple outer loop larger than the total number that read from the fvSolution (I still need the value in the dictionary because the first two time step is controled by the pimple algorithm). I have read "pimple.loop()" but I think I did not find anything useful about this parallel running problem.

I don't know much about the parallel running, but I am very confused why this happens? Could anyone give me some suggestions?

Thanks a lot!

WDX
My guess with this function is that something is wrong with the flux between the different CPU spaces or domains. Without seeing your entire case I doubt anyone will be able to help you.

Code:
    
scalarField sumPhi
    (
        fvc::surfaceSum(mag(phi))().primitiveField()
    );
massive_turbulence is offline   Reply With Quote

Old   February 24, 2019, 19:42
Default
  #3
Member
 
Dongxu Wang
Join Date: Sep 2018
Location: China
Posts: 33
Rep Power: 7
wdx_cfd is on a distinguished road
Quote:
Originally Posted by massive_turbulence View Post
My guess with this function is that something is wrong with the flux between the different CPU spaces or domains. Without seeing your entire case I doubt anyone will be able to help you.

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

Thank you for your reply. The entire code is a little bit complicated because I modified both the solver and the sixDof module. So updating the entire code is not an easy thing...

I think the problem is due to my newly added criterion for the pimple outer loop. Once the pimple outer loop is stopped by it, the program will crash (when parallel running).

I'll continue to find out the reason why this error occurs.

wdx_cfd is offline   Reply With Quote

Old   June 27, 2019, 05:49
Default
  #4
Member
 
Hosein
Join Date: Nov 2011
Location: Germany
Posts: 93
Rep Power: 14
einstein_zee is on a distinguished road
Quote:
Originally Posted by wdx_cfd View Post
Hi FOAMers,

I am doing some modifications on interFOAM, OpenFOAM v6. It is something about the dynamic mesh and I have changed the functions "pimple.loop()" to another one which is developed by myself. My new program runs good with the single core but will crash if I run it parallel. Here is the error information:

Code:
[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
and another similar case:
Code:
[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
I find that this error happens at the moment of (CourantNo.H):
Code:
    
scalarField sumPhi
    (
        fvc::surfaceSum(mag(phi))().primitiveField()
    );
What's more, this error will occur after the pimple outer loop is stopped by my newly added criterion (i.e. entering into the next time step and calculating the courantNo as mentioned above). It seems that there is something important in the function of "pimple.loop()" for parallel running but not ciritical for serial running. I have read "pimple.loop()" but I think I did not find anything useful about this parallel running problem.

I don't know much about the parallel running, but I am very confused why this happens? Could anyone give me some suggestions?

Thanks a lot!

WDX
Hey there,

I doubt that the problem would be because of "CourantNo.H". Cause interFoam already works perfectly fine in parallel . To pinpoint the real trouble you might switch to run in debug mode. Moreover, a basic understanding of how MPI works and how OF manages it is needed(at the very least, in case you want to remedy this on your own).
einstein_zee is offline   Reply With Quote

Old   April 13, 2023, 23:15
Default
  #5
New Member
 
Lin Xiangfeng
Join Date: Dec 2016
Posts: 11
Rep Power: 9
Linxiangfeng is on a distinguished road
Quote:
Originally Posted by wdx_cfd View Post
Thank you for your reply. The entire code is a little bit complicated because I modified both the solver and the sixDof module. So updating the entire code is not an easy thing...

I think the problem is due to my newly added criterion for the pimple outer loop. Once the pimple outer loop is stopped by it, the program will crash (when parallel running).

I'll continue to find out the reason why this error occurs.

Have you solved your problem? I met similar problems, but had no idea what to do with it
Linxiangfeng is offline   Reply With Quote

Old   April 14, 2023, 03:56
Default
  #6
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by Linxiangfeng View Post
Have you solved your problem? I met similar problems, but had no idea what to do with it
This is a typical beginners problem when writing things for parallel. You need to ensure that your program logic is consistent. It is no problem if you stop based on some a global value (eg, the residual), or based on a value which is globally consistent (eg, the iterations of a loop), but you CANNOT stop based on some local value without ensuring that everyone knows about it.
Examples,
Code:
// Exit when there are more than N cells with excess temperature


volScalarField T = ....;
 
while (....)
{
    label nTooHot = 0;
    forAll(T, celli)
    {
        if (T[celli] > 1000) ++nTooHot;
    }

    if (nTooHot > 20)
    {
        Pout<< "Have " << nTooHot << " cells exceeding temperature" << nl;
        break;
    }
}
Can you see what will happen here? One (or more) processors may hit that condition, while the others do not. This means that the while loop continues for those other branches and they will continue to calculate, solve, communicating but will not be in the same program branch as the ones that already exited the loop.

There are several remedies, depending on which logic you actually intend.
For example,
Code:
// Break on overall value.
label nTooHot = ...;   // summation loop as before

// make into a global 

reduce(nTooHot, sumOp<label>());
if (nTooHot > 20) { break; }

// This is frequently used, so there is a convenient wrapper.

label nTooHot = ...;   // summation loop as before

 if (returnReduce(nTooHot, sumOp<label>()) > 20)
{
      break;
}
Or else
Code:
// Break on local logic
label nTooHot = ...;   // summation loop as before

bool needToStop = (nTooHot > 20);


// a)
if (returnReduce(needToStop, orOp<bool>())) break;


// b)

if (returnReduce((nTooHot > 20), orOp<bool>())) break; 

 

// c)

 reduce(needToStop, orOp<bool>()); 
 if (needToStop)
{
    break;
}



// Using OpenFOAM 2212 
 
if (returnReduceOr(nTooHot > 20))
{
    break;
}
The reduce and returnReduce functions have internal parallel/non-parallel checks, so they also work in non-parallel.
tyhero likes this.
olesen is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Mode:Platform MPI Local Parallel core problem mztcu CFX 0 October 13, 2016 03:14
[snappyHexMesh] Error while running SnappyHex in parallel mg.mithun OpenFOAM Meshing & Mesh Conversion 1 February 10, 2016 13:13
[mesh manipulation] Importing Multiple Meshes thomasnwalshiii OpenFOAM Meshing & Mesh Conversion 18 December 19, 2015 18:57
Explicitly filtered LES saeedi Main CFD Forum 16 October 14, 2015 11:58
Update boundary conditions calculated by an external program CedricVH OpenFOAM 2 January 15, 2010 11:55


All times are GMT -4. The time now is 06:52.