CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   how to search all cells that have the same value of x[0] (https://www.cfd-online.com/Forums/fluent-udf/83267-how-search-all-cells-have-same-value-x-0-a.html)

lig December 21, 2010 21:33

how to search all cells that have the same value of x[0]
 
Hi, All,

Thank you for taking your time. I have a problem on how to loop search all cells that have the same value of x[0] in a domain using UDF of FLUENT.

Thanks,

lig

Bernhard December 22, 2010 07:45

If you want to do it for the same value of x[0] each time, you can mark the cells (Adapt > Mark), which you can then access in your UDF as a separate zone. Otherwise I see no better alternative than to loop over all cells and check x[0].

ComputerGuy December 24, 2010 13:22

Try this unchecked code...It is a partial UDF, in that I don't know where you're using it (DEFINE_PROPERTY, etc...), but it should loop over all threads and all cells in a domain. Note that this assumes your UDF is passed a domain pointer.

Code:

real value_to_search_for;
Thread *c_thread;
cell_t c;
real xc[ND_ND];

/* your value here */
value_to_search_for=5.0;

thread_loop_c(c_thread, domain) /*loops over all cell threads in domain*/
{
begin_c_loop(c, c_thread)    /* loops over cells in a cell thread  */
        {                       
                C_CENTROID(xc,c,c_thread);
                if (xc[0]==value_to_search_for)
                {
                        /* your code here */
                }
        }                       
end_c_loop(c, c_thread)               
}


lig December 31, 2010 00:46

Hi, ComputerGuy,

Really thank you for the reply. I was working on my code using the similar method you mentioned. However, I could not be able to make the program work. The main purpose is to get the summation of values of cells in same rows of a zone (the code is for the source term in UDS and applied for a porous zone). If possible, could you please help me to check the code I wrote? If so I am really appreciated, and please tell me your email address that I can sent the code file to you.

Thanks and Happy New Year,

Lig

ComputerGuy December 31, 2010 00:55

Check your inbox. Reply with your code.

Cheers!


All times are GMT -4. The time now is 14:17.