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
55f708b6
Commit
55f708b6
authored
Nov 30, 2017
by
Matthieu Schaller
Browse files
Merge branch 'gravity_fixes' of gitlab.cosma.dur.ac.uk:swift/swiftsim into gravity_fixes
parents
6e797b6b
1eb6629e
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/engine.c
View file @
55f708b6
...
@@ -4470,16 +4470,16 @@ void engine_makeproxies(struct engine *e) {
...
@@ -4470,16 +4470,16 @@ void engine_makeproxies(struct engine *e) {
/* Get the cell ID. */
/* Get the cell ID. */
const
int
cid
=
cell_getid
(
cdim
,
i
,
j
,
k
);
const
int
cid
=
cell_getid
(
cdim
,
i
,
j
,
k
);
if
(
with_gravity
)
{
if
(
with_gravity
)
{
/* Get ci's multipole */
/* Get ci's multipole */
const
struct
gravity_tensors
*
multi_i
=
cells
[
cid
].
multipole
;
const
struct
gravity_tensors
*
multi_i
=
cells
[
cid
].
multipole
;
CoM_i
[
0
]
=
multi_i
->
CoM
[
0
];
CoM_i
[
0
]
=
multi_i
->
CoM
[
0
];
CoM_i
[
1
]
=
multi_i
->
CoM
[
1
];
CoM_i
[
1
]
=
multi_i
->
CoM
[
1
];
CoM_i
[
2
]
=
multi_i
->
CoM
[
2
];
CoM_i
[
2
]
=
multi_i
->
CoM
[
2
];
r_max_i
=
multi_i
->
r_max
;
r_max_i
=
multi_i
->
r_max
;
}
}
/* Loop over every other cell */
/* Loop over every other cell */
for
(
int
ii
=
0
;
ii
<
cdim
[
0
];
ii
++
)
{
for
(
int
ii
=
0
;
ii
<
cdim
[
0
];
ii
++
)
{
for
(
int
jj
=
0
;
jj
<
cdim
[
1
];
jj
++
)
{
for
(
int
jj
=
0
;
jj
<
cdim
[
1
];
jj
++
)
{
...
@@ -4488,44 +4488,43 @@ void engine_makeproxies(struct engine *e) {
...
@@ -4488,44 +4488,43 @@ void engine_makeproxies(struct engine *e) {
/* Get the cell ID. */
/* Get the cell ID. */
const
int
cjd
=
cell_getid
(
cdim
,
ii
,
jj
,
kk
);
const
int
cjd
=
cell_getid
(
cdim
,
ii
,
jj
,
kk
);
/* In the gravity case, check distances using the MAC. */
/* In the gravity case, check distances using the MAC. */
if
(
with_gravity
)
{
if
(
with_gravity
)
{
/* Get cj's multipole */
/* Get cj's multipole */
const
struct
gravity_tensors
*
multi_j
=
cells
[
cjd
].
multipole
;
const
struct
gravity_tensors
*
multi_j
=
cells
[
cjd
].
multipole
;
const
double
CoM_j
[
3
]
=
{
multi_j
->
CoM
[
0
],
multi_j
->
CoM
[
1
],
const
double
CoM_j
[
3
]
=
{
multi_j
->
CoM
[
0
],
multi_j
->
CoM
[
1
],
multi_j
->
CoM
[
2
]};
multi_j
->
CoM
[
2
]};
const
double
r_max_j
=
multi_j
->
r_max
;
const
double
r_max_j
=
multi_j
->
r_max
;
/* Let's compute the current distance between the cell pair*/
/* Let's compute the current distance between the cell pair*/
double
dx
=
CoM_i
[
0
]
-
CoM_j
[
0
];
double
dx
=
CoM_i
[
0
]
-
CoM_j
[
0
];
double
dy
=
CoM_i
[
1
]
-
CoM_j
[
1
];
double
dy
=
CoM_i
[
1
]
-
CoM_j
[
1
];
double
dz
=
CoM_i
[
2
]
-
CoM_j
[
2
];
double
dz
=
CoM_i
[
2
]
-
CoM_j
[
2
];
/* Apply BC */
/* Apply BC */
if
(
periodic
)
{
if
(
periodic
)
{
dx
=
nearest
(
dx
,
dim
[
0
]);
dx
=
nearest
(
dx
,
dim
[
0
]);
dy
=
nearest
(
dy
,
dim
[
1
]);
dy
=
nearest
(
dy
,
dim
[
1
]);
dz
=
nearest
(
dz
,
dim
[
2
]);
dz
=
nearest
(
dz
,
dim
[
2
]);
}
}
const
double
r2
=
dx
*
dx
+
dy
*
dy
+
dz
*
dz
;
const
double
r2
=
dx
*
dx
+
dy
*
dy
+
dz
*
dz
;
if
(
gravity_M2L_accept
(
r_max_i
,
r_max_j
,
theta_crit2
,
r2
))
continue
;
}
/* In the hydro case, only carre about neighbours */
else
if
(
with_hydro
)
{
if
(
!
((
abs
(
i
-
ii
)
<=
1
||
abs
(
i
-
ii
-
cdim
[
0
])
<=
1
||
abs
(
i
-
ii
+
cdim
[
0
])
<=
1
)
&&
(
abs
(
j
-
jj
)
<=
1
||
abs
(
j
-
jj
-
cdim
[
1
])
<=
1
||
abs
(
j
-
jj
+
cdim
[
1
])
<=
1
)
&&
(
abs
(
k
-
kk
)
<=
1
||
abs
(
k
-
kk
-
cdim
[
2
])
<=
1
||
abs
(
k
-
kk
+
cdim
[
2
])
<=
1
)))
continue
;
}
if
(
gravity_M2L_accept
(
r_max_i
,
r_max_j
,
theta_crit2
,
r2
))
continue
;
}
/* In the hydro case, only carre about neighbours */
else
if
(
with_hydro
)
{
if
(
!
((
abs
(
i
-
ii
)
<=
1
||
abs
(
i
-
ii
-
cdim
[
0
])
<=
1
||
abs
(
i
-
ii
+
cdim
[
0
])
<=
1
)
&&
(
abs
(
j
-
jj
)
<=
1
||
abs
(
j
-
jj
-
cdim
[
1
])
<=
1
||
abs
(
j
-
jj
+
cdim
[
1
])
<=
1
)
&&
(
abs
(
k
-
kk
)
<=
1
||
abs
(
k
-
kk
-
cdim
[
2
])
<=
1
||
abs
(
k
-
kk
+
cdim
[
2
])
<=
1
)))
continue
;
}
/* Add to proxies? */
/* Add to proxies? */
if
(
cells
[
cid
].
nodeID
==
e
->
nodeID
&&
if
(
cells
[
cid
].
nodeID
==
e
->
nodeID
&&
...
...
src/partition.c
View file @
55f708b6
...
@@ -354,23 +354,56 @@ static void pick_metis(struct space *s, int nregions, double *vertexw,
...
@@ -354,23 +354,56 @@ static void pick_metis(struct space *s, int nregions, double *vertexw,
/* Init the vertex weights array. */
/* Init the vertex weights array. */
if
(
vertexw
!=
NULL
)
{
if
(
vertexw
!=
NULL
)
{
for
(
int
k
=
0
;
k
<
ncells
;
k
++
)
{
for
(
int
k
=
0
;
k
<
ncells
;
k
++
)
{
if
(
vertexw
[
k
]
>
0
)
{
if
(
vertexw
[
k
]
>
1
)
{
weights_v
[
k
]
=
vertexw
[
k
];
weights_v
[
k
]
=
vertexw
[
k
];
}
else
{
}
else
{
weights_v
[
k
]
=
1
;
weights_v
[
k
]
=
1
;
}
}
}
}
#ifdef SWIFT_DEBUG_CHECKS
/* Check weights are all in range. */
int
failed
=
0
;
for
(
int
k
=
0
;
k
<
ncells
;
k
++
)
{
if
((
idx_t
)
vertexw
[
k
]
<
0
)
{
message
(
"Input vertex weight out of range: %ld"
,
(
long
)
vertexw
[
k
]);
failed
++
;
}
if
(
weights_v
[
k
]
<
1
)
{
message
(
"Used vertex weight out of range: %"
PRIDX
,
weights_v
[
k
]);
failed
++
;
}
}
if
(
failed
>
0
)
error
(
"%d vertex weights are out of range"
,
failed
);
#endif
}
}
/* Init the edges weights array. */
/* Init the edges weights array. */
if
(
edgew
!=
NULL
)
{
if
(
edgew
!=
NULL
)
{
for
(
int
k
=
0
;
k
<
26
*
ncells
;
k
++
)
{
for
(
int
k
=
0
;
k
<
26
*
ncells
;
k
++
)
{
if
(
edgew
[
k
]
>
0
)
{
if
(
edgew
[
k
]
>
1
)
{
weights_e
[
k
]
=
edgew
[
k
];
weights_e
[
k
]
=
edgew
[
k
];
}
else
{
}
else
{
weights_e
[
k
]
=
1
;
weights_e
[
k
]
=
1
;
}
}
}
}
#ifdef SWIFT_DEBUG_CHECKS
/* Check weights are all in range. */
int
failed
=
0
;
for
(
int
k
=
0
;
k
<
26
*
ncells
;
k
++
)
{
if
((
idx_t
)
edgew
[
k
]
<
0
)
{
message
(
"Input edge weight out of range: %ld"
,
(
long
)
edgew
[
k
]);
failed
++
;
}
if
(
weights_e
[
k
]
<
1
)
{
message
(
"Used edge weight out of range: %"
PRIDX
,
weights_e
[
k
]);
failed
++
;
}
}
if
(
failed
>
0
)
error
(
"%d edge weights are out of range"
,
failed
);
#endif
}
}
/* Set the METIS options. */
/* Set the METIS options. */
...
@@ -661,35 +694,42 @@ static void repart_edge_metis(int partweights, int bothweights, int timebins,
...
@@ -661,35 +694,42 @@ static void repart_edge_metis(int partweights, int bothweights, int timebins,
double
wmine
=
weights_e
[
0
];
double
wmine
=
weights_e
[
0
];
double
wmaxe
=
weights_e
[
0
];
double
wmaxe
=
weights_e
[
0
];
for
(
int
k
=
0
;
26
*
k
<
nr_cells
;
k
++
)
{
for
(
int
k
=
0
;
k
<
26
*
nr_cells
;
k
++
)
{
wmaxe
=
weights_e
[
k
]
>
wmaxe
?
weights_e
[
k
]
:
wmaxe
;
wmaxe
=
weights_e
[
k
]
>
wmaxe
?
weights_e
[
k
]
:
wmaxe
;
wmine
=
weights_e
[
k
]
<
wmine
?
weights_e
[
k
]
:
wmine
;
wmine
=
weights_e
[
k
]
<
wmine
?
weights_e
[
k
]
:
wmine
;
}
}
double
wscalev
=
1
.
0
;
double
wscalee
=
1
.
0
;
if
(
bothweights
)
{
if
(
bothweights
)
{
/* Make maximum value same in both weights systems. */
/* Make range the same in both weights systems. */
if
(
wmaxv
>
wmaxe
)
{
if
((
wmaxv
-
wminv
)
>
(
wmaxe
-
wmine
))
{
wscalee
=
wmaxv
/
wmaxe
;
double
wscale
=
(
wmaxv
-
wminv
)
/
(
wmaxe
-
wmine
);
for
(
int
k
=
0
;
k
<
26
*
nr_cells
;
k
++
)
{
weights_e
[
k
]
=
(
weights_e
[
k
]
-
wmine
)
*
wscale
+
wminv
;
}
wmine
=
wminv
;
wmaxe
=
wmaxv
;
wmaxe
=
wmaxv
;
}
else
{
}
else
{
wscalev
=
wmaxe
/
wmaxv
;
double
wscale
=
(
wmaxe
-
wmine
)
/
(
wmaxv
-
wminv
);
for
(
int
k
=
0
;
k
<
nr_cells
;
k
++
)
{
weights_v
[
k
]
=
(
weights_v
[
k
]
-
wminv
)
*
wscale
+
wmine
;
}
wminv
=
wmine
;
wmaxv
=
wmaxe
;
wmaxv
=
wmaxe
;
}
}
/* Scale to the METIS range. */
/* Scale to the METIS range. */
wscale
v
*
=
metis_maxweight
/
(
wmaxv
-
wminv
);
double
wscale
=
(
metis_maxweight
-
1
.
0
)
/
(
wmaxv
-
wminv
);
for
(
int
k
=
0
;
k
<
nr_cells
;
k
++
)
{
for
(
int
k
=
0
;
k
<
nr_cells
;
k
++
)
{
weights_v
[
k
]
=
(
weights_v
[
k
]
-
wminv
)
*
wscale
v
+
1
.
0
;
weights_v
[
k
]
=
(
weights_v
[
k
]
-
wminv
)
*
wscale
+
1
.
0
;
}
}
}
}
/* Scale to the METIS range. */
/* Scale to the METIS range. */
wscale
e
*
=
metis_maxweight
/
(
wmaxe
-
wmine
);
double
wscale
=
(
metis_maxweight
-
1
.
0
)
/
(
wmaxe
-
wmine
);
for
(
int
k
=
0
;
k
<
26
*
nr_cells
;
k
++
)
{
for
(
int
k
=
0
;
k
<
26
*
nr_cells
;
k
++
)
{
weights_e
[
k
]
=
(
weights_e
[
k
]
-
wmine
)
*
wscale
e
+
1
.
0
;
weights_e
[
k
]
=
(
weights_e
[
k
]
-
wmine
)
*
wscale
+
1
.
0
;
}
}
/* And partition, use both weights or not as requested. */
/* And partition, use both weights or not as requested. */
...
...
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