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

Writing txt file in an UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 2, 2014, 13:11
Default Writing txt file in an UDF
  #1
New Member
 
Sayan Bose
Join Date: Apr 2013
Posts: 17
Rep Power: 13
sayan_bose is on a distinguished road
I want to write the particle accelerations in a separate txt file, in a DPM_BODY_FORCE UDF, by performing a file operation, to do that I added this few line in the DPM body force UDF, which logically should have worked.

But after loading the udf, when I am executing calculation fluent is getting closed when the particle update is about to happen, and the txt files created doe not have any thing in them, they are just blank.

This is the code, which just show the file operation part along with the conventional DPM body force codes, please tell me where I have gone wrong and what should I do to correct it.

DEFINE_DPM_BODY_FORCE(particle_body_force,p,i)
{
FILE *x_comp;
FILE *y_comp;
FILE *z_comp;

real bforce,bforcex,bforcey,bforcez;

x_comp=fopen("x-comp.txt","w");
y_comp=fopen("y-comp.txt","w");
z_comp=fopen("z-comp.txt","w");

x=P_POS(p)[0]-xmag;
y=P_POS(p)[1]-ymag;
z=P_POS(p)[2]-zmag;
modr=............................................. ........
................................Denomx;


if(i==0.)

{
bforcex=bforce*unitsx;
Ax = bforcex/P_MASS(p);
fprintf(x_comp,"%g\t\n",Ax);

}
else if(i==1.)
{
bforcey=bforce*unitsy;
Ay = bforcey/P_MASS(p);
fprintf(y_comp,"%g\t\n",Ay);

}
else if(i==2.)
{
bforcez=bforce*unitsz;
Az = bforcez/P_MASS(p);
fprintf(z_comp,"%g\t\n",Az);

}

return((bforce)/P_MASS(p));

fclose(x_comp);
fclose(y_comp);
fclose(z_comp);


}
sayan_bose is offline   Reply With Quote

Old   February 3, 2014, 08:52
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
It can be that you still have the files opened in some editor (notepad or whatever). I think I did that once and then Fluent also shut down without warning.
pakk 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
[Other] mesh airfoil NACA0012 anand_30 OpenFOAM Meshing & Mesh Conversion 13 March 7, 2022 18:22
how to calculate mass flow rate on patches and summation of that during the run? immortality OpenFOAM Post-Processing 104 February 16, 2021 09:46
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 keepfit ParaView 60 September 18, 2013 04:23
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 12:44
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 15:00


All times are GMT -4. The time now is 00:33.