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
*/
28
struct
sph_particle_data_hydrocore
29
{
30
MyFloat
Hsml
;
31
MyFloat
DhsmlDensityFactor
;
32
MyFloat
VelPred
[3];
34
MyFloat
DivVel
;
35
MyFloat
CurlVel
;
36
MyFloat
Csnd
;
37
38
MyFloat
Density
;
39
MyFloat
Pressure
;
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
54
struct
sph_particle_data
:
public
sph_particle_data_hydrocore
55
{
56
MyFloat
Entropy
;
57
MyFloat
EntropyPred
;
59
MyFloat
HydroAccel
[3];
60
#ifdef HIERARCHICAL_GRAVITY
61
MyFloat
FullGravAccel[3];
62
#endif
63
MyFloat
DtEntropy
;
64
MyFloat
DtDensity
;
65
MyFloat
DtHsml
;
67
MyFloat
NumNgb
;
70
MyFloat
Rot
[3];
72
MyFloat
MaxSignalVel
;
73
MyFloat
CurrentMaxTiStep
;
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
117
inline
MyFloat
get_sound_speed
(
void
)
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
{
141
Pressure
=
get_pressure
();
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
NUMDIMS
#define NUMDIMS
Definition:
constants.h:369
GAMMA
#define GAMMA
Definition:
constants.h:99
MyFloat
float MyFloat
Definition:
dtypes.h:86
MyReal
double MyReal
Definition:
dtypes.h:82
Terminate
#define Terminate(...)
Definition:
macros.h:15
half_float::detail::pow
expr pow(half base, half exp)
Definition:
half.hpp:2803
half_float::detail::sqrt
expr sqrt(half arg)
Definition:
half.hpp:2777
sph_particle_data_hydrocore
Definition:
sph_particle_data.h:29
sph_particle_data_hydrocore::DivVel
MyFloat DivVel
Definition:
sph_particle_data.h:34
sph_particle_data_hydrocore::Density
MyFloat Density
Definition:
sph_particle_data.h:38
sph_particle_data_hydrocore::Hsml
MyFloat Hsml
Definition:
sph_particle_data.h:30
sph_particle_data_hydrocore::DhsmlDensityFactor
MyFloat DhsmlDensityFactor
Definition:
sph_particle_data.h:31
sph_particle_data_hydrocore::Csnd
MyFloat Csnd
Definition:
sph_particle_data.h:36
sph_particle_data_hydrocore::VelPred
MyFloat VelPred[3]
Definition:
sph_particle_data.h:32
sph_particle_data_hydrocore::Pressure
MyFloat Pressure
Definition:
sph_particle_data.h:39
sph_particle_data_hydrocore::CurlVel
MyFloat CurlVel
Definition:
sph_particle_data.h:35
sph_particle_data
Definition:
sph_particle_data.h:55
sph_particle_data::Rot
MyFloat Rot[3]
Definition:
sph_particle_data.h:70
sph_particle_data::get_sound_speed
MyFloat get_sound_speed(void)
Definition:
sph_particle_data.h:117
sph_particle_data::MaxSignalVel
MyFloat MaxSignalVel
Definition:
sph_particle_data.h:72
sph_particle_data::get_pressure
MyFloat get_pressure(void)
Definition:
sph_particle_data.h:130
sph_particle_data::DtEntropy
MyFloat DtEntropy
Definition:
sph_particle_data.h:63
sph_particle_data::set_thermodynamic_variables
void set_thermodynamic_variables(void)
Definition:
sph_particle_data.h:139
sph_particle_data::HydroAccel
MyFloat HydroAccel[3]
Definition:
sph_particle_data.h:59
sph_particle_data::CurrentMaxTiStep
MyFloat CurrentMaxTiStep
Definition:
sph_particle_data.h:73
sph_particle_data::Entropy
MyFloat Entropy
Definition:
sph_particle_data.h:56
sph_particle_data::NumNgb
MyFloat NumNgb
Definition:
sph_particle_data.h:67
sph_particle_data::DtHsml
MyFloat DtHsml
Definition:
sph_particle_data.h:65
sph_particle_data::get_Hsml
MyFloat get_Hsml()
Definition:
sph_particle_data.h:149
sph_particle_data::EntropyPred
MyFloat EntropyPred
Definition:
sph_particle_data.h:57
sph_particle_data::DtDensity
MyFloat DtDensity
Definition:
sph_particle_data.h:64
src
data
sph_particle_data.h
Generated by
1.9.2