CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Type conversion question (https://www.cfd-online.com/Forums/openfoam/95377-type-conversion-question.html)

feldy77 December 15, 2011 03:33

Type conversion question
 
Dear forum,
I need to compare the value of z coordinate of my boundary mesh with some variable, let say of a double or scalar type

scalar min=10.0;
forAll (ccSph.boundaryField(), patchI)
{
ccSph.boundaryField()[patchI] = sph.localVector(mesh.C().boundaryField()[patchI]);
if (ccSph.boundaryField()[patchI].component(vector::Z)>max) {do something };
}
Unfortunately this code does not pass compilation, since the first argument in if return reference to a surface field. How can I circumvent the problem? Is there any standard way of type conversion in OpenFoam.
Many thanks, Yuri

ngj December 15, 2011 03:50

Hi Yuri

You are comparing a scalarField with a scalar, which does not make much sense. Instead, you should loop over the scalarField and make the comparison one boundary face at the time.

Best regards,

Niels


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