CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   udf init random particles positions (https://www.cfd-online.com/Forums/fluent/34311-udf-init-random-particles-positions.html)

olivia August 2, 2004 10:37

udf init random particles positions
 
Hello everyone! Hope somebody can give me a helping hand: i m currently trying to create a udf to set the initial positions of particles that will be tracked. I want them to be random, so i try to get the coords of random cell centers and apply them to the particles. But there is somehting wrong in my udf. I get a segmentation violation message; can someone help me, please? I m not a udf power user and it is the first time that i wrote something in C...

Thank you very much.

here is my prog: #include "udf.h" #include <stdio.h> #include <stdlib.h> #include <time.h>

DEFINE_DPM_INJECTION_INIT(random_pos,I) { real x[ND_ND]; cell_t c; Thread *t; Tracked_Particle *p; int i,j,k,nb; nb=RP_Get_Real("nb_particles"); int m[nb];

for (j=0;j=nb-1;j++) { srand( time(NULL) ); A: c=rand()%nb; m[j]=c; if (j!=0) { for (k=0;k=j-1;k++)

{

if (m[k]=m[j])

{

goto A;

}

} } C_CENTROID(x,c,t); }

for (i=0;i=2;i++) { P_INIT_POS(p)[i]=x[i]; } }


Ryan Zarnitz August 2, 2004 18:24

Re: udf init random particles positions
 
If you are not good with UDF's (like me), I suggest manually (or with a programming language of your choice) generating a file of the particle initial positions and using the read-from-file injection type. The file format is shown in 21.9.2 of the 6.1 users guide.

olivia August 3, 2004 03:35

Re: udf init random particles positions
 
Good idea! I think i will use the gambit mesh file to get some nodes coords and i will use a ramdomization prog to select a part of them.

Thanks a lot, Ryan!!


All times are GMT -4. The time now is 11:03.