CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF force on a face (http://www.cfd-online.com/Forums/fluent-udf/70079-udf-force-face.html)

enry November 13, 2009 14:22

UDF force on a face
 
Hi, I have a question:
I wanna calculate the entire force on a blade with Fluent for linux. The problem is a 2d rotating blade. Blade are modelling as an edge (and edge-shadow).
I write this UDF (It's my first UDF!!!! :-S ):

#include "udf.h"

DEFINE_ON_DEMAND(force_on_demand)
{
real force = 0.;
real NV_VEC(A);
int IDblades = 10;

face_t f;
Thread *f_thread;
Domain *d;

d = Get_Domain(3); /* Fluid ID */
f_thread = Lookup_Thread(d, IDblades);


begin_f_loop(f,f_thread)
{
F_AREA(A,f,f_thread);
force += F_P(f,f_thread) * NV_MAG(A);
}
end_f_loop(f,f_thread)

printf("\n FORCE = %g \n", force); */
}

but Fluent stamp an error :
fluent.6.3.26 received a fatal signal (segmentation violation)
Error Object: #f

Can somebody help me??!?!?!??!?!
Thanks!

dmoroian November 13, 2009 16:57

Check for errors
 
Try to replace
Code:

d = Get_Domain(3); /* Fluid ID */
f_thread = Lookup_Thread(d, IDblades);

with
Code:

d = Get_Domain(3); /* Fluid ID */

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

f_thread = Lookup_Thread(d, IDblades);

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

But there is an already implemented force reporting facility accessible through the menus (report-forces).

enry November 13, 2009 18:00

HI dmoroian;

I replace it, but Fluent finds an error in:

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

So I write replace it only with:

d = Get_Domain(3); /* Fluid ID */

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

f_thread = Lookup_Thread(d, IDblades);

if(NULL == f_thread)
Error("Something wrong with your face id!\n");
This code runs on Fluent, but before running Fluent show this Error:


Error: C:\Documents and Settings\Enrico\Desktop\UDF windows\define_on_demand.c: line 32: function "CX_Primitive_Error" not found (pc=39).
Error: C:\Documents and Settings\Enrico\Desktop\UDF windows\define_on_demand.c: line 32: function "CX_Primitive_Error" not found (pc=67).
.entry




Of course I can do it through menu, but I have to calculate the mean-time moment coefficient on the blades, so I'm starting with easier code. (Do you know if there is any way to do it through menu?).
Thanks!

enry November 13, 2009 18:17

HI! Sorry... I'm a beginner with UDF! Now I write this code :





#include "udf.h"

DEFINE_ON_DEMAND(force_on_demand)
{
real force = 0.;
real NV_VEC(A);
int IDblades = 10;

face_t f;
Thread *f_thread;
Domain *d;

d = Get_Domain(3); /* Fluid ID */

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


f_thread = Lookup_Thread(d, IDblades);

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


begin_f_loop(f,f_thread)
{
F_AREA(A,f,f_thread);
force += F_P(f,f_thread) * NV_MAG(A);
}
end_f_loop(f,f_thread)

/*printf("\n FORCE = %g \n", force);*/
}



Then I compile it (Define User-Defined Function Interpreted), and Fluent doesn't report any errors.
When I do "Execute on demand" Fluent report this message:

Something wrong with your domain id!
Something wrong with your face id!

Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()






SO... something wrong! .... :-S

enry November 13, 2009 18:27

I replace ID fluid domain with ID default-interior domain, and Fluent report FORCE!!!! =)

I have another question: do you know how can I calculate the moment-coefficient of the blade? ( the blade is a 1d blade, so I have also the blade-shadow). I have to calculate it in order to get the mean-time moment coefficient of the blade.

THANKS! ;)

qiyang860908 November 15, 2009 04:59

what is the difference between the cavitation model and the evaporation UDF?
 
I want to the process of the evaporation of water .So fluent may be a good tool.The problem is there is a interior cavitation model in fluent,and you can also write your own C files ,in other words ,the UDF program.BUt is there any difference between them?

enry November 15, 2009 06:29

Sorry but, I can't answer... I never solve problem like that. ;)

I have a question for you. Is it possible to match to the VISCOUS FORCE by UDF script?
I need to sum viscous force and pressur force. The command for pressur force is F_P(..), are there any command for viscous force?

O.D.Y. November 15, 2009 07:28

you can let Fluent caluclate the moment-coefficient -> monitors
but you have to set proper reference values and the depth of the blade before....

enry November 15, 2009 08:35

Yes, of course I can do that through Moment-coefficient - monitors, but I need Moment coefficient in a UDF in order to obtain the time average cm.
So I wrote a UDF function and I'm able to calculate the PRESSURE force through the command F_P (then I multiply F_P * moment arm = MOMENT), but I'm unable to calculate the VISCOUS force.
Do you know how I can do it?

enry November 15, 2009 11:53

I solve my own problem with

Wall_Shear_Force_X = F_STORAGE_R_N3V(f,f_thread,SV_WALL_SHEAR)[0];
Wall_Shear_Force_Y = F_STORAGE_R_N3V(f,f_thread,SV_WALL_SHEAR)[1];

( I find these funcions on the web; they are NOT on UDF manual!!!! )

Atze March 23, 2011 11:48

Hi enry,

i have to calculate pressure moment on my body. I've written
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
F_AREA(A,f,t);
NV_D(force, = ,A[0]*F_P(f,t),A[1]*F_P(f,t),0);
NV_CROSS(Mp,x,force);
NV_V(Mp_t,+=,Mp);
}
end_f_loop(f,t)

but something is wrong.... how did you calculate your pressure moments?

thanks


All times are GMT -4. The time now is 18:10.