diff --git a/src/Makefile.am b/src/Makefile.am index 3d748b135c93cf409464a199232b243c699fabe1..4710f3c99371f3bd585c328db51426363651e04e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,8 +50,9 @@ include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \ chemistry.h chemistry_io.h chemistry_struct.h cosmology.h restart.h space_getsid.h utilities.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 fof.h fof_struct.h fof_io.h \ - star_formation_struct.h star_formation.h star_formation_iact.h \ + star_formation_struct.h star_formation.h \ star_formation_logger.h star_formation_logger_struct.h \ + pressure_floor.h pressure_floor_struct.h pressure_floor_iact.h \ velociraptor_struct.h velociraptor_io.h random.h memuse.h black_holes.h black_holes_io.h \ black_holes_properties.h black_holes_struct.h feedback.h feedback_struct.h feedback_properties.h @@ -172,11 +173,11 @@ nobase_noinst_HEADERS = align.h approx_math.h atomic.h barrier.h cycle.h error.h potential/isothermal/potential.h potential/disc_patch/potential.h \ potential/sine_wave/potential.h \ star_formation/none/star_formation.h star_formation/none/star_formation_struct.h \ - star_formation/none/star_formation_io.h star_formation/none/star_formation_iact.h \ + star_formation/none/star_formation_io.h \ star_formation/EAGLE/star_formation.h star_formation/EAGLE/star_formation_struct.h \ - star_formation/EAGLE/star_formation_io.h star_formation/EAGLE/star_formation_iact.h \ + star_formation/EAGLE/star_formation_io.h \ star_formation/GEAR/star_formation.h star_formation/GEAR/star_formation_struct.h \ - star_formation/GEAR/star_formation_io.h star_formation/GEAR/star_formation_iact.h \ + star_formation/GEAR/star_formation_io.h \ star_formation/EAGLE/star_formation_logger.h star_formation/EAGLE/star_formation_logger_struct.h \ star_formation/GEAR/star_formation_logger.h star_formation/GEAR/star_formation_logger_struct.h \ star_formation/none/star_formation_logger.h star_formation/none/star_formation_logger_struct.h \ @@ -223,8 +224,9 @@ nobase_noinst_HEADERS = align.h approx_math.h atomic.h barrier.h cycle.h error.h black_holes/EAGLE/black_holes_part.h black_holes/EAGLE/black_holes_iact.h \ black_holes/EAGLE/black_holes_properties.h \ black_holes/EAGLE/black_holes_struct.h \ - pressure_floor.h \ - pressure_floor/GEAR/pressure_floor.h pressure_floor/none/pressure_floor.h + pressure_floor/GEAR/pressure_floor.h pressure_floor/none/pressure_floor.h \ + pressure_floor/GEAR/pressure_floor_iact.h pressure_floor/none/pressure_floor_iact.h \ + pressure_floor/GEAR/pressure_floor_struct.h pressure_floor/none/pressure_floor_struct.h # Sources and flags for regular library diff --git a/src/cell.c b/src/cell.c index 0649d31b38279f3a75ec2b439f71de105425ae27..4e05c645e5292f52261c35124ecb5c42b51b1b17 100644 --- a/src/cell.c +++ b/src/cell.c @@ -4413,7 +4413,7 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) { if (part_is_active(p, e)) { hydro_init_part(p, &e->s->hs); chemistry_init_part(p, e->chemistry); - star_formation_init_part(p, xp, e->star_formation); + pressure_floor_init_part(p, xp); tracers_after_init(p, xp, e->internal_units, e->physical_constants, with_cosmology, e->cosmology, e->hydro_properties, e->cooling_func, e->time); diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h index 93c0e58068341ab29a7ed0fb6b0d21f76980d952..518437241e85cb56f681dbd4725ab1e32b330f39 100644 --- a/src/hydro/Gadget2/hydro.h +++ b/src/hydro/Gadget2/hydro.h @@ -466,7 +466,7 @@ __attribute__((always_inline)) INLINE static void hydro_timestep_extra( * @brief Prepares a particle for the density calculation. * * Zeroes all the relevant arrays in preparation for the sums taking place in - * the variaous density tasks + * the various density tasks * * @param p The particle to act upon * @param hs #hydro_space containing hydro specific space information. diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h index 853d2adf17bc069434562fa96ddb881f760f6830..5f4cca366b101c2341863f47d7a9adce51b860a2 100644 --- a/src/hydro/Gadget2/hydro_part.h +++ b/src/hydro/Gadget2/hydro_part.h @@ -35,6 +35,7 @@ #include "chemistry_struct.h" #include "cooling_struct.h" #include "logger.h" +#include "pressure_floor_struct.h" #include "star_formation_struct.h" #include "tracers_struct.h" @@ -155,8 +156,8 @@ struct part { /*! Black holes information (e.g. swallowing ID) */ struct black_holes_part_data black_holes_data; - /* Additional data used by the star formation */ - struct star_formation_part_data sf_data; + /* Additional data used by the pressure floor */ + struct pressure_floor_part_data pressure_floor_data; /* Time-step length */ timebin_t time_bin; diff --git a/src/pressure_floor/GEAR/pressure_floor.h b/src/pressure_floor/GEAR/pressure_floor.h index dd715c155a095f9ad5f97b1d14cabfc94d9b11b0..a547b91d2e6e15df3c9a8fa0e1c7cc46cd3a970f 100644 --- a/src/pressure_floor/GEAR/pressure_floor.h +++ b/src/pressure_floor/GEAR/pressure_floor.h @@ -1,6 +1,6 @@ /******************************************************************************* * This file is part of SWIFT. - * Copyright (c) 2019 Matthieu Schaller (schaller@strw.leidenuniv.nl) + * Copyright (c) 2019 Loic Hausammann (loic.hausammann@epfl.ch) * * 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 @@ -19,9 +19,15 @@ #ifndef SWIFT_PRESSURE_FLOOR_GEAR_H #define SWIFT_PRESSURE_FLOOR_GEAR_H +/* Forward declaration */ +__attribute__((always_inline)) static INLINE float pressure_floor_get_pressure( + const struct part *p, const float rho, const float pressure); + #include "adiabatic_index.h" #include "cosmology.h" +#include "dimension.h" #include "equation_of_state.h" +#include "hydro.h" #include "hydro_properties.h" #include "parser.h" #include "part.h" @@ -58,9 +64,8 @@ struct pressure_floor_properties { * * @return The physical or comoving pressure with the floor. */ -static INLINE float pressure_floor_get_pressure(const struct part *p, - const float rho, - const float pressure) { +__attribute__((always_inline)) static INLINE float pressure_floor_get_pressure( + const struct part *p, const float rho, const float pressure) { /* Compute pressure floor */ float floor = p->h * p->h * rho * pressure_floor_props.constants; @@ -83,11 +88,12 @@ static INLINE float pressure_floor_get_pressure(const struct part *p, * @param hydro_props The propoerties of the hydro scheme. * @param props The pressure floor properties to fill. */ -static INLINE void pressure_floor_init(struct pressure_floor_properties *props, - const struct phys_const *phys_const, - const struct unit_system *us, - const struct hydro_props *hydro_props, - struct swift_params *params) { +__attribute__((always_inline)) static INLINE void pressure_floor_init( + struct pressure_floor_properties *props, + const struct phys_const *phys_const, + const struct unit_system *us, + const struct hydro_props *hydro_props, + struct swift_params *params) { /* Read the Jeans factor */ props->n_jeans = @@ -103,7 +109,7 @@ static INLINE void pressure_floor_init(struct pressure_floor_properties *props, * * @param props The pressure floor properties. */ -static INLINE void pressure_floor_print( +__attribute__((always_inline)) static INLINE void pressure_floor_print( const struct pressure_floor_properties *props) { message("Pressure floor is 'GEAR' with:"); @@ -116,9 +122,77 @@ static INLINE void pressure_floor_print( * @brief Writes the current model of pressure floor to the file * @param h_grp The HDF5 group in which to write */ -INLINE static void pressure_floor_print_snapshot(hid_t h_grp) { +__attribute__((always_inline)) INLINE static void pressure_floor_print_snapshot(hid_t h_grp) { io_write_attribute_s(h_grp, "Pressure floor", "GEAR"); } + +/** + * @brief Finishes the density calculation. + * + * @param p The particle to act upon + * @param cosmo The current cosmological model. + */ +__attribute__((always_inline)) INLINE static void pressure_floor_end_density( + struct part* restrict p, + const struct cosmology* cosmo) { + + /* To finish the turbulence estimation we devide by the density */ + p->pressure_floor_data.sigma2 /= + pow_dimension(p->h) * hydro_get_physical_density(p, cosmo); + + /* Add the cosmological factor */ + p->pressure_floor_data.sigma2 *= cosmo->a * cosmo->a; +} + +/** + * @brief Sets all particle fields to sensible values when the #part has 0 ngbs. + * + * @param p The particle to act upon + * @param xp The extended particle data to act upon + * @param cosmo The current cosmological model. + */ +__attribute__((always_inline)) INLINE static void +pressure_floor_part_has_no_neighbours(struct part* restrict p, + struct xpart* restrict xp, + const struct cosmology* cosmo) { + + /* If part has 0 neighbours, the estimation of turbulence is 0 */ + p->pressure_floor_data.sigma2 = 0.f; +} + +/** + * @brief Sets the pressure_floor properties of the (x-)particles to a valid + * start state. + * + * @param p Pointer to the particle data. + * @param xp Pointer to the extended particle data. + */ +__attribute__((always_inline)) INLINE static void pressure_floor_init_part( + struct part* restrict p, struct xpart* restrict xp) { + p->pressure_floor_data.sigma2 = 0.f; +} + + +/** + * @brief Sets the pressure_floor properties of the (x-)particles to a valid + * start state. + * + * @param phys_const The physical constant in internal units. + * @param us The unit system. + * @param cosmo The current cosmological model. + * @param p Pointer to the particle data. + * @param xp Pointer to the extended particle data. + */ +__attribute__((always_inline)) INLINE static void pressure_floor_first_init_part( + const struct phys_const* restrict phys_const, + const struct unit_system* restrict us, + const struct cosmology* restrict cosmo, + struct part* restrict p, + struct xpart* restrict xp) { + + pressure_floor_init_part(p, xp); +} + #endif #endif /* SWIFT_PRESSURE_FLOOR_GEAR_H */ diff --git a/src/star_formation/GEAR/star_formation_iact.h b/src/pressure_floor/GEAR/pressure_floor_iact.h similarity index 83% rename from src/star_formation/GEAR/star_formation_iact.h rename to src/pressure_floor/GEAR/pressure_floor_iact.h index 7325b92af2840b317cf1a924a1e509b34bdffba3..7469f237ca09d95879759e4fdd65ce6830d33b2f 100644 --- a/src/star_formation/GEAR/star_formation_iact.h +++ b/src/pressure_floor/GEAR/pressure_floor_iact.h @@ -17,16 +17,16 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ -#ifndef SWIFT_GEAR_STAR_FORMATION_IACT_H -#define SWIFT_GEAR_STAR_FORMATION_IACT_H +#ifndef SWIFT_GEAR_PRESSURE_FLOOR_IACT_H +#define SWIFT_GEAR_PRESSURE_FLOOR_IACT_H /** - * @file GEAR/star_formation_iact.h + * @file GEAR/pressure_floor_iact.h * @brief Density computation */ /** - * @brief do star_formation computation after the runner_iact_density (symmetric + * @brief do pressure_floor computation after the runner_iact_density (symmetric * version) * * Compute the velocity dispersion follow eq. 2 in Revaz & Jablonka 2018. @@ -40,7 +40,7 @@ * @param a Current scale factor. * @param H Current Hubble parameter. */ -__attribute__((always_inline)) INLINE static void runner_iact_star_formation( +__attribute__((always_inline)) INLINE static void runner_iact_pressure_floor( float r2, const float *dx, float hi, float hj, struct part *restrict pi, struct part *restrict pj, float a, float H) { @@ -61,12 +61,12 @@ __attribute__((always_inline)) INLINE static void runner_iact_star_formation( const float sigma2 = norm_v2 + H * norm_x2; /* Compute the velocity dispersion */ - pi->sf_data.sigma2 += sigma2 * wi * hydro_get_mass(pj); - pj->sf_data.sigma2 += sigma2 * wj * hydro_get_mass(pi); + pi->pressure_floor_data.sigma2 += sigma2 * wi * hydro_get_mass(pj); + pj->pressure_floor_data.sigma2 += sigma2 * wj * hydro_get_mass(pi); } /** - * @brief do star_formation computation after the runner_iact_density (non + * @brief do pressure_floor computation after the runner_iact_density (non * symmetric version) * * @param r2 Comoving square distance between the two particles. @@ -79,7 +79,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_star_formation( * @param H Current Hubble parameter. */ __attribute__((always_inline)) INLINE static void -runner_iact_nonsym_star_formation(float r2, const float *dx, float hi, float hj, +runner_iact_nonsym_pressure_floor(float r2, const float *dx, float hi, float hj, struct part *restrict pi, const struct part *restrict pj, float a, float H) { @@ -98,7 +98,7 @@ runner_iact_nonsym_star_formation(float r2, const float *dx, float hi, float hj, const float sigma2 = norm_v2 + H * norm_x2; /* Compute the velocity dispersion */ - pi->sf_data.sigma2 += sigma2 * wi * hydro_get_mass(pj); + pi->pressure_floor_data.sigma2 += sigma2 * wi * hydro_get_mass(pj); } -#endif /* SWIFT_GEAR_STAR_FORMATION_IACT_H */ +#endif /* SWIFT_GEAR_PRESSURE_FLOOR_IACT_H */ diff --git a/src/pressure_floor/GEAR/pressure_floor_struct.h b/src/pressure_floor/GEAR/pressure_floor_struct.h new file mode 100644 index 0000000000000000000000000000000000000000..ba04be080c8365251f41c31d67f69f3074a287c4 --- /dev/null +++ b/src/pressure_floor/GEAR/pressure_floor_struct.h @@ -0,0 +1,32 @@ +/******************************************************************************* + * This file is part of SWIFT. + * Copyright (c) 2019 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_PRESSURE_FLOOR_PART_GEAR_H +#define SWIFT_PRESSURE_FLOOR_PART_GEAR_H + +/** + * Structure containing the required variables for the pressure + * floor in the density loop. + */ +struct pressure_floor_part_data { + /*! Estimation of local turbulence (squared) */ + float sigma2; +}; + + +#endif // SWIFT_PRESSURE_FLOOR_PART_GEAR_H diff --git a/src/star_formation/none/star_formation_iact.h b/src/pressure_floor/none/pressure_floor_iact.h similarity index 75% rename from src/star_formation/none/star_formation_iact.h rename to src/pressure_floor/none/pressure_floor_iact.h index dd74115bec699029748806b512c9d6bd7fb829fe..fedacfe06be1a6de2a87f14ce2b5a6306f29ac09 100644 --- a/src/star_formation/none/star_formation_iact.h +++ b/src/pressure_floor/none/pressure_floor_iact.h @@ -1,4 +1,7 @@ /******************************************************************************* + * This file is part of SWIFT. + * Coypright (c) 2019 Loic Hausammann (loic.hausammann@epfl.ch) + * 2019 Fabien Jeanquartier (fabien.jeanquartier@epfl.ch) * * 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 @@ -14,18 +17,20 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ -#ifndef SWIFT_NONE_STAR_FORMATION_IACT_H -#define SWIFT_NONE_STAR_FORMATION_IACT_H +#ifndef SWIFT_NONE_PRESSURE_FLOOR_IACT_H +#define SWIFT_NONE_PRESSURE_FLOOR_IACT_H /** - * @file none/star_formation_iact.h + * @file NONE/pressure_floor_iact.h * @brief Density computation */ /** - * @brief do star_formation computation after the runner_iact_density (symmetric + * @brief do pressure_floor computation after the runner_iact_density (symmetric * version) * + * Compute the velocity dispersion follow eq. 2 in Revaz & Jablonka 2018. + * * @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. @@ -35,12 +40,12 @@ * @param a Current scale factor. * @param H Current Hubble parameter. */ -__attribute__((always_inline)) INLINE static void runner_iact_star_formation( +__attribute__((always_inline)) INLINE static void runner_iact_pressure_floor( float r2, const float *dx, float hi, float hj, struct part *restrict pi, struct part *restrict pj, float a, float H) {} /** - * @brief do star_formation computation after the runner_iact_density (non + * @brief do pressure_floor computation after the runner_iact_density (non * symmetric version) * * @param r2 Comoving square distance between the two particles. @@ -53,9 +58,9 @@ __attribute__((always_inline)) INLINE static void runner_iact_star_formation( * @param H Current Hubble parameter. */ __attribute__((always_inline)) INLINE static void -runner_iact_nonsym_star_formation(float r2, const float *dx, float hi, float hj, +runner_iact_nonsym_pressure_floor(float r2, const float *dx, float hi, float hj, struct part *restrict pi, const struct part *restrict pj, float a, float H) {} -#endif /* SWIFT_NONE_STAR_FORMATION_IACT_H */ +#endif /* SWIFT_NONE_PRESSURE_FLOOR_IACT_H */ diff --git a/src/pressure_floor/none/pressure_floor_struct.h b/src/pressure_floor/none/pressure_floor_struct.h new file mode 100644 index 0000000000000000000000000000000000000000..cad9f22093e03450455eb34613d3c9b62f167e47 --- /dev/null +++ b/src/pressure_floor/none/pressure_floor_struct.h @@ -0,0 +1,29 @@ +/******************************************************************************* + * This file is part of SWIFT. + * Copyright (c) 2019 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_PRESSURE_FLOOR_PART_NONE_H +#define SWIFT_PRESSURE_FLOOR_PART_NONE_H + +/** + * Structure containing the required variables for the pressure + * floor in the density loop. + */ +struct pressure_floor_part_data {}; + + +#endif // SWIFT_PRESSURE_FLOOR_PART_NONE_H diff --git a/src/star_formation_iact.h b/src/pressure_floor_iact.h similarity index 69% rename from src/star_formation_iact.h rename to src/pressure_floor_iact.h index ef457214a23102bc33385705db41c89dc29d8b8f..351a90f57c4063675a164751e0f5b26bb85bfb32 100644 --- a/src/star_formation_iact.h +++ b/src/pressure_floor_iact.h @@ -1,6 +1,6 @@ /******************************************************************************* * This file is part of SWIFT. - * Copyright (c) 2018 Folkert Nobels (nobels@strw.leidenuniv.nl) + * Copyright (c) 2019 Loic Hausammann (loic.hausammann@epfl.ch) * * 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 @@ -16,11 +16,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ -#ifndef SWIFT_STAR_FORMATION_IACT_H -#define SWIFT_STAR_FORMATION_IACT_H +#ifndef SWIFT_PRESSURE_FLOOR_IACT_H +#define SWIFT_PRESSURE_FLOOR_IACT_H /** - * @file src/star_formation_iact.h + * @file src/pressure_floor_iact.h * @brief Branches between the different star formation iact. */ @@ -28,14 +28,12 @@ #include "../config.h" /* Import the right star formation law definition */ -#if defined(STAR_FORMATION_NONE) -#include "./star_formation/none/star_formation_iact.h" -#elif defined(STAR_FORMATION_EAGLE) -#include "./star_formation/EAGLE/star_formation_iact.h" -#elif defined(STAR_FORMATION_GEAR) -#include "./star_formation/GEAR/star_formation_iact.h" +#if defined(PRESSURE_FLOOR_NONE) +#include "./pressure_floor/none/pressure_floor_iact.h" +#elif defined(PRESSURE_FLOOR_GEAR) +#include "./pressure_floor/GEAR/pressure_floor_iact.h" #else #error "Invalid choice of star formation law" #endif -#endif /* SWIFT_STAR_FORMATION_IACT_H */ +#endif /* SWIFT_PRESSURE_FLOOR_IACT_H */ diff --git a/src/pressure_floor_struct.h b/src/pressure_floor_struct.h new file mode 100644 index 0000000000000000000000000000000000000000..7a029578cc1834c43976daf7e27c5fbdd508d871 --- /dev/null +++ b/src/pressure_floor_struct.h @@ -0,0 +1,39 @@ +/******************************************************************************* + * This file is part of SWIFT. + * Copyright (c) 2019 Loic Hausammann (loic.hausammann@epfl.ch) + * + * 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_PRESSURE_FLOOR_STRUCT_H +#define SWIFT_PRESSURE_FLOOR_STRUCT_H + +/** + * @file src/pressure_floor_struct.h + * @brief Branches between the different particle data SF tracers + */ + +/* Config parameters. */ +#include "../config.h" + +/* Import the right cooling definition */ +#if defined(PRESSURE_FLOOR_NONE) +#include "./pressure_floor/none/pressure_floor_struct.h" +#elif defined(PRESSURE_FLOOR_GEAR) +#include "./pressure_floor/GEAR/pressure_floor_struct.h" +#else +#error "Invalid choice of star formation structure." +#endif + +#endif /* SWIFT_PRESSURE_FLOOR_STRUCT_H */ diff --git a/src/runner.c b/src/runner.c index 05dc33e97e74901bd87d1fe4da4259b6d8aa29e0..2f274992aba0864355e9fc2fa0c47730e1130c06 100644 --- a/src/runner.c +++ b/src/runner.c @@ -60,13 +60,14 @@ #include "logger.h" #include "memuse.h" #include "minmax.h" +#include "pressure_floor.h" +#include "pressure_floor_iact.h" #include "runner_doiact_vec.h" #include "scheduler.h" #include "sort_part.h" #include "space.h" #include "space_getsid.h" #include "star_formation.h" -#include "star_formation_iact.h" #include "star_formation_logger.h" #include "stars.h" #include "task.h" @@ -2032,7 +2033,6 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) { const struct hydro_space *hs = &s->hs; const struct cosmology *cosmo = e->cosmology; const struct chemistry_global_data *chemistry = e->chemistry; - const struct star_formation *star_formation = e->star_formation; const int with_cosmology = (e->policy & engine_policy_cosmology); @@ -2129,7 +2129,7 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) { /* Finish the density calculation */ hydro_end_density(p, cosmo); chemistry_end_density(p, chemistry, cosmo); - star_formation_end_density(p, star_formation, cosmo); + pressure_floor_end_density(p, cosmo); /* Compute one step of the Newton-Raphson scheme */ const float n_sum = p->density.wcount * h_old_dim; @@ -2276,7 +2276,7 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) { /* Re-initialise everything */ hydro_init_part(p, hs); chemistry_init_part(p, chemistry); - star_formation_init_part(p, xp, star_formation); + pressure_floor_init_part(p, xp); tracers_after_init(p, xp, e->internal_units, e->physical_constants, with_cosmology, e->cosmology, e->hydro_properties, e->cooling_func, e->time); @@ -2298,8 +2298,7 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) { if (has_no_neighbours) { hydro_part_has_no_neighbours(p, xp, cosmo); chemistry_part_has_no_neighbours(p, xp, chemistry, cosmo); - star_formation_part_has_no_neighbours(p, xp, star_formation, - cosmo); + pressure_floor_part_has_no_neighbours(p, xp, cosmo); } } else { diff --git a/src/runner_doiact.h b/src/runner_doiact.h index 1a39c8d49f2c4234c04982e255705f06ec1c5d38..8aabb05d177385c6bbee1a91eb2ea231ccbca3e4 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -213,7 +213,7 @@ void DOPAIR1_NAIVE(struct runner *r, struct cell *restrict ci, IACT_NONSYM(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } if (r2 < hjg2 && pj_active) { @@ -225,7 +225,7 @@ void DOPAIR1_NAIVE(struct runner *r, struct cell *restrict ci, IACT_NONSYM(r2, dx, hj, hi, pj, pi, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hj, hi, pj, pi, a, H); - runner_iact_nonsym_star_formation(r2, dx, hj, hi, pj, pi, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hj, hi, pj, pi, a, H); #endif } @@ -325,14 +325,14 @@ void DOPAIR2_NAIVE(struct runner *r, struct cell *restrict ci, IACT(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } else if (pi_active) { IACT_NONSYM(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } else if (pj_active) { @@ -343,7 +343,7 @@ void DOPAIR2_NAIVE(struct runner *r, struct cell *restrict ci, IACT_NONSYM(r2, dx, hj, hi, pj, pi, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hj, hi, pj, pi, a, H); - runner_iact_nonsym_star_formation(r2, dx, hj, hi, pj, pi, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hj, hi, pj, pi, a, H); #endif } } @@ -431,14 +431,14 @@ void DOSELF1_NAIVE(struct runner *r, struct cell *restrict c) { IACT(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } else if (doi) { IACT_NONSYM(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } else if (doj) { @@ -449,7 +449,7 @@ void DOSELF1_NAIVE(struct runner *r, struct cell *restrict c) { IACT_NONSYM(r2, dx, hj, hi, pj, pi, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hj, hi, pj, pi, a, H); - runner_iact_nonsym_star_formation(r2, dx, hj, hi, pj, pi, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hj, hi, pj, pi, a, H); #endif } } /* loop over the parts in cj. */ @@ -536,14 +536,14 @@ void DOSELF2_NAIVE(struct runner *r, struct cell *restrict c) { IACT(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } else if (doi) { IACT_NONSYM(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } else if (doj) { @@ -554,7 +554,7 @@ void DOSELF2_NAIVE(struct runner *r, struct cell *restrict c) { IACT_NONSYM(r2, dx, hj, hi, pj, pi, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hj, hi, pj, pi, a, H); - runner_iact_nonsym_star_formation(r2, dx, hj, hi, pj, pi, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hj, hi, pj, pi, a, H); #endif } } /* loop over the parts in cj. */ @@ -640,7 +640,7 @@ void DOPAIR_SUBSET_NAIVE(struct runner *r, struct cell *restrict ci, IACT_NONSYM(r2, dx, hi, pj->h, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hi, pj->h, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dx, hi, pj->h, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hi, pj->h, pi, pj, a, H); #endif } } /* loop over the parts in cj. */ @@ -733,7 +733,7 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci, IACT_NONSYM(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } } /* loop over the parts in cj. */ @@ -789,7 +789,7 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci, IACT_NONSYM(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } } /* loop over the parts in cj. */ @@ -931,7 +931,7 @@ void DOSELF_SUBSET(struct runner *r, struct cell *restrict ci, IACT_NONSYM(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } } /* loop over the parts in cj. */ @@ -1095,7 +1095,7 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj, const int sid, IACT_NONSYM(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } } /* loop over the parts in cj. */ @@ -1183,7 +1183,7 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj, const int sid, IACT_NONSYM(r2, dx, hj, hi, pj, pi, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hj, hi, pj, pi, a, H); - runner_iact_nonsym_star_formation(r2, dx, hj, hi, pj, pi, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hj, hi, pj, pi, a, H); #endif } } /* loop over the parts in ci. */ @@ -1483,7 +1483,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid, IACT_NONSYM(r2, dx, hj, hi, pj, pi, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hj, hi, pj, pi, a, H); - runner_iact_nonsym_star_formation(r2, dx, hj, hi, pj, pi, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hj, hi, pj, pi, a, H); #endif } } /* loop over the active parts in cj. */ @@ -1554,13 +1554,13 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid, IACT(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } else { IACT_NONSYM(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } } @@ -1663,7 +1663,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid, IACT_NONSYM(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } } /* loop over the active parts in ci. */ @@ -1736,13 +1736,13 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj, const int sid, IACT(r2, dx, hj, hi, pj, pi, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_chemistry(r2, dx, hj, hi, pj, pi, a, H); - runner_iact_star_formation(r2, dx, hj, hi, pj, pi, a, H); + runner_iact_pressure_floor(r2, dx, hj, hi, pj, pi, a, H); #endif } else { IACT_NONSYM(r2, dx, hj, hi, pj, pi, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hj, hi, pj, pi, a, H); - runner_iact_nonsym_star_formation(r2, dx, hj, hi, pj, pi, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hj, hi, pj, pi, a, H); #endif } } @@ -1931,7 +1931,7 @@ void DOSELF1(struct runner *r, struct cell *restrict c) { IACT_NONSYM(r2, dx, hj, hi, pj, pi, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hj, hi, pj, pi, a, H); - runner_iact_nonsym_star_formation(r2, dx, hj, hi, pj, pi, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hj, hi, pj, pi, a, H); #endif } } /* loop over all other particles. */ @@ -1983,14 +1983,14 @@ void DOSELF1(struct runner *r, struct cell *restrict c) { IACT(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } else if (doi) { IACT_NONSYM(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } else if (doj) { @@ -2000,7 +2000,7 @@ void DOSELF1(struct runner *r, struct cell *restrict c) { IACT_NONSYM(r2, dx, hj, hi, pj, pi, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hj, hi, pj, pi, a, H); - runner_iact_nonsym_star_formation(r2, dx, hj, hi, pj, pi, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hj, hi, pj, pi, a, H); #endif } } @@ -2127,7 +2127,7 @@ void DOSELF2(struct runner *r, struct cell *restrict c) { IACT_NONSYM(r2, dx, hj, hi, pj, pi, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hj, hi, pj, pi, a, H); - runner_iact_nonsym_star_formation(r2, dx, hj, hi, pj, pi, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hj, hi, pj, pi, a, H); #endif } } /* loop over all other particles. */ @@ -2174,13 +2174,13 @@ void DOSELF2(struct runner *r, struct cell *restrict c) { IACT(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } else { IACT_NONSYM(r2, dx, hi, hj, pi, pj, a, H); #if (FUNCTION_TASK_LOOP == TASK_LOOP_DENSITY) runner_iact_nonsym_chemistry(r2, dx, hi, hj, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dx, hi, hj, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hi, hj, pi, pj, a, H); #endif } } diff --git a/src/space.c b/src/space.c index 250af5efafa506408c9fd91c1adffb7cd96a1a21..57be6edf091c972b675de4231e830696430d90ee 100644 --- a/src/space.c +++ b/src/space.c @@ -56,9 +56,9 @@ #include "memuse.h" #include "minmax.h" #include "multipole.h" +#include "pressure_floor.h" #include "restart.h" #include "sort_part.h" -#include "star_formation.h" #include "star_formation_logger.h" #include "stars.h" #include "threadpool.h" @@ -4030,7 +4030,6 @@ void space_first_init_parts_mapper(void *restrict map_data, int count, const int with_gravity = e->policy & engine_policy_self_gravity; const struct chemistry_global_data *chemistry = e->chemistry; - const struct star_formation *star_formation = e->star_formation; const struct cooling_function_data *cool_func = e->cooling_func; /* Check that the smoothing lengths are non-zero */ @@ -4081,8 +4080,8 @@ void space_first_init_parts_mapper(void *restrict map_data, int count, /* Also initialise the chemistry */ chemistry_first_init_part(phys_const, us, cosmo, chemistry, &p[k], &xp[k]); - /* Also initialise the star formation */ - star_formation_first_init_part(phys_const, us, cosmo, star_formation, &p[k], + /* Also initialise the pressure floor */ + pressure_floor_first_init_part(phys_const, us, cosmo, &p[k], &xp[k]); /* And the cooling */ @@ -4365,7 +4364,7 @@ void space_init_parts_mapper(void *restrict map_data, int count, for (int k = 0; k < count; k++) { hydro_init_part(&parts[k], hs); chemistry_init_part(&parts[k], e->chemistry); - star_formation_init_part(&parts[k], &xparts[k], e->star_formation); + pressure_floor_init_part(&parts[k], &xparts[k]); tracers_after_init(&parts[k], &xparts[k], e->internal_units, e->physical_constants, with_cosmology, e->cosmology, e->hydro_properties, e->cooling_func, e->time); diff --git a/src/star_formation/EAGLE/star_formation.h b/src/star_formation/EAGLE/star_formation.h index f2c77e036842b4ca040c58a6bcad1513b03a42bd..377bf37c4b2e57b8a1d5002720f91bcbee7f2e68 100644 --- a/src/star_formation/EAGLE/star_formation.h +++ b/src/star_formation/EAGLE/star_formation.h @@ -627,71 +627,4 @@ INLINE static void starformation_print_backend( starform->max_gas_density_HpCM3); } -/** - * @brief Finishes the density calculation. - * - * Nothing to do here. We do not need to compute any quantity in the hydro - * density loop for the EAGLE star formation model. - * - * @param p The particle to act upon - * @param cd The global star_formation information. - * @param cosmo The current cosmological model. - */ -__attribute__((always_inline)) INLINE static void star_formation_end_density( - struct part* restrict p, const struct star_formation* cd, - const struct cosmology* cosmo) {} - -/** - * @brief Sets all particle fields to sensible values when the #part has 0 ngbs. - * - * Nothing to do here. We do not need to compute any quantity in the hydro - * density loop for the EAGLE star formation model. - * - * @param p The particle to act upon - * @param xp The extended particle data to act upon - * @param cd #star_formation containing star_formation informations. - * @param cosmo The current cosmological model. - */ -__attribute__((always_inline)) INLINE static void -star_formation_part_has_no_neighbours(struct part* restrict p, - struct xpart* restrict xp, - const struct star_formation* cd, - const struct cosmology* cosmo) {} - -/** - * @brief Sets the star_formation properties of the (x-)particles to a valid - * start state. - * - * Nothing to do here. - * - * @param phys_const The physical constant in internal units. - * @param us The unit system. - * @param cosmo The current cosmological model. - * @param data The global star_formation information used for this run. - * @param p Pointer to the particle data. - * @param xp Pointer to the extended particle data. - */ -__attribute__((always_inline)) INLINE static void -star_formation_first_init_part(const struct phys_const* restrict phys_const, - const struct unit_system* restrict us, - const struct cosmology* restrict cosmo, - const struct star_formation* data, - const struct part* restrict p, - struct xpart* restrict xp) {} - -/** - * @brief Sets the star_formation properties of the (x-)particles to a valid - * start state. - * - * Nothing to do here. We do not need to compute any quantity in the hydro - * density loop for the EAGLE star formation model. - * - * @param p Pointer to the particle data. - * @param xp Pointer to the extended particle data. - * @param data The global star_formation information. - */ -__attribute__((always_inline)) INLINE static void star_formation_init_part( - struct part* restrict p, struct xpart* restrict xp, - const struct star_formation* data) {} - #endif /* SWIFT_EAGLE_STAR_FORMATION_H */ diff --git a/src/star_formation/EAGLE/star_formation_iact.h b/src/star_formation/EAGLE/star_formation_iact.h deleted file mode 100644 index ab917cbe7aa67cad93a92a4b24212c5f1dcf3aeb..0000000000000000000000000000000000000000 --- a/src/star_formation/EAGLE/star_formation_iact.h +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * This file is part of SWIFT. - * Copyright (c) 2018 Matthieu Schaller (matthieu.schaller@durham.ac.uk) - * - * 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_EAGLE_STAR_FORMATION_IACT_H -#define SWIFT_EAGLE_STAR_FORMATION_IACT_H - -/** - * @file EAGLE/star_formation_iact.h - * @brief Density computation - */ - -/** - * @brief do star_formation computation after the runner_iact_density (symmetric - * version) - * - * @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 pi First particle. - * @param pj Second particle. - * @param a Current scale factor. - * @param H Current Hubble parameter. - */ -__attribute__((always_inline)) INLINE static void runner_iact_star_formation( - float r2, const float *dx, float hi, float hj, struct part *restrict pi, - struct part *restrict pj, float a, float H) { - - /* Nothing to do here. We do not need to compute any quantity in the hydro - density loop for the EAGLE star formation model. */ -} - -/** - * @brief do star_formation computation after the runner_iact_density (non - * symmetric version) - * - * @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 pi First particle. - * @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_star_formation(float r2, const float *dx, float hi, float hj, - struct part *restrict pi, - const struct part *restrict pj, float a, - float H) { - - /* Nothing to do here. We do not need to compute any quantity in the hydro - density loop for the EAGLE star formation model. */ -} - -#endif /* SWIFT_EAGLE_STAR_FORMATION_IACT_H */ diff --git a/src/star_formation/EAGLE/star_formation_struct.h b/src/star_formation/EAGLE/star_formation_struct.h index 8caac49d4b57652c5db9ae93e3789dc690e6d23f..41247e160a3eddbc9184c59b67cfa2a1d7259a05 100644 --- a/src/star_formation/EAGLE/star_formation_struct.h +++ b/src/star_formation/EAGLE/star_formation_struct.h @@ -29,6 +29,4 @@ struct star_formation_xpart_data { float SFR; }; -struct star_formation_part_data {}; - #endif /* SWIFT_EAGLE_STAR_FORMATION_STRUCT_H */ diff --git a/src/star_formation/GEAR/star_formation.h b/src/star_formation/GEAR/star_formation.h index ac423a51865609460e870f65b1eeeb266182e2ef..66276c6a7e0bbcc0003fb8f1e1a627749fbabdaf 100644 --- a/src/star_formation/GEAR/star_formation.h +++ b/src/star_formation/GEAR/star_formation.h @@ -70,8 +70,9 @@ INLINE static int star_formation_is_star_forming( } /* Get the required variables */ - const float sigma2 = p->sf_data.sigma2; - const float n_jeans_2_3 = starform->n_jeans_2_3; + const float sigma2 = p->pressure_floor_data.sigma2; + // TODO precompute it + const float n_jeans_2_3 = pow(pressure_floor_props.n_jeans, 2./3.); const float h = p->h; const float density = hydro_get_physical_density(p, cosmo); @@ -223,79 +224,4 @@ INLINE static void starformation_print_backend( message("Star formation law is 'GEAR'"); } -/** - * @brief Finishes the density calculation. - * - * @param p The particle to act upon - * @param xp The extended particle data to act upon - * @param sf The global star_formation information. - * @param cosmo The current cosmological model. - */ -__attribute__((always_inline)) INLINE static void star_formation_end_density( - struct part* restrict p, const struct star_formation* sf, - const struct cosmology* cosmo) { - - // TODO move into pressure floor - /* To finish the turbulence estimation we devide by the density */ - p->sf_data.sigma2 /= - pow_dimension(p->h) * hydro_get_physical_density(p, cosmo); - - /* Add the cosmological factor */ - p->sf_data.sigma2 *= cosmo->a * cosmo->a; -} - -/** - * @brief Sets all particle fields to sensible values when the #part has 0 ngbs. - * - * @param p The particle to act upon - * @param xp The extended particle data to act upon - * @param cd #star_formation containing star_formation informations. - * @param cosmo The current cosmological model. - */ -__attribute__((always_inline)) INLINE static void -star_formation_part_has_no_neighbours(struct part* restrict p, - struct xpart* restrict xp, - const struct star_formation* cd, - const struct cosmology* cosmo) { - - // TODO move into pressure floor - /* If part has 0 neighbours, the estimation of turbulence is 0 */ - p->sf_data.sigma2 = 0.f; -} - -/** - * @brief Sets the star_formation properties of the (x-)particles to a valid - * start state. - * - * @param p Pointer to the particle data. - * @param xp Pointer to extended particle data - * @param data The global star_formation information. - */ -__attribute__((always_inline)) INLINE static void star_formation_init_part( - struct part* restrict p, struct xpart* restrict xp, - const struct star_formation* data) { - p->sf_data.sigma2 = 0.f; -} - -/** - * @brief Sets the star_formation properties of the (x-)particles to a valid - * start state. - * @param phys_const The physical constant in internal units. - * @param us The unit system. - * @param cosmo The current cosmological model. - * @param data The global star_formation information used for this run. - * @param p Pointer to the particle data. - */ -__attribute__((always_inline)) INLINE static void -star_formation_first_init_part(const struct phys_const* restrict phys_const, - const struct unit_system* restrict us, - const struct cosmology* restrict cosmo, - const struct star_formation* data, - struct part* restrict p, - struct xpart* restrict xp) { - - /* Nothing special here */ - star_formation_init_part(p, xp, data); -} - #endif /* SWIFT_GEAR_STAR_FORMATION_H */ diff --git a/src/star_formation/GEAR/star_formation_io.h b/src/star_formation/GEAR/star_formation_io.h index 3e021f7844c1deaeca40d7144d6f7b69cb6c2bdb..15e5862fbd0d40a7a798020dad137d028b7580ec 100644 --- a/src/star_formation/GEAR/star_formation_io.h +++ b/src/star_formation/GEAR/star_formation_io.h @@ -56,11 +56,6 @@ INLINE static void starformation_init_backend( const struct unit_system* us, const struct hydro_props* hydro_props, struct star_formation* starform) { - // TODO move into pressure floor - starform->n_jeans_2_3 = - parser_get_param_float(parameter_file, "GEARStarFormation:NJeans"); - starform->n_jeans_2_3 = pow(starform->n_jeans_2_3, 2. / 3.); - /* Star formation efficiency */ starform->star_formation_efficiency = parser_get_param_double( parameter_file, "GEARStarFormation:star_formation_efficiency"); diff --git a/src/star_formation/GEAR/star_formation_struct.h b/src/star_formation/GEAR/star_formation_struct.h index 2e9a7548f83ca6ae9bb78ee7bcf4be69a0a31489..b46d12ebd0462b41d74a8c483e3a31db7751e4ab 100644 --- a/src/star_formation/GEAR/star_formation_struct.h +++ b/src/star_formation/GEAR/star_formation_struct.h @@ -25,22 +25,11 @@ */ struct star_formation_xpart_data {}; -struct star_formation_part_data { - // TODO move it to the pressure floor - /*! Estimation of local turbulence (squared) */ - float sigma2; -}; - /** * @brief Global star formation properties */ struct star_formation { - // TODO move it to pressure floor - /*! Number of particle required to resolved the Jeans criterion (at power 2/3) - */ - float n_jeans_2_3; - /*! Maximal temperature for forming a star */ float maximal_temperature; diff --git a/src/star_formation/none/star_formation.h b/src/star_formation/none/star_formation.h index 6b83010ec5f8935778af8c9ad21010ff3452fc0e..0f53e951cb5842e5be3bb9bbe64eb6686f822b1e 100644 --- a/src/star_formation/none/star_formation.h +++ b/src/star_formation/none/star_formation.h @@ -163,64 +163,4 @@ INLINE static void starformation_print_backend( message("Star formation law is 'No Star Formation'"); } -/** - * @brief Finishes the density calculation. - * - * @param p The particle to act upon - * @param cd The global star_formation information. - * @param cosmo The current cosmological model. - */ -__attribute__((always_inline)) INLINE static void star_formation_end_density( - struct part* restrict p, const struct star_formation* cd, - const struct cosmology* cosmo) {} - -/** - * @brief Sets all particle fields to sensible values when the #part has 0 ngbs. - * - * @param p The particle to act upon - * @param xp The extended particle data to act upon - * @param cd #star_formation containing star_formation informations. - * @param cosmo The current cosmological model. - */ -__attribute__((always_inline)) INLINE static void -star_formation_part_has_no_neighbours(struct part* restrict p, - struct xpart* restrict xp, - const struct star_formation* cd, - const struct cosmology* cosmo) {} - -/** - * @brief Sets the star_formation properties of the (x-)particles to a valid - * start state. - * - * Nothing to do here. - * - * @param phys_const The physical constant in internal units. - * @param us The unit system. - * @param cosmo The current cosmological model. - * @param data The global star_formation information used for this run. - * @param p Pointer to the particle data. - * @param xp Pointer to the extended particle data. - */ -__attribute__((always_inline)) INLINE static void -star_formation_first_init_part(const struct phys_const* restrict phys_const, - const struct unit_system* restrict us, - const struct cosmology* restrict cosmo, - const struct star_formation* data, - const struct part* restrict p, - struct xpart* restrict xp) {} - -/** - * @brief Sets the star_formation properties of the (x-)particles to a valid - * start state. - * - * Nothing to do here. - * - * @param p Pointer to the particle data. - * @param xp Pointer to the extended particle data. - * @param data The global star_formation information. - */ -__attribute__((always_inline)) INLINE static void star_formation_init_part( - struct part* restrict p, struct xpart* restrict xp, - const struct star_formation* data) {} - #endif /* SWIFT_NONE_STAR_FORMATION_H */ diff --git a/src/star_formation/none/star_formation_struct.h b/src/star_formation/none/star_formation_struct.h index 2f5241a58caf1ca70fa98a40d467c8ff5a3237f7..27a2adaf83d0a02a0d08e7eef8b45bea630689e4 100644 --- a/src/star_formation/none/star_formation_struct.h +++ b/src/star_formation/none/star_formation_struct.h @@ -25,10 +25,4 @@ */ struct star_formation_xpart_data {}; -/** - * @brief Star-formation-related properties stored in the particle - * data. - */ -struct star_formation_part_data {}; - #endif /* SWIFT_NONE_STAR_FORMATION_STRUCT_H */ diff --git a/src/tools.c b/src/tools.c index bd467e1841b78d45a74b037c63e8ed58dd92183f..bd8c3e9ed89f62ec513290a32d7858c17e4ed509 100644 --- a/src/tools.c +++ b/src/tools.c @@ -46,7 +46,7 @@ #include "part.h" #include "periodic.h" #include "runner.h" -#include "star_formation_iact.h" +#include "pressure_floor_iact.h" #include "stars.h" /** @@ -224,7 +224,7 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) { /* Interact */ runner_iact_nonsym_density(r2, dx, hi, pj->h, pi, pj, a, H); runner_iact_nonsym_chemistry(r2, dx, hi, pj->h, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dx, hi, pj->h, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hi, pj->h, pi, pj, a, H); } } } @@ -257,7 +257,7 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) { /* Interact */ runner_iact_nonsym_density(r2, dx, hj, pi->h, pj, pi, a, H); runner_iact_nonsym_chemistry(r2, dx, hj, pi->h, pj, pi, a, H); - runner_iact_nonsym_star_formation(r2, dx, hj, pi->h, pj, pi, a, H); + runner_iact_nonsym_pressure_floor(r2, dx, hj, pi->h, pj, pi, a, H); } } } @@ -535,7 +535,7 @@ void self_all_density(struct runner *r, struct cell *ci) { /* Interact */ runner_iact_nonsym_density(r2, dxi, hi, hj, pi, pj, a, H); runner_iact_nonsym_chemistry(r2, dxi, hi, hj, pi, pj, a, H); - runner_iact_nonsym_star_formation(r2, dxi, hi, hj, pi, pj, a, H); + runner_iact_nonsym_pressure_floor(r2, dxi, hi, hj, pi, pj, a, H); } /* Hit or miss? */ @@ -548,7 +548,7 @@ void self_all_density(struct runner *r, struct cell *ci) { /* Interact */ runner_iact_nonsym_density(r2, dxi, hj, hi, pj, pi, a, H); runner_iact_nonsym_chemistry(r2, dxi, hj, hi, pj, pi, a, H); - runner_iact_nonsym_star_formation(r2, dxi, hj, hi, pj, pi, a, H); + runner_iact_nonsym_pressure_floor(r2, dxi, hj, hi, pj, pi, a, H); } } }