MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
slotsmanager.h
Go to the documentation of this file.
1 #ifndef __GARBAGE_H
2 #define __GARBAGE_H
3 #include <mpi.h>
4 #include "utils.h"
5 
6 #include "types.h"
7 #include "partmanager.h"
8 
9 struct slot_info {
10  char * ptr; /* aliasing ptr for this slot */
11  int64_t maxsize; /* max number of supported slots */
12  int64_t size; /* currently used slots*/
13  size_t elsize; /* itemsize */
14  int enabled;
15 };
16 
17 /* Slot particle data structures: first the base extension slot, then black holes,
18  * then stars, then SPH. SPH still has some compile-time optional elements.
19  * Each particle also has the base data, stored in particle_data.*/
21  /* Used at GC for reverse link to P.
22  * Garbage slots have this impossibly large. */
24  MyIDType ID; /* for data consistency check, same as particle ID */
25 };
26 
27 /* Data stored for each black hole in addition to collisionless data*/
29  struct particle_data_ext base;
30 
32 
37  /* Merger time of the black hole.
38  * After this, all values are fixed. */
41  double MinPotPos[3];
43  /* After a merger, this gives the ID of the particle which swallowed the BH. Used to keep track of merger trees.*/
45 
46  /*******************************************************/
47  double DragAccel[3];
48  double DFAccel[3];
49  /*******************************************************/
50  double KineticFdbkEnergy; /* accumulated KineticFdbk Energy */
51 
52  /* Stores the minimum timebins of all black hole neighbours.
53  * The black hole timebin is then set to this.*/
55  int encounter; /* mark the event when BH encounters another BH */
56  double Mtrack; /*Swallow gas particle when BHP.Mass accretes from SeedBHMass to SeedDynMass for mass conservation */
57  double Mseed; /*Log the seed mass of BH, would be useful in case of the powerlaw seeding*/
58 };
59 
60 #define NMETALS 9
61 
62 /*Data for each star particle*/
64 {
65  struct particle_data_ext base;
67  MyFloat LastEnrichmentMyr; /* Last time the star particle had an enrichment event, in Myr since FormationTime.*/
68  MyFloat TotalMassReturned; /* The total mass returned from this star since formation.
69  The initial mass of the SSP in this star is STARP.TotalMassReturned + P.Mass.
70  It is stored like this to retain compatibility with older snapshots. */
73  float Metals[NMETALS]; /* Metal mass of each species in star particle*/
74 };
75 
76 /* the following structure holds data that is stored for each SPH particle in addition to the collisionless
77  * variables.
78  */
80 {
81  struct particle_data_ext base;
82 
83  /*This is only used if DensityIndependentSph is on.
84  * If DensityIndependentSph is off then Density is used instead.*/
97  /* CurlVel has to be here and not in scratch because we re-use the
98  * CurlVel of inactive particles inside the artificial viscosity calculation.*/
105  MyFloat Sfr; /* Star formation rate in Msun/year. Stored here because, if the H2 dependent star formation is used,
106  it depends on the scratch variable GradRho and thus cannot be recomputed after a fof-exchange. */
108  float Metals[NMETALS];
109 };
110 
111 extern struct slots_manager_type {
112  struct slot_info info[6];
113  char * Base; /* memory ptr that holds of all slots */
114  double increase; /* Percentage amount to increase
115  * slot reservation by when requested.*/
117 
118 /* shortcuts for accessing different slots directly by the index */
119 #define SphP ((struct sph_particle_data*) SlotsManager->info[0].ptr)
120 #define StarP ((struct star_particle_data*) SlotsManager->info[4].ptr)
121 #define BhP ((struct bh_particle_data*) SlotsManager->info[5].ptr)
122 
123 /* shortcuts for accessing slots from base particle index */
124 #define SPHP(i) SphP[P[i].PI]
125 #define BHP(i) BhP[P[i].PI]
126 #define STARP(i) StarP[P[i].PI]
127 
128 extern MPI_Datatype MPI_TYPE_PARTICLE;
129 extern MPI_Datatype MPI_TYPE_SLOT[6];
130 
131 /* shortcuts to access base slot attributes */
132 #define BASESLOT_PI(PI, ptype, sman) ((struct particle_data_ext *)(sman->info[ptype].ptr + sman->info[ptype].elsize * (PI)))
133 
134 void slots_init(double increase, struct slots_manager_type * sman);
135 /*Enable a slot on type ptype. All slots are disabled after slots_init().*/
136 void slots_set_enabled(int ptype, size_t elsize, struct slots_manager_type * sman);
137 void slots_free(struct slots_manager_type * sman);
138 void slots_mark_garbage(int i, struct part_manager_type * pman, struct slots_manager_type * sman);
139 void slots_setup_topology(struct part_manager_type * pman, int64_t * NLocal, struct slots_manager_type * sman);
140 void slots_setup_id(const struct part_manager_type * pman, struct slots_manager_type * sman);
141 int slots_split_particle(int parent, double childmass, struct part_manager_type * pman);
142 int slots_convert(int parent, int ptype, int placement, struct part_manager_type * pman, struct slots_manager_type * sman);
143 int slots_gc(int * compact_slots, struct part_manager_type * pman, struct slots_manager_type * sman);
144 void slots_gc_sorted(struct part_manager_type * pman, struct slots_manager_type * sman);
145 size_t slots_reserve(int where, int64_t atleast[6], struct slots_manager_type * sman);
146 void slots_check_id_consistency(struct part_manager_type * pman, struct slots_manager_type * sman);
147 
148 typedef struct {
150  int parent;
151  int64_t child;
152 } EISlotsFork;
153 
154 #endif
void slots_setup_id(const struct part_manager_type *pman, struct slots_manager_type *sman)
Definition: slotsmanager.c:653
size_t slots_reserve(int where, int64_t atleast[6], struct slots_manager_type *sman)
Definition: slotsmanager.c:475
MPI_Datatype MPI_TYPE_SLOT[6]
Definition: slotsmanager.c:13
MPI_Datatype MPI_TYPE_PARTICLE
Definition: slotsmanager.c:11
void slots_set_enabled(int ptype, size_t elsize, struct slots_manager_type *sman)
Definition: slotsmanager.c:560
void slots_mark_garbage(int i, struct part_manager_type *pman, struct slots_manager_type *sman)
Definition: slotsmanager.c:577
void slots_free(struct slots_manager_type *sman)
Definition: slotsmanager.c:570
void slots_setup_topology(struct part_manager_type *pman, int64_t *NLocal, struct slots_manager_type *sman)
Definition: slotsmanager.c:624
int slots_gc(int *compact_slots, struct part_manager_type *pman, struct slots_manager_type *sman)
Definition: slotsmanager.c:145
void slots_check_id_consistency(struct part_manager_type *pman, struct slots_manager_type *sman)
Definition: slotsmanager.c:587
struct slots_manager_type SlotsManager[1]
void slots_gc_sorted(struct part_manager_type *pman, struct slots_manager_type *sman)
Definition: slotsmanager.c:442
void slots_init(double increase, struct slots_manager_type *sman)
Definition: slotsmanager.c:550
#define NMETALS
Definition: slotsmanager.h:60
int slots_convert(int parent, int ptype, int placement, struct part_manager_type *pman, struct slots_manager_type *sman)
Definition: slotsmanager.c:60
int slots_split_particle(int parent, double childmass, struct part_manager_type *pman)
Definition: slotsmanager.c:103
Definition: event.h:8
int64_t child
Definition: slotsmanager.h:151
MyFloat SwallowTime
Definition: slotsmanager.h:39
struct particle_data_ext base
Definition: slotsmanager.h:29
double DFAccel[3]
Definition: slotsmanager.h:48
double DragAccel[3]
Definition: slotsmanager.h:47
double MinPotPos[3]
Definition: slotsmanager.h:41
MyIDType SwallowID
Definition: slotsmanager.h:44
double KineticFdbkEnergy
Definition: slotsmanager.h:50
MyFloat MinPotVel[3]
Definition: slotsmanager.h:42
MyFloat FormationTime
Definition: slotsmanager.h:36
size_t elsize
Definition: slotsmanager.h:13
int64_t maxsize
Definition: slotsmanager.h:11
int64_t size
Definition: slotsmanager.h:12
char * ptr
Definition: slotsmanager.h:10
struct slot_info info[6]
Definition: slotsmanager.h:112
struct particle_data_ext base
Definition: slotsmanager.h:81
MyFloat HydroAccel[3]
Definition: slotsmanager.h:92
MyFloat MaxSignalVel
Definition: slotsmanager.h:89
MyFloat EgyWtDensity
Definition: slotsmanager.h:85
MyFloat DhsmlEgyDensityFactor
Definition: slotsmanager.h:95
float Metals[NMETALS]
Definition: slotsmanager.h:108
MyFloat TotalMassReturned
Definition: slotsmanager.h:68
MyFloat LastEnrichmentMyr
Definition: slotsmanager.h:67
float Metals[NMETALS]
Definition: slotsmanager.h:73
struct particle_data_ext base
Definition: slotsmanager.h:65
uint64_t MyIDType
Definition: types.h:10
LOW_PRECISION MyFloat
Definition: types.h:19
static enum TransferType ptype
Definition: zeldovich.c:146