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/)
-   -   UDF for an oscillating 3d body (https://www.cfd-online.com/Forums/fluent-udf/132894-udf-oscillating-3d-body.html)

Pinto April 7, 2014 16:01

UDF for an oscillating 3d body
 
I am trying to oscillate a 3d body in in the heave direction in Fluent and also read the Force-Time graph.
Here is my UDF:

/************3D Body************************/
#include "udf.h"
#include "dynamesh_tools.h"
#include "sg_mem.h"
#include "unsteady.h"
real t;
real n;
real dtm;
real m_glob;
real x_cg;
real f_glob;
FILE *fp;

/*Velocity vector of the center of gravity*/

static real Omega_CG[2];
static int i;


DEFINE_EXECUTE_AT_END(exe_end)
{

real x_cg[n],f_glob[n],m_glob[n];
Domain *domain=Get_Domain(1);
Thread *tf=Lookup_Thread(domain,6);
usrloop(n,ND_ND)
x_cg[n]=f_glob[n]=m_glob[n]=0;

if (!Data_Valid_P())
return;
Compute_Force_And_Moment(domain,tf,x_cg,f_glob,m_g lob,TRUE);

t+=dtm;
fp=fopen("udf.txt","a");
fprintf(fp,"%5f,%.8f\n",t,f_glob[2]);
fclose(fp);
}


DEFINE_CG_MOTION(ssu, dt, cg_vel, cg_omega, time, dtime)
{
real delta_t;
real freq = 2; real amp = 0.1;
real omega;
real vel;
Domain *domain;
Thread *tf;

omega=2.0*3.143*freq;

/* disp=-Asin(omega*t) */ /* vel =-A*omega*cos(omega*t) */

vel=-amp*omega*cos(omega*time);
cg_vel[0]=0;
cg_vel[1]=0;
cg_vel[2]=vel;
NV_S (cg_omega, =, 0.0);
}

I have received a syntax error after loading this UDF.

Can someone please tell me what to do or if you can give a a better one.

Thanks


All times are GMT -4. The time now is 23:01.