CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   findMax not working in parallel with scalarField (http://www.cfd-online.com/Forums/openfoam/94035-findmax-not-working-parallel-scalarfield.html)

pablodecastillo November 3, 2011 11:47

findMax not working in parallel with scalarField
 
hello,

I found that findMax not working in parallel with scalarField.

I want to find the min coordinate_X for my pacht and at the same time with coordinate_Z <= 0.

Any idea?

Thanks

Phicau November 3, 2011 12:17

I've never tried to use findMax, but this should work:

Code:

scalar whatever = findMax...;

reduce(whatever, maxOp<scalar>());

There are other options depending on your needs: minOp, sumOp...

Regards

pablodecastillo November 3, 2011 12:25

So it would be;

label whatever = findMax...;

reduce(whatever, maxOp<label>());

I am using gMax, so get the max value, but now how can i get what label is the max value (and working in parallel)

Thanks

Phicau November 3, 2011 12:50

Just loop the entire patch:

Code:

    vectorField coord = patch().Cf();
    scalar auxiliar = 999999.0;

    forAll(coord.component(2), index)
    {
        if(coord.component(2)[index]<=0.0)
        {
            if(coord.component(0)[index]<auxiliar)
            {
                auxiliar = coord.component(0)[index];
            }
        }
    }

reduce(auxiliar, minOp<scalar>());


pablodecastillo November 3, 2011 13:38

thank you, but still i can not get the label for the value, any idea?

Pablo

Phicau November 3, 2011 13:55

Another loop...
Code:

    label auxiliarLabel = -999999;

    forAll(coord.component(2), index2)
    {
            if(coord.component(2)[index2]<=0.0)
            {
                      if(coord.component(0)[index2]==auxiliar)
                      {
                              auxiliarLabel = index2;
                              break;
                      }
            }
    }

reduce(auxiliarLabel, maxOp<label>());


pablodecastillo November 3, 2011 14:28

the second loop to find the cell is not working; i mean it is not giving the correct label

label celdabuscada = -99999;
scalar pto_X = -10000.0;

forAll(mesh.boundary()[patchK], faceI)
{
if (NN2[faceI].component(vector::Z) <= 0.0) {
if (NN2[faceI].component(vector::X) >= pto_X){
pto_X=NN2[faceI].component(vector::X);
}
}
}
reduce(pto_X, maxOp<scalar>());
forAll(mesh.boundary()[patchK], face2)
{
if (NN2[face2].component(vector::Z) <= 0.0) {
if (NN2[face2].component(vector::X)==pto_X){
celdabuscada=face2;
Info <<"////celda buscada " << celdabuscada << nl;
break;
}
}
}
reduce(celdabuscada, maxOp<label>());

more ideas??


All times are GMT -4. The time now is 19:36.