Author Topic: Body Force UDF problem  (Read 16567 times)

Offline sfotovati

  • Newbie
  • *
  • Posts: 8
  • Reputation: +0/-0
  • Searching for solution
    • View Profile
Body Force UDF problem
« on: June 17, 2012, 12:45:22 AM »
Advertisement
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?
Sean

Offline william

  • Full Member
  • ***
  • Posts: 159
  • Reputation: +15/-0
  • Know it, share it.
    • View Profile
Re: Body Force UDF problem
« Reply #1 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));

Offline sfotovati

  • Newbie
  • *
  • Posts: 8
  • Reputation: +0/-0
  • Searching for solution
    • View Profile
Re: Body Force UDF problem
« Reply #2 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?
Sean

Offline sfotovati

  • Newbie
  • *
  • Posts: 8
  • Reputation: +0/-0
  • Searching for solution
    • View Profile
Re: Body Force UDF problem
« Reply #3 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!  :-[

Sean

Offline admin

  • Administrator
  • Newbie
  • *****
  • Posts: 11
  • Reputation: +0/-0
    • View Profile
Re: Body Force UDF problem
« Reply #4 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.

Offline sfotovati

  • Newbie
  • *
  • Posts: 8
  • Reputation: +0/-0
  • Searching for solution
    • View Profile
Re: Body Force UDF problem
« Reply #5 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,
Sean