CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   UDF to modify the value of a user defined scalar (

Raja Banerjee December 11, 2000 18:07

UDF to modify the value of a user defined scalar
Hi, I have a two-phase flow between two parallel plates. I am using VOF model to simulate the flow. I have introduced a user defined scalar and trying to assign a value to the scalar at the interface. I am finding the interface by determining the cells which have the liquid volume fraction between 0 and 1. I am using DEFINE_ADJUST macro as I want it to be done every iteration. But it is not assigning the scalar value at the interface. I am provding here the code which I have written:

#include "udf.h" #include "sg_mphase.h"

DEFINE_ADJUST(vol_frac_find, domain) {

Thread *t=Lookup_Thread(domain,8);

cell_t c;



if(C_VOF(c,t,1)>0. && C_VOF(c,t,1)<1.)





I would appreciate, if someone can point out my mistake.

The id that I have used in the Lookup_Thread function corresponds to the zone- default-interior in the boundary conditions dialog-box.

Thanks Raja Banerjee

Greg Perkins December 11, 2000 19:06

Re: UDF to modify the value of a user defined scal

DEFINE_ADJUST(find_vof, domain) {

cell_t c;

Thread *thread;

thread_loop_c (thread, domain)


begin_c_loop (c, thread)


if(C_VOF(c,thread,1)>0. && C_VOF(c,thread,1)<1.)



end_c_loop (c, thread)



Raja Banerjee December 12, 2000 01:52

Re: UDF to modify the value of a user defined scal
Thanks for your advice. But, the value that is being assigned is still not correct. The interface value seem to increase from zero to the maximum value as we go downstream. This should not happen because as can be seen from the code that the interface value is a constant and is not related to the distance in the downstream direction.

I would appreciate if have any suggestion for this behaviour. Raja

Greg Perkins December 12, 2000 02:14

Re: UDF to modify the value of a user defined scal
One point is - what are you doing with the scalar transport equation (0) which you use for assigning C_UDSI(c,t,0) = value ??

If you just want to use this as storage for this value you should turn off solution of the UDS from the GUI (see manual to deselect solving the eqn - I think its in solution - controls - etc.). Alternatively in Fluent 5.4 you can use a memory location C_UDMI(c,t,0) instead which is more efficient than using a scalar transport eqn as a storage location - see udf manual for 5.4.


Raja Banerjee December 12, 2000 11:42

Re: UDF to modify the value of a user defined scal
Well the idea of this whole excercise is that I am trying to determine the concentration of an evaporating liquid. As VOF does not support evaporation, I am introducing this scalar equation which is basically the species equation of the evaporating vapour. At the gas/liquid interface the mass fraction of the vapour corresponds to the saturated value, which is a function of vapour pressure. The diffusivity of the vapour inside the liquid is zero and a constant value in the gas phase.

Therefore the algorithm that I am trying to implement is:

1. Determine the interface i.e. 0<vol. frac <1 2. Assign saturated mass fraction at the interface, i.e C_UDSI(c,t,0) 3. Solve the scalar equation for the concentration profile over the liquid surface.

Therefore, I need to solve the scalar equation. Thanks Raja

All times are GMT -4. The time now is 12:46.