|
[Sponsors] |
August 2, 2004, 11:37 |
udf init random particles positions
|
#1 |
Guest
Posts: n/a
|
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]; } } |
|
August 2, 2004, 19:24 |
Re: udf init random particles positions
|
#2 |
Guest
Posts: n/a
|
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.
|
|
August 3, 2004, 04:35 |
Re: udf init random particles positions
|
#3 |
Guest
Posts: n/a
|
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!! |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
DPM: UDF - loop over all particles | chris | Fluent UDF and Scheme Programming | 31 | June 17, 2020 06:52 |
Parallel INIT UDF trouble | mil3st3g | Fluent UDF and Scheme Programming | 2 | January 6, 2011 15:07 |
UDF for sampling particles from multiple injections | JaC | Fluent UDF and Scheme Programming | 0 | March 31, 2010 11:43 |
How to define a parabolic velocity inlet of particles with UDF | zumaqiong | FLUENT | 2 | February 22, 2010 10:46 |
Problem trapping Particles with UDF | J. Krick | FLUENT | 2 | November 19, 2008 03:28 |