MP-Gadget
5.0.1.dev1-76bc7d4726-dirty
libgadget
partmanager.h
Go to the documentation of this file.
1
#ifndef _PART_DATA_H
2
#define _PART_DATA_H
3
4
#include "
types.h
"
5
#include "
utils/peano.h
"
6
10
struct
particle_data
11
{
12
double
Pos
[3];
13
float
Mass
;
15
struct
{
16
/* particle type. 0=gas, 1=halo, 2=disk, 3=bulge, 4=stars, 5=bndry */
17
unsigned
int
Type
:4;
18
19
unsigned
int
IsGarbage
:1;
/* True for a garbage particle. readonly: Use slots_mark_garbage to mark this.*/
20
unsigned
int
Swallowed
:1;
/* True if the particle is being swallowed; used in BH to determine swallower and swallowee;*/
21
unsigned
int
spare_1
:1;
/*Unused, ensures alignment to a char*/
22
unsigned
int
BHHeated
:1;
/* Flags that particle was heated by a BH this timestep*/
23
unsigned
char
Generation
;
/* How many particles it has spawned; used to generate unique particle ID.
24
may wrap around with too many SFR/BH if a feedback model goes rogue */
25
26
unsigned
char
TimeBin
;
/* Time step bin; 0 for unassigned.*/
27
/* To ensure alignment to a 32-bit boundary.*/
28
unsigned
char
HeIIIionized
;
/* True if the particle has undergone helium reionization.
29
* This could be a bitfield: it isn't because we need to change it in an atomic.
30
* Changing a bitfield in an atomic seems to work in OpenMP 5.0 on gcc 9 and icc 18 and 19,
31
* so we should be able to make it a bitfield at some point. */
32
};
33
34
int
PI
;
/* particle property index; used by BH, SPH and STAR.
35
points to the corresponding structure in (SPH|BH|STAR)P array.*/
36
inttime_t
Ti_drift
;
38
MyIDType
ID
;
39
40
MyFloat
Vel
[3];
/* particle velocity at its current time */
41
MyFloat
GravAccel
[3];
/* particle acceleration due to short-range gravity */
42
43
MyFloat
GravPM
[3];
/* particle acceleration due to long-range PM gravity force */
44
45
MyFloat
Potential
;
/* gravitational potential. This is the total potential after gravtree+gravpm is called. */
46
47
/* DtHsml is 1/3 DivVel * Hsml evaluated at the last active timestep for this particle.
48
* This predicts Hsml during the current timestep in the way used in Gadget-4, more accurate
49
* than the Gadget-2 prediction which could run away in deep timesteps. Used also
50
* to limit timesteps by density change. */
51
union
{
52
MyFloat
DtHsml
;
53
/* This is the destination task during the fof particle exchange.
54
* It is never used outside of that code, and the
55
* particles are copied into a new PartManager before setting it,
56
* so it is safe to union with DtHsml.*/
57
int
TargetTask
;
58
};
59
MyFloat
Hsml
;
60
61
/* Union these two because they are transients: they are hard to move
62
* to private arrays because they need to travel with the particle during exchange*/
63
union
{
64
/* The peano key is a hash of the position used in the domain decomposition.
65
* It is slow to generate so we store it here.*/
66
peano_t
Key
;
/* only by domain.c and force_tree_rebuild */
67
/* FOF Group number: only has meaning during FOF.*/
68
int64_t
GrNr
;
69
};
70
71
};
72
73
extern
struct
part_manager_type
{
74
struct
particle_data
*
Base
;
/* Pointer to particle data on local processor. */
76
int64_t
NumPart
;
78
int64_t
MaxPart
;
79
/* Random shift applied to the box. This is changed
80
* every domain decomposition to prevent correlated
81
* errors building up in the tree force. */
82
double
CurrentParticleOffset
[3];
83
/* Current box size so we can work out periodic boundaries*/
84
double
BoxSize
;
85
}
PartManager
[1];
86
87
/*Compatibility define*/
88
#define P PartManager->Base
89
90
/*Allocate memory for the particles*/
91
void
particle_alloc_memory
(
struct
part_manager_type
*
PartManager
,
double
BoxSize, int64_t MaxPart);
92
93
/* Updates the global storing the current random offset of the particles,
94
* and stores the relative offset from the last random offset in rel_random_shift.
95
* RandomParticleOffset is the max adjustment as a fraction of the box. */
96
void
update_random_offset
(
struct
part_manager_type
*
PartManager
,
double
* rel_random_shift,
double
RandomParticleOffset);
97
98
/* Finds the correct relative position accounting for periodicity*/
99
#define NEAREST(x, BoxSize) (((x)>0.5*BoxSize)?((x)-BoxSize):(((x)<-0.5*BoxSize)?((x)+BoxSize):(x)))
100
101
static
inline
double
DMAX
(
double
a,
double
b) {
102
if
(a > b)
return
a;
103
return
b;
104
}
105
static
inline
double
DMIN
(
double
a,
double
b) {
106
if
(a < b)
return
a;
107
return
b;
108
}
109
static
inline
int
IMAX
(
int
a,
int
b) {
110
if
(a > b)
return
a;
111
return
b;
112
}
113
static
inline
int
IMIN
(
int
a,
int
b) {
114
if
(a < b)
return
a;
115
return
b;
116
}
117
118
#endif
DMIN
static double DMIN(double a, double b)
Definition:
partmanager.h:105
DMAX
static double DMAX(double a, double b)
Definition:
partmanager.h:101
IMIN
static int IMIN(int a, int b)
Definition:
partmanager.h:113
IMAX
static int IMAX(int a, int b)
Definition:
partmanager.h:109
PartManager
struct part_manager_type PartManager[1]
update_random_offset
void update_random_offset(struct part_manager_type *PartManager, double *rel_random_shift, double RandomParticleOffset)
Definition:
partmanager.c:43
particle_alloc_memory
void particle_alloc_memory(struct part_manager_type *PartManager, double BoxSize, int64_t MaxPart)
Definition:
partmanager.c:14
peano.h
peano_t
uint64_t peano_t
Definition:
peano.h:7
part_manager_type
Definition:
partmanager.h:73
part_manager_type::NumPart
int64_t NumPart
Definition:
partmanager.h:76
part_manager_type::Base
struct particle_data * Base
Definition:
partmanager.h:74
part_manager_type::CurrentParticleOffset
double CurrentParticleOffset[3]
Definition:
partmanager.h:82
part_manager_type::MaxPart
int64_t MaxPart
Definition:
partmanager.h:78
part_manager_type::BoxSize
double BoxSize
Definition:
partmanager.h:84
particle_data
Definition:
partmanager.h:11
particle_data::TimeBin
unsigned char TimeBin
Definition:
partmanager.h:26
particle_data::PI
int PI
Definition:
partmanager.h:34
particle_data::GrNr
int64_t GrNr
Definition:
partmanager.h:68
particle_data::Potential
MyFloat Potential
Definition:
partmanager.h:45
particle_data::spare_1
unsigned int spare_1
Definition:
partmanager.h:21
particle_data::HeIIIionized
unsigned char HeIIIionized
Definition:
partmanager.h:28
particle_data::Hsml
MyFloat Hsml
Definition:
partmanager.h:59
particle_data::ID
MyIDType ID
Definition:
partmanager.h:38
particle_data::Swallowed
unsigned int Swallowed
Definition:
partmanager.h:20
particle_data::Mass
float Mass
Definition:
partmanager.h:13
particle_data::DtHsml
MyFloat DtHsml
Definition:
partmanager.h:52
particle_data::Vel
MyFloat Vel[3]
Definition:
partmanager.h:40
particle_data::GravAccel
MyFloat GravAccel[3]
Definition:
partmanager.h:41
particle_data::Pos
double Pos[3]
Definition:
partmanager.h:12
particle_data::GravPM
MyFloat GravPM[3]
Definition:
partmanager.h:43
particle_data::Key
peano_t Key
Definition:
partmanager.h:66
particle_data::Type
unsigned int Type
Definition:
partmanager.h:17
particle_data::IsGarbage
unsigned int IsGarbage
Definition:
partmanager.h:19
particle_data::BHHeated
unsigned int BHHeated
Definition:
partmanager.h:22
particle_data::TargetTask
int TargetTask
Definition:
partmanager.h:57
particle_data::Ti_drift
inttime_t Ti_drift
Definition:
partmanager.h:36
particle_data::Generation
unsigned char Generation
Definition:
partmanager.h:23
types.h
inttime_t
int32_t inttime_t
Definition:
types.h:8
MyIDType
uint64_t MyIDType
Definition:
types.h:10
MyFloat
LOW_PRECISION MyFloat
Definition:
types.h:19
Generated by
1.9.1