CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   openfoam reduce() and MPI_barrier (https://www.cfd-online.com/Forums/openfoam-programming-development/124316-openfoam-reduce-mpi_barrier.html)

mechy October 1, 2013 23:55

openfoam reduce() and MPI_barrier
 
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

chegdan October 3, 2013 14:32

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 :D

mechy October 6, 2013 16:48

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)

chegdan October 7, 2013 09:11

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).


All times are GMT -4. The time now is 14:24.