Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
42c8270a
Commit
42c8270a
authored
9 years ago
by
Peter W. Draper
Browse files
Options
Downloads
Patches
Plain Diff
Handle change in root level cell size
Primitive proof of implementation
parent
56e187d9
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!112
Root level parts
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/space.c
+37
-3
37 additions, 3 deletions
src/space.c
with
37 additions
and
3 deletions
src/space.c
+
37
−
3
View file @
42c8270a
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
#include
"lock.h"
#include
"lock.h"
#include
"minmax.h"
#include
"minmax.h"
#include
"runner.h"
#include
"runner.h"
#include
"tools.h"
/* Shared sort structure. */
/* Shared sort structure. */
struct
parallel_sort
space_sort_struct
;
struct
parallel_sort
space_sort_struct
;
...
@@ -200,10 +201,13 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
...
@@ -200,10 +201,13 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
"Must have at least 3 cells in each spatial dimension when periodicity "
"Must have at least 3 cells in each spatial dimension when periodicity "
"is switched on."
);
"is switched on."
);
/* In MPI-Land, we're not allowed to change the top-level cell size. */
/* In MPI-Land, changing the top-level cell size requires that the
* global partition is recomputed and the particles redistributed.
* Be prepared to do that. */
#ifdef WITH_MPI
#ifdef WITH_MPI
int
partition
=
0
;
if
(
cdim
[
0
]
<
s
->
cdim
[
0
]
||
cdim
[
1
]
<
s
->
cdim
[
1
]
||
cdim
[
2
]
<
s
->
cdim
[
2
])
if
(
cdim
[
0
]
<
s
->
cdim
[
0
]
||
cdim
[
1
]
<
s
->
cdim
[
1
]
||
cdim
[
2
]
<
s
->
cdim
[
2
])
error
(
"Root-level change of cell size not allowed."
)
;
partition
=
1
;
#endif
#endif
/* Do we need to re-build the upper-level cells? */
/* Do we need to re-build the upper-level cells? */
...
@@ -263,6 +267,32 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
...
@@ -263,6 +267,32 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
cdim
[
2
]);
cdim
[
2
]);
fflush
(
stdout
);
fflush
(
stdout
);
#ifdef WITH_MPI
/* XXX create an engine_resplit() function to use the same method as the
* initial partition. Fake for now. */
if
(
partition
)
{
if
(
s
->
e
->
nodeID
==
0
)
message
(
"cell dimensions have decreased. Recalculating the "
"global partition."
);
/* Change the global partitioning. */
int
grid
[
3
];
factor
(
s
->
e
->
nr_nodes
,
&
grid
[
0
],
&
grid
[
1
]);
factor
(
s
->
e
->
nr_nodes
/
grid
[
1
],
&
grid
[
0
],
&
grid
[
2
]);
factor
(
grid
[
0
]
*
grid
[
1
],
&
grid
[
1
],
&
grid
[
0
]);
/* Run through the cells and set their nodeID. */
int
ind
[
3
];
for
(
int
k
=
0
;
k
<
s
->
nr_cells
;
k
++
)
{
c
=
&
s
->
cells
[
k
];
for
(
int
j
=
0
;
j
<
3
;
j
++
)
ind
[
j
]
=
c
->
loc
[
j
]
/
s
->
dim
[
j
]
*
grid
[
j
];
c
->
nodeID
=
ind
[
0
]
+
grid
[
0
]
*
(
ind
[
1
]
+
grid
[
1
]
*
ind
[
2
]);
}
/* Make the proxies. */
engine_makeproxies
(
s
->
e
);
}
#endif
}
/* re-build upper-level cells? */
}
/* re-build upper-level cells? */
// message( "rebuilding upper-level cells took %.3f ms." , (double)(getticks()
// message( "rebuilding upper-level cells took %.3f ms." , (double)(getticks()
// - tic) / CPU_TPS * 1000 );
// - tic) / CPU_TPS * 1000 );
...
@@ -304,7 +334,7 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
...
@@ -304,7 +334,7 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
void
space_rebuild
(
struct
space
*
s
,
double
cell_max
,
int
verbose
)
{
void
space_rebuild
(
struct
space
*
s
,
double
cell_max
,
int
verbose
)
{
int
j
,
k
,
cdim
[
3
],
nr_parts
=
s
->
nr_parts
,
nr_gparts
=
s
->
nr_gparts
;
int
j
,
k
,
cdim
[
3
],
nr_parts
,
nr_gparts
;
struct
cell
*
restrict
c
,
*
restrict
cells
;
struct
cell
*
restrict
c
,
*
restrict
cells
;
struct
part
*
restrict
p
;
struct
part
*
restrict
p
;
int
*
ind
;
int
*
ind
;
...
@@ -316,7 +346,11 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
...
@@ -316,7 +346,11 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
/* Re-grid if necessary, or just re-set the cell data. */
/* Re-grid if necessary, or just re-set the cell data. */
space_regrid
(
s
,
cell_max
,
verbose
);
space_regrid
(
s
,
cell_max
,
verbose
);
/* Now set local space variables. */
nr_parts
=
s
->
nr_parts
;
cells
=
s
->
cells
;
cells
=
s
->
cells
;
nr_gparts
=
s
->
nr_gparts
;
/* Run through the particles and get their cell index. */
/* Run through the particles and get their cell index. */
// tic = getticks();
// tic = getticks();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment