|
[Sponsors] |
November 5, 2014, 13:02 |
Min Max of scalarField
|
#1 |
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 319
Rep Power: 16 |
Hi All,
Do min and max function work for scalarField? something like scalar xMin = min(myScalarField); scalar xMax = max(myScalarField); Do they work also in parallel? I need to calcualte the minimum and maximum value of a vector during a parallel simulation and use them for some calculations. I got different values when using or not the "reduce" command on xMin and xMax and it looks like i get the correct values when "reduce" is not used. I am a bit confused. Which is the best/correct way to calculate minimum and maximum value of a scalarField during a parallel run? Thanks Andrea |
|
November 5, 2014, 14:44 |
|
#2 |
Senior Member
|
Hi,
if you just use min or max you get minimum/maximum on a processor. In case of serial run you've got one process, so value is unique. In case of parallel run you can either use gMax/gMin functions (they do reduce thing for you), or first do min/max to get minimum/maximum on a processor and then do reduce to get minimum/maximum of all processors. |
|
November 5, 2014, 15:47 |
|
#3 |
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 319
Rep Power: 16 |
Hi Alexey,
thank you for interesting in my post. Which is the correct sintax for the reduce operations? Something like reduce(xMin, minOp<scalar>()); reduce(xMax, maxOp<scalar>()); i will also try with gmax/gmin... thanks again andrea |
|
November 5, 2014, 16:02 |
|
#4 |
Senior Member
|
Well, if you take a look at src/OpenFOAM/fields/Fields/Field/FieldFunctions.C
Code:
#define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc) \ \ template<class Type> \ ReturnType gFunc(const UList<Type>& f, const int comm) \ { \ ReturnType res = Func(f); \ reduce(res, rFunc##Op<Type>(), Pstream::msgType(), comm); \ return res; \ } \ TMP_UNARY_FUNCTION(ReturnType, gFunc) G_UNARY_FUNCTION(Type, gMax, max, max) G_UNARY_FUNCTION(Type, gMin, min, min) Code:
template<class Type> Type gMax(const UList<Type>& f, const int comm) { Type res = max(f); reduce(res, maxOp<type>(), Pstream::msgType(), comm); return res; } ... Code:
reduce(xMax, maxOp<scalar>()); |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
y+ and u+ values with low-Re RANS turbulence models: utility + testcase | florian_krause | OpenFOAM | 114 | August 23, 2023 06:37 |
multiphase turbulance case floating error | harsha_kulkarni | OpenFOAM Running, Solving & CFD | 3 | February 18, 2016 06:06 |
Problem of simulating of small droplet with radius of 2mm | liguifan | OpenFOAM Running, Solving & CFD | 5 | June 3, 2014 03:53 |
On the damBreak4phaseFine cases | paean | OpenFOAM Running, Solving & CFD | 0 | November 14, 2008 22:14 |
Could anybody help me see this error and give help | liugx212 | OpenFOAM Running, Solving & CFD | 3 | January 4, 2006 19:07 |