Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Wall distance calculation

    • angelo_97
      Subscriber

      Hello guys I found a problem in a UDF. I have to calculate the distance of the particle respect to the wall. I did a loop to find the minimum distance. My questions are:

      1) how can I know in which face of the thread i found the minimum distance

      2) how can I create a normal vector in that point in such ba why to project the vector "vec" in that direction


      This is my UDF, thanks in advance


      /* UDF adding an external body force to the particles */

      #include "udf.h"

      #include "dpm.h"

      #include "dpm_mem.h"

      #include "surf.h"


      DEFINE_DPM_BODY_FORCE(particle_body_force, p, i)

      {


        /* declaration of variables */

        double w, Dh, Ufx, Ufy, Ufz, Gx, rho, a, F_L, c_height, c_length,

          c_volume, side, H, W, f_height_total, Renx, Reny, Renz, crDh, mu, aUfx, aUfy, aUfz, C1, C2, C3, C4, C_Ly, C_Lz, z, y, distancewall, cosine;


        real xw[ND_ND];

        real vec[ND_ND];

        Domain* d;

        cell_t c;

        Thread* t;

        face_t f; //f is the face index that is inside the face thread t(our wall). You will extract the face area vector from f index 

        d = Get_Domain(1);

        c = P_CELL(p); //cell in witch the particle is currently in 

        t = Lookup_Thread(d, 9); //9 is the ID number of the upper wall. t is the thread index(pointer) of the wall boundary surface 9


        distancewall = 100; //i'm setting a generic initial value

        begin_f_loop(f, t)

        {

          F_CENTROID(xw, f, t); //center of each face 

          NV_VV(vec, =, xw, -, P_POS(p)); //vector connecting the particle to the face center that is placed at the wall. The NV_VV do the operation between 2 vectors :(vec=xw-P_POS(p))


          //now you want to calculate the minimum distance between particle and wall, and so you want to find the minimum of the vector vec doing the loop over all the boundary face


          if (distancewall >= NV_MAG(vec))

          {

            distancewall = NV_MAG(vec);

          }

        }

        end_f_loop(f, t)

    • Rob
      Forum Moderator
      You might be better off finding the cell distance from the nearest wall for every cell, storing that and then getting particles to check that. Otherwise every particle needs to update in every step which might be computationally expensive.
    • angelo_97
      Subscriber
      Thanksfor the answer, my issue is that okay i found the minimum distance of the particle respect to the wall but for example when Inject one particle i see that every DPM interaction i obtain a lot of message of wall distance and other message that i wrote in the Udf. For example i wrote on UDF on message: the min distance is distance Wall but i have a lot of message in the console like this(or i wanna say similar) and I'm not understanding.
      In fact if i inject a lot of particles i take like 6/7 minutes only for DPM interaction.
      I thought that in the DPM interaction the particle is able to move and fluent will calculate a lot of times, or i don't know if the particles will move only when I do iterations of fluid.
      One time step is composed by 20 iterations and i have 2 DPM iterations each 10 itaration.
      If i want to inject 2500 particles is not possible because I take a lot of time.

      The Udf is written in serial, but when I open fluent i choose parallel with 0 processors because if i use serial and i import my UDF fluent switch automatically to parallel but my UDF is not parallelized and so i cannot compile it.
      If i use parallel with 1 processors i get error when I compile.

      Thanks in advance

    • Rob
      Forum Moderator
      Yes, the wall distance will be calculated every time the DPM position is updated. What error do you see if you try and compile in parallel?
    • angelo_97
      Subscriber
      my question is: how much time i will enter in the udf. I know that in dpm bodyforce i should enter 3 times for i=0,1 and 2 but i didn't get 3 message in the DPM but more. my question is how much ??
    • angelo_97
      Subscriber
      and i need your help for the previous question. Thanks in advance.
    • DrAmine
      Ansys Employee
      Why are you writing messages? It will be executed for every particle whenever it is tracked.
      I do not understand your question, probably.
    • angelo_97
      Subscriber
      I printed the value of the force and due to UDF body force,fluent will enter 3 times for x,y and z. But i don't see only 3 messages but it's like multiplying a lot of times.



    • angelo_97
      Subscriber
      I have the same problem also if i inject 1 particles.
    • angelo_97
      Subscriber
      I don't understand why i have a lot of messages. I don't know if also in DPM the particle can move and so i have a lot of values but i don't know

    • Rob
      Forum Moderator
      Each parcel has it's position checked every time it moves. That's typically on entering a cell, 1-2 time in the cell and on leaving. In transient you get (default) 500 particle sub steps per time step, in steady it's 5000 (which often isn't enough). So, each particle will generate up to 500 messages per time step, or 5000 per track.
    • angelo_97
      Subscriber
      since that I'm using transient simulation with a time step size of 0.001second composed by 20 iterations and a DPM composed by 2 iterations (each 10 itaration), i will get up to 250 messages in a single DPM iteration?
      Because the DPM iteration is splitter in 2 times in the time step size.

    • Rob
      Forum Moderator
      You'll get up to 1000 per time step, with up to 500 per DPM update. With the accuracy control tools the number of steps may be reduced if the particles aren't changing direction very much.
    • angelo_97
      Subscriber
      Okay now it's clear thank you so much you was so gently. I have only the last question.
      The UDF will calculate the force for each particle? Because I see that if i inject 4 particles the value that i have on the console seems refered only to one particle. I don't know if in the UDF i have to call also the fact that i have more particle. I saw something related to loop over all the injection but i don't know.
      Thank you again for the time that you are investing with me
    • DrAmine
      Ansys Employee
      The force will be invoked and the UDF with it for each particle.
    • angelo_97
      Subscriber
      Thank you so much and for the reply, you clarified my doubts.
    • DrAmine
      Ansys Employee
      Great!

Viewing 16 reply threads
  • The topic ‘Wall distance calculation’ is closed to new replies.