CFD Online Logo CFD Online URL
www.cfd-online.com
Home > Forums > Fluent UDF and Scheme Programming

UDF save data to a file!!

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   February 8, 2010, 13:48
Default UDF save data to a file!!
  #1
spk
New Member
 
Join Date: Aug 2009
Posts: 6
Rep Power: 2
spk is on a distinguished road
Hi guys,

I need help!!!
I'm not familiar with UDF. I compiled the Udf of cavitation rate which is found at udf manual. I add the last line (Message...) and everything is ok.
I can see the values of cavitation mass transfer rate at fluent window. But i want to save these values in a .txt file. How can i do this?

Thanks a lot!

#include
"udf.h"
#define c_evap 1.0
#define c_con 0.1
DEFINE_CAVITATION_RATE(user_cav_rate, c, t, p, rhoV, rhoL, mafV, p_v, cigma, f_gas, m_dot)
{
real p_vapor = *p_v;
real dp, dp0, source;
p_vapor += MIN(0.195*C_R(c,t)*C_K(c,t), 5.0*p_vapor);
dp = p_vapor - ABS_P(p[c], op_pres);
dp0 = MAX(0.1, ABS(dp));
source = sqrt(2.0/3.0*rhoL[c])*dp0;
if(dp > 0.0)
*m_dot = c_evap*rhoV[c]*source;
else
*m_dot = -c_con*rhoL[c]*source;
Message("Cavitation Mass Transfer Rate: %g\n",m_dot);
}
spk is offline   Reply With Quote

Old   February 9, 2010, 07:15
Default
  #2
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 508
Rep Power: 4
dmoroian is on a distinguished road
Code:
#include"udf.h"
#define c_evap 1.0
#define c_con 0.1
DEFINE_CAVITATION_RATE(user_cav_rate, c, t, p, rhoV, rhoL, mafV, p_v, cigma, f_gas, m_dot)
{
   FILE *pf;
   real p_vapor = *p_v;
   real dp, dp0, source;
   p_vapor += MIN(0.195*C_R(c,t)*C_K(c,t), 5.0*p_vapor);
   dp = p_vapor - ABS_P(p[c], op_pres);
   dp0 = MAX(0.1, ABS(dp));
   source = sqrt(2.0/3.0*rhoL[c])*dp0;
   if(dp > 0.0)
      *m_dot = c_evap*rhoV[c]*source;
   else
      *m_dot = -c_con*rhoL[c]*source;

   Message("Cavitation Mass Transfer Rate: %g\n",m_dot);
   
   if(NULL == (pf = fopen("bubu.txt","a")))
      Error("Could not open file for append!\n");
   
   fprintf(pf,"%e\n",m_dot);
   fclose(pf);
}
dmoroian is offline   Reply With Quote

Old   February 9, 2010, 13:39
Default
  #3
spk
New Member
 
Join Date: Aug 2009
Posts: 6
Rep Power: 2
spk is on a distinguished road
Thanks friend!!!
It works!!!
spk is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF Getting data from file jreig FLUENT 0 July 10, 2009 08:07
Working directory via command line Luiz CFX 3 March 31, 2009 17:52
Smallest binary file format to save large data Zonexo Main CFD Forum 2 June 2, 2008 20:25
Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing: blockMesh 10 April 2, 2007 14:00
UDF (write a data file) problem lichun Dong FLUENT 2 July 29, 2005 11:39


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