|
[Sponsors] |
September 27, 2006, 10:41 |
udf begin_c_loop problems
|
#1 |
Guest
Posts: n/a
|
I am trying to write a udf in order to count the number of cells within a certain zone in my domain. I will then input a source in this zone the value of which will depend on the number of cells. I am doing this because I want to make sure I get the same source value in different zones that will have different number of cells (it is a tetrahedral grid.).
My main question/problems are: 1) Have I understood correctly in thinking the udf will put the source value in at each cell. 2) How does the fluent macro begin_c_loop….end_c_loop work. I was hoping to use it to loop through the cells to count the number in my zone and then use a second loop to input the source value but this does not seem to work. How can I get it to move out of the first loop? 3)I have pasted my code below. I put in a print to screen command at the end of the first loop counting cells to check what was happening. All that happens when I run this is it prints out the number of cells, and keeps adding to them and printing them out. When I compile I get several warnings saying my x[1], x[2] are used uninitialised and for the final line it gives a warning "Control reaches end of non-void function." Thanks for any help Abigail #include "udf.h" DEFINE_SOURCE(my_source, cell, thread, dS, eqn) { real x[3]; /* this will hold the position vector */ real source; real i; real no_of_cells; real Source_Quantity; real small_x_value,large_x_value,small_y_value,large_y_ value,small_z_value,large_z_value; small_x_value=2.08; large_x_value=2.18; small_y_value=1.10; large_y_value=1.20; small_z_value=1.625; large_z_value=1.725; begin_c_loop(cell,thread) { C_CENTROID(x,cell,thread); if ((small_x_value<=x[0])&(x[0]<=large_x_value)) { if ((small_y_value<=x[1])&(x[1]<=large_y_value)) { if((small_z_value<=x[2])&(x[2]<=large_z_value)) { /* Find number of cells source is inputted over*/ i=1; no_of_cells=no_of_cells+i; } else { } } else { } } else { } } end_c_loop(cell,thread) printf("\n Numberofcells=%f\n",no_of_cells); /*print no of cells to screen for check*/ Source_Quantity=(500/(no_of_cells)); begin_c_loop(cell,thread) { C_CENTROID(x,cell,thread); if ((small_x_value<=x[0])&(x[0]<=large_x_value)) { if ((small_y_value<=x[1])&(x[1]<=large_y_value)) { if((small_z_value<=x[2])&(x[2]<=large_z_value)) { source=(Source_Quantity); dS[eqn]=0; } else { source=0; dS[eqn]=0; } } else { source=0; dS[eqn]=0; } } else { source=0; dS[eqn]=0; } return source; } end_c_loop(cell,thread) } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dynamic Mesh UDF | Qureshi | FLUENT | 7 | March 23, 2017 08:37 |
parse error while interpreting udf | Kristin | Fluent UDF and Scheme Programming | 3 | March 15, 2012 07:43 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
problems with UDF to set contact angle | poiuy219 | Main CFD Forum | 0 | April 30, 2009 11:43 |
I need UDF help. | S.Whitney | FLUENT | 0 | October 15, 2007 12:29 |