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

Own code - Writing timestep in parallel

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 22, 2022, 04:55
Default Own code - Writing timestep in parallel
  #1
Member
 
UOCFD
Join Date: Oct 2020
Posts: 40
Rep Power: 6
uosilos is on a distinguished road
I have coded this switch to write and end the simulation when pressure reaches a defined value.

The code works nice in serial mode but in parallel it gets stuck while writing, it creates only a few fields in the processor0 folder and nothing in others proc folders.

What could be the problem?


Code:

pimple
{
...
rho = thermo.rho();
         
  runTime.write();
                    
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
                
if (pressureOpening=="on")
    {

        #include "Panels.H"
                
        if (valueDiffAvg >= pStatAbs.value()) 
        {
            Info << "Aborting:  pressure threshold has been reached. \n" ;
            Info << "valueDiffAvg: " << valueDiffAvg << "   pStatAbs: " << pStatAbs.value() << endl ;
            
            runTime.writeAndEnd();
        }          
     }
 }
   Info<< "End\n" << endl;
 
  return 0;
uosilos is offline   Reply With Quote

Old   February 22, 2022, 12:58
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by uosilos View Post
I have coded this switch to write and end the simulation when pressure reaches a defined value.

The code works nice in serial mode but in parallel it gets stuck while writing, it creates only a few fields in the processor0 folder and nothing in others proc folders.

What could be the problem?

Your code very likely has different branching logic. I.e. some processes think they are finished, but others do not. The volField write however is parallel-aware, so if you only call it from one process things will simply "block". This usually looks like some really ugly MPI error at exit.



You probably want to test something like the following:

Code:
if (returnReduce((valueDiffAvg >= pStatAbs.value()), orOp<bool>())) 
{
     Info<< "Aborting:  pressure threshold has been reached" << nl
          << "valueDiffAvg: " << valueDiffAvg << "   pStatAbs: " << pStatAbs.value() << endl ;
            
     runTime.writeAndEnd();
}
Of course, without knowing what your code is, can't say if you want an andOp<bool>() logic, reduce the values ahead or whatever. Either way, I hope you get the idea.
olesen is offline   Reply With Quote

Old   February 23, 2022, 04:28
Default
  #3
Member
 
UOCFD
Join Date: Oct 2020
Posts: 40
Rep Power: 6
uosilos is on a distinguished road
Quote:
Originally Posted by olesen View Post
Your code very likely has different branching logic. I.e. some processes think they are finished, but others do not. The volField write however is parallel-aware, so if you only call it from one process things will simply "block". This usually looks like some really ugly MPI error at exit.

Thanks a lot mate, you gave sense to the OF "community".


I wondered it should be something related with processors but my attempt was to include an if Pstream::master(), write, what neither work.


In a new attempt with your improvement seems that at least it is stopping and writing nicely, I will try further validation.


Thanks again
uosilos 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
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Community Contributions 58 December 23, 2021 03:36
Parallel Fortran 95 code using Openmp Shiv1510 Main CFD Forum 5 February 14, 2020 12:36
How to Mix AIR and WATER Elvis1991 FLUENT 12 December 1, 2016 13:28
[snappyHexMesh] crash sHM H25E OpenFOAM Meshing & Mesh Conversion 11 November 10, 2014 12:27
Design Integration with CFD? John C. Chien Main CFD Forum 19 May 17, 2001 16:56


All times are GMT -4. The time now is 19:34.