Skip to content
GitLab
Menu
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
9d579c4b
Commit
9d579c4b
authored
Dec 26, 2016
by
Matthieu Schaller
Browse files
Can now get the first few time-steps with a correct size.
parent
5d91cae2
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
9d579c4b
...
...
@@ -715,7 +715,7 @@ void cell_clean_links(struct cell *c, void *data) {
*/
void
cell_check_drift_point
(
struct
cell
*
c
,
void
*
data
)
{
integertime_t
ti_current
=
*
(
int
*
)
data
;
integertime_t
ti_current
=
*
(
int
egertime_t
*
)
data
;
if
(
c
->
ti_old
!=
ti_current
&&
c
->
nodeID
==
engine_rank
)
error
(
"Cell in an incorrect time-zone! c->ti_old=%lld ti_current=%lld"
,
...
...
src/const.h
View file @
9d579c4b
...
...
@@ -59,4 +59,6 @@
#define SOURCETERMS_NONE
//#define SOURCETERMS_SN_FEEDBACK
#define ICHECK 116650
#endif
/* SWIFT_CONST_H */
src/drift.h
View file @
9d579c4b
...
...
@@ -39,8 +39,8 @@
* @param ti_current Integer end of time-step
*/
__attribute__
((
always_inline
))
INLINE
static
void
drift_gpart
(
struct
gpart
*
restrict
gp
,
float
dt
,
double
timeBase
,
int
ti_old
,
int
ti_current
)
{
struct
gpart
*
restrict
gp
,
float
dt
,
double
timeBase
,
int
egertime_t
ti_old
,
int
egertime_t
ti_current
)
{
/* Drift... */
gp
->
x
[
0
]
+=
gp
->
v_full
[
0
]
*
dt
;
gp
->
x
[
1
]
+=
gp
->
v_full
[
1
]
*
dt
;
...
...
@@ -64,7 +64,7 @@ __attribute__((always_inline)) INLINE static void drift_gpart(
*/
__attribute__
((
always_inline
))
INLINE
static
void
drift_part
(
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
,
float
dt
,
double
timeBase
,
int
ti_old
,
int
ti_current
)
{
double
timeBase
,
int
egertime_t
ti_old
,
int
egertime_t
ti_current
)
{
/* Drift... */
p
->
x
[
0
]
+=
xp
->
v_full
[
0
]
*
dt
;
...
...
src/engine.c
View file @
9d579c4b
...
...
@@ -2683,9 +2683,14 @@ void engine_step(struct engine *e) {
engine_launch
(
e
,
e
->
nr_threads
);
TIMER_TOC
(
timer_runners
);
#ifdef SWIFT_DEBUG_CHECKS
for
(
size_t
i
=
0
;
i
<
e
->
s
->
nr_parts
;
++
i
)
{
if
(
e
->
s
->
parts
[
i
].
time_bin
==
0
)
error
(
"Particle in bin 0"
);
}
#endif
/* if(e->step > 2) */
/* error("Done"); */
/* Save some statistics */
if
(
e
->
time
-
e
->
timeLastStatistics
>=
e
->
deltaTimeStatistics
)
{
...
...
src/runner.c
View file @
9d579c4b
...
...
@@ -113,9 +113,6 @@ const char runner_flip[27] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
#include
"runner_doiact_fft.h"
#include
"runner_doiact_grav.h"
#undef ICHECK
#define ICHECK 116650
/**
* @brief Perform source terms
*
...
...
@@ -972,8 +969,6 @@ void runner_do_kick(struct runner *r, struct cell *c, int timer) {
if
(
timer
)
TIMER_TOC
(
timer_kick
);
}
#ifdef WITH_MPI
/**
* @brief Construct the cell properties from the received particles
*
...
...
@@ -1036,8 +1031,6 @@ void runner_do_recv_cell(struct runner *r, struct cell *c, int timer) {
if
(
timer
)
TIMER_TOC
(
timer_dorecv_cell
);
}
#endif
/* WITH_MPI */
/**
* @brief The #runner main thread routine.
*
...
...
src/runner_doiact_grav.h
View file @
9d579c4b
...
...
@@ -25,8 +25,6 @@
#include
"gravity.h"
#include
"part.h"
#define ICHECK -1000
/**
* @brief Compute the recursive upward sweep, i.e. construct the
* multipoles in a cell hierarchy.
...
...
src/space.c
View file @
9d579c4b
...
...
@@ -1988,7 +1988,7 @@ void space_link_cleanup(struct space *s) {
* @param s The #space to check.
* @param ti_current The (integer) time.
*/
void
space_check_drift_point
(
struct
space
*
s
,
int
ti_current
)
{
void
space_check_drift_point
(
struct
space
*
s
,
int
egertime_t
ti_current
)
{
/* Recursively check all cells */
space_map_cells_pre
(
s
,
1
,
cell_check_drift_point
,
&
ti_current
);
...
...
src/space.h
View file @
9d579c4b
...
...
@@ -185,7 +185,7 @@ void space_do_gparts_sort();
void
space_init_parts
(
struct
space
*
s
);
void
space_init_gparts
(
struct
space
*
s
);
void
space_link_cleanup
(
struct
space
*
s
);
void
space_check_drift_point
(
struct
space
*
s
,
int
ti_current
);
void
space_check_drift_point
(
struct
space
*
s
,
int
egertime_t
ti_current
);
void
space_clean
(
struct
space
*
s
);
#endif
/* SWIFT_SPACE_H */
src/timeline.h
View file @
9d579c4b
...
...
@@ -101,7 +101,7 @@ static INLINE integertime_t get_integer_time_end(integertime_t ti_current,
if
(
dti
==
0
)
return
0
;
else
return
dti
*
ceil
((
double
)
ti_current
/
(
double
)
dti
);
return
dti
*
ceil
l
((
double
)
ti_current
/
(
double
)
dti
);
}
/**
...
...
src/timestep.h
View file @
9d579c4b
...
...
@@ -35,30 +35,40 @@
* @param ti_current The current time on the integer time-line.
* @param timeBase_inv The inverse of the system's minimal time-step.
*/
__attribute__
((
always_inline
))
INLINE
static
int
make_
integer
_
time
step
(
float
new_dt
,
timebin_t
old_bin
,
integertime_t
ti_current
,
double
timeBase_inv
)
{
__attribute__
((
always_inline
))
INLINE
static
integertime
_t
make_integer_timestep
(
float
new_dt
,
timebin_t
old_bin
,
integertime_t
ti_current
,
double
timeBase_inv
,
int
verbose
)
{
/* Convert to integer time */
integertime_t
new_dti
=
(
integertime_t
)(
new_dt
*
timeBase_inv
);
if
(
verbose
)
message
(
"new_dti=%lld"
,
new_dti
);
/* Current time-step */
integertime_t
current_dti
=
get_integer_timestep
(
old_bin
);
integertime_t
ti_end
=
get_integer_time_end
(
ti_current
,
old_bin
);
if
(
verbose
)
message
(
"current_dti=%lld old_bin=%d ti_end=%lld"
,
current_dti
,
old_bin
,
ti_end
);
/* Limit timestep increase */
if
(
old_bin
>
0
)
new_dti
=
min
(
new_dti
,
2
*
current_dti
);
/* Put this timestep on the time line */
integertime_t
dti_timeline
=
max_nr_timesteps
;
while
(
new_dti
<
dti_timeline
)
dti_timeline
/=
2
;
while
(
new_dti
<
dti_timeline
)
dti_timeline
/=
2
LL
;
new_dti
=
dti_timeline
;
if
(
verbose
)
message
(
"new_dti=%lld"
,
new_dti
);
/* Make sure we are allowed to increase the timestep size */
if
(
new_dti
>
current_dti
)
{
if
((
max_nr_timesteps
-
ti_end
)
%
new_dti
>
0
)
new_dti
=
current_dti
;
}
if
(
verbose
)
message
(
"new_dti=%lld"
,
new_dti
);
return
new_dti
;
}
...
...
@@ -68,7 +78,7 @@ __attribute__((always_inline)) INLINE static int make_integer_timestep(
* @param gp The #gpart.
* @param e The #engine (used to get some constants).
*/
__attribute__
((
always_inline
))
INLINE
static
int
get_gpart_timestep
(
__attribute__
((
always_inline
))
INLINE
static
int
egertime_t
get_gpart_timestep
(
const
struct
gpart
*
restrict
gp
,
const
struct
engine
*
restrict
e
)
{
const
float
new_dt_external
=
external_gravity_timestep
(
...
...
@@ -86,7 +96,7 @@ __attribute__((always_inline)) INLINE static int get_gpart_timestep(
/* Convert to integer time */
const
integertime_t
new_dti
=
make_integer_timestep
(
new_dt
,
gp
->
time_bin
,
e
->
ti_current
,
e
->
timeBase_inv
);
new_dt
,
gp
->
time_bin
,
e
->
ti_current
,
e
->
timeBase_inv
,
0
);
return
new_dti
;
}
...
...
@@ -98,7 +108,7 @@ __attribute__((always_inline)) INLINE static int get_gpart_timestep(
* @param xp The #xpart partner of p.
* @param e The #engine (used to get some constants).
*/
__attribute__
((
always_inline
))
INLINE
static
int
get_part_timestep
(
__attribute__
((
always_inline
))
INLINE
static
int
egertime_t
get_part_timestep
(
const
struct
part
*
restrict
p
,
const
struct
xpart
*
restrict
xp
,
const
struct
engine
*
restrict
e
)
{
...
...
@@ -140,9 +150,13 @@ __attribute__((always_inline)) INLINE static int get_part_timestep(
new_dt
=
min
(
new_dt
,
e
->
dt_max
);
new_dt
=
max
(
new_dt
,
e
->
dt_min
);
if
(
p
->
id
==
ICHECK
)
message
(
"new_dt=%e"
,
new_dt
);
/* Convert to integer time */
const
integertime_t
new_dti
=
make_integer_timestep
(
new_dt
,
p
->
time_bin
,
e
->
ti_current
,
e
->
timeBase_inv
);
new_dt
,
p
->
time_bin
,
e
->
ti_current
,
e
->
timeBase_inv
,
p
->
id
==
ICHECK
);
if
(
p
->
id
==
ICHECK
)
message
(
"new_dti=%lld"
,
new_dti
);
return
new_dti
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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