Commit 691d8a15 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Re-generated the code from timestep_limiter2. Code runs until the first rebuild.

parent b3421a96
...@@ -36,7 +36,8 @@ Parameters: ...@@ -36,7 +36,8 @@ Parameters:
-s, --hydro Run with hydrodynamics. -s, --hydro Run with hydrodynamics.
-S, --stars Run with stars. -S, --stars Run with stars.
-x, --velociraptor Run with structure finding. -x, --velociraptor Run with structure finding.
--limiter Run with time-step limiter.
Control options: Control options:
-a, --pin Pin runners using processor affinity. -a, --pin Pin runners using processor affinity.
......
...@@ -84,6 +84,7 @@ Parameters: ...@@ -84,6 +84,7 @@ Parameters:
-s, --hydro Run with hydrodynamics. -s, --hydro Run with hydrodynamics.
-S, --stars Run with stars. -S, --stars Run with stars.
-x, --velociraptor Run with structure finding. -x, --velociraptor Run with structure finding.
--limiter Run with time-step limiter.
Control options: Control options:
......
...@@ -31,6 +31,7 @@ can be found by typing ``./swift -h``:: ...@@ -31,6 +31,7 @@ can be found by typing ``./swift -h``::
-s, --hydro Run with hydrodynamics. -s, --hydro Run with hydrodynamics.
-S, --stars Run with stars. -S, --stars Run with stars.
-x, --velociraptor Run with structure finding. -x, --velociraptor Run with structure finding.
--limiter Run with time-step limiter.
Control options: Control options:
......
...@@ -8,7 +8,7 @@ then ...@@ -8,7 +8,7 @@ then
fi fi
# Run SWIFT # Run SWIFT
../swift --hydro --threads=1 sedov.yml 2>&1 | tee output.log ../swift --hydro --limiter --threads=1 sedov.yml 2>&1 | tee output.log
# Plot the solution # Plot the solution
python plotSolution.py 5 python plotSolution.py 5
...@@ -11,7 +11,7 @@ TimeIntegration: ...@@ -11,7 +11,7 @@ TimeIntegration:
time_begin: 0. # The starting time of the simulation (in internal units). time_begin: 0. # The starting time of the simulation (in internal units).
time_end: 5e-2 # The end time of the simulation (in internal units). time_end: 5e-2 # The end time of the simulation (in internal units).
dt_min: 1e-7 # The minimal time-step size of the simulation (in internal units). dt_min: 1e-7 # The minimal time-step size of the simulation (in internal units).
dt_max: 1e-5 # The maximal time-step size of the simulation (in internal units). dt_max: 1e-2 # The maximal time-step size of the simulation (in internal units).
# Parameters governing the snapshots # Parameters governing the snapshots
Snapshots: Snapshots:
...@@ -21,7 +21,7 @@ Snapshots: ...@@ -21,7 +21,7 @@ Snapshots:
# Parameters governing the conserved quantities statistics # Parameters governing the conserved quantities statistics
Statistics: Statistics:
delta_time: 1e-5 # Time between statistics output delta_time: 1e-2 # Time between statistics output
# Parameters for the hydrodynamics scheme # Parameters for the hydrodynamics scheme
SPH: SPH:
......
...@@ -153,6 +153,7 @@ int main(int argc, char *argv[]) { ...@@ -153,6 +153,7 @@ int main(int argc, char *argv[]) {
int with_stars = 0; int with_stars = 0;
int with_star_formation = 0; int with_star_formation = 0;
int with_feedback = 0; int with_feedback = 0;
int with_limiter = 0;
int with_fp_exceptions = 0; int with_fp_exceptions = 0;
int with_drift_all = 0; int with_drift_all = 0;
int with_mpole_reconstruction = 0; int with_mpole_reconstruction = 0;
...@@ -202,6 +203,8 @@ int main(int argc, char *argv[]) { ...@@ -202,6 +203,8 @@ int main(int argc, char *argv[]) {
OPT_BOOLEAN('S', "stars", &with_stars, "Run with stars.", NULL, 0, 0), OPT_BOOLEAN('S', "stars", &with_stars, "Run with stars.", NULL, 0, 0),
OPT_BOOLEAN('x', "velociraptor", &with_structure_finding, OPT_BOOLEAN('x', "velociraptor", &with_structure_finding,
"Run with structure finding.", NULL, 0, 0), "Run with structure finding.", NULL, 0, 0),
OPT_BOOLEAN(0, "limiter", &with_limiter, "Run with time-step limiter.",
NULL, 0, 0),
OPT_GROUP(" Control options:\n"), OPT_GROUP(" Control options:\n"),
OPT_BOOLEAN('a', "pin", &with_aff, OPT_BOOLEAN('a', "pin", &with_aff,
...@@ -456,6 +459,7 @@ int main(int argc, char *argv[]) { ...@@ -456,6 +459,7 @@ int main(int argc, char *argv[]) {
if (with_feedback) error("Can't run with feedback over MPI (yet)."); if (with_feedback) error("Can't run with feedback over MPI (yet).");
if (with_star_formation) if (with_star_formation)
error("Can't run with star formation over MPI (yet)"); error("Can't run with star formation over MPI (yet)");
if (with_limiter) error("Can't run with time-step limiter over MPI (yet)");
#endif #endif
#if defined(WITH_MPI) && defined(HAVE_VELOCIRAPTOR) #if defined(WITH_MPI) && defined(HAVE_VELOCIRAPTOR)
...@@ -878,6 +882,7 @@ int main(int argc, char *argv[]) { ...@@ -878,6 +882,7 @@ int main(int argc, char *argv[]) {
engine_policies |= engine_policy_external_gravity; engine_policies |= engine_policy_external_gravity;
if (with_cosmology) engine_policies |= engine_policy_cosmology; if (with_cosmology) engine_policies |= engine_policy_cosmology;
if (with_temperature) engine_policies |= engine_policy_temperature; if (with_temperature) engine_policies |= engine_policy_temperature;
if (with_limiter) engine_policies |= engine_policy_limiter;
if (with_cooling) engine_policies |= engine_policy_cooling; if (with_cooling) engine_policies |= engine_policy_cooling;
if (with_stars) engine_policies |= engine_policy_stars; if (with_stars) engine_policies |= engine_policy_stars;
if (with_star_formation) engine_policies |= engine_policy_star_formation; if (with_star_formation) engine_policies |= engine_policy_star_formation;
......
...@@ -75,7 +75,7 @@ nobase_noinst_HEADERS = align.h approx_math.h atomic.h barrier.h cycle.h error.h ...@@ -75,7 +75,7 @@ nobase_noinst_HEADERS = align.h approx_math.h atomic.h barrier.h cycle.h error.h
gravity_iact.h kernel_long_gravity.h vector.h cache.h runner_doiact.h runner_doiact_vec.h runner_doiact_grav.h \ gravity_iact.h kernel_long_gravity.h vector.h cache.h runner_doiact.h runner_doiact_vec.h runner_doiact_grav.h \
runner_doiact_nosort.h runner_doiact_stars.h units.h intrinsics.h minmax.h kick.h timestep.h drift.h \ runner_doiact_nosort.h runner_doiact_stars.h units.h intrinsics.h minmax.h kick.h timestep.h drift.h \
adiabatic_index.h io_properties.h dimension.h part_type.h periodic.h memswap.h dump.h logger.h sign.h \ adiabatic_index.h io_properties.h dimension.h part_type.h periodic.h memswap.h dump.h logger.h sign.h \
logger_io.h \ logger_io.h timestep_limiter.h \
gravity.h gravity_io.h gravity_cache.h \ gravity.h gravity_io.h gravity_cache.h \
gravity/Default/gravity.h gravity/Default/gravity_iact.h gravity/Default/gravity_io.h \ gravity/Default/gravity.h gravity/Default/gravity_iact.h gravity/Default/gravity_io.h \
gravity/Default/gravity_debug.h gravity/Default/gravity_part.h \ gravity/Default/gravity_debug.h gravity/Default/gravity_part.h \
......
...@@ -1232,8 +1232,11 @@ void cell_clean_links(struct cell *c, void *data) { ...@@ -1232,8 +1232,11 @@ void cell_clean_links(struct cell *c, void *data) {
c->hydro.density = NULL; c->hydro.density = NULL;
c->hydro.gradient = NULL; c->hydro.gradient = NULL;
c->hydro.force = NULL; c->hydro.force = NULL;
c->hydro.limiter = NULL;
c->grav.grav = NULL; c->grav.grav = NULL;
c->grav.mm = NULL; c->grav.mm = NULL;
c->stars.density = NULL;
c->stars.feedback = NULL;
} }
/** /**
...@@ -1599,6 +1602,14 @@ void cell_clear_drift_flags(struct cell *c, void *data) { ...@@ -1599,6 +1602,14 @@ void cell_clear_drift_flags(struct cell *c, void *data) {
c->grav.do_sub_drift = 0; c->grav.do_sub_drift = 0;
} }
/**
* @brief Clear the limiter flags on the given cell.
*/
void cell_clear_limiter_flags(struct cell *c, void *data) {
c->hydro.do_limiter = 0;
c->hydro.do_sub_limiter = 0;
}
/** /**
* @brief Activate the #part drifts on the given cell. * @brief Activate the #part drifts on the given cell.
*/ */
...@@ -1686,6 +1697,34 @@ void cell_activate_drift_spart(struct cell *c, struct scheduler *s) { ...@@ -1686,6 +1697,34 @@ void cell_activate_drift_spart(struct cell *c, struct scheduler *s) {
cell_activate_drift_gpart(c, s); cell_activate_drift_gpart(c, s);
} }
/**
* @brief Activate the drifts on the given cell.
*/
void cell_activate_limiter(struct cell *c, struct scheduler *s) {
/* If this cell is already marked for drift, quit early. */
if (c->hydro.do_limiter) return;
/* Mark this cell for drifting. */
c->hydro.do_limiter = 1;
/* Set the do_sub_limiter all the way up and activate the super limiter
if this has not yet been done. */
if (c == c->super) {
scheduler_activate(s, c->timestep_limiter);
} else {
for (struct cell *parent = c->parent;
parent != NULL && !parent->hydro.do_sub_limiter;
parent = parent->parent) {
parent->hydro.do_sub_limiter = 1;
if (parent == c->super) {
scheduler_activate(s, parent->timestep_limiter);
break;
}
}
}
}
/** /**
* @brief Activate the sorts up a cell hierarchy. * @brief Activate the sorts up a cell hierarchy.
*/ */
...@@ -1816,6 +1855,7 @@ void cell_activate_stars_sorts(struct cell *c, int sid, struct scheduler *s) { ...@@ -1816,6 +1855,7 @@ void cell_activate_stars_sorts(struct cell *c, int sid, struct scheduler *s) {
void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj, void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj,
struct scheduler *s) { struct scheduler *s) {
const struct engine *e = s->space->e; const struct engine *e = s->space->e;
const int with_limiter = (e->policy & engine_policy_limiter);
/* Store the current dx_max and h_max values. */ /* Store the current dx_max and h_max values. */
ci->hydro.dx_max_part_old = ci->hydro.dx_max_part; ci->hydro.dx_max_part_old = ci->hydro.dx_max_part;
...@@ -1849,6 +1889,7 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj, ...@@ -1849,6 +1889,7 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj,
/* We have reached the bottom of the tree: activate drift */ /* We have reached the bottom of the tree: activate drift */
cell_activate_drift_part(ci, s); cell_activate_drift_part(ci, s);
if (with_limiter) cell_activate_limiter(ci, s);
} }
} }
...@@ -2154,6 +2195,12 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj, ...@@ -2154,6 +2195,12 @@ void cell_activate_subcell_hydro_tasks(struct cell *ci, struct cell *cj,
if (ci->nodeID == engine_rank) cell_activate_drift_part(ci, s); if (ci->nodeID == engine_rank) cell_activate_drift_part(ci, s);
if (cj->nodeID == engine_rank) cell_activate_drift_part(cj, s); if (cj->nodeID == engine_rank) cell_activate_drift_part(cj, s);
/* Also activate the time-step limiter */
if (ci->nodeID == engine_rank && with_limiter)
cell_activate_limiter(ci, s);
if (cj->nodeID == engine_rank && with_limiter)
cell_activate_limiter(cj, s);
/* Do we need to sort the cells? */ /* Do we need to sort the cells? */
cell_activate_hydro_sorts(ci, sid, s); cell_activate_hydro_sorts(ci, sid, s);
cell_activate_hydro_sorts(cj, sid, s); cell_activate_hydro_sorts(cj, sid, s);
...@@ -2718,6 +2765,7 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { ...@@ -2718,6 +2765,7 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
struct engine *e = s->space->e; struct engine *e = s->space->e;
const int nodeID = e->nodeID; const int nodeID = e->nodeID;
const int with_limiter = (e->policy & engine_policy_limiter);
int rebuild = 0; int rebuild = 0;
/* Un-skip the density tasks involved with this cell. */ /* Un-skip the density tasks involved with this cell. */
...@@ -2743,6 +2791,7 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { ...@@ -2743,6 +2791,7 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
/* Activate hydro drift */ /* Activate hydro drift */
if (t->type == task_type_self) { if (t->type == task_type_self) {
if (ci_nodeID == nodeID) cell_activate_drift_part(ci, s); if (ci_nodeID == nodeID) cell_activate_drift_part(ci, s);
if (ci->nodeID == nodeID && with_limiter) cell_activate_limiter(ci, s);
} }
/* Set the correct sorting flags and activate hydro drifts */ /* Set the correct sorting flags and activate hydro drifts */
...@@ -2757,6 +2806,10 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { ...@@ -2757,6 +2806,10 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
if (ci_nodeID == nodeID) cell_activate_drift_part(ci, s); if (ci_nodeID == nodeID) cell_activate_drift_part(ci, s);
if (cj_nodeID == nodeID) cell_activate_drift_part(cj, s); if (cj_nodeID == nodeID) cell_activate_drift_part(cj, s);
/* Activate the limiter tasks. */
if (ci->nodeID == nodeID && with_limiter) cell_activate_limiter(ci, s);
if (cj->nodeID == nodeID && with_limiter) cell_activate_limiter(cj, s);
/* Check the sorts and activate them if needed. */ /* Check the sorts and activate them if needed. */
cell_activate_hydro_sorts(ci, t->flags, s); cell_activate_hydro_sorts(ci, t->flags, s);
cell_activate_hydro_sorts(cj, t->flags, s); cell_activate_hydro_sorts(cj, t->flags, s);
...@@ -2791,7 +2844,11 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { ...@@ -2791,7 +2844,11 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
} }
/* If the foreign cell is active, we want its ti_end values. */ /* If the foreign cell is active, we want its ti_end values. */
if (ci_active) scheduler_activate(s, ci->mpi.recv_ti); if (ci_active || with_limiter) scheduler_activate(s, ci->mpi.recv_ti);
if (with_limiter) scheduler_activate(s, ci->mpi.limiter.recv);
if (with_limiter)
scheduler_activate_send(s, cj->mpi.limiter.send, ci->nodeID);
/* Is the foreign cell active and will need stuff from us? */ /* Is the foreign cell active and will need stuff from us? */
if (ci_active) { if (ci_active) {
...@@ -2801,6 +2858,7 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { ...@@ -2801,6 +2858,7 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
/* Drift the cell which will be sent; note that not all sent /* Drift the cell which will be sent; note that not all sent
particles will be drifted, only those that are needed. */ particles will be drifted, only those that are needed. */
cell_activate_drift_part(cj, s); cell_activate_drift_part(cj, s);
if (with_limiter) cell_activate_limiter(cj, s);
/* If the local cell is also active, more stuff will be needed. */ /* If the local cell is also active, more stuff will be needed. */
if (cj_active) { if (cj_active) {
...@@ -2813,7 +2871,8 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { ...@@ -2813,7 +2871,8 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
} }
/* If the local cell is active, send its ti_end values. */ /* If the local cell is active, send its ti_end values. */
if (cj_active) scheduler_activate_send(s, cj->mpi.send_ti, ci_nodeID); if (cj_active || with_limiter)
scheduler_activate_send(s, cj->mpi.send_ti, ci_nodeID);
} else if (cj_nodeID != nodeID) { } else if (cj_nodeID != nodeID) {
...@@ -2830,7 +2889,11 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { ...@@ -2830,7 +2889,11 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
} }
/* If the foreign cell is active, we want its ti_end values. */ /* If the foreign cell is active, we want its ti_end values. */
if (cj_active) scheduler_activate(s, cj->mpi.recv_ti); if (cj_active || with_limiter) scheduler_activate(s, cj->mpi.recv_ti);
if (with_limiter) scheduler_activate(s, cj->mpi.limiter.recv);
if (with_limiter)
scheduler_activate_send(s, ci->mpi.limiter.send, cj->nodeID);
/* Is the foreign cell active and will need stuff from us? */ /* Is the foreign cell active and will need stuff from us? */
if (cj_active) { if (cj_active) {
...@@ -2840,6 +2903,7 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { ...@@ -2840,6 +2903,7 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
/* Drift the cell which will be sent; note that not all sent /* Drift the cell which will be sent; note that not all sent
particles will be drifted, only those that are needed. */ particles will be drifted, only those that are needed. */
cell_activate_drift_part(ci, s); cell_activate_drift_part(ci, s);
if (with_limiter) cell_activate_limiter(ci, s);
/* If the local cell is also active, more stuff will be needed. */ /* If the local cell is also active, more stuff will be needed. */
if (ci_active) { if (ci_active) {
...@@ -2853,7 +2917,8 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { ...@@ -2853,7 +2917,8 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
} }
/* If the local cell is active, send its ti_end values. */ /* If the local cell is active, send its ti_end values. */
if (ci_active) scheduler_activate_send(s, ci->mpi.send_ti, cj_nodeID); if (ci_active || with_limiter)
scheduler_activate_send(s, ci->mpi.send_ti, cj_nodeID);
} }
#endif #endif
} }
...@@ -2866,6 +2931,8 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { ...@@ -2866,6 +2931,8 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
scheduler_activate(s, l->t); scheduler_activate(s, l->t);
for (struct link *l = c->hydro.force; l != NULL; l = l->next) for (struct link *l = c->hydro.force; l != NULL; l = l->next)
scheduler_activate(s, l->t); scheduler_activate(s, l->t);
for (struct link *l = c->hydro.limiter; l != NULL; l = l->next)
scheduler_activate(s, l->t);
if (c->hydro.extra_ghost != NULL) if (c->hydro.extra_ghost != NULL)
scheduler_activate(s, c->hydro.extra_ghost); scheduler_activate(s, c->hydro.extra_ghost);
...@@ -2879,7 +2946,6 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { ...@@ -2879,7 +2946,6 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
if (c->hydro.cooling != NULL) scheduler_activate(s, c->hydro.cooling); if (c->hydro.cooling != NULL) scheduler_activate(s, c->hydro.cooling);
if (c->hydro.star_formation != NULL) if (c->hydro.star_formation != NULL)
scheduler_activate(s, c->hydro.star_formation); scheduler_activate(s, c->hydro.star_formation);
if (c->sourceterms != NULL) scheduler_activate(s, c->sourceterms);
if (c->logger != NULL) scheduler_activate(s, c->logger); if (c->logger != NULL) scheduler_activate(s, c->logger);
} }
......
...@@ -263,6 +263,9 @@ struct cell { ...@@ -263,6 +263,9 @@ struct cell {
/*! Linked list of the tasks computing this cell's hydro forces. */ /*! Linked list of the tasks computing this cell's hydro forces. */
struct link *force; struct link *force;
/*! Linked list of the tasks computing this cell's limiter. */
struct link *limiter;
/*! Dependency implicit task for the ghost (in->ghost->out)*/ /*! Dependency implicit task for the ghost (in->ghost->out)*/
struct task *ghost_in; struct task *ghost_in;
...@@ -348,6 +351,12 @@ struct cell { ...@@ -348,6 +351,12 @@ struct cell {
/*! Do any of this cell's sub-cells need to be sorted? */ /*! Do any of this cell's sub-cells need to be sorted? */
char do_sub_sort; char do_sub_sort;
/*! Does this cell need to be limited? */
char do_limiter;
/*! Do any of this cell's sub-cells need to be limited? */
char do_sub_limiter;
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
/*! Last (integer) time the cell's sort arrays were updated. */ /*! Last (integer) time the cell's sort arrays were updated. */
...@@ -570,6 +579,15 @@ struct cell { ...@@ -570,6 +579,15 @@ struct cell {
struct link *send; struct link *send;
} grav; } grav;
struct {
/* Task receiving gpart data. */
struct task *recv;
/* Linked list for sending gpart data. */
struct link *send;
} limiter;
/* Task receiving data (time-step). */ /* Task receiving data (time-step). */
struct task *recv_ti; struct task *recv_ti;
...@@ -603,8 +621,8 @@ struct cell { ...@@ -603,8 +621,8 @@ struct cell {
/*! The task to compute time-steps */ /*! The task to compute time-steps */
struct task *timestep; struct task *timestep;
/*! Task for source terms */ /*! The task to limit the time-step of inactive particles */
struct task *sourceterms; struct task *timestep_limiter;
/*! The logger task */ /*! The logger task */
struct task *logger; struct task *logger;
...@@ -705,7 +723,9 @@ void cell_activate_drift_gpart(struct cell *c, struct scheduler *s); ...@@ -705,7 +723,9 @@ void cell_activate_drift_gpart(struct cell *c, struct scheduler *s);
void cell_activate_drift_spart(struct cell *c, struct scheduler *s); void cell_activate_drift_spart(struct cell *c, struct scheduler *s);
void cell_activate_hydro_sorts(struct cell *c, int sid, struct scheduler *s); void cell_activate_hydro_sorts(struct cell *c, int sid, struct scheduler *s);
void cell_activate_stars_sorts(struct cell *c, int sid, struct scheduler *s); void cell_activate_stars_sorts(struct cell *c, int sid, struct scheduler *s);
void cell_activate_limiter(struct cell *c, struct scheduler *s);
void cell_clear_drift_flags(struct cell *c, void *data); void cell_clear_drift_flags(struct cell *c, void *data);
void cell_clear_limiter_flags(struct cell *c, void *data);
void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data); void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data);
void cell_check_spart_pos(const struct cell *c, void cell_check_spart_pos(const struct cell *c,
const struct spart *global_sparts); const struct spart *global_sparts);
......
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
/* Time integration constants. */ /* Time integration constants. */
#define const_max_u_change 0.1f #define const_max_u_change 0.1f
/* Time-step limiter maximal difference in signal velocity */
#define const_limiter_max_v_sig_ratio 4.1f
/* Type of gradients to use (GIZMO_SPH only) */ /* Type of gradients to use (GIZMO_SPH only) */
/* If no option is chosen, no gradients are used (first order scheme) */ /* If no option is chosen, no gradients are used (first order scheme) */
//#define GRADIENTS_SPH //#define GRADIENTS_SPH
......
...@@ -113,7 +113,8 @@ const char *engine_policy_names[] = {"none", ...@@ -113,7 +113,8 @@ const char *engine_policy_names[] = {"none",
"stars", "stars",
"structure finding", "structure finding",
"star formation", "star formation",
"feedback"}; "feedback",
"time-step limiter"};
/** The rank of the engine as a global variable (for messages). */ /** The rank of the engine as a global variable (for messages). */
int engine_rank; int engine_rank;
...@@ -1907,6 +1908,10 @@ int engine_estimate_nr_tasks(struct engine *e) { ...@@ -1907,6 +1908,10 @@ int engine_estimate_nr_tasks(struct engine *e) {
#endif #endif
#endif #endif
} }
if (e->policy & engine_policy_limiter) {
n1 += 18;
n2 += 1;
}
if (e->policy & engine_policy_self_gravity) { if (e->policy & engine_policy_self_gravity) {
n1 += 125; n1 += 125;
n2 += 8; n2 += 8;
...@@ -2585,8 +2590,11 @@ void engine_skip_force_and_kick(struct engine *e) { ...@@ -2585,8 +2590,11 @@ void engine_skip_force_and_kick(struct engine *e) {
/* Skip everything that updates the particles */ /* Skip everything that updates the particles */
if (t->type == task_type_drift_part || t->type == task_type_drift_gpart || if (t->type == task_type_drift_part || t->type == task_type_drift_gpart ||
t->type == task_type_kick1 || t->type == task_type_kick2 || t->type == task_type_kick1 || t->type == task_type_kick2 ||
t->type == task_type_timestep || t->subtype == task_subtype_force || t->type == task_type_timestep ||
t->subtype == task_subtype_grav || t->type == task_type_end_force || t->type == task_type_timestep_limiter ||
t->subtype == task_subtype_force ||
t->subtype == task_subtype_limiter || t->subtype == task_subtype_grav ||
t->type == task_type_end_force ||
t->type == task_type_grav_long_range || t->type == task_type_grav_mm || t->type == task_type_grav_long_range || t->type == task_type_grav_mm ||
t->type == task_type_grav_down || t->type == task_type_cooling) t->type == task_type_grav_down || t->type == task_type_cooling)
t->skip = 1; t->skip = 1;
...@@ -2594,6 +2602,7 @@ void engine_skip_force_and_kick(struct engine *e) { ...@@ -2594,6 +2602,7 @@ void engine_skip_force_and_kick(struct engine *e) {
/* Run through the cells and clear some flags. */ /* Run through the cells and clear some flags. */
space_map_cells_pre(e->s, 1, cell_clear_drift_flags, NULL); space_map_cells_pre(e->s, 1, cell_clear_drift_flags, NULL);
space_map_cells_pre(e->s, 1, cell_clear_limiter_flags, NULL);
} }
/** /**
...@@ -2803,6 +2812,11 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs, ...@@ -2803,6 +2812,11 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs,
gravity_exact_force_check(e->s, e, 1e-1); gravity_exact_force_check(e->s, e, 1e-1);
#endif #endif
#ifdef SWIFT_DEBUG_CHECKS
/* Make sure all woken-up particles have been processed */
space_check_limiter(e->s);
#endif
/* Recover the (integer) end of the next time-step */ /* Recover the (integer) end of the next time-step */
engine_collect_end_of_step(e, 1); engine_collect_end_of_step(e, 1);
...@@ -3060,6 +3074,11 @@ void engine_step(struct engine *e) { ...@@ -3060,6 +3074,11 @@ void engine_step(struct engine *e) {
gravity_exact_force_check(e->s, e, 1e-1); gravity_exact_force_check(e->s, e, 1e-1);
#endif #endif
#ifdef SWIFT_DEBUG_CHECKS
/* Make sure all woken-up particles have been processed */
space_check_limiter(e->s);
#endif
/* Collect information about the next time-step */ /* Collect information about the next time-step */
engine_collect_end_of_step(e, 1); engine_collect_end_of_step(e, 1);
e->forcerebuild = e->collect_group1.forcerebuild; e->forcerebuild = e->collect_group1.forcerebuild;
......
...@@ -74,9 +74,10 @@ enum engine_policy { ...@@ -74,9 +74,10 @@ enum engine_policy {
engine_policy_stars = (1 << 15), engine_policy_stars = (1 << 15),
engine_policy_structure_finding = (1 << 16), engine_policy_structure_finding = (1 << 16),
engine_policy_star_formation = (1 << 17), engine_policy_star_formation = (1 << 17),