CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF extern variable - mean time moment coefficient

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Search this Thread Display Modes
Old   November 14, 2009, 06:56
Unhappy UDF extern variable - mean time moment coefficient
Senior Member
Join Date: Nov 2009
Posts: 122
Rep Power: 16
enry is on a distinguished road
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!


enry is offline   Reply With Quote


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
TimeVaryingMappedFixedValue irishdave OpenFOAM Running, Solving & CFD 32 June 16, 2021 06:55
Transient simulation not converging skabilan OpenFOAM Running, Solving & CFD 14 December 16, 2019 23:12
Time Averaged Moment Coefficient prasad84 FLUENT 0 October 16, 2009 14:27
Differences between serial and parallel runs carsten OpenFOAM Bugs 11 September 12, 2008 11:16
Modeling in micron scale using icoFoam m9819348 OpenFOAM Running, Solving & CFD 7 October 27, 2007 00:36

All times are GMT -4. The time now is 04:12.