## Fluids

#### UDF to calculate distance from a specific boundary?

• Ferrero
Subscriber

Hello to everybody,

I am simulating a 2D axisymmetric CFD system with volumetric power generation coming from neutronic irradiation. In my system there is no localized source, but the power distribution (negative exponential) is dependent on the distance from a specified boundary, which is non-moving but has a complex shape.

I tried to write some UDFs to compute the distance from a given boundary, but the main problem is that if I use a face loop and a cell loop in the same function I get a SIGSEGV error, because of the different natures of the pointer. Is there something that I am missing? Is there a simpler method to compute the distance from a boundary (which is different from the nearest wall distance) that I am missing?

Thank you in advance.

• DrAmine
Ansys Employee
Workaround you change the type of the boundary to wall. In global UDM you store the value of wall distance to that wall. Then you switch back to whatever. Will that work for you (before solving Laplace Equations to have distances to boundaries calculated).
• Ferrero
Subscriber
I have a domain where fluid flows and I have to assign power Source to cells, dependent on the cell distance from a specific face. If I use a UDM I still have to point to the face and use the F_UDMI(f,t,i) MACRO to access the stored F_CENTROID values, while also acceding to a cell (for source MACRO) and if I am not mistaken, this causes me a SIGSEGV error. Probably this is a very easy task yet I have not resolved the problem yet.
Thank you for your assistance
• Ferrero
Subscriber
The only MACRO I found to compute the distance between cell and faces is the BOUNDARY_FACE_GEOMETRY macro, and in the example in the User Guide (ANSYS Fluent UDF Manual) it is used coupled with the connectivity macro F_C0 (inside a begin_f_loop inside a PROFILE macro). F_C0 sees only the nearest cell to a face, and I want to access the distance for all cells. Therefore this is not a solution to my problem.
The simplest method would be: access to a cell loop in a SOURCE macro, then loop over all faces of the specified boundary and update the distance value if this one is smaller than the smallest value registered. Best if this is done just once with a DEFINE_ON_DEMAND probably. But this method tries to access both faces and cells giving me a SIGSEGV error.
I hope that this can help us to find an effective solution