CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

compilation error

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 14, 2000, 12:29
Default compilation error
  #1
M.A. Rakib
Guest
 
Posts: n/a
Why is the following UDF not being compiled as an interpreted UDF?

#include "udf.h" DEFINE_PROPERTY(cell_temperature,cell,thread) {

real temp = C_T(cell,thread);

face_t f;

real flow_time = RP_Get_Real("flow-time");

begin_f_loop (f,thread)

{

if (flow_time = 0)

temp = 300;

else

temp = 350;

return temp;

}

Error is:line 12: invalid expression for if : float
  Reply With Quote

Old   June 14, 2000, 16:37
Default Re: compilation error
  #2
kostya
Guest
 
Posts: n/a
This error comes from unability to check equality between integer and real numbers. You could change the line

if (flow_time = 0) to if (flow_time < 1.0e-7)

and this line should be OK. I don't have much experience with UDF, but i'm not sure with what you are trying to achieve with this one. Temperature is not property, why dont't you use DEFINE_PROFILE or a field function?

Hope it helps
  Reply With Quote

Old   June 15, 2000, 12:34
Default Re: compilation error
  #3
Chris
Guest
 
Posts: n/a
Note that the equality operator in C is ==.

You have an assignment (setting flow_time to zero), not an equality test.
  Reply With Quote

Old   June 15, 2000, 12:35
Default Re: compilation error
  #4
M.A. Rakib
Guest
 
Posts: n/a
Dear kostya, thanks for the comments. But really I am still confused about the UDF to be used. Actually I want to define an energy source from time t=0 secs to time t=60 secs (i.e. 1 minute) at the constant value of say 5 W/m3. Then I want to stop the energy source ( at t > 60 secs), and find out the temperature profile as a function of temperature and time. Following is the crude form of the program, which of course has errors, as they appear on the console window.

#include "udf.h" DEFINE_SOURCE(energy_source,cell,thread,dS,eqn) {

real source;

real flow_time = RP_Get_Real("flow-time");

{

if (flow_time < 1.0e-7)

source = 0.;

for (flow_time>=1.0e-7; flow_time<=60;

source = 5.0;

else

source = 0.;

dS[eqn] = 0.0;

return source;

}

The compilation errors that appear are as follows:

Error: source.cpp: line 10: parse error. Error: source.cpp: line 11: parse error. Error: source.cpp: line 17: parse error.

Here source.cpp is the relevant file.

Another question that I would like to ask is about the error. What is the meaning of parse error?

  Reply With Quote

Old   June 21, 2000, 05:12
Default Re: compilation error
  #5
Matthew Brannock
Guest
 
Posts: n/a
I've just started to learn to program in C and use these UDF's also. I found a parse error just to mean a format error of some type (ie the use of brackets inside your 'if' loops, if you have more than 1 line after your 'if' and 'else' statements you need to put the '{' brackets in)

cheers,

Matthew.
  Reply With Quote

Old   June 21, 2000, 11:28
Default Re: compilation error
  #6
Chris
Guest
 
Posts: n/a
A parse error indicates that the code is not syntactically valid C. You are going to need to learn C to do anything effective with UDFs. Here is a version of your code that sets source to 5 if flow-time is between (0,60] and 0 otherwise. I am not familiar with the DEFINE_SOURCE hook so I can't comment on whether it is doing something useful.

#include "udf.h"

DEFINE_SOURCE(energy_source,cell,thread,dS,eqn) {

real source;

real flow_time = RP_Get_Real("flow-time");

if (flow_time > 0.0 && flow_time <= 60.)

source = 5.0;

else

source = 0.0;

dS[eqn] = 0.0;

return source;

}
  Reply With Quote

Reply


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
[OpenFOAM] Native ParaView Reader Bugs tj22 ParaView 270 January 4, 2016 12:39
OpenFOAM install on Ubuntu Natty 11.04 bkubicek OpenFOAM 13 May 26, 2011 06:48
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
Compiling problems with hello worldC fw407 OpenFOAM Installation 21 January 6, 2008 18:38
user defined function cfduser CFX 0 April 29, 2006 11:58


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