CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   patch region with UDF (https://www.cfd-online.com/Forums/fluent/43446-patch-region-udf.html)

cle3000 January 23, 2007 06:48

patch region with UDF
 
Hello, I would like to patch a region in a domain with UDF and set the phase value for VOF to 1 each timestep. The problem is that I can't define the dimension of my rectangular volume. Do I have to define my node limits? I am a beginner so I would be pleased if there is any sample code. Thanks in advance for any help!

Bogdan January 23, 2007 10:57

Re: patch region with UDF
 
Have a look at the following code:

/************************************************** *************** UDF for initializing phase volume fraction ************************************************** ****************/ #include "udf.h" /* domain pointer that is passed by INIT function is mixture domain */ DEFINE_INIT(my_init_function, mixture_domain) { int phase_domain_index; cell_t cell; Thread *cell_thread; Domain *subdomain; real xc[ND_ND]; /* loop over all subdomains (phases) in the superdomain (mixture) */ sub_domain_loop(subdomain, mixture_domain, phase_domain_index) { /* loop if secondary phase */ if (DOMAIN_ID(subdomain) == 3) /* loop over all cell threads in the secondary phase domain */ thread_loop_c (cell_thread,subdomain) { /* loop over all cells in secondary phase cell threads */ begin_c_loop_all (cell,cell_thread) { C_CENTROID(xc,cell,cell_thread); if (sqrt(ND_SUM(pow(xc[0] - 0.5,2.), pow(xc[1] - 0.5,2.), pow(xc[2] - 0.5,2.))) < 0.25) /* set volume fraction to 1 for centroid */ C_VOF(cell,cell_thread) = 1.; else /* otherwise initialize to zero */ C_VOF(cell,cell_thread) = 0.; } end_c_loop_all (cell,cell_thread) } } }

cle3000 January 23, 2007 11:02

Re: patch region with UDF
 
Thank you for your response. This code creates a squerical region. I need a rectangular one with certain geometrical limits. My questions is if I need to take nodes into consideration.

Sujith January 23, 2007 12:55

Re: patch region with UDF
 
I hope, instead of udf you can specify an execute command and ask it to execute the commands to patch the region every time step. To make it easier you can write a journal file for patching. steps are as follows.

Go to write--->start journal and give journal file name. Then do the steps to patch the required area. Then stop journal (write--stop journal). You can open the journal in any text editor and delete the last command of stop journal and save it.

Now if u read the journal the performed actions will be repeated. So at execute commands specify to read the journal to read every time step. "file read journal"

It will be better to perform th above operations in TUI than GUI.

cle3000 January 25, 2007 05:50

Re: patch region with UDF
 
Thanks ... I will try this as well. This UDF works:

#include "udf.h" /* domain pointer that is passed by INIT function is mixture domain */ DEFINE_INIT(my_init_function, mixture_domain) {

int phase_domain_index;

cell_t cell;

Thread *cell_thread;

Domain *subdomain;

real xc[ND_ND];

/* loop over all subdomains (phases) in the superdomain (mixture) */

sub_domain_loop(subdomain, mixture_domain, phase_domain_index)

{

/* loop if secondary phase */

if (DOMAIN_ID(subdomain) == 3)

/* loop over all cell threads in the secondary phase domain */

thread_loop_c (cell_thread,subdomain)

{

/* loop over all cells in secondary phase cell threads */

begin_c_loop_all (cell,cell_thread)

{

C_CENTROID(xc,cell,cell_thread);

if sqrt(ND_SUM(-1< NODE_X(xc[0])< 1,

0.5<NODE_Y(xc[1])<5,

-1 <NODE_Z(xc[2])<0.75))

/* set volume fraction to 1 for centroid */

C_VOF(cell,cell_thread) = 1.;

else

/* otherwise initialize to zero */

C_VOF(cell,cell_thread) = 0.;

}

end_c_loop_all (cell,cell_thread)

}

} }


All times are GMT -4. The time now is 04:23.