GADGET-4
sph_particle_data.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 SPHPARTDATA_H
13 #define SPHPARTDATA_H
14 
15 #include "../data/constants.h"
16 #include "../data/dtypes.h"
17 #include "../data/intposconvert.h"
18 #include "../data/macros.h"
19 #include "../data/mymalloc.h"
20 #include "../mpi_utils/setcomm.h"
21 #include "../system/system.h"
22 #include "../time_integration/timestep.h"
23 
24 /* in this structure, all SPH variables are put that are needed for passive
25  * particles in the hydro force calculation. Only this part will be sent
26  * to other nodes if needed
27  */
29 {
37 
41 #ifdef TIMEDEP_ART_VISC
42  MyFloat Alpha;
43 #endif
44 #ifdef PRESSURE_ENTROPY_SPH
45  MyFloat EntropyToInvGammaPred;
46  MyFloat DhsmlDerivedDensityFactor;
47  MyFloat PressureSphDensity; /* current density derived from the pressure estimate */
48 #endif
49 };
50 
55 {
60 #ifdef HIERARCHICAL_GRAVITY
61  MyFloat FullGravAccel[3];
62 #endif
70  MyFloat Rot[3];
74 
75 #ifdef PRESSURE_ENTROPY_SPH
76  MyFloat
77  DtPressureSphDensity;
78 #endif
79 
80 #ifdef TIMEDEP_ART_VISC
81  MyFloat DivVelOld; /* local velocity gradient from the previous time step */
82  MyFloat decayVel; /* decay velocity for the viscosity parameter */
83 #endif
84 
85 #ifdef IMPROVED_VELOCITY_GRADIENTS
86  struct
87  {
88  MyFloat dx_dx;
89  MyFloat dx_dy;
90  MyFloat dx_dz;
91  MyFloat dy_dy;
92  MyFloat dy_dz;
93  MyFloat dz_dz;
94  } dpos; /* contains the matrix elements needed for the improved gradient estimate */
95 
96  MyFloat dvel[NUMDIMS][NUMDIMS]; /* contains the velocity gradients */
97 #endif
98 
99 #ifdef STARFORMATION
100  MyFloat Metallicity;
101  MyFloat MassMetallicity;
102 #endif
103 
104 #ifdef COOLING
105  MyFloat Ne;
107 #endif
108 
109 #ifdef OUTPUT_COOLHEAT
110  MyFloat CoolHeat;
111 #endif
112 
113 #ifdef STARFORMATION
114  MyFloat Sfr;
115 #endif
116 
118  {
119  MyFloat csnd;
120 
121  if(Density > 0)
122  csnd = sqrt(static_cast<MyReal>(GAMMA) * Pressure / Density);
123  else
124  csnd = 0;
125 
126  return csnd;
127  }
128 
129  /* compute the pressure of particle i */
130  inline MyFloat get_pressure(void)
131  {
132 #ifndef PRESSURE_ENTROPY_SPH
133  return EntropyPred * pow(Density, (MyFloat)GAMMA);
134 #else
135  return pow(EntropyToInvGammaPred * PressureSphDensity, GAMMA);
136 #endif
137  }
138 
139  inline void set_thermodynamic_variables(void)
140  {
142 
143  if(Pressure < 0)
144  Terminate("Pressure=%g rho=%g entr=%g entrpred=%g\n", Pressure, Density, Entropy, EntropyPred);
145 
146  Csnd = get_sound_speed();
147  }
148 
149  inline MyFloat get_Hsml() { return Hsml; }
150 
151 #ifdef IMPROVED_VELOCITY_GRADIENTS
152  void set_velocity_gradients(void);
153 #endif
154 
155 #ifdef TIMEDEP_ART_VISC
156  void set_viscosity_coefficient(double dt);
157 #endif
158 };
159 
160 #endif
#define NUMDIMS
Definition: constants.h:369
#define GAMMA
Definition: constants.h:99
float MyFloat
Definition: dtypes.h:86
double MyReal
Definition: dtypes.h:82
#define Terminate(...)
Definition: macros.h:19
expr pow(half base, half exp)
Definition: half.hpp:2803
expr sqrt(half arg)
Definition: half.hpp:2777
MyFloat get_sound_speed(void)
MyFloat get_pressure(void)
void set_thermodynamic_variables(void)