CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Separate phase data in DPM_SCALAR_UPDATE (https://www.cfd-online.com/Forums/fluent-udf/233079-separate-phase-data-dpm_scalar_update.html)

bloodflow January 12, 2021 10:40

Separate phase data in DPM_SCALAR_UPDATE
 
I have an eulerian multiphase model with 2 phases, and am using a DPM to track particles in the flow. I want to lookup variables about the cell a particle is in, but cannot return any involving the second phase, only the primary. I need both but can't access them and it feel like it should be obvious. I use the following code:

PHP Code:

DEFINE_DPM_SCALAR_UPDATE(activation_potential,cell,thread,initialize,p)
{
    
int n_cphases 2/* Both phases interact with DPM */
    
cphase_state_t= &(p->cphase[0]); /* Gets the cell the particle is in - I thought [0] specified primary phase but not sure */
   
if (initialize)
    {
      
/* this is the initialization call, set:
     * P_USER_REAL(p,0) contains the activation potential, initialize to 0.
     * Variables 1-3 Contain the Viscosity, Strain and Volume fraction of the Primary (Continuous) Phase*/
      
P_USER_REAL(p,0) = 0.;
      
P_USER_REAL(p,1) = c->mu;
      
P_USER_REAL(p,2) = c->strain_rate_mag;
      
P_USER_REAL(p,3) = c->cont_phase_vof;
     }
  else
    {
      
/* Activation potential is: Exposure time * Strain rate * Viscosity * Volume Fraction */
      
P_USER_REAL(p,0) += P_DT(p) * P_USER_REAL(p,1) * P_USER_REAL(p,2) * P_USER_REAL(p,3);
     
/* save current values for start of next step */
      
P_USER_REAL(p,1) = c->mu;
      
P_USER_REAL(p,2) = c->strain_rate_mag;
      
P_USER_REAL(p,3) = c->cont_phase_vof;
     }


Which I then write using DPM_OUTPUT and works fine for giving values of viscoisty,strain etc for the primary phase but nothing I try gives these values for the secondary phase! I've tried:

PHP Code:

cphase_state_t= &(p->cphase[1]); 

And about every other number there and it outputs 0 for everything. I've looked through the "cphase_state_struct" in "dpm_types.h" and can't find anything on how to ask for this for other phases.

Any tips?

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 *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));
    }




All times are GMT -4. The time now is 00:40.