diff --git a/src/Makefile.am b/src/Makefile.am index 3c1e73dbb66fb46a08b3d7315ea4f781ba52515c..62ed550dd2172c4daeb2cd976050a453a36c2a52 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -51,7 +51,8 @@ include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \ mesh_gravity.h cbrt.h exp10.h velociraptor_interface.h swift_velociraptor_part.h outputlist.h \ logger_io.h tracers_io.h tracers.h tracers_struct.h star_formation_io.h \ star_formation_struct.h star_formation.h star_formation_iact.h \ - velociraptor_struct.h velociraptor_io.h random.h memuse.h black_holes.h black_holes_io.h + velociraptor_struct.h velociraptor_io.h random.h memuse.h black_holes.h black_holes_io.h \ + feedback.h feedback_struct.h feedback_properties.h # source files for EAGLE cooling EAGLE_COOLING_SOURCES = @@ -185,6 +186,11 @@ nobase_noinst_HEADERS = align.h approx_math.h atomic.h barrier.h cycle.h error.h tracers/none/tracers_io.h \ tracers/EAGLE/tracers.h tracers/EAGLE/tracers_struct.h \ tracers/EAGLE/tracers_io.h \ + feedback/none/feedback.h feedback/none/feedback_struct.h feedback/none/feedback_iact.h \ + feedback/none/feedback_properties.h \ + feedback/EAGLE/feedback.h feedback/EAGLE/feedback_struct.h feedback/EAGLE/feedback_iact.h \ + feedback/EAGLE/feedback_properties.h feedback/EAGLE/imf.h feedback/EAGLE/interpolate.h \ + feedback/EAGLE/yield_tables.h \ black_holes/Default/black_holes.h black_holes/Default/black_holes_io.h \ black_holes/Default/black_holes_part.h diff --git a/src/feedback.h b/src/feedback.h index d988e0280ee370947277ba909244161757743586..ee2934c76456dd58b6909c63acfaa34104ac0300 100644 --- a/src/feedback.h +++ b/src/feedback.h @@ -24,8 +24,8 @@ /* Select the correct feedback model */ #if defined(FEEDBACK_NONE) -#include "./deedback/Default/feedback_iact.h" -#include "./feedback/Default/feedback.h" +#include "./feedback/none/feedback.h" +#include "./feedback/none/feedback_iact.h" #elif defined(FEEDBACK_EAGLE) #include "./feedback/EAGLE/feedback.h" #include "./feedback/EAGLE/feedback_iact.h" diff --git a/src/feedback/EAGLE/feedback.c b/src/feedback/EAGLE/feedback.c index 206af3dd120faa30775762c8e837a7eeff348d51..46c5fc646cafee88fb6d666db81efe0057d62fff 100644 --- a/src/feedback/EAGLE/feedback.c +++ b/src/feedback/EAGLE/feedback.c @@ -23,6 +23,7 @@ /* Local includes. */ #include "hydro_properties.h" #include "imf.h" +#include "inline.h" #include "interpolate.h" #include "yield_tables.h" @@ -130,7 +131,7 @@ double eagle_feedback_energy_fraction(const struct spart* sp, * @param ngb_gas_mass Total un-weighted mass in the star's kernel. * @param feedback_props The properties of the feedback model. */ -inline static void compute_SNe_feedback( +INLINE static void compute_SNe_feedback( struct spart* sp, const double star_age, const double dt, const float ngb_gas_mass, const struct feedback_props* feedback_props) { @@ -186,7 +187,7 @@ inline static void compute_SNe_feedback( * @param log10_Z log10 of the star metallicity (metal mass fraction). * @param props The properties of the feedback model. */ -inline static void determine_bin_yield_AGB(int* iz_low, int* iz_high, float* dz, +INLINE static void determine_bin_yield_AGB(int* iz_low, int* iz_high, float* dz, const float log10_Z, const struct feedback_props* props) { @@ -237,7 +238,7 @@ inline static void determine_bin_yield_AGB(int* iz_low, int* iz_high, float* dz, * @param log10_Z log10 of the star metallicity (metal mass fraction). * @param props The properties of the feedback model. */ -inline static void determine_bin_yield_SNII( +INLINE static void determine_bin_yield_SNII( int* iz_low, int* iz_high, float* dz, const float log10_Z, const struct feedback_props* props) { @@ -290,7 +291,7 @@ inline static void determine_bin_yield_SNII( * @param star_age_Gyr age of star in Gyr * @param dt_Gyr timestep dt in Gyr */ -inline static void evolve_SNIa(const float log10_min_mass, +INLINE static void evolve_SNIa(const float log10_min_mass, const float log10_max_mass, const struct feedback_props* props, struct spart* sp, float star_age_Gyr, @@ -359,7 +360,7 @@ inline static void evolve_SNIa(const float log10_min_mass, * @param props properties of the feedback model. * @param sp spart we are computing feedback from */ -inline static void evolve_SNII(float log10_min_mass, float log10_max_mass, +INLINE static void evolve_SNII(float log10_min_mass, float log10_max_mass, float* stellar_yields, const struct feedback_props* props, struct spart* sp) { @@ -515,7 +516,7 @@ inline static void evolve_SNII(float log10_min_mass, float log10_max_mass, * @param props Properties of the feedback model. * @param sp spart we are computing feedback for. */ -inline static void evolve_AGB(const float log10_min_mass, float log10_max_mass, +INLINE static void evolve_AGB(const float log10_min_mass, float log10_max_mass, float* stellar_yields, const struct feedback_props* props, struct spart* sp) { @@ -654,7 +655,7 @@ inline static void evolve_AGB(const float log10_min_mass, float log10_max_mass, * @brief Prepares a star's feedback field before computing what * needs to be distributed. */ -inline static void feedback_init_to_distribute(struct spart* sp) { +INLINE static void feedback_init_to_distribute(struct spart* sp) { /* Zero the amount of mass that is distributed */ sp->feedback_data.to_distribute.mass = 0.f; diff --git a/src/feedback/EAGLE/imf.h b/src/feedback/EAGLE/imf.h index 9997990e70ad3db431a225df3c8fb99b7f543ef9..5510c95ca197170c01b24fbe10539d1c7010541f 100644 --- a/src/feedback/EAGLE/imf.h +++ b/src/feedback/EAGLE/imf.h @@ -23,6 +23,7 @@ #include <string.h> /* Local includes. */ +#include "inline.h" #include "interpolate.h" #include "minmax.h" #include "yield_tables.h" @@ -46,7 +47,7 @@ enum eagle_imf_integration_type { * @param i_max (return) Index of IMF mass bin containing log10_max_mass * @param feedback_props the #feedback_props data struct */ -inline static void determine_imf_bins( +INLINE static void determine_imf_bins( double log10_min_mass, double log10_max_mass, int *i_min, int *i_max, const struct feedback_props *feedback_props) { @@ -89,7 +90,7 @@ inline static void determine_imf_bins( * yield-weighted integration. * @param feedback_props the #feedback_props data structure */ -inline static float integrate_imf(const float log10_min_mass, +INLINE static float integrate_imf(const float log10_min_mass, const float log10_max_mass, const enum eagle_imf_integration_type mode, const float *stellar_yields, @@ -194,7 +195,7 @@ inline static float integrate_imf(const float log10_min_mass, * * @param feedback_props #feedback_props data structure */ -inline static void init_imf(struct feedback_props *feedback_props) { +INLINE static void init_imf(struct feedback_props *feedback_props) { /* Compute size of mass bins in log10 space */ const double imf_log10_mass_bin_size = @@ -269,7 +270,7 @@ inline static void init_imf(struct feedback_props *feedback_props) { * @param feedback_props the #feedback_props data structure. * @return Mass of stars died up to that age in solar masses. */ -inline static float dying_mass_msun( +INLINE static float dying_mass_msun( const float age_Gyr, const float Z, const struct feedback_props *feedback_props) { @@ -403,7 +404,7 @@ inline static float dying_mass_msun( * @param feedback_props the #feedback_props data structure. * @return The life time in Giga-years. */ -inline static float lifetime_in_Gyr( +INLINE static float lifetime_in_Gyr( const float mass, const float Z, const struct feedback_props *feedback_props) { diff --git a/src/feedback/EAGLE/interpolate.h b/src/feedback/EAGLE/interpolate.h index 5f07494f433edfe04df9f4fd616051253d28b1cb..2da39c3d200694f9f60fd57904e5254838cb4863 100644 --- a/src/feedback/EAGLE/interpolate.h +++ b/src/feedback/EAGLE/interpolate.h @@ -21,6 +21,7 @@ /* Local includes. */ #include "error.h" +#include "inline.h" /** * @brief Returns the 1d index of element with 2d indices i,j diff --git a/src/feedback/EAGLE/yield_tables.h b/src/feedback/EAGLE/yield_tables.h index 2bdd8e784ab3b1de48e27937dc3a81a2e0b5aefb..435826f7f94559f094e5e27be31a3ef32d064de1 100644 --- a/src/feedback/EAGLE/yield_tables.h +++ b/src/feedback/EAGLE/yield_tables.h @@ -21,6 +21,7 @@ /* Local includes. */ #include "chemistry.h" +#include "inline.h" static const float log10_min_metallicity = -20; @@ -65,7 +66,7 @@ static const float log10_min_metallicity = -20; * @param element_array array of element names * @param n_elements size of element_array */ -inline static int get_element_index(const char *element_name, +INLINE static int get_element_index(const char *element_name, char **element_array, int n_elements) { /* Compare element name we are trying to index to names in element_array */ @@ -83,7 +84,7 @@ inline static int get_element_index(const char *element_name, * * @param feedback_props the #feedback_props data struct to read the table into. */ -inline static void read_yield_tables(struct feedback_props *feedback_props) { +INLINE static void read_yield_tables(struct feedback_props *feedback_props) { #ifdef HAVE_HDF5 @@ -386,7 +387,7 @@ inline static void read_yield_tables(struct feedback_props *feedback_props) { * * @param feedback_props the #feedback_props data struct to store the tables in */ -inline static void allocate_yield_tables( +INLINE static void allocate_yield_tables( struct feedback_props *feedback_props) { /* Allocate array to store SNIa yield tables */ @@ -606,7 +607,7 @@ inline static void allocate_yield_tables( * * @param feedback_props the #feedback_props data struct. */ -inline static void compute_yields(struct feedback_props *feedback_props) { +INLINE static void compute_yields(struct feedback_props *feedback_props) { int flat_index_3d, flat_index_2d; @@ -756,7 +757,7 @@ inline static void compute_yields(struct feedback_props *feedback_props) { * * @param feedback_props the #feedback_props data struct. */ -inline static void compute_ejecta(struct feedback_props *feedback_props) { +INLINE static void compute_ejecta(struct feedback_props *feedback_props) { /* Declare temporary tables to accumulate yields */ double SNII_ejecta[eagle_feedback_SNII_N_masses]; diff --git a/src/feedback/none/feedback.h b/src/feedback/none/feedback.h new file mode 100644 index 0000000000000000000000000000000000000000..e4f74356b89dd30b51eedbf9b2da1799428100df --- /dev/null +++ b/src/feedback/none/feedback.h @@ -0,0 +1,80 @@ +/******************************************************************************* + * 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 <http://www.gnu.org/licenses/>. + * + ******************************************************************************/ +#ifndef SWIFT_FEEDBACK_NONE_H +#define SWIFT_FEEDBACK_NONE_H + +#include "cosmology.h" +#include "error.h" +#include "feedback_properties.h" +#include "hydro_properties.h" +#include "part.h" +#include "units.h" + +/** + * @brief Prepares a s-particle for its feedback interactions + * + * @param sp The particle to act upon + */ +__attribute__((always_inline)) INLINE static void feedback_init_spart( + struct spart* sp) {} + +/** + * @brief Initialises the s-particles feedback props for the first time + * + * This function is called only once just after the ICs have been + * read in to do some conversions. + * + * @param sp The particle to act upon. + * @param feedback_props The properties of the feedback model. + */ +__attribute__((always_inline)) INLINE static void feedback_first_init_spart( + struct spart* sp, const struct feedback_props* feedback_props) {} + +/** + * @brief Initialises the s-particles feedback props for the first time + * + * This function is called only once just after the ICs have been + * read in to do some conversions. + * + * @param sp The particle to act upon. + * @param feedback_props The properties of the feedback model. + */ +__attribute__((always_inline)) INLINE static void feedback_prepare_spart( + struct spart* sp, const struct feedback_props* feedback_props) {} + +/** + * @brief Evolve the stellar properties of a #spart. + * + * This function allows for example to compute the SN rate before sending + * this information to a different MPI rank. + * + * @param sp The particle to act upon + * @param feedback_props The #feedback_props structure. + * @param cosmo The current cosmological model. + * @param us The unit system. + * @param star_age_beg_step The age of the star at the star of the time-step in + * internal units. + * @param dt The time-step size of this star in internal units. + */ +__attribute__((always_inline)) INLINE static void feedback_evolve_spart( + struct spart* restrict sp, const struct feedback_props* feedback_props, + const struct cosmology* cosmo, const struct unit_system* us, + const double star_age_beg_step, const double dt) {} + +#endif /* SWIFT_FEEDBACK_NONE_H */ diff --git a/src/feedback/none/feedback_iact.h b/src/feedback/none/feedback_iact.h new file mode 100644 index 0000000000000000000000000000000000000000..1c2613337a17d55ec1e3c9defd742b1ed0c41fd8 --- /dev/null +++ b/src/feedback/none/feedback_iact.h @@ -0,0 +1,72 @@ +/******************************************************************************* + * This file is part of SWIFT. + * Coypright (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 <http://www.gnu.org/licenses/>. + * + ******************************************************************************/ +#ifndef SWIFT_NONE_FEEDBACK_IACT_H +#define SWIFT_NONE_FEEDBACK_IACT_H + +/** + * @brief Density interaction between two particles (non-symmetric). + * + * Nothing to do here for the no-feedback model. + * + * @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 xp Extra particle data (not updated). + * @param cosmo The cosmological model. + * @param ti_current Current integer time value + */ +__attribute__((always_inline)) INLINE static void +runner_iact_nonsym_feedback_density(const float r2, const float *dx, + const float hi, const float hj, + struct spart *restrict si, + const struct part *restrict pj, + const struct xpart *restrict xp, + const struct cosmology *restrict cosmo, + const integertime_t ti_current) {} + +/** + * @brief Feedback interaction between two particles (non-symmetric). + * Used for updating properties of gas particles neighbouring a star particle + * + * Nothing to do here for the no-feedback model. + * + * @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 xp Extra particle data + * @param cosmo The cosmological model. + * @param ti_current Current integer time used value for seeding random number + * generator + */ +__attribute__((always_inline)) INLINE static void +runner_iact_nonsym_feedback_apply(const float r2, const float *dx, + const float hi, const float hj, + const struct spart *restrict si, + struct part *restrict pj, + struct xpart *restrict xp, + const struct cosmology *restrict cosmo, + const integertime_t ti_current) {} + +#endif /* SWIFT_NONE_FEEDBACK_IACT_H */ diff --git a/src/feedback/none/feedback_properties.h b/src/feedback/none/feedback_properties.h new file mode 100644 index 0000000000000000000000000000000000000000..45b275779780f35547dd158f6a2b44aaeab1dfef --- /dev/null +++ b/src/feedback/none/feedback_properties.h @@ -0,0 +1,50 @@ +/******************************************************************************* + * This file is part of SWIFT. + * Coypright (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 <http://www.gnu.org/licenses/>. + * + ******************************************************************************/ +#ifndef SWIFT_NONE_FEEDBACK_PROPERTIES_H +#define SWIFT_NONE_FEEDBACK_PROPERTIES_H + +#include "chemistry.h" +#include "hydro_properties.h" +#include "inline.h" + +/** + * @brief Properties of the EAGLE feedback model. + */ +struct feedback_props {}; + +/** + * @brief Initialize the global properties of the feedback scheme. + * + * Nothing to do here for the no feedback model. + * + * @param fp The #feedback_props. + * @param phys_const The physical constants in the internal unit system. + * @param us The internal unit system. + * @param params The parsed parameters. + * @param hydro_props The already read-in properties of the hydro scheme. + * @param cosmo The cosmological model. + */ +INLINE static void feedback_props_init(struct feedback_props *fp, + const struct phys_const *phys_const, + const struct unit_system *us, + struct swift_params *params, + const struct hydro_props *hydro_props, + const struct cosmology *cosmo) {} + +#endif /* SWIFT_NONE_FEEDBACK_PROPERTIES_H */ diff --git a/src/feedback/none/feedback_struct.h b/src/feedback/none/feedback_struct.h new file mode 100644 index 0000000000000000000000000000000000000000..0dde77bbd7e58a1768abfd285af2804be7c28865 --- /dev/null +++ b/src/feedback/none/feedback_struct.h @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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 <http://www.gnu.org/licenses/>. + * + ******************************************************************************/ +#ifndef SWIFT_FEEDBACK_STRUCT_NONE_H +#define SWIFT_FEEDBACK_STRUCT_NONE_H + +#include "chemistry_struct.h" + +/** + * @brief Feedback fields carried by each star particles + * + * Nothing here since this is a no-feedback model. + */ +struct feedback_spart_data {}; + +#endif /* SWIFT_FEEDBACK_STRUCT_NONE_H */ diff --git a/src/feedback_properties.h b/src/feedback_properties.h index 70a5feb41bd69339fb10a235bd915d67d8391cf2..83afbb1eeac2aeab080d9c564542b180ea1429af 100644 --- a/src/feedback_properties.h +++ b/src/feedback_properties.h @@ -24,7 +24,7 @@ /* Select the correct feedback model */ #if defined(FEEDBACK_NONE) -#include "./feedback/Default/feedback_properties.h" +#include "./feedback/none/feedback_properties.h" #elif defined(FEEDBACK_EAGLE) #include "./feedback/EAGLE/feedback_properties.h" #else