CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   How to access procNo (http://www.cfd-online.com/Forums/openfoam/105935-how-access-procno.html)

zxj160 August 13, 2012 13:59

How to access procNo
 
I want to access the procNo in the main solver code. as follows:

if (ProcNo==0)
forAll(mesh.C(), pointI)
{
if ((mesh.C()[pointI].x()>0)&&(mesh.C()[pointI].x()<0.2))
{
in1[ii1] = pointI;
ii1++;
}
if ((mesh.C()[pointI].x()>0.2)&&(mesh.C()[pointI].x()<0.4))
{
in2[ii2] = pointI;
ii2++;
}
if ((mesh.C()[pointI].x()>0.4)&&(mesh.C()[pointI].x()<0.6))
{
in3[ii3] = pointI;
ii3++;
}
};

But when I wmake it and the error message is
error procNo is not declared in this scope

Arnoldinho August 14, 2012 03:18

It should work with
Code:

if (Pstream::myProcNo() == 0)
{
...
}

or
Code:

if (Pstream::master())
{
...
}



All times are GMT -4. The time now is 11:46.