12#include "gadgetconfig.h"
20#include "../cooling_sfr/cooling.h"
21#include "../data/allvars.h"
22#include "../data/dtypes.h"
23#include "../data/intposconvert.h"
24#include "../data/mymalloc.h"
25#include "../data/simparticles.h"
26#include "../logs/logs.h"
27#include "../logs/timer.h"
28#include "../main/simulation.h"
29#include "../system/system.h"
30#include "../time_integration/driftfac.h"
31#include "../time_integration/timestep.h"
41#ifndef FORCE_EQUAL_TIMESTEPS
62 if(
P[target].getType() != 0)
74 if(bin >
P[target].TimeBinGrav)
85#ifdef FORCE_EQUAL_TIMESTEPS
96#if defined(PMGRID) && !defined(TREEPM_NOTIMESPLIT)
97 globTimeStep =
Sp.get_timestep_pm();
100#if defined(SELFGRAVITY) || defined(EXTERNALGRAVITY)
106 if(ti_step < globTimeStep)
107 globTimeStep = ti_step;
118 if(ti_step < globTimeStep)
119 globTimeStep = ti_step;
122#ifdef ENLARGE_DYNAMIC_RANGE_IN_TIME
125 MPI_Allreduce(&globTimeStep, &
All.GlobalTimeStep, 1, MPI_INT, MPI_MIN,
Communicator);
164 if(ti_step < ti_step_bin)
183#if defined(PMGRID) && !defined(TREEPM_NOTIMESPLIT)
189 double ac =
sqrt(ax * ax + ay * ay + az * az);
211#if defined(SELFGRAVITY) && defined(PMGRID) && !defined(TREEPM_NOTIMESPLIT)
212 if(dt >=
All.DtDisplacement)
213 dt =
All.DtDisplacement;
219#ifndef NO_STOP_BELOW_MINTIMESTEP
221 "Timestep wants to be below the limit MinSizeTimestep=%g\n"
222 "Part-ID=%lld task=%d type=%d dtgrav=%g ac=%g soft=%g\n",
230 if(!(ti_step > 0 && ti_step <
TIMEBASE))
236 "\nError: A timestep of size zero was assigned on the integer timeline!\n"
238 "Task=%d Part-ID=%lld type=%d dt_grav=%g dt=%g tibase=%g ac=%g xyz=(%g|%g|%g) vel=(%g|%g|%g) tree=(%g|%g|%g) mass=%g\n\n",
239 ThisTask, (
long long)
P[p].ID.get(),
P[p].
getType(), dt_grav, dt,
All.
Timebase_interval, ac, pos[0], pos[1], pos[2],
243 Terminate(
"integer timestep reached zero");
249#if defined(PMGRID) && !defined(TREEPM_NOTIMESPLIT)
256 if(ti_step > (
All.PM_Ti_endstep -
All.PM_Ti_begstep))
276 if(
P[p].getType() != 0)
287#if defined(PMGRID) && !defined(TREEPM_NOTIMESPLIT)
293 double ac =
sqrt(ax * ax + ay * ay + az * az);
316 if(dt > dt_treebased)
322 if(
P[p].getType() == 0)
342#if defined(PMGRID) && !defined(TREEPM_NOTIMESPLIT)
343 if(dt >=
All.DtDisplacement)
344 dt =
All.DtDisplacement;
349 if(
P[p].getType() == 0)
351 "Timestep wants to be below the limit MinSizeTimestep=%g\n"
352 "Part-ID=%lld task=%d dtkin=%g dtcourant=%g ac=%g\n",
359 if(!(ti_step > 0 && ti_step <
TIMEBASE))
365 "\nError: A timestep of size zero was assigned on the integer timeline!\n"
367 "Task=%d Part-ID=%lld type=%d dt=%g dtc=%g dt_kin=%g dt_treebased=%g dt_hsml=%g tibase=%g ti_step=%d ac=%g xyz=(%g|%g|%g) "
369 "tree=(%g|%g|%g) mass=%g All.cf_hubble_a=%g\n\n",
371 (
int)ti_step, ac, pos[0], pos[1], pos[2],
P[p].
Vel[0],
P[p].
Vel[1],
P[p].
Vel[2],
P[p].
GravAccel[0],
P[p].
GravAccel[1],
378#if defined(PMGRID) && defined(PERIODIC) && !defined(TREEPM_NOTIMESPLIT)
379void simparticles::find_long_range_step_constraint(
void)
383 for(
int p = 0; p <
NumPart; p++)
385 if(
P[p].getType() == 0)
393 double ac =
sqrt(ax * ax + ay * ay + az * az);
411 MPI_Allreduce(&dtmin, &
All.DtDisplacement, 1, MPI_DOUBLE, MPI_MIN,
Communicator);
428 Terminate(
"time-step of integer size 1 not allowed\n");
453 strncpy(
Name, name, 99);
460 char Identifier[200];
463 snprintf(Identifier, 199,
"NextActiveParticle%s",
Name);
466 snprintf(Identifier, 199,
"NextInTimeBin%s",
Name);
469 snprintf(Identifier, 199,
"PrevInTimeBin%s",
Name);
498 while(ti_min > ti_step)
509 Terminate(
"time-step of integer size 1 not allowed\n");
533 Terminate(
"we are beyond the end of the timeline");
541 if(timeBin_old == timeBin_new)
630 if(addToListOfActiveParticles)
645 if(
P[i].ID.get() == 0 &&
P[i].
getMass() == 0)
667 for(
int tbin = timebin; tbin >= 0; tbin--)
global_data_all_processes All
void intpos_to_pos(MyIntPosType *intpos, T *posdiff)
void mpi_printf(const char *fmt,...)
void find_hydro_timesteps(void)
void find_global_timesteps(void)
int get_timestep_bin(integertime ti_step)
void timebin_cleanup_list_of_active_particles(void)
integertime get_timestep_grav(int p)
void assign_hydro_timesteps(void)
integertime get_timestep_hydro(int p)
int test_if_grav_timestep_is_too_large(int p, int bin)
TimeBinData TimeBinsGravity
void timebins_get_bin_and_do_validity_checks(integertime ti_step, int *bin_new, int bin_old)
TimeBinData TimeBinsHydro
int TimeBinSynchronized[TIMEBINS]
void tree_based_timesteps(void)
#define MAX_DOUBLE_NUMBER
#define TIMER_START(counter)
Starts the timer counter.
#define TIMER_STOP(counter)
Stops the timer counter.
void minimum_large_ints(int n, long long *src, long long *res, MPI_Comm comm)
void timebins_reallocate(void)
void timebins_init(const char *name, int *MaxPart)
void timebin_remove_particle(int idx, int bin)
void timebin_make_list_of_active_particles_up_to_timebin(int timebin)
int TimeBinCount[TIMEBINS]
void timebin_add_particles_of_timebin_to_list_of_active_particles(int timebin)
int FirstInTimeBin[TIMEBINS]
void timebins_allocate(void)
void timebin_move_particle(int p, int timeBin_old, int timeBin_new)
int LastInTimeBin[TIMEBINS]
void timebin_add_particle(int i_new, int i_old, int timeBin, int addToListOfActiveParticles)
double ForceSoftening[NSOFTCLASSES+NSOFTCLASSES_HYDRO+2]
void set_cosmo_factors_for_current_time(void)
double SofteningTable[NSOFTCLASSES+NSOFTCLASSES_HYDRO]
unsigned char getSofteningClass(void)
unsigned char getTimeBinHydro(void)
unsigned char getType(void)
void setTimeBinHydro(unsigned char bin)
vector< MyFloat > GravAccel
void myflush(FILE *fstream)