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

Open files in a UDF

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

Like Tree1Likes
  • 1 Post By Greg Perkins

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 25, 2002, 05:09
Default Open files in a UDF
  #1
Riccardo
Guest
 
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) {

fscanf(fp,"%g",cond);

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, 21:04
Default Re: Open files in a UDF
  #2
Greg Perkins
Guest
 
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

Greg
czhao86 likes this.
  Reply With Quote

Old   June 26, 2002, 11:45
Default Re: Open files in a UDF
  #3
Lanre
Guest
 
Posts: n/a
fp=fopen("space/ICADdisk/provafile.ext,"r");

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

Reply

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
wmake compiling new solver mksca OpenFOAM Programming & Development 14 June 22, 2018 07:29
UDF for reading dat files mrestrepo30 Fluent UDF and Scheme Programming 2 July 9, 2009 17:47
Errno 24 linux ivanwhlau OpenFOAM Running, Solving & CFD 6 July 1, 2009 11: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 18:57.