You are on page 1of 5

c 

  c
  

    c


There are not to many tutorials out there on this, probably due to the wide variety of things
you can do with the UDF interface. The documentation the Fluent provides is pretty good
once you know what you are trying to do (chapter 8 of the UDF manual has examples). UDF
programming is easier if you have C programming experience, so it is advisable to learn a
little C programming, then do some of the simple cases that Fluent provides, then tackle the
problem you really want to solve.

       c




The simplest way to add a UDF into Fluent is to write your UDF in the C programming
language and then use Define -> User-Defined -> Functions to either interpret or compile
your UDF. It can then be loaded. Fluent provides good documentation of the UDF interface
with numerous examples, so read that before trying too much.

     

Yes and no. To hook your UDF into Fluent, you'll probably have to use one of the
DEFINE_* macros that Fluent provides, and this is most easily done using C. However, you
can write routines that are used in the routines that are defined with the DEFINE_* macros in
other languages and then link them together. This requires some knowledge of mixed
language programming,Makefiles, the text user interface (TUI), and is not necessarily very
portable. An example using Fortran is given in Section 5.4.1 of the Fluent UDF Manual
(version 6.3).

   !

On Unix-like machines, GCC is the compiler of choice. On Windows machines, Microsoft


Visual C++ is the compiler of choice (GCC may also work on Windows- if anyone has
firsthand knowledge of this, please share). The free Express Edition of the Microsoft
compiler also works.

"# c
$        

The answer depends upon what exactly has happened.

jm If Fluent complains about not being able to find a compiler, then check to make sure
that the compiler is properly installed. On Windows machines, it is possible to install
the Visual C++ compiler without fully setting up the command line compiler (which
Fluent needs to be able to find). During the installation process, you need to select the
"register environment variables" option. Failure to do so will likely lead to complaints
about things being "not recognized as an internal or external command, operable
program or batch file" or missing DLL's. It is theoretically possible to fix this issue by
setting the appropriate environment variables, but keep in mind that even when nmake
can be found there still may be DLL issues. The easy path is probably reinstallation of
Visual Studio (taking special care to make sure that the command line interface is set
up properly), but the reinstallation path is always perilous. If you have long-term
experience using Windows you should probably know the risks, and if you don't you
should consult an expert.

jm If you are interpreting, keep in mind that not everything that is supported for compiled
UDF's is supported for interpreted UDF's. This is true both for the UDF interface and
the C language. If you are doing something pretty involved and it fails inexplicably,
try compiling to see if that makes a difference.

jm There is also the possibility of coding errors. Keep in mind that your source code gets
run through the C preprocessor (to change the Fluent macros into C code), so
unintended interactions are very possible.

#       %$!$    &      ' 


(      %

This is a Windows/Visual Studio issue. In order to compile your UDF, Fluent needs to know
where the nmake program is located, and it currently can't find it. If you open up a command
window and enter "nmake", you should probably get the same message. See the previous
question/answer.

"# c
       '     

This commonly occurs due to a faulty operation of some kind. For example, user-defined
memory (UDM) is not allocated until initialization, so attempting to access a UDM variable
before initialization can lead to a segmentation fault. Try to isolate the cause, and then look
for places where your expectation of what is available may not match reality. Finally, keep in
mind that if you do something really bad, you may need to restart Fluent before even a fixed
UDF will work.

) *  "   +  ,, -./.  !  


  -0

In the Fluent Launcher, there is a tab called "Environment". On this tab there is a check box
"Setup Compilation Environment for UDF", which has to be checked. If this is not enough,
and the compilation still fails, then the udf.bat file should be edited. The following has to be
added

set MSVC_DEFAULT=%ProgramFiles%\Microsoft Visual Studio 10.0


if exist "%MSVC_DEFAULT%\vC\vcvarsall.bat" set
MSVC=%MSVC_DEFAULT%
if not "%MSVC%" == "" goto msvc_env10
msvc_env10
set MSVC_VERSION=10
call "%MSVC%\VC\vcvarsall.bat" x86
gotomsvc_end

Basically it tries to run the vcvarsall.bat script. That is it!

)    01 # 


The questions surfacing in the discussion forum are most of the time solved with some simple
steps.

As they are mentioned frequently it may be appropriate to mention the solution steps here:

jm   +  * . Most of the time the Visual C++ 2008 Express Edition [1] is
recommended. On my system it even works with the new Visual Studio 2010
Professional Release Candidate [2].
jm *     . Browse your way through the Windows
system control to 'System'. There you will find a section 'Advanced system settings'.
In the following dialog go to the 'Advanced' tabulator and click on 'Environment
variables' (lower right corner). Go through the 'System variables' list and search for
the 'Path' entry. Add the following to the variable: ï 

 

 
ï  !ï 

 
 

ï"
!ï 
#$%&'(  "
)
*. Adjust this entry
to your system concerning the installation directories!
jm The Visual Studio entry should point to the location where 'nmake.exe' is located. If
this file is missing while trying to compile your UDF you will be fine with this step. If
other files are missing during the compilation find their location on you hard disc and
add their directory to the PATH entry.
jm  
2c34)   +  *    5 This is what most of the
users don't know. Start the Visual Studio command prompt which comes with your
Visual Studio installation. It is the familiar Windows style command prompt.
Navigate to the directory, where your FLUENT files are and start FLUENT by
entering 'fluent'. Don't use symbols on your desktop or start menue entries to start
FLUENT. (This does not apply to 64bit systems! See this entry.)

ƒmHi, The New version of FLUENT has a GUI to help build and
Load compiled UDF the older version have just the "Load"
part. You would need Microsoft Visual Studio . Net for this ( I
use it , dont know how to do with something else)

You need to follow the following steps

1) set up the environmental variable This is done by going to


the start menu > Programs>Fluent>Set_environment clicking
this would set the path and variable.

2) set up a directory structure as follows create a dirlibudf in


that create "src" and "ntx86". In ntx86 create "3d".( am
asuming that ur simulation is 3d)
3) copy the udf (.C file) and the required header( u can get the
header files frm c:\FLUENT.INC\fluent6.*.*\ntx86\src) files
into the "src" folder.

4) go to c:\FLUENT.INC\fluent6.*.*\ntx86\3d copy the


contents into the 3d folder which you created.

5) go to c:\FLUENT.INC\fluent6.*.*\ntx86\src copy
makefile_nt.udf and user_nt.udf to your 3d folder

6) rename makefile_nt.edf to makefile and open user_nt.udf


and read the instructions and do accordingly.

7) close FLUENT . Open command prompt ( start> accessories


> command prompt ) type the following C:\ CD program Files \
microsoft visual studio .net\vc7\bin

8) type :- vcvars32

9)go to the libudf\ntx86\3d which u have created

10) type nmake

11) This will compile ur code and build a lib if u dont have any
errors , if errors are present it will say so u need to debug it
then.

12) once this is done u can open fluent again and load the lib u
have just created , in this case it would be libudf.
I know itsconfusing ! Keep trying it took me a long time to get
all things correct.

You might also like