CFD Online Logo CFD Online URL
Home > Forums > FLUENT

Open files in a UDF

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

Like Tree1Likes
  • 1 Post By Greg Perkins

LinkBack Thread Tools Display Modes
Old   June 25, 2002, 04:09
Default Open files in a UDF
Posts: n/a
Hi everyone! could you tell me in which way I can access data stored in a file and use it in UDF to define a profile? I'm not so expert in C language, and the UDF i've made is this one:

#include "udf.h" DEFINE_PROFILE(wall_temp,thread,position) { face_t f; real cond; FILE *fp; fp=fopen("space/ICADdisk/provafile.ext,"r"); begin_f_loop (f,thread) {


F_PROFILE(f,thread,position) = cond; } end_f_loop (f,thread) }

Fluent can compile the UDF, but when I try to initialize the solution to start the iterations, i get a"SEGMENTATION VIOLATION" error. What can I do? Thank you! Riccardo
  Reply With Quote

Old   June 25, 2002, 20:04
Default Re: Open files in a UDF
Greg Perkins
Posts: n/a
Its probably best not to do file manipulation inside a DEFINE_PROFILE rotuine - since this can be executed frequently during the solution process.

I've been using file read/writes for a long time, without problems. In the past I found it best to use format of "%f" for single precision and "%lf" for double precision in the read statements. Never tried the "%g" format.

Here's some other tips:

1. open and then close files - don't leave open as in the above code 2. probably do the file stuff in a routine called from either a DEFINE_INITIALIZE or DEFINE_ON_DEMAND. 3. if you use parallel fluent - you will need to pay special attention when writing files. reading should be ok, but writing is best performed by only the host or a specified node - this will require #ifdef switches in your code.

Good Luck

czhao86 likes this.
  Reply With Quote

Old   June 26, 2002, 10:45
Default Re: Open files in a UDF
Posts: n/a

Missing a quote here------------------^
  Reply With Quote


Thread Tools
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
wmake compiling new solver mksca OpenFOAM Programming & Development 13 August 18, 2014 22:26
UDF for reading dat files mrestrepo30 Fluent UDF and Scheme Programming 2 July 9, 2009 16:47
Errno 24 linux ivanwhlau OpenFOAM Running, Solving & CFD 6 July 1, 2009 10:16
open files with tecplot George Tecplot 1 January 16, 2007 10:02
UDF files don joe FLUENT 0 March 13, 2001 14:42

All times are GMT -4. The time now is 21:00.