Skip to content
Snippets Groups Projects
Commit 3fbee202 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Better function name for the first initialiation of all the parts at the very...

Better function name for the first initialiation of all the parts at the very start of engine_init_particles()
parent 5b7ea015
No related branches found
No related tags found
No related merge requests found
......@@ -4133,6 +4133,26 @@ void engine_launch(struct engine *e) {
clocks_getunit());
}
/**
* @brief Calls the 'first init' function on the particles of all types.
*
* @param e The #engine.
*/
void engine_first_init_particles(struct engine *e) {
const ticks tic = getticks();
/* Set the particles in a state where they are ready for a run */
space_first_init_parts(e->s, e->chemistry);
space_first_init_xparts(e->s, e->cooling_func);
space_first_init_gparts(e->s, e->gravity_properties);
space_first_init_sparts(e->s);
if (e->verbose)
message("took %.3f %s.", clocks_from_ticks(getticks() - tic),
clocks_getunit());
}
/**
* @brief Initialises the particles and set them in a state ready to move
*forward in time.
......@@ -4152,26 +4172,11 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs,
clocks_gettime(&time1);
/* Start by setting the particles in a good state */
ticks my_tic = getticks();
if (e->nodeID == 0) message("first init...");
/* Set the particles in a state where they are ready for a run */
space_first_init_parts(s, e->chemistry);
space_first_init_xparts(s, e->cooling_func);
space_first_init_gparts(s);
space_first_init_sparts(s);
if (e->verbose)
message("took %.3f %s.", clocks_from_ticks(getticks() - my_tic),
clocks_getunit());
if (e->nodeID == 0) message("Setting particles to a valid state...");
engine_first_init_particles(e);
if (e->nodeID == 0) message("Computing initial gas densities.");
/* Initialise the softening lengths */
if (e->policy & engine_policy_self_gravity) {
for (size_t i = 0; i < s->nr_gparts; ++i)
gravity_init_softening(&s->gparts[i], e->gravity_properties);
}
/* Construct all cells and tasks to start everything */
engine_rebuild(e, clean_h_values);
......@@ -4245,7 +4250,9 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs,
if (e->nodeID == 0) scheduler_write_dependencies(&e->sched, e->verbose);
/* Run the 0th time-step */
TIMER_TIC2;
engine_launch(e);
TIMER_TOC2(timer_runners);
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
/* Check the accuracy of the gravity calculation */
......
......@@ -147,27 +147,15 @@ gravity_reset_predicted_values(struct gpart* gp) {}
* read in to do some conversions.
*
* @param gp The particle to act upon
* @param grav_props The global properties of the gravity calculation.
*/
__attribute__((always_inline)) INLINE static void gravity_first_init_gpart(
struct gpart* gp) {
struct gpart* gp, const struct gravity_props* grav_props) {
gp->time_bin = 0;
gp->epsilon = 0.f;
gp->epsilon = grav_props->epsilon;
gravity_init_gpart(gp);
}
/**
* @brief Initialises the softening of the g-particles
*
* @param gp The particle to act upon.
* @param grav_props The properties of the gravity scheme.
*/
__attribute__((always_inline)) INLINE static void gravity_init_softening(
struct gpart* gp, const struct gravity_props* grav_props) {
/* Note 3 is the Plummer-equivalent correction */
gp->epsilon = grav_props->epsilon;
}
#endif /* SWIFT_DEFAULT_GRAVITY_H */
......@@ -2618,6 +2618,7 @@ void space_synchronize_particle_positions(struct space *s) {
* @brief Initialises all the particles by setting them into a valid state
*
* Calls hydro_first_init_part() on all the particles
* Calls chemistry_first_init_part() on all the particles
*/
void space_first_init_parts(struct space *s,
const struct chemistry_data *chemistry) {
......@@ -2673,7 +2674,8 @@ void space_first_init_xparts(struct space *s,
*
* Calls gravity_first_init_gpart() on all the particles
*/
void space_first_init_gparts(struct space *s) {
void space_first_init_gparts(struct space *s,
const struct gravity_props *grav_props) {
const size_t nr_gparts = s->nr_gparts;
struct gpart *restrict gp = s->gparts;
......@@ -2690,7 +2692,7 @@ void space_first_init_gparts(struct space *s) {
gp[i].v_full[1] = gp[i].v_full[2] = 0.f;
#endif
gravity_first_init_gpart(&gp[i]);
gravity_first_init_gpart(&gp[i], grav_props);
#ifdef SWIFT_DEBUG_CHECKS
gp->ti_drift = 0;
......
......@@ -30,11 +30,11 @@
#include <stddef.h>
/* Includes. */
#include "gravity_properties.h"
#include "hydro_space.h"
#include "lock.h"
#include "parser.h"
#include "part.h"
#include "space.h"
/* Avoid cyclic inclusions */
struct cell;
......@@ -227,7 +227,8 @@ void space_first_init_parts(struct space *s,
const struct chemistry_data *chemistry);
void space_first_init_xparts(struct space *s,
const struct cooling_function_data *cool_func);
void space_first_init_gparts(struct space *s);
void space_first_init_gparts(struct space *s,
const struct gravity_props *grav_props);
void space_first_init_sparts(struct space *s);
void space_init_parts(struct space *s, int verbose);
void space_init_gparts(struct space *s, int verbose);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment