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
ba4e4e6c
Commit
ba4e4e6c
authored
Jan 26, 2016
by
Matthieu Schaller
Browse files
Removed nested function in engine_init_particles()
parent
29ba1972
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
ba4e4e6c
...
...
@@ -545,3 +545,26 @@ void cell_split(struct cell *c) {
for
(
k
=
0
;
k
<
gcount
;
k
++
)
if
(
gparts
[
k
].
id
>
0
)
gparts
[
k
].
part
->
gpart
=
&
gparts
[
k
];
}
/**
* @brief Initialises all particles to a valid state even if the ICs were stupid
*
* @param c Cell to act upon
* @param data Unused parameter
*/
void
cell_init_parts
(
struct
cell
*
c
,
void
*
data
)
{
struct
part
*
p
=
c
->
parts
;
struct
xpart
*
xp
=
c
->
xparts
;
for
(
int
i
=
0
;
i
<
c
->
count
;
++
i
)
{
p
[
i
].
t_begin
=
0
.;
p
[
i
].
t_end
=
0
.;
p
[
i
].
rho
=
-
1
.;
xp
[
i
].
v_full
[
0
]
=
p
[
i
].
v
[
0
];
xp
[
i
].
v_full
[
1
]
=
p
[
i
].
v
[
1
];
xp
[
i
].
v_full
[
2
]
=
p
[
i
].
v
[
2
];
}
c
->
t_end_min
=
0
.;
}
src/cell.h
View file @
ba4e4e6c
...
...
@@ -169,5 +169,6 @@ int cell_pack(struct cell *c, struct pcell *pc);
int
cell_unpack
(
struct
pcell
*
pc
,
struct
cell
*
c
,
struct
space
*
s
);
int
cell_getsize
(
struct
cell
*
c
);
int
cell_link
(
struct
cell
*
c
,
struct
part
*
parts
);
void
cell_init_parts
(
struct
cell
*
c
,
void
*
data
);
#endif
/* SWIFT_CELL_H */
src/engine.c
View file @
ba4e4e6c
...
...
@@ -1849,41 +1849,10 @@ void engine_init_particles(struct engine *e) {
//engine_print(e);
//fflush(stdout);
//message("Engine prepared");
/* Nested functions are not standard C. Please extract. */
/* Make sure all particles are ready to go */
void
initParts
(
struct
part
*
p
,
struct
xpart
*
xp
,
struct
cell
*
c
)
{
p
->
t_begin
=
0
.;
p
->
t_end
=
0
.;
p
->
rho
=
-
1
.;
xp
->
v_full
[
0
]
=
p
->
v
[
0
];
xp
->
v_full
[
1
]
=
p
->
v
[
1
];
xp
->
v_full
[
2
]
=
p
->
v
[
2
];
c
->
t_end_min
=
0
.;
}
/* i.e. clean-up any stupid state in the ICs */
message
(
"Initialising particles"
);
space_map_parts_xparts
(
s
,
initParts
);
/* Now everybody should have sensible smoothing length */
void
printParts
(
struct
part
*
p
,
struct
xpart
*
xp
,
struct
cell
*
c
)
{
if
(
p
->
id
==
1000
)
message
(
"id=%lld h=%f rho=%f t_begin=%f t_end=%f"
,
p
->
id
,
p
->
h
,
p
->
rho
,
p
->
t_begin
,
p
->
t_end
);
}
// space_map_parts_xparts(s, printParts);
void
printCells
(
struct
part
*
p
,
struct
xpart
*
xp
,
struct
cell
*
c
)
{
if
(
c
->
super
!=
NULL
&&
0
)
message
(
"c->t_end_min=%f c->t_end_max=%f c->super=%p sort=%p ghost=%p "
"kick=%p"
,
c
->
t_end_min
,
c
->
t_end_max
,
c
->
super
,
c
->
sorts
,
c
->
ghost
,
c
->
kick
);
}
// space_map_parts_xparts(s, printCells);
space_map_cells_pre
(
s
,
1
,
cell_init_parts
,
NULL
);
/* Now do a density calculation */
TIMER_TIC
;
...
...
@@ -1895,10 +1864,6 @@ void engine_init_particles(struct engine *e) {
TIMER_TOC
(
timer_runners
);
// space_map_parts_xparts(s, printParts);
printf
(
"
\n\n
"
);
/* Ready to go */
e
->
step
=
-
1
;
}
...
...
src/space.c
View file @
ba4e4e6c
...
...
@@ -849,7 +849,6 @@ void space_map_parts(struct space *s,
*
* @param c The #cell we are working in.
* @param fun Function pointer to apply on the cells.
* @param data Data passed to the function fun.
*/
static
void
rec_map_parts_xparts
(
struct
cell
*
c
,
...
...
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