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
5f8486e6
Commit
5f8486e6
authored
Sep 20, 2016
by
Matthieu Schaller
Browse files
Be more explicit in the index_mapper
parent
a7ba8821
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/cell.h
View file @
5f8486e6
...
...
@@ -216,6 +216,9 @@ struct cell {
#define cell_getid(cdim, i, j, k) \
((int)(k) + (cdim)[2] * ((int)(j) + (cdim)[1] * (int)(i)))
#define cell_getid2(cdim_x, cdim_y, cdim_z, i, j, k) \
((int)(k) + cdim_z * ((int)(j) + cdim_y * (int)(i)))
/* Function prototypes. */
void
cell_split
(
struct
cell
*
c
,
ptrdiff_t
parts_offset
);
void
cell_sanitize
(
struct
cell
*
c
);
...
...
src/space.c
View file @
5f8486e6
...
...
@@ -750,31 +750,42 @@ void space_parts_get_cell_index_mapper(void *map_data, int nr_parts,
struct
part
*
restrict
parts
=
(
struct
part
*
)
map_data
;
struct
index_data
*
data
=
(
struct
index_data
*
)
extra_data
;
struct
space
*
s
=
data
->
s
;
int
*
ind
=
data
->
ind
+
(
ptrdiff_t
)(
parts
-
s
->
parts
);
// struct cell *cells = data->cells;
int
*
const
ind
=
data
->
ind
+
(
ptrdiff_t
)(
parts
-
s
->
parts
);
/* Get some constants */
const
double
dim
[
3
]
=
{
s
->
dim
[
0
],
s
->
dim
[
1
],
s
->
dim
[
2
]};
const
int
cdim
[
3
]
=
{
s
->
cdim
[
0
],
s
->
cdim
[
1
],
s
->
cdim
[
2
]};
const
double
ih
[
3
]
=
{
s
->
iwidth
[
0
],
s
->
iwidth
[
1
],
s
->
iwidth
[
2
]};
const
double
dim_x
=
s
->
dim
[
0
];
const
double
dim_y
=
s
->
dim
[
1
];
const
double
dim_z
=
s
->
dim
[
2
];
// const int cdim_x = s->cdim[0];
const
int
cdim_y
=
s
->
cdim
[
1
];
const
int
cdim_z
=
s
->
cdim
[
2
];
const
double
ih_x
=
s
->
iwidth
[
0
];
const
double
ih_y
=
s
->
iwidth
[
1
];
const
double
ih_z
=
s
->
iwidth
[
2
];
for
(
int
k
=
0
;
k
<
nr_parts
;
k
++
)
{
/* Get the particle */
struct
part
*
restrict
p
=
&
parts
[
k
];
const
double
old_pos_x
=
p
->
x
[
0
];
const
double
old_pos_y
=
p
->
x
[
1
];
const
double
old_pos_z
=
p
->
x
[
2
];
/* Put it back into the simulation volume */
p
->
x
[
0
]
=
box_wrap
(
p
->
x
[
0
]
,
0
.
0
,
dim
[
0
]
);
p
->
x
[
1
]
=
box_wrap
(
p
->
x
[
1
]
,
0
.
0
,
dim
[
1
]
);
p
->
x
[
2
]
=
box_wrap
(
p
->
x
[
2
]
,
0
.
0
,
dim
[
2
]
);
const
double
pos_x
=
box_wrap
(
old_pos_x
,
0
.
0
,
dim
_x
);
const
double
pos_y
=
box_wrap
(
old_pos_y
,
0
.
0
,
dim
_y
);
const
double
pos_z
=
box_wrap
(
old_pos_z
,
0
.
0
,
dim
_z
);
/* Get its cell index */
const
int
index
=
cell_getid
(
cdim
,
p
->
x
[
0
]
*
ih
[
0
],
p
->
x
[
1
]
*
ih
[
1
],
p
->
x
[
2
]
*
ih
[
2
]
);
const
int
index
=
cell_getid2
(
0
.,
cdim_y
,
cdim_z
,
pos_x
*
ih_x
,
pos_y
*
ih_y
,
pos_z
*
ih
_z
);
ind
[
k
]
=
index
;
/* Tell the cell it has a new member */
// atomic_inc(&(cells[index].count));
/* Update the position */
p
->
x
[
0
]
=
pos_x
;
p
->
x
[
1
]
=
pos_y
;
p
->
x
[
2
]
=
pos_z
;
}
}
...
...
@@ -792,8 +803,7 @@ void space_gparts_get_cell_index_mapper(void *map_data, int nr_gparts,
struct
gpart
*
restrict
gparts
=
(
struct
gpart
*
)
map_data
;
struct
index_data
*
data
=
(
struct
index_data
*
)
extra_data
;
struct
space
*
s
=
data
->
s
;
int
*
ind
=
data
->
ind
+
(
ptrdiff_t
)(
gparts
-
s
->
gparts
);
// struct cell *cells = data->cells;
int
*
const
ind
=
data
->
ind
+
(
ptrdiff_t
)(
gparts
-
s
->
gparts
);
/* Get some constants */
const
double
dim
[
3
]
=
{
s
->
dim
[
0
],
s
->
dim
[
1
],
s
->
dim
[
2
]};
...
...
@@ -814,9 +824,6 @@ void space_gparts_get_cell_index_mapper(void *map_data, int nr_gparts,
const
int
index
=
cell_getid
(
cdim
,
gp
->
x
[
0
]
*
ih
[
0
],
gp
->
x
[
1
]
*
ih
[
1
],
gp
->
x
[
2
]
*
ih
[
2
]);
ind
[
k
]
=
index
;
/* Tell the cell it has a new member */
// atomic_inc(&(cells[index].gcount));
}
}
...
...
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