CFD Online URL
Home > Forums > Fluent UDF and Scheme Programming

fluent udf problem: write specific data for every iteration in a file.

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

LinkBack Thread Tools Display Modes
Old   May 23, 2013, 15:20
Default fluent udf problem: write specific data for every iteration in a file.
New Member
Join Date: Apr 2013
Posts: 17
Rep Power: 3
nnvoro is on a distinguished road
Hi guys,

I have a problem with my calculations in Fluent. Could somebody please help me with it?

I calculate blood flow in a straight pipe with taper. I use parallel calculations with 4 processors. I need to store pressure data for specific plane for each iteration. As I know there are at least 2 way to do that:

The first one is to write macro and to run command after each iteration. But it doesn't work for me because fluent overwrites file after each iteration. I could add the number of iteration in the name of file so that files don't overwrite. But I would have too much files stored if I save separate file for each iteration.

Second way is to write udf which writes pressure measurement in a file for each iteration. I tried to write it but it doesn't work and I can't find the reason why it doesn't work. Fluent interprets it but when I execute udf Fluent crashes. There is the code for my last udf:

#include "udf.h"

FILE *fp;
Domain *domain;
Thread *t;
real p4 ,p5;
real p_monitor;
real Lh = 236;

t=Lookup_Thread(domain, 4); /**/
p4 = C_P(1,t); /*pressure in plane-4*/
t=Lookup_Thread(domain, 5);
p5 = C_P(1,t); /*pressure in plane-5*/

fp = fopen("output_file.txt","w");
fprintf(fp, "%f", p_monitor);

I simply take the pressure in the cell #1 for two planes, which are defined by ids: 4 and 5. For my case pressure should be the same everywhere in the plane-4 and it is the same everywhere in the plane-5 and it doesn't matter which cell I take, thus I could take cell#1.

Could the reason why my udf doesn't work be that I run Fluent in parallel?
nnvoro is offline   Reply With Quote

Old   May 27, 2013, 16:26
New Member
Join Date: Apr 2013
Posts: 17
Rep Power: 3
nnvoro is on a distinguished road
It turned out that reading and writing files require parallelization of serial source code: Need to rewrite completely my udf.
For the people who might be interested in the same problem, I found useful example (Example: Writing Data to a Common File on the Host Process's File System):

Last edited by nnvoro; May 27, 2013 at 18:33.
nnvoro is offline   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
funkySetFields compilation error tayo OpenFOAM 39 December 3, 2012 06:18
error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Native Meshers: blockMesh 2 March 14, 2012 11:56
pisoFoam compiling error with OF 1.7.1 on MAC OSX Greg Givogue OpenFOAM Programming & Development 3 March 4, 2011 18:18
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 02:24
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 18:51

All times are GMT -4. The time now is 05:36.