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
1dbaf1bd
Commit
1dbaf1bd
authored
Aug 20, 2016
by
Matthieu Schaller
Browse files
Allow users to drift all particles via an engine policy
parent
bfdc2008
Changes
8
Hide whitespace changes
Inline
Side-by-side
README
View file @
1dbaf1bd
...
...
@@ -22,12 +22,12 @@ Valid options are:
-d Dry run. Read the parameter file, allocate memory but does not read
the particles from ICs and exit before the start of time integration.
Allows user to check validy of parameter and IC files as well as memory limits.
-D Always drift all particles even the ones far from active particles.
-e Enable floating-point exceptions (debugging mode)
-f {int} Overwrite the CPU frequency (Hz) to be used for time measurements
-g Run with an external gravitational potential
-G Run with self-gravity
-n {int} Execute a fixed number of time steps. When unset use the time_end
parameter to stop.
-n {int} Execute a fixed number of time steps. When unset use the time_end parameter to stop.
-s Run with SPH
-t {int} The number of threads to use on each MPI rank. Defaults to 1 if not specified.
-v [12] Increase the level of verbosity 1: MPI-rank 0 writes
...
...
examples/main.c
View file @
1dbaf1bd
...
...
@@ -67,6 +67,8 @@ void print_help_message() {
printf
(
" %2s %8s %s
\n
"
,
""
,
""
,
"Allows user to check validy of parameter and IC files as well as "
"memory limits."
);
printf
(
" %2s %8s %s
\n
"
,
"-D"
,
""
,
"Always drift all particles even the ones far from active particles."
);
printf
(
" %2s %8s %s
\n
"
,
"-e"
,
""
,
"Enable floating-point exceptions (debugging mode)"
);
printf
(
" %2s %8s %s
\n
"
,
"-f"
,
"{int}"
,
...
...
@@ -75,7 +77,8 @@ void print_help_message() {
"Run with an external gravitational potential"
);
printf
(
" %2s %8s %s
\n
"
,
"-G"
,
""
,
"Run with self-gravity"
);
printf
(
" %2s %8s %s
\n
"
,
"-n"
,
"{int}"
,
"Execute a fixed number of time steps"
);
"Execute a fixed number of time steps. When unset use the time_end "
"parameter to stop."
);
printf
(
" %2s %8s %s
\n
"
,
"-s"
,
""
,
"Run with SPH"
);
printf
(
" %2s %8s %s
\n
"
,
"-t"
,
"{int}"
,
"The number of threads to use on each MPI rank. Defaults to 1 if not "
...
...
@@ -146,6 +149,7 @@ int main(int argc, char *argv[]) {
int
with_self_gravity
=
0
;
int
with_hydro
=
0
;
int
with_fp_exceptions
=
0
;
int
with_drift_all
=
0
;
int
verbose
=
0
;
int
nr_threads
=
1
;
char
paramFileName
[
200
]
=
""
;
...
...
@@ -153,7 +157,7 @@ int main(int argc, char *argv[]) {
/* Parse the parameters */
int
c
;
while
((
c
=
getopt
(
argc
,
argv
,
"acdef:gGhn:st:v:y:"
))
!=
-
1
)
switch
(
c
)
{
while
((
c
=
getopt
(
argc
,
argv
,
"acd
D
ef:gGhn:st:v:y:"
))
!=
-
1
)
switch
(
c
)
{
case
'a'
:
with_aff
=
1
;
break
;
...
...
@@ -163,6 +167,9 @@ int main(int argc, char *argv[]) {
case
'd'
:
dry_run
=
1
;
break
;
case
'D'
:
with_drift_all
=
1
;
break
;
case
'e'
:
with_fp_exceptions
=
1
;
break
;
...
...
@@ -438,6 +445,7 @@ int main(int argc, char *argv[]) {
/* Construct the engine policy */
int
engine_policies
=
ENGINE_POLICY
|
engine_policy_steal
;
if
(
with_drift_all
)
engine_policies
|=
engine_policy_drift_all
;
if
(
with_hydro
)
engine_policies
|=
engine_policy_hydro
;
if
(
with_self_gravity
)
engine_policies
|=
engine_policy_self_gravity
;
if
(
with_external_gravity
)
engine_policies
|=
engine_policy_external_gravity
;
...
...
src/engine.c
View file @
1dbaf1bd
...
...
@@ -68,7 +68,7 @@
#include
"units.h"
#include
"version.h"
const
char
*
engine_policy_names
[
1
3
]
=
{
"none"
,
const
char
*
engine_policy_names
[
1
4
]
=
{
"none"
,
"rand"
,
"steal"
,
"keep"
,
...
...
@@ -80,7 +80,8 @@ const char *engine_policy_names[13] = {"none",
"hydro"
,
"self_gravity"
,
"external_gravity"
,
"cosmology_integration"
};
"cosmology_integration"
,
"drift_all"
};
/** The rank of the engine as a global variable (for messages). */
int
engine_rank
;
...
...
@@ -2093,7 +2094,9 @@ void engine_prepare(struct engine *e) {
e
->
drift_all
=
1
;
threadpool_map
(
&
e
->
threadpool
,
runner_do_drift_mapper
,
e
->
s
->
cells
,
e
->
s
->
nr_cells
,
sizeof
(
struct
cell
),
1
,
e
);
e
->
drift_all
=
0
;
/* Restore the default drifting policy */
e
->
drift_all
=
(
e
->
policy
&
engine_policy_drift_all
);
/* And now rebuild */
engine_rebuild
(
e
);
...
...
@@ -2479,7 +2482,9 @@ void engine_step(struct engine *e) {
e
->
drift_all
=
1
;
threadpool_map
(
&
e
->
threadpool
,
runner_do_drift_mapper
,
e
->
s
->
cells
,
e
->
s
->
nr_cells
,
sizeof
(
struct
cell
),
1
,
e
);
e
->
drift_all
=
0
;
/* Restore the default drifting policy */
e
->
drift_all
=
(
e
->
policy
&
engine_policy_drift_all
);
/* Dump... */
engine_dump_snapshot
(
e
);
...
...
src/engine.h
View file @
1dbaf1bd
...
...
@@ -61,7 +61,8 @@ enum engine_policy {
engine_policy_hydro
=
(
1
<<
8
),
engine_policy_self_gravity
=
(
1
<<
9
),
engine_policy_external_gravity
=
(
1
<<
10
),
engine_policy_cosmology
=
(
1
<<
11
)
engine_policy_cosmology
=
(
1
<<
11
),
engine_policy_drift_all
=
(
1
<<
12
)
};
extern
const
char
*
engine_policy_names
[];
...
...
src/hydro/Gadget2/hydro_iact.h
View file @
1dbaf1bd
...
...
@@ -432,7 +432,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
const
float
balsara_j
=
pj
->
force
.
balsara
;
/* Are the particles moving towards each others ? */
const
float
omega_ij
=
(
dvdr
<
0
.
f
)
?
dvdr
:
0
.
f
;
const
float
omega_ij
=
(
dvdr
<
0
.
f
)
?
dvdr
:
0
.
f
;
const
float
mu_ij
=
fac_mu
*
r_inv
*
omega_ij
;
/* This is 0 or negative */
/* Signal velocity */
...
...
@@ -707,7 +707,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
const
float
balsara_j
=
pj
->
force
.
balsara
;
/* Are the particles moving towards each others ? */
const
float
omega_ij
=
(
dvdr
<
0
.
f
)
?
dvdr
:
0
.
f
;
const
float
omega_ij
=
(
dvdr
<
0
.
f
)
?
dvdr
:
0
.
f
;
const
float
mu_ij
=
fac_mu
*
r_inv
*
omega_ij
;
/* This is 0 or negative */
/* Signal velocity */
...
...
src/runner.c
View file @
1dbaf1bd
...
...
@@ -487,8 +487,8 @@ void runner_do_ghost(struct runner *r, struct cell *c) {
h_corr
=
(
target_wcount
-
p
->
density
.
wcount
)
/
p
->
density
.
wcount_dh
;
/* Truncate to the range [ -p->h/2 , p->h ]. */
h_corr
=
(
h_corr
<
p
->
h
)
?
h_corr
:
p
->
h
;
h_corr
=
(
h_corr
>
-
0
.
5
f
*
p
->
h
)
?
h_corr
:
-
0
.
5
f
*
p
->
h
;
h_corr
=
(
h_corr
<
p
->
h
)
?
h_corr
:
p
->
h
;
h_corr
=
(
h_corr
>
-
0
.
5
f
*
p
->
h
)
?
h_corr
:
-
0
.
5
f
*
p
->
h
;
}
/* Did we get the right number density? */
...
...
@@ -626,7 +626,7 @@ static void runner_do_drift(struct cell *c, struct engine *e) {
const
float
dx2
=
gp
->
x_diff
[
0
]
*
gp
->
x_diff
[
0
]
+
gp
->
x_diff
[
1
]
*
gp
->
x_diff
[
1
]
+
gp
->
x_diff
[
2
]
*
gp
->
x_diff
[
2
];
dx2_max
=
(
dx2_max
>
dx2
)
?
dx2_max
:
dx2
;
dx2_max
=
(
dx2_max
>
dx2
)
?
dx2_max
:
dx2
;
}
/* Loop over all the particles in the cell (more work for these !) */
...
...
@@ -644,7 +644,7 @@ static void runner_do_drift(struct cell *c, struct engine *e) {
const
float
dx2
=
xp
->
x_diff
[
0
]
*
xp
->
x_diff
[
0
]
+
xp
->
x_diff
[
1
]
*
xp
->
x_diff
[
1
]
+
xp
->
x_diff
[
2
]
*
xp
->
x_diff
[
2
];
dx2_max
=
(
dx2_max
>
dx2
)
?
dx2_max
:
dx2
;
dx2_max
=
(
dx2_max
>
dx2
)
?
dx2_max
:
dx2
;
/* Maximal smoothing length */
h_max
=
(
h_max
>
p
->
h
)
?
h_max
:
p
->
h
;
...
...
src/serial_io.c
View file @
1dbaf1bd
...
...
@@ -225,11 +225,11 @@ void prepareArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
}
/* Impose data compression */
if
(
e
->
snapshotCompression
>
0
)
{
if
(
e
->
snapshotCompression
>
0
)
{
h_err
=
H5Pset_deflate
(
h_prop
,
e
->
snapshotCompression
);
if
(
h_err
<
0
)
{
error
(
"Error while setting compression options for field '%s'."
,
props
.
name
);
props
.
name
);
}
}
...
...
src/timestep.h
View file @
1dbaf1bd
...
...
@@ -74,7 +74,8 @@ __attribute__((always_inline)) INLINE static int get_gpart_timestep(
/* gravity_compute_timestep_self(e->physical_constants, gp); */
const
float
new_dt_self
=
FLT_MAX
;
// MATTHIEU
float
new_dt
=
(
new_dt_external
<
new_dt_self
)
?
new_dt_external
:
new_dt_self
;
float
new_dt
=
(
new_dt_external
<
new_dt_self
)
?
new_dt_external
:
new_dt_self
;
/* Limit timestep within the allowed range */
new_dt
=
(
new_dt
<
e
->
dt_max
)
?
new_dt
:
e
->
dt_max
;
...
...
@@ -111,11 +112,12 @@ __attribute__((always_inline)) INLINE static int get_part_timestep(
/* gravity_compute_timestep_self(e->physical_constants, p->gpart); */
const
float
new_dt_self
=
FLT_MAX
;
// MATTHIEU
new_dt_grav
=
(
new_dt_external
<
new_dt_self
)
?
new_dt_external
:
new_dt_self
;
new_dt_grav
=
(
new_dt_external
<
new_dt_self
)
?
new_dt_external
:
new_dt_self
;
}
/* Final time-step is minimum of hydro and gravity */
float
new_dt
=
(
new_dt_hydro
<
new_dt_grav
)
?
new_dt_hydro
:
new_dt_grav
;
float
new_dt
=
(
new_dt_hydro
<
new_dt_grav
)
?
new_dt_hydro
:
new_dt_grav
;
/* Limit change in h */
const
float
dt_h_change
=
...
...
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