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

How can I save the all data to txt file?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 22, 2016, 23:51
Default How can I save the all data to txt file?
  #1
New Member
 
S.J Chung
Join Date: Mar 2015
Posts: 6
Rep Power: 11
ssavi22 is on a distinguished road
Hi guys. I always thank you for your help.

I learn lots of info. and techniques for udf.

However, I have one problem.

I finished calculating cell volumes and centroids.

This is my code
=====================================
#include "udf.h"

DEFINE_ON_DEMAND(demo_calc)
{
real volume, vol_tot;
Domain* domain;
Thread* t;
cell_t c;
real x[ND_ND];
real y, z;

vol_tot = 0.;
domain = Get_Domain(1);

thread_loop_c(t, domain)
{
begin_c_loop(c, t)
{
volume = C_VOLUME(c, t);
Message("Cell Volume=%g\n", volume);
vol_tot += volume;
C_CENTROID(x, c, t);
y = x[1];
z = x[2];
Message("x_centroid=%g, y_centroid=%g, z_centroid=%g\n", x[0], x[1], x[2]);
}
end_c_loop(c, t)
}
Message("Total Volume=%g\n", vol_tot);
}
============================================

But, I cannot find method which save these data (each cells volume, centroid coordinates) to txt file.

Naturally, it is possible by mouse (copy and paste to notepad)

But I want to know how can i automate this result.

Waiting your help
ssavi22 is offline   Reply With Quote

Old   May 23, 2016, 04:11
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
From memory:

Code:
#include "udf.h" 

DEFINE_ON_DEMAND(demo_calc)
{
real volume, vol_tot;
Domain* domain;
Thread*	t;
cell_t c;
real x[ND_ND];
real y, z;
file *foutput;

vol_tot = 0.;
domain = Get_Domain(1); 
foutput = fopen("outputfile.txt",a);

thread_loop_c(t, domain)
{
begin_c_loop(c, t)
{
volume = C_VOLUME(c, t);
fprintf(foutput,"Cell Volume=%g\n", volume);
vol_tot += volume;
C_CENTROID(x, c, t);
y = x[1];
z = x[2];
fprintf(foutput,"x_centroid=%g, y_centroid=%g, z_centroid=%g\n", x[0], x[1], x[2]);
}
end_c_loop(c, t)
}
fprintf(foutput,"Total Volume=%g\n", vol_tot);
fclose(foutput);
}
ssavi22 likes this.

Last edited by pakk; May 23, 2016 at 06:25.
pakk is offline   Reply With Quote

Reply

Tags
.txt, result to txt, text file, udf


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] groovyBC in openFOAM-2.0 for parabolic velocity bc ofslcm OpenFOAM Community Contributions 25 March 6, 2017 11:03
[OpenFOAM.org] Error creating ParaView-4.1.0 OpenFOAM 2.3.0 tlcoons OpenFOAM Installation 13 April 20, 2016 18:34
[swak4Foam] Problem installing swak_2.x for OpenFoam-2.4.0 towanda OpenFOAM Community Contributions 6 September 5, 2015 22:03
[swak4Foam] Error bulding swak4Foam sfigato OpenFOAM Community Contributions 18 August 22, 2013 13:41
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 14:59


All times are GMT -4. The time now is 07:10.