|
[Sponsors] |
October 2, 2013, 00:55 |
openfoam reduce() and MPI_barrier
|
#1 |
Senior Member
Join Date: Jun 2011
Posts: 163
Rep Power: 15 |
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>()); 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 |
|
October 3, 2013, 15:32 |
|
#2 |
Senior Member
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0 |
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 |
|
October 6, 2013, 17:48 |
|
#3 |
Senior Member
Join Date: Jun 2011
Posts: 163
Rep Power: 15 |
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) |
|
October 7, 2013, 10:11 |
|
#4 |
Senior Member
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0 |
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).
|
|
|
|