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/)
-   -   an udf for boundry condition of reciprocating flow (https://www.cfd-online.com/Forums/fluent-udf/196150-udf-boundry-condition-reciprocating-flow.html)

mohamad-p November 27, 2017 05:59

an udf for boundry condition of reciprocating flow
 
I want to model the time dependent reciprocating flow through a pipe. the boundary conditions at inlet and outlet are sinusoidal velocity and fully developed flow condition respectively which change in each half cycle.
So i need an udf to define a time dependent sinusoidal velocity profile at inlet and define fully developed condition at the other end of the pipe which be reversed in each half cycle.
the following udf is which i use for left boundry

#include <stdio.h>
#include <math.h>
#include "udf.h"
DEFINE_PROFILE(left_vel_x_comp,thread,index)
{
double t,PI,h_cyc,vel;
face_t f;
Thread *t0=THREAD_T0(thread);
cell_t c0;
t = CURRENT_TIME;

begin_f_loop(f,thread)
{
c0=F_C0(f,thread);
PI=4.*atan(1.);
h_cyc=sin(5.*t); /****half cycle****/
if (h_cyc>=0.0)
{
vel = h_cyc;
}
else
{
vel=(C_U(c0,t0))/0.2;
}
F_PROFILE(f,thread,index)=0.2*vel;
}
end_f_loop(f,thread)
}

DEFINE_PROFILE(left_vel_y_comp,thread,index)
{
face_t f;
begin_f_loop(f,thread)
{
F_PROFILE(f,thread,index)=0.0;
}
end_f_loop(f,thread)
}


I would be so grateful if anyone help me.
Regards.


All times are GMT -4. The time now is 01:00.