-
-
April 26, 2022 at 11:26 pm
angelo_97
SubscriberHello 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)
April 28, 2022 at 1:40 pmRob
Forum ModeratorYou 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.
April 29, 2022 at 10:45 pmangelo_97
SubscriberThanksfor 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
May 3, 2022 at 12:54 pmRob
Forum ModeratorYes, 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?
May 3, 2022 at 4:57 pmangelo_97
Subscribermy 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 ??
May 3, 2022 at 10:25 pmangelo_97
Subscriberand i need your help for the previous question. Thanks in advance.
May 4, 2022 at 7:55 amAmine Ben Hadj Ali
Ansys EmployeeWhy are you writing messages? It will be executed for every particle whenever it is tracked.
I do not understand your question, probably.
May 4, 2022 at 8:38 amangelo_97
SubscriberI 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.
May 4, 2022 at 8:40 amangelo_97
SubscriberI have the same problem also if i inject 1 particles.
May 4, 2022 at 8:42 amangelo_97
SubscriberI 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
May 4, 2022 at 8:46 amRob
Forum ModeratorEach 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.
May 4, 2022 at 9:02 amangelo_97
Subscribersince 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.
May 4, 2022 at 10:22 amRob
Forum ModeratorYou'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.
May 4, 2022 at 11:03 amangelo_97
SubscriberOkay 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
May 4, 2022 at 11:22 amAmine Ben Hadj Ali
Ansys EmployeeThe force will be invoked and the UDF with it for each particle.
May 4, 2022 at 7:17 pmangelo_97
SubscriberThank you so much and for the reply, you clarified my doubts.
May 5, 2022 at 7:02 amAmine Ben Hadj Ali
Ansys EmployeeGreat!
Viewing 16 reply threads- The topic ‘Wall distance calculation’ is closed to new replies.
Ansys Innovation SpaceTrending discussionsTop Contributors-
2979
-
970
-
857
-
755
-
599
Top Rated Tags© 2025 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-

Ansys Assistant

Welcome to Ansys Assistant!
An AI-based virtual assistant for active Ansys Academic Customers. Please login using your university issued email address.

Hey there, you are quite inquisitive! You have hit your hourly question limit. Please retry after '10' minutes. For questions, please reach out to ansyslearn@ansys.com.
RETRY