CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

DPM: UDF - loop over all particles

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   February 1, 2007, 05:54
Default DPM: UDF - loop over all particles
  #1
chris
Guest
 
Posts: n/a
I would like to have my EXECUTE_AT_END udf loop over all particles in the domain. I would like to know how many particles there are in every cell. But i get a "Segmentation violation" when i want to access any variable that is beeing processed during the "begin_particle_cell_loop". I am using FLUENT 6.3

Thanks for your help!

This is my code:

DEFINE_EXECUTE_AT_END(execute_at_end) {

Thread *t;

Domain *d;

Particle *pi; /* Particle index for looping over all particles in the cell */

real numb_cell=0.;

real numb_part_dom=0.;

cell_t c;

d = Get_Domain(1); /* mixture domain if multiphase */

thread_loop_c(t,d)

{

begin_c_loop(c,t)

{

numb_cell += 1;

begin_particle_cell_loop(pi,c,t)

{

numb_part_dom += 1;

}

end_particle_cell_loop(pi,c,t)

}

end_c_loop(c,t)

}

printf("Number of cells %g\n", numb_cell);

printf("Number of particles %g\n", numb_part_dom);

fflush(stdout); }
  Reply With Quote

Old   July 11, 2009, 08:38
Default any solution?
  #2
New Member
 
Mayank Kumar
Join Date: May 2009
Posts: 4
Rep Power: 8
kmayank is on a distinguished road
Hey Chris,

Did you manage to get any solution to this problem? I am also stuck there.

Thanks
Mayank
kmayank is offline   Reply With Quote

Old   November 11, 2010, 00:20
Default
  #3
Member
 
john
Join Date: Nov 2010
Posts: 50
Rep Power: 6
johnwinter is on a distinguished road
Hi Kmayank,

Do you have any idea How to get particle concentration in each cell?.
I am facing that problem now. any suggestion

John
johnwinter is offline   Reply With Quote

Old   November 18, 2010, 16:39
Default
  #4
New Member
 
Rok Sibanc
Join Date: Sep 2009
Posts: 9
Rep Power: 7
snow is on a distinguished road
DEFINE_ON_DEMAND(particle_cells_count)
{
Domain *d;
Thread *t;
cell_t c;
Particle *p;

int particles;
int cells;

d = Get_Domain(1);

Alloc_Storage_Vars(d, SV_DPM_PARTICLE_BIN, SV_NULL);
bin_particles_in_cells(d);

particles=0;
cells=0;

thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
cells++;
begin_particle_cell_loop(p,c,t)
{
particles++;
}
end_particle_cell_loop(p,c,t)
}
end_c_loop(c,t)
}

Free_Storage_Vars(d, SV_DPM_PARTICLE_BIN, SV_NULL);

Message("Number of cells: %d\n",cells);
Message("Number of particles: %d\n",particles);
}
snow is offline   Reply With Quote

Old   December 1, 2010, 17:22
Default
  #5
Member
 
Roman Gobitz-Pfeifer
Join Date: Dec 2009
Location: Stuttgart
Posts: 76
Rep Power: 7
Wikie is on a distinguished road
hi,

are you able to compile the last code? I'm always getting the following error message:

error C2198: 'bin_particles_in_cells' : too few arguments for call

The error occurs in this line:

bin_particles_in_cells(d);

Any idea why I'm not able to compile this code??

cheers
wikie
Wikie is offline   Reply With Quote

Old   January 18, 2011, 02:38
Default
  #6
Member
 
Roman Gobitz-Pfeifer
Join Date: Dec 2009
Location: Stuttgart
Posts: 76
Rep Power: 7
Wikie is on a distinguished road
Hi,

I still stuck at this problem. I'm always getting the same error message saying: "error C2198: 'bin_particles_in_cells' : too few arguments for call".
Can anybody help me please, I have to know the number of particles to continue my work.

Thanks,
wikie
Wikie is offline   Reply With Quote

Old   January 18, 2011, 05:08
Default
  #7
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 8
coglione is on a distinguished road
I would do it the following way:

loop(I, Ilist)
{
loop(p, I->p)
{
c = P_CELL(p);
c_t = P_CELL_THREAD(p);
parcel_trapped+=1;
num_part=p->number_in_parcel;
}
}
cheers
cdf_user likes this.
coglione is offline   Reply With Quote

Old   January 19, 2011, 14:24
Default
  #8
Member
 
Roman Gobitz-Pfeifer
Join Date: Dec 2009
Location: Stuttgart
Posts: 76
Rep Power: 7
Wikie is on a distinguished road
Hi coglione,

thank you very much for your reply.
I wrote the UDF as you recommended, but I want to make sure that I understood erverything.
In my case I'm getting num_part = 12, parcel_trapped = 45 and number_in_parcel = 0. parcel_trapped is clear, this is the number parcel from my surface injection. But why is number_in_parcel = 0? This should be the number of particles in one parcel, isn't it? Do I have to multiple num_part x parcel_trapped to get the total number of particles in my domain??

thank you
Wikie

--------------------------

Here you can see my UDF.

#include "udf.h"

