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
9c9be1bc
Commit
9c9be1bc
authored
Mar 08, 2017
by
Matthieu Schaller
Browse files
Re-introduced the check tht multipoles have the same CoM
parent
f1b488a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
9c9be1bc
...
...
@@ -1127,8 +1127,7 @@ void cell_check_multipole(struct cell *c, void *data) {
gravity_P2M
(
&
ma
,
c
->
gparts
,
c
->
gcount
);
/* Now compare the multipole expansion */
if
(
!
gravity_multipole_equal
(
&
ma
.
m_pole
,
&
c
->
multipole
->
m_pole
,
tolerance
))
{
if
(
!
gravity_multipole_equal
(
&
ma
,
c
->
multipole
,
tolerance
))
{
message
(
"Multipoles are not equal at depth=%d!"
,
c
->
depth
);
message
(
"Correct answer:"
);
gravity_multipole_print
(
&
ma
.
m_pole
);
...
...
src/multipole.h
View file @
9c9be1bc
...
...
@@ -230,25 +230,26 @@ INLINE static void gravity_multipole_add(struct multipole *ma,
/**
* @brief Verifies whether two #multipole's are equal or not.
*
* @param
m
a The first #multipole.
* @param
m
b The second #multipole.
* @param
g
a The first #multipole.
* @param
g
b The second #multipole.
* @param tolerance The maximal allowed difference for the fields.
* @return 1 if the multipoles are equal 0 otherwise.
*/
INLINE
static
int
gravity_multipole_equal
(
const
struct
multipole
*
m
a
,
const
struct
multipole
*
m
b
,
INLINE
static
int
gravity_multipole_equal
(
const
struct
gravity_tensors
*
g
a
,
const
struct
gravity_tensors
*
g
b
,
double
tolerance
)
{
/* Check CoM */
/* if (fabs(ma->CoM[0] - mb->CoM[0]) / fabs(ma->CoM[0] + mb->CoM[0]) >
* tolerance) */
/* return 0; */
/* if (fabs(ma->CoM[1] - mb->CoM[1]) / fabs(ma->CoM[1] + mb->CoM[1]) >
* tolerance) */
/* return 0; */
/* if (fabs(ma->CoM[2] - mb->CoM[2]) / fabs(ma->CoM[2] + mb->CoM[2]) >
* tolerance) */
/* return 0; */
if
(
fabs
(
ga
->
CoM
[
0
]
-
gb
->
CoM
[
0
])
/
fabs
(
ga
->
CoM
[
0
]
+
gb
->
CoM
[
0
])
>
tolerance
)
return
0
;
if
(
fabs
(
ga
->
CoM
[
1
]
-
gb
->
CoM
[
1
])
/
fabs
(
ga
->
CoM
[
1
]
+
gb
->
CoM
[
1
])
>
tolerance
)
return
0
;
if
(
fabs
(
ga
->
CoM
[
2
]
-
gb
->
CoM
[
2
])
/
fabs
(
ga
->
CoM
[
2
]
+
gb
->
CoM
[
2
])
>
tolerance
)
return
0
;
/* Helper pointers */
const
struct
multipole
*
ma
=
&
ga
->
m_pole
;
const
struct
multipole
*
mb
=
&
gb
->
m_pole
;
/* Check bulk velocity (if non-zero)*/
if
(
fabsf
(
ma
->
vel
[
0
]
+
mb
->
vel
[
0
])
>
0
.
f
&&
...
...
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