|
[Sponsors] |
January 14, 2014, 13:11 |
UDF with data-output to file
|
#1 |
New Member
-
Join Date: Nov 2013
Posts: 11
Rep Power: 12 |
Hello everyone,
I am writing a UFD to simulate a dynamic mesh in Fluent. The function itself works fine. But I want to include a data output, so I can work with the values (e.g. in Matlab). Besides, it's important for me to have a feedback what the function does because I'm still learning C / UDFs and need to understand the language. Here is my UDF: //================================== #include "udf.h" #include <stdio.h> DEFINE_CG_MOTION(movement,dt,vel,omega,time,dtime) { real t = CURRENT_TIME; real a,w; a=1.6; w=1.5; NV_S(vel, =, 0.0); if (!Data_Valid_P()) return; vel[0]=1; vel[1] = a * sin(w*t); printf("x-Vel: %f, y-Vel: %f",vel[0],vel[1]); // Works till here! // Data output: FILE *str; str = fopen ("Output.txt","w"); if(str==NULL) { printf("Error\n"); } fprintf (str,"x-vel: %f , y-vel: %f \n", vel[0], vel[1]); fclose (str); } //============================ The last part SHOULD create a "Output.txt" file and save all the velocities line by line in it. I hoped that the \n would work but it doesn't. The file appears and the LAST velocity entry is in line one. Here is my question: How can I make this UDF write each entry in a new line? I really hope you guys can help me. |
|
Tags |
data extract, data file, output data, udf exporting variable |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
patch error OF v2.2.2 mac | hewei | OpenFOAM Installation | 4 | November 30, 2013 16:55 |
Trouble compiling utilities using source-built OpenFOAM | Artur | OpenFOAM Programming & Development | 14 | October 29, 2013 10:59 |
[swak4Foam] swak4Foam-groovyBC build problem | zxj160 | OpenFOAM Community Contributions | 18 | July 30, 2013 13:14 |
ParaView Compilation | jakaranda | OpenFOAM Installation | 3 | October 27, 2008 11:46 |
DxFoam reader update | hjasak | OpenFOAM Post-Processing | 69 | April 24, 2008 01:24 |