GADGET-4
sph.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 SPH_H
13#define SPH_H
14
15#include "../mpi_utils/shared_mem_handler.h"
16#include "../ngbtree/ngbtree.h"
17
18#define MAX_NGBS 500000
19
20class sph : public ngbtree
21{
22 public:
23 void compute_densities(void);
24 void density(int *targetlist, int ntarget);
25 void hydro_forces_determine(int ntarget, int *targetlist);
26 void tree_based_timesteps(void);
27
28#ifdef PRESSURE_ENTROPY_SPH
29 void setup_entropy_to_invgamma(void);
30#endif
31
32 double fac_mu;
33
34 private:
35 int max_ncycles;
36
37 double fac_vsic_fix;
38
39 double MaxBoxDist;
40
41#ifdef PRESERVE_SHMEM_BINARY_INVARIANCE
42 bool skip_actual_force_computation;
43#endif
44
45 struct pinfo
46 {
47 int target;
48 int numngb;
49
50 MyIntPosType *searchcenter;
51 MyIntPosType search_min[3], search_range[3];
52 MyIntPosType inthsml;
53 MyNgbTreeFloat hsml;
54 MyNgbTreeFloat hsml2;
55 };
56
57 inline void get_pinfo(int i, pinfo &pdat)
58 {
59 pdat.target = i;
60
61 pdat.searchcenter = Tp->P[i].IntPos;
62 pdat.hsml = Tp->SphP[i].Hsml;
63 pdat.hsml2 = pdat.hsml * pdat.hsml;
64 pdat.inthsml = pdat.hsml * Tp->FacCoordToInt;
65
66 for(int i = 0; i < 3; i++)
67 {
68 pdat.search_min[i] = pdat.searchcenter[i] - pdat.inthsml;
69 pdat.search_range[i] = pdat.inthsml + pdat.inthsml;
70 }
71
72 pdat.numngb = 0;
73 }
74
75 struct ngbdata_density
76 {
77 MyIntPosType *IntPos;
78 MyFloat *VelPred;
79 MyDouble Mass;
80#ifdef PRESSURE_ENTROPY_SPH
81 MyDouble EntropyToInvGammaPred;
82#endif
83#ifdef TIMEDEP_ART_VISC
84 MyDouble Csnd;
85#endif
86 };
87
88 ngbdata_density *Ngbdensdat;
89
90 struct ngbdata_hydro
91 {
92 MyIntPosType *IntPos;
94
95 MyDouble Mass;
96 signed char TimeBinHydro;
97 };
98
99 ngbdata_hydro *Ngbhydrodat;
100
101 inline foreign_sphpoint_data *get_foreignpointsp(int n, unsigned char shmrank)
102 {
103 return (foreign_sphpoint_data *)((char *)TreeSharedMemBaseAddr[shmrank] + TreeForeign_Points_offsets[shmrank]) + n;
104 }
105 void densities_determine(int ntarget, int *targetlist);
106 void density_evaluate_kernel(pinfo &pdat);
107 void sph_density_interact(pinfo &pdat, int no, char no_type, unsigned char shmrank, int mintopleafnode, int committed);
108 inline void sph_density_open_node(pinfo &pdat, ngbnode *nop, int mintopleafnode, int committed);
109 inline int sph_density_evaluate_particle_node_opening_criterion(pinfo &pdat, ngbnode *nop);
110 inline void sph_density_check_particle_particle_interaction(pinfo &pdat, int p, int p_type, unsigned char shmrank);
111 inline void clear_density_result(sph_particle_data *SphP);
112
113 void hydro_evaluate_kernel(pinfo &pdat);
114 inline void sph_hydro_interact(pinfo &pdat, int no, char no_type, unsigned char shmrank, int mintopleafnode, int committed);
115 inline void sph_hydro_open_node(pinfo &pdat, ngbnode *nop, int mintopleafnode, int committed);
116 inline int sph_hydro_evaluate_particle_node_opening_criterion(pinfo &pdat, ngbnode *nop);
117 inline void sph_hydro_check_particle_particle_interaction(pinfo &pdat, int p, int p_type, unsigned char shmrank);
118 inline void clear_hydro_result(sph_particle_data *SphP);
119
120 inline void sph_treetimestep_interact(pinfo &pdat, int no, char no_type, unsigned char shmrank, int mintopleafnode, int committed);
121 inline void sph_treetimestep_open_node(pinfo &pdat, ngbnode *nop, int mintopleafnode, int committed);
122 inline int sph_treetimestep_evaluate_particle_node_opening_criterion(pinfo &pdat, ngbnode *nop);
123 inline void sph_treetimestep_check_particle_particle_interaction(pinfo &pdat, int p, int p_type, unsigned char shmrank);
124
125#ifdef PRESSURE_ENTROPY_SPH
126 void init_entropy(void);
127#endif
128};
129
130#endif
MyReal FacCoordToInt
Definition: intposconvert.h:38
particle_data * P
Definition: simparticles.h:54
sph_particle_data * SphP
Definition: simparticles.h:59
Definition: sph.h:21
void compute_densities(void)
Definition: density.cc:410
void density(int *targetlist, int ntarget)
Definition: density.cc:434
void hydro_forces_determine(int ntarget, int *targetlist)
Definition: hydra.cc:271
void tree_based_timesteps(void)
double fac_mu
Definition: sph.h:32
float MyDouble
Definition: dtypes.h:87
float MyFloat
Definition: dtypes.h:86
uint32_t MyIntPosType
Definition: dtypes.h:35
float MyNgbTreeFloat
Definition: dtypes.h:88
MyIntPosType IntPos[3]
Definition: particle_data.h:53