Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
1cefa9b3
Commit
1cefa9b3
authored
Dec 19, 2017
by
Matthieu Schaller
Browse files
Make the hydro schemes compute the dirfted velocities themselves when collecting statistics.
parent
84423a50
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/hydro/Default/hydro.h
View file @
1cefa9b3
...
@@ -97,6 +97,23 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
...
@@ -97,6 +97,23 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
return
p
->
mass
;
return
p
->
mass
;
}
}
/**
* @brief Returns the velocities drifted to the current time of a particle.
*
* @param p The particle of interest
* @param xp The extended data of the particle.
* @param dt The time since the last kick.
* @param v (return) The velocities at the current time.
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_get_drifted_velocities
(
const
struct
part
*
restrict
p
,
const
struct
xpart
*
xp
,
float
dt
,
float
v
[
3
])
{
v
[
0
]
=
xp
->
v_full
[
0
]
+
p
->
a_hydro
[
0
]
*
dt
;
v
[
1
]
=
xp
->
v_full
[
1
]
+
p
->
a_hydro
[
1
]
*
dt
;
v
[
2
]
=
xp
->
v_full
[
2
]
+
p
->
a_hydro
[
2
]
*
dt
;
}
/**
/**
* @brief Returns the time derivative of internal energy of a particle
* @brief Returns the time derivative of internal energy of a particle
*
*
...
...
src/hydro/Gadget2/hydro.h
View file @
1cefa9b3
...
@@ -106,6 +106,23 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
...
@@ -106,6 +106,23 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
return
p
->
mass
;
return
p
->
mass
;
}
}
/**
* @brief Returns the velocities drifted to the current time of a particle.
*
* @param p The particle of interest
* @param xp The extended data of the particle.
* @param dt The time since the last kick.
* @param v (return) The velocities at the current time.
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_get_drifted_velocities
(
const
struct
part
*
restrict
p
,
const
struct
xpart
*
xp
,
float
dt
,
float
v
[
3
])
{
v
[
0
]
=
xp
->
v_full
[
0
]
+
p
->
a_hydro
[
0
]
*
dt
;
v
[
1
]
=
xp
->
v_full
[
1
]
+
p
->
a_hydro
[
1
]
*
dt
;
v
[
2
]
=
xp
->
v_full
[
2
]
+
p
->
a_hydro
[
2
]
*
dt
;
}
/**
/**
* @brief Returns the time derivative of internal energy of a particle
* @brief Returns the time derivative of internal energy of a particle
*
*
...
...
src/hydro/Gizmo/hydro.h
View file @
1cefa9b3
...
@@ -754,6 +754,18 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
...
@@ -754,6 +754,18 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
return
p
->
conserved
.
mass
;
return
p
->
conserved
.
mass
;
}
}
/**
* @brief Returns the velocities drifted to the current time of a particle.
*
* @param p The particle of interest
* @param xp The extended data of the particle.
* @param dt The time since the last kick.
* @param v (return) The velocities at the current time.
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_get_drifted_velocities
(
const
struct
part
*
restrict
p
,
const
struct
xpart
*
xp
,
float
dt
,
float
v
[
3
])
{}
/**
/**
* @brief Returns the density of a particle
* @brief Returns the density of a particle
*
*
...
...
src/hydro/Minimal/hydro.h
View file @
1cefa9b3
...
@@ -116,6 +116,23 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
...
@@ -116,6 +116,23 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
return
p
->
mass
;
return
p
->
mass
;
}
}
/**
* @brief Returns the velocities drifted to the current time of a particle.
*
* @param p The particle of interest
* @param xp The extended data of the particle.
* @param dt The time since the last kick.
* @param v (return) The velocities at the current time.
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_get_drifted_velocities
(
const
struct
part
*
restrict
p
,
const
struct
xpart
*
xp
,
float
dt
,
float
v
[
3
])
{
v
[
0
]
=
xp
->
v_full
[
0
]
+
p
->
a_hydro
[
0
]
*
dt
;
v
[
1
]
=
xp
->
v_full
[
1
]
+
p
->
a_hydro
[
1
]
*
dt
;
v
[
2
]
=
xp
->
v_full
[
2
]
+
p
->
a_hydro
[
2
]
*
dt
;
}
/**
/**
* @brief Returns the time derivative of internal energy of a particle
* @brief Returns the time derivative of internal energy of a particle
*
*
...
...
src/hydro/PressureEntropy/hydro.h
View file @
1cefa9b3
...
@@ -106,6 +106,23 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
...
@@ -106,6 +106,23 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
return
p
->
mass
;
return
p
->
mass
;
}
}
/**
* @brief Returns the velocities drifted to the current time of a particle.
*
* @param p The particle of interest
* @param xp The extended data of the particle.
* @param dt The time since the last kick.
* @param v (return) The velocities at the current time.
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_get_drifted_velocities
(
const
struct
part
*
restrict
p
,
const
struct
xpart
*
xp
,
float
dt
,
float
v
[
3
])
{
v
[
0
]
=
xp
->
v_full
[
0
]
+
p
->
a_hydro
[
0
]
*
dt
;
v
[
1
]
=
xp
->
v_full
[
1
]
+
p
->
a_hydro
[
1
]
*
dt
;
v
[
2
]
=
xp
->
v_full
[
2
]
+
p
->
a_hydro
[
2
]
*
dt
;
}
/**
/**
* @brief Returns the time derivative of internal energy of a particle
* @brief Returns the time derivative of internal energy of a particle
*
*
...
...
src/hydro/Shadowswift/hydro.h
View file @
1cefa9b3
...
@@ -544,6 +544,18 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
...
@@ -544,6 +544,18 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
return
p
->
conserved
.
mass
;
return
p
->
conserved
.
mass
;
}
}
/**
* @brief Returns the velocities drifted to the current time of a particle.
*
* @param p The particle of interest
* @param xp The extended data of the particle.
* @param dt The time since the last kick.
* @param v (return) The velocities at the current time.
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_get_drifted_velocities
(
const
struct
part
*
restrict
p
,
const
struct
xpart
*
xp
,
float
dt
,
float
v
[
3
])
{}
/**
/**
* @brief Returns the density of a particle
* @brief Returns the density of a particle
*
*
...
...
src/statistics.c
View file @
1cefa9b3
...
@@ -135,22 +135,11 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
...
@@ -135,22 +135,11 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
const
integertime_t
ti_end
=
get_integer_time_end
(
ti_current
,
p
->
time_bin
);
const
integertime_t
ti_end
=
get_integer_time_end
(
ti_current
,
p
->
time_bin
);
const
float
dt
=
(
ti_current
-
((
ti_begin
+
ti_end
)
/
2
))
*
timeBase
;
const
float
dt
=
(
ti_current
-
((
ti_begin
+
ti_end
)
/
2
))
*
timeBase
;
/* Get the total acceleration */
float
v
[
3
];
float
a_tot
[
3
]
=
{
p
->
a_hydro
[
0
],
p
->
a_hydro
[
1
],
p
->
a_hydro
[
2
]};
hydro_get_drifted_velocities
(
p
,
xp
,
dt
,
v
);
if
(
gp
!=
NULL
)
{
a_tot
[
0
]
+=
gp
->
a_grav
[
0
];
a_tot
[
1
]
+=
gp
->
a_grav
[
1
];
a_tot
[
2
]
+=
gp
->
a_grav
[
2
];
}
/* Extrapolate velocities to current time */
const
float
v
[
3
]
=
{
xp
->
v_full
[
0
]
+
a_tot
[
0
]
*
dt
,
xp
->
v_full
[
1
]
+
a_tot
[
1
]
*
dt
,
xp
->
v_full
[
2
]
+
a_tot
[
2
]
*
dt
};
const
float
m
=
hydro_get_mass
(
p
);
const
double
x
[
3
]
=
{
p
->
x
[
0
],
p
->
x
[
1
],
p
->
x
[
2
]};
const
double
x
[
3
]
=
{
p
->
x
[
0
],
p
->
x
[
1
],
p
->
x
[
2
]};
const
float
rho
=
hydro_get_density
(
p
);
const
float
m
=
hydro_get_mass
(
p
);
const
float
entropy
=
hydro_get_entropy
(
p
);
const
float
u_int
=
hydro_get_internal_energy
(
p
);
const
float
u_int
=
hydro_get_internal_energy
(
p
);
/* Collect mass */
/* Collect mass */
...
@@ -182,7 +171,7 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
...
@@ -182,7 +171,7 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
}
}
/* Collect entropy */
/* Collect entropy */
stats
.
entropy
+=
m
*
gas_
entropy
_from_internal_energy
(
rho
,
u_int
)
;
stats
.
entropy
+=
m
*
entropy
;
}
}
/* Now write back to memory */
/* Now write back to memory */
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment