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
e740b7aa
Commit
e740b7aa
authored
Aug 02, 2016
by
Stefan Arridge
Browse files
Added cooling tasks to the engine
parent
0ef836d1
Changes
6
Hide whitespace changes
Inline
Side-by-side
examples/main.c
View file @
e740b7aa
...
...
@@ -143,6 +143,7 @@ int main(int argc, char *argv[]) {
int
nsteps
=
-
2
;
int
with_cosmology
=
0
;
int
with_external_gravity
=
0
;
int
with_cooling
=
0
;
int
with_self_gravity
=
0
;
int
with_hydro
=
0
;
int
with_fp_exceptions
=
0
;
...
...
@@ -160,6 +161,9 @@ int main(int argc, char *argv[]) {
case
'c'
:
with_cosmology
=
1
;
break
;
case
'C'
:
with_cooling
=
1
;
break
;
case
'd'
:
dry_run
=
1
;
break
;
...
...
@@ -335,6 +339,11 @@ int main(int argc, char *argv[]) {
if
(
with_external_gravity
)
potential_init
(
params
,
&
us
,
&
potential
);
if
(
with_external_gravity
&&
myrank
==
0
)
potential_print
(
&
potential
);
/* Initialise the external potential properties */
struct
cooling_data
cooling
;
if
(
with_cooling
)
cooling_init
(
params
,
&
us
,
&
cooling
);
if
(
with_cooling
&&
myrank
==
0
)
cooling_print
(
&
cooling
);
/* Read particles and space information from (GADGET) ICs */
char
ICfileName
[
200
]
=
""
;
parser_get_param_string
(
params
,
"InitialConditions:file_name"
,
ICfileName
);
...
...
@@ -441,6 +450,7 @@ int main(int argc, char *argv[]) {
if
(
with_self_gravity
)
engine_policies
|=
engine_policy_self_gravity
;
if
(
with_external_gravity
)
engine_policies
|=
engine_policy_external_gravity
;
if
(
with_cosmology
)
engine_policies
|=
engine_policy_cosmology
;
if
(
with_cooling
)
engine_policies
|=
engine_policy_cooling
;
/* Initialize the engine with the space and policies. */
if
(
myrank
==
0
)
clocks_gettime
(
&
tic
);
...
...
src/cell.h
View file @
e740b7aa
...
...
@@ -136,6 +136,9 @@ struct cell {
/* Task for external gravity */
struct
task
*
grav_external
;
/* Task for cooling */
struct
task
*
cooling_task
;
/* Number of tasks that are associated with this cell. */
int
nr_tasks
;
...
...
src/engine.c
View file @
e740b7aa
...
...
@@ -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"
,
"cooling"
};
/** The rank of the engine as a global variable (for messages). */
int
engine_rank
;
...
...
@@ -191,6 +192,9 @@ void engine_make_hydro_hierarchical_tasks(struct engine *e, struct cell *c,
struct
scheduler
*
s
=
&
e
->
sched
;
const
int
is_fixdt
=
(
e
->
policy
&
engine_policy_fixdt
)
==
engine_policy_fixdt
;
const
int
is_with_cooling
=
(
e
->
policy
&
engine_policy_cooling
)
==
engine_policy_cooling
;
/* Is this the super-cell? */
if
(
super
==
NULL
&&
(
c
->
density
!=
NULL
||
(
c
->
count
>
0
&&
!
c
->
split
)))
{
...
...
@@ -225,6 +229,10 @@ void engine_make_hydro_hierarchical_tasks(struct engine *e, struct cell *c,
/* Generate the ghost task. */
c
->
ghost
=
scheduler_addtask
(
s
,
task_type_ghost
,
task_subtype_none
,
0
,
0
,
c
,
NULL
,
0
);
if
(
is_with_cooling
)
c
->
cooling_task
=
scheduler_addtask
(
s
,
task_type_cooling
,
task_subtype_none
,
0
,
0
,
c
,
NULL
,
0
);
}
}
...
...
@@ -1611,6 +1619,12 @@ void engine_make_extra_hydroloop_tasks(struct engine *e) {
scheduler_addunlock
(
sched
,
t
->
ci
->
init
,
t
);
scheduler_addunlock
(
sched
,
t
,
t
->
ci
->
kick
);
}
/* Cooling tasks should depend on kick and does not unlock anything since
it is the last task*/
else
if
(
t
->
type
==
task_type_cooling
)
{
scheduler_addunlock
(
sched
,
t
->
ci
->
kick
,
t
);
}
}
}
...
...
@@ -2612,6 +2626,11 @@ void engine_step(struct engine *e) {
mask
|=
1
<<
task_type_grav_external
;
}
/* Add the tasks corresponding to cooling to the masks */
if
(
e
->
policy
&
engine_policy_cooling
)
{
mask
|=
1
<<
task_type_cooling
;
}
/* Add MPI tasks if need be */
if
(
e
->
policy
&
engine_policy_mpi
)
{
...
...
@@ -2937,7 +2956,9 @@ void engine_init(struct engine *e, struct space *s,
const
struct
UnitSystem
*
internal_units
,
const
struct
phys_const
*
physical_constants
,
const
struct
hydro_props
*
hydro
,
const
struct
external_potential
*
potential
)
{
const
struct
external_potential
*
potential
,
const
struct
cooling_data
*
cooling
)
{
/* Clean-up everything */
bzero
(
e
,
sizeof
(
struct
engine
));
...
...
@@ -2986,6 +3007,7 @@ void engine_init(struct engine *e, struct space *s,
e
->
physical_constants
=
physical_constants
;
e
->
hydro_properties
=
hydro
;
e
->
external_potential
=
potential
;
e
->
cooling_data
=
cooling
;
e
->
parameter_file
=
params
;
engine_rank
=
nodeID
;
...
...
src/engine.h
View file @
e740b7aa
...
...
@@ -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_cooling
=
(
1
<<
12
)
};
extern
const
char
*
engine_policy_names
[];
...
...
@@ -204,6 +205,9 @@ struct engine {
/* Properties of external gravitational potential */
const
struct
external_potential
*
external_potential
;
/* Properties of the cooling scheme */
const
struct
cooling_data
*
cooling_data
;
/* The (parsed) parameter file */
const
struct
swift_params
*
parameter_file
;
};
...
...
src/runner.h
View file @
e740b7aa
...
...
@@ -53,6 +53,7 @@ void runner_do_kick(struct runner *r, struct cell *c, int timer);
void
runner_do_kick_fixdt
(
struct
runner
*
r
,
struct
cell
*
c
,
int
timer
);
void
runner_do_drift
(
struct
runner
*
r
,
struct
cell
*
c
,
int
timer
);
void
runner_do_init
(
struct
runner
*
r
,
struct
cell
*
c
,
int
timer
);
void
runner_do_cooling
(
struct
runner
*
r
,
struct
cell
*
c
,
int
timer
);
void
*
runner_main
(
void
*
data
);
#endif
/* SWIFT_RUNNER_H */
src/task.h
View file @
e740b7aa
...
...
@@ -51,6 +51,7 @@ enum task_types {
task_type_grav_mm
,
task_type_grav_up
,
task_type_grav_external
,
task_type_cooling
,
task_type_part_sort
,
task_type_gpart_sort
,
task_type_split_cell
,
...
...
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