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
8b036533
Commit
8b036533
authored
Mar 27, 2016
by
Matthieu Schaller
Browse files
Always initialise the gparts to a sensible state
parent
858df3cb
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
8b036533
...
...
@@ -605,6 +605,26 @@ void cell_init_parts(struct cell *c, void *data) {
c
->
ti_end_max
=
0
;
}
/**
* @brief Initialises all g-particles to a valid state even if the ICs were
*stupid
*
* @param c Cell to act upon
* @param data Unused parameter
*/
void
cell_init_gparts
(
struct
cell
*
c
,
void
*
data
)
{
struct
gpart
*
gp
=
c
->
gparts
;
const
int
gcount
=
c
->
gcount
;
for
(
int
i
=
0
;
i
<
gcount
;
++
i
)
{
gp
[
i
].
ti_begin
=
0
;
gp
[
i
].
ti_end
=
0
;
}
c
->
ti_end_min
=
0
;
c
->
ti_end_max
=
0
;
}
/**
* @brief Converts hydro quantities to a valid state after the initial density
*calculation
...
...
src/cell.h
View file @
8b036533
...
...
@@ -178,6 +178,7 @@ int cell_getsize(struct cell *c);
int
cell_link_parts
(
struct
cell
*
c
,
struct
part
*
parts
);
int
cell_link_gparts
(
struct
cell
*
c
,
struct
gpart
*
gparts
);
void
cell_init_parts
(
struct
cell
*
c
,
void
*
data
);
void
cell_init_gparts
(
struct
cell
*
c
,
void
*
data
);
void
cell_convert_hydro
(
struct
cell
*
c
,
void
*
data
);
void
cell_clean_links
(
struct
cell
*
c
,
void
*
data
);
...
...
src/engine.c
View file @
8b036533
...
...
@@ -1846,7 +1846,15 @@ void engine_init_particles(struct engine *e) {
/* Make sure all particles are ready to go */
/* i.e. clean-up any stupid state in the ICs */
space_map_cells_pre
(
s
,
1
,
cell_init_parts
,
NULL
);
if
((
e
->
policy
&
engine_policy_hydro
)
==
engine_policy_hydro
)
{
space_map_cells_pre
(
s
,
1
,
cell_init_parts
,
NULL
);
}
if
(((
e
->
policy
&
engine_policy_self_gravity
)
==
engine_policy_self_gravity
)
||
((
e
->
policy
&
engine_policy_external_gravity
)
==
engine_policy_external_gravity
))
{
space_map_cells_pre
(
s
,
1
,
cell_init_gparts
,
NULL
);
}
engine_prepare
(
e
);
...
...
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