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

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

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 23, 2013, 14:20
Default fluent udf problem: write specific data for every iteration in a file.
  #1
New Member
 
Join Date: Apr 2013
Posts: 17
Rep Power: 13
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"

DEFINE_EXECUTE_AT_END(execute_at_end)
{
FILE *fp;
Domain *domain;
Thread *t;
real p4 ,p5;
real p_monitor;
real Lh = 236;

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

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

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, 15:26
Default
  #2
New Member
 
Join Date: Apr 2013
Posts: 17
Rep Power: 13
nnvoro is on a distinguished road
It turned out that reading and writing files require parallelization of serial source code: http://jullio.pe.kr/fluent6.1/help/html/udf/node187.htm. 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): http://cdlab2.fluid.tuwien.ac.at/LEH...df/node219.htm

Last edited by nnvoro; May 27, 2013 at 17:33.
nnvoro is offline   Reply With Quote

Reply


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
[swak4Foam] funkySetFields compilation error tayo OpenFOAM Community Contributions 39 December 3, 2012 05:18
[blockMesh] error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Meshing & Mesh Conversion 2 March 14, 2012 09:56
pisoFoam compiling error with OF 1.7.1 on MAC OSX Greg Givogue OpenFOAM Programming & Development 3 March 4, 2011 17:18
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 01:24
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51


All times are GMT -4. The time now is 02:06.