CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   If statement for time dependent UDF (https://www.cfd-online.com/Forums/fluent-udf/139438-if-statement-time-dependent-udf.html)

serhan July 24, 2014 05:57

If statement for time dependent UDF
 
1 Attachment(s)
Hello my friends;

I am currently working on defroster performance on inclined surfaces and I have the attached temperature warm-up curve for inlet condition. I try to write an UDF but every single time it gives parse error for "else" statement line. Anyone knows the rootcause of this error could help me?

************************************************** ******

#include "udf.h"
DEFINE_PROFILE(temperature,thread,position)
{
face_t f;
real t=CURRENT_TIME;
begin_f_loop(f,thread)
t=t-floor(t);
{
if (t>=1750.);
F_PROFILE(f,thread,position)= 323.;
else
F_PROFILE(f,thread,position)=6.*0.000000001*t*t*t-3.*0.00001*t*t+0.0636*t+265.;
}
end_f_loop(f,thread)

************************************************** ******
Thank you..

mprinkey July 28, 2014 23:44

Quote:

Originally Posted by serhan (Post 502947)
Hello my friends;

I am currently working on defroster performance on inclined surfaces and I have the attached temperature warm-up curve for inlet condition. I try to write an UDF but every single time it gives parse error for "else" statement line. Anyone knows the rootcause of this error could help me?

************************************************** ******

#include "udf.h"
DEFINE_PROFILE(temperature,thread,position)
{
face_t f;
real t=CURRENT_TIME;
begin_f_loop(f,thread)
t=t-floor(t);
{
if (t>=1750.);
F_PROFILE(f,thread,position)= 323.;
else
F_PROFILE(f,thread,position)=6.*0.000000001*t*t*t-3.*0.00001*t*t+0.0636*t+265.;
}
end_f_loop(f,thread)

************************************************** ******
Thank you..

This is just a C coding error. Remove the semicolon from the end of the if (t>=1750.) line. You are getting a parse error because that semicolon ends the if statement. The following F_PROFILE() is its own statement independent of the if. The else line doesn't have an associated if, so you get a parse error.


All times are GMT -4. The time now is 11:10.