CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Code to rotate a cone (https://www.cfd-online.com/Forums/main/200911-code-rotate-cone.html)

emadR April 16, 2018 15:40

Code to rotate a cone
 
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)
}


All times are GMT -4. The time now is 18:53.