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 to perform 2-axes of rotations simultaneously (https://www.cfd-online.com/Forums/fluent-udf/134570-udf-perform-2-axes-rotations-simultaneously.html)

Benjaminc89 May 1, 2014 13:11

UDF to perform 2-axes of rotations simultaneously
 
Hi,

I have got a problem with compiling a UDF function using "DEFINE_GRID_MOTION".
I'm wondering if this Macro only works for a single 2-D co-ordinate transformation.
It was working fine if the motion only includes rotation about a single axis.
The code is as shown:

#include "udf.h"
#include "stdio.h"
#include "math.h"
#define pi 3.1415
#define amp 0.174 //number of rotations
#define freq 3.0
real w=2*pi*freq;
DEFINE_GRID_MOTION(motion,domain,dt,time,dtime)
{
Thread *tf = DT_THREAD(dt);
face_t f;
Node *v;
real theta,a,b;
int n;
SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));
begin_f_loop(f,tf)
{
f_node_loop(f,tf,n)
{
v=F_NODE(f,tf,n);


if (NODE_POS_NEED_UPDATE (v))
{
NODE_POS_UPDATED(v);
theta=(-1)*amp*w*cos(w*time)*dtime;
a=cos(theta)*NODE_X(v)-sin(theta)*NODE_Y(v);
b=sin(theta)*NODE_X(v)+cos(theta)*NODE_Y(v);
NODE_X(v)=a;
NODE_Y(v)=b;
}
}
}
end_f_loop(f,tf);
}

However, if an additional rotational motion is included in the UDF.. Fluent just doesn't allow the compilation to be done. (Showing error message of: Error: The UDF library you are trying to load (libudf) is not compiled for 3ddp on the current platform (win64))
Euler angles calculations are included in the modified UDF where "double-axes rotation" is needed simultaneously.

The modified UDF is shown:

#include "stdio.h"
#include "math.h"
#define pi 3.1415
#define amp 0.174 //number of rotations
#define freq 0.25
real w=2*pi*freq;
DEFINE_GRID_MOTION(motion,domain,dt,time,dtime)
{
Thread *tf = DT_THREAD(dt);
face_t f;
Node *v;
real theta,a,b,bb,beta;
int n;
SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));
begin_f_loop(f,tf)
{
f_node_loop(f,tf,n)
{
v=F_NODE(f,tf,n);


if (NODE_POS_NEED_UPDATE (v))
{
NODE_POS_UPDATED(v);
theta=(-1)*amp*w*cos(w*time)*dtime;
beta=w*dtime;
a=cos(theta)*cos(beta)*NODE_X(v)-sin(beta)*NODE_Y(v)-sin(theta)*cos(beta)*NODE_Z(v);
b=sin(beta)*cos(theta)*NODE_X(v)+cos(beta)*NODE_Y( v)-sin(beta)*sin(theta)*NODE_Z(v);
bb=sin(theta)*NODE_X(v)+cos(theta)*NODE_Z(v);
NODE_X(v)=a;
NODE_Y(v)=b;
NODE_Z(v)=bb;
}
}
}
end_f_loop(f,tf);
}

Anyone could please provide an advice?
Greatly Appreciated!


All times are GMT -4. The time now is 20:50.