12#include "gadgetconfig.h"
19#include "../data/allvars.h"
20#include "../data/dtypes.h"
21#include "../data/intposconvert.h"
22#include "../data/mymalloc.h"
23#include "../domain/domain.h"
24#include "../fmm/fmm.h"
25#include "../gravtree/gravtree.h"
26#include "../logs/logs.h"
27#include "../logs/timer.h"
28#include "../main/simulation.h"
29#include "../mpi_utils/mpi_utils.h"
31#include "../system/system.h"
32#include "../time_integration/timestep.h"
55#if defined(PMGRID) && defined(PERIODIC) && \
56 !defined(TREEPM_NOTIMESPLIT)
60#ifdef PLACEHIGHRESREGION
72#ifdef PLACEHIGHRESREGION
96#ifdef SECOND_ORDER_LPT_ICS
98 second_order_ic_correction();
107#if defined(PMGRID) && defined(PERIODIC) && !defined(TREEPM_NOTIMESPLIT)
122#if defined(PMGRID) && defined(PERIODIC) && !defined(TREEPM_NOTIMESPLIT)
127 GravTest.gravity_forcetest(timebin);
132 for(
int i = 0; i < (int)(FORCETEST)-1; i++)
143 GravTest.gravity_forcetest(timebin);
154 mpi_printf(
"ACCEL: tree force computation done.\n");
183 Sp.
P[target].Potential = 0;
185 for(
int j = 0; j < 3; j++)
197#if defined(PMGRID) && (defined(TREEPM_NOTIMESPLIT) || defined(PLACEHIGHRESREGION))
201#if defined(FORCETEST) && defined(PLACEHIGHRESREGION)
205 Sp.
P[target].PotentialHPM =
All.
G *
Sp.
P[target].Potential;
206 for(
int j = 0; j < 3; j++)
213#ifdef ALLOW_DIRECT_SUMMATION
223#ifdef HIERARCHICAL_GRAVITY
243#ifdef EXTERNALGRAVITY
250#ifdef HIERARCHICAL_GRAVITY
254 mpi_printf(
"GRAVTREE/FMM: Setting OldAcc!\n");
258 double ginv = 1 /
All.
G;
263#if defined(PMGRID) && defined(PERIODIC) && !defined(TREEPM_NOTIMESPLIT)
264 double ax = P[target].
GravAccel[0] + P[target].GravPM[0];
265 double ay = P[target].
GravAccel[1] + P[target].GravPM[1];
266 double az = P[target].
GravAccel[2] + P[target].GravPM[2];
272 P[target].
OldAcc =
sqrt(ax * ax + ay * ay + az * az) * ginv;
294 for(
int j = 0; j < 3; j++)
295 P[target].GravAccel[j] += fac * pos[j];
299 for(
int k = 0; k < 3; k++)
300 r2 += pos[k] * pos[k];
301 P[target].Potential -= fac * r2;
312 for(
int j = 0; j < 3; j++)
313 P[target].GravAccel[j] *=
All.
G;
315#
if defined(EVALPOTENTIAL) && defined(PMGRID) && defined(PERIODIC)
320#ifndef GRAVITY_TALLBOX
325 double alpha = 0.5 /
Sp.Asmth[0];
326 P[target].Potential +=
332#if defined(EVALPOTENTIAL)
343#if defined(FMM) && defined(PERIODIC) && !defined(PMGRID)
345 P[target].Potential += P[target].
getMass() *
Ewald.ewald_gridlookup_origin_D0();
348 P[target].Potential *=
All.
G;
350#if defined(PMGRID) && !defined(FORCETEST_TESTFORCELAW)
351 P[target].Potential += P[target].PM_Potential;
359 "You specified a periodic simulation in physical coordinates but with a non-zero cosmological constant - this can't be "
370 for(
int j = 0; j < 3; j++)
375 for(
int k = 0; k < 3; k++)
376 r2 += pos[k] * pos[k];
377 P[target].Potential -= 0.5 * fac * r2;
383#if defined(PMGRID) && (defined(TREEPM_NOTIMESPLIT) || defined(PLACEHIGHRESREGION))
388 mpi_printf(
"TREEPM: Starting PM part of force calculation. (timebin=%d)\n", timebin);
390#if !defined(PERIODIC) || defined(PLACEHIGHRESREGION)
391 PM.pm_init_regionsize();
397 PM.pmforce_periodic(
LOW_MESH, NULL);
404#ifdef PLACEHIGHRESREGION
409 mpi_printf(
"TREEPM: Finished PM part of force calculation.\n");
419#if defined(PMGRID) && defined(PERIODIC) && !defined(TREEPM_NOTIMESPLIT)
431 Sp.
P[i].GravPM[0] =
Sp.
P[i].GravPM[1] =
Sp.
P[i].GravPM[2] = 0;
433 Sp.
P[i].PM_Potential = 0;
437 PM.pmforce_periodic(0, NULL);
442 for(
int j = 0; j < 3; j++)
453 Sp.find_long_range_step_constraint();
global_data_all_processes All
void set_softenings(void)
This function sets the (comoving) softening length of all particle types in the table All....
void gravity_tree(int timebin)
This function computes the gravitational forces for all active particles.
void intpos_to_pos(MyIntPosType *intpos, T *posdiff)
double timediff(double t0, double t1)
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 gravity_comoving_factors(int timebin)
void gravity(int timebin)
main driver routine of gravity tree/fmm force calculation
void gravity_pm(int timebin)
void gravity_long_range_force(void)
void gravity_set_oldacc(int timebin)
void endrun(void)
This function aborts the simulations.
TimeBinData TimeBinsGravity
void treeallocate(int max_partindex, partset *Pptr, domain< partset > *Dptr)
int treebuild(int ninsert, int *indexlist)
#define DIRECT_SUMMATION_THRESHOLD
#define TREE_ACTIVE_CUTTOFF_HIGHRES_PM
#define TREE_DO_HIGHRES_PM
#define TREE_ACTIVE_CUTTOFF_BASE_PM
#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)
long long GlobalNActiveParticles
double CPUForLastPMExecution
int ComovingIntegrationOn
double ForceSoftening[NSOFTCLASSES+NSOFTCLASSES_HYDRO+2]
int HighestOccupiedGravTimeBin
int TypeOfOpeningCriterion
char RelOpeningCriterionInUse
unsigned char getSofteningClass(void)
vector< MyFloat > GravAccel