8 #include"mpi_routines.h" 19 #include"gravity/grav3D.h" 23 #include "particles/particles_3D.h" 27 #include"cosmology/cosmology.h" 30 #ifdef COOLING_GRACKLE 31 #include "cooling/cool_grackle.h" 35 #include "timing_functions.h" 203 #ifdef AVERAGE_SLOW_CELLS 221 Real temperature_floor;
226 bool TRANSFER_HYDRO_BOUNDARIES;
231 int n_ghost_potential_offset;
235 bool OUTPUT_SCALE_FACOR;
287 Particles_3D Particles;
295 #ifdef COOLING_GRACKLE 341 Real *Grav_potential;
357 void AllocateMemory(
void);
365 void Get_Position(
long i,
long j,
long k, Real *xpos, Real *ypos, Real *zpos);
369 void Set_Domain_Properties(
struct parameters P);
373 void set_dt(Real dti);
378 void set_dt_Gravity();
383 Real calc_dti_CPU_1D();
387 Real calc_dti_CPU_2D();
391 Real calc_dti_CPU_3D_function(
int g_start,
int g_end );
395 Real calc_dti_CPU_3D();
403 Real Update_Grid(
void);
407 Real Update_Hydro_Grid(
void);
413 void Write_Header_Binary(FILE *fp);
417 void Write_Grid_Binary(FILE *fp);
422 void Write_Header_HDF5(hid_t file_id);
426 void Write_Grid_HDF5(hid_t file_id);
430 void Write_Projection_HDF5(hid_t file_id);
434 void Write_Header_Rotated_HDF5(hid_t file_id);
438 void Write_Rotated_Projection_HDF5(hid_t file_id);
442 void Write_Slices_HDF5(hid_t file_id);
452 void Read_Grid_Binary(FILE *fp);
457 void Read_Grid_HDF5(hid_t file_id,
struct parameters P);
466 void FreeMemory(
void);
470 void Constant(Real rho, Real vx, Real vy, Real vz, Real P);
474 void Sound_Wave(Real rho, Real vx, Real vy, Real vz, Real P, Real A);
478 void Square_Wave(Real rho, Real vx, Real vy, Real vz, Real P, Real A);
482 void Riemann(Real rho_l, Real v_l, Real P_l, Real rho_r, Real v_r, Real P_r, Real diaph);
502 void Rayleigh_Taylor();
538 void Set_Boundary_Conditions_Grid(
parameters P);
542 int Check_Custom_Boundary(
int *flags,
struct parameters P);
546 void Set_Boundaries(
int dir,
int flags[]);
550 void Set_Boundary_Extents(
int dir,
int *imin,
int *imax);
555 int Set_Boundary_Mapping(
int ig,
int jg,
int kg,
int flags[], Real *a);
560 int Find_Index(
int ig,
int nx,
int flag,
int face, Real *a);
564 void Custom_Boundary(
char bcnd[MAXLEN]);
573 void Spherical_Overpressure_3D();
577 void Spherical_Overdensity_3D();
581 void Zeldovich_Pancake(
struct parameters P );
586 void Set_Boundaries_MPI_SLAB(
int *flags,
struct parameters P);
587 void Set_Boundaries_MPI_BLOCK(
int *flags,
struct parameters P);
588 void Set_Edge_Boundaries(
int dir,
int *flags);
589 void Set_Edge_Boundary_Extents(
int dir,
int edge,
int *imin,
int *imax);
590 void Load_and_Send_MPI_Comm_Buffers(
int dir,
int *flags);
591 void Load_and_Send_MPI_Comm_Buffers_SLAB(
int *flags);
592 void Load_and_Send_MPI_Comm_Buffers_BLOCK(
int dir,
int *flags);
593 void Wait_and_Unload_MPI_Comm_Buffers_SLAB(
int *flags);
594 void Wait_and_Unload_MPI_Comm_Buffers_BLOCK(
int dir,
int *flags);
595 void Unload_MPI_Comm_Buffers(
int index);
596 void Unload_MPI_Comm_Buffers_SLAB(
int index);
597 void Unload_MPI_Comm_Buffers_BLOCK(
int index);
598 int Load_Hydro_Buffer_X0();
599 int Load_Hydro_Buffer_X1();
600 int Load_Hydro_Buffer_Y0();
601 int Load_Hydro_Buffer_Y1();
602 int Load_Hydro_Buffer_Z0();
603 int Load_Hydro_Buffer_Z1();
607 void Initialize_Gravity(
struct parameters *P );
608 void Compute_Gravitational_Potential(
struct parameters *P );
609 void Copy_Hydro_Density_to_Gravity_Function(
int g_start,
int g_end);
610 void Copy_Hydro_Density_to_Gravity();
611 void Extrapolate_Grav_Potential_Function(
int g_start,
int g_end );
612 void Extrapolate_Grav_Potential();
613 void Copy_Potential_Boundaries(
int direction,
int side );
614 int Load_Gravity_Potential_To_Buffer(
int direction,
int side, Real *buffer,
int buffer_start );
615 void Unload_Gravity_Potential_from_Buffer(
int direction,
int side, Real *buffer,
int buffer_start );
619 void Initialize_Particles(
struct parameters *P );
620 void Initialize_Uniform_Particles();
621 void Copy_Particles_Density_function(
int g_start,
int g_end );
622 void Copy_Particles_Density();
623 void Copy_Particles_Density_to_Gravity(
struct parameters P);
624 void Copy_Particles_Density_Boundaries(
int direction,
int side );
625 void Transfer_Particles_Boundaries(
struct parameters P );
626 Real Update_Grid_and_Particles_KDK(
struct parameters P );
627 void Set_Particles_Boundary(
int dir,
int side);
629 int Load_Particles_Density_Boundary_to_Buffer(
int direction,
int side, Real *buffer );
630 void Unload_Particles_Density_Boundary_From_Buffer(
int direction,
int side, Real *buffer );
631 void Load_and_Send_Particles_X0(
int ireq_n_particles,
int ireq_particles_transfer );
632 void Load_and_Send_Particles_X1(
int ireq_n_particles,
int ireq_particles_transfer );
633 void Load_and_Send_Particles_Y0(
int ireq_n_particles,
int ireq_particles_transfer );
634 void Load_and_Send_Particles_Y1(
int ireq_n_particles,
int ireq_particles_transfer );
635 void Load_and_Send_Particles_Z0(
int ireq_n_particles,
int ireq_particles_transfer );
636 void Load_and_Send_Particles_Z1(
int ireq_n_particles,
int ireq_particles_transfer );
637 void Unload_Particles_from_Buffer_X0(
int *flags );
638 void Unload_Particles_from_Buffer_X1(
int *flags );
639 void Unload_Particles_from_Buffer_Y0(
int *flags );
640 void Unload_Particles_from_Buffer_Y1(
int *flags );
641 void Unload_Particles_from_Buffer_Z0(
int *flags );
642 void Unload_Particles_from_Buffer_Z1(
int *flags );
643 void Wait_NTransfer_and_Request_Recv_Particles_Transfer_BLOCK(
int dir,
int *flags);
644 void Load_NTtransfer_and_Request_Receive_Particles_Transfer(
int index,
int *ireq_particles_transfer);
645 void Wait_and_Unload_MPI_Comm_Particles_Buffers_BLOCK(
int dir,
int *flags);
646 void Unload_Particles_From_Buffers_BLOCK(
int index,
int *flags );
647 void Finish_Particles_Transfer();
649 void Transfer_Particles_Density_Boundaries(
struct parameters P );
651 void WriteData_Particles(
struct parameters P,
int nfile);
652 void OutputData_Particles(
struct parameters P,
int nfile);
653 void Load_Particles_Data(
struct parameters P);
655 void Write_Particles_Header_HDF5( hid_t file_id);
656 void Write_Particles_Data_HDF5( hid_t file_id);
657 void Load_Particles_Data_HDF5(hid_t file_id,
int nfile);
659 void Get_Gravity_Field_Particles_function(
int g_start,
int g_end );
660 void Get_Gravity_Field_Particles();
661 void Get_Gravity_CIC_function( part_int_t p_start, part_int_t p_end );
662 void Get_Gravity_CIC();
663 void Advance_Particles_KDK_Step1( );
664 void Advance_Particles_KDK_Step2( );
665 void Advance_Particles_KDK_Step1_function( part_int_t p_start, part_int_t p_end );
666 void Advance_Particles_KDK_Step2_function( part_int_t p_start, part_int_t p_end );
667 void Get_Particles_Acceleration();
668 void Advance_Particles(
int N_KDK_step );
669 Real Calc_Particles_dt_function( part_int_t p_start, part_int_t p_end );
670 Real Calc_Particles_dt();
672 Real Calc_Particles_dt_GPU();
673 void Advance_Particles_KDK_Step1_GPU();
674 void Advance_Particles_KDK_Step2_GPU();
675 void Set_Particles_Boundary_GPU(
int dir,
int side);
676 #endif//PARTICLES_GPU 680 void Initialize_Cosmology(
struct parameters *P );
681 void Change_DM_Frame_System(
bool forward );
682 void Change_GAS_Frame_System(
bool forward );
683 void Change_Cosmological_Frame_Sytem(
bool forward );
684 void Advance_Particles_KDK_Cosmo_Step1_function( part_int_t p_start, part_int_t p_end );
685 void Advance_Particles_KDK_Cosmo_Step2_function( part_int_t p_start, part_int_t p_end );
686 Real Calc_Particles_dt_Cosmo_function( part_int_t p_start, part_int_t p_end );
687 Real Calc_Particles_dt_Cosmo();
689 void Advance_Particles_KDK_Cosmo_Step1_GPU();
690 void Advance_Particles_KDK_Cosmo_Step2_GPU();
691 #endif//PARTICLES_GPU 694 #ifdef COOLING_GRACKLE 695 void Initialize_Grackle(
struct parameters *P );
696 void Allocate_Memory_Grackle();
697 void Initialize_Fields_Grackle();
698 void Copy_Fields_To_Grackle_function(
int g_start,
int g_end );
699 void Copy_Fields_To_Grackle();
700 void Update_Internal_Energy_function(
int g_start,
int g_end );
701 void Update_Internal_Energy();
702 void Do_Cooling_Step_Grackle();
int nz_min
Bottom most point in the projected image for this subvolume.
Definition: grid3D.h:58
Real phi
Rotation angle about y axis in simulation frame.
Definition: grid3D.h:74
int i_delta
number of output projection for delta rotation
Definition: grid3D.h:86
int nx
Number of pixels in x-dir of rotated, projected image.
Definition: grid3D.h:42
int flag_delta
output mode for box rotation
Definition: grid3D.h:98
Real * momentum_x
Array containing the momentum in the x direction of each cell in the grid.
Definition: grid3D.h:312
Real theta
Rotation angle about x axis in simulation frame.
Definition: grid3D.h:70
int flag_init
Initialization flag.
Definition: grid3D.h:258
Real ddelta_dt
rate of delta rotation
Definition: grid3D.h:94
Real delta
Rotation angle about z axis in simulation frame.
Definition: grid3D.h:66
Real * momentum_z
Array containing the momentum in the z direction of each cell in the grid.
Definition: grid3D.h:320
Real * density
Array containing the density of each cell in the grid.
Definition: grid3D.h:308
Real * Energy
Array containing the total Energy of each cell in the grid.
Definition: grid3D.h:324
int gflag
Flag that determines which buffer contains updated conserved variables.
Definition: grid3D.h:262
Real * buffer0
Buffer to hold conserved variable arrays.
Definition: grid3D.h:274
int nz_max
Top most point in the projected image for this subvolume.
Definition: grid3D.h:62
Class to create a the gravity object.
Definition: grid3D.h:252
Real n_delta
total number of output projection for delta rotation
Definition: grid3D.h:90
int nz
Number of pixels in z-dir of rotated, projected image.
Definition: grid3D.h:46
Real Lx
Physical x-dir size of projected image.
Definition: grid3D.h:78
Real * buffer1
Buffer to hold conserved variable arrays.
Definition: grid3D.h:278
int nx_max
Right most point in the projected image for this subvolume.
Definition: grid3D.h:54
Real Lz
Physical z-dir size of projected image.
Definition: grid3D.h:82
int nx_min
Left most point in the projected image for this subvolume.
Definition: grid3D.h:50
Real * momentum_y
Array containing the momentum in the y direction of each cell in the grid.
Definition: grid3D.h:316