### Author Topic: Solution on computing the gradient of the volume fraction for multiphase VOF  (Read 9007 times)

#### william

• Full Member
• Posts: 159
• Reputation: +15/-0
• Know it, share it.
##### Solution on computing the gradient of the volume fraction for multiphase VOF
« on: November 12, 2016, 06:17:35 PM »
Suppose you have a multiphase VOF problem in ANSYS Fluent and you wish to calculate the gradient of the volume of fluid variable (VOF). One application would be to determine the local interfacial area of a cell, which is given by the product of the magnitude of the cell VOF gradient and the cell volume.

A User-Defined Function (UDF) can be written (see below) to calculate gradient of a flow variable using User Defined Scalars (UDS) and User Defined Memory locations (UDM). For any UDS, ANSYS Fluent can calculate the gradient using an available macro. Hence, passing the variable to a UDS permits the cell-centered gradient of any flow variable to be calculated. This vector result can then be stored in UDM arrays. The steps for doing this are as follows:
1. Read in the converged case and data
2. Compile the UDF listed below in the Interpreted mode (Define->User Defined->Functions->Intepreted). You may also Compile the UDF for your platform if desired (Define->User Defined->Functions->Compiled).
3. Hook up the DEFINE_ADJUST function (Define->User Defined->Function Hooks->Adjust Function)
4. Define UDM (Define->User Defined->Memory 1)
5. Define UDS (Define->User Defined->Scalars 1)
6. Turn off all equations (Solve->Controls->Solution)
7. Do one solver iteration
8. Execute the UDF store_gradient (Define->User Defined->Execute On Demand)

/* VOF gradient UDF */
# include ʺudf.hʺ
# define domain_ID 2
{
cell_t c;
face_t f;
domain = Get_Domain(domain_ID);
/* Fill UDS with the variable. */
{ begin_c_loop (c,t)
{ C_UDSI(c,t,0) = C_VOF(c,t); }
end_c_loop (c,t) }
begin_f_loop (f,t)
{F_UDSI(f,t,0) = F_VOF(f,t); }
end_f_loop (f,t) }
}
{
Domain *domain;
cell_t c;