CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Code to rotate a cone

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 16, 2018, 15:40
Default Code to rotate a cone
  #1
New Member
 
Emad Ramadan
Join Date: Jan 2018
Posts: 2
Rep Power: 0
emadR is on a distinguished road
Hello everyone. I am trying to make my boundary condition rotate in two different directions. My velocity profile depends on time and position. As my cone is rotating around the Y-axis, I only need to define a x-velocity component and a z-velocity component. I am a newbie with this. I am attaching my code. Any help is highly appreciated.


#include "udf.h"

DEFINE_PROFILE(velocity_x_comp,thread,position)
{
real x[ND_ND];
face_t f;
real v, x, y, z, rho, phi, theta;
real flow_time;
flow_time = CURRENT_TIME;

if (0=< flow_time <0.5)
{
v = 20.94;
}
else if (0.5 =< flow_time <0.51 )
{
v = 0;
}
else if (0.51 =< flow_time <1.01)
{
v = -20.94;
}
else if ( 1.01 =< flow_time < 1.02)
{
v = 0;
}
else if ( 1.02 =< flow_time < 1.52)
{
v = 20.94;
}
else if (1.52 =< flow_time < 1.53)
{
v = 0;
}
else if (1.53 =< flow_time < 2.03)
{
v = -20.94;
}
else if (2.03 =< flow_time < 2.04)
{
v = 0;
}
else if (2.04 =< flow_time < 2.54)
{
v = 20.94;
}
else if (2.54 =< flow_time < 2.55 )
{
v= 0;
}
else if (2.55 =< flow_time < 3.05 )
{
v = -20.94;
}
else if (3.05 =< flow_time < 3.06)
{
v = 0;
}
else if (3.06 =< flow_time < 3.56 )
{
v= 20.94;
}
else if (3.56 =< flow_time < 3.57)
{
v =0;
}
else if (3.57 =< flow_time < 4.07)
{
v = -20.94;
}
else
{
v =0;
}
begin_f_loop(f,thread)
{
F_CENTROID(x,f,thread);
rho = sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2]);
theta = atan(x[0]/x[2]);
phi = asin(x[1]/rho);

F_PRFOLE(f,thread,position)= v*rho*cos(phi)*sin(theta);
}
end_f_loop(f,ft)
}
emadR is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
The FOAM Documentation Project - SHUT-DOWN holger_marschall OpenFOAM 242 March 7, 2013 12:30
How to make code run in parallel? cwang5 OpenFOAM Programming & Development 1 May 30, 2011 04:47
Open Source Vs Commercial Software MechE OpenFOAM 28 May 16, 2011 11:02
Design Integration with CFD? John C. Chien Main CFD Forum 19 May 17, 2001 15:56
What is the Better Way to Do CFD? John C. Chien Main CFD Forum 54 April 23, 2001 08:10


All times are GMT -4. The time now is 07:06.