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
a689d22a
Commit
a689d22a
authored
9 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
some more fixes, remove dangerous local 'nr_parts' variable.
Former-commit-id: da7b602652035ec285cf3db3950cccc4008c87f2
parent
59948fa6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/space.c
+10
-11
10 additions, 11 deletions
src/space.c
with
10 additions
and
11 deletions
src/space.c
+
10
−
11
View file @
a689d22a
...
...
@@ -303,7 +303,7 @@ void space_regrid ( struct space *s , double cell_max ) {
void
space_rebuild
(
struct
space
*
s
,
double
cell_max
)
{
int
j
,
k
,
cdim
[
3
],
nr_parts
=
s
->
nr_parts
,
nr_gparts
=
s
->
nr_gparts
;
int
j
,
k
,
cdim
[
3
],
nr_gparts
=
s
->
nr_gparts
;
struct
cell
*
restrict
c
,
*
restrict
cells
;
struct
part
*
restrict
finger
,
*
restrict
p
,
*
parts
=
s
->
parts
;
struct
xpart
*
xfinger
,
*
xparts
=
s
->
xparts
;
...
...
@@ -327,7 +327,7 @@ void space_rebuild ( struct space *s , double cell_max ) {
ih
[
0
]
=
s
->
ih
[
0
];
ih
[
1
]
=
s
->
ih
[
1
];
ih
[
2
]
=
s
->
ih
[
2
];
dim
[
0
]
=
s
->
dim
[
0
];
dim
[
1
]
=
s
->
dim
[
1
];
dim
[
2
]
=
s
->
dim
[
2
];
cdim
[
0
]
=
s
->
cdim
[
0
];
cdim
[
1
]
=
s
->
cdim
[
1
];
cdim
[
2
]
=
s
->
cdim
[
2
];
for
(
k
=
0
;
k
<
nr_parts
;
k
++
)
{
for
(
k
=
0
;
k
<
s
->
nr_parts
;
k
++
)
{
p
=
&
parts
[
k
];
for
(
j
=
0
;
j
<
3
;
j
++
)
if
(
p
->
x
[
j
]
<
0
.
0
)
...
...
@@ -346,7 +346,7 @@ void space_rebuild ( struct space *s , double cell_max ) {
/* Move non-local parts to the end of the list. */
int
nodeID
=
s
->
e
->
nodeID
;
int
nr_local_parts
=
s
->
nr_parts
;
for
(
k
=
0
;
k
<
nr_parts
;
k
++
)
for
(
k
=
0
;
k
<
nr_
local_
parts
;
k
++
)
if
(
cells
[
ind
[
k
]
].
nodeID
!=
nodeID
)
{
cells
[
ind
[
k
]
].
count
-=
1
;
nr_local_parts
-=
1
;
...
...
@@ -363,7 +363,7 @@ void space_rebuild ( struct space *s , double cell_max ) {
/* Exchange the strays, note that this potentially re-allocates
the parts arrays. */
s
->
nr_parts
=
nr_local_parts
+
engine_exchange_strays
(
s
->
e
,
nr_local_parts
,
&
ind
[
nr_parts
]
,
nr_parts
-
nr_local_parts
);
s
->
nr_parts
=
nr_local_parts
+
engine_exchange_strays
(
s
->
e
,
nr_local_parts
,
&
ind
[
nr_
local_
parts
]
,
s
->
nr_parts
-
nr_local_parts
);
parts
=
s
->
parts
;
xparts
=
s
->
xparts
;
...
...
@@ -372,29 +372,28 @@ void space_rebuild ( struct space *s , double cell_max ) {
int
*
ind_new
;
if
(
(
ind_new
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
s
->
nr_parts
)
)
==
NULL
)
error
(
"Failed to allocate temporary particle indices."
);
memcpy
(
ind_new
,
ind
,
sizeof
(
int
)
*
nr_parts
);
memcpy
(
ind_new
,
ind
,
sizeof
(
int
)
*
nr_
local_
parts
);
free
(
ind
);
ind
=
ind_new
;
}
/* Assign each particle to its cell. */
for
(
k
=
nr_parts
;
k
<
s
->
nr_parts
;
k
++
)
{
for
(
k
=
nr_
local_
parts
;
k
<
s
->
nr_parts
;
k
++
)
{
p
=
&
parts
[
k
];
ind
[
k
]
=
cell_getid
(
cdim
,
p
->
x
[
0
]
*
ih
[
0
]
,
p
->
x
[
1
]
*
ih
[
1
]
,
p
->
x
[
2
]
*
ih
[
2
]
);
cells
[
ind
[
k
]
].
count
+=
1
;
/*
if ( cells[ ind[k] ].nodeID != nodeID )
error( "Received part that does not belong to me (nodeID=%i)." , cells[ ind[k] ].nodeID );
*/
if
(
cells
[
ind
[
k
]
].
nodeID
!=
nodeID
)
error
(
"Received part that does not belong to me (nodeID=%i)."
,
cells
[
ind
[
k
]
].
nodeID
);
}
nr_parts
=
s
->
nr_parts
;
#endif
/* Sort the parts according to their cells. */
// tic = getticks();
parts_sort
(
parts
,
xparts
,
ind
,
nr_parts
,
0
,
s
->
nr_cells
-
1
);
parts_sort
(
parts
,
xparts
,
ind
,
s
->
nr_parts
,
0
,
s
->
nr_cells
-
1
);
// message( "parts_sort took %.3f ms." , (double)(getticks() - tic) / CPU_TPS * 1000 );
/* Re-link the gparts. */
for
(
k
=
0
;
k
<
nr_parts
;
k
++
)
for
(
k
=
0
;
k
<
s
->
nr_parts
;
k
++
)
if
(
parts
[
k
].
gpart
!=
NULL
)
parts
[
k
].
gpart
->
part
=
&
parts
[
k
];
...
...
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