|
|
¡¾´ð°¸¡¿Ó¦Öú»ØÌû
¸Ðл²ÎÓ룬ӦÖúÖ¸Êý +1
ÇóÖú£¬ÏÂÃæµÄ³ÌÐòÊÇʲôÒâ˼£¿ÖмäµÄÊý¾ÝÎÒÊ¡ÂÔÁË£¬Ð»¹ý£¡
/**************************************************************************************
UDF: for specifying a time-dependent velocity profile boundary condition:
u(t) - interpolated via cubic spine from measurements by Traykovski
written by Houshuo Jiang on August 17, 2006
***************************************************************************************/
#include "udf.h"
DEFINE_PROFILE(unsteady_flow, thread, position)
{
/* ttt[]: sampled times */
/* u[]: sampled streamwise flow velocity */
/* d2_u_dt2[]: calculated 2nd time derivative of u */
/* start time = 0.12499359 , end time = 602.12499000 */
static real ttt[4817]=
{
0.00000000E+00, 0.12499430E+00, 0.24999865E+00, 0.37499294E+00, 0.49999729E+00,
0.62500164E+00, 0.74999593E+00, 0.87500029E+00, 0.99999461E+00, 0.11249989E+01,
0.12500033E+01, 0.13749976E+01, 0.14999919E+01, 0.16249962E+01, 0.17500006E+01,
0.18749949E+01, 0.19999992E+01, 0.21249935E+01, 0.22499978E+01,
};
static real u[4817]=
{
0.29486706E+00, 0.25832370E+00, 0.22072441E+00, 0.18439429E+00, 0.14780788E+00,
0.11332307E+00, 0.80134080E-01, 0.49663854E-01, 0.21209121E-01,-0.60646123E-02,
-0.28923945E-01,-0.49841599E-01,-0.66707764E-01,-0.79936611E-01,-0.88913036E-01,
0.26710739E+00, 0.27723406E+00, 0.28560768E+00, 0.29210729E+00, 0.29621414E+00,
0.29912153E+00, 0.30260917E+00
};
static real d2_u_dt2[4817]=
{
0.85972525E-01,-0.17194505E+00, 0.19746624E+00,-0.13169408E+00, 0.23201899E+00,
0.10576336E-01, 0.22222984E+00, 0.14550020E+00,-0.31192043E-01, 0.43361966E+00,
-0.82670364E-02, 0.34437811E+00, 0.18666827E+00, 0.30615838E+00, 0.22151801E+00,
0.29484003E+00, 0.38174390E+00, 0.11195380E+00, 0.17885390E+00, 0.26852023E+00,
0.21346864E+00, 0.30599166E-01, 0.10479063E+00, 0.10472997E+00,-0.22994860E-01,
0.16925363E-01,-0.11893041E+00,-0.12963144E+00,-0.57996749E-01,-0.38344444E-01,
-0.23898451E+00,-0.79638780E-01,-0.11563157E+00,-0.17745479E+00,-0.93369114E-01,
0.90338604E-01,-0.45169302E-01
};
int n=4817;
/* variables for the cubic spline algorithm */
int klo,khi,k;
real h,a,b;
/* variables for printing out messages */
/* variables for the FLUENT UDF settings */
face_t ft;
real t, xvelocity;
t = CURRENT_TIME;
/* By means of bisection to locate the right place for t in the table */
klo=1;
khi=n;
while (khi-klo > 1)
{
k=(khi+klo) >> 1;
if (ttt[k-1] > t) khi=k;
else klo=k;
}
/* klo and khi now bracket the input value of t. */
/* Transfer from unit-offset to zero-offset. */
klo=klo-1;
khi=khi-1;
h=ttt[khi]-ttt[klo];
a=(ttt[khi]-t)/h;
b=(t-ttt[klo])/h;
/* Cubic spline polynomial is now evaluated to obtain the velocity at time t. */
xvelocity = a*u[klo]+b*u[khi]+((a*a*a-a)*d2_u_dt2[klo]+(b*b*b-b)*d2_u_dt2[khi])*(h*h)/6.0;
Message("current time = %15.8e s, u = %15.8e m/s\n", t, xvelocity); /* \n denotes a new line */
begin_f_loop(ft, thread)
{
F_PROFILE(ft, thread, position) = xvelocity;
}
end_f_loop(ft, thread)
}
/*****************************************************************
UDF for volume-integrating k and epsilon, for calculating the total
volume, and for writing them into a file.
Exporting U,W at a cell about 50cm above the ripple crest to a
file.
written by Houshuo Jiang on August 25, 2006.
******************************************************************/
DEFINE_ON_DEMAND(tke_epsilon_pointuw)
{
real sum_tke=0.0, sum_epsilon=0.0, sum_volume=0.0;
real flowtime, xx[ND_ND];
real x0_ripple=-0.39102757, x1_ripple=0.37087719; /* define the two sides of the ripple interested */
real cellx0=0.0450395, cellx1=0.05541; /* define the streamwise bound of the cell */
real cellz0=-0.2933, cellz1=-0.2639; /* define the vertical bound of the cell */
real cellu=0.0,cellw=0.0,cellcentroidx=0.0,cellcentroidz=0.0;
Domain *d; /* declare domain pointer since it is not passed as an argument to the DEFINE macro */
Thread *t;
cell_t c;
FILE *fp1, *fp2;
d = Get_Domain(1); /* returns fluid domain pointer */
flowtime = CURRENT_TIME;
/* Integrate TKE, epsilon, and export the cell variables */
thread_loop_c(t,d)
{
begin_c_loop(c,t)
C_CENTROID(xx,c,t)
if ((xx[0]>x0_ripple) && (xx[0]<x1_ripple))
{
sum_tke += C_K(c,t)*C_VOLUME(c,t);
sum_epsilon += C_MU_EFF(c,t)/C_R(c,t)*C_STRAIN_RATE_MAG(c,t)*C_STRAIN_RATE_MAG(c,t)*C_VOLUME(c,t);
sum_volume += C_VOLUME(c,t);
}
if ( ( (xx[0]>cellx0) && (xx[0]<cellx1) ) && ( (xx[1]>cellz0) && (xx[1]<cellz1) ) )
{
cellu = C_U(c,t);
cellw = C_V(c,t);
cellcentroidx = xx[0];
cellcentroidz = xx[1];
}
end_c_loop(c,t)
}
fp1 = fopen("TKE_epsilon_vs_t.dat","a" ; /* open a file named TKE_epsilon_vs_t.dat in append mode and assign it to fp1 */
fprintf(fp1,"%15.8e %15.8e %15.8e %15.8e\n", flowtime,sum_volume,sum_tke,sum_epsilon);
fclose(fp1);
fp2 = fopen("pointUW_vs_t.dat","a" ; /* open a file named pointUW_vs_t.dat in append mode and assign it to fp2 */
fprintf(fp2,"%15.8e %15.8e %15.8e %15.8e %15.8e\n", flowtime,cellu,cellw,cellcentroidx,cellcentroidz);
fclose(fp2);
Message(" Success!" ;
} |
|