/******************************************************************************* * This file is part of SWIFT. * Copyright (c) 2018 Matthieu Schaller (schaller@strw.leidenuniv.nl) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * ******************************************************************************/ #ifndef SWIFT_EAGLE_STARS_IACT_H #define SWIFT_EAGLE_STARS_IACT_H #include "random.h" /** * @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. */ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_stars_density(const float r2, const float dx[3], const float hi, const float hj, struct spart *si, const struct part *pj, const float a, const float H) { float wi, wi_dx; /* Get r. */ const float r = sqrtf(r2); /* 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 */ si->density.wcount += wi; si->density.wcount_dh -= (hydro_dimension * wi + ui * wi_dx); #ifdef SWIFT_STARS_DENSITY_CHECKS si->rho += pj->mass * wi; si->n += wi; si->N_density++; #endif #ifdef DEBUG_INTERACTIONS_STARS /* Update ngb counters */ if (si->num_ngb_density < MAX_NUM_OF_NEIGHBOURS_STARS) si->ids_ngbs_density[si->num_ngb_density] = pj->id; ++si->num_ngb_density; #endif } __attribute__((always_inline)) INLINE static void runner_iact_nonsym_stars_prep1(const float r2, const float dx[3], const float hi, const float hj, struct spart *si, const struct part *pj, const float a, const float H) {} __attribute__((always_inline)) INLINE static void runner_iact_nonsym_stars_prep2(const float r2, const float dx[3], const float hi, const float hj, struct spart *si, const struct part *pj, const float a, const float H) {} /** * @brief Feedback interaction between two particles (non-symmetric). * Used for updating properties of gas particles neighbouring a star particle * * @param r2 Comoving square distance between the two particles. * @param dx Comoving vector separating both particles (si - pj). * @param hi Comoving smoothing-length of particle i. * @param hj Comoving smoothing-length of particle j. * @param si First (star) particle (not updated). * @param pj Second (gas) particle. * @param a Current scale factor. * @param H Current Hubble parameter. */ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_stars_feedback(const float r2, const float dx[3], const float hi, const float hj, const struct spart *si, struct part *pj, const float a, const float H) { #ifdef DEBUG_INTERACTIONS_STARS /* Update ngb counters */ if (si->num_ngb_feedback < MAX_NUM_OF_NEIGHBOURS_STARS) si->ids_ngbs_feedback[si->num_ngb_feedback] = pj->id; ++si->num_ngb_feedback; #endif } #endif /* SWIFT_EAGLE_STARS_IACT_H */