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

UDF extern variable - mean time moment coefficient

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 14, 2009, 07:56
Unhappy UDF extern variable - mean time moment coefficient
  #1
Senior Member
 
Herman
Join Date: Nov 2009
Posts: 122
Rep Power: 17
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"

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


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



CAN ANYBODY HELP ME?!



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


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