|
[Sponsors] |
January 28, 2002, 13:23 |
UDF to write interp files
|
#1 |
Guest
Posts: n/a
|
Hello,
I am trying to write a UDF so that I can save an interpolation file containing velocity and TKE data every few time steps for only the stationary zone of a two zone sliding mesh. This doesn't seem to be possible using a journal file or macro as the text interface doesn't provide capablility to write these files for only a single zone (although the GUI interface does). I am having a deal of difficulty understanding how to write these UDF's, even though I know C. Does anyone have a skeleton of a similar UDF I could use or suggestions in getting started. Your advice is very much appreciated. Thanks. Karl |
|
January 31, 2002, 18:49 |
Re: UDF to write interp files
|
#2 |
Guest
Posts: n/a
|
Have you searched the archives for a sample udf? I've posted quite a few over the past year or so.
The udf manual also has some code for looping pver threads/cells in the domain - you can use that. Basically I would do something like: Domain *domain; DEFINE_ON_DEMAND(EXEC_Write_Interpolate) { /* --- here define outfile and open file using usual C code.... */ /* --- loop over all cells in domain - you can restict to particular threads using additional code. */ thread_loop_c(thread, domain) { begin_c_loop_int(cell,thread) { /* --- can access cell data */ /* --- eg. write temp */ fprintf(outfile,"%f",C_T(cell,thread)); /*--- write other data....*/ } end_c_loop_int(cell,thread) } fclose(outfile); } NOTE: I don't know the format of the interpolation file. Its probaly quite complex, so it will be easier for you to write your own file, and then write another udf to read this file into a new grid and perform the interpolation yourself. Perhaps Fluent can help. The required code snippets, commands for doing complex things isn't documented by Fluent, so I think you'll find it easier to do it yourself than try writing your macro to produce a generic interpolation file which Fluent can understand. |
|
February 4, 2002, 20:02 |
Re: UDF to write interp files
|
#3 |
Guest
Posts: n/a
|
Thanks for you udf file. Actually I wrote a similar one today following some examples. If I write " extern Domain *domain;", the compiler will return the following error messages:
Creating library libudf.lib and object libudf.exp esource.obj : error LNK2001: unresolved external symbol _domain libudf.dll : fatal error LNK1120: 1 unresolved externals NMAKE : fatal error U1077: 'link' : return code '0x460' Stop. If I get rid of "extern" like what you did, everything's fine. I haven't run the dll yet( the cas file is missing ) and don't know if it works. Could you tell me why I can't use "extern" here? Thanks! Lu |
|
February 4, 2002, 20:39 |
Re: UDF to write interp files
|
#4 |
Guest
Posts: n/a
|
Its a good question. To be honest I'm not sure - it may be to do with how Domain type is defined. The above works, and since I'm a bit pressed for time, I'm not going to spend any time to find out the details.
Let me know, if you work it out. Greg |
|
February 6, 2002, 00:05 |
Re: UDF to write interp files
|
#5 |
Guest
Posts: n/a
|
I guess you used compiled udf. I can compile the file and get a dll file. But when I tried to run the udf in Fluent, it gave the error message: Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: ()
I tried to debug the program and simplified it as: #include "udf.h" Domain* domain; DEFINE_ON_DEMAND(test) { Thread *t; cell_t c; thread_loop_c(t,domain) { begin_c_loop(c,t) { } end_c_loop(c,t) } } The error still exists. Seems I cannot use thread_loop_c. The operation system is Win2000 Professional. Could you give me some suggestions? Thanks a lot. Lu |
|
February 6, 2002, 00:27 |
Re: UDF to write interp files
|
#6 |
Guest
Posts: n/a
|
Actually I had another look a my source code, I do in fact use
extern Domain* domain; as the declaration..... Also I use unix - and all my code has worked on several platforms, HP-UX, IRIX6r10 etc. I don't use Windows - I'm not a big fan of this OS for Fluent, since they develop on unix boxes and when they port to Windows, some strange things have occurred in the past - acces to some variables is limited and the setup to compile is a bit different. Also, scripting etc in Windows is not standard, whereas on unix I can use the same scripts etc on a HP, an SGI or whatever - so this make things a lot easier, at least for me. So can't really help much with detailed Win2k questions, sorry. Greg |
|
February 7, 2002, 13:10 |
Re: UDF to write interp files
|
#7 |
Guest
Posts: n/a
|
Anyway, thanks for your help. I am kind of hooked to win2000 and it is not easy to change to another system. I agree with you. Sometimes windows OS is rather confusing.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to write UDF to define 2 profiles at inlet? | emma | FLUENT | 5 | January 30, 2011 06:22 |
Grid-rotation with UDF Files | Titasse | FLUENT | 2 | July 15, 2010 11:59 |
critical error during installation of openfoam | Fabio88 | OpenFOAM Installation | 21 | June 2, 2010 04:01 |
UDF (write a data file) problem | lichun Dong | FLUENT | 2 | July 29, 2005 12:39 |
Results saving in CFD | hawk | Main CFD Forum | 16 | July 21, 2005 21:51 |