DEFINE_ON_DEMAND(particle_cells_count)
{
Injection *Ilist;
Injection *I;
Particle *p;
cell_t c;
Thread *c_t;
int parcel_trapped = 0;
int num_part = 0;
int number_in_parcel = 0;

Ilist = Get_dpm_injections();

loop(I, Ilist)
{
loop(p, I->p)
{
c = P_CELL(p);
c_t = P_CELL_THREAD(p);
parcel_trapped+=1;
num_part=p->number_in_parcel;
}
}

Message("num_part: %d\n",num_part);
Message("parcel_trapped: %d\n",parcel_trapped);
Message("number_in_parcel: %d\n",number_in_parcel);

}
Wikie is offline   Reply With Quote

Old   January 20, 2011, 04:04
Default
  #9
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 8
coglione is on a distinguished road
1) number_in_parcel is a member function of the particle class defined somewhere in the source code of Fluent --> you redefine and initialize it with zero what may cause the behaviour you observe.
2) number_in_parcel returns a floating point number --> define num_part as real

cheers
cdf_user likes this.
coglione is offline   Reply With Quote

Old   January 20, 2011, 12:53
Default
  #10
Member
 
Roman Gobitz-Pfeifer
Join Date: Dec 2009
Location: Stuttgart
Posts: 76
Rep Power: 7
Wikie is on a distinguished road
Hi coglione,

sorry it's me again. I change my UDF as recommended, but now the result is num_part=0 and parcel_trapped = 0 :-(
Could you please check my UDF again?

Thank you very much,
Wikie

#include "udf.h"

DEFINE_ON_DEMAND(particle_cells_count)
{
Injection *Ilist;
Injection *I;
Particle *p;
cell_t c;
Thread *c_t;
int parcel_trapped = 0;
real num_part = 0;

Ilist = Get_dpm_injections();

loop(I, Ilist)
{
loop(p, I->p)
{
c = P_CELL(p);
c_t = P_CELL_THREAD(p);
parcel_trapped+=1;
num_part=p->number_in_parcel;
}
}

Message("num_part: %d\n",num_part);
Message("parcel_trapped: %d\n",parcel_trapped);

}
Wikie is offline   Reply With Quote

Old   January 23, 2011, 09:18
Default
  #11
Member
 
Roman Gobitz-Pfeifer
Join Date: Dec 2009
Location: Stuttgart
Posts: 76
Rep Power: 7
Wikie is on a distinguished road
Hi coglione,

I still wasn't able to solve this problem. I looked up number_in_parcel in the dpm_types.h file and I found "real number_in_parcel; /* number of particles in parcel (unsteady only) */". I can use this just in unsteay simulation, am I right? But my simulation is steady :-( Any ideas to get the number of all particles in whole domain for stady cases?

I'm finally interested in the total reacting surface of all particles. Perhaps there is a better way to determine this area.

Greatings,
Wikie
Wikie is offline   Reply With Quote

Old   May 10, 2011, 11:15
Default
  #12
New Member
 
patty
Join Date: Nov 2010
Posts: 21
Rep Power: 6
TedBrogan is on a distinguished road
coglione (or anyone else for that matter),

Where did you find the command for loop(I,Ilist) { }? Stumbling upon this thread and finding that command was a major help for the udf I'm working on. I need a few more of these undocumented commands to finish the udf, and I was wondering if you knew of a place where I could find all of these. I've tried going through files like dpm.h, but I don't see how you could know loop(I,Ilist) is a command from that.

Specifically, I'm trying to change the start and stop time of unsteady particle injection in a udf. It's easy enough and documented how to change position, velocity, etc in the udf help files, but I can't find anything on this one.

Thanks!
TedBrogan is offline   Reply With Quote

Old   May 11, 2011, 01:05
Default
  #13
Member
 
Roman Gobitz-Pfeifer
Join Date: Dec 2009
Location: Stuttgart
Posts: 76
Rep Power: 7
Wikie is on a distinguished road
Hi TedBrogan,

this is the normal command for loops. You'll also find it in manuals. I also learned this due to my discussion here in the forum.

cheers
wikie
Wikie is offline   Reply With Quote

Old   March 20, 2012, 19:15
Default
  #14
Member
 
Join Date: Mar 2011
Posts: 50
Rep Power: 6
cdf_user is on a distinguished road
Quote:
Originally Posted by coglione View Post
I would do it the following way:

loop(I, Ilist)
{
loop(p, I->p)
{
c = P_CELL(p);
c_t = P_CELL_THREAD(p);
parcel_trapped+=1;
num_part=p->number_in_parcel;
}
}
cheers

Ilist = Get_dpm_Injections();

does not work. I get the error

function: "Get_dpm_Injections" not found (pc=12).

I have included udf.h, dpm.h, surf.h, mem.h, sg_mphase.h, sg.h,
cxiface.h

Please help!
cdf_user is offline   Reply With Quote

Old   March 20, 2012, 20:06
Default
  #15
Member
 
Join Date: Mar 2011
Posts: 50
Rep Power: 6
cdf_user is on a distinguished road
Quote:
Originally Posted by Wikie View Post
Hi coglione,

