Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
8534b6d7
Commit
8534b6d7
authored
Aug 15, 2019
by
Loic Hausammann
Browse files
Options
Downloads
Patches
Plain Diff
PU: add update_soundspeed and remove computation in get_comoving_soundspeed
parent
19490f8e
No related branches found
No related tags found
1 merge request
!885
Gear merge pressure floor and GEAR star formation
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/hydro/PressureEnergy/hydro.h
+27
-21
27 additions, 21 deletions
src/hydro/PressureEnergy/hydro.h
with
27 additions
and
21 deletions
src/hydro/PressureEnergy/hydro.h
+
27
−
21
View file @
8534b6d7
...
@@ -212,21 +212,33 @@ hydro_get_drifted_physical_entropy(const struct part *restrict p,
...
@@ -212,21 +212,33 @@ hydro_get_drifted_physical_entropy(const struct part *restrict p,
return
gas_entropy_from_internal_energy
(
p
->
rho
,
p
->
u
);
return
gas_entropy_from_internal_energy
(
p
->
rho
,
p
->
u
);
}
}
/**
/**
* @brief
Returns the comoving
sound speed of a particle
* @brief
Update the
sound speed of a particle
*
*
* @param p The particle of interest
* @param p The particle of interest.
* @param cosmo The cosmological model.
*/
*/
__attribute__
((
always_inline
))
INLINE
static
float
__attribute__
((
always_inline
))
INLINE
static
void
hydro_get_comoving_soundspeed
(
const
struct
part
*
restrict
p
)
{
hydro_update_soundspeed
(
struct
part
*
restrict
p
,
const
struct
cosmology
*
cosmo
)
{
/* Compute the sound speed -- see theory section for justification */
/* Compute the sound speed -- see theory section for justification */
/* IDEAL GAS ONLY -- P-U does not work with generic EoS. */
/* IDEAL GAS ONLY -- P-U does not work with generic EoS. */
const
float
comoving_pressure
=
const
float
comoving_pressure
=
pressure_floor_get_comoving_pressure
(
p
,
p
->
rho
,
p
->
pressure_bar
);
pressure_floor_get_comoving_pressure
(
p
,
p
->
pressure_bar
,
cosmo
);
const
float
square_rooted
=
sqrtf
(
hydro_gamma
*
comoving_pressure
/
p
->
rho
);
p
->
force
.
soundspeed
=
sqrtf
(
hydro_gamma
*
comoving_pressure
/
p
->
rho
);
}
/**
* @brief Returns the comoving sound speed of a particle
*
* @param p The particle of interest.
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_comoving_soundspeed
(
const
struct
part
*
restrict
p
)
{
return
square_root
ed
;
return
p
->
force
.
soundspe
ed
;
}
}
/**
/**
...
@@ -418,11 +430,8 @@ hydro_set_drifted_physical_internal_energy(struct part *p,
...
@@ -418,11 +430,8 @@ hydro_set_drifted_physical_internal_energy(struct part *p,
/* Now recompute the extra quantities */
/* Now recompute the extra quantities */
/* Compute the sound speed */
const
float
soundspeed
=
hydro_get_comoving_soundspeed
(
p
);
/* Update variables. */
/* Update variables. */
p
->
force
.
soundspeed
=
soundspeed
;
hydro_update_soundspeed
(
p
,
cosmo
)
;
}
}
/**
/**
...
@@ -631,6 +640,7 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
...
@@ -631,6 +640,7 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
const
float
abs_div_v
=
fabsf
(
p
->
density
.
div_v
);
const
float
abs_div_v
=
fabsf
(
p
->
density
.
div_v
);
/* Compute the sound speed -- see theory section for justification */
/* Compute the sound speed -- see theory section for justification */
hydro_update_soundspeed
(
p
,
cosmo
);
const
float
soundspeed
=
hydro_get_comoving_soundspeed
(
p
);
const
float
soundspeed
=
hydro_get_comoving_soundspeed
(
p
);
/* Compute the Balsara switch */
/* Compute the Balsara switch */
...
@@ -646,11 +656,10 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
...
@@ -646,11 +656,10 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
/* Get the pressures */
/* Get the pressures */
const
float
comoving_pressure_with_floor
=
const
float
comoving_pressure_with_floor
=
pressure_floor_get_comoving_pressure
(
p
,
p
->
rho
,
p
->
pressure_bar
);
pressure_floor_get_comoving_pressure
(
p
,
p
->
pressure_bar
,
cosmo
);
/* Update variables. */
/* Update variables. */
p
->
force
.
f
=
grad_h_term
;
p
->
force
.
f
=
grad_h_term
;
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
balsara
=
balsara
;
p
->
force
.
balsara
=
balsara
;
p
->
force
.
pressure_bar_with_floor
=
comoving_pressure_with_floor
;
p
->
force
.
pressure_bar_with_floor
=
comoving_pressure_with_floor
;
}
}
...
@@ -685,7 +694,8 @@ __attribute__((always_inline)) INLINE static void hydro_reset_acceleration(
...
@@ -685,7 +694,8 @@ __attribute__((always_inline)) INLINE static void hydro_reset_acceleration(
* @param xp The extended data of this particle.
* @param xp The extended data of this particle.
*/
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_reset_predicted_values
(
__attribute__
((
always_inline
))
INLINE
static
void
hydro_reset_predicted_values
(
struct
part
*
restrict
p
,
const
struct
xpart
*
restrict
xp
)
{
struct
part
*
restrict
p
,
const
struct
xpart
*
restrict
xp
,
const
struct
cosmology
*
cosmo
)
{
/* Re-set the predicted velocities */
/* Re-set the predicted velocities */
p
->
v
[
0
]
=
xp
->
v_full
[
0
];
p
->
v
[
0
]
=
xp
->
v_full
[
0
];
...
@@ -696,9 +706,7 @@ __attribute__((always_inline)) INLINE static void hydro_reset_predicted_values(
...
@@ -696,9 +706,7 @@ __attribute__((always_inline)) INLINE static void hydro_reset_predicted_values(
p
->
u
=
xp
->
u_full
;
p
->
u
=
xp
->
u_full
;
/* Compute the sound speed */
/* Compute the sound speed */
const
float
soundspeed
=
hydro_get_comoving_soundspeed
(
p
);
hydro_update_soundspeed
(
p
,
cosmo
);
p
->
force
.
soundspeed
=
soundspeed
;
}
}
/**
/**
...
@@ -761,13 +769,11 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
...
@@ -761,13 +769,11 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
}
}
/* Compute the new sound speed */
/* Compute the new sound speed */
const
float
soundspeed
=
hydro_get_comoving_soundspeed
(
p
);
hydro_update_soundspeed
(
p
,
cosmo
);
p
->
force
.
soundspeed
=
soundspeed
;
/* update the required variables */
/* update the required variables */
const
float
comoving_pressure_with_floor
=
const
float
comoving_pressure_with_floor
=
pressure_floor_get_comoving_pressure
(
p
,
p
->
rho
,
p
->
pressure_bar
);
pressure_floor_get_comoving_pressure
(
p
,
p
->
pressure_bar
,
cosmo
);
p
->
force
.
pressure_bar_with_floor
=
comoving_pressure_with_floor
;
p
->
force
.
pressure_bar_with_floor
=
comoving_pressure_with_floor
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
sign in
to comment