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
f6734af8
Commit
f6734af8
authored
Sep 21, 2018
by
Loic Hausammann
Browse files
Add feedback policy
parent
bdb4fb7e
Changes
4
Hide whitespace changes
Inline
Side-by-side
examples/main.c
View file @
f6734af8
...
...
@@ -98,6 +98,7 @@ void print_help_message(void) {
printf
(
" %2s %14s %s
\n
"
,
"-r"
,
""
,
"Continue using restart files."
);
printf
(
" %2s %14s %s
\n
"
,
"-s"
,
""
,
"Run with hydrodynamics."
);
printf
(
" %2s %14s %s
\n
"
,
"-S"
,
""
,
"Run with stars."
);
printf
(
" %2s %14s %s
\n
"
,
"-b"
,
""
,
"Run with stars feedback."
);
printf
(
" %2s %14s %s
\n
"
,
"-t"
,
"{int}"
,
"The number of threads to use on each MPI rank. Defaults to 1 if not "
"specified."
);
...
...
@@ -193,6 +194,7 @@ int main(int argc, char *argv[]) {
int
with_self_gravity
=
0
;
int
with_hydro
=
0
;
int
with_stars
=
0
;
int
with_feedback
=
0
;
int
with_fp_exceptions
=
0
;
int
with_drift_all
=
0
;
int
with_mpole_reconstruction
=
0
;
...
...
@@ -209,7 +211,7 @@ int main(int argc, char *argv[]) {
/* Parse the parameters */
int
c
;
while
((
c
=
getopt
(
argc
,
argv
,
"acCdDef:FgGhMn:o:P:rsSt:Tv:xy:Y:"
))
!=
-
1
)
while
((
c
=
getopt
(
argc
,
argv
,
"a
b
cCdDef:FgGhMn:o:P:rsSt:Tv:xy:Y:"
))
!=
-
1
)
switch
(
c
)
{
case
'a'
:
#if defined(HAVE_SETAFFINITY) && defined(HAVE_LIBNUMA)
...
...
@@ -218,6 +220,9 @@ int main(int argc, char *argv[]) {
error
(
"Need NUMA support for thread affinity"
);
#endif
break
;
case
'b'
:
with_feedback
=
1
;
break
;
case
'c'
:
with_cosmology
=
1
;
break
;
...
...
@@ -385,6 +390,15 @@ int main(int argc, char *argv[]) {
return
1
;
}
if
(
!
with_stars
&&
with_feedback
)
{
if
(
myrank
==
0
)
printf
(
"Error: Cannot process feedback without stars, -S must be "
"chosen.
\n
"
);
if
(
myrank
==
0
)
print_help_message
();
return
1
;
}
/* Let's pin the main thread, now we know if affinity will be used. */
#if defined(HAVE_SETAFFINITY) && defined(HAVE_LIBNUMA) && defined(_GNU_SOURCE)
if
(
with_aff
&&
...
...
@@ -887,6 +901,7 @@ int main(int argc, char *argv[]) {
if
(
with_cooling
)
engine_policies
|=
engine_policy_cooling
;
if
(
with_sourceterms
)
engine_policies
|=
engine_policy_sourceterms
;
if
(
with_stars
)
engine_policies
|=
engine_policy_stars
;
if
(
with_feedback
)
engine_policies
|=
engine_policy_feedback
;
if
(
with_structure_finding
)
engine_policies
|=
engine_policy_structure_finding
;
...
...
src/engine.c
View file @
f6734af8
...
...
@@ -110,7 +110,8 @@ const char *engine_policy_names[] = {"none",
"cooling"
,
"sourceterms"
,
"stars"
,
"structure finding"
};
"structure finding"
,
"feedback"
};
/** The rank of the engine as a global variable (for messages). */
int
engine_rank
;
...
...
@@ -463,7 +464,7 @@ void engine_make_hierarchical_tasks_mapper(void *map_data, int num_elements,
const
int
is_with_self_gravity
=
(
e
->
policy
&
engine_policy_self_gravity
);
const
int
is_with_external_gravity
=
(
e
->
policy
&
engine_policy_external_gravity
);
const
int
is_with_
stars
=
(
e
->
policy
&
engine_policy_
stars
);
const
int
is_with_
feedback
=
(
e
->
policy
&
engine_policy_
feedback
);
for
(
int
ind
=
0
;
ind
<
num_elements
;
ind
++
)
{
struct
cell
*
c
=
&
((
struct
cell
*
)
map_data
)[
ind
];
...
...
@@ -474,7 +475,7 @@ void engine_make_hierarchical_tasks_mapper(void *map_data, int num_elements,
/* And the gravity stuff */
if
(
is_with_self_gravity
||
is_with_external_gravity
)
engine_make_hierarchical_tasks_gravity
(
e
,
c
);
if
(
is_with_
stars
)
engine_make_hierarchical_tasks_stars
(
e
,
c
);
if
(
is_with_
feedback
)
engine_make_hierarchical_tasks_stars
(
e
,
c
);
}
}
...
...
@@ -3431,7 +3432,7 @@ void engine_maketasks(struct engine *e) {
tic2
=
getticks
();
/* Construct the stars hydro loop over neighbours */
if
(
e
->
policy
&
engine_policy_
stars
)
{
if
(
e
->
policy
&
engine_policy_
feedback
)
{
threadpool_map
(
&
e
->
threadpool
,
engine_make_starsloop_tasks_mapper
,
NULL
,
s
->
nr_cells
,
1
,
0
,
e
);
}
...
...
src/engine.h
View file @
f6734af8
...
...
@@ -71,9 +71,10 @@ enum engine_policy {
engine_policy_cooling
=
(
1
<<
13
),
engine_policy_sourceterms
=
(
1
<<
14
),
engine_policy_stars
=
(
1
<<
15
),
engine_policy_structure_finding
=
(
1
<<
16
)
engine_policy_structure_finding
=
(
1
<<
16
),
engine_policy_feedback
=
(
1
<<
17
)
};
#define engine_maxpolicy 1
6
#define engine_maxpolicy 1
7
extern
const
char
*
engine_policy_names
[];
/**
...
...
src/stars/Default/stars_io.h
View file @
f6734af8
...
...
@@ -45,7 +45,7 @@ INLINE static void stars_read_particles(struct spart *sparts,
sparts
,
mass
);
list
[
3
]
=
io_make_input_field
(
"ParticleIDs"
,
LONGLONG
,
1
,
COMPULSORY
,
UNIT_CONV_NO_UNITS
,
sparts
,
id
);
list
[
4
]
=
io_make_input_field
(
"SmoothingLength"
,
FLOAT
,
1
,
COMPULSORY
,
list
[
4
]
=
io_make_input_field
(
"SmoothingLength"
,
FLOAT
,
1
,
OPTIONAL
,
UNIT_CONV_LENGTH
,
sparts
,
h
);
}
...
...
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