Author Topic: How can I compute gradient of VOF simulation  (Read 4971 times)

Offline infocfd

  • Newbie
  • *
  • Posts: 45
  • Reputation: +0/-0
  • Searching for solution
    • View Profile
How can I compute gradient of VOF simulation
« on: February 08, 2012, 10:17:44 AM »
Advertisement
Hi,

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

Thanks.

Offline william

  • Full Member
  • ***
  • Posts: 159
  • Reputation: +15/-0
  • Know it, share it.
    • View Profile
Re: How can I compute gradient of VOF simulation
« Reply #1 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)
3. Hook adjust funtion (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 iterations
8. Execute store_gradient (Define->User Defined->Execute On Demand)

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


# include "udf.h"
# define domain_ID 2

DEFINE_ADJUST(adjust_gradient, domain)
{
Thread *t;
cell_t c;
face_t f;

domain = Get_Domain(domain_ID);

/* Fill UDS with the variable. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDSI(c,t,0) = C_VOF(c,t);
}
end_c_loop (c,t)
}

thread_loop_f (t,domain)
{
if (THREAD_STORAGE(t,SV_UDS_I(0))!=NULL)
begin_f_loop (f,t)
{
F_UDSI(f,t,0) = F_VOF(f,t);
}
end_f_loop (f,t)
}

}

DEFINE_ON_DEMAND(store_gradient)
{
Domain *domain;
cell_t c;
Thread *t;

domain=Get_Domain(1);

/* Fill the UDM with magnitude of gradient. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDMI(c,t,0) = NV_MAG(C_UDSI_G(c,t,0));
}
end_c_loop (c,t)
}
}