CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   heaviside? (https://www.cfd-online.com/Forums/openfoam/85453-heaviside.html)

ginette February 25, 2011 13:41

heaviside?
 
Dear Open Foam Community,

I am a brand new to OpenFoam.

I would like to create a field like
Code:

volScalarField toto = toto1 * heaviside(phi) + toto2 * heaviside(-phi);
where toto1 and toto2 are two "constants" and phi is a "volScalarField". Is there a way to do this?

Many thanks in advance,
Martin.

ngj February 25, 2011 14:00

Hi Martine

You could use either of the functions Foam::neg or Foam::pos. These functions return 1 if the argument is negative (positive) and 0 if the argument is positive (negative). I do not know how the functions handles 0, however.

Best regards,

Niels

ginette February 25, 2011 14:24

Indeed!

Thanks so much, Niels!

Martin.

PS: Is there a way to close the thread and tag is "solved"?


All times are GMT -4. The time now is 12:52.