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

Help: the output of DPM

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 27, 2010, 10:16
Default Help: the output of DPM
  #1
New Member
 
xinyu zhao
Join Date: Sep 2009
Posts: 19
Rep Power: 16
zhaoxinyu is on a distinguished road
Hi!
In unsteady DPM model, how to output the position and velocities of particles in a cell at a certain time using UDF?

Last edited by zhaoxinyu; April 27, 2010 at 12:01.
zhaoxinyu is offline   Reply With Quote

Old   April 27, 2010, 12:08
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
I once obtained this from Fluent support desk. Good luck
Code:
/********************************************************************/ 
/* */
/* Hook on the DPM panel under DPM Scalar Update */
/* */
/********************************************************************/

#include "udf.h"
#include "dpm.h"

DEFINE_DPM_SCALAR_UPDATE(track_dpm_particles,c,t,initialize,p)
{
if (RP_Get_Boolean("dpm/unsteady-tracking?"))
{

if (initialize)
{

float time = RP_Get_Real("flow-time");
float x = p->state.pos[0];
float y = p->state.pos[1];
float u = p->state.V[0];
float v = p->state.V[1];
#if RP_3D
float z = p->state.pos[2];
float w = p->state.V[2];
#endif

FILE *fd;
int id = p->part_id;
char whoru[80];
sprintf(whoru,"dpm_positions%f.out",time);
fd = fopen(whoru, "a");
#if RP_3D
fprintf(fd, "%i %f %e %e %e %e %e %e %e %e %e \n", id, time, x, y, z, u, v, w, P_T(p), P_MASS(p), P_RHO(p));
#else
fprintf(fd, "%i %f %e %e %e %e %e %e %e \n", id, time, x, y, u, v, P_T(p), P_MASS(p), P_RHO(p));
#endif
fclose(fd);

}
}

else
{
float time = RP_Get_Real("flow-time");
float x = p->state.pos[0];
float y = p->state.pos[1];
float u = p->state.V[0];
float v = p->state.V[1];
#if RP_3D
float z = p->state.pos[2];
float w = p->state.V[2];
#endif

FILE *fd;
int id = p->part_id;
char whoru[80];
sprintf(whoru,"dpm_positions%f.out",time);
fd = fopen(whoru, "a");
#if RP_3D
fprintf(fd, "%i %f %e %e %e %e %e %e %e %e %e \n", id, time, x, y, z, u, v, w, P_T(p), P_MASS(p), P_RHO(p));
#else
fprintf(fd, "%i %f %e %e %e %e %e %e %e \n", id, time, x, y, u, v, P_T(p), P_MASS(p), P_RHO(p));
#endif
fclose(fd);
}

}
Bernhard is offline   Reply With Quote

Old   April 27, 2010, 19:07
Default
  #3
New Member
 
xinyu zhao
Join Date: Sep 2009
Posts: 19
Rep Power: 16
zhaoxinyu is on a distinguished road
Quote:
Originally Posted by Bernhard View Post
I once obtained this from Fluent support desk. Good luck
Code:
/********************************************************************/ 
/* */
/* Hook on the DPM panel under DPM Scalar Update */
/* */
/********************************************************************/
 
#include "udf.h"
#include "dpm.h"
 
DEFINE_DPM_SCALAR_UPDATE(track_dpm_particles,c,t,initialize,p)
{
if (RP_Get_Boolean("dpm/unsteady-tracking?"))
{
 
if (initialize)
{
 
float time = RP_Get_Real("flow-time");
float x = p->state.pos[0];
float y = p->state.pos[1];
float u = p->state.V[0];
float v = p->state.V[1];
#if RP_3D
float z = p->state.pos[2];
float w = p->state.V[2];
#endif
 
FILE *fd;
int id = p->part_id;
char whoru[80];
sprintf(whoru,"dpm_positions%f.out",time);
fd = fopen(whoru, "a");
#if RP_3D
fprintf(fd, "%i %f %e %e %e %e %e %e %e %e %e \n", id, time, x, y, z, u, v, w, P_T(p), P_MASS(p), P_RHO(p));
#else
fprintf(fd, "%i %f %e %e %e %e %e %e %e \n", id, time, x, y, u, v, P_T(p), P_MASS(p), P_RHO(p));
#endif
fclose(fd);
 
}
}
 
else
{
float time = RP_Get_Real("flow-time");
float x = p->state.pos[0];
float y = p->state.pos[1];
float u = p->state.V[0];
float v = p->state.V[1];
#if RP_3D
float z = p->state.pos[2];
float w = p->state.V[2];
#endif
 
FILE *fd;
int id = p->part_id;
char whoru[80];
sprintf(whoru,"dpm_positions%f.out",time);
fd = fopen(whoru, "a");
#if RP_3D
fprintf(fd, "%i %f %e %e %e %e %e %e %e %e %e \n", id, time, x, y, z, u, v, w, P_T(p), P_MASS(p), P_RHO(p));
#else
fprintf(fd, "%i %f %e %e %e %e %e %e %e \n", id, time, x, y, u, v, P_T(p), P_MASS(p), P_RHO(p));
#endif
fclose(fd);
}
 
}
Thanks for you help!
zhaoxinyu is offline   Reply With Quote

Old   August 3, 2011, 07:40
Default
  #4
New Member
 
Ro'ee Orland
Join Date: Nov 2010
Posts: 18
Rep Power: 15
orland is on a distinguished road
when I tried to use that code, all the particle id's get the value zero
has this also happened to you?
orland is offline   Reply With Quote

Old   April 25, 2016, 02:52
Default
  #5
New Member
 
Outside US and Canada
Join Date: Apr 2015
Location: Beijing
Posts: 9
Rep Power: 11
arctan is on a distinguished road
The code works fine except that it writes duplicated data for me, the positions and velocities are repeated 4 times in the .out file, why? and how to fix it?
arctan is offline   Reply With Quote

Old   April 25, 2016, 03:50
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Are you working in parallel mode with four processes? In that case, the reason that you get four lines is that this code is not meant for parallel computing.

This can be fixed by parallelizing the code (putting the correct macro's in the right position, see Fluent manual for more info). But if you are not familiar with this, it might be better to just ignore the extra output you get.
pakk is offline   Reply With Quote

Old   April 25, 2016, 04:50
Default
  #7
New Member
 
Outside US and Canada
Join Date: Apr 2015
Location: Beijing
Posts: 9
Rep Power: 11
arctan is on a distinguished road
The thing is that I'm working in serial, so it's weird that I'm getting four lines. My computer has four cores though, I'm not sure if it has anything to do with four cores.
arctan is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to name the DPM Output file deepinheart Main CFD Forum 0 April 14, 2009 12:19
DPM - do the particles affect the liquid? Nikhil Dani FLUENT 0 January 1, 2009 11:58
[Other] Output Format of MetaMesh t42 OpenFOAM Meshing & Mesh Conversion 0 August 3, 2007 04:28
Output for DPM macros Js FLUENT 0 February 7, 2005 17:23
Help with DPM UDF for OUTPUT needed Zhengcai Ye FLUENT 0 January 5, 2004 16:58


All times are GMT -4. The time now is 05:07.