.c file

#include "udf.h"
DEFINE_PROFILE(velocity1_inlet,thread,index)
{
real x[ND_ND],A[ND_ND];
real y;
face_t f;
real current_time;
double data[30],a0,a[15],b[15];
double vel,beat,R_radius,w_omega,pi,area,volume,ii,xi,yi;
int i,j,m,n;
FILE *data1,*para1;
//initial vlue//
current_time=CURRENT_TIME;
//current_time=current_time;

pi=2.0e0*acos(0.0e0);
beat=95.5e0;
w_omega=2.0e0*pi*beat/60.0e0;
//R_radius=2.77e-2;
data1 = fopen("vfr_inlet1.dat","r");
for(i=0;i<30;i++)
{
fscanf(data1, "%lf", &data[i]);
//printf("%lf\n",data[i]);
}
fclose(data1);
//Getting the parameters//
a0=0.0e0;
a[15]=0.0e0;
b[15]=0.0e0;
m=1;
for(i=0;i<30;i++)
{
a0=a0+data[i];
}
a0=a0/30;
for(j=0;j<15;j++)
{
for(i=0;i<30;i++)
{
a[j]=a[j]+data[i]*cos(m*i*pi/15);
b[j]=b[j]+data[i]*sin(m*i*pi/15);
}
a[j]=a[j]/15;
b[j]=b[j]/15;
m=m+1;
}
//Volume Flow Rate Getting//
volume=0.0e0;
ii=1.0e0;
for(i=0;i<15;i++)
{
volume=volume+a[i]*cos(w_omega*(ii)*current_time)+b[i]*sin(w_omega*(ii)*current_time);
ii=ii+1.0e0;
}
volume=volume+a0;
area=0e0;
begin_f_loop(f,thread)
{
F_AREA(A,f,thread);
area+=NV_MAG(A);
}
end_f_loop(f,thread);
area=area*1.0e6;
vel=volume/area;
//printf("volume=%lf\n",volume);
//printf("area=%lf\n",area);
//printf("velocity=%lf\n",vel);
/*
n=0;
xi=0.0e0,yi=0.0e0;
begin_f_loop(f,thread)
{
F_CENTROID(x,f,thread);
xi=x[0]+xi;
yi=x[1]+yi;
n=n+1;
}
end_f_loop(f,thread);
xi=xi/n;
yi=yi/n;
// printf("n=%d\n",n);
// printf("xi=%lf\n",xi);
// printf("yi=%lf\n",yi);
*/
begin_f_loop(f,thread) /* loops over all faces in the thread passed
in the DEFINE macro argument */
{
//F_CENTROID(x,f,thread);
//y =sqrt((x[1]-yi)*(x[1]-yi)+(x[0]-xi)*(x[0]-xi));
//y=y/R_radius;
//F_PROFILE(f,thread,index)=vel*2.0e0*(1.0e0-y*y);
F_PROFILE(f,thread,index)=vel;
}
end_f_loop(f,thread)
}

DEFINE_PROFILE(velocity2_inlet,thread,index)
{
real x[ND_ND],A[ND_ND];
real y;
face_t f;
real current_time;
double data[30],a0,a[15],b[15];
double vel,beat,R_radius,w_omega,pi,area,volume,ii,xi,yi;
int i,j,m,n;
FILE *data1,*para1;
//initial vlue//
current_time=CURRENT_TIME;
//current_time=current_time;

pi=2.0e0*acos(0.0e0);
beat=95.5e0;
w_omega=2.0e0*pi*beat/60.0e0;
//R_radius=2.77e-2;
data1 = fopen("vfr_inlet2.dat","r");
for(i=0;i<30;i++)
{
fscanf(data1, "%lf", &data[i]);
//printf("%lf\n",data[i]);
}
fclose(data1);
//Getting the parameters//
a0=0.0e0;
a[15]=0.0e0;
b[15]=0.0e0;
m=1;
for(i=0;i<30;i++)
{
a0=a0+data[i];
}
a0=a0/30;
for(j=0;j<15;j++)
{
for(i=0;i<30;i++)
{
a[j]=a[j]+data[i]*cos(m*i*pi/15);
b[j]=b[j]+data[i]*sin(m*i*pi/15);
}
a[j]=a[j]/15;
b[j]=b[j]/15;
m=m+1;
}
//Volume Flow Rate Getting//
volume=0.0e0;
ii=1.0e0;
for(i=0;i<15;i++)
{
volume=volume+a[i]*cos(w_omega*(ii)*current_time)+b[i]*sin(w_omega*(ii)*current_time);
ii=ii+1.0e0;
}
volume=volume+a0;
area=0e0;
begin_f_loop(f,thread)
{
F_AREA(A,f,thread);
area+=NV_MAG(A);
}
end_f_loop(f,thread);
area=area*1.0e6;
vel=volume/area;
//printf("volume=%lf\n",volume);
//printf("area=%lf\n",area);
//printf("velocity=%lf\n",vel);
/*
n=0;
xi=0.0e0,yi=0.0e0;
begin_f_loop(f,thread)
{
F_CENTROID(x,f,thread);
xi=x[0]+xi;
yi=x[1]+yi;
n=n+1;
}
end_f_loop(f,thread);
xi=xi/n;
yi=yi/n;
// printf("n=%d\n",n);
// printf("xi=%lf\n",xi);
// printf("yi=%lf\n",yi);
*/
begin_f_loop(f,thread) /* loops over all faces in the thread passed
in the DEFINE macro argument */
{
//F_CENTROID(x,f,thread);
//y =sqrt((x[1]-yi)*(x[1]-yi)+(x[0]-xi)*(x[0]-xi));
//y=y/R_radius;
//F_PROFILE(f,thread,index)=vel*2.0e0*(1.0e0-y*y);
F_PROFILE(f,thread,index)=vel;
}
end_f_loop(f,thread)
}
I have got this error :warning C4789: buffer 'b' of size 120 bytes will be overrun; 8 bytes will be written starting at offset 120
Any body knows the solution?
the valid index goes from 0 to size-1

you've declared double b[15]; but later try to do b[15] = 0.0. That's an invalid access.
Don't know what you are trying to do there, so can't give you a solution.
I am trying to compile it in my geometry in Ansys software as a boundary condition.
I dont know about the .c program my Prof. gave this file to me to just compile it!!! but I have this error!!
Topic archived. No new replies allowed.