CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

UDF to perform 2-axes of rotations simultaneously

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   May 1, 2014, 13:11
Question UDF to perform 2-axes of rotations simultaneously
  #1
New Member
 
Benjamin
Join Date: Mar 2014
Posts: 1
Rep Power: 0
Benjaminc89 is on a distinguished road
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!
Benjaminc89 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! Delete the UDM codes in the UDF Messi Fluent UDF and Scheme Programming 2 January 28, 2014 10:01
udf for multiple reaction alihosseini63 Fluent UDF and Scheme Programming 0 July 4, 2013 18:37
Help me to check my UDF Liufeng_ustb Fluent UDF and Scheme Programming 2 May 7, 2013 10:25
UDF for linear PTT model implementation dpitz Fluent UDF and Scheme Programming 1 February 4, 2011 11:08
I need UDF help. S.Whitney FLUENT 0 October 15, 2007 11:29


All times are GMT -4. The time now is 17:49.