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

why the UDF cann't trap particles? thanks

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By bloodflow

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 5, 2017, 07:55
Question why the UDF cann't trap particles? thanks
  #1
New Member
 
Join Date: Feb 2017
Posts: 5
Rep Power: 9
guohf is on a distinguished road
Hello everyone,

I write UDF to loop all injection particles, and the particles will be trap by the wall when the distance between the particle and the wall equal or less than the radius of the particle.
The udf can be 'compiled' and compute. However, it cannot trap particles. Please help me and thanks.

This is my UDF:


#include "stdio.h"
#include "udf.h"
#include "dpm.h"
#include "mem.h"
#include "sg.h"
#include "math.h"
#include "surf.h" /* for macros: RP_Cell() & RP_Thread() */
#include "sg_mphase.h"



#define wall_id 9 /* wall face ID*/
#define dim 2 /* dimension number 2D or 3D */

DEFINE_ADJUST(trapparticle, domain)

{
cell_t pc;
face_t f;
Thread *ft, *tcell;
Injection *Ilist;
Injection *I;
Particle *p;


real fp_dis, x, y, radius,particlenum=0, total_volume=0.0;
real xc[ND_ND], xf[ND_ND];

int i; /*working counter for script*/

ft = Lookup_Thread(domain, wall_id); /* wall face*/

Ilist = Get_dpm_injections();
loop(I, Ilist)
{
loop(p, I->p) /* Standard ANSYS FLUENT Looping Macro to get particle streams in an Injection */
{
pc = P_CELL(p); /* Get the cell and thread that the particle is currently in */
tcell = P_CELL_THREAD(p); /* Particle Structure using new macros*/

radius=P_DIAM(p); /* Particle radius*/
x = P_POS(p)[0];
y = P_POS(p)[1];
C_UDMI(pc,tcell,0) = 0;

begin_f_loop(f,ft)
{
F_CENTROID(xf,f,ft); /*face centerial */
fp_dis=fabs(sqrt(SQR(x-xf[0]) + SQR(y-xf[1]))); /* the distance between particle centre and wall face*/

/* if the distance less than particle radius,particle velocity equal 0 and save particle cell 1 and particle position */
if(fp_dis <= radius)
{
for (i=0; i<dim; i++)
{
P_VEL(p)[i] = 0.0;
}
C_UDMI(pc,tcell,0) = 1;
C_UDMI(pc,tcell,1) = P_POS(p)[0];
C_UDMI(pc,tcell,2) = P_POS(p)[1];
particlenum +=1; /* if particle is trapped, increase particle-number */
MARK_PARTICLE(p, P_FL_REMOVED); /* Remove particle after accretion */

}
else
{
C_UDMI(pc,tcell,0) = 0;
C_UDMI(pc,tcell,1) = 0.0;
C_UDMI(pc,tcell,2) = 0.0;
particlenum +=0;

}
}
end_f_loop(f,ft)

C_UDMI(pc,tcell,3) = particlenum;


}
}
}
Attached Files
File Type: c particle2D_trap3.c (2.0 KB, 17 views)
guohf is offline   Reply With Quote

Old   April 18, 2017, 00:26
Default
  #2
New Member
 
Yoon
Join Date: Mar 2015
Location: Seoul
Posts: 22
Rep Power: 11
touyet is on a distinguished road
Did you get Answer of this problem? please share your UDF of this Method (Collection on Outer Boundary of Particle)
touyet is offline   Reply With Quote

Old   April 18, 2017, 19:32
Default
  #3
New Member
 
Join Date: Mar 2017
Posts: 8
Rep Power: 9
ctw987 is on a distinguished road
hi touyet! You seem to like the filter too much.
ctw987 is offline   Reply With Quote

Old   April 18, 2017, 19:35
Default
  #4
New Member
 
Join Date: Mar 2017
Posts: 8
Rep Power: 9
ctw987 is on a distinguished road
hi touyet!! Do you want anonymous?
ctw987 is offline   Reply With Quote

Old   April 23, 2019, 10:08
Default
  #5
Member
 
Sebi
Join Date: Mar 2019
Posts: 49
Rep Power: 7
bloodflow is on a distinguished road
Quote:
Originally Posted by guohf View Post
Hello everyone,

I write UDF to loop all injection particles, and the particles will be trap by the wall when the distance between the particle and the wall equal or less than the radius of the particle.
The udf can be 'compiled' and compute. However, it cannot trap particles. Please help me and thanks.

This is my UDF:


#include "stdio.h"
#include "udf.h"
#include "dpm.h"
#include "mem.h"
#include "sg.h"
#include "math.h"
#include "surf.h" /* for macros: RP_Cell() & RP_Thread() */
#include "sg_mphase.h"



#define wall_id 9 /* wall face ID*/
#define dim 2 /* dimension number 2D or 3D */

DEFINE_ADJUST(trapparticle, domain)

{
cell_t pc;
face_t f;
Thread *ft, *tcell;
Injection *Ilist;
Injection *I;
Particle *p;


real fp_dis, x, y, radius,particlenum=0, total_volume=0.0;
real xc[ND_ND], xf[ND_ND];

int i; /*working counter for script*/

ft = Lookup_Thread(domain, wall_id); /* wall face*/

Ilist = Get_dpm_injections();
loop(I, Ilist)
{
loop(p, I->p) /* Standard ANSYS FLUENT Looping Macro to get particle streams in an Injection */
{
pc = P_CELL(p); /* Get the cell and thread that the particle is currently in */
tcell = P_CELL_THREAD(p); /* Particle Structure using new macros*/

radius=P_DIAM(p); /* Particle radius*/
x = P_POS(p)[0];
y = P_POS(p)[1];
C_UDMI(pc,tcell,0) = 0;

begin_f_loop(f,ft)
{
F_CENTROID(xf,f,ft); /*face centerial */
fp_dis=fabs(sqrt(SQR(x-xf[0]) + SQR(y-xf[1]))); /* the distance between particle centre and wall face*/

/* if the distance less than particle radius,particle velocity equal 0 and save particle cell 1 and particle position */
if(fp_dis <= radius)
{
for (i=0; i<dim; i++)
{
P_VEL(p)[i] = 0.0;
}
C_UDMI(pc,tcell,0) = 1;
C_UDMI(pc,tcell,1) = P_POS(p)[0];
C_UDMI(pc,tcell,2) = P_POS(p)[1];
particlenum +=1; /* if particle is trapped, increase particle-number */
MARK_PARTICLE(p, P_FL_REMOVED); /* Remove particle after accretion */

}
else
{
C_UDMI(pc,tcell,0) = 0;
C_UDMI(pc,tcell,1) = 0.0;
C_UDMI(pc,tcell,2) = 0.0;
particlenum +=0;

}
}
end_f_loop(f,ft)

C_UDMI(pc,tcell,3) = particlenum;


}
}
}


Did anyone have any progress to this? I am attempting a similar thing
Mostafa Allahyari likes this.
bloodflow is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF acasas CFD Freelancers 1 January 23, 2015 07:26
is it possible to inject DPM particles via UDF? Saidul Fluent UDF and Scheme Programming 3 January 20, 2015 05:03
How to create over one particles in udf chaocaho_0627 FLUENT 0 July 26, 2014 22:43
Injecting Particles via UDF in Parallel FLUENT TedBrogan FLUENT 3 July 11, 2011 13:43
How to define a parabolic velocity inlet of particles with UDF zumaqiong FLUENT 2 February 22, 2010 09:46


All times are GMT -4. The time now is 13:14.