CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   DEFINED_GRID_MOTION!Could anyone help me,Thanks (https://www.cfd-online.com/Forums/fluent/115652-defined_grid_motion-could-anyone-help-me-thanks.html)

laibin-wang April 4, 2013 01:33

DEFINED_GRID_MOTION!Could anyone help me,Thanks
 
I have been stuck by this problem for several weeks and I have exhausted my intelligence now,so I really hope anyone who can give me a hand please!The following is my UDF file.The problem is When I run calculation ,the fluent:"recevied fatal error(access violation)...occers,could any help me.

#include "stdlib.h"
#include "math.h"
#include "udf.h"
#include "dynamesh_tools.h"
#define fi 0.55851
#define kxl 0.4
#define ID 13
DEFINE_GRID_MOTION(dynamicsurface,domain,dt,time,d time)
{
Thread *tf=DT_THREAD((Dynamic_Thread *)dt);
face_t f;
Node *v;
double *NX,*NY;
double *x1,*y1,*z1;
double disp,u1,v1,w1,alf,sita,shearstressm,shearstressx,s hearstressy;
double qbx,qby,tbcr,tr,tm;
int i=0,j=0,n;
double NV_VEC(a),NV_VEC(b),NV_VEC(c),NV_VEC(velocity),NV_ VEC(temp_1),NV_VEC(temp_2);
double NV_VEC(displacement);
static int numf=0;
static int numn=0;
tf=Lookup_Thread(domain,ID);
SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));
Message("current time=%f\n,time");
NV_D(a,=,1.0,0.0,0.0);
NV_D(b,=,0.0,1.0,0.0);
NV_D(c,=,0.0,0.0,1.0);
begin_f_loop(f,tf)
{
numf+=1;
}
end_f_loop(f,tf);
message("good_1");
x1=(double *)malloc(sizeof(int)*numf);
y1=(double *)malloc(sizeof(int)*numf);
z1=(double *)malloc(sizeof(int)*numf);
message("good_2");
begin_f_loop(f,tf)
{
F_AREA(temp_1,f,tf);
x1[i]=NV_DOT(temp_1,a);
y1[i]=NV_DOT(temp_1,b);
z1[i]=NV_DOT(temp_1,c);
i+=1;
}
end_f_loop(f,tf);
message("good_3");
i=0;
j=0;
begin_f_loop(f,tf)
{
numn=0;
u1=F_U(f,tf);
v1=F_U(f,tf);
w1=F_U(f,tf);
NV_D(velocity,=,u1,v1,w1);
alf=fabs(NV_DOT(velocity,b)/(NV_MAG(velocity)*NV_MAG(b)));
F_AREA(temp_2,f,tf);
sita=fabs((NV_DOT(temp_2,c))/(NV_MAG(temp_2)*(NV_MAG(c))));
shearstressx= F_STORAGE_R_N3V(f,tf,SV_WALL_SHEAR)[0];
shearstressy= F_STORAGE_R_N3V(f,tf,SV_WALL_SHEAR)[1];
shearstressm=fabs((NV_MAG(F_STORAGE_R_N3V(f,tf,SV_ WALL_SHEAR))/NV_MAG(temp_2)));
f_node_loop(f,tf,n)
{
numn+=1;
}
NX=(double *)malloc(sizeof(int)*numn);
NY=(double *)malloc(sizeof(int)*numn);
f_node_loop(f,tf,n)
{
v=F_NODE(f,tf,n);
NX[j]=NODE_X(v);
NY[j]=NODE_Y(v);
j+=1;
}
f_node_loop(f,tf,n)
{
if(NODE_POS_NEED_UPDATE(v))
{
NODE_POS_UPDATED(v);
tbcr=5243.33*(((1+0.85*sin(fi)/cos(fi))*(cos(sita)*cos(sita)-sin(sita)*sin(sita)*cos(fi)*cos(fi)/(sin(fi)*sin(fi)))*cos(fi)/sin(fi))*\
pow(((0.85*cos(sita)+sin(sita)*sin(alf)*cos(fi)*co s(fi)/(sin(fi)*sin(fi)))+cos(fi)/sin(fi)*sqrt(cos(sita)*cos(sita)-sin(sita)*\
sin(sita)*cos(fi)*cos(fi)/(sin(fi)*sin(fi))+0.7225*sin(sita)*sin(sita)+1.7*s in(sita)*cos(sita)*sin(alf)+sin(sita)*sin(sita)*\
sin(alf)*sin(alf)*cos(fi)*cos(fi)/(sin(fi)*sin(fi)))),-1));
if(shearstressm>tbcr)
{
if((shearstressm-tbcr)/tbcr<2.5)
{
tr=((shearstressm-tbcr)/tbcr);
qbx=0.053*sqrt(1.68)*sqrt(9.8)*0.0002388862*0.5041 35*pow(tr,2.1)*(shearstressx/shearstressm+1.5*x1[i]/z1[i]);
qby=0.053*sqrt(1.68)*sqrt(9.8)*0.0002388862*0.5041 35*pow(tr,2.1)*(shearstressy/shearstressm+1.5*y1[i]/z1[i]);
}
else
{
tm=((0.7266*shearstressm-tbcr)/tbcr);
qbx=0.100*sqrt(1.68)*sqrt(9.8)*0.0002388862*0.5041 35*pow(tm,1.5)*(shearstressx/shearstressm+1.5*x1[i]/z1[i]);
qby=0.100*sqrt(1.68)*sqrt(9.8)*0.0002388862*0.5041 35*pow(tm,1.5)*(shearstressy/shearstressm+1.5*y1[i]/z1[i]);
}
if(j==numn||i==numf)
{
disp=((0-abs((-1/(1-kxl))*((y1[i]/x1[i]-y1[i-1]/x1[i-1])/(NX[j]-NX[j-1])+(z1[i]/x1[i]-z1[i-1]/x1[i-1])/(NY[j]-NY[j-1])))));
}
else
{
disp=(0-abs(((-1/(1-kxl))*((y1[i+1]/x1[i+1]-y1[i]/x1[i])/(NX[j+1]-NX[j])+(z1[i+1]/x1[i+1]-z1[i]/x1[i])/(NY[j+1]-NY[j])))));
}
NV_D(displacement,=,0,0,disp);
NV_S(displacement,*=,dtime);
NV_V(NODE_COORD(v),+=,displacement);
}
j+=1;
}
}
free(NX);
free(NY);
i+=1;
}
end_f_loop(f,tf);
free(x1);
free(y1);
free(z1);
}

kingboy1225 December 3, 2013 09:11

hello,i have a problem just like yours,could you tell me how you solved your problem?


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