GADGET-4
grav_external.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
#ifdef EXTERNALGRAVITY
15
16
#include <math.h>
17
#include <mpi.h>
18
#include <stdlib.h>
19
#include <string.h>
20
21
#include "../data/allvars.h"
22
#include "../data/dtypes.h"
23
#include "../data/intposconvert.h"
24
#include "../data/mymalloc.h"
25
#include "../domain/domain.h"
26
#include "../fmm/fmm.h"
27
#include "../gravtree/gravtree.h"
28
#include "../logs/logs.h"
29
#include "../logs/timer.h"
30
#include "../main/simulation.h"
31
#include "../mpi_utils/mpi_utils.h"
32
#include "../pm/pm.h"
33
#include "../system/system.h"
34
#include "../time_integration/timestep.h"
35
36
void
sim::gravity_external(
void
)
37
{
38
for
(
int
i = 0; i <
Sp
.
TimeBinsGravity
.
NActiveParticles
; i++)
39
{
40
int
target =
Sp
.
TimeBinsGravity
.
ActiveParticleList
[i];
41
42
#if defined(EVALPOTENTIAL) || defined(OUTPUT_POTENTIAL)
43
Sp
.
P
[target].ExtPotential = 0;
44
#endif
45
46
#ifdef EXTERNALGRAVITY_STATICHQ
47
{
48
vector<double>
pos;
49
Sp
.
intpos_to_pos
(
Sp
.
P
[target].
IntPos
, pos.
da
);
/* converts the integer coordinate to floating point */
50
51
double
r =
sqrt
(pos.
r2
());
52
53
double
m =
All
.Mass_StaticHQHalo *
pow
(r / (r +
All
.A_StaticHQHalo), 2);
54
55
if
(r > 0)
56
Sp
.
P
[target].
GravAccel
+= (-
All
.
G
* m / (r * r * r)) * pos;
57
58
#if defined(EVALPOTENTIAL) || defined(OUTPUT_POTENTIAL)
59
Sp
.
P
[target].ExtPotential += (-
All
.
G
*
All
.Mass_StaticHQHalo / (r +
All
.A_StaticHQHalo));
60
#endif
61
}
62
#endif
63
}
64
}
65
66
#endif
All
global_data_all_processes All
Definition:
main.cc:40
intposconvert::intpos_to_pos
void intpos_to_pos(MyIntPosType *intpos, T *posdiff)
Definition:
intposconvert.h:380
sim::Sp
simparticles Sp
Definition:
simulation.h:56
simparticles::TimeBinsGravity
TimeBinData TimeBinsGravity
Definition:
simparticles.h:205
simparticles::P
particle_data * P
Definition:
simparticles.h:54
vector
Definition:
symtensors.h:104
vector::r2
T r2(void)
Definition:
symtensors.h:187
vector::da
T da[3]
Definition:
symtensors.h:106
half_float::detail::pow
expr pow(half base, half exp)
Definition:
half.hpp:2803
half_float::detail::sqrt
expr sqrt(half arg)
Definition:
half.hpp:2777
TimeBinData::NActiveParticles
int NActiveParticles
Definition:
timestep.h:18
TimeBinData::ActiveParticleList
int * ActiveParticleList
Definition:
timestep.h:20
global_data_all_processes::G
double G
Definition:
allvars.h:132
particle_data::GravAccel
vector< MyFloat > GravAccel
Definition:
particle_data.h:55
particle_data::IntPos
MyIntPosType IntPos[3]
Definition:
particle_data.h:53
src
gravity
grav_external.cc
Generated by
1.9.2