|
[Sponsors] |
June 25, 2002, 05:09 |
Open files in a UDF
|
#1 |
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 |
|
June 25, 2002, 21:04 |
Re: Open files in a UDF
|
#2 |
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 |
|
June 26, 2002, 11:45 |
Re: Open files in a UDF
|
#3 |
Guest
Posts: n/a
|
fp=fopen("space/ICADdisk/provafile.ext,"r");
Missing a quote here------------------^ |
|
|
|
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 |