"if" command in CFX-13 is not really an "if" command!!!!

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

 October 16, 2012, 07:16 "if" command in CFX-13 is not really an "if" command!!!! #1 Senior Member   mohammad Join Date: Dec 2010 Location: Seoul, South korea Posts: 214 Rep Power: 8 Dear All, I am trying to make a conditional expression with "if" command in CFX-13. Amazingly, the if command is not true... for example, create this expression and see the results!!! -if (a>5,10,loge(5-a)) if we see the results for any a>5 (e.g. "a=6") the results must be 10 However, the CFX-post tried to calculate the value of "loge(5-a)" which will be an mathematical error. Seemningly, before applying the if command, the CFX-POST calculated the consequences ..... Any Idea or Alternative solution!!!??? Regards, Lemanes likes this.

 October 16, 2012, 09:45 #2 Senior Member   Chris DeGroot Join Date: Nov 2011 Location: Canada Posts: 388 Rep Power: 7 This is answered in the CFX Reference Guide, section 13.2.2. CEL supports the conditional if statement using the following syntax: if( cond_expr, true_expr, false_expr ) where: cond_expr: is the logical expression used as the conditional test true_expr: is the mathematical expression used to determine the result if the conditional test is true. false_expr : is the mathematical expression used to determine the result if the conditional test is false. Note:**The expressions true_expr and false_expr are always evaluated independent of whether the evaluation of cond_expr is true or false. As a consequence, a conditional statement cannot be used to avoid division by zero as in if( x>0, 1/x, 1.0). In this case, when x=0.0, a division by zero will still occur because the expression 1/x is evaluated independent of whether x>0 is satisfied or not. mvoss, Luis Lei, mrkmrk and 1 others like this. Last edited by cdegroot; October 16, 2012 at 09:47. Reason: Mistake

September 25, 2013, 08:32
alternative here?
#3
New Member

Lingyun Lei
Join Date: Jun 2013
Posts: 4
Rep Power: 5
thank you very much for your infos, which is quite helpful to me. But, what can I do, if i do need the ,,real'' conditional statement? Is there a alternative maybe?

best wishes
Quote:
 Originally Posted by cdegroot This is answered in the CFX Reference Guide, section 13.2.2. CEL supports the conditional if statement using the following syntax: if( cond_expr, true_expr, false_expr ) where: cond_expr: is the logical expression used as the conditional test true_expr: is the mathematical expression used to determine the result if the conditional test is true. false_expr : is the mathematical expression used to determine the result if the conditional test is false. Note:**The expressions true_expr and false_expr are always evaluated independent of whether the evaluation of cond_expr is true or false. As a consequence, a conditional statement cannot be used to avoid division by zero as in if( x>0, 1/x, 1.0). In this case, when x=0.0, a division by zero will still occur because the expression 1/x is evaluated independent of whether x>0 is satisfied or not.

 September 25, 2013, 18:39 #4 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 12,707 Rep Power: 98 If you are asking how to get around the caveat Chris mentions (that both true and false expression must evaluate or you get an error) - then the best way around this is to use a fortran user routine where you can use if/then/else statements. This is reasonably easy to do, use a user CEL expression linked to the fortran routine. See the documentation for details, it has examples of how to do it. Luis Lei likes this.

September 26, 2013, 07:10
#5
New Member

Lingyun Lei
Join Date: Jun 2013
Posts: 4
Rep Power: 5
Quote:
 Originally Posted by ghorrocks If you are asking how to get around the caveat Chris mentions (that both true and false expression must evaluate or you get an error) - then the best way around this is to use a fortran user routine where you can use if/then/else statements. This is reasonably easy to do, use a user CEL expression linked to the fortran routine. See the documentation for details, it has examples of how to do it.
Yep, thanks very much, i've found the documents needed and i'll do it.

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post ftab CFX 7 September 27, 2012 07:57 aerospace_guy_ CFX 8 March 20, 2012 23:06 Val Main CFD Forum 3 June 10, 2011 02:20 Joseph CFX 14 April 20, 2010 15:45 Pandu Sattvika CFX 1 December 1, 2001 05:07

All times are GMT -4. The time now is 05:43.