CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

patch region with UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 23, 2007, 05:48
Default patch region with UDF
  #1
cle3000
Guest
 
Posts: n/a
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!
  Reply With Quote

Old   January 23, 2007, 09:57
Default Re: patch region with UDF
  #2
Bogdan
Guest
 
Posts: n/a
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) } } }
  Reply With Quote

Old   January 23, 2007, 10:02
Default Re: patch region with UDF
  #3
cle3000
Guest
 
Posts: n/a
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.
  Reply With Quote

Old   January 23, 2007, 11:55
Default Re: patch region with UDF
  #4
Sujith
Guest
 
Posts: n/a
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.
  Reply With Quote

Old   January 25, 2007, 04:50
Default Re: patch region with UDF
  #5
cle3000
Guest
 
Posts: n/a
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)

}

} }
  Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[CGNS] CGNS converters available mbeaudoin OpenFOAM Meshing & Mesh Conversion 137 December 14, 2018 04:20
Cht tutorial in 15 braennstroem OpenFOAM Running, Solving & CFD 197 June 10, 2015 03:02
chtMultiRegionFoam Tutorial m.nichols19 OpenFOAM 12 September 9, 2010 11:56
Particle Tracking and Patch Region Sri FLUENT 0 November 18, 2008 02:49
[Netgen] Create boundary fabrizio OpenFOAM Meshing & Mesh Conversion 1 October 26, 2008 14:12


All times are GMT -4. The time now is 16:34.