Professional Documents
Culture Documents
/* vprofile.c */
/* UDF for specifying steady-state velocity profile boundary condition */
/***********************************************************************/
#include "udf.h"
begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
y = x[1];
F_PROFILE(f, thread, position) = 20. - y*y/(.0745*.0745)*20.;
}
end_f_loop(f, thread)
}
/**********************************************************************/
/* unsteady.c */
/* UDF for specifying a transient velocity profile boundary condition */
/**********************************************************************/
#include "udf.h"
begin_f_loop(f, thread)
{
real t = RP_Get_Real("flow-time");
F_PROFILE(f, thread, position) = 20. + 5.0*sin(10.*t);
}
end_f_loop(f, thread)
}
/******************************************************************/
/* UDF that adds momentum source term and derivative to duct flow */
/******************************************************************/
#include "udf.h"
return source;
}
/*********************************************************************/
/* UDF for specifying a temperature-dependent viscosity property */
/*********************************************************************/
#include "udf.h"
return mu_lam;
}
/**************************************************************/
/* rate.c */
/* UDF for specifying a reaction rate in a porous medium */
/**************************************************************/
#include "udf.h"
#define K1 2.0e-2
#define K2 5.
/***********************************************************************/
/* UDF for computing the magnitude of the gradient of T^4 */
/***********************************************************************/
#include "udf.h"
DEFINE_ADJUST(adjust_fcn, domain)
{
Thread *t;
cell_t c;
face_t f;
thread_loop_f (t,domain)
{
if (NULL != THREAD_STORAGE(t,SV_UDS_I(T4)))
{
begin_f_loop (f,t)
{
real T = 0.;
if (NULL != THREAD_STORAGE(t,SV_T))
T = F_T(f,t);
else if (NULL != THREAD_STORAGE(t->t0,SV_T))
T = C_T(F_C0(f,t),t->t0);
F_UDSI(f,t,T4) = pow(T,4.);
}
end_f_loop (f,t)
}
}
thread_loop_f (t,domain)
{
if (NULL != THREAD_STORAGE(t,SV_UDS_I(T4)) &&
NULL != T_STORAGE_R_NV(t->t0,SV_UDSI_G(T4)))
{
begin_f_loop (f,t)
{
F_UDSI(f,t,MAG_GRAD_T4)=C_UDSI(F_C0(f,t),t->t0,MAG_GRAD_T4);
}
end_f_loop (f,t)
}
}
}
/**************************************************************/
/* Implementation of the P1 model using user-defined scalars */
/**************************************************************/
#include "udf.h"
DEFINE_ADJUST(p1_adjust, domain)
{
/* Make sure there are enough user defined-scalars. */
if (n_uds < N_REQUIRED_UDS)
Internal_Error("not enough user-defined scalars allocated");
}
DEFINE_DIFFUSIVITY(p1_diffusivity, c, t, i)
{
return 1./(3.*abs_coeff + (3. - las_coeff)*scat_coeff);
}
{
face_t f;
real A[ND_ND],At;
real dG[ND_ND],dr0[ND_ND],es[ND_ND],ds,A_by_es;
real aterm,alpha0,beta0,gamma0,Gsource,Ibw;
real Ew = epsilon_w/(2.*(2. - epsilon_w));
Thread *t0=thread->t0;
begin_f_loop (f,thread)
{
cell_t c0 = F_C0(f,thread);
BOUNDARY_FACE_GEOMETRY(f,thread,A,ds,es,A_by_es,dr0);
At = NV_MAG(A);
if (NULLP(T_STORAGE_R_NV(t0,SV_UDSI_G(P1))))
Gsource = 0.; /* if gradient not stored yet */
else
BOUNDARY_SECONDARY_GRADIENT_SOURCE(Gsource,SV_UDSI_G(P1),
dG,es,A_by_es,1.);
gamma0 = C_UDSI_DIFF(c0,t0,P1);
alpha0 = A_by_es/ds;
beta0 = Gsource/alpha0;
aterm = alpha0*gamma0/At;
Ibw = SIGMA_SBC*pow(WALL_TEMP_OUTER(f,thread),4.)/M_PI;
cid[0] = Ew * F_UDSI(f,t,P1);
cid[3] = 4.0 * Ew * SIGMA_SBC;
#define DEFINE_SCAT_PHASE_FUNC(name, c, f) \
real name(real c, real *f)
#define DEFINE_SOURCE(name, c, t, dS, i) \
real name(cell_t c, Thread *t, real dS[], int i)
#define DEFINE_SR_RATE(name, f, t, r, mw, yi, rr) \
void name(face_t c, Thread *t, \
Reaction *r, real *mw, real *yi, real *rr)
#define DEFINE_TURB_PREMIX_SOURCE(name, c, t, turbulent_flame_speed, source) \
void name(cell_t c, Thread *t, real *turbulent_flame_speed, real *source)
#define DEFINE_TURBULENT_VISCOSITY(name, c, t) real name(cell_t c, Thread *t)
#define DEFINE_UDS_FLUX(name, f, t, i) \
real name(face_t f, Thread *t, int i)
#define DEFINE_UDS_UNSTEADY(name, c, t, i, apu, su) \
void name(cell_t c, Thread *t, int i, real *apu, real *su)
#define DEFINE_VR_RATE(name, c, t, r, mw, yi, rr, rr_t) \
void name(cell_t c, Thread *t, \
Reaction *r, real *mw, real *yi, \
real *rr, real *rr_t)
#define DEFINE_DPM_BODY_FORCE(name, p, i) \
real name(Tracked_Particle *p, int i)
#define DEFINE_DPM_DRAG(name, Re) \
real name(real Re)
#define DEFINE_DPM_SOURCE(name, c, t, S, strength, p) \
void name(cell_t c, Thread *t, dpms_t *S, \
real strength, Tracked_Particle *p)
#define DEFINE_DPM_PROPERTY(name, c, t, p) \
real name(cell_t c, Thread *t, Tracked_Particle *p)
#define DEFINE_DPM_OUTPUT(name, header, fp, p, t, plane) \
void name(int header, FILE *fp, \
Tracked_Particle *p, Thread *t, Plane *plane)
#define DEFINE_DPM_EROSION(name, p, t, f, normal, alpha, Vmag, mdot) \
void name(Tracked_Particle *p, Thread *t, \
face_t f, real normal[], real alpha, \
real Vmag, real mdot)
#define DEFINE_DPM_SCALAR_UPDATE(name, c, t, initialize, p) \
void name(cell_t c, Thread *t, int initialize, \
Tracked_Particle *p)