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/)
-   -   UDF in Cell Zone (Adjacent Cells) (https://www.cfd-online.com/Forums/fluent-udf/243879-udf-cell-zone-adjacent-cells.html)

joshuawong2011 July 11, 2022 05:27

UDF in Cell Zone (Adjacent Cells)
 
Hello,

I am hooking a UDF onto a phase cell zone condition to fix the velocities in each cell which will depend on the adjacent cells' density. I am using DEFINE_PROFILE(name,thread,i) for this purpose. My workflow to achieve this in the UDF is:
  1. Loop over all cells.
  2. Within the loop, loop over all faces of each cell to get the face index and thread using C_FACE and C_FACE_THREAD
  3. Using the face index and thread obtained, get the adjacent cell index and thread using F_C0, F_C0_THREAD and F_C1, F_C1_THREAD.
  4. Using the cell index and thread, get the adjacent cell density (C_R).

I drafted my UDF with guidance from the manual. My problem is that when I try to initialize my case in Fluent, I get a an error "Received signal SIGSEGV". I have checked that the c_loop works using that Message, but when I enable the c_face_loop, initializing the case gives me the error. Interestingly, when I initialize the c_loop with check1, the error happens as well but initializing with check2 has no problem (the difference being that check2 is initialized during declaration.**

real check1, check2 =0;
begin_c_loop(c,thread)
{
* * *Message ("OK");
* * *// check1 =1;
* * *// check2 = 1;
* * *c_face_loop(c,thread,n)
* * *{
.......
}
}

May I know if the workflow for getting adjacent cell properties above is correct, and also what am I doing wrong in there? Thank you.

AlexanderZ July 14, 2022 21:41

i think you don't need second loop (c_face_loop(c,thread,n))
use C_FACE and C_FACE_THREAD as a second step and continue with workflow

joshuawong2011 July 14, 2022 22:38

I've tried removing the c_face_loop, still does not work and gives me the "Received signal SIGSEGV" error when initializing.

AlexanderZ July 18, 2022 00:50

show your code


All times are GMT -4. The time now is 04:27.