CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   Writing UDF for DPM (

Cantstandit May 8, 2009 18:18

Writing UDF for DPM
I'm trying to write UDF that will inject particles with the initial velocities equal to those in cell of injection. Its my first UDF so I realy don't have any expirence, please help me!
This is what I wrote so far, it compiles but won't work.

#include "udf.h"

DEFINE_DPM_INJECTION_INIT(velocity_magnitude, I){

Particle *p;
cell_t cell;
Thread *cthread;

cell = P_CELL(p);
cthread = P_CELL_THREAD(p);
P_VEL(p)[0] = C_U(cell, cthread);
P_VEL(p)[1] = C_V(cell, cthread);
P_VEL(p)[2] = C_W(cell, cthread);


Actually it works if I hook it up to 1 injection, but when I try to do it with 2 injections at the same time it returns error


The udf-inject-init property was changed for  2 injections
Error: SET-CDR!: invalid argument [1]: wrong type [not a pair]
Error Object: #f

Amir May 11, 2009 01:48

I propose you to use DEFINE_DPM_SCALAR_UPDATE macro and use
P_VEL0 in your code.

good luck,;)

Cantstandit May 11, 2009 15:16

P_VEL0 is velocity of particle at the entry of current cell?
how do I make sure that "current cell" is the injection cell?
I want only to *inject* them at certain velocity (and DEFINE_DPM_SCALAR_UPDATE does not have Injection *I as an argument)

Amir May 12, 2009 07:43

to define injection you can use Injection *I
P_VEL0(p) is a special macro and it does not modified when
so it returns the value due to the first cell that contains the particle.

Amir May 12, 2009 07:48

note that the DEFINE_DPM_SCALAR_UPDATE has the particle argument
so you can use it without definition of injection.
also you do not to need to use a loop on particle or injections using this
define macro.

sfotovati September 20, 2010 20:30

run this macro parallel
Dear friends, I wrote a UDF using DEFINE_DPM_INJECTION_INIT and this work perfectly while I am using single CPU. As long as I am chaning it to parallel, then the particles go out of the geometry and everything is wrong. should I take any consideretaion while I want to run it in Parallel?

All times are GMT -4. The time now is 06:51.