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
08d09ee8
Commit
08d09ee8
authored
9 years ago
by
Peter W. Draper
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into time-in-seconds
Conflict: examples/main.c resolved
parents
b87545bc
d527f532
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!136
Master
,
!105
Show time in real milli seconds
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/main.c
+4
-4
4 additions, 4 deletions
examples/main.c
src/engine.c
+46
-9
46 additions, 9 deletions
src/engine.c
src/engine.h
+1
-1
1 addition, 1 deletion
src/engine.h
with
51 additions
and
14 deletions
examples/main.c
+
4
−
4
View file @
08d09ee8
...
...
@@ -167,7 +167,7 @@ int main(int argc, char *argv[]) {
case
'd'
:
if
(
sscanf
(
optarg
,
"%f"
,
&
dt_min
)
!=
1
)
error
(
"Error parsing minimal timestep."
);
if
(
myrank
==
0
)
message
(
"dt_min set to %e."
,
dt_m
ax
);
if
(
myrank
==
0
)
message
(
"dt_min set to %e."
,
dt_m
in
);
fflush
(
stdout
);
break
;
case
'e'
:
...
...
@@ -194,8 +194,8 @@ int main(int argc, char *argv[]) {
with_outputs
=
0
;
break
;
case
'P'
:
/* Partition type is one of "g", "m", "w", or "v"; "g" can be
* followed by three numbers defining the grid. */
/* Partition type is one of "g", "m", "w", or "v"; "g" can be
* followed by three numbers defining the grid. */
#ifdef WITH_MPI
switch
(
optarg
[
0
])
{
case
'g'
:
...
...
@@ -487,7 +487,7 @@ int main(int argc, char *argv[]) {
"[ms]
\n
"
);
/* Let loose a runner on the space. */
for
(
j
=
0
;
e
.
time
<
time_end
;
j
++
)
{
for
(
j
=
0
;
!
engine_is_done
(
&
e
)
;
j
++
)
{
/* Repartition the space amongst the nodes? */
#ifdef WITH_MPI
...
...
This diff is collapsed.
Click to expand it.
src/engine.c
+
46
−
9
View file @
08d09ee8
...
...
@@ -286,7 +286,6 @@ void engine_redistribute(struct engine *e) {
#endif
}
/**
* @brief Repartition the cells amongst the nodes.
*
...
...
@@ -1394,7 +1393,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 */
...
...
@@ -1631,6 +1630,13 @@ void engine_step(struct engine *e) {
// printParticle(e->s->parts, e->s->xparts,515050, e->s->nr_parts);
}
/**
* @brief Returns 1 if the simulation has reached its end point, 0 otherwise
*/
int
engine_is_done
(
struct
engine
*
e
)
{
return
!
(
e
->
ti_current
<
max_nr_timesteps
);
}
/**
* @brief Create and fill the proxies.
*
...
...
@@ -1837,7 +1843,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
;
...
...
@@ -1934,15 +1940,25 @@ 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
);
/* Check we have sensible time bounds */
if
(
timeBegin
>=
timeEnd
)
error
(
"Final simulation time (t_end = %e) must be larger than the start time "
"(t_beg = %e)"
,
timeEnd
,
timeBegin
);
/* Check we have sensible time step bounds */
if
(
e
->
dt_min
>
e
->
dt_max
)
error
(
"Minimal time step size must be smaller than maximal time step size "
);
/* 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
;
...
...
@@ -1953,11 +1969,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
(
"Maximal 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 absolute 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
...
...
This diff is collapsed.
Click to expand it.
src/engine.h
+
1
−
1
View file @
08d09ee8
...
...
@@ -63,7 +63,6 @@ extern const char *engine_policy_names[];
#define engine_maxproxies 64
#define engine_tasksreweight 10
/* The rank of the engine as a global variable (for messages). */
extern
int
engine_rank
;
...
...
@@ -186,5 +185,6 @@ void engine_makeproxies(struct engine *e);
void
engine_redistribute
(
struct
engine
*
e
);
struct
link
*
engine_addlink
(
struct
engine
*
e
,
struct
link
*
l
,
struct
task
*
t
);
void
engine_print_policy
(
struct
engine
*
e
);
int
engine_is_done
(
struct
engine
*
e
);
#endif
/* SWIFT_ENGINE_H */
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