|
[Sponsors] |
fluent udf problem: write specific data for every iteration in a file. |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 23, 2013, 15:20 |
fluent udf problem: write specific data for every iteration in a file.
|
#1 |
New Member
Join Date: Apr 2013
Posts: 17
Rep Power: 13 |
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? |
|
May 27, 2013, 16:26 |
|
#2 |
New Member
Join Date: Apr 2013
Posts: 17
Rep Power: 13 |
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 18:33. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] funkySetFields compilation error | tayo | OpenFOAM Community Contributions | 39 | December 3, 2012 06:18 |
[blockMesh] error message with modeling a cube with a hold at the center | hsingtzu | OpenFOAM Meshing & Mesh Conversion | 2 | March 14, 2012 10: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 |