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

Unknown lines in code

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By `e`

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 22, 2015, 22:21
Default Unknown lines in code
  #1
New Member
 
Join Date: Apr 2015
Posts: 16
Rep Power: 11
why? is on a distinguished road
Hi This is a code I found online and trying to understand.

Could someone tell the difference between using pointer p and tp as the tracked particle pointers.

Also what do the lines
Code:
void assign_init_mass_to_tp_and_p(Tracked_Particle *tp, real mass_factor)
and
Code:
#if RP_NODE
Injection *I = tp->injection;
Particle *p = NULL;
#endif
and
Code:
#if RP_NODE
if (dpm_par.unsteady_tracking)
do.

The full code is below. (Not quite, I have still cut out the second part of the code).


Code:
#include "udf.h"

#define BREAKUP_SMALL 1e-8

void assign_init_mass_to_tp_and_p(Tracked_Particle *tp, real mass_factor)
{
#if RP_NODE
Injection *I = tp->injection;
Particle *p = NULL;
#endif

P_INIT_MASS(tp) *= mass_factor;

#if RP_NODE
if (dpm_par.unsteady_tracking)
return;

loop(p, I->p)
if (p->part_id == tp->part_id)
P_INIT_MASS(p) *= mass_factor;
#endif
}
why? is offline   Reply With Quote

Old   April 22, 2015, 22:59
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
You can name variables and pointers however you desire; using *tp, *p, *areallylongpointername has no affect on your code.

Code:
void assign_init_mass_to_tp_and_p(Tracked_Particle *tp, real mass_factor)
Defines a function which returns nothing ("void"). Two arguments are passed to this function: *tp and mass_factor with data types of Tracked_Particle and real, respectively.

Code:
#if RP_NODE
Injection *I = tp->injection;
Particle *p = NULL;
#endif
For compute nodes, declare and initialise the *I (injection stream) and *p pointers. As this code does not loop through particle injections, I'd expect this function to be called for each injection.

Code:
if (dpm_par.unsteady_tracking)
return;
If the unsteady tracking option is enabled within DPM then the function returns immediately without executing the lines below (initialising the particle parcel masses).

Side note: looping through particles with I->p loops over all particles regardless of their state and residence time. Use I->p_init for initialising unsteady particles.
`e` is offline   Reply With Quote

Old   April 22, 2015, 23:20
Default
  #3
New Member
 
Join Date: Apr 2015
Posts: 16
Rep Power: 11
why? is on a distinguished road
Actually this code is posted here and apparently breaks an injected droplet into two droplets after a certain plane is passed.
HTML Code:
http://cape-forum.com/index.php/topic,528.0.html
Quote:
Defines a function which returns nothing ("void").
Why would you define a function which returns nothing?

Also, is this code in steady state initializing the particle data twice?
Code:
loop(p, I->p) if (p->part_id == tp->part_id) P_INIT_MASS(p) *= mass_factor; #endif
and also initializing earlier
#if RP_NODE Injection *I = tp->injection; Particle *p = NULL; #endif
From the second part
Code:
if (initialize)
{
p->user[0] = 0.;
}
What is user[0] here?
Thanks
why? is offline   Reply With Quote

Old   April 22, 2015, 23:37
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
The code modifies values in arrays, namely P_INIT_MASS(p), and therefore has no requirement of returning a value.

The particle and injection pointers are only initialised and declared once, regardless of steady/unsteady state, with:

Code:
#if RP_NODE
Injection *I = tp->injection;
Particle *p = NULL;
#endif
I'd imagine this code is from an older version of Fluent where the developers used the -> for collecting variables. It's recommended you use the new equivalent user-defined macro P_USER_REAL(p,0).
why? likes this.

Last edited by `e`; April 23, 2015 at 02:24.
`e` 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
The FOAM Documentation Project - SHUT-DOWN holger_marschall OpenFOAM 242 March 7, 2013 13:30
Small 3-D code Zdravko Stojanovic Main CFD Forum 2 July 19, 2010 11:11
OpenFOAM15 paraFoam bug koen OpenFOAM Bugs 19 June 30, 2009 11:46
compressible two phase flow in CFX4.4 youngan CFX 0 July 2, 2003 00:32
own Code vs. commercial code Bernhard Mueck Main CFD Forum 10 February 16, 2000 11:07


All times are GMT -4. The time now is 15:03.