thank you very much for your reply.
I wrote the UDF as you recommended, but I want to make sure that I understood erverything.
In my case I'm getting num_part = 12, parcel_trapped = 45 and number_in_parcel = 0. parcel_trapped is clear, this is the number parcel from my surface injection. But why is number_in_parcel = 0? This should be the number of particles in one parcel, isn't it? Do I have to multiple num_part x parcel_trapped to get the total number of particles in my domain??

thank you
Wikie

--------------------------

Here you can see my UDF.

#include "udf.h"

DEFINE_ON_DEMAND(particle_cells_count)
{
Injection *Ilist;
Injection *I;
Particle *p;
cell_t c;
Thread *c_t;
int parcel_trapped = 0;
int num_part = 0;
int number_in_parcel = 0;

Ilist = Get_dpm_injections();

loop(I, Ilist)
{
loop(p, I->p)
{
c = P_CELL(p);
c_t = P_CELL_THREAD(p);
parcel_trapped+=1;
num_part=p->number_in_parcel;
}
}

Message("num_part: %d\n",num_part);
Message("parcel_trapped: %d\n",parcel_trapped);
Message("number_in_parcel: %d\n",number_in_parcel);

}

My Get_dpm_Injections does not works

Fluent says function Get_dpm_Injections not found

I have included "dpm.h"

Please Help!
cdf_user is offline   Reply With Quote

Old   April 21, 2012, 02:06
Default
  #16
Member
 
Join Date: Mar 2011
Posts: 50
Rep Power: 6
cdf_user is on a distinguished road
Quote:
Originally Posted by TedBrogan View Post
coglione (or anyone else for that matter),

Where did you find the command for loop(I,Ilist) { }? Stumbling upon this thread and finding that command was a major help for the udf I'm working on. I need a few more of these undocumented commands to finish the udf, and I was wondering if you knew of a place where I could find all of these. I've tried going through files like dpm.h, but I don't see how you could know loop(I,Ilist) is a command from that.

Specifically, I'm trying to change the start and stop time of unsteady particle injection in a udf. It's easy enough and documented how to change position, velocity, etc in the udf help files, but I can't find anything on this one.

Thanks!

If you go in system files of the fluent, you will find many .c files in include folder. One of those files is dpm.h. All the commands are listed there.
cdf_user is offline   Reply With Quote

Old   April 24, 2012, 03:00
Default CFD Simulation of Gas turbine Engine_ Combustion Chamber
  #17
Member
 
Join Date: Apr 2012
Location: Heidenheim
Posts: 51
Rep Power: 5
juzer_700 is on a distinguished road
Hello everyone,

Can anyone suggest me a good document/book to start with simulation in gas turbine engine (combustion chamber).

I am planning to do the post processing in FLUENT. Is Openfoam software better than Fluent for combustion purpose?

Also, I intend to use C language to develop the code. Does Fluent take code written in Fortran. And which one is better? Fortran or C?

Please help me as I'm a beginner in this field.
juzer_700 is offline   Reply With Quote

Old   April 24, 2012, 05:49
Default
  #18
Member
 
Join Date: Mar 2011
Posts: 50
Rep Power: 6
cdf_user is on a distinguished road
Fluent is better. Fluent takes c++ code for user defined functions. I dont much about combustion so cant really recommend a book. I have experience in simulating turbomachinary though..
cdf_user is offline   Reply With Quote

Old   April 24, 2012, 12:12
Default
  #19
ADI
New Member
 
Adithya nagesh
Join Date: Oct 2009
Posts: 9
Rep Power: 7
ADI is on a distinguished road
Send a message via MSN to ADI
JUZER_700, OpeanFOAM is completely custom. As in you can define your own equations for everything from Continuity to Turbulence and much more.

FLUENT commercial package however has a ton of these in-built and ready to use.

As for good books on gas turbine combustion chamber i suggest
GAS Turbine Combustion by Lefebvre, Mechanics and thermodynamics of Propulsion by Hill and petersen and the AIAA series book named Aerothermodynamicsof gas turbine and rocket propulsion by Oates...
__________________
Adi.
ADI is offline   Reply With Quote

Old   April 25, 2012, 01:46
Default
  #20
Member
 
Join Date: Apr 2012
Location: Heidenheim
Posts: 51
Rep Power: 5
juzer_700 is on a distinguished road
@ADI Thanks for the suggestion. I am planning to code advance combustion model and then link it to fluent/openfoam. I have certain parts of the code written in Fortran. Is there anyway I can directly use the fortran code in FLUENT?

Do I need to convert all the FORTRAn code into C language? Any method?

Please help.
juzer_700 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
DPM UDF Injection leads to 2 different particles sega Fluent UDF and Scheme Programming 3 March 10, 2010 20:38
DPM - do the particles affect the liquid? Nikhil Dani FLUENT 0 January 1, 2009 12:58
NACA0012 geometry/design software needed Franny Main CFD Forum 13 July 7, 2007 15:57
DPM: using UDF for creating and deleting Particles Markus Alzon FLUENT 0 July 4, 2007 01:18
DPM; particle seeded / deleted by UDF Laika FLUENT 6 January 23, 2006 00:40


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