CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF extern variable - mean time moment coefficient (https://www.cfd-online.com/Forums/fluent-udf/70096-udf-extern-variable-mean-time-moment-coefficient.html)

enry November 14, 2009 06:51

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 time step, and the program sum 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 "sum_cm" 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"

DEFINE_EXECUTE_AT_END(moment_coefficient)
{
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");
/*if(!BOUNDARY_FACE_THREAD_P(f_thread))
Error("Something wrong with your face id!\n");
*/

begin_f_loop(f,f_thread)
{
F_AREA(A,f,f_thread);
f_node_loop(f,f_thread,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;
}
}
end_f_loop(f,f_thread)


begin_f_loop(f_sh,f_thread_sh)
{
F_AREA(A,f_sh,f_thread_sh);

f_node_loop(f_sh,f_thread,n)
{
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;
}
}
end_f_loop(f_sh,f_thread_sh)

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


CAN ANYBODY HELP ME?!


All times are GMT -4. The time now is 14:26.