GADGET-4
lightcone.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 LIGHTCONE_H
13#define LIGHTCONE_H
14
15#include "gadgetconfig.h"
16
17#ifdef LIGHTCONE
18
19#include "../data/allvars.h"
20#include "../data/dtypes.h"
21#include "../data/lcparticles.h"
22#include "../data/mmparticles.h"
23#include "../data/simparticles.h"
24#include "../data/symtensors.h"
25#include "../mpi_utils/setcomm.h"
26#include "../time_integration/driftfac.h"
27
28#ifdef LIGHTCONE_MASSMAPS
29#include <chealpix.h>
30#endif
31
32#ifndef LIGHTCONE_MAX_BOXREPLICAS
33#define LIGHTCONE_MAX_BOXREPLICAS 1000
34#endif
35
36#ifndef LIGHTCONE_ORDER_NSIDE
37#define LIGHTCONE_ORDER_NSIDE 256
38#endif
39
40#define LC_TYPE_FULLSKY 0
41#define LC_TYPE_OCTANT 1
42#define LC_TYPE_PENCIL 2
43#define LC_TYPE_DISK 3
44#define LC_TYPE_SQUAREMAP 4
45
46class lightcone : public parameters
47{
48 public:
49 simparticles *Sp;
50
51#if defined(LIGHTCONE_PARTICLES)
52 lcparticles *Lp;
53#endif
54#if defined(LIGHTCONE_MASSMAPS)
55 mmparticles *Mp;
56#endif
57
58 public:
59#if defined(LIGHTCONE_PARTICLES) && defined(LIGHTCONE_MASSMAPS) /* both particles and massmaps */
60 lightcone(MPI_Comm comm, simparticles *Sp_ptr, lcparticles *Lp_ptr, mmparticles *Mp_ptr) : parameters(comm)
61 {
62 Sp = Sp_ptr;
63 Lp = Lp_ptr;
64 Mp = Mp_ptr;
65
66 Sp->LightCone = this;
67 }
68#else
69#if defined(LIGHTCONE_PARTICLES)
70 lightcone(MPI_Comm comm, simparticles *Sp_ptr, lcparticles *Lp_ptr) : parameters(comm) /* only particles */
71 {
72 Sp = Sp_ptr;
73 Lp = Lp_ptr;
74
75 Sp->LightCone = this;
76 }
77#else
78#if defined(LIGHTCONE_MASSMAPS)
79 lightcone(MPI_Comm comm, simparticles *Sp_ptr, mmparticles *Mp_ptr) : parameters(comm) /* only massmaps */
80 {
81 Sp = Sp_ptr;
82 Mp = Mp_ptr;
83
84 Sp->LightCone = this;
85 }
86#endif
87#endif
88#endif
89
90 void lightcone_init_intposconverter(double linklength);
91
92 int lightcone_test_for_particle_addition(particle_data *P, integertime time0, integertime time1, double dt_drift);
93
94 void register_parameters(void);
95
96 void makeimage(int argc, char **argv);
97
98#ifdef LIGHTCONE_PARTICLES
99 int Nlightcones;
100
101 struct cone_data
102 {
103 double Astart;
104 double Aend;
105
106 integertime Time_start;
107 integertime Time_end;
108
109 double ComDistStart;
110 double ComDistEnd;
111
112 int LcType;
113 int OnlyMostBoundFlag;
114
115 int OctantNr;
116
117 vector<double> PencilDir;
118 double PencilAngle;
119 double PencilAngleRad;
120
121 vector<double> DiskNormal;
122 double DiskThickness;
123
124 vector<double> SquareMapXdir;
125 vector<double> SquareMapYdir;
126 vector<double> SquareMapZdir;
127
128 double SquareMapAngle;
129 double SquareMapAngleRad;
130
131 char Tag[100];
132 };
133 cone_data *Cones;
134
135 double ConeGlobAstart;
136 double ConeGlobAend;
137
138 double ConeGlobTime_start;
139 double ConeGlobTime_end;
140
141 double ConeGlobComDistStart;
142 double ConeGlobComDistEnd;
143
144#endif
145
146 struct boxlist
147 {
148 int i, j, k; /* displacement of principal box */
149 double Rmin; /* minimum comoving distance of this box */
150 double Rmax; /* minimum comoving distance of this box */
151 };
152 boxlist *BoxList;
153 int NumBoxes;
154 int NumLastCheck;
155
156 void lightcone_init_geometry(char *fname);
157 void lightcone_add_position_particles(particle_data *P, double *pos, double ascale);
158 int lightcone_init_times(void);
159 bool lightcone_is_cone_member(int i, int cone);
160 bool lightcone_is_cone_member_basic(double ascale, vector<double> &pos, bool previously, int cone);
161
162 bool lightcone_box_at_corner_overlaps_at_least_with_one_cone(double *corner, double &rmin, double &rmax);
163 void lightcone_clear_boxlist(double ascale);
164
165 static bool lightcone_compare_BoxList_Rmax(const boxlist &a, const boxlist &b)
166 {
167 return a.Rmax > b.Rmax; /* sort in descending order */
168 }
169
170#ifdef LIGHTCONE_MASSMAPS
171
172 double *MassMap;
173
174 int NumMassMapBoundaries;
175 double *MassMapBoundariesAscale;
176 integertime *MassMapBoundariesTime;
177 double *MassMapBoundariesComDist;
178
179 void lightcone_init_massmaps(void);
180 void lightcone_massmap_binning(void);
181 void lightcone_massmap_flush(int dump_allowed_flag);
182 int lightcone_add_position_massmaps(particle_data *P, double *pos, double ascale);
183 int lightcone_massmap_report_boundaries(void);
184
185 static bool compare_doubles(const double &a, const double &b) { return a < b; }
186#endif
187};
188
189#endif
190#endif
int integertime
Definition: constants.h:331