CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   operators in openfoam (http://www.cfd-online.com/Forums/openfoam/122114-operators-openfoam.html)

openfoammaofnepo August 12, 2013 17:20

operators in openfoam
 
Hi All,

When I add the following lines in fireFoam.C:

if(x > length)
{
........
}

I failed to compiled it successfully. The error message is:

mo match for 'operator>' in x > length

If I indeed would like this condition in if statements, how can modify the source file fireFoam.C? Can anybody help me ? My C++ skill is a little low.

Thank you in advance!

fumiya August 12, 2013 21:14

Hi,

If you want to find the cells whose x-coordinates are greater than the value "length", you can use the following:

Code:

forAll(mesh.cells(), cellI) //Loop over the cells
{
if(mesh.C()[cellI].x() > length) //Compare the x-coordinate of the cellI's center with the scalar length
{
......
}
}

Hope this helps,
Fumiya


All times are GMT -4. The time now is 17:39.