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/)
-   -   reduce an equal operation (https://www.cfd-online.com/Forums/openfoam-programming-development/177136-reduce-equal-operation.html)

T.D. September 6, 2016 05:53

reduce an equal operation
 
Dear Foamers,

I am looking for a "reduce" function but on an "equal operation".

For example, we know that reduce function is already Ok for:
sumOp, minOp and maxOp

How to do it (or extend it) for an "equal operation" and a "pow operation".

I need to make the following code to work also in parallel:
Code:

            forAll(mesh.C(),celli)
            {
            Sens[celli] = Foam::pow(SSS[celli], 0.5) ;
            }

          // Sens and SSS are both volScalarField type

Thank you and regards,
T.D.

jherb September 6, 2016 12:00

Your code should run without modification in multi process mode. Each processor has its own mesh with the cells of that fluid partition it is responsible for. So no need for any reduce operation. The latter would only be necessary if data from all processors should be put together, e.g. the sum of a value of all cells of all the meshes on all the processors/processes.

But your equal and pow operation only uses local information. So also no need for data exchange between processors. This would become much more complicate, if values of neighbor cells should be used.


All times are GMT -4. The time now is 07:27.