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

Not able to interpret UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 15, 2007, 05:13
Default Not able to interpret UDF
  #1
Prasad
Guest
 
Posts: n/a
I am not able to Interpret the following UDF in Fluent6.2.16 on Unix. Error seems to be in FILE *fp. And it gives a message that line 14: syntax error (ie FILE *fp) and line 15: undeclared fp (ie fp = fopen...). Can some one let me know how I should modify this. Thanks in advance. (This UDF is intended to print out the data for the boundary at the end of run for steady state. In future I want to modify it to do the same for every time step for transient case)

#include "udf.h"

DEFINE_EXECUTE_AT_END(acoustic)

{

face_t f;

cell_t c0;

Thread *t0;

Domain *d;

real u, v, w, psta, ke, epsi;

real x[3];

Thread *t_boundary;

d = Get_Domain(1);

t_boundary = Lookup_Thread(d, 1);

/* Change this number to the ZONE-ID of the BC for which data is needed*/

FILE *fp;

fp = fopen("acoustic.out", "w");

fprintf(fp, "x y z u v w psta Turb-KE Epsilon \n");

begin_f_loop(f, t_boundary)

{

F_CENTROID(x, f, t_boundary);

c0 = F_C0(f, t_boundary);

t0 = THREAD_T0(t_boundary);

u = C_U(c0, t0);

v = C_V(c0, t0);

w = C_W(c0, t0);

psta = C_P(c0, t0);

ke = C_K(c0, t0);

epsi = C_D(c0, t0);

fprintf(fp, "%8.3d %8.3d %8.3d %8.3d %8.3d %8.3d %8.3d %8.3d %8.3d\n", x[1], x[2], x[3], u, v, w, psta, ke, epsi);

} end_f_loop(f, t_boundary) fclose(fp); }

  Reply With Quote

Old   August 15, 2007, 09:44
Default Re: Not able to interpret UDF
  #2
Prasad
Guest
 
Posts: n/a
I could figure out what was the problem. Please find below the correct UDF.. in some one is interested, can use it.. It writes out the data for boundary after each iteration in steady state (run it with UDF just for 1 iteration if you need data). It also writes the data for transient for every time step. but the file is over written every time.. To avoid it you can append to the same file or write a small C program to change the file with each timestep...

#include "udf.h"

DEFINE_EXECUTE_AT_END(acoustic)

{

face_t f;

cell_t c0;

Thread *t0;

Domain *d;

real u, v, w, psta, ke, epsi;

real x[ND_ND];

Thread *t_boundary;

int curr_ts, n;

FILE *fp;

n = 0;

d = Get_Domain(1);

t_boundary = Lookup_Thread(d, 15);

/* Change this number to the ZONE-ID of the BC for which data is needed*/

curr_ts = N_TIME; fp = fopen("acoustic.out", "w");

fprintf(fp, "Time Step = %d \n", curr_ts);

fprintf(fp, " S.No. x y z u v w psta Turb-KE Epsilon \n");

begin_f_loop(f, t_boundary)

{

n++;

F_CENTROID(x, f, t_boundary);

c0 = F_C0(f, t_boundary);

t0 = THREAD_T0(t_boundary);

u = C_U(c0, t0);

v = C_V(c0, t0);

w = C_W(c0, t0);

psta = C_P(c0, t0);

ke = C_K(c0, t0);

epsi = C_D(c0, t0);

fprintf(fp, "%7d %12.5f %12.5f %12.5f %12.5f %12.5f %12.5f %12.5f %12.5f %12.5f\n", n, x[0], x[1], x[2], u, v, w, psta, ke, epsi);

}

end_f_loop(f, t_boundary)

fclose(fp);

}

  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
UDF interpret error with "C_CENTROID" Jinfeng Fluent UDF and Scheme Programming 6 November 6, 2020 16:38
interpret several UDF eddiegolpesar FLUENT 0 November 1, 2010 09:23
interpret or compile an UDF (emergency) Lotfi FLUENT 1 August 26, 2007 13:58
Interpret three UDF for property Atsu FLUENT 4 April 22, 2006 16:04
UDF Interpret - Syntax Error Leonard FLUENT 1 October 22, 2005 11:06


All times are GMT -4. The time now is 22:37.