Cholla 3.0.1-dev
Cholla - Massively parallel hydro on GPUs
Loading...
Searching...
No Matches
grav3D.h
1#ifndef GRAV3D_H
2#define GRAV3D_H
3
4#include <stdio.h>
5
6#include "../global/global.h"
7#include "../grid/spatial_domain_props.h"
8#include "../io/FnameTemplate.h"
9
10#ifdef SOR
11 #include "../gravity/potential_SOR_3D.h"
12#endif
13
14#ifdef PARIS
15 #include "../gravity/potential_paris_3D.h"
16#endif
17
18#ifdef PARIS_GALACTIC
19 #include "../gravity/potential_paris_galactic.h"
20#endif
21
22#ifdef HDF5
23 #include <hdf5.h>
24#endif
25
26#define GRAV_ISOLATED_BOUNDARY_X
27#define GRAV_ISOLATED_BOUNDARY_Y
28#define GRAV_ISOLATED_BOUNDARY_Z
29
30#define TPB_GRAV 1024
31#define TPBX_GRAV 16
32#define TPBY_GRAV 8
33#define TPBZ_GRAV 8
34
37class Grav3D
38{
39 public:
40 Real Lbox_x;
41 Real Lbox_y;
42 Real Lbox_z;
43
44 Real xMin;
45 Real yMin;
46 Real zMin;
47 Real xMax;
48 Real yMax;
49 Real zMax;
52 int nx_total;
55 int ny_total;
58 int nz_total;
59
69
72 Real dx;
75 Real dy;
78 Real dz;
79
80#ifdef COSMOLOGY
81 Real current_a;
82#endif
83
84 Real dens_avrg;
85
86 int n_cells;
87 int n_cells_potential;
88
89 bool INITIAL;
90
91 Real dt_prev;
92 Real dt_now;
93
94 Real Gconst;
95
96 bool TRANSFER_POTENTIAL_BOUNDARIES;
97
98 bool BC_FLAGS_SET;
99 int *boundary_flags;
100
101#ifdef SOR
102 Potential_SOR_3D Poisson_solver;
103#endif
104
105#ifdef PARIS
106 PotentialParis3D Poisson_solver;
107#endif
108
109#ifdef PARIS_GALACTIC
110 #ifdef SOR
111 #define PARIS_GALACTIC_TEST
112 PotentialParisGalactic Poisson_solver_test;
113 #else
114 PotentialParisGalactic Poisson_solver;
115 #endif
116#endif
117
118 struct Fields {
122
127
131 Real *potential_1_h;
132
136 Real *analytic_potential_h;
137
138#ifdef GRAVITY_GPU
139
142 Real *density_d;
143
147 Real *potential_d;
148
152 Real *potential_1_d;
153
157 Real *analytic_potential_d;
158
159#endif // GRAVITY_GPU
160
161// Arrays for computing the potential values in isolated boundaries
162#ifdef GRAV_ISOLATED_BOUNDARY_X
163 Real *pot_boundary_x0;
164 Real *pot_boundary_x1;
165#endif
166#ifdef GRAV_ISOLATED_BOUNDARY_Y
167 Real *pot_boundary_y0;
168 Real *pot_boundary_y1;
169#endif
170#ifdef GRAV_ISOLATED_BOUNDARY_Z
171 Real *pot_boundary_z0;
172 Real *pot_boundary_z1;
173#endif
174
175#ifdef GRAVITY_GPU
176 #ifdef GRAV_ISOLATED_BOUNDARY_X
177 Real *pot_boundary_x0_d;
178 Real *pot_boundary_x1_d;
179 #endif
180 #ifdef GRAV_ISOLATED_BOUNDARY_Y
181 Real *pot_boundary_y0_d;
182 Real *pot_boundary_y1_d;
183 #endif
184 #ifdef GRAV_ISOLATED_BOUNDARY_Z
185 Real *pot_boundary_z0_d;
186 Real *pot_boundary_z1_d;
187 #endif
188#endif // GRAVITY_GPU
189
190 } F;
191
194 Grav3D(void);
195
198 void Initialize(const SpatialDomainProps &spatial_props, Real Lx, Real Ly, Real Lz, int n_ghost_pot_offset,
199 Parameters *P);
200
201 void AllocateMemory_CPU(void);
202 void Initialize_values_CPU();
203 void FreeMemory_CPU(void);
204
205 void Read_Restart_HDF5(struct Parameters *P, int nfile);
206 void Write_Restart_HDF5(struct Parameters *P, int nfile, const FnameTemplate &fname_template);
207
208 Real Get_Average_Density();
209 Real Get_Average_Density_function(int g_start, int g_end);
210
211 void Set_Boundary_Flags(int *flags);
212
213#ifdef SOR
214 void Copy_Isolated_Boundary_To_GPU_buffer(Real *isolated_boundary_h, Real *isolated_boundary_d, int boundary_size);
215 void Copy_Isolated_Boundaries_To_GPU(struct Parameters *P);
216#endif
217
218#ifdef GRAVITY_GPU
219 void AllocateMemory_GPU(void);
220 void FreeMemory_GPU(void);
221#endif
222};
223
224#endif // GRAV3D_H
Definition FnameTemplate.h:43
Definition grav3D.h:38
int nz_local
Local number of cells in the z-dimension.
Definition grav3D.h:68
Real dy
y-width of cells
Definition grav3D.h:75
int nx_local
Local number of cells in the x-dimension.
Definition grav3D.h:62
Real dz
z-width of cells
Definition grav3D.h:78
Grav3D(void)
Constructor for the gravity class.
int ny_local
Local number of cells in the y-dimension.
Definition grav3D.h:65
Real dx
x-width of cells
Definition grav3D.h:72
void Initialize(const SpatialDomainProps &spatial_props, Real Lx, Real Ly, Real Lz, int n_ghost_pot_offset, Parameters *P)
Initialize the grid.
Definition grav3D.h:118
Real * density_h
Array containing the density of each cell in the grid.
Definition grav3D.h:121
Real * potential_h
Array containing the gravitational potential of each cell in the grid.
Definition grav3D.h:126
Definition global.h:217
Definition spatial_domain_props.h:14