Functions

particles/utils_particle.c File Reference

Contains most of the utilities for the particle code. More...

Go to the source code of this file.

Functions

int compare_gr (Grid *pG, Vector cell1, Grain gr1, Grain gr2)
 Compare the order of two particles according to their positions in the grid.
void quicksort_particle (Grid *pG, Vector cell1, long start, long end)
 Quick sort algorithm to shuffle the particles.
void getwei_linear (Grid *pG, Real x1, Real x2, Real x3, Vector cell1, Real weight[3][3][3], int *is, int *js, int *ks)
 Get weight using linear interpolation.
void getwei_TSC (Grid *pG, Real x1, Real x2, Real x3, Vector cell1, Real weight[3][3][3], int *is, int *js, int *ks)
 Get weight using Triangular Shaped Cloud (TSC) interpolation Input: pG: grid; x1,x2,x3: global coordinate; cell1: 1 over dx1,dx2,dx3 Output: weight: weight function; is,js,ks: starting cell indices in the grid.
void getwei_QP (Grid *pG, Real x1, Real x2, Real x3, Vector cell1, Real weight[3][3][3], int *is, int *js, int *ks)
 Get weight using quadratic polynomial interpolation.
int getvalues (Grid *pG, Real weight[3][3][3], int is, int js, int ks,#ifndef FEEDBACK Real *rho, Real *u1, Real *u2, Real *u3, Real *cs#else Real *rho, Real *u1, Real *u2, Real *u3, Real *cs, Real *stiff#endif)
Real get_ts_general (Grid *pG, int type, Real rho, Real cs, Real vd)
 Calculate the stopping time for the most general case.
Real get_ts_epstein (Grid *pG, int type, Real rho, Real cs, Real vd)
 Calculate the stopping time in the Epstein regime.
Real get_ts_fixed (Grid *pG, int type, Real rho, Real cs, Real vd)
 Return the fixed stopping time.
void get_gasinfo (Grid *pG)
 Calculate the gas information from conserved variables for feedback_predictor.
void feedback_clear (Grid *pG)
 clean the feedback array
void distrFB_pred (Grid *pG, Real weight[3][3][3], int is, int js, int ks,#ifndef BAROTROPIC Vector fb, Real stiffness, Real Elosspar#else Vector fb, Real stiffness#endif)
void distrFB_corr (Grid *pG, Real weight[3][3][3], int is, int js, int ks, Vector fb, Real Elosspar)
 Distribute the feedback force to grid cells for the correct step.
void shuffle (Grid *pG)
 Shuffle the particles.

Detailed Description

Contains most of the utilities for the particle code.

PURPOSE: Contains most of the utilities for the particle code: all the interpolation functions, stopping time calculation functions, shuffle algorithms. Also contained are the default (and trivial) gas velocity shift function. The get_gasinfo(Grid *pG) routine is used for test purposes only.

CONTAINS PUBLIC FUNCTIONS:

PRIVATE FUNCTION PROTOTYPES:

History:

Definition in file utils_particle.c.


Function Documentation

int compare_gr ( Grid *  pG,
Vector  cell1,
Grain  gr1,
Grain  gr2 
)

Compare the order of two particles according to their positions in the grid.

Input: pG: grid;

  • cell1: 1/dx1,1/dx2,1/dx3, or 0 if that dimension collapses.
  • gr1,gr2: pointers of the two particles to be compared. Output: pointer of the particle that should be put in front of the other.

Definition at line 673 of file utils_particle.c.

Referenced by quicksort_particle().

Here is the caller graph for this function:

void distrFB_corr ( Grid *  pG,
Real  weight[3][3][3],
int  is,
int  js,
int  ks,
Vector  fb,
Real  Elosspar 
)

Distribute the feedback force to grid cells for the correct step.

Input:

  • pG: grid; weight: weight function;
  • is,js,ks: starting cell indices in the grid.
  • f1, f2, f3: feedback force from one particle. Output:
  • pG: feedback array is updated.

Definition at line 595 of file utils_particle.c.

References GPCouple::Eloss, GPCouple::fb1, GPCouple::fb2, GPCouple::fb3, ilp, iup, jlp, jup, klp, kup, and ncell.

Referenced by feedback_corrector().

Here is the caller graph for this function:

void distrFB_pred ( Grid *  pG,
Real  weight[3][3][3],
int  is,
int  js,
int  ks,
#ifndef BAROTROPIC Vector  fb,
Real  stiffness,
Real Elosspar#else Vector  fb,
Real stiffness#  endif 
)

Definition at line 546 of file utils_particle.c.

References GPCouple::Eloss, GPCouple::fb1, GPCouple::fb2, GPCouple::fb3, GPCouple::FBstiff, ilp, iup, jlp, jup, klp, kup, and ncell.

Referenced by feedback_predictor().

Here is the caller graph for this function:

void feedback_clear ( Grid *  pG  ) 

clean the feedback array

Definition at line 515 of file utils_particle.c.

References GPCouple::Eloss, GPCouple::fb1, GPCouple::fb2, GPCouple::fb3, ilp, iup, jlp, jup, klp, and kup.

Referenced by Integrate_Particles().

Here is the caller graph for this function:

void get_gasinfo ( Grid *  pG  ) 

Calculate the gas information from conserved variables for feedback_predictor.

Input: pG: grid (not evolved yet). Output: calculate 3D array grid_v/grid_cs in the grid structure. Calculated are gas velocity and sound speed.

Definition at line 469 of file utils_particle.c.

References ath_error(), Gamma, Gamma_1, GPCouple::grid_cs, GPCouple::grid_d, GPCouple::grid_v1, GPCouple::grid_v2, GPCouple::grid_v3, ilp, iup, jlp, jup, klp, and kup.

Referenced by feedback_predictor().

Here is the call graph for this function:

Here is the caller graph for this function:

Real get_ts_epstein ( Grid *  pG,
int  type,
Real  rho,
Real  cs,
Real  vd 
)

Calculate the stopping time in the Epstein regime.

Note grrhoa == rho_s*a in normalized unit

Definition at line 426 of file utils_particle.c.

References grrhoa.

Real get_ts_fixed ( Grid *  pG,
int  type,
Real  rho,
Real  cs,
Real  vd 
)

Return the fixed stopping time.

Definition at line 439 of file utils_particle.c.

References tstop0.

Real get_ts_general ( Grid *  pG,
int  type,
Real  rho,
Real  cs,
Real  vd 
)

Calculate the stopping time for the most general case.

The relavent scale to calculate is:

  • 1. a/lambda_m == alam
  • 2. rho_s*a in normalized unit == rhoa

Definition at line 383 of file utils_particle.c.

References a, alamcoeff, and grrhoa.

int getvalues ( Grid *  pG,
Real  weight[3][3][3],
int  is,
int  js,
int  ks,
#ifndef FEEDBACK Real rho,
Real u1,
Real u2,
Real u3,
Real *cs#else Real rho,
Real u1,
Real u2,
Real u3,
Real cs,
Real *stiff#  endif 
)

Definition at line 296 of file utils_particle.c.

References C, GPCouple::FBstiff, GPCouple::grid_cs, GPCouple::grid_d, GPCouple::grid_v1, GPCouple::grid_v2, GPCouple::grid_v3, ilp, Iso_csound, iup, jlp, jup, klp, kup, and ncell.

Referenced by dump_particle_binary(), feedback_predictor(), Get_Drag(), and Get_Term().

Here is the caller graph for this function:

void getwei_linear ( Grid *  pG,
Real  x1,
Real  x2,
Real  x3,
Vector  cell1,
Real  weight[3][3][3],
int *  is,
int *  js,
int *  ks 
)

Get weight using linear interpolation.

Input: pG: grid; x1,x2,x3: global coordinate; cell1: 1 over dx1,dx2,dx3 Output: weight: weight function; is,js,ks: starting cell indices in the grid. Note: this interpolation works in any 1-3 dimensions.

Definition at line 84 of file utils_particle.c.

References a, celli(), cellj(), and cellk().

Here is the call graph for this function:

void getwei_QP ( Grid *  pG,
Real  x1,
Real  x2,
Real  x3,
Vector  cell1,
Real  weight[3][3][3],
int *  is,
int *  js,
int *  ks 
)

Get weight using quadratic polynomial interpolation.

Input: pG: grid; x1,x2,x3: global coordinate; cell1: 1 over dx1,dx2,dx3 Output: weight: weight function; is,js,ks: starting cell indices in the grid. Note: this interpolation works in any 1-3 dimensions.

Definition at line 221 of file utils_particle.c.

References a, celli(), cellj(), and cellk().

Here is the call graph for this function:

void getwei_TSC ( Grid *  pG,
Real  x1,
Real  x2,
Real  x3,
Vector  cell1,
Real  weight[3][3][3],
int *  is,
int *  js,
int *  ks 
)

Get weight using Triangular Shaped Cloud (TSC) interpolation Input: pG: grid; x1,x2,x3: global coordinate; cell1: 1 over dx1,dx2,dx3 Output: weight: weight function; is,js,ks: starting cell indices in the grid.

Note: this interpolation works in any 1-3 dimensions.

Definition at line 149 of file utils_particle.c.

References a, celli(), cellj(), and cellk().

Here is the call graph for this function:

void quicksort_particle ( Grid *  pG,
Vector  cell1,
long  start,
long  end 
)

Quick sort algorithm to shuffle the particles.

Input: pG, cell1: for compare_gr subroutine only. See above. head, rear: head and rear of the linked list. They do not contain data, or equal the pivot in the recursion. length: length of the linked list (does not contain head or rear). Output: *head: linked list with shuffling finished.

Definition at line 706 of file utils_particle.c.

References compare_gr().

Referenced by shuffle().

Here is the call graph for this function:

Here is the caller graph for this function:

void shuffle ( Grid *  pG  ) 

Shuffle the particles.

Input: pG: grid with particles; Output: pG: particles in the linked list are rearranged by the order of their locations that are consistent with grid cell storage.

Definition at line 645 of file utils_particle.c.

References ath_pout(), and quicksort_particle().

Referenced by set_bvals_particle().

Here is the call graph for this function:

Here is the caller graph for this function: