CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   how to compiled udf ? (http://www.cfd-online.com/Forums/fluent/82049-how-compiled-udf.html)

zzyan November 14, 2010 23:42

how to compiled udf ?
 
hi all
i do have no idea about udf, udf1:

#include "udf.h"


static real v_prev = 0.0;


DEFINE_CG_MOTION(piston,dt,vel,omega,time,dtime)


{


Thread *t;


face_t f;


real NV_VEC(A);


real force, dv;



/* reset velocities */


NV_S(vel, =, 0.0);


NV_S(omega, =, 0.0);



if (!Data_Valid_P())


return;



/* get the thread pointer for which this motion is defined */


t = DT_THREAD(dt);



/* compute pressure force on body by looping through all faces */


force = 90.0;


begin_f_loop(f,t)


{


F_AREA(A,f,t);


force += F_P(f,t) * NV_MAG(A);


}


end_f_loop(f,t)



/* compute change in velocity, i.e., dv = F * dt / mass


velocity update using explicit Euler formula */


dv = dtime * force / 50.0;


v_prev += dv;


Message ("time = %f, x_vel = %f, force = %f\n", time, v_prev,


force);



/* set x-component of velocity */


vel[0] = v_prev;


}


it can be compiled like that:
http://b51.photo.store.qq.com/http_i...c6b9&a=57&b=51
http://b58.photo.store.qq.com/http_i...0cde&a=58&b=58

but udf 2:
#include "udf.h"
#include "unsteady.h"
#include "memory.h"
#include "stdlib.h"
#include "stdio.h"
DEFINE_CG_MOTION(movewall,dt,vel,omega,time,dtime)
{
Thread *t;
cell_t c;
real cx,cy;
//CArray<real,real&> vx,vy;
int i;
int n=0;
//if(!Data_Valid_P())
//return;
t=DT_THREAD(dt);
cx=0;
cy=0;
begin_c_loop(c,t)
{
//vx.Add(C_U(c,t));
//vy.Add(C_U(c,t));
cx=cx+C_U(c,t);
cy=cy+C_V(c,t);
n++;
}
end_c_loop(c,t);
cx=cx/n;
cy=cy/n;
cx=0;
cy=0.05;
vel[0]=cx;
vel[1]=cy;
//Message("\n n=%d, vx=%f, vy=%f\n",n,vel[0],vel[1]);
}
it can not be compiled :
http://b58.photo.store.qq.com/http_i...f0ca&a=58&b=58
http://b51.photo.store.qq.com/http_i...cc25&a=52&b=51

is anyone can help me?

thanks.

lehoang_mai November 15, 2010 06:55

I can't see pictures about error:-(

zzyan November 19, 2010 02:53

Quote:

Originally Posted by lehoang_mai (Post 283476)
I can't see pictures about error:-(

thank You lehoang_mai
i have slover that problem


All times are GMT -4. The time now is 11:33.