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

Beginner help, coordinate udf with output file

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 20, 2014, 05:16
Default Beginner help, coordinate udf with output file
  #1
New Member
 
Nick
Join Date: Feb 2014
Posts: 5
Rep Power: 12
nb92 is on a distinguished road
Hi, I am a beginner in both Fluent and C++.
I am trying to write a UDF for my project, it is a 2D axi-symmetric VOF model for a droplet impact; see link at the end of the post for the domain. The symmetry axis is my x axis and the wall my y axis.

The UDF will be used to calculate droplet height and the wall contact radius at every time step.
I need to find the coordinates of two cells at each time step. Both cells will have a volume fraction of between 0 and 1 (they lie at the interface).
One of the cells will have an x coordinate of 0, the other a y coordinate of 0.

The output file must contain the time step number, current time progressed, the x and then the y coordinates.

I am sure my UDF is not correct, I am unsure whether I have used suitable macros for the task, so would like advice on what I have not included or what needs changing.

If possible please can you explain in layman's terms.

Thanks in advance
Nick

Quote:
#include "udf.h"
#include "mem.h"

DEFINE_PROFILE(xc, thread, position)
{
fp=fopen("data.txt","a"); /*opens file; data will be added on the end. 'a' stands for append*/
begin_c_loop_all(c,t); /*loops all cells*/
{
cell_t c0 = F_C0(f,t); /*sets desired volume fraction to 0.5, i.e. the interface cells*/
if (C_VOF(c0,t) = 0.5);
{
C_CENTROID(xc,c,t); /*find coordinate position of cell with desired volume fraction*/
if (xc[1] == 0 ); /*sets y coordinate equal to zero*/
x=xc[0]; /*names x coordinate*/
else
C_CENTROID(xc,c,t); /*find coordinate position of cell with desired volume fraction*/
if (xc[0] == 0 ); /*sets x coordinate equal to zero*/
y=xc[1]; /*names y coordinate*/
}
fprintf(fp,"Time Step %d", t, x, y); /*appends file with time step number, time, x coordinate and then y coordinate*/
}
end_c_loop_all(c,t); /*closes cell loop*/
fclose(fp); /*closes file*/
}
http://www.cfd-online.com/Forums/att...hase-image.jpg
nb92 is offline   Reply With Quote

Reply

Tags
2 dimensional, beginner, coordinate, output file, vof


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
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 04:30
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error FerdiFuchs OpenFOAM Community Contributions 27 April 16, 2014 16:14
[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


All times are GMT -4. The time now is 13:20.