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
28c96a8f
Commit
28c96a8f
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Corrected time-step evolution and better use of the fixdt policy in the kick task
parent
71bacd96
No related branches found
No related tags found
2 merge requests
!136
Master
,
!79
First version of the multiple time-stepping
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/engine.c
+0
-5
0 additions, 5 deletions
src/engine.c
src/runner.c
+27
-19
27 additions, 19 deletions
src/runner.c
with
27 additions
and
24 deletions
src/engine.c
+
0
−
5
View file @
28c96a8f
...
...
@@ -2169,11 +2169,6 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
/* Deal with timestep */
if
(
e
->
policy
&
engine_policy_fixdt
)
{
e
->
dt_min
=
e
->
dt_max
;
/* Put this timestep on the time line */
float
dt_timeline
=
e
->
timeEnd
-
e
->
timeBegin
;
while
(
e
->
dt_min
<
dt_timeline
)
dt_timeline
/=
2
.;
e
->
dt_min
=
e
->
dt_max
=
dt_timeline
;
}
/* Construct types for MPI communications */
...
...
This diff is collapsed.
Click to expand it.
src/runner.c
+
27
−
19
View file @
28c96a8f
...
...
@@ -850,6 +850,7 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
const
float
global_dt_min
=
r
->
e
->
dt_min
,
global_dt_max
=
r
->
e
->
dt_max
;
const
float
t_current
=
r
->
e
->
time
;
const
int
nr_parts
=
c
->
count
;
const
int
fixdt
=
r
->
e
->
policy
&
engine_policy_fixdt
;
int
count
=
0
,
updated
;
float
new_dt
=
0
.
0
f
,
new_dt_hydro
=
0
.
0
f
,
new_dt_grav
=
0
.
0
f
,
...
...
@@ -883,7 +884,7 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
x
[
0
]
=
p
->
x
[
0
],
x
[
1
]
=
p
->
x
[
1
],
x
[
2
]
=
p
->
x
[
2
];
/* If particle needs to be kicked */
if
(
p
->
t_end
<=
t_current
)
{
if
(
p
->
t_end
<=
t_current
||
fixdt
)
{
/* First, finish the force loop */
p
->
force
.
h_dt
*=
p
->
h
*
0
.
333333333
f
;
...
...
@@ -891,26 +892,34 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
/* Recover the current timestep */
current_dt
=
p
->
t_end
-
p
->
t_begin
;
/* Compute the next timestep */
new_dt_hydro
=
compute_timestep_hydro
(
p
,
xp
);
new_dt_grav
=
compute_timestep_grav
(
p
,
xp
);
if
(
fixdt
)
{
new_dt
=
fminf
(
new_dt_hydro
,
new_dt_grav
);
/* Limit timestep increase */
if
(
current_dt
>
0
.
0
f
)
new_dt
=
fminf
(
new_dt
,
2
.
0
f
*
current_dt
);
/* Now we have a time step, proceed with the kick */
new_dt
=
global_dt_max
;
}
else
{
/* Limit timestep within the allowed range */
new_dt
=
fminf
(
new_dt
,
global_dt_max
);
new_dt
=
fmaxf
(
new_dt
,
global_dt_min
);
/* Compute the next timestep */
new_dt_hydro
=
compute_timestep_hydro
(
p
,
xp
);
new_dt_grav
=
compute_timestep_grav
(
p
,
xp
);
new_dt
=
fminf
(
new_dt_hydro
,
new_dt_grav
);
/* Limit timestep increase */
if
(
current_dt
>
0
.
0
f
)
new_dt
=
fminf
(
new_dt
,
2
.
0
f
*
current_dt
);
/* Put this timestep on the time line */
dt_timeline
=
dt_max_timeline
;
while
(
new_dt
<
dt_timeline
)
dt_timeline
/=
2
.;
/* Now we have a time step, proceed with the kick */
new_dt
=
dt_timeline
;
/* Limit timestep within the allowed range */
new_dt
=
fminf
(
new_dt
,
global_dt_max
);
new_dt
=
fmaxf
(
new_dt
,
global_dt_min
);
/* Put this timestep on the time line */
dt_timeline
=
dt_max_timeline
;
while
(
new_dt
<
dt_timeline
)
dt_timeline
/=
2
.;
/* Now we have a time step, proceed with the kick */
new_dt
=
dt_timeline
;
}
/* Compute the time step for this kick */
t_start
=
0
.
5
f
*
(
p
->
t_begin
+
p
->
t_end
);
t_end
=
p
->
t_end
+
0
.
5
f
*
new_dt
;
...
...
@@ -918,8 +927,7 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) {
/* Move particle forward in time */
p
->
t_begin
=
p
->
t_end
;
p
->
t_end
=
p
->
t_begin
+
dt
;
p
->
t_end
=
p
->
t_begin
+
new_dt
;
/* Kick particles in momentum space */
xp
->
v_full
[
0
]
+=
p
->
a
[
0
]
*
dt
;
...
...
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