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
16fce7e4
Commit
16fce7e4
authored
Mar 02, 2016
by
Matthieu Schaller
Browse files
Safely exit in engine_init() when the minimal and maximal time-steps are badly chosen
parent
56e187d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/engine.c
View file @
16fce7e4
...
...
@@ -285,7 +285,6 @@ void engine_redistribute(struct engine *e) {
#endif
}
/**
* @brief Repartition the cells amongst the nodes.
*
...
...
@@ -1393,7 +1392,7 @@ void engine_init_particles(struct engine *e) {
struct
space
*
s
=
e
->
s
;
if
(
e
->
nodeID
==
0
)
message
(
"Initialising particles"
);
if
(
e
->
nodeID
==
0
)
message
(
"Initialising particles"
);
/* Make sure all particles are ready to go */
/* i.e. clean-up any stupid state in the ICs */
...
...
@@ -1831,7 +1830,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
int
home
=
numa_node_of_cpu
(
sched_getcpu
()),
half
=
nr_cores
/
2
;
bool
done
=
false
,
swap_hyperthreads
=
hyperthreads_present
();
if
(
swap_hyperthreads
&&
nodeID
==
0
)
message
(
"prefer physical cores to hyperthreads"
);
message
(
"prefer physical cores to hyperthreads"
);
while
(
!
done
)
{
done
=
true
;
...
...
@@ -1928,15 +1927,13 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
engine_print_policy
(
e
);
/* Print information about the hydro scheme */
if
(
e
->
nodeID
==
0
)
message
(
"Hydrodynamic scheme: %s"
,
SPH_IMPLEMENTATION
);
if
(
e
->
nodeID
==
0
)
message
(
"Hydrodynamic scheme: %s"
,
SPH_IMPLEMENTATION
);
/* Deal with timestep */
e
->
timeBase
=
(
timeEnd
-
timeBegin
)
/
max_nr_timesteps
;
e
->
ti_current
=
0
;
if
(
e
->
nodeID
==
0
)
message
(
"Absolute minimal timestep size: %e"
,
e
->
timeBase
);
/* Fixed time-step case */
if
((
e
->
policy
&
engine_policy_fixdt
)
==
engine_policy_fixdt
)
{
e
->
dt_min
=
e
->
dt_max
;
...
...
@@ -1947,11 +1944,32 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
e
->
dt_min
=
e
->
dt_max
=
dti_timeline
*
e
->
timeBase
;
if
(
e
->
nodeID
==
0
)
message
(
"Timestep set to %e"
,
e
->
dt_max
);
}
else
{
if
(
e
->
nodeID
==
0
)
{
message
(
"Absolute minimal timestep size: %e"
,
e
->
timeBase
);
float
dt_min
=
timeEnd
-
timeBegin
;
while
(
dt_min
>
e
->
dt_min
)
dt_min
/=
2
.
f
;
message
(
"Minimal timestep size (on time-line): %e"
,
dt_min
);
float
dt_max
=
timeEnd
-
timeBegin
;
while
(
dt_max
>
e
->
dt_max
)
dt_max
/=
2
.
f
;
message
(
"Minimal timestep size (on time-line): %e"
,
dt_max
);
}
}
if
(
e
->
dt_min
<
e
->
timeBase
&&
e
->
nodeID
==
0
)
error
(
"Minimal timestep smaller than the absolue possible minimum dt=%e"
,
e
->
timeBase
);
error
(
"Minimal time-step size smaller than the absolue possible minimum "
"dt=%e"
,
e
->
timeBase
);
if
(
e
->
dt_max
>
(
e
->
timeEnd
-
e
->
timeBegin
)
&&
e
->
nodeID
==
0
)
error
(
"Maximal time-step size larger than the simulation run time t=%e"
,
e
->
timeEnd
-
e
->
timeBegin
);
/* Construct types for MPI communications */
#ifdef WITH_MPI
...
...
src/runner.c
View file @
16fce7e4
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
...
...
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