CAPE Forum

Ansys => Fluent => Topic started by: sfotovati on June 17, 2012, 12:45:22 AM

Title: Body Force UDF problem
Post by: sfotovati on June 17, 2012, 12:45:22 AM
hi every body,

I wrote the following UDF:

# include "udf.h"
# include "stdio.h"
# include "dpm.h"
# include "mem.h"
# include "surf.h"
# define mag 2.0
DEFINE_DPM_BODY_FORCE(partbf,p,i)
{
    double bforce=0., Bc=0.;
    Thread *t;
    cell_t c;
    Particle *pi;
    t = P_CELL_THREAD(p);
    c = P_CELL(p);
    begin_particle_cell_loop(pi,c,t)
    {
       Bc+=0.2/mag;
    }
    end_particle_cell_loop(pi,c,t)
    bforce=Bc+1.;       
    return bforce; 
}

But as I am running it it gives me the following error:

Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: #f

Can anybody help me please?
Title: Re: Body Force UDF problem
Post by: william on June 19, 2012, 08:40:24 AM
You should use the following to get the cell in which the particle is in:

cell_t c  = RP_CELL(&(tp->cCell));
Thread *t = RP_THREAD(&(tp->cCell));
Title: Re: Body Force UDF problem
Post by: sfotovati on June 20, 2012, 07:26:35 AM
Thanks for the hint.

I am wondering to know if I use the above to obtain cell and thread, then can I use begin_particle_cell_loop or not?
Title: Re: Body Force UDF problem
Post by: sfotovati on June 20, 2012, 04:34:36 PM
William, Even though I used those macros for obtaining cell and thread of the particle, it still does not let me to loop over other particles. So I am still recieving the same error!  :-[

Title: Re: Body Force UDF problem
Post by: admin on June 20, 2012, 05:32:31 PM
To loop over all the injections, you first need to get a list of all the injections you have defined. This can be done using the following command

Injection *Ilist = Get_dpm_injections();

You will also have to define a generic injection pointer

Injection *I;

Now, looping over all the injections can be done using the following command

loop(I, Ilist)
{
}
You can loop over all the particles from a given injection. To do that, you first need to define a particle pointer

Particle *p;

Looping over all the particles can be done using

loop(p, I->p)
{
}
In unsteady DPM calculations, if you want to initialize the transient particles, you will require the following loop
loop(p, I->p_init)
{
}

You can use these loops to fetch particle data using particle specific macros like

P_DIAM(p) for particle diameter
P_T(p) for particle temperature etc.
Title: Re: Body Force UDF problem
Post by: sfotovati on June 26, 2012, 12:48:31 AM
Thanks,

But apparently, if you want to combine the above with define_dpm_body_force, it cannot be done. All you mentioned is correct if one does not aim to combine it with macros which consider tracked particles in sequential order.

Thank you anyway,