CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   HELP! adding a mass source to VOF eqn. by UDF??? (

ROOZBEH May 26, 2003 03:18

HELP! adding a mass source to VOF eqn. by UDF???
Hi all; I want to model the sheet cavitation with the VOF method. But this model has not any mass source terms to model the mass transfer during the cavitation. I have written a UDF. But when I compiled my UDF by "INTERPRETED" option successfully,during the initialization I resived an "access violation" error.

I think that I shoud compile my udf with the "compile" option. But I can not compile my udf.

Please see my UDF and tell me a suggestion if you have an experience.

My source terms are combination of evaporation and condensation process. I have take Inance senocak model.

I think and found that my main problem is from the macro :"C_VOF(cell,pt[1])" , because without this macro I have not any problem during the initialization after compilation by "interpreted" option, but I require this macro! ****************** my udf *************************

#include "udf.h"

#define Cdest 9e5

#define Cprod 3e4

#define Vdens .5542

#define Ldens 998.2

#define pv 101175

#define U 1

#define Lch .136 DEFINE_SOURCE(Vcond, cell, thread, dS, eqn) { Thread **pt; double source; double vof;

vof = C_VOF(cell,pt[1]); source = (Cprod * Vdens * (pow((1-vof),2) - pow((1-vof),3))) / (Ldens * (Lch / U)); dS[eqn] = (Cprod * Vdens * (2 * (1-vof) - 3 * pow((1-vof),2))) / (Ldens * (Lch / U));

return source; }

/* ************************************************** ***** */

DEFINE_SOURCE(Levap, cell, thread, dS, eqn) { Thread **pt; /* initialize pt */ double source; double vof; double p; double min; double pabs;

vof = C_VOF(cell,pt[1]); p = C_P(cell,thread); pabs = p + 101325; min = 0;

if ( (pabs-pv) < 0 )

min = (pabs-pv);

source = (Cdest * Vdens * (1-vof) * min) / (Ldens * .5 * Ldens * (U*U) * (Lch / U)); dS[eqn] = (Cdest * Vdens * min) / (Ldens * .5 * Ldens * (U*U) * (Lch / U));

return source; }


Shiping Liu May 27, 2003 09:43

Re: HELP! adding a mass source to VOF eqn. by UDF?
why don't use "patch"?

Raja Banerjee May 27, 2003 18:15

Re: HELP! adding a mass source to VOF eqn. by UDF?
The reason you are getting an access violation is because you are not using the correct thread when calling the C_VOF macro. The thread that you are passing from the DEFINE_SOURCE is most probably in the mixture domain. It depends from where you are calling this udf inside FLUENT. If the thread refers to mixture domain, you need to extract the phase thread. Say you want to volume fraction of the secondary phase, then use secondary_thread=THREAD_SUB_THREAD(thread,1) where "thread" is from your DEFINE_SOURCE function. In your code you are using *pt, which is not defined anywhere. HEnce the access violation. Also, remember, the "thread" is phase thread if you are calling it from boundary condition->fluid->(your phase)->source term. From all other places it is mixture thread.

santi May 28, 2003 22:20

Re: HELP! adding a mass source to VOF eqn. by UDF?
Try to compile in Visual C++ until no error occur, then follow the procedure to link the library to FLUENT , so that you can use 'compile' option in UDF, not 'interprete' option. I also try the same. Good luck

mahesh May 29, 2003 09:54

Re: HELP! adding a mass source to VOF eqn. by UDF?
Dear roozbeh,

While adding a source term to ur udf, it is called through the respective phase. So its better to first access the mixture domain using the phase & then again access the phases u want in your computation.

Can u send me the model & its info u r used for solving it. Because I am also slving a problem for condensation ( Using Mixture model).



All times are GMT -4. The time now is 18:57.