|
[Sponsors] |
February 1, 2007, 05:54 |
DPM: UDF - loop over all particles
|
#1 |
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); } |
|
July 11, 2009, 09:38 |
any solution?
|
#2 |
New Member
Mayank Kumar
Join Date: May 2009
Posts: 4
Rep Power: 17 |
Hey Chris,
Did you manage to get any solution to this problem? I am also stuck there. Thanks Mayank |
|
November 11, 2010, 00:20 |
|
#3 |
Member
john
Join Date: Nov 2010
Posts: 50
Rep Power: 16 |
Hi Kmayank,
Do you have any idea How to get particle concentration in each cell?. I am facing that problem now. any suggestion John |
|
November 18, 2010, 16:39 |
|
#4 |
New Member
Rok Sibanc
Join Date: Sep 2009
Posts: 9
Rep Power: 17 |
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); } |
|
December 1, 2010, 17:22 |
|
#5 |
Member
Roman Gobitz-Pfeifer
Join Date: Dec 2009
Location: Stuttgart
Posts: 83
Rep Power: 17 |
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 |
|
January 18, 2011, 02:38 |
|
#6 |
Member
Roman Gobitz-Pfeifer
Join Date: Dec 2009
Location: Stuttgart
Posts: 83
Rep Power: 17 |
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 |
|
January 18, 2011, 05:08 |
|
#7 |
Senior Member
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17 |
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 |
|
January 19, 2011, 14:24 |
|
#8 |
Member
Roman Gobitz-Pfeifer
Join Date: Dec 2009
Location: Stuttgart
Posts: 83
Rep Power: 17 |
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); } |
|
January 20, 2011, 04:04 |
|
#9 |
Senior Member
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17 |
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 |
|
January 20, 2011, 12:53 |
|
#10 |
Member
Roman Gobitz-Pfeifer
Join Date: Dec 2009
Location: Stuttgart
Posts: 83
Rep Power: 17 |
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); } |
|
January 23, 2011, 09:18 |
|
#11 |
Member
Roman Gobitz-Pfeifer
Join Date: Dec 2009
Location: Stuttgart
Posts: 83
Rep Power: 17 |
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 |
|
May 10, 2011, 12:15 |
|
#12 |
New Member
patty
Join Date: Nov 2010
Posts: 21
Rep Power: 16 |
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! |
|
May 11, 2011, 02:05 |
|
#13 |
Member
Roman Gobitz-Pfeifer
Join Date: Dec 2009
Location: Stuttgart
Posts: 83
Rep Power: 17 |
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 |
|
March 20, 2012, 19:15 |
|
#14 | |
Member
Join Date: Mar 2011
Posts: 50
Rep Power: 15 |
Quote:
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! |
||
March 20, 2012, 20:06 |
|
#15 | |
Member
Join Date: Mar 2011
Posts: 50
Rep Power: 15 |
Quote:
My Get_dpm_Injections does not works Fluent says function Get_dpm_Injections not found I have included "dpm.h" Please Help! |
||
April 21, 2012, 03:06 |
|
#16 | |
Member
Join Date: Mar 2011
Posts: 50
Rep Power: 15 |
Quote:
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. |
||
April 24, 2012, 04:00 |
CFD Simulation of Gas turbine Engine_ Combustion Chamber
|
#17 |
Member
Join Date: Apr 2012
Location: Mainz, Germany
Posts: 60
Rep Power: 14 |
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. |
|
April 24, 2012, 06:49 |
|
#18 |
Member
Join Date: Mar 2011
Posts: 50
Rep Power: 15 |
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..
|
|
April 24, 2012, 13:12 |
|
#19 |
New Member
|
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. |
|
April 25, 2012, 02:46 |
|
#20 |
Member
Join Date: Apr 2012
Location: Mainz, Germany
Posts: 60
Rep Power: 14 |
@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. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
DPM UDF Injection leads to 2 different particles | sega | Fluent UDF and Scheme Programming | 4 | December 28, 2017 23:57 |
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 16:57 |
DPM: using UDF for creating and deleting Particles | Markus Alzon | FLUENT | 0 | July 4, 2007 02:18 |
DPM; particle seeded / deleted by UDF | Laika | FLUENT | 6 | January 23, 2006 00:40 |