|
[Sponsors] |
April 22, 2015, 22:21 |
Unknown lines in code
|
#1 |
New Member
Join Date: Apr 2015
Posts: 16
Rep Power: 11 |
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) Code:
#if RP_NODE Injection *I = tp->injection; Particle *p = NULL; #endif Code:
#if RP_NODE if (dpm_par.unsteady_tracking) 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 } |
|
April 22, 2015, 22:59 |
|
#2 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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) Code:
#if RP_NODE Injection *I = tp->injection; Particle *p = NULL; #endif Code:
if (dpm_par.unsteady_tracking) return; 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. |
|
April 22, 2015, 23:20 |
|
#3 | |
New Member
Join Date: Apr 2015
Posts: 16
Rep Power: 11 |
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:
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 Code:
if (initialize) { p->user[0] = 0.; } Thanks |
||
April 22, 2015, 23:37 |
|
#4 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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 Last edited by `e`; April 23, 2015 at 02:24. |
|
|
|
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 |