|
[Sponsors] |
February 9, 2016, 22:19 |
C_CENTROID macro
|
#1 |
Senior Member
Join Date: Mar 2014
Posts: 375
Rep Power: 13 |
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) |
|
February 9, 2016, 23:48 |
|
#2 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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) |
|
February 10, 2016, 00:13 |
|
#3 | ||
Senior Member
Join Date: Mar 2014
Posts: 375
Rep Power: 13 |
From the manual
Quote:
Quote:
Hope I make sense. |
|||
February 10, 2016, 00:23 |
|
#4 | |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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:
|
||
February 10, 2016, 00:40 |
|
#5 |
Senior Member
Join Date: Mar 2014
Posts: 375
Rep Power: 13 |
Now it makes sense!!! woah
So difficult to understand all this UDF science |
|
|
|
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 |