CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   bin_particles_in_cells (https://www.cfd-online.com/Forums/fluent/135978-bin_particles_in_cells.html)

massoudepsilon May 21, 2014 02:20

bin_particles_in_cells
 
Hi everybody,

is there anyone who knows that what the macro (bin_particles_in_cells) exactly does?

Thank you so much,

HyperNova April 10, 2015 13:15

hi
From 3 years ago u are still stuck in that ?!

`e` April 10, 2015 19:40

Wow, you're not wrong, he's asked the same question on 11th of November 2011.

It appears this macro loops over all the particles in a domain on a cell-by-cell basis according to this page.

`e` April 10, 2015 19:41

If this macro has been removed (or altered) between versions of Fluent, you may require some code adjustments. What are you trying to achieve overall?

HyperNova April 11, 2015 00:58

hi 'e'
i wrote my code and i used

bin_particles_in_cells(d); /* particles are bined in each cell of the fluid domain */

but this works ok in fluent 6.3.26 but in v15.0 no, in v15.0 it changed , in cl_dpm.h it wrote :

FLUENT_EXPORT void bin_particles_in_cells(Domain *domain, cxboolean init_cells);

there is another argument and i dont know what to write there .

i am working with dpm and i want to add source terms to k and epsilon.

any idea ?
thanks for your reply

HyperNova April 11, 2015 01:00

Quote:

Originally Posted by `e` (Post 541096)
Wow, you're not wrong, he's asked the same question on 11th of November 2011.

It appears this macro loops over all the particles in a domain on a cell-by-cell basis according to this page.

:D:D:D:D i found him in another thread in 2011 as you mentioned :D;)

massoudepsilon April 11, 2015 02:37

[QUOTE=HyperNova;541073]hi
From 3 years ago u are still stuck in that ?!

4 years ago I needed this macro for a project. but I solved the problem with another method.
last year for another project I needed it again. but no one could answer my question. but I solved the problem on my own.

it seems that you feel high self confidence and make fun on the others. I am waiting to see how long it takes you to solve the problem.

good luck:D:D:D:D:D:D:D:D:D:D

`e` April 11, 2015 02:53

If you want to add source terms to k and e of the turbulence model of the continuous phase then use the DEFINE_SOURCE macro.

As for looping through all particles, try this code (source):

Code:

Injection *I, *Ilist = Get_dpm_injections();
Particle *p;

...

loop(I, Ilist) // loop through all injections
{
    loop(p, I->p) // loop through all particles
    {
        // all particles execute this code
    }
}


HyperNova April 11, 2015 05:07

masoud come on , i need it quick
i used

bin_particles_in_cells(d); /* particles are bined in each cell of the fluid domain */

but it just works in fluent 6.3.26 , in v15.0 it doeant work and it says it needs another argument! id cl_dpm it wrote

FLUENT_EXPORT void bin_particles_in_cells(Domain *domain, cxboolean init_cells);

i dont know what is cxboolean init_cells and what should i put there , masoud please help!

HyperNova April 11, 2015 05:08

this is my UDF

DEFINE_SOURCE(k_new_model_all_terms,c,t,dS,eqn) /* source term for the k equation */

{

Domain *d=Get_Domain(1); /* domain used in the particle loop. this should be the fluid domain , change index if necessary*/

Particle *p; /* particle index to be used in particle loop */

double umean[3], vmean[3], mass_mean, diamp, V_relative; /* declaration of variables */

double Skp, Sep, Rep, aaa, Mu, rho, TKEDR, TKE, v_mean[3];

int i; /* index used in for loops */

real g = 9.81; /* gravity constant */

real ce3 = 1.0; /* proportionality constant */

real x[ND_ND]; /* this will hold the position vector */

real depth = 0.42;
real injection_height = 0.01;
real Temp = 25.0;
real Pressure_REF = 101325.0;
real MolarWeight = 28.97; /* air */
real ST = 0.072;

real Ck1 = 6.0;
real Ck2 = 0.75;
real Ce1 = 4.0;
real Ce2 = 0.6;

real gas_density, P, Eo, Cd, Cd_sphere, Re, Cf, dpm_frac;
real a11, a22, a33, a12, a13, a21, a23, a31, a32, sen, Production_K;

Alloc_Storage_Vars(d, SV_DPM_PARTICLE_BIN, SV_NULL); /* memory is allocated for the particles which are to be bined in each cell */

bin_particles_in_cells(d); /* particles are bined in each cell of the fluid domain */

begin_particle_cell_loop(p, c, t) /* loops over all particle p which are contained in each cell c */

{

}

HyperNova April 11, 2015 07:59

Quote:

Originally Posted by `e` (Post 541117)
If you want to add source terms to k and e of the turbulence model of the continuous phase then use the DEFINE_SOURCE macro.

As for looping through all particles, try this code (source):

Code:

Injection *I, *Ilist = Get_dpm_injections();
Particle *p;

...

loop(I, Ilist) // loop through all injections
{
    loop(p, I->p) // loop through all particles
    {
        // all particles execute this code
    }
}


i put my code here , upper of this message, would you mind taking a look of that, that sentence in red color id making problem, i don't know why particles deleted from domain automaticly ,
with bin_particles_in_cells(d); Fluent says another argument is needed, in another thread (http://www.cfd-online.com/Forums/flu...s-command.html) LICH tried to put 0 1 true false as another argument but i did not work for him and me either, if you have any idea i will be thankful if you share it ,

massoudepsilon August 28, 2017 03:36

UDF for looping on all particles in each cell.
 
Since Fluent 12, the implementation of bin_particles_in_cells(domain, count) has changed and you need additional macro (unthread_particles_to_all_inj(domain, check)). Please be aware that this additional macro had only one argument at least until Fluent version 14. Since Fluent 17 it needs 2 arguments (domain and check (which is a boolean variable)).

Here is a simple UDF for looping on all particles in each cell.

DEFINE_ADJUST(Looping, domain)
{
cxboolean count;
cxboolean check;
Thread *t;
cell_t c;
Particle *p;

Alloc_Storage_Vars(domain, SV_DPM_PARTICLE_BIN, SV_NULL);

bin_particles_in_cells(domain, count);
thread_loop_c (t,domain)
{
begin_c_loop(c, t)

{

begin_particle_cell_loop(p,c,t)
{
/* you can do your calculation on particles in one cell here*/
}
end_particle_cell_loop(p, c, t)
}
end_c_loop(c, t)
unthread_particles_to_all_inj(domain, check);
Free_Storage_Vars(domain, SV_DPM_PARTICLE_BIN, SV_NULL); /* release allocated memory*/
}
}


All times are GMT -4. The time now is 20:41.