/******************************************************************************* * 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_DEFAULT_BH_IACT_H #define SWIFT_DEFAULT_BH_IACT_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 bi First particle (black hole). * @param pj Second particle (gas, not updated). * @param xpj The extended data of the second particle (not updated). * @param with_cosmology Are we doing a cosmological run? * @param cosmo The cosmological model. * @param grav_props The properties of the gravity scheme (softening, G, ...). * @param ti_current Current integer time value (for random numbers). * @param time current physical time in the simulation */ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_bh_gas_density( const float r2, const float dx[3], const float hi, const float hj, struct bpart *bi, const struct part *pj, const struct xpart *xpj, const int with_cosmology, const struct cosmology *cosmo, const struct gravity_props *grav_props, const struct black_holes_props *bh_props, const struct entropy_floor_properties *floor_props, const integertime_t ti_current, const double time) { float wi, wi_dx; /* Get r and 1/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 */ bi->density.wcount += wi; bi->density.wcount_dh -= (hydro_dimension * wi + ui * wi_dx); #ifdef DEBUG_INTERACTIONS_BH /* Update ngb counters */ if (si->num_ngb_density < MAX_NUM_OF_NEIGHBOURS_BH) bi->ids_ngbs_density[si->num_ngb_density] = pj->id; /* Update ngb counters */ ++si->num_ngb_density; #endif } /** * @brief Repositioning interaction between two particles (non-symmetric). * * Function used to identify the gas particle that this BH may move towards. * * @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 bi First particle (black hole). * @param pj Second particle (gas) * @param xpj The extended data of the second particle. * @param with_cosmology Are we doing a cosmological run? * @param cosmo The cosmological model. * @param grav_props The properties of the gravity scheme (softening, G, ...). * @param bh_props The properties of the BH scheme * @param ti_current Current integer time value (for random numbers). * @param time Current physical time in the simulation. */ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_bh_gas_repos( const float r2, const float dx[3], const float hi, const float hj, struct bpart *bi, const struct part *pj, const struct xpart *xpj, const int with_cosmology, const struct cosmology *cosmo, const struct gravity_props *grav_props, const struct black_holes_props *bh_props, const struct entropy_floor_properties *floor_props, const integertime_t ti_current, const double time) {} /** * @brief Swallowing interaction between two particles (non-symmetric). * * Function used to flag the gas particles that will be swallowed * by the black hole particle. * * @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 bi First particle (black hole). * @param pj Second particle (gas) * @param xpj The extended data of the second particle. * @param with_cosmology Are we doing a cosmological run? * @param cosmo The cosmological model. * @param grav_props The properties of the gravity scheme (softening, G, ...). * @param ti_current Current integer time value (for random numbers). * @param time current physical time in the simulation */ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_bh_gas_swallow( const float r2, const float dx[3], const float hi, const float hj, const struct bpart *bi, struct part *pj, struct xpart *xpj, const int with_cosmology, const struct cosmology *cosmo, const struct gravity_props *grav_props, const struct black_holes_props *bh_props, const struct entropy_floor_properties *floor_props, const integertime_t ti_current, const double time) {} /** * @brief Swallowing interaction between two BH particles (non-symmetric). * * Function used to identify the BH particle that this BH may move towards. * * @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 bi First particle (black hole). * @param bj Second particle (black hole) * @param cosmo The cosmological model. * @param grav_props The properties of the gravity scheme (softening, G, ...). * @param bh_props The properties of the BH scheme * @param ti_current Current integer time value (for random numbers). */ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_bh_bh_repos(const float r2, const float dx[3], const float hi, const float hj, struct bpart *bi, const struct bpart *bj, const struct cosmology *cosmo, const struct gravity_props *grav_props, const struct black_holes_props *bh_props, const integertime_t ti_current) {} /** * @brief Swallowing interaction between two BH particles (non-symmetric). * * Function used to flag the BH particles that will be swallowed * by the black hole particle. * * @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 bi First particle (black hole). * @param bj Second particle (black hole) * @param cosmo The cosmological model. * @param grav_props The properties of the gravity scheme (softening, G, ...). * @param ti_current Current integer time value (for random numbers). */ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_bh_bh_swallow(const float r2, const float dx[3], const float hi, const float hj, const struct bpart *bi, struct bpart *bj, const struct cosmology *cosmo, const struct gravity_props *grav_props, const struct black_holes_props *bh_props, const integertime_t ti_current) {} /** * @brief Feedback 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 bi First particle (black hole). * @param pj Second particle (gas) * @param xpj The extended data of the second particle. * @param with_cosmology Are we doing a cosmological run? * @param cosmo The cosmological model. * @param grav_props The properties of the gravity scheme (softening, G, ...). * @param ti_current Current integer time value (for random numbers). * @param time current physical time in the simulation */ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_bh_gas_feedback( const float r2, const float dx[3], const float hi, const float hj, const struct bpart *bi, struct part *pj, struct xpart *xpj, const int with_cosmology, const struct cosmology *cosmo, const struct gravity_props *grav_props, const struct black_holes_props *bh_props, const struct entropy_floor_properties *floor_props, const integertime_t ti_current, const double time) { #ifdef DEBUG_INTERACTIONS_BH /* Update ngb counters */ if (si->num_ngb_force < MAX_NUM_OF_NEIGHBOURS_BH) bi->ids_ngbs_force[si->num_ngb_force] = pj->id; /* Update ngb counters */ ++si->num_ngb_force; #endif } #endif