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

UDF help

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 25, 2011, 05:53
Red face UDF Done
  #1
New Member
 
jason
Join Date: May 2011
Location: uk
Posts: 10
Rep Power: 15
zhaolinchen is on a distinguished road
I am simulating a wing using fluent and want to output all the aerodynamic forces into a txt or dat file, does anyone know which udf command shoud i use. I know command "message " only shows the forces on the windows, so anyone knows please give me a hand, many thanks

Last edited by zhaolinchen; May 27, 2011 at 06:40.
zhaolinchen is offline   Reply With Quote

Old   May 26, 2011, 13:56
Default
  #2
New Member
 
jason
Join Date: May 2011
Location: uk
Posts: 10
Rep Power: 15
zhaolinchen is on a distinguished road
Ok i made this script to integrate the forces however it only works as a interpreted UDF and not a compiled UDF. Any ideas?

/************************************************** ******************
************************************************** *******************/
#include "udf.h"
#define airfoil_tid 15 /* Zone ID of airfoil */
#define domain_zone 1
float P_i;
float A_i;
float U_i;
float V_i;
float W_i;
float Fpx;
float Fpy;
float A[3];
Domain *domain;
face_t f; /* airfoil surface*/
Thread *t;/* wing thread*/
DEFINE_ADJUST(forces,domain)
{
domain = Get_Domain(domain_zone);
t = Lookup_Thread(domain, airfoil_tid);
Fpx=0;
Fpy=0;
begin_f_loop(f,t)
{

F_AREA(A,f,t);
P_i = F_P(f,t);
Fpx += P_i*A[0];
Fpy += P_i*A[1];
}
end_f_loop(f,t)


printf("forces are: %f\n,%f\n", Fpx,Fpy);
}
zhaolinchen is offline   Reply With Quote

Old   May 31, 2011, 06:27
Default
  #3
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
The normal way is to include <stdio.h> when you want to use printf. However, try to use Message, instead of printf, it takes exactly the same arguments.
You have to be aware, though, that your udf will not work correctly in parallel (due to the face summation).
dmoroian is offline   Reply With Quote

Old   May 31, 2011, 08:52
Default
  #4
New Member
 
jason
Join Date: May 2011
Location: uk
Posts: 10
Rep Power: 15
zhaolinchen is on a distinguished road
Quote:
Originally Posted by dmoroian View Post
The normal way is to include <stdio.h> when you want to use printf. However, try to use Message, instead of printf, it takes exactly the same arguments.
You have to be aware, though, that your udf will not work correctly in parallel (due to the face summation).
thanks dmoroian, do you have any ideals about the commands for parallel? many thanks
zhaolinchen is offline   Reply With Quote

Old   May 31, 2011, 09:09
Default short example
  #5
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Code:
#include "udf.h"
#include "prf.h"
#define airfoil_tid  15    /* Zone ID of airfoil */
#define domain_zone  1
float P_i;
float A_i;
float U_i;
float V_i;
float W_i;
float Fpx;
float Fpy;
float A[3];
Domain *domain;
face_t f; /* airfoil surface*/
Thread *t;/* wing thread*/
DEFINE_ADJUST(forces,domain)
{
#if !RP_HOST
   domain = Get_Domain(domain_zone);   
   if(NULL == (t = Lookup_Thread(domain, airfoil_tid)))
      Error("Something is wrong with the thread:0x%x\n",t);
   Fpx=0;
   Fpy=0;                
   begin_f_loop(f,t)
   {
      
      F_AREA(A,f,t);
      P_i = F_P(f,t);
      Fpx += P_i*A[0];
      Fpy += P_i*A[1]; 
   }      
   end_f_loop(f,t)

   Fpx = PRF_GRSUM1(Fpx);
   Fpy = PRF_GRSUM1(Fpy);
 
   Message0("forces are: %f\n,%f\n", Fpx,Fpy);
}
dmoroian is offline   Reply With Quote

Old   June 2, 2011, 09:46
Default
  #6
New Member
 
jason
Join Date: May 2011
Location: uk
Posts: 10
Rep Power: 15
zhaolinchen is on a distinguished road
Hi dmoroian, thanks for the help, I was trying to get the shear stress along the airfoil, however, got some problems when i check the values: code shows below:
/************************************************** ******************
UDF for integrating pressure forces and displaying it in the
console
************************************************** *******************/
#include "udf.h"
#include "metric.h"
#include "mem.h"
#define airfoil_tid 13 /* Zone ID of airfoil */
#define domain_zone 1
float DUDX,DUDX1;
float pressure;
float DPDX1;
int counter;
int nface;
int a;
int b;
int zone_ID;
Domain *domain;
face_t f; /* airfoil surface*/
cell_t c;
cell_t c0;
Thread *t;
Thread *t0;
Thread *t1;

DEFINE_ADJUST(forces,domain)
{

//if (!Data_Valid_P()) return;
domain = Get_Domain(domain_zone);
t = Lookup_Thread(domain, airfoil_tid);
//zone_ID = THREAD_ID(t); /*out put the airfoil thread number*/
//Message("zone_ID: %d\n",zone_ID);
//counter = 0;
//if(b = BOUNDARY_FACE_THREAD_P(t));
//{Message("boundary: %d\n", b);
//}
begin_f_loop(f,t)
{


t0 = F_C0_THREAD(f,t);
c0 = F_C0(f,t);
nface = C_NFACES(c0,t0);
DUDX = C_DUDX(c0,t0);/* seems problems come from here, which not match to the fluent post-process values, see the values at the bottom*/
pressure = C_P(c0,t0);/*also the pressure force is not right as well*/
a = FLUID_THREAD_P(t0); /* check whether t0 is a thread in the domain*/

Message("DUDX: %e,%d,%d,%e\n",DUDX,nface,a,pressure);


}
end_f_loop(f,t)

begin_c_loop(c,t)
{
//if (BOUNDARY_FACE_THREAD_P(t))
// {
DPDX1 = C_P_G(c,t)[0];
//t1 = C_FACE_THREAD(c,t,0);
// c = C_FACE(c,t,0);

//Message("DPDX = %e\n", DPDX1);
// }
}
end_c_loop(c,t)

}
********************************************
values from the codes:
this colume is pressure force at wall
DUDX: 3.746866e+000,4,1,-1.851858e+001
DUDX: -1.253381e+000,4,1,-2.228758e+001
DUDX: -4.220629e+000,4,1,-1.864905e+001
DUDX: -2.343874e+000,4,1,1.658862e+001
DUDX: -9.178568e+001,4,1,1.796235e+001
DUDX: -2.398940e+000,4,1,1.648010e+001
DUDX: -5.881291e+000,4,1,-2.434795e+001
DUDX: -5.239357e+000,4,1,-2.471040e+001
DUDX: -5.963025e+000,4,1,-2.434571e+001
DUDX: 4.096624e+000,4,1,-1.958149e+001
DUDX: -1.208462e+000,4,1,-2.364586e+001
DUDX: -4.264113e+000,4,1,-1.990714e+001

***********************************************
forces from the fluent write file, from plots of du/dx--x and pressure--x
pressure du/dx
-20.3986 1.24743
-20.4641 -2.73684
-21.4992 -5.42141
-24.5353 -5.63565
-24.534 -5.66827
-22.1281 -5.43965
-21.7746 -2.73628
-21.6116 1.44466
-1.54782 0.625361
17.2248 -47.0923
17.2791 -47.0647
-0.960895 0.08465

****************************************
below is the case file:
element_test.zip
zhaolinchen is offline   Reply With Quote

Old   June 3, 2011, 02:59
Default
  #7
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
I'm sorry, but I don't really understand your problem. It seems different than the first one above.
dmoroian is offline   Reply With Quote

Old   August 31, 2011, 01:57
Default
  #8
Member
 
Nirav
Join Date: Jul 2011
Posts: 43
Rep Power: 15
niravtm007 is on a distinguished road
Send a message via Skype™ to niravtm007
Hii friendss.. i have worked out with 2d udf for parabolic velocity inlet.
please help me how this code will change with 3d. i wanna know how will be the equation considering 3rd dimmension.
as in 2d we have V(x)=Vmax- y^2/(disatnce from centre in y direction )^2 * Vmax.
please help me.
also give suggestion how to work out on sinusoidal inlet udf.
thanks in advance
niravtm007 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
Dynamic Mesh UDF Qureshi FLUENT 7 March 23, 2017 08:37
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 22:38
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 05:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


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