12#include "gadgetconfig.h"
20#include "../data/allvars.h"
21#include "../data/dtypes.h"
22#include "../domain/domain.h"
23#include "../gravtree/gravtree.h"
24#include "../logs/logs.h"
25#include "../logs/timer.h"
26#include "../main/main.h"
27#include "../main/simulation.h"
28#include "../mpi_utils/mpi_utils.h"
29#include "../ngbtree/ngbtree.h"
30#include "../system/system.h"
31#include "../time_integration/driftfac.h"
32#include "../time_integration/timestep.h"
46#if defined(PMGRID) && !defined(TREEPM_NOTIMESPLIT)
52 All.PM_Ti_begstep =
All.PM_Ti_endstep;
53 All.PM_Ti_endstep =
All.PM_Ti_begstep + ti_step;
67 for(
int j = 0; j < 3; j++)
68 Sp.
P[i].
Vel[j] +=
Sp.
P[i].GravPM[j] * dt_gravkick;
76#ifdef FORCE_EQUAL_TIMESTEPS
80#ifdef HIERARCHICAL_GRAVITY
96 double dt_gravsum = 0;
98 int bin_highest_occupied = 0;
136 int push_down_flag = 0;
141 "KICKS: We reduce the highest occupied timestep by pushing %lld particles on timebin=%d down in timestep (fraction "
142 "wanting lower bin is: %g)\n",
156 int bin = binold - 1;
167 else if(binold > bin_highest_occupied)
168 bin_highest_occupied = binold;
192 double dt_save = dt_gravkick;
196 ti_step = (timebin + 1) ? (((
integertime)1) << (timebin + 1)) : 0;
199 tend = tstart + ti_step / 2;
207 dt_gravsum += dt_gravkick;
209 mpi_printf(
"KICKS: 1st gravity for hierarchical timebin=%d: %lld particles dt_gravkick=%g %g %g\n", timebin,
216 for(
int j = 0; j < 3; j++)
233#ifndef FORCE_EQUAL_TIMESTEPS
239 ti_step = timebin ? (((
integertime)1) << timebin) : 0;
258 for(
int j = 0; j < 3; j++)
281 sprintf(fullmark,
"(*)");
287 fprintf(
Logs.
FdTimings,
"\nStep%s: %d, t: %g, dt: %g, highest active timebin: %d (lowest active: %d, highest occupied: %d)\n",
291 fprintf(
Logs.
FdDensity,
"\nStep%s: %d, t: %g, dt: %g, highest active timebin: %d (lowest active: %d, highest occupied: %d)\n",
295 fprintf(
Logs.
FdHydro,
"\nStep%s: %d, t: %g, dt: %g, highest active timebin: %d (lowest active: %d, highest occupied: %d)\n",
302#ifdef HIERARCHICAL_GRAVITY
322 mpi_printf(
"KICKS: 2nd gravity for hierarchical timebin=%d: particles %lld\n", timebin,
338 ti_step = (timebin + 1) ? (((
integertime)1) << (timebin + 1)) : 0;
342 tstart = tend - ti_step / 2;
354 for(
int j = 0; j < 3; j++)
359 for(
int j = 0; j < 3; j++)
400 for(
int j = 0; j < 3; j++)
405 for(
int j = 0; j < 3; j++)
413#if defined(PMGRID) && defined(PERIODIC) && !defined(TREEPM_NOTIMESPLIT)
432 for(
int j = 0; j < 3; j++)
433 Sp.
P[i].
Vel[j] +=
Sp.
P[i].GravPM[j] * dt_gravkick;
437 for(
int j = 0; j < 3; j++)
486 int *targetlist = (
int *)
Mem.mymalloc(
"targetlist",
Sp.
NumGas *
sizeof(
int));
488 struct old_hydro_accel
492 old_hydro_accel *Old = NULL;
497 int Nhydroforces = 0;
503 if(target < 0 || target >=
Sp.
NumGas)
504 Terminate(
"target=%d i=%d\n", target, i);
513 targetlist[Nhydroforces++] = target;
516#ifdef REUSE_HYDRO_ACCELERATIONS_FROM_PREVIOUS_STEP
525 for(
int i = 0; i < Nhydroforces; i++)
536 tstart = tend - ti_step / 2;
541 tend = tstart + ti_step / 2;
549 dt_hydrokick = dt_entr;
560#ifdef PRESSURE_ENTROPY_SPH
578 Mem.myfree(targetlist);
global_data_all_processes All
double get_gravkick_factor(integertime time0, integertime time1)
double get_hydrokick_factor(integertime time0, integertime time1)
void mpi_printf(const char *fmt,...)
void compute_grav_accelerations(int timebin)
This routine computes the gravitational accelerations for all active particles.
domain< simparticles > Domain
void do_hydro_step_second_half(void)
void hydro_force(int step_indicator)
void do_hydro_step_first_half(void)
void gravity_long_range_force(void)
void find_timesteps_and_do_gravity_step_first_half(void)
performs the first half step kick operator for the gravity
void gravity_set_oldacc(int timebin)
void find_global_timesteps(void)
void do_gravity_step_second_half(void)
performs the second gravity half step kick operator
integertime get_timestep_grav(int p)
int test_if_grav_timestep_is_too_large(int p, int bin)
TimeBinData TimeBinsGravity
void print_particle_info(int i)
Print information relative to a particle / cell to standard output.
void timebins_get_bin_and_do_validity_checks(integertime ti_step, int *bin_new, int bin_old)
TimeBinData TimeBinsHydro
int TimeBinSynchronized[TIMEBINS]
void mark_active_timebins(void)
void hydro_forces_determine(int ntarget, int *targetlist)
void treeallocate(int max_partindex, partset *Pptr, domain< partset > *Dptr)
int treebuild(int ninsert, int *indexlist)
#define TIMER_START(counter)
Starts the timer counter.
#define TIMER_STOP(counter)
Stops the timer counter.
void sumup_large_ints(int n, int *src, long long *res, MPI_Comm comm)
expr pow(half base, half exp)
void timebin_make_list_of_active_particles_up_to_timebin(int timebin)
void timebin_add_particles_of_timebin_to_list_of_active_particles(int timebin)
long long GlobalNActiveParticles
void timebin_move_particle(int p, int timeBin_old, int timeBin_new)
int HighestSynchronizedTimeBin
integertime Ti_begstep[TIMEBINS]
int ComovingIntegrationOn
void set_cosmo_factors_for_current_time(void)
int HighestOccupiedGravTimeBin
int HighestOccupiedTimeBin
unsigned char getTimeBinHydro(void)
unsigned char getType(void)
vector< MyFloat > GravAccel
void set_thermodynamic_variables(void)