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

UDF for data export?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 2, 2014, 18:35
Default UDF for data export?
  #1
New Member
 
anonymous
Join Date: Mar 2014
Posts: 5
Rep Power: 12
Topspin is on a distinguished road
I want to export heat flux from a panel in a flat plate flow where the temperature of the plate varies with time.

The ASCII automatic data export tool in Fluent is nice, but it creates a new file for every timestep.

Is there a way to write a UDF to export the data from every timestep into a single file in this manner?:

time1|temperature1|vector1 of heat flux from cell center
time2|temperature2|vector2 of heat flux from cell center
...
time100|temperature100|vector100 of heat flux from cell center

If there is could I be pointed to a similar example?
Topspin is offline   Reply With Quote

Old   April 4, 2014, 15:59
Default
  #2
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Hi,

Try this udf, it works in serial, you will have to modify the code if you work in parallel:

Code:
#include "udf.h"
DEFINE_EXECUTE_AT_END(execute_at_end)
{
FILE *data;
real coord[ND_ND];
real temperature;
real time = CURRENT_TIME;
real timestep = N_TIME;
Domain *d;
Thread *t;
cell_t c;
d = Get_Domain(1);

if (timestep == 1)
     {
     data = fopen("data.txt", "w");
     fprintf(data, "time x y z temperature\n");
     }
else
     data = fopen("data.txt", "a");

//fprintf(data, "current time is %g s\n", time);

thread_loop_c(t,d)
     {
     begin_c_loop(c,t)
          {
          C_CENTROID(coord,c,t);
          temperature = C_T(c,t);
          fprintf(data, "%g %g %g %g %f\n", time, coord[0], coord[1], coord[2], temperature);
          }
     end_c_loop(c,t)
     }
fclose(data);
}
macfly is offline   Reply With Quote

Old   April 4, 2014, 16:52
Default
  #3
New Member
 
anonymous
Join Date: Mar 2014
Posts: 5
Rep Power: 12
Topspin is on a distinguished road
Thank you I will try it very soon! Right now I've been using Matlab to automate the process of pulling data from each timestep file, but this is a much more elegant solution.
Topspin 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
Help! Delete the UDM codes in the UDF Messi Fluent UDF and Scheme Programming 2 January 28, 2014 10:01
udf for multiple reaction alihosseini63 Fluent UDF and Scheme Programming 0 July 4, 2013 19:37
Help me to check my UDF Liufeng_ustb Fluent UDF and Scheme Programming 2 May 7, 2013 11:25
udf to export the pressure on a surface thread every timestep? zeitistgeld Fluent UDF and Scheme Programming 0 April 30, 2009 05:10
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


All times are GMT -4. The time now is 18:19.