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

C_CENTROID macro

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 9, 2016, 22:19
Default C_CENTROID macro
  #1
Senior Member
 
Join Date: Mar 2014
Posts: 375
Rep Power: 13
hwet is on a distinguished road
Hi I Have taken the below code from the UDF manual from the example using the DEFINE_INIT macro.
I am wondering how C_CENTROID is able to pin point the location of a cell with the following code. The thread could be containing a lot of cells...Shouldn't it be returning the positions of all the cells in the thread?

Code:
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)
hwet is offline   Reply With Quote

Old   February 9, 2016, 23:48
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
The macro C_CENTROID(xc,cell,cell_thread) has three arguments: real x[ND_ND] (variable for holding the cell centroid coordinates), cell_t cell (unique integer for the cell within the cell thread) and Thread *t (pointer to the cell's thread).

Check the lines of code immediately above your excerpt:

Code:
/* loop over all cells in secondary phase cell threads */
begin_c_loop_all (cell,cell_thread)
This macro loops over all cells within the thread "cell_thread" and returns the cell ID of each one, "cell".
`e` is offline   Reply With Quote

Old   February 10, 2016, 00:13
Default
  #3
Senior Member
 
Join Date: Mar 2014
Posts: 375
Rep Power: 13
hwet is on a distinguished road
From the manual
Quote:
The function sets up a spherical volume
centered at 0.5, 0.5, 0.5 with a radius of 0.25. A secondary-phase volume fraction of 1 is then patched to the cells within the spherical volume, while the volume fraction for the secondary phase in all other cells is set to 0.
This UDF initializes the secondary phase which means that 1)There was secondary phase already in the flow domain+now it was initialized to new values. 2) There was no secondary phase and it was introduced through this initialization. Looping over all the cells should then patch the volume fraction in all the cells in the volume(the whole geometry), not just the spherical volume with radius 0.25. I want to know how these lines patched the volume fraction in this region alone.

Quote:
This macro loops over all cells within the thread "cell_thread" and returns the cell ID of each one, "cell".
Is this similar to the Zone ID's which can be seen/listed in numbers from the GUI. Or can i only give a UDF the cell ID's depending on some 'if' statement of a property in a cell and depend on the UDF to use that statement, get the cell based on that statement and process it with what I want?

Hope I make sense.
hwet is offline   Reply With Quote

Old   February 10, 2016, 00:23
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
The DEFINE_INIT macro allows you to have greater control over the initial conditions using a UDF (this macro is called after the initialisation and before the first iteration). The phases should already be created and this macro modifies the initial values.

The example includes a conditional if statement to allocate a volume fraction of either unity (inside sphere) or zero (outside sphere). This statement uses the cell centroid coordinates (found with C_CENTROID) to calculate the radial distance from the origin of the sphere (located at x=y=z=0.5 m).

Code:
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.;
Quote:
Originally Posted by hwet View Post
Is this similar to the Zone ID's which can be seen/listed in numbers from the GUI. Or can i only give a UDF the cell ID's depending on some 'if' statement of a property in a cell and depend on the UDF to use that statement, get the cell based on that statement and process it with what I want?
The thread ("t") can be matched to the cell zone IDs but the cell number ("c") is unique for each cell within a thread.
`e` is offline   Reply With Quote

Old   February 10, 2016, 00:40
Default
  #5
Senior Member
 
Join Date: Mar 2014
Posts: 375
Rep Power: 13
hwet is on a distinguished road
Now it makes sense!!! woah

So difficult to understand all this UDF science
hwet is offline   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
Macro within a Macro beyonder1 Tecplot 1 September 4, 2015 19:33
StarCCM+ Command line options and Macro execution isidp STAR-CCM+ 8 January 29, 2013 06:00
Macro Trouble -Winows Explorer Crashes with Macro Martin Castillo FLUENT 1 July 25, 2007 05:18
Macro problem cfddummy Siemens 1 April 9, 2007 13:37
Call a macro from a macro Flav Siemens 2 July 1, 2004 06:42


All times are GMT -4. The time now is 20:12.