|
[Sponsors] |
UDF to loop over Inlet and inject particles at the face centroids |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 20, 2022, 06:40 |
UDF to loop over Inlet and inject particles at the face centroids
|
#1 |
New Member
Vera
Join Date: Jan 2022
Posts: 2
Rep Power: 0 |
Hello everyone,
I am trying to inject particles starting from my velocity-inlet. I have already managed to inject particles via a surface injection. However, I don't want to inject a particle from every face center, but only if the face centers have a defined distance to the center of the inlet. For example, I would like to inject particles with a certain mass flow and a certain size only in a certain radius around the inlet center point. To achieve this, I would like to use a UDF. I tried it with the macro DEFINE_DPM_INJECTION_INIT and can predefine one particle in each iteration with set diameter and mass flow at a defined position. I would like to loop over this and inject particles with my predefined settings in each iteration on the face centroids that are within the radius. However, as soon as I loop over the inlet with begin_f_loop(f, thread) and set the command loop(p, I->p_init) within the face loop, no more particles are injected at all, because the loop command that is supposed to apply the particles is no longer executed. I am very new to CFD and especially UDF, so I am not sure if the loop over the faces can be executed like this. Therefore I would be very grateful if someone could help me. I am also attaching my previous code so that errors can be identified and hopefully I can be helped further. Many thanks in advance, Vera dpm_surface_v2.c |
|
January 25, 2022, 08:34 |
|
#2 |
New Member
Vera
Join Date: Jan 2022
Posts: 2
Rep Power: 0 |
Hello everyone,
I have modified my code and wanted to share my progress with you. With the new code, I can loop over the inlet faces and inject particles if the distance of the face center to the inlet center is smaller than the radius I have specified (dpm_radius in the code). It worked, after I changed the position of the command loop(p, I->p_init). It needs to be executed first. Then the command begin_f_loop(f, thread) can be executed within the loop over the particles. My final goal now would be to inject one particle per parcel at the face centers within the defined radius with desired properties (like particle/parcel diameter, mass flow and position). Is it possible to define not only the conditions for the particles, but also for the parcels? The problem is that depending on whether I select surface injection or single injection in the DPM settings in Fluent, the loop(p, I->p_init) command is repeated as many times as the number of faces of the inlet (surface injection) or only once (single injection). In a simplified example, my velocity-inlet has 126 faces. If I choose a surface injection, the command loop(p, I->p_init) is executed 126 times, within this loop the loop begin_f_loop(f,thread) is executed 126 times again, because looping should be done over all faces and the face center should be stored using F_CENTROID. That means I loop 126 * 126 times. Of the 126 faces of my inlet, 7 face centers are within the radius dpm_radius given by me. Consequently 126 * 7 particles are injected on the inlet and distributed on 126 parcels. If I choose single injection, the command loop(p, I->p_init) is executed once and the command begin_f_loop(f,thread) loops over all faces again. Since again 7 face centers are within the radius dpm_radius, 7 particles are injected and due to the setting single injection they are injected in one parcel. The option one particle per parcel in the DPM settings is not selectable once I specify the UDF. Is there a possibility to define the number of particles in the parcels as well as the number of injected parcels independently from the Fluent DPM settings like single or surface only in UDF? This is the new code: #include "udf.h" #include "surf.h" #include "dpm.h" DEFINE_DPM_INJECTION_INIT(wuerfeltest,I) { Particle *p; cell_t cell; face_t f; real r; int zone_ID = 12; Domain *domain; domain = Get_Domain(1); Thread *thread = Lookup_Thread(domain,zone_ID); Thread *cthread; /*the centroid of the boundary face (x0,y0,z0) */ real x0 = 0.0702225; real y0 = -0.0911812; real z0 = 1.3; real x[3]; /*the maximum radius of the offset where particles should be emitted*/ real dpm_radius = 0.005; /*radius of the pipe in m*/ loop(p, I->p_init) { begin_f_loop(f,thread) { /* this function stores the center coordinates of every face in the predefined 2D or 3D vector x*/ F_CENTROID(x,f,thread); /* three-dimensional pythagoras to calculate distance */ r = pow(pow((x[0]-x0),2)+pow((x[1]-y0),2)+pow((x[2]-z0),2),0.5); if (r < dpm_radius) { cell = PP_CELL(p); /*Get the cell and thread that * the particle is currently in */ cthread = PP_CELL_THREAD(p); P_POS(p)[0] = x[0]; P_DIAM(p) = 3e-7; P_RHO(p) = 1000.0; P_MASS(p) = 1.413716694115407e-17; P_FLOW_RATE(p) = 1.979203371761569e-15; } } end_f_loop(f,thread) } } Thank you all in advance, Vera |
|
February 2, 2022, 20:11 |
|
#3 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
it should be tested, but in your code you have macros to get cell and thread where particle is located, this could be your way out
Code:
cell = PP_CELL(p); /*Get the cell and thread that * the particle is currently in */ cthread = PP_CELL_THREAD(p); 1. on_demand macro to define cells adjusted to inlet (c0,thread0) 2. check if they are inside radius 3. if yes -> set udmi_0 = 1, else 0 (udmi - user define memory) 4. inside loop(p, I->p_init) you can use macros mentioned above to get cell thread Code:
cell = PP_CELL(p); /*Get the cell and thread that * the particle is currently in */ cthread = PP_CELL_THREAD(p);
__________________
best regards ****************************** press LIKE if this message was helpful |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF to get the average temperator of a face and use it to in a boundary condition | mperrin | Fluent UDF and Scheme Programming | 4 | December 18, 2020 06:34 |
inject particles of different densities - kinematiccloud | benz25 | OpenFOAM Pre-Processing | 24 | June 19, 2017 04:49 |
DPMFoam diverged when inject particles with high "nParticle" | bijan darbari | OpenFOAM Running, Solving & CFD | 0 | July 30, 2016 04:03 |
is it possible to inject DPM particles via UDF? | Saidul | Fluent UDF and Scheme Programming | 3 | January 20, 2015 06:03 |
HELP! how inject the same number of particles that exits the domain? | matiashess | Fluent UDF and Scheme Programming | 3 | October 10, 2013 12:09 |