GADGET-4
gwalk.h
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#ifndef GRAVTREE_WALK_H
13#define GRAVTREE_WALK_H
14
15#include "../mpi_utils/shared_mem_handler.h"
16
17class gwalk : public gravtree<simparticles>
18{
19 public:
20 void gravity_tree(int timebin);
21
22 private:
23 long long interactioncountPP;
24 long long interactioncountPN;
25
26 MyReal theta2;
27 MyReal thetamax2;
28 MyReal errTolForceAcc;
29
30#ifdef PRESERVE_SHMEM_BINARY_INVARIANCE
31 bool skip_actual_force_computation;
32#endif
33
34 struct pinfo
35 {
36 MyIntPosType *intpos;
37 MyReal aold;
38 MyReal h_i;
39 int Type;
40#if NSOFTCLASSES > 1
41 int SofteningClass;
42#endif
43#if defined(PMGRID) && defined(PLACEHIGHRESREGION)
44 int InsideOutsideFlag;
45#endif
46
47 vector<MyFloat> *acc;
48 MyFloat *pot;
49 int *GravCost;
50 };
51
52 inline int get_pinfo(int i, pinfo &pdat)
53 {
54 int ptype;
55
56 if(i < Tp->NumPart)
57 {
59
60 pdat.intpos = Tp->P[i].IntPos;
61
62 pdat.Type = Tp->P[i].getType();
63#if NSOFTCLASSES > 1
64 pdat.SofteningClass = Tp->P[i].getSofteningClass();
65#endif
66 pdat.aold = Tp->P[i].OldAcc;
67#if defined(PMGRID) && defined(PLACEHIGHRESREGION)
68 pdat.InsideOutsideFlag = Tp->P[i].InsideOutsideFlag;
69#endif
70
71 pdat.acc = &Tp->P[i].GravAccel;
72#ifdef EVALPOTENTIAL
73 pdat.pot = &Tp->P[i].Potential;
74#endif
75 pdat.GravCost = &Tp->P[i].GravCost;
76 }
77 else
78 {
80
81 int n = i - ImportedNodeOffset;
82
83 pdat.intpos = Points[n].IntPos;
84
85 pdat.Type = Points[n].Type;
86#if NSOFTCLASSES > 1
87 pdat.SofteningClass = Points[n].SofteningClass;
88#endif
89 pdat.aold = Points[n].OldAcc;
90#if defined(PMGRID) && defined(PLACEHIGHRESREGION)
91 pdat.InsideOutsideFlag = Points[n].InsideOutsideFlag;
92#endif
93
94 int idx = ResultIndexList[n];
95 pdat.acc = &ResultsActiveImported[idx].GravAccel;
96#ifdef EVALPOTENTIAL
97 pdat.pot = &ResultsActiveImported[idx].Potential;
98#endif
99 pdat.GravCost = &ResultsActiveImported[idx].GravCost;
100 }
101
102#if NSOFTCLASSES > 1
103 pdat.h_i = All.ForceSoftening[pdat.SofteningClass];
104#else
105 pdat.h_i = All.ForceSoftening[0];
106#endif
107
108 return ptype;
109 }
110
111 inline void gwalk_open_node(const pinfo &pdat, int i, char ptype, gravnode *nop, int mintopleafnode, int committed);
112 void gravity_force_interact(const pinfo &pdat, int i, int no, char ptype, char no_type, unsigned char shmrank, int mintopleafnode,
113 int committed);
114
115 inline int evaluate_particle_node_opening_criterion_and_interaction(const pinfo &pdat, gravnode *nop);
116 inline void evaluate_particle_particle_interaction(const pinfo &pdat, const int no, const char jtype, int no_task);
117};
118
119#endif
global_data_all_processes All
Definition: main.cc:40
resultsactiveimported_data * ResultsActiveImported
Definition: gravtree.h:293
Definition: gwalk.h:18
void gravity_tree(int timebin)
This function computes the gravitational forces for all active particles.
Definition: gwalk.cc:600
particle_data * P
Definition: simparticles.h:54
float MyFloat
Definition: dtypes.h:86
uint32_t MyIntPosType
Definition: dtypes.h:35
double MyReal
Definition: dtypes.h:82
#define NODE_TYPE_TREEPOINT_PARTICLE
Definition: gravtree.h:30
#define NODE_TYPE_LOCAL_PARTICLE
Definition: gravtree.h:29
double ForceSoftening[NSOFTCLASSES+NSOFTCLASSES_HYDRO+2]
Definition: allvars.h:258
unsigned char Type
Definition: gravtree.h:107
unsigned char SofteningClass
Definition: gravtree.h:109
float OldAcc
Definition: gravtree.h:104
MyIntPosType IntPos[3]
Definition: gravtree.h:102
unsigned char getSofteningClass(void)
unsigned char getType(void)
vector< MyFloat > GravAccel
Definition: particle_data.h:55
MyIntPosType IntPos[3]
Definition: particle_data.h:53