CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   UDF source terms (http://www.cfd-online.com/Forums/fluent/32396-udf-source-terms.html)

Andrew Garrard October 28, 2003 06:40

UDF source terms
 
I am starting to learn source terms in UDF, I have looked at the manual in section 4.3.8. I have a couple of questions:

1) Is it necessary to specify you dS term? What if your equation varies with as a function of a variable that you are not setting the source for, eg, you are setting heat source as a function of x velocity.

2) in the example what is the "fabs" part all about?

DEFINE_SOURCE(xmom_source, c, t, dS, eqn)

{

real x[ND_ND];

real con, source;

C_CENTROID(x, c, t);

con = C2*0.5*C_R(c, t)*x[1];

source = -con*fabs(C_U(c, t))*C_U(c, t);

dS[eqn] = -2.*con*fabs(C_U(c, t));


ap October 30, 2003 11:48

Re: UDF source terms
 
1) It's not necessary to define dS. You can define it or put dS=0. This, however, may afflict the stability of the solution because it forces FLUENT to explicitly manage the source term.

The dS term has to be defined as the derivative of the source term with respect to the dependent variable of the transport equation.

If your source is not function of the dependent variable of the transport equation, just set dS[eqn] = 0.

2) fabs is the C function which returns the absolute value of a float variable.

It's used to avoid an if statement for the dS[eqn] definition. You can write (supposing con > 0):


-con*(C_U)^2 if C_U >= 0
/
source = -con*|C_U|*CU =
\
con*(C_U)^2 if C_U < 0


so you'd have


-2*con*C_U if C_U >= 0
/
dS =
\
2*con*C_U if C_U < 0


which is equivalent to dS = -2*con*|C_U|

Hi :)

ap


All times are GMT -4. The time now is 17:33.