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

openfoam reduce() and MPI_barrier

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 2, 2013, 00:55
Default openfoam reduce() and MPI_barrier
  #1
Senior Member
 
Join Date: Jun 2011
Posts: 163
Rep Power: 15
mechy is on a distinguished road
Hi All
In a parallel Run, I want to calculate the pressure force on a boundary (p*mesh.sf() on it)
therefore I used the bellow code :


Code:
  totalPressureForce =
        sum
        (
            p.boundaryField()[fluidPatchID]
         *mesh.Sf().boundaryField()[fluidPatchID]
         );       
         
reduce(totalPressureForce,sumOp<scalar>());
I think, In parallel Run, before reduce command all procs should be stop (MPI_barrier) and when all procs calculate the new value of totalPressureForce, the reduce command add totalPressureForce in non-master procs to master one and scatter it.

does reduce command execute by all procs or only by master one ?
does the reduce command contain MPI_barrier ?
in other words does it Blocks until all processes in the communicator have reached this routine ? or I block the run before it by another command ?


Best Regards
mechy is offline   Reply With Quote

Old   October 3, 2013, 15:32
Default
  #2
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
Have you tried using gSum() instead of sum()?

gSum should work in parallel so you should not need your reduce operation. This may do what you want without answering the rest of your questions
chegdan is offline   Reply With Quote

Old   October 6, 2013, 17:48
Default
  #3
Senior Member
 
Join Date: Jun 2011
Posts: 163
Rep Power: 15
mechy is on a distinguished road
Hi Daniel
I have checked the gsum code
if is only a sum and then reduce (see at bellow)
I think in each time step a MPI_barrier is execute
do you know which command do it ?
(I think runTime++ is good choice for it)




#define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc) \ 00478 \ 00479 template<class Type> \ 00480 ReturnType gFunc(const UList<Type>& f) \ 00481 { \ 00482 ReturnType res = Func(f); \ 00483 reduce(res, rFunc##Op<Type>()); \ 00484 return res; \ 00485 } \ 00486 TMP_UNARY_FUNCTION(ReturnType, gFunc) 00487 00488 G_UNARY_FUNCTION(Type, gMax, max, max) 00489 G_UNARY_FUNCTION(Type, gMin, min, min) 00490 G_UNARY_FUNCTION(Type, gSum, sum, sum)
mechy is offline   Reply With Quote

Old   October 7, 2013, 10:11
Default
  #4
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
Not sure I understand your question. Also, if you post code to the forum you may want to use the [CODE] tages around your code (also accessible from the "#" in the advanced menu of your message editor for posting messages to this forum).
chegdan 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



All times are GMT -4. The time now is 18:02.