CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Error during Compiling UDF for Rotor Motion (http://www.cfd-online.com/Forums/fluent-udf/124746-error-during-compiling-udf-rotor-motion.html)

deepak.dce06 October 11, 2013 18:51

Error during Compiling UDF for Rotor Motion
 
I had written a UDF to give motion to udf about a point.
The case is a 2D case.
When I try to compile the udf it gives an error that the UDF is not written for 2D. Could anyone have a look at it.
Appreciate the Help.

#include "udf.h"
#include "stdio.h"
#include<math.h>
DEFINE_CG_MOTION(ROtor_Motion,dt,vel,omega,time,dt ime)
{
Thread *tf = DT_THREAD (dt);
face_t f;
Node *v;
real time1, time2, theta1, theta2;
int n;
real CGravity[ND_ND];
real xnew[ND_ND];
real count;
real omega,e;
real trans[ND_ND];

SET_DEFORMING_THREAD_FLAG (THREAD_T0 (tf));

Omega=1047.2; /*angular vel*/
e=0.16; /*eccentricity*/

time1 = time;
time2 = time+dtime;
theta1= time1 * omega; /*whirling angles at two consecutive times*/
theta2= time2 * omega;

trans[0]=e*(cos(theta2)-cos(theta1)); /* change in x & y coordinate*/
trans[1]= e*(sin(theta2)-sin(theta1));

CGravity[0] =0;
CGravity[1] =0;
count =0;
begin_f_loop (f, tf) /*loop to change the position of each node*/
{
F_CENTROID(xnew,f,tf);
CGravity[0] = CGravity[0]+xnew[0];
CGravity[1] = CGravity[1]+xnew[1];
count = count + 1;
f_node_loop (f, tf, n)
{
v = F_NODE (f, tf, n);
if (NODE_POS_NEED_UPDATE (v))
{
NODE_POS_UPDATED(v);
NV_V (NODE_COORD (v), +=, trans);
}
}
}
end_f_loop (f, tf);
CGravity[0] = CGravity[0]/count;
CGravity[1] = CGravity[1]/count;
Message ("%f %f \n", CGravity[0], CGravity[1]);
}

deepak.dce06 October 15, 2013 12:51

Anyone with UDF expertise??


All times are GMT -4. The time now is 13:37.