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
e0a98486
Commit
e0a98486
authored
Aug 14, 2017
by
Matthieu Schaller
Browse files
Added a check to verify that a field tensor has been initialised before use.
parent
fa6bd92d
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/multipole.h
View file @
e0a98486
...
...
@@ -96,6 +96,9 @@ struct grav_tensor {
/* Total number of gpart this field tensor interacted with */
long
long
num_interacted
;
/* Last time this tensor was zeroed */
integertime_t
ti_init
;
#endif
};
...
...
@@ -232,9 +235,14 @@ INLINE static void gravity_drift(struct gravity_tensors *m, double dt) {
*
* @param l The field tensor.
*/
INLINE
static
void
gravity_field_tensors_init
(
struct
grav_tensor
*
l
)
{
INLINE
static
void
gravity_field_tensors_init
(
struct
grav_tensor
*
l
,
integertime_t
ti_current
)
{
bzero
(
l
,
sizeof
(
struct
grav_tensor
));
#ifdef SWIFT_DEBUG_CHECKS
l
->
ti_init
=
ti_current
;
#endif
}
/**
...
...
@@ -2185,7 +2193,7 @@ INLINE static void gravity_L2L(struct grav_tensor *la,
const
double
pos_a
[
3
],
const
double
pos_b
[
3
])
{
/* Initialise everything to zero */
gravity_field_tensors_init
(
la
);
gravity_field_tensors_init
(
la
,
0
);
#ifdef SWIFT_DEBUG_CHECKS
if
(
lb
->
num_interacted
==
0
)
error
(
"Shifting tensors that did not interact"
);
...
...
src/runner.c
View file @
e0a98486
...
...
@@ -557,7 +557,7 @@ void runner_do_init_grav(struct runner *r, struct cell *c, int timer) {
cell_drift_multipole
(
c
,
e
);
/* Reset the gravity acceleration tensors */
gravity_field_tensors_init
(
&
c
->
multipole
->
pot
);
gravity_field_tensors_init
(
&
c
->
multipole
->
pot
,
e
->
ti_current
);
/* Recurse? */
if
(
c
->
split
)
{
...
...
src/runner_doiact_grav.h
View file @
e0a98486
...
...
@@ -47,6 +47,8 @@ void runner_do_grav_down(struct runner *r, struct cell *c, int timer) {
#ifdef SWIFT_DEBUG_CHECKS
if
(
c
->
ti_old_multipole
!=
e
->
ti_current
)
error
(
"c->multipole not drifted."
);
if
(
c
->
multipole
->
pot
.
ti_init
!=
e
->
ti_current
)
error
(
"c->field tensor not initialised"
);
#endif
if
(
c
->
split
)
{
/* Node case */
...
...
@@ -61,6 +63,8 @@ void runner_do_grav_down(struct runner *r, struct cell *c, int timer) {
#ifdef SWIFT_DEBUG_CHECKS
if
(
cp
->
ti_old_multipole
!=
e
->
ti_current
)
error
(
"cp->multipole not drifted."
);
if
(
cp
->
multipole
->
pot
.
ti_init
!=
e
->
ti_current
)
error
(
"cp->field tensor not initialised"
);
#endif
struct
grav_tensor
shifted_tensor
;
...
...
@@ -137,8 +141,8 @@ void runner_dopair_grav_mm(const struct runner *r, struct cell *restrict ci,
if
(
multi_j
->
M_000
==
0
.
f
)
error
(
"Multipole does not seem to have been set."
);
if
(
ci
->
ti_old_
multipole
!=
e
->
ti_current
)
error
(
"ci->
multipole not drift
ed."
);
if
(
ci
->
multipole
->
pot
.
ti_init
!=
e
->
ti_current
)
error
(
"ci->
grav tensor not initialis
ed."
);
#endif
/* Do we need to drift the multipole ? */
...
...
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