stars_iact.h 1.26 KB
Newer Older
Loic Hausammann's avatar
Loic Hausammann committed
1
2
3
4
5
6
7
8
9
10
11
12
/**
 * @brief Density interaction between two particles (non-symmetric).
 *
 * @param r2 Comoving square distance between the two particles.
 * @param dx Comoving vector separating both particles (pi - pj).
 * @param hi Comoving smoothing-length of particle i.
 * @param hj Comoving smoothing-length of particle j.
 * @param si First sparticle.
 * @param pj Second particle (not updated).
 * @param a Current scale factor.
 * @param H Current Hubble parameter.
 */
Loic Hausammann's avatar
Loic Hausammann committed
13
__attribute__((always_inline)) INLINE static void runner_iact_nonsym_stars_density(
Loic Hausammann's avatar
Loic Hausammann committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
    float r2, const float *dx, float hi, float hj, struct spart *restrict si,
    const struct part *restrict pj, float a, float H) {

  float wi, wi_dx;

  /* Get r and 1/r. */
  const float r_inv = 1.0f / sqrtf(r2);
  const float r = r2 * r_inv;

  /* Compute the kernel function */
  const float hi_inv = 1.0f / hi;
  const float ui = r * hi_inv;
  kernel_deval(ui, &wi, &wi_dx);

  /* Compute contribution to the number of neighbours */
29
30
  si->density.wcount += wi;
  si->density.wcount_dh -= (hydro_dimension * wi + ui * wi_dx);    
Loic Hausammann's avatar
Loic Hausammann committed
31
32
33

#ifdef DEBUG_INTERACTIONS_STARS
  /* Update ngb counters */
34
  if (si->num_ngb_density < MAX_NUM_OF_NEIGHBOURS_STARS)
Loic Hausammann's avatar
Loic Hausammann committed
35
36
37
38
    si->ids_ngbs_density[si->num_ngb_density] = pj->id;
  ++si->num_ngb_density;
#endif
}