CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   How to access all nodes and pressures. (https://www.cfd-online.com/Forums/fluent-udf/86084-how-access-all-nodes-pressures.html)

sutthinan March 14, 2011 05:51

How to access all nodes and pressures.
 
Hi everyone;

I need to calculate the deformation of geometry. The pressure will effect on the geometry, deform=(xx[j+1]-xx[j])*presur[j]*log(fabs((xx[ii+1]+xx[ii])/2.-xx[j])*fabs((xx[ii-1]+xx[ii])/2.-xx[j])) ,so I need to access all nodes and keep the pressure and x-coordinates in P[] , x[] for calculatiog the deformation equation.

This is my UDF ( it is not working, when i run, it will show the message "fetal error"


#include "udf.h"
DEFINE_GEOM(deform_ball, domain, dt, position)
{
Thread *t;
face_t f;
/*real xx[1000];
real yy[1000];
real presur[1000]; */
real x[ND_ND];
real NV_VEC (A);
real ho=0.01, hc, def,e=345230000000.0, wref, deform,n;
real r=10.0,b=0.00039,ap=800000000.0, vb=1.0, vp=0.3;
int max,i,j,ii,size;
node *n;
n=F_NODE(face, thread, n);
real *px=NULL;
real *xx=NULL;
real *yy=NULL;
px=(real*)malloc(n*sizeof(real));
xx=(real *)malloc(n*sizeof(real));
yy=(real *)malloc(n*sizeof(real));

i=0.;
begin_f_loop (f, t)
{
F_CENTROID(x,f,t);
xx[i]=x[0];
yy[i]=x[1];
presur[i]=F_P(f, t);
max=i;
i=i+1;
}
end_f_loop (f, t);
i=0.;
j=0.;
ii=0.;
for(j=0;j<max;j++)
{
if (position[0]==xx[j]) goto start;
}
start:
for(i=0;i< max;i++)
{
ii=i;
if (i==max)
{
ii=max-1;
}
if (i==0.)
{
ii=1;
}
if (j==max)
{
j=max-1;
}

deform=(xx[j+1]-xx[j])*presur[j]*log(fabs((xx[ii+1]+xx[ii])/2.-xx[j])*fabs((xx[ii-1]+xx[ii])/2.-xx[j]));
}
hc=-2*(vb-vp)*deform/(e*3.14);
position[1]=position[1]*0.9+0.1*(ho+sqrt(fabs(yy[j]*yy[j]-r))+(hc));
position[1]=position[1];
free(xx);
free(yy);
free(presur);
Message ("x = %f, y= %f, deform=%f",position[0],position[1]),deform;
return position[1];
}







Thanks you


All times are GMT -4. The time now is 17:19.