CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   if statement for volScalarField (http://www.cfd-online.com/Forums/openfoam-programming-development/100328-if-statement-volscalarfield.html)

AnjaMiehe April 24, 2012 03:37

if statement for volScalarField
 
Hello Foamers,

I want to code an if condition for a volScalarField and I do get errors in compiling that the if statement does not work.
Code:

volScalarField T

volScalarField lambda
(
    IOobject
    (
        "lambda",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    if (T>Tf)? 0 : pow((Tf-T)/(Tf-Tl),-0.35)     
)

As the pow coding of a negative base with a negative exponent does not work, I need a workaround.
Any other coding idea is welcome as well.

Thanks in advance,
Regards,
Anja

akidess April 24, 2012 05:00

Use pos() and neg(): pos(T - Tf)* pow((Tf-T)/(Tf-Tl),-0.35)

AnjaMiehe April 24, 2012 07:01

Hello akidess,

and thank you very much. That was the basic idea I needed. To make it work finally, I changed it a little bit using the magnitude:
Code:

pos(Tf-T)*pow(mag(Tf-T)/(Tf-Tl),-0.35)
in order not to have a negative base.

Thanks again, Anja


All times are GMT -4. The time now is 23:55.