CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

if statement for volScalarField

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By akidess

Reply
 
LinkBack Thread Tools Display Modes
Old   April 24, 2012, 03:37
Default if statement for volScalarField
  #1
Member
 
Anja Miehe
Join Date: Dec 2009
Location: Freiberg / Germany
Posts: 48
Rep Power: 7
AnjaMiehe is on a distinguished road
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
AnjaMiehe is offline   Reply With Quote

Old   April 24, 2012, 05:00
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 919
Rep Power: 17
akidess will become famous soon enough
Use pos() and neg(): pos(T - Tf)* pow((Tf-T)/(Tf-Tl),-0.35)
AnjaMiehe likes this.
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
*Help define the OpenFOAM stackexchange Q&A site: http://area51.stackexchange.com/prop...oam-technology
akidess is offline   Reply With Quote

Old   April 24, 2012, 07:01
Default
  #3
Member
 
Anja Miehe
Join Date: Dec 2009
Location: Freiberg / Germany
Posts: 48
Rep Power: 7
AnjaMiehe is on a distinguished road
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
AnjaMiehe is offline   Reply With Quote

Reply

Tags
if volscalarfield

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional statement over the entire mesh xisto OpenFOAM Programming & Development 6 November 24, 2010 13:13
If Statement Zaktatir CFX 5 June 19, 2010 06:09
Weak statement for Galerkin Method rugabug Main CFD Forum 0 March 26, 2010 20:19
Need help with statement in Gambit kbs FLUENT 16 May 9, 2008 08:15
marking statement in Latex mike Main CFD Forum 0 October 8, 2006 12:01


All times are GMT -4. The time now is 02:35.