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
44a4091d
Commit
44a4091d
authored
May 03, 2020
by
Matthieu Schaller
Browse files
Use the correct CoM when testing cells in the MAC at rebuild time
parent
da2533ef
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
44a4091d
...
...
@@ -3327,7 +3327,7 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj,
if
(
lock_unlock
(
&
cj
->
grav
.
mlock
)
!=
0
)
error
(
"Impossible to unlock m-pole"
);
/* Can we use multipoles ? */
if
(
cell_can_use_pair_mm
(
ci
,
cj
,
e
,
sp
,
/*use_rebuild_
sizes
=*/
0
))
{
if
(
cell_can_use_pair_mm
(
ci
,
cj
,
e
,
sp
,
/*use_rebuild_
data
=*/
0
))
{
/* Ok, no need to drift anything */
return
;
}
...
...
@@ -6381,12 +6381,12 @@ void cell_reorder_extra_gparts(struct cell *c, struct part *parts,
* @param cj The second #cell.
* @param e The #engine.
* @param s The #space.
* @param use_rebuild_
sizes
Are we considering the
sizes
at the last tree-build
* (1) or current
sizes
(0)?
* @param use_rebuild_
data
Are we considering the
data
at the last tree-build
* (1) or current
data
(0)?
*/
int
cell_can_use_pair_mm
(
const
struct
cell
*
ci
,
const
struct
cell
*
cj
,
const
struct
engine
*
e
,
const
struct
space
*
s
,
const
int
use_rebuild_
sizes
)
{
const
int
use_rebuild_
data
)
{
const
struct
gravity_props
*
props
=
e
->
gravity_properties
;
const
int
periodic
=
s
->
periodic
;
...
...
@@ -6396,10 +6396,18 @@ int cell_can_use_pair_mm(const struct cell *ci, const struct cell *cj,
const
struct
gravity_tensors
*
const
multi_i
=
ci
->
grav
.
multipole
;
const
struct
gravity_tensors
*
const
multi_j
=
cj
->
grav
.
multipole
;
double
dx
,
dy
,
dz
;
/* Get the distance between the CoMs */
double
dx
=
multi_i
->
CoM
[
0
]
-
multi_j
->
CoM
[
0
];
double
dy
=
multi_i
->
CoM
[
1
]
-
multi_j
->
CoM
[
1
];
double
dz
=
multi_i
->
CoM
[
2
]
-
multi_j
->
CoM
[
2
];
if
(
use_rebuild_data
)
{
dx
=
multi_i
->
CoM_rebuild
[
0
]
-
multi_j
->
CoM_rebuild
[
0
];
dy
=
multi_i
->
CoM_rebuild
[
1
]
-
multi_j
->
CoM_rebuild
[
1
];
dz
=
multi_i
->
CoM_rebuild
[
2
]
-
multi_j
->
CoM_rebuild
[
2
];
}
else
{
dx
=
multi_i
->
CoM
[
0
]
-
multi_j
->
CoM
[
0
];
dy
=
multi_i
->
CoM
[
1
]
-
multi_j
->
CoM
[
1
];
dz
=
multi_i
->
CoM
[
2
]
-
multi_j
->
CoM
[
2
];
}
/* Apply BC */
if
(
periodic
)
{
...
...
@@ -6410,5 +6418,5 @@ int cell_can_use_pair_mm(const struct cell *ci, const struct cell *cj,
const
double
r2
=
dx
*
dx
+
dy
*
dy
+
dz
*
dz
;
return
gravity_M2L_accept_symmetric
(
props
,
multi_i
,
multi_j
,
r2
,
use_rebuild_
sizes
);
use_rebuild_
data
);
}
src/cell.h
View file @
44a4091d
...
...
@@ -960,7 +960,7 @@ void cell_reorder_extra_gparts(struct cell *c, struct part *parts,
void
cell_reorder_extra_sparts
(
struct
cell
*
c
,
const
ptrdiff_t
sparts_offset
);
int
cell_can_use_pair_mm
(
const
struct
cell
*
ci
,
const
struct
cell
*
cj
,
const
struct
engine
*
e
,
const
struct
space
*
s
,
const
int
use_rebuild_
sizes
);
const
int
use_rebuild_
data
);
/**
* @brief Compute the square of the minimal distance between any two points in
...
...
src/engine_maketasks.c
View file @
44a4091d
...
...
@@ -1381,7 +1381,7 @@ void engine_make_self_gravity_tasks_mapper(void *map_data, int num_elements,
if
(
periodic
&&
min_radius2
>
max_distance2
)
continue
;
/* Are the cells too close for a MM interaction ? */
if
(
!
cell_can_use_pair_mm
(
ci
,
cj
,
e
,
s
,
/*use_rebuild_
sizes
=*/
1
))
{
if
(
!
cell_can_use_pair_mm
(
ci
,
cj
,
e
,
s
,
/*use_rebuild_
data
=*/
1
))
{
/* Ok, we need to add a direct pair calculation */
scheduler_addtask
(
sched
,
task_type_pair
,
task_subtype_grav
,
0
,
0
,
...
...
src/scheduler.c
View file @
44a4091d
...
...
@@ -873,7 +873,7 @@ static void scheduler_splittask_gravity(struct task *t, struct scheduler *s) {
if
(
cj
->
progeny
[
j
]
!=
NULL
)
{
/* Can we use a M-M interaction here? */
if
(
cell_can_use_pair_mm
(
ci
->
progeny
[
i
],
cj
->
progeny
[
j
],
e
,
sp
,
/*use_rebuild_
sizes
=*/
1
))
{
sp
,
/*use_rebuild_
data
=*/
1
))
{
/* Flag this pair as being treated by the M-M task.
* We use the 64 bits in the task->flags field to store
...
...
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