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

if statement for volScalarField

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By akidess

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 24, 2012, 04:37
Default if statement for volScalarField
  #1
Member
 
Anja Miehe
Join Date: Dec 2009
Location: Freiberg / Germany
Posts: 48
Rep Power: 17
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, 06:00
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30
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.
akidess is offline   Reply With Quote

Old   April 24, 2012, 08:01
Default
  #3
Member
 
Anja Miehe
Join Date: Dec 2009
Location: Freiberg / Germany
Posts: 48
Rep Power: 17
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


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 Off
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 07: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 09:15
marking statement in Latex mike Main CFD Forum 0 October 8, 2006 13:01


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