CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

Please help me run UDF code for source

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 3, 2006, 02:56
Default Please help me run UDF code for source
  #1
Suga
Guest
 
Posts: n/a
Hello everybody. I have UDF code for define source term but it is not work. I think the problem of this code are in the define_adjust. Please anybody help me. This is my code

#include "udf.h" #include "math.h"

/* Turbulence model constants */ const real C_1=-0.2; const real C_2=0.4; const real C_5=0.0; const real CE_1=1.44; const real CE_2=1.92; const real SIG_K=1.0; const real SIG_E=1.3; const real C_MU_ke=0.09; const real kappa=0.42; const real E_log=9.793;

/* User-defined scalars */ enum { UU, VV, WW, UV, UW, VW };

DEFINE_SOURCE(u_source, c, t, dS, eqn) { real source;

dS[eqn]=0.0;

source= - C_R(c,t) * ( C_UDSI_G(c,t,UU)[0] + C_UDSI_G(c,t,UV)[1] + C_UDSI_G(c,t,UW)[2] );

return source; }

DEFINE_SOURCE(v_source, c, t, dS, eqn) { real source;

dS[eqn]= 0.0;

source= - C_R(c,t) * ( C_UDSI_G(c,t,UV)[0] + C_UDSI_G(c,t,VV)[1] + C_UDSI_G(c,t,VW)[2] );

return source; }

DEFINE_SOURCE(w_source, c, t, dS, eqn) { real source;

dS[eqn]= 0.0;

source= - C_R(c,t) * ( C_UDSI_G(c,t,UW)[0] + C_UDSI_G(c,t,VW)[1] + C_UDSI_G(c,t,WW)[2] );

return source; }

DEFINE_TURBULENT_VISCOSITY(user_mu_t,c,t) { real S,W,c_mu,T,mu_t; real S11, S12, S13, S21, S22, S23, S31, S32, S33; real W11, W12, W13, W21, W22, W23, W31, W32, W33;

S11 = 0.5*( C_DUDX(c,t)+C_DUDX(c,t) );

S12 = 0.5*( C_DUDY(c,t)+C_DVDX(c,t) );

S13 = 0.5*( C_DUDZ(c,t)+C_DWDX(c,t) );

S21 = 0.5*( C_DVDX(c,t)+C_DUDY(c,t) );

S22 = 0.5*( C_DVDY(c,t)+C_DVDY(c,t) );

S23 = 0.5*( C_DVDZ(c,t)+C_DWDY(c,t) );

S31 = 0.5*( C_DWDX(c,t)+C_DUDZ(c,t) );

S32 = 0.5*( C_DWDY(c,t)+C_DVDZ(c,t) );

S33 = 0.5*( C_DWDZ(c,t)+C_DWDZ(c,t) );

W11 = 0.5*( C_DUDX(c,t)-C_DUDX(c,t) );

W12 = 0.5*( C_DUDY(c,t)-C_DVDX(c,t) );

W13 = 0.5*( C_DUDZ(c,t)-C_DWDX(c,t) );

W21 = 0.5*( C_DVDX(c,t)-C_DUDY(c,t) );

W22 = 0.5*( C_DVDY(c,t)-C_DVDY(c,t) );

W23 = 0.5*( C_DVDZ(c,t)-C_DWDY(c,t) );

W31 = 0.5*( C_DWDX(c,t)-C_DUDZ(c,t) );

W32 = 0.5*( C_DWDY(c,t)-C_DVDZ(c,t) );

W33 = 0.5*( C_DWDZ(c,t)-C_DWDZ(c,t) );

T=C_K(c,t)/C_D(c,t);

S=T*sqrt( 2*(S11*S11+S12*S12+S13*S13+S21*S21+S22*S22+S23*S23 +S31*S31+S32*S32+S33*S33) );

W=T*sqrt( 2*(W11*W11+W12*W12+W13*W13+W21*W21+W22*W22+W23*W23 +W31*W31+W32*W32+W33*W33) );

c_mu=MIN( 1./(0.9*pow(S,1.4)+0.4*pow(W,1.4)+3.5) , 0.15 );

mu_t=c_mu*T*C_K(c,t);

return mu_t; }

