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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
844e06ea
Commit
844e06ea
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Smoothing length time derivative computed correctly in the Gadget-2 case
parent
2b522851
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!136
Master
,
!90
Improved multi-timestep SPH
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/hydro/Default/hydro.h
+26
-3
26 additions, 3 deletions
src/hydro/Default/hydro.h
src/hydro/Gadget2/hydro.h
+1
-1
1 addition, 1 deletion
src/hydro/Gadget2/hydro.h
src/hydro/Gadget2/hydro_iact.h
+8
-1
8 additions, 1 deletion
src/hydro/Gadget2/hydro_iact.h
src/runner.c
+5
-0
5 additions, 0 deletions
src/runner.c
with
40 additions
and
5 deletions
src/hydro/Default/hydro.h
+
26
−
3
View file @
844e06ea
...
...
@@ -70,9 +70,10 @@ __attribute__((always_inline))
* and add the self-contribution term.
*
* @param p The particle to act upon
* @param time The current time
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_end_density
(
struct
part
*
p
)
{
INLINE
static
void
hydro_end_density
(
struct
part
*
p
,
float
time
)
{
/* Some smoothing length multiples. */
const
float
h
=
p
->
h
;
...
...
@@ -166,12 +167,15 @@ __attribute__((always_inline))
*
* @param p The particle
* @param xp The extended data of the particle
* @param dt The time-step over which to drift
* @param t0 The time at the start of the drift
* @param t1 The time at the end of the drift
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_predict_extra
(
struct
part
*
p
,
struct
xpart
*
xp
,
float
d
t
)
{
struct
part
*
p
,
struct
xpart
*
xp
,
float
t
0
,
float
t1
)
{
float
u
,
w
;
const
float
dt
=
t1
-
t0
;
/* Predict internal energy */
w
=
p
->
force
.
u_dt
/
p
->
u
*
dt
;
if
(
fabsf
(
w
)
<
0
.
01
f
)
/* 1st order expansion of exp(w) */
...
...
@@ -196,3 +200,22 @@ __attribute__((always_inline))
p
->
force
.
h_dt
*=
p
->
h
*
0
.
333333333
f
;
}
/**
* @brief Kick the additional variables
*
* @param p The particle to act upon
* @param dt The time-step for this kick
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_kick_extra
(
struct
part
*
p
,
float
dt
)
{}
/**
* @brief Converts hydro quantity of a particle
*
* Requires the density to be known
*
* @param p The particle to act upon
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_convert_quantities
(
struct
part
*
p
)
{}
This diff is collapsed.
Click to expand it.
src/hydro/Gadget2/hydro.h
+
1
−
1
View file @
844e06ea
...
...
@@ -203,7 +203,7 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_end_force
(
struct
part
*
p
)
{
p
->
entropy_dt
*=
(
const_hydro_gamma
-
1
.
f
)
*
powf
(
p
->
rho
,
-
(
const_hydro_gamma
-
1
.
f
));
}
...
...
This diff is collapsed.
Click to expand it.
src/hydro/Gadget2/hydro_iact.h
+
8
−
1
View file @
844e06ea
...
...
@@ -197,7 +197,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
const
float
r_inv
=
1
.
0
f
/
r
;
/* Get some values in local variables. */
//
const float mi = pi->mass;
const
float
mi
=
pi
->
mass
;
const
float
mj
=
pj
->
mass
;
const
float
rhoi
=
pi
->
rho
;
const
float
rhoj
=
pj
->
rho
;
...
...
@@ -280,6 +280,10 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
pj
->
a
[
1
]
+=
acc
*
dx
[
1
];
pj
->
a
[
2
]
+=
acc
*
dx
[
2
];
/* Get the time derivative for h. */
pi
->
force
.
h_dt
-=
mj
*
dvdr
/
rhoj
*
wi_dr
;
pj
->
force
.
h_dt
-=
mi
*
dvdr
/
rhoi
*
wj_dr
;
/* Update the signal velocity. */
pi
->
v_sig
=
fmaxf
(
pi
->
v_sig
,
v_sig
);
pj
->
v_sig
=
fmaxf
(
pj
->
v_sig
,
v_sig
);
...
...
@@ -366,6 +370,9 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
pi
->
a
[
1
]
-=
acc
*
dx
[
1
];
pi
->
a
[
2
]
-=
acc
*
dx
[
2
];
/* Get the time derivative for h. */
pi
->
force
.
h_dt
-=
mj
*
dvdr
/
rhoj
*
wi_dr
;
/* Update the signal velocity. */
pi
->
v_sig
=
fmaxf
(
pi
->
v_sig
,
v_sig
);
...
...
This diff is collapsed.
Click to expand it.
src/runner.c
+
5
−
0
View file @
844e06ea
...
...
@@ -851,8 +851,13 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
if
(
is_fixdt
||
p
->
t_end
<=
t_current
)
{
/* First, finish the force loop */
p
->
force
.
h_dt
*=
p
->
h
*
0
.
333333333
f
;
/* And do the same of the extra variable */
hydro_end_force
(
p
);
/* Now we are ready to compute the next time-step size */
if
(
is_fixdt
)
{
/* Now we have a time step, proceed with the kick */
...
...
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
register
or
sign in
to comment