bloodflow |
January 12, 2021 16:53 |
Found out how to get the variables I wanted in the less dodgy way with the code below. Ensure you tell it to allocate 6 scalars when you hook the Scalar_DPM UDF otherwise you'll get a SIGESV bullshit error.
PHP Code:
DEFINE_DPM_SCALAR_UPDATE(scalar_calc,cell,thread,initialize,p)
{
cell_t c = P_CELL(p); /* Define cell particle is in */
Thread *t = P_CELL_THREAD(p); /* Thread particle is in (General thread - not a phase thread!) */
Thread** pt;
pt = THREAD_SUB_THREADS(t); /* Pointer to the phase thread within general thread - [0] - Primary and [1] - Secondary*/
if (initialize)
{
P_USER_REAL(p,0) = C_MU_EFF_MIXTURE(c,t,pt,0); /* Plasma Viscosity */
P_USER_REAL(p,1) = C_MU_EFF_MIXTURE(c,t,pt,1); /* RBC Viscosity*/
P_USER_REAL(p,2) = C_VOF(c,pt[0]); /* PLASMA VOF */
P_USER_REAL(p,3) = C_VOF(c,pt[1]); /* RBC VOF */
P_USER_REAL(p,4) = C_STRAIN_RATE_MAG(c,pt[0]); /* Plasma Strain */
P_USER_REAL(p,5) = C_STRAIN_RATE_MAG(c,pt[1]); /* RBC Strain */
P_USER_REAL(p,6) = 0; /* Initial Variable for Activation Potential */
}
else
{
P_USER_REAL(p,0) = C_MU_EFF_MIXTURE(c,t,pt,0);
P_USER_REAL(p,1) = C_MU_EFF_MIXTURE(c,t,pt,1);
P_USER_REAL(p,2) = C_VOF(c,pt[0]);
P_USER_REAL(p,3) = C_VOF(c,pt[1]);
P_USER_REAL(p,4) = C_STRAIN_RATE_MAG(c,pt[0]);
P_USER_REAL(p,5) = C_STRAIN_RATE_MAG(c,pt[1]);
/* Calculation of Activation Potential at each particle step */
P_USER_REAL(p,6) = P_DT(p) * (P_USER_REAL(p,0) * P_USER_REAL(p,2) * P_USER_REAL(p,4) + P_USER_REAL(p,1) * P_USER_REAL(p,3) * P_USER_REAL(p,5));
}
}
|