# CAPE Forum

## Ansys => Fluent => Topic started by: infocfd on February 08, 2012, 10:17:44 AM

Title: How can I compute gradient of VOF simulation
Post by: infocfd on February 08, 2012, 10:17:44 AM
Hi,

I am carrying out VOF simulation. I want to calculate the gradient VOF. Can any one suggest me how to do this?

Thanks.
Title: Re: How can I compute gradient of VOF simulation
Post by: william on February 08, 2012, 10:19:17 AM
You can use UDF for this purpose, see below:

/*************************************************************************
UDF used to calculate gradient for post-processing

User defined scaler (UDS) and user defined memory (UDM) are used.
For any UDS, fluent will automatically calculate the gradient. So,
We need to pass the variable to UDS, and fluent will caculate the
gradient for you. UDM is used to save the results.

Steps to take to make it work
1. Read in the converged case and data
2. Link the udf (Define->User Defined->Functions->Intepreted)
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 iterations
8. Execute store_gradient (Define->User Defined->Execute On Demand)

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

# 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;