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

UDF force on a face

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

Reply
 
LinkBack Thread Tools Display Modes
Old   November 13, 2009, 14:22
Unhappy UDF force on a face
  #1
Senior Member
 
Herman
Join Date: Nov 2009
Posts: 122
Rep Power: 7
enry is on a distinguished road
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!
enry is offline   Reply With Quote

Old   November 13, 2009, 16:57
Default Check for errors
  #2
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
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).
dmoroian is offline   Reply With Quote

Old   November 13, 2009, 18:00
Default
  #3
Senior Member
 
Herman
Join Date: Nov 2009
Posts: 122
Rep Power: 7
enry is on a distinguished road
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 is offline   Reply With Quote

Old   November 13, 2009, 18:17
Default
  #4
Senior Member
 
Herman
Join Date: Nov 2009
Posts: 122
Rep Power: 7
enry is on a distinguished road
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 is offline   Reply With Quote

Old   November 13, 2009, 18:27
Red face
  #5
Senior Member
 
Herman
Join Date: Nov 2009
Posts: 122
Rep Power: 7
enry is on a distinguished road
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!
enry is offline   Reply With Quote

Old   November 15, 2009, 04:59
Question what is the difference between the cavitation model and the evaporation UDF?
  #6
New Member
 
qiyang
Join Date: Nov 2009
Posts: 3
Rep Power: 7
qiyang860908 is on a distinguished road
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?
qiyang860908 is offline   Reply With Quote

Old   November 15, 2009, 06:29
Default
  #7
Senior Member
 
Herman
Join Date: Nov 2009
Posts: 122
Rep Power: 7
enry is on a distinguished road
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?
enry is offline   Reply With Quote

Old   November 15, 2009, 07:28
Default
  #8
Member
 
O.D.Y.'s Avatar
 
Join Date: Mar 2009
Posts: 49
Rep Power: 8
O.D.Y. is on a distinguished road
you can let Fluent caluclate the moment-coefficient -> monitors
but you have to set proper reference values and the depth of the blade before....
O.D.Y. is offline   Reply With Quote

Old   November 15, 2009, 08:35
Default
  #9
Senior Member
 
Herman
Join Date: Nov 2009
Posts: 122
Rep Power: 7
enry is on a distinguished road
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 is offline   Reply With Quote

Old   November 15, 2009, 11:53
Default
  #10
Senior Member
 
Herman
Join Date: Nov 2009
Posts: 122
Rep Power: 7
enry is on a distinguished road
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!!!! )
enry is offline   Reply With Quote

Old   March 23, 2011, 11:48
Default
  #11
Member
 
Join Date: Apr 2010
Location: Pisa / Italy
Posts: 57
Rep Power: 7
Atze is on a distinguished road
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
Atze is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import netgen mesh to OpenFOAM hsieh Open Source Meshers: Gmsh, Netgen, CGNS, ... 32 September 13, 2011 05:50
BlockMeshmergePatchPairs hjasak OpenFOAM Native Meshers: blockMesh 11 August 15, 2008 07:36
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55
Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Native Meshers: blockMesh 10 April 2, 2007 14:00
Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 2 July 15, 2005 04:15


All times are GMT -4. The time now is 01:27.