diff --git a/src/runner.c b/src/runner.c index 7dea47aa0820f375f85d574a11e3dfa3700d36c6..72b7e8d15790d6aa5278e3f554cd0509151e6534 100644 --- a/src/runner.c +++ b/src/runner.c @@ -64,7 +64,11 @@ #include "task.h" #include "timers.h" #include "timestep.h" +<<<<<<< HEAD #include "tracers.h" +======= +#include "starformation.h" +>>>>>>> Remove a few bugs #define TASK_LOOP_DENSITY 0 #define TASK_LOOP_GRADIENT 1 @@ -465,6 +469,8 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) { struct engine *e = r->e; const struct cosmology *cosmo = e->cosmology; + const struct star_formation starform = e->star_formation; + const struct phys_const *constants = e->physical_constants; const int count = c->hydro.count; struct part *restrict parts = c->hydro.parts; struct xpart *restrict xparts = c->hydro.xparts; @@ -491,19 +497,15 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) { const float rho = hydro_get_physical_density(p, cosmo); + if (starformation_potential_to_become_star(starform, p, xp, constants, cosmo) ) { + starformation_convert_to_gas(starform, p, xp, cosmo); + } // MATTHIEU: Temporary star-formation law // Do not use this at home. - if (rho > 1.7e7 && e->step > 2) { - message("Removing particle id=%lld rho=%e", p->id, rho); - - struct spart *sp = cell_convert_part_to_spart(e, c, p, xp); - - /* Did we run out of fresh particles? */ - if (sp == NULL) continue; - - /* Set everything to a valid state */ - stars_init_spart(sp); - } + //if (rho > 1.5e7 && e->step > 2) { + // message("Removing particle id=%lld rho=%e", p->id, rho); + // cell_convert_part_to_gpart(e, c, p, xp); + //} } } } diff --git a/src/starformation.c b/src/starformation.c index a11220ec096234fa5850d9359fda61fcf57c8f71..c9dd394beb3061c42a15a35b33c55cc4e9222c45 100644 --- a/src/starformation.c +++ b/src/starformation.c @@ -23,6 +23,8 @@ /* This object's header. */ #include "starformation.h" #include "restart.h" +#include "part.h" +#include "units.h" /** * @brief Initialises the star formation law properties in the internal @@ -59,7 +61,7 @@ void starformation_print(const struct star_formation* starform) { * @param starform the star formation struct * @param stream the file stream */ -void potential_struct_dump(const struct star_formation* starform, +void starformation_struct_dump(const struct star_formation* starform, FILE* stream) { restart_write_blocks((void*)starform, sizeof(struct star_formation), 1, stream, "starformation", "star formation"); @@ -72,7 +74,7 @@ void potential_struct_dump(const struct star_formation* starform, * @param starform the star formation struct * @param streeam the file stream */ -void potential_struct_restore(const struct star_formation* starform, +void starformation_struct_restore(const struct star_formation* starform, FILE* stream) { restart_read_blocks((void*)starform, sizeof(struct star_formation), 1, stream, NULL, "star formation"); diff --git a/src/starformation.h b/src/starformation.h index 02287e4ae6c451b819243ce60ae84e8b11ab25a7..a785135a3051c0d75ed772b29fc7cd1ee3c243f1 100644 --- a/src/starformation.h +++ b/src/starformation.h @@ -36,5 +36,19 @@ #error "Invalid choice of star formation law" #endif +/* General functions defined in the source file */ +void starformation_init(struct swift_params* parameter_file, + const struct phys_const* phys_const, + const struct unit_system* us, + struct star_formation* starform); + +void starformation_print(const struct star_formation* starform); + +/* Dump store */ +void starformation_struct_dump(const struct star_formation* starform, + FILE* stream); + +void starformation_struct_restore(const struct star_formation* starform, + FILE* stream); #endif /* SWIFT_STARFORMATION_H */ diff --git a/src/starformation/none/starformation.h b/src/starformation/none/starformation.h index 2edccc0798c2e9083faaad98533c35494eb12761..953b1f038a9b1c36f9da328fd643df0f2ab3fd9d 100644 --- a/src/starformation/none/starformation.h +++ b/src/starformation/none/starformation.h @@ -26,9 +26,11 @@ /* Local includes */ #include "cosmology.h" #include "physical_constants.h" +#include "part.h" #include "units.h" #include "parser.h" #include "equation_of_state.h" +#include "error.h" /* Starformation struct */ struct star_formation {}; diff --git a/src/starformation/schaye08/starformation.h b/src/starformation/schaye08/starformation.h index 0f7ae4c4145a092945b070f230c62f943be52e10..aeb25d0e517adc9a54449145c24d0e5eb3cf558b 100644 --- a/src/starformation/schaye08/starformation.h +++ b/src/starformation/schaye08/starformation.h @@ -29,6 +29,7 @@ #include "units.h" #include "parser.h" #include "equation_of_state.h" +#include "part.h" /* Starformation struct */ struct star_formation {