CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   I wrote a UDF to return the maximum velocity within 2 inches of a specified surface. (https://www.cfd-online.com/Forums/fluent/245217-i-wrote-udf-return-maximum-velocity-within-2-inches-specified-surface.html)

cnemecek05 September 21, 2022 20:36

I wrote a UDF to return the maximum velocity within 2 inches of a specified surface.
 
I wrote a UDF to return the maximum velocity within 2 inches of a specified surface. To accomplish this, I defined a cell register to get all cells within 2 inches of that specified surface. I then used the register to separate out a new cell zone. The UDF loops over all cells within that new cell zone and returns the max velocity and cell centroid of where the max velocity occurs. I separated out the new cell zone for two reasons: 1) to reduce the number of cells to loop through and 2) to limit the cells to the surface of interest (ie, I wanted to exclude all other surfaces/walls other than the one I am interested in). Without separating out the cell zone, I would have had to loop over all cells in the entire domain and all face cells of the surface of interest to determine if the volume cell was within 2 inches.

I believe the above can be accomplished via expressions. However, I believe I can only return the maximum velocity within the cell register and not the location of that velocity using expressions.

Is there a way to accomplish the whole UDF (ie, find max velocity and location within 2 inches of desired surface) using expressions? Is there a better was to accomplish this via UDF? Is there a function that will calculate the distance between a face zone ID and cell or does that have to be programmed manually as described above (ie, looping over all cells and face cells)?

Can you give C_WALL_DIST(c,cell_thread) a face_thread instead of a cell_thread, where the face_thread would be the id a wall?

AlexanderZ September 26, 2022 00:30

the way you explained your case makes me doubting you have working code,
show your code if you need help

cnemecek05 September 26, 2022 15:28

1 Attachment(s)
AlexanderZ - The attached UDF code does work for my applications. Was just wondering if there was a better way.


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