GADGET-4
fof_io.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 FOF_IO_H
13#define FOF_IO_H
14
15#include "../fof/fof.h"
16#include "../io/io.h"
17
18template <typename partset>
19class fof_io : public IO_Def
20{
21 public:
22 fof<partset> *FoF;
23
24 fof_io(fof<partset> *FoF_ptr, MPI_Comm comm, int format); /* constructor */
25
26 void fof_subfind_save_groups(int num, const char *basename, const char *grpcat_dirbasename);
28
29 /* supplied virtual functions */
30 void fill_file_header(int writeTask, int lastTask, long long *nloc_part, long long *npart);
31 void read_file_header(const char *fname, int filenr, int readTask, int lastTask, long long *nloc_part, long long *npart,
32 int *nstart);
33 void get_datagroup_name(int grnr, char *gname);
35 void read_header_fields(const char *fname);
36 void read_increase_numbers(int type, int n_for_this_task);
39 void *get_base_address_of_structure(enum arrays array, int index);
40 int get_type_of_element(int index);
41 void set_type_of_element(int index, int type);
42
43 public:
45 {
46 long long Ngroups;
47 long long Nsubhalos;
48 long long Nids;
49 long long TotNgroups;
50 long long TotNsubhalos;
51 long long TotNids;
53 double time;
54 double redshift;
55 double BoxSize;
56 };
58
59 int LegacyFormat = 0;
60
61 private:
62 struct id_list
63 {
64 MyIDType ID;
65 MyHaloNrType GroupNr;
66 int Type;
67#ifdef SUBFIND
68 int SubRankInGr;
69 MyFloat BindingEgy;
70#endif
71 };
72 id_list *ID_list;
73
74 void fof_subfind_prepare_ID_list(void);
75
76 static bool fof_subfind_compare_ID_list(const id_list &a, const id_list &b)
77 {
78 if(a.GroupNr < b.GroupNr)
79 return true;
80 if(a.GroupNr > b.GroupNr)
81 return false;
82
83#ifdef SUBFIND
84 if(a.SubRankInGr < b.SubRankInGr)
85 return true;
86 if(a.SubRankInGr > b.SubRankInGr)
87 return false;
88#endif
89
90 if(a.Type < b.Type)
91 return true;
92 if(a.Type > b.Type)
93 return false;
94
95#ifdef SUBFIND
96 return a.BindingEgy < b.BindingEgy;
97#else
98 return a.ID < b.ID;
99#endif
100 }
101};
102
103#endif
Definition: io.h:129
Definition: fof_io.h:20
int get_filenr_from_header(void)
void read_header_fields(const char *fname)
int LegacyFormat
Definition: fof_io.h:59
void * get_base_address_of_structure(enum arrays array, int index)
void fof_subfind_load_groups(int num)
void read_increase_numbers(int type, int n_for_this_task)
fof< partset > * FoF
Definition: fof_io.h:22
void fill_file_header(int writeTask, int lastTask, long long *nloc_part, long long *npart)
void fof_subfind_save_groups(int num, const char *basename, const char *grpcat_dirbasename)
void read_file_header(const char *fname, int filenr, int readTask, int lastTask, long long *nloc_part, long long *npart, int *nstart)
void set_type_of_element(int index, int type)
void write_header_fields(hid_t)
fof_io(fof< partset > *FoF_ptr, MPI_Comm comm, int format)
void get_datagroup_name(int grnr, char *gname)
void set_filenr_in_header(int)
fof_subfind_header catalogue_header
Definition: fof_io.h:57
int get_type_of_element(int index)
float MyFloat
Definition: dtypes.h:86
unsigned int MyIDType
Definition: dtypes.h:68
arrays
Definition: io.h:30
long long TotNsubhalos
Definition: fof_io.h:50