DEFINE_ADJUST(rsm_adjust,domain) {

Thread *t;

cell_t c;

real T;

real mu_t, c_mu;

real S11, S12, S13, S21, S22, S23, S31, S32, S33;

real W11, W12, W13, W21, W22, W23, W31, W32, W33;

real S, W, Sij, Wij;

real C_3, C_4, C_6, C_7;

real P11, P22, P33, Pkk;

real tau_w, u_tauw, u_star, y_star, Gk, u_mag;

/* Set the turbulent viscosity */

thread_loop_c(t,domain)

if (FLUID_THREAD_P(t))

{

begin_c_loop(c,t)

{

S11 = 0.5*( C_DUDX(c,t)+C_DUDX(c,t) );

S12 = 0.5*( C_DUDY(c,t)+C_DVDX(c,t) );

S13 = 0.5*( C_DUDZ(c,t)+C_DWDX(c,t) );

S21 = 0.5*( C_DVDX(c,t)+C_DUDY(c,t) );

S22 = 0.5*( C_DVDY(c,t)+C_DVDY(c,t) );

S23 = 0.5*( C_DVDZ(c,t)+C_DWDY(c,t) );

S31 = 0.5*( C_DWDX(c,t)+C_DUDZ(c,t) );

S32 = 0.5*( C_DWDY(c,t)+C_DVDZ(c,t) );

S33 = 0.5*( C_DWDZ(c,t)+C_DWDZ(c,t) );

W11 = 0.5*( C_DUDX(c,t)-C_DUDX(c,t) );

W12 = 0.5*( C_DUDY(c,t)-C_DVDX(c,t) );

W13 = 0.5*( C_DUDZ(c,t)-C_DWDX(c,t) );

W21 = 0.5*( C_DVDX(c,t)-C_DUDY(c,t) );

W22 = 0.5*( C_DVDY(c,t)-C_DVDY(c,t) );

W23 = 0.5*( C_DVDZ(c,t)-C_DWDY(c,t) );

W31 = 0.5*( C_DWDX(c,t)-C_DUDZ(c,t) );

W32 = 0.5*( C_DWDY(c,t)-C_DVDZ(c,t) );

W33 = 0.5*( C_DWDZ(c,t)-C_DWDZ(c,t) );

T=C_K(c,t)/C_D(c,t);

S=T*sqrt( 2*(S11*S11+S12*S12+S13*S13+S21*S21+S22*S22+S23*S23 +S31*S31+S32*S32+S33*S33) );

W=T*sqrt( 2*(W11*W11+W12*W12+W13*W13+W21*W21+W22*W22+W23*W23 +W31*W31+W32*W32+W33*W33) );

Sij=S11*S11+S12*S12+S13*S13+S21*S21+S22*S22+S23*S2 3+S31*S31+S32*S32+S33*S33;

Wij=W11*W11+W12*W12+W13*W13+W21*W21+W22*W22+W23*W2 3+W31*W31+W32*W32+W33*W33;

c_mu=MIN( 1./(0.9*pow(S,1.4)+0.4*pow(W,1.4)+3.5) , 0.15 );

mu_t=c_mu*T*C_K(c,t);

C_3=2.0-exp(-SQR(S-W));

C_4=-32.0*SQR(c_mu);

C_6=-16.0*SQR(c_mu);

C_7=16.0*SQR(c_mu);

C_UDSI(c,t,UU)= C_1*mu_t*T* (S11*S11+S12*S12+S13*S13-1./3.*Sij)

+ 2.*C_2*mu_t*T*(W12*S12+W13*S13)

+ C_3*mu_t*T*(W12*W12+W13*W13-1./3.*Wij)

- 2.*C_4*mu_t*T*T * (W12*(S11*S12+S12*S22+S13*S23)+W13*(S11*S13+S12*S2 3+S13*S33))

+ C_6*mu_t*T*T* (S11*Sij)

+ C_7*mu_t*T*T* (S11*Wij);

C_UDSI(c,t,VV)= C_1*mu_t*T* (S12*S12+S22*S22+S23*S23-1./3.*Sij)

+ 2.*C_2*mu_t*T*(W23*S23-W12*S12)

+ C_3*mu_t*T*(W12*W12+W23*W23-1./3.*Wij)

+ 2.*C_4*mu_t*T*T * (W12*(S11*S12+S12*S22+S13*S23)-W23*(S12*S13+S22*S23+S23*S33))

+ C_6*mu_t*T*T* (S22*Sij)

+ C_7*mu_t*T*T* (S22*Wij);

C_UDSI(c,t,WW)= C_1*mu_t*T* (S13*S13+S23*S23+S33*S33-1./3.*Sij)

- 2.*C_2*mu_t*T*(W13*S13+W23*S23)

+ C_3*mu_t*T*(W13*W13+W23*W23-1./3.*Wij)

+ 2.*C_4*mu_t*T*T * (W13*(S11*S13+S12*S23+S13*S33)+W23*(S12*S13+S22*S2 3+S23*S33))

+ C_6*mu_t*T*T* (S33*Sij)

+ C_7*mu_t*T*T* (S33*Wij);

C_UDSI(c,t,UV)= C_1*mu_t*T* (S11*S12+S12*S22+S13*S23)

+ C_2*mu_t*T*(W12*(S22-S11)+W13*S23+W23*S13)

+ C_3*mu_t*T*(W13*W23)

+ C_4*mu_t*T*T* (W12*(S11*S11+S13*S13-S22*S22-S23*S23)-W13*(S12*S13+S22*S23+S23*S33)-W23*(S11*S13+S12*S23+S13*S33))

+ C_6*mu_t*T*T* (S12*Sij)

+ C_7*mu_t*T*T* (S12*Wij);

C_UDSI(c,t,UW)= C_1*mu_t*T* (S11*S13+S12*S23+S13*S33)

+ C_2*mu_t*T*(W13*(S33-S11)+W12*S23-W23*S12)

- C_3*mu_t*T*(W12*W23)

+ C_4*mu_t*T*T* (W13*(S11*S11+S12*S12-S23*S23-S33*S33)-W12*(S11*S13+S22*S23+S23*S33)+W23*(S11*S12+S12*S22 +S13*S23))

+ C_6*mu_t*T*T* (S13*Sij)

+ C_7*mu_t*T*T* (S13*Wij);

C_UDSI(c,t,VW)= C_1*mu_t*T* (S12*S13+S22*S23+S23*S33)

+ C_2*mu_t*T*(W23*(S33-S22)-W12*S13-W13*S12)

+ C_3*mu_t*T*(W12*W13)

+ C_4*mu_t*T*T* (W23*(S12*S12+S22*S22-S13*S13-S33*S33)+W12*(S11*S13+S12*S23+S13*S33)+W13*(S11*S1 2+S12*S22+S13*S23))

+ C_6*mu_t*T*T* (S23*Sij)

+ C_7*mu_t*T*T* (S23*Wij);

C_UDMI(c,t,0)= -2.*mu_t*S11 + 2./3.*C_K(c,t) + C_UDSI(c,t,UU);

C_UDMI(c,t,1)= -2.*mu_t*S22 + 2./3.*C_K(c,t) + C_UDSI(c,t,VV);

C_UDMI(c,t,2)= -2.*mu_t*S33 + 2./3.*C_K(c,t) + C_UDSI(c,t,WW);

C_UDMI(c,t,3)= -2.*mu_t*S12 + C_UDSI(c,t,UV);

C_UDMI(c,t,4)= -2.*mu_t*S13 + C_UDSI(c,t,UW);

C_UDMI(c,t,5)= -2.*mu_t*S23 + C_UDSI(c,t,VW);

}

end_c_loop(c,t)

} }
  Reply With Quote

Old   February 3, 2006, 04:40
Default Re: Please help me run UDF code for source
  #2
Markus
Guest
 
Posts: n/a
There are at least some brackets missing for the thread_loop_c(t,domain)
  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
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 22:38
fluent UDF external library lapack problem Rick FLUENT 0 May 7, 2008 11:16
udf cannot run in windows but can in linux ra shmi FLUENT 2 February 14, 2006 13:12
public CFD Code development Heinz Wilkening Main CFD Forum 38 March 5, 1999 12:44
What kind of Cmmercial CFD code you feel well? Lans Main CFD Forum 13 October 27, 1998 11:20


All times are GMT -4. The time now is 14:22.