GADGET-4
timestep.cc
Go to the documentation of this file.
1/*******************************************************************************
2 * \copyright This file is part of the GADGET4 N-body/SPH code developed
3 * \copyright by Volker Springel. Copyright (C) 2014-2020 by Volker Springel
4 * \copyright (vspringel@mpa-garching.mpg.de) and all contributing authors.
5 *******************************************************************************/
6
12#include "gadgetconfig.h"
13
14#include <math.h>
15#include <mpi.h>
16#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19
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"
32
40{
41#ifndef FORCE_EQUAL_TIMESTEPS
42
44
46
47 TIMER_START(CPU_TIMELINE);
48
50
51 TIMER_STOP(CPU_TIMELINE);
52
53#endif
54}
55
57{
58 /* Now assign new timesteps for the hydro particles that are synchronized */
59 for(int i = 0; i < TimeBinsHydro.NActiveParticles; i++)
60 {
61 int target = TimeBinsHydro.ActiveParticleList[i];
62 if(P[target].getType() != 0)
63 continue;
64
65 if(TimeBinSynchronized[P[target].getTimeBinHydro()])
66 {
67 integertime ti_step = get_timestep_hydro(target);
68
69 int bin;
70 timebins_get_bin_and_do_validity_checks(ti_step, &bin, P[target].getTimeBinHydro());
71
72#ifdef SELFGRAVITY
73 /* we enforce that the hydro timestep is nested inside the gravity step */
74 if(bin > P[target].TimeBinGrav)
75 bin = P[target].TimeBinGrav;
76#endif
77
78 TimeBinsHydro.timebin_move_particle(target, P[target].getTimeBinHydro(), bin);
79
80 P[target].setTimeBinHydro(bin);
81 }
82 }
83}
84
85#ifdef FORCE_EQUAL_TIMESTEPS
87{
89
91
92 TIMER_START(CPU_TIMELINE);
93
94 integertime globTimeStep = TIMEBASE;
95
96#if defined(PMGRID) && !defined(TREEPM_NOTIMESPLIT)
97 globTimeStep = Sp.get_timestep_pm();
98#endif
99
100#if defined(SELFGRAVITY) || defined(EXTERNALGRAVITY)
101 for(int idx = 0; idx < Sp.TimeBinsGravity.NActiveParticles; idx++)
102 {
104
105 integertime ti_step = Sp.get_timestep_grav(i);
106 if(ti_step < globTimeStep)
107 globTimeStep = ti_step;
108 }
109#endif
110
111 for(int idx = 0; idx < Sp.TimeBinsHydro.NActiveParticles; idx++)
112 {
114 if(Sp.P[i].getType() != 0)
115 continue;
116
117 integertime ti_step = Sp.get_timestep_hydro(i);
118 if(ti_step < globTimeStep)
119 globTimeStep = ti_step;
120 }
121
122#ifdef ENLARGE_DYNAMIC_RANGE_IN_TIME
123 minimum_large_ints(1, &globTimeStep, &All.GlobalTimeStep, Communicator);
124#else
125 MPI_Allreduce(&globTimeStep, &All.GlobalTimeStep, 1, MPI_INT, MPI_MIN, Communicator);
126#endif
127
128 for(int idx = 0; idx < Sp.TimeBinsGravity.NActiveParticles; idx++)
129 {
130 int target = Sp.TimeBinsGravity.ActiveParticleList[idx];
131
132 int bin;
133
134 Sp.timebins_get_bin_and_do_validity_checks(All.GlobalTimeStep, &bin, Sp.P[target].TimeBinGrav);
136 Sp.P[target].TimeBinGrav = bin;
137 }
138
139 for(int idx = 0; idx < Sp.TimeBinsHydro.NActiveParticles; idx++)
140 {
141 int target = Sp.TimeBinsHydro.ActiveParticleList[idx];
142 if(Sp.P[target].getType() != 0)
143 continue;
144
145 int bin;
146
147 Sp.timebins_get_bin_and_do_validity_checks(All.GlobalTimeStep, &bin, Sp.P[target].getTimeBinHydro());
149#ifndef LEAN
150 Sp.P[target].TimeBinHydro = bin;
151#endif
152 }
153
154 TIMER_STOP(CPU_TIMELINE);
155}
156#endif
157
159{
160 integertime ti_step_bin = bin ? (((integertime)1) << bin) : 0;
161
162 integertime ti_step = get_timestep_grav(p);
163
164 if(ti_step < ti_step_bin)
165 return 1;
166 else
167 return 0;
168}
169
178{
179 double ax = All.cf_a2inv * P[p].GravAccel[0];
180 double ay = All.cf_a2inv * P[p].GravAccel[1];
181 double az = All.cf_a2inv * P[p].GravAccel[2];
182
183#if defined(PMGRID) && !defined(TREEPM_NOTIMESPLIT)
184 ax += All.cf_a2inv * P[p].GravPM[0];
185 ay += All.cf_a2inv * P[p].GravPM[1];
186 az += All.cf_a2inv * P[p].GravPM[2];
187#endif
188
189 double ac = sqrt(ax * ax + ay * ay + az * az); /* this is now the physical acceleration */
190
191 if(ac == 0)
192 ac = MIN_FLOAT_NUMBER;
193
194 /* determine the "kinematic" timestep dt_grav, in physical units */
195#if NSOFTCLASSES > 1
196 double dt_grav = sqrt(2 * All.ErrTolIntAccuracy * All.cf_atime * All.SofteningTable[P[p].getSofteningClass()] / ac);
197#else
198 double dt_grav = sqrt(2 * All.ErrTolIntAccuracy * All.cf_atime * All.SofteningTable[0] / ac);
199#endif
200
201 double dt = dt_grav;
202
203 /* convert the physical timestep to dloga if needed. Note: If comoving integration has not been selected,
204 All.cf_hubble_a=1.
205 */
206 dt *= All.cf_hubble_a;
207
208 if(dt >= All.MaxSizeTimestep)
209 dt = All.MaxSizeTimestep;
210
211#if defined(SELFGRAVITY) && defined(PMGRID) && !defined(TREEPM_NOTIMESPLIT)
212 if(dt >= All.DtDisplacement)
213 dt = All.DtDisplacement;
214#endif
215
216 if(dt < All.MinSizeTimestep)
217 {
218 dt = All.MinSizeTimestep;
219#ifndef NO_STOP_BELOW_MINTIMESTEP
220 Terminate(
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",
223 All.MinSizeTimestep, (long long)P[p].ID.get(), ThisTask, P[p].getType(), dt, ac,
225#endif
226 }
227
229
230 if(!(ti_step > 0 && ti_step < TIMEBASE))
231 {
232 double pos[3];
233 intpos_to_pos(P[p].IntPos, pos); /* converts the integer coordinates to floating point */
234
235 Terminate(
236 "\nError: A timestep of size zero was assigned on the integer timeline!\n"
237 "We better stop.\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],
240 P[p].Vel[0], P[p].Vel[1], P[p].Vel[2], P[p].GravAccel[0], P[p].GravAccel[1], P[p].GravAccel[2], P[p].getMass());
241
242 myflush(stdout);
243 Terminate("integer timestep reached zero");
244 }
245
246 return ti_step;
247}
248
249#if defined(PMGRID) && !defined(TREEPM_NOTIMESPLIT)
250integertime simparticles::get_timestep_pm(void)
251{
252 integertime ti_step = TIMEBASE;
253 while(ti_step > (All.DtDisplacement / All.Timebase_interval))
254 ti_step >>= 1;
255
256 if(ti_step > (All.PM_Ti_endstep - All.PM_Ti_begstep)) /* PM-timestep wants to increase */
257 {
258 int bin = get_timestep_bin(ti_step);
259 int binold = get_timestep_bin(All.PM_Ti_endstep - All.PM_Ti_begstep);
260
261 while(TimeBinSynchronized[bin] == 0 && bin > binold) /* make sure the new step is synchronized */
262 bin--;
263
264 ti_step = bin ? (((integertime)1) << bin) : 0;
265 }
266
267 if(All.Ti_Current == TIMEBASE) /* we here finish the last timestep. */
268 ti_step = 0;
269
270 return ti_step;
271}
272#endif
273
275{
276 if(P[p].getType() != 0)
277 Terminate("P[p].getType() != 0");
278
279 double ax = All.cf_afac2 * SphP[p].HydroAccel[0];
280 double ay = All.cf_afac2 * SphP[p].HydroAccel[1];
281 double az = All.cf_afac2 * SphP[p].HydroAccel[2];
282
283 ax += All.cf_a2inv * P[p].GravAccel[0];
284 ay += All.cf_a2inv * P[p].GravAccel[1];
285 az += All.cf_a2inv * P[p].GravAccel[2];
286
287#if defined(PMGRID) && !defined(TREEPM_NOTIMESPLIT)
288 ax += All.cf_a2inv * P[p].GravPM[0];
289 ay += All.cf_a2inv * P[p].GravPM[1];
290 az += All.cf_a2inv * P[p].GravPM[2];
291#endif
292
293 double ac = sqrt(ax * ax + ay * ay + az * az); /* this is now the physical acceleration */
294
295 if(ac == 0)
296 ac = MIN_FLOAT_NUMBER;
297
298 /* determine the "kinematic" timestep dt_grav, in physical units */
299 double dt_kin = sqrt(2 * All.ErrTolIntAccuracy * All.cf_atime * SphP[p].Hsml / ac);
300
301 /* calculate local Courant timestep and treebased maximum timestep in physical units */
302
303 double dt_courant = (All.cf_atime / All.cf_afac3) * All.CourantFac * 2.0 * SphP[p].Hsml / (SphP[p].MaxSignalVel + MIN_FLOAT_NUMBER);
304
305 double dt_treebased = (All.cf_atime / All.cf_afac3) * SphP[p].CurrentMaxTiStep;
306
307 /* calculate a timestep that restricts the rate at which the smoothing length may change,
308 * in physical units
309 */
310 double dt_hsml = All.cf_atime2 * All.CourantFac * fabs(SphP[p].Hsml / (SphP[p].DtHsml + MIN_FLOAT_NUMBER));
311
312 /* now take the smallest of these four criteria */
313 double dt = dt_kin;
314 if(dt > dt_courant)
315 dt = dt_courant;
316 if(dt > dt_treebased)
317 dt = dt_treebased;
318 if(dt > dt_hsml)
319 dt = dt_hsml;
320
321#ifdef STARFORMATION
322 if(P[p].getType() == 0) /* to protect using a particle that has been turned into a star */
323 {
324 if(SphP[p].Sfr > 0)
325 {
326 double dt_sfr =
327 0.1 * P[p].getMass() / (SphP[p].Sfr / ((All.UnitMass_in_g / SOLAR_MASS) / (All.UnitTime_in_s / SEC_PER_YEAR)));
328 if(dt_sfr < dt)
329 dt = dt_sfr;
330 }
331 }
332#endif
333
334 /* convert the physical timestep to dloga in the cosmological case.
335 * Note: If comoving integration has not been selected, All.cf_hubble_a = 1.0.
336 */
337 dt *= All.cf_hubble_a;
338
339 if(dt >= All.MaxSizeTimestep)
340 dt = All.MaxSizeTimestep;
341
342#if defined(PMGRID) && !defined(TREEPM_NOTIMESPLIT)
343 if(dt >= All.DtDisplacement)
344 dt = All.DtDisplacement;
345#endif
346
347 if(dt < All.MinSizeTimestep)
348 {
349 if(P[p].getType() == 0)
350 Terminate(
351 "Timestep wants to be below the limit MinSizeTimestep=%g\n"
352 "Part-ID=%lld task=%d dtkin=%g dtcourant=%g ac=%g\n",
353 All.MinSizeTimestep, (long long)P[p].ID.get(), ThisTask, dt_kin * All.cf_hubble_a, dt_courant * All.cf_hubble_a, ac);
354 dt = All.MinSizeTimestep;
355 }
356
358
359 if(!(ti_step > 0 && ti_step < TIMEBASE))
360 {
361 double pos[3];
362 intpos_to_pos(P[p].IntPos, pos); /* converts the integer coordinates to floating point */
363
364 Terminate(
365 "\nError: A timestep of size zero was assigned on the integer timeline!\n"
366 "We better stop.\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) "
368 "vel=(%g|%g|%g) "
369 "tree=(%g|%g|%g) mass=%g All.cf_hubble_a=%g\n\n",
370 ThisTask, (long long)P[p].ID.get(), P[p].getType(), dt, dt_courant, dt_kin, dt_treebased, dt_hsml, All.Timebase_interval,
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],
372 P[p].GravAccel[2], P[p].getMass(), All.cf_hubble_a);
373 }
374
375 return ti_step;
376}
377
378#if defined(PMGRID) && defined(PERIODIC) && !defined(TREEPM_NOTIMESPLIT)
379void simparticles::find_long_range_step_constraint(void)
380{
381 double dtmin = MAX_DOUBLE_NUMBER;
382
383 for(int p = 0; p < NumPart; p++)
384 {
385 if(P[p].getType() == 0)
386 continue;
387
388 /* calculate acceleration */
389 double ax = All.cf_a2inv * P[p].GravPM[0];
390 double ay = All.cf_a2inv * P[p].GravPM[1];
391 double az = All.cf_a2inv * P[p].GravPM[2];
392
393 double ac = sqrt(ax * ax + ay * ay + az * az); /* this is now the physical acceleration */
394
395 if(ac < 1.0e-30)
396 ac = 1.0e-30;
397
398#if NSOFTCLASSES > 1
399 double dt = sqrt(2 * All.ErrTolIntAccuracy * All.cf_atime * All.ForceSoftening[P[p].getSofteningClass()] / 2.8 / ac);
400#else
401 double dt = sqrt(2 * All.ErrTolIntAccuracy * All.cf_atime * All.ForceSoftening[0] / 2.8 / ac);
402#endif
403 dt *= All.cf_hubble_a;
404
405 if(dt < dtmin)
406 dtmin = dt;
407 }
408
409 dtmin *= 2.0; /* move it one timebin higher to prevent being too conservative */
410
411 MPI_Allreduce(&dtmin, &All.DtDisplacement, 1, MPI_DOUBLE, MPI_MIN, Communicator);
412
413 mpi_printf("TIMESTEPS: displacement time constraint: %g (%g)\n", All.DtDisplacement, All.MaxSizeTimestep);
414
415 if(All.DtDisplacement > All.MaxSizeTimestep)
416 All.DtDisplacement = All.MaxSizeTimestep;
417}
418#endif
419
421{
422 int bin = -1;
423
424 if(ti_step == 0)
425 return 0;
426
427 if(ti_step == 1)
428 Terminate("time-step of integer size 1 not allowed\n");
429
430 while(ti_step)
431 {
432 bin++;
433 ti_step >>= 1;
434 }
435
436 return bin;
437}
438
439void TimeBinData::timebins_init(const char *name, int *maxPart)
440{
443
444 for(int i = 0; i < TIMEBINS; i++)
445 {
446 FirstInTimeBin[i] = -1;
447 LastInTimeBin[i] = -1;
448 }
449
450 NextInTimeBin = 0;
451 PrevInTimeBin = 0;
452
453 strncpy(Name, name, 99);
454 Name[99] = 0;
455 MaxPart = maxPart;
456}
457
459{
460 char Identifier[200];
461 Identifier[199] = 0;
462
463 snprintf(Identifier, 199, "NextActiveParticle%s", Name);
464 ActiveParticleList = (int *)Mem.mymalloc_movable(&ActiveParticleList, Identifier, *(MaxPart) * sizeof(int));
465
466 snprintf(Identifier, 199, "NextInTimeBin%s", Name);
467 NextInTimeBin = (int *)Mem.mymalloc_movable(&NextInTimeBin, Identifier, *(MaxPart) * sizeof(int));
468
469 snprintf(Identifier, 199, "PrevInTimeBin%s", Name);
470 PrevInTimeBin = (int *)Mem.mymalloc_movable(&PrevInTimeBin, Identifier, *(MaxPart) * sizeof(int));
471}
472
474{
475 Mem.myfree_movable(PrevInTimeBin);
476 Mem.myfree_movable(NextInTimeBin);
477 Mem.myfree_movable(ActiveParticleList);
478
479 PrevInTimeBin = NULL;
480 NextInTimeBin = NULL;
481 ActiveParticleList = NULL;
482}
483
485{
486 if(ActiveParticleList != NULL)
487 {
488 ActiveParticleList = (int *)Mem.myrealloc_movable(ActiveParticleList, *(MaxPart) * sizeof(int));
489 NextInTimeBin = (int *)Mem.myrealloc_movable(NextInTimeBin, *(MaxPart) * sizeof(int));
490 PrevInTimeBin = (int *)Mem.myrealloc_movable(PrevInTimeBin, *(MaxPart) * sizeof(int));
491 }
492}
493
495{
496 /* make it a power 2 subdivision */
497 integertime ti_min = TIMEBASE;
498 while(ti_min > ti_step)
499 ti_min >>= 1;
500 ti_step = ti_min;
501
502 /* get timestep bin */
503 int bin = -1;
504
505 if(ti_step == 0)
506 bin = 0;
507
508 if(ti_step == 1)
509 Terminate("time-step of integer size 1 not allowed\n");
510
511 while(ti_step)
512 {
513 bin++;
514 ti_step >>= 1;
515 }
516
517 if(bin > bin_old) /* timestep wants to increase */
518 {
519 while(TimeBinSynchronized[bin] == 0 && bin > bin_old) /* make sure the new step is synchronized */
520 bin--;
521
522 ti_step = bin ? (((integertime)1) << bin) : 0;
523 }
524
525 if(All.Ti_Current >= TIMEBASE) /* we here finish the last timestep. */
526 {
527 ti_step = 0;
528 bin = 0;
529 }
530
531 if((TIMEBASE - All.Ti_Current) < ti_step) /* check that we don't run beyond the end */
532 {
533 Terminate("we are beyond the end of the timeline"); /* should not happen */
534 }
535
536 *bin_new = bin;
537}
538
539void TimeBinData::timebin_move_particle(int p, int timeBin_old, int timeBin_new)
540{
541 if(timeBin_old == timeBin_new)
542 return;
543
544 TimeBinCount[timeBin_old]--;
545
546 int prev = PrevInTimeBin[p];
547 int next = NextInTimeBin[p];
548
549 if(FirstInTimeBin[timeBin_old] == p)
550 FirstInTimeBin[timeBin_old] = next;
551 if(LastInTimeBin[timeBin_old] == p)
552 LastInTimeBin[timeBin_old] = prev;
553 if(prev >= 0)
554 NextInTimeBin[prev] = next;
555 if(next >= 0)
556 PrevInTimeBin[next] = prev;
557
558 if(TimeBinCount[timeBin_new] > 0)
559 {
560 PrevInTimeBin[p] = LastInTimeBin[timeBin_new];
561 NextInTimeBin[LastInTimeBin[timeBin_new]] = p;
562 NextInTimeBin[p] = -1;
563 LastInTimeBin[timeBin_new] = p;
564 }
565 else
566 {
567 FirstInTimeBin[timeBin_new] = LastInTimeBin[timeBin_new] = p;
568 PrevInTimeBin[p] = NextInTimeBin[p] = -1;
569 }
570
571 TimeBinCount[timeBin_new]++;
572}
573
575{
576 int p = ActiveParticleList[idx];
577 ActiveParticleList[idx] = -1;
578
579 TimeBinCount[bin]--;
580
581 if(p >= 0)
582 {
583 int prev = PrevInTimeBin[p];
584 int next = NextInTimeBin[p];
585
586 if(prev >= 0)
587 NextInTimeBin[prev] = next;
588 if(next >= 0)
589 PrevInTimeBin[next] = prev;
590
591 if(FirstInTimeBin[bin] == p)
592 FirstInTimeBin[bin] = next;
593 if(LastInTimeBin[bin] == p)
594 LastInTimeBin[bin] = prev;
595 }
596}
597
598/* insert a particle into the timebin struct behind another already existing particle */
599void TimeBinData::timebin_add_particle(int i_new, int i_old, int timeBin, int addToListOfActiveParticles)
600{
601 TimeBinCount[timeBin]++;
602
603 if(i_old < 0)
604 {
605 /* if we don't have an existing particle to add if after, let's take the last one in this timebin */
606 i_old = LastInTimeBin[timeBin];
607
608 if(i_old < 0)
609 {
610 /* the timebin is empty at the moment, so just add the new particle */
611 FirstInTimeBin[timeBin] = i_new;
612 LastInTimeBin[timeBin] = i_new;
613 NextInTimeBin[i_new] = -1;
614 PrevInTimeBin[i_new] = -1;
615 }
616 }
617
618 if(i_old >= 0)
619 {
620 /* otherwise we added it already */
621 PrevInTimeBin[i_new] = i_old;
622 NextInTimeBin[i_new] = NextInTimeBin[i_old];
623 if(NextInTimeBin[i_old] >= 0)
624 PrevInTimeBin[NextInTimeBin[i_old]] = i_new;
625 NextInTimeBin[i_old] = i_new;
626 if(LastInTimeBin[timeBin] == i_old)
627 LastInTimeBin[timeBin] = i_new;
628 }
629
630 if(addToListOfActiveParticles)
631 {
634 }
635}
636
638{
639 for(int idx = 0; idx < TimeBinsGravity.NActiveParticles; idx++)
640 {
642 if(i < 0)
643 continue;
644
645 if(P[i].ID.get() == 0 && P[i].getMass() == 0)
646 {
647 TimeBinsGravity.timebin_remove_particle(idx, P[i].TimeBinGrav);
648 }
649 }
650
651 for(int idx = 0; idx < TimeBinsHydro.NActiveParticles; idx++)
652 {
654 if(i < 0)
655 continue;
656
657 if(P[i].ID.get() == 0 && P[i].getMass() == 0 && P[i].getType() == 0)
658 {
659 TimeBinsHydro.timebin_remove_particle(idx, P[i].getTimeBinHydro());
660 }
661 }
662}
663
665{
667 for(int tbin = timebin; tbin >= 0; tbin--)
669}
670
672{
673 for(int i = FirstInTimeBin[timebin]; i >= 0; i = NextInTimeBin[i])
674 {
677 }
678}
global_data_all_processes All
Definition: main.cc:40
MyIDType get(void) const
Definition: idstorage.h:87
void intpos_to_pos(MyIntPosType *intpos, T *posdiff)
void mpi_printf(const char *fmt,...)
Definition: setcomm.h:55
int ThisTask
Definition: setcomm.h:33
MPI_Comm Communicator
Definition: setcomm.h:31
void find_hydro_timesteps(void)
Definition: timestep.cc:39
sph NgbTree
Definition: simulation.h:68
void find_global_timesteps(void)
simparticles Sp
Definition: simulation.h:56
int get_timestep_bin(integertime ti_step)
Definition: timestep.cc:420
void timebin_cleanup_list_of_active_particles(void)
Definition: timestep.cc:637
integertime get_timestep_grav(int p)
Definition: timestep.cc:177
void assign_hydro_timesteps(void)
Definition: timestep.cc:56
integertime get_timestep_hydro(int p)
Definition: timestep.cc:274
int test_if_grav_timestep_is_too_large(int p, int bin)
Definition: timestep.cc:158
TimeBinData TimeBinsGravity
Definition: simparticles.h:205
particle_data * P
Definition: simparticles.h:54
sph_particle_data * SphP
Definition: simparticles.h:59
void timebins_get_bin_and_do_validity_checks(integertime ti_step, int *bin_new, int bin_old)
Definition: timestep.cc:494
TimeBinData TimeBinsHydro
Definition: simparticles.h:204
int TimeBinSynchronized[TIMEBINS]
Definition: simparticles.h:203
void tree_based_timesteps(void)
#define TIMEBINS
Definition: constants.h:332
#define SOLAR_MASS
Definition: constants.h:119
#define SEC_PER_YEAR
Definition: constants.h:128
#define MIN_FLOAT_NUMBER
Definition: constants.h:80
int integertime
Definition: constants.h:331
#define MAX_DOUBLE_NUMBER
Definition: constants.h:81
#define TIMEBASE
Definition: constants.h:333
#define TIMER_START(counter)
Starts the timer counter.
Definition: logs.h:197
#define TIMER_STOP(counter)
Stops the timer counter.
Definition: logs.h:220
#define Terminate(...)
Definition: macros.h:15
void minimum_large_ints(int n, long long *src, long long *res, MPI_Comm comm)
memory Mem
Definition: main.cc:44
half fabs(half arg)
Definition: half.hpp:2627
expr sqrt(half arg)
Definition: half.hpp:2777
void timebins_reallocate(void)
Definition: timestep.cc:484
void timebins_init(const char *name, int *MaxPart)
Definition: timestep.cc:439
int NActiveParticles
Definition: timestep.h:18
int * ActiveParticleList
Definition: timestep.h:20
void timebin_remove_particle(int idx, int bin)
Definition: timestep.cc:574
void timebin_make_list_of_active_particles_up_to_timebin(int timebin)
Definition: timestep.cc:664
char Name[100]
Definition: timestep.h:27
int TimeBinCount[TIMEBINS]
Definition: timestep.h:21
void timebin_add_particles_of_timebin_to_list_of_active_particles(int timebin)
Definition: timestep.cc:671
int FirstInTimeBin[TIMEBINS]
Definition: timestep.h:23
void timebins_allocate(void)
Definition: timestep.cc:458
int * PrevInTimeBin
Definition: timestep.h:26
int * MaxPart
Definition: timestep.h:28
void timebin_move_particle(int p, int timeBin_old, int timeBin_new)
Definition: timestep.cc:539
int * NextInTimeBin
Definition: timestep.h:25
int LastInTimeBin[TIMEBINS]
Definition: timestep.h:24
void timebin_add_particle(int i_new, int i_old, int timeBin, int addToListOfActiveParticles)
Definition: timestep.cc:599
void timebins_free(void)
Definition: timestep.cc:473
integertime Ti_Current
Definition: allvars.h:188
double ForceSoftening[NSOFTCLASSES+NSOFTCLASSES_HYDRO+2]
Definition: allvars.h:258
void set_cosmo_factors_for_current_time(void)
Definition: allvars.cc:20
double SofteningTable[NSOFTCLASSES+NSOFTCLASSES_HYDRO]
Definition: allvars.h:256
MyDouble getMass(void)
unsigned char getSofteningClass(void)
unsigned char getTimeBinHydro(void)
MyFloat Vel[3]
Definition: particle_data.h:54
MyIDStorage ID
Definition: particle_data.h:70
signed char TimeBinGrav
Definition: particle_data.h:71
unsigned char getType(void)
void setTimeBinHydro(unsigned char bin)
signed char TimeBinHydro
Definition: particle_data.h:73
vector< MyFloat > GravAccel
Definition: particle_data.h:55
void myflush(FILE *fstream)
Definition: system.cc:125