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

Source Term - UDF Parse error (but simulation seems to work)

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 5, 2015, 03:11
Default Source Term - UDF Parse error (but simulation seems to work)
  #1
New Member
 
Lamboram
Join Date: Jul 2011
Location: Munich
Posts: 16
Rep Power: 14
lamboram is on a distinguished road
Hello all,

this is the code I used for my source term heat generation. When I try to interpret it in Fluent. I get Parse error (line 3). But then I simulated it, the results are sensible and converged. What could be possibly wrong here.

#include "udf.h"

DEFINE_SOURCE(heat_source,cell,thread,dS,eqn)
{
real source;
real time;

source = 0.0;
time = CURRENT_TIME;

if (time >= 0 && time <= 10)
source = 129639.04;
else if (time >= 11 && time <= 50)
source = 56939.5;
else if (time >= 51 && time <= 1140)
source = 21606.5;
else if (time > 1140)
source = 14234.87;
else
source = 0.0;

return source;

}

Cheers,
Ram
lamboram is offline   Reply With Quote

Old   October 5, 2015, 07:18
Default
  #2
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 12
Bruno Machado is on a distinguished road
If possible avoid the use of interpreted UDFs. The compiled UDF is more "safe".
Bruno Machado is offline   Reply With Quote

Old   October 6, 2015, 11:07
Default
  #3
Senior Member
 
Bruno
Join Date: Mar 2009
Location: Brazil
Posts: 277
Rep Power: 21
brunoc is on a distinguished road
Quote:
Originally Posted by Bruno Machado View Post
If possible avoid the use of interpreted UDFs. The compiled UDF is more "safe".
Any example of when compiling a UDF is "safer" then using an interpreted version?
brunoc is offline   Reply With Quote

Old   October 8, 2015, 06:55
Default
  #4
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 12
Bruno Machado is on a distinguished road
Quote:
16 Interpreted vs. Compiled UDF’s
Functions can either be read in and interpreted at run time or compiled and grouped into a shared library that is linked with the standard FLUENT executable.

• Interpreted vs. compiled code
o Interpreter
 Interpreter is a large program that sits in the computer’s memory.
 Executes code on a “line by line” basis instantaneously
 Advantages – does not need a separate compiler
 Disadvantage – slow and takes up space in memory

o Compiler (refer to User’s Guide for instructions)
 Code is translated “once” into machine language (object modules).
 Efficient way to run UDF’s. Uses Makefiles
 Creates “shared libraries” which are linked with the rest of the solver
 Overcomes interpreter limitations e.g. mixed mode arithmetic, structure references etc.
Got this from internet (author: Saeed Sadeghi).
Bruno Machado is offline   Reply With Quote

Old   October 8, 2015, 08:06
Default
  #5
Senior Member
 
Bruno
Join Date: Mar 2009
Location: Brazil
Posts: 277
Rep Power: 21
brunoc is on a distinguished road
Ok, but those just say that compiling a UDF is more efficient, both in speed and memory usage. There is nothing there about it being "safer".

Also, some of the points are a bit misleading. For instance, compiled UDFs also take up computer memory once they're loaded. And interpreted UDFs also create code that is shared with the solver.

Compiled UDFs are overall better, but interpreted are great for quick tests or when you don't have a compiler installed. One very good thing about interpreted UDFs in the past was that if wanted your code ready to run on every machine you had to re-compile it several times: win/linux, 32/64 bits, 2d/3d, single/double precision, serial/parallel. But with 16.0 compiling is as easy (and free!) in Windows as it is in Linux. Fluent will also auto-compile your UDF as needed, so no more of those multiple compilers.

Cheers.
brunoc is offline   Reply With Quote

Reply

Tags
compiled, fluent, heat generation, source term, udf

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is swap4foam ?? AB08 OpenFOAM 28 February 2, 2016 01:22
Trouble compiling utilities using source-built OpenFOAM Artur OpenFOAM Programming & Development 14 October 29, 2013 10:59
ATTENTION! Reliability problems in CFX 5.7 Joseph CFX 14 April 20, 2010 15:45
UDF Source Term Units? Brian FLUENT 1 October 24, 2005 09:15
UDFs for Scalar Eqn - Fluid/Solid HT Greg Perkins FLUENT 0 October 11, 2000 03:43


All times are GMT -4. The time now is 07:25.