Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

How to obtain wall distance value for udf?

    • newbie123
      Subscriber
      I need to obtain wall distance and I try C_Wall_Distance(c,t) but it appears to be removed. I have been looking around but I can't find a solution.nIf wall distance value is not provided, it the y+ value provided? Likewise, what about the wall-based Reynolds number Re_y and is it provided or not?n
    • DrAmine
      Ansys Employee
      Please refer to the Customization Documentation which contains all documented and hence supported macros. I still see C_WALL_DIST somewhere in my internal notes. n
    • newbie123
      Subscriber
      Hi I can't find the command from the manual. I try using it but the solver crash when I initialize it. It shows 99999:mpt_accept error ...nnI am using Fluent 2020 R1n
    • DrAmine
      Ansys Employee
      Then probably bad access. It is not in the documentation and so is not supported. The usage might be deprecated. I see they are some other hidden function but I cannot share on this open platformn
    • newbie123
      Subscriber
      Is there other way at which I can obtain the wall distance value? n
    • Rob
      Forum Moderator
      Have a look for the macro c_wall_dist on Google, you'd be surprised how quickly you find the replacement. n
    • newbie123
      Subscriber
      I have been searching around but most of the search revolves around how to use C_Wall_dist which doesn't work in this case. So far I found a code but I am unsure how to use it.nhttps://www.cfd-online.com/Forums/fluent-udf/63211-calculate-distance-wall-neighbourig-cell-centroid.htmlnbegin_c_loop (c,t)n{nc_face_loop(c,t,n)n{ntf = C_FACE_THREAD(c,t,n);nif(THREAD_TYPE(tf) == THREAD_F_WALL)n{nf = C_FACE(c,t,n);nF_CENTROID(x,f,t);nwf = x[1]; /* for 2D */nC_CENTROID(cell,c,t);nnc = cell[1];ndist = FABS(wf-nc);n}n}n}nend_c_loop (c,t)nnMy issue is I don't know where to place it. I need the wall distance value for my eddy viscosity and I don't think I can't place the above into my EVM udf as it contains a loop which will lag my solver. How do I place the above code such that it only activates during the initialization step and that the calculated wall distance value can be used in later calculations subsequently?n
    • newbie123
      Subscriber
      Can you please tell me the highly accessible replacement you mention? I have been testing codes but none of them seem to workn
    • DrAmine
      Ansys Employee
      Please provide a university mail address so that I can share the new sets with you.n
    • Lukas Kramer
      Subscriber

      hey im a student from dresden and currently working on something receiving the same problem with c_wall_dist giving the error. could you share the outcome with me too please? 2 years later i still didnt find a documentation for it while browsing the web or looking in the costumization manual. c_wall_dist is still used there. i just find Boundary_face_geometry but its not what i need.

      kind regards

      lukas

       

    • DrAmine
      Ansys Employee

      The customization manual has an example where C_WALL_DIST is used.

      • Lukas Kramer
        Subscriber

        yeah. thats what i wrote. but its in an example and not documented as a function on how to use it. how i use it and i assume many people i read on forums do it produces sigsev node errors. its only used as argument in the geko and user_trans_alg_reg_cor functions in the manual. but its not clear how it writes the data to the function or how you could extract the data from c_wall_dist and save it for example in a udm for further use.

        do you have an idea on that topic?

        i also found this online, but it somehow flushes the UDM after one read out somehow. dont get it fully yet but it utilizes a function which is also supposed to be used in C_wall_dist (calc_cell_wall_distance_new). does it have something to do with pseudo local time steps?

        code:

        DEFINE_ON_DEMAND(calcDistance)
        {
        #if !RP_HOST

            Domain *d=Get_Domain(1);
            Thread *ct;
            cell_t c;

            if (! wall_dist_set)
            {
                Alloc_Storage_Vars(d, SV_RTMP_0, SV_NULL);
                Calc_Cell_Wall_Distance_New(d, SV_RTMP_0);
                
                thread_loop_c(ct,d)
                {
                    begin_c_loop(c,ct)
                    {
                        C_ABSTAND(c,ct) = C_TMP0(c,ct);
                    }
                    end_c_loop(c,ct)
                }

                wall_dist_set = TRUE;
            }
            
        #endif
        }

        DEFINE_ON_DEMAND(distanceReset)
        {
        #if !RP_HOST

            Domain *d=Get_Domain(1);
            Thread *ct;
            cell_t c;
            
            thread_loop_c(ct,d)
            {
                begin_c_loop(c,ct)
                {
                    C_DISTANCE(c,ct) = 0.0;
                }
                end_c_loop(c,ct)
            }

        #endif
            wall_dist_set = FALSE;
        }

         

    • DrAmine
      Ansys Employee

      Which are the arguments of the C_WALL_DIST which you do not understand? It does require Cell Index and Cell Thread. The macro does work for me.

      Yes there are some other macros / ways to access the wall distance which are not documented. One of these function is what you have found online. I remember I/ we wrote similar thing some years ago and posted on the Ansys Customer Portal. That has nothing to do with pseudo-time stepping.

    • Lukas Kramer
      Subscriber

      Hey thank you for your answer.

      Im using Ansys 2022 and when i use C_WALL_DIST with the correct arguments for Cell Index and Cell Thread it gives me sigsev errors for each node and crashes the program. I want to do a simple calculation where i loop over the cells in the thread and multiply something with C_WALL_DIST. For this i tried to put C_WALL_DIST in the calculation itself and also another approach where i tried to save C_WALL_DIST in an extra UDM first. Both approaches gave me the sigsev errors. Might there be any Problem with the datatype, which C_WALL_DIST gives to the calculation or UDM?

      I remember looking in Forums and some people had this problem with the sigsev errors too with no resolve. Thats why I tried to use the other method provided above.

    • Lukas Kramer
      Subscriber

      Note: the sigsev errors only occured when placing C_WALL_DIST into the calculation or trying to save it via UDM. The code works perfectly with any constant Wall distance value in the calculation. Also its just a simple rectangle 2D geometry with walls on 2 opposing sites, an inlet-velocity and an outflow.

    • DrAmine
      Ansys Employee

      Hi Lukas, I am using 23R1 and I am using the macro to access the wall distance and storing that in a cell memory. The procedure is working as it should. If it is not working for you and another apporach is doing the job: That is good too!

Viewing 14 reply threads
  • The topic ‘How to obtain wall distance value for udf?’ is closed to new replies.
[bingo_chatbox]