1#if defined(GRAVITY) && defined(SOR)
3 #ifndef POTENTIAL_SOR_3D_H
4 #define POTENTIAL_SOR_3D_H
8 #include "../global/global.h"
38 grav_int_t n_cells_local;
39 grav_int_t n_cells_potential;
40 grav_int_t n_cells_total;
47 bool TRANSFER_POISSON_BOUNDARIES;
51 bool potential_initialized;
65 Real *boundaries_buffer_x0_d;
66 Real *boundaries_buffer_x1_d;
67 Real *boundaries_buffer_y0_d;
68 Real *boundaries_buffer_y1_d;
69 Real *boundaries_buffer_z0_d;
70 Real *boundaries_buffer_z1_d;
72 Real *boundary_isolated_x0_d;
73 Real *boundary_isolated_x1_d;
74 Real *boundary_isolated_y0_d;
75 Real *boundary_isolated_y1_d;
76 Real *boundary_isolated_z0_d;
77 Real *boundary_isolated_z1_d;
80 Real *recv_boundaries_buffer_x0_d;
81 Real *recv_boundaries_buffer_x1_d;
82 Real *recv_boundaries_buffer_y0_d;
83 Real *recv_boundaries_buffer_y1_d;
84 Real *recv_boundaries_buffer_z0_d;
85 Real *recv_boundaries_buffer_z1_d;
90 Potential_SOR_3D(
void);
92 void Initialize(Real Lx, Real Ly, Real Lz, Real x_min, Real y_min, Real z_min,
int nx,
int ny,
int nz,
int nx_real,
93 int ny_real,
int nz_real, Real dx, Real dy, Real dz);
95 void AllocateMemory_CPU(
void);
96 void AllocateMemory_GPU(
void);
97 void FreeMemory_GPU(
void);
99 void Copy_Input(
int n_cells, Real *input_d, Real *input_density_h, Real Grav_Constant, Real dens_avrg,
102 void Copy_Output(Real *output_potential);
103 void Copy_Potential_From_Host(Real *output_potential);
105 void Set_Boundaries();
110 void Allocate_Array_GPU_Real(Real **array_dev, grav_int_t size);
111 void Allocate_Array_GPU_bool(
bool **array_dev, grav_int_t size);
112 void Free_Array_GPU_Real(Real *array_dev);
113 void Free_Array_GPU_bool(
bool *array_dev);
115 void Initialize_Potential(
int nx,
int ny,
int nz,
int n_ghost_potential, Real *potential_d, Real *density_d);
116 void Copy_Input_And_Initialize(Real *input_density,
const Real *input_potential, Real Grav_Constant, Real dens_avrg,
119 void Poisson_iteration(
int n_cells,
int nx,
int ny,
int nz,
int n_ghost_potential, Real dx, Real dy, Real dz,
120 Real omega, Real epsilon, Real *density_d, Real *potential_d,
bool *converged_h,
122 void Poisson_iteration_Patial_1(
int n_cells,
int nx,
int ny,
int nz,
int n_ghost_potential, Real dx, Real dy, Real dz,
123 Real omega, Real epsilon, Real *density_d, Real *potential_d,
bool *converged_h,
125 void Poisson_iteration_Patial_2(
int n_cells,
int nx,
int ny,
int nz,
int n_ghost_potential, Real dx, Real dy, Real dz,
126 Real omega, Real epsilon, Real *density_d, Real *potential_d,
bool *converged_h,
128 void Poisson_Partial_Iteration(
int n_step, Real omega, Real epsilon);
130 void Load_Transfer_Buffer_GPU(
int direction,
int side,
int nx,
int ny,
int nz,
int n_ghost_transfer,
131 int n_ghost_potential, Real *potential_d, Real *transfer_buffer_d);
132 void Load_Transfer_Buffer_Half_GPU(
int direction,
int side,
int nx,
int ny,
int nz,
int n_ghost_transfer,
133 int n_ghost_potential, Real *potential_d, Real *transfer_buffer_d);
134 void Load_Transfer_Buffer_GPU_x0();
135 void Load_Transfer_Buffer_GPU_x1();
136 void Load_Transfer_Buffer_GPU_y0();
137 void Load_Transfer_Buffer_GPU_y1();
138 void Load_Transfer_Buffer_GPU_z0();
139 void Load_Transfer_Buffer_GPU_z1();
140 void Unload_Transfer_Buffer_GPU(
int direction,
int side,
int nx,
int ny,
int nz,
int n_ghost_transfer,
141 int n_ghost_potential, Real *potential_d, Real *transfer_buffer_d);
142 void Unload_Transfer_Buffer_Half_GPU(
int direction,
int side,
int nx,
int ny,
int nz,
int n_ghost_transfer,
143 int n_ghost_potential, Real *potential_d, Real *transfer_buffer_d);
144 void Unload_Transfer_Buffer_GPU_x0();
145 void Unload_Transfer_Buffer_GPU_x1();
146 void Unload_Transfer_Buffer_GPU_y0();
147 void Unload_Transfer_Buffer_GPU_y1();
148 void Unload_Transfer_Buffer_GPU_z0();
149 void Unload_Transfer_Buffer_GPU_z1();
151 void Copy_Poisson_Boundary_Periodic(
int direction,
int side);
153 void Copy_Poisson_Boundary_Open(
int direction,
int side);
158 void Copy_Transfer_Buffer_To_Host(
int size_buffer, Real *transfer_bufer_h, Real *transfer_buffer_d);
159 void Copy_Transfer_Buffer_To_Device(
int size_buffer, Real *transfer_bufer_h, Real *transfer_buffer_d);
161 void Set_Isolated_Boundary_Conditions(
int *boundary_flags,
struct Parameters *P);
162 void Set_Isolated_Boundary_GPU(
int direction,
int side, Real *boundary_d);
165 bool Get_Global_Converged(
bool converged_local);