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

openfoam reduce() and MPI_barrier

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   October 1, 2013, 23:55
Default openfoam reduce() and MPI_barrier
  #1
Senior Member
 
Join Date: Jun 2011
Posts: 141
Rep Power: 6
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, 14:32
Default
  #2
Senior Member
 
chegdan's Avatar
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 543
Rep Power: 18
chegdan 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
__________________
Dan

Find me on twitter @dancombest and LinkedIn
chegdan is offline   Reply With Quote

Old   October 6, 2013, 16:48
Default
  #3
Senior Member
 
Join Date: Jun 2011
Posts: 141
Rep Power: 6
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, 09:11
Default
  #4
Senior Member
 
chegdan's Avatar
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 543
Rep Power: 18
chegdan 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).
__________________
Dan

Find me on twitter @dancombest and LinkedIn
chegdan is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On



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