CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   UDF extern variable - mean time moment coefficient (

enry November 14, 2009 07:56

UDF extern variable - mean time moment coefficient
Hi ! I wanna calculate the mean time moment coefficient in an unsteady simulation.
I write a function as DEFINE_EXECUTE_AT_END in order to have the moment coefficient at the end of every time step, and the program sums cm every time step.
So I have the sum of every cm for all time step at the end of simulation.
The problem is: how can I declare the variable "int_moment" (i.e. the moment sum )as an extern variable, in order to divide it at the end of the simulation?
I try to write the next program:

#include "udf.h"
#include "extfile.h"

real NV_VEC(A);
real moment = 0., x_nodo = 0., y_nodo = 0.;
int IDblades = 10, IDblades_sh = 14;
int n;
face_t f,f_sh;
Thread *f_thread, *f_thread_sh;
Domain *d;
Node *node;

d = Get_Domain(1); /* Default Interior ID */

if(NULL == d)
printf("Something wrong with your domain id!\n");

f_thread = Lookup_Thread(d, IDblades);
f_thread_sh = Lookup_Thread(d,IDblades_sh);

if(NULL == f_thread)
printf("Something wrong with your face id!\n");

if(NULL == f_thread_sh)
printf("Something wrong with your face shadow id!\n");
Error("Something wrong with your face id!\n");

node = F_NODE(f,f_thread,n);
x_nodo = NODE_X(node);
y_nodo = NODE_Y(node);
moment += F_P(f,f_thread) * A[1] * x_nodo - F_P(f,f_thread) * A[0] * y_nodo;


node = F_NODE(f_sh,f_thread,n);
x_nodo = NODE_X(node);
y_nodo = NODE_Y(node);
moment += F_P(f_sh,f_thread_sh) * A[1] * x_nodo - F_P(f_sh,f_thread_sh) * A[0] * y_nodo;

moment = moment/2;

int_moment += moment;

printf("\n MOMENT = %g \n", moment);
printf("\n INT MOMENT = %g \n", int_moment);

where the extfile.h is the following:

#include "udf.h"

extern real int_moment = 0.;

I compile it as "compiled UDF", but Fluent reports some errors, and the most dangerous is the following:

moment_coefficient.c:2:21: error: extfile.h: No such file or directory

PS. If I replace #include "extfile.h" with real int_moment = 0.; it works!



All times are GMT -4. The time now is 21:03.