Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QuickSched
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
QuickSched
Commits
2c10e5b4
Commit
2c10e5b4
authored
10 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Simplified the calculation of the distance between cells in the case of two cells of the same size.
parent
0cbf4d4a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/test_bh_sorted.c
+36
-6
36 additions, 6 deletions
examples/test_bh_sorted.c
with
36 additions
and
6 deletions
examples/test_bh_sorted.c
+
36
−
6
View file @
2c10e5b4
...
...
@@ -743,9 +743,10 @@ static inline void make_interact_pc(struct cell* leaf, struct cell* cj) {
*/
static
inline
int
is_inside
(
struct
cell
*
leaf
,
struct
cell
*
c
)
{
if
(
leaf
->
loc
[
0
]
>=
c
->
loc
[
0
]
&&
leaf
->
loc
[
0
]
<
c
->
loc
[
0
]
+
c
->
h
&&
leaf
->
loc
[
1
]
>=
c
->
loc
[
1
]
&&
leaf
->
loc
[
1
]
<
c
->
loc
[
1
]
+
c
->
h
&&
leaf
->
loc
[
2
]
>=
c
->
loc
[
2
]
&&
leaf
->
loc
[
2
]
<
c
->
loc
[
2
]
+
c
->
h
)
if
(
leaf
->
loc
[
0
]
>=
c
->
loc
[
0
]
&&
leaf
->
loc
[
0
]
<
c
->
loc
[
0
]
+
c
->
h
&&
leaf
->
loc
[
1
]
>=
c
->
loc
[
1
]
&&
leaf
->
loc
[
1
]
<
c
->
loc
[
1
]
+
c
->
h
&&
leaf
->
loc
[
2
]
>=
c
->
loc
[
2
]
&&
leaf
->
loc
[
2
]
<
c
->
loc
[
2
]
+
c
->
h
)
/* if ( leaf->parts >= c->parts && leaf->parts < c->parts + c->count ) */
return
1
;
else
return
0
;
...
...
@@ -756,14 +757,14 @@ static inline int is_inside(struct cell* leaf, struct cell* c)
/**
* @brief Checks whether the cells are direct neighbours ot not
*/
static
inline
int
are_neighbours
(
struct
cell
*
ci
,
struct
cell
*
cj
){
static
inline
int
are_neighbours
_different_size
(
struct
cell
*
ci
,
struct
cell
*
cj
){
int
k
;
float
dx
[
3
];
double
cih
=
ci
->
h
,
cjh
=
cj
->
h
;
/* Maximum allowed distance */
double
min_dist
=
0
.
5
*
(
cih
+
cjh
);
float
min_dist
=
0
.
5
*
(
cih
+
cjh
);
/* (Manhattan) Distance between the cells */
for
(
k
=
0
;
k
<
3
;
k
++
)
{
...
...
@@ -778,6 +779,35 @@ static inline int are_neighbours(struct cell* ci, struct cell* cj){
return
0
;
}
/**
* @brief Checks whether the cells are direct neighbours ot not. Both cells have to be of the same size
*/
static
inline
int
are_neighbours
(
struct
cell
*
ci
,
struct
cell
*
cj
){
int
k
;
float
dx
[
3
];
#ifdef SANITY_CHECKS
if
(
ci
->
h
!=
cj
->
h
)
error
(
" Cells of different size in distance calculation."
);
#endif
/* Maximum allowed distance */
float
min_dist
=
ci
->
h
;
/* (Manhattan) Distance between the cells */
for
(
k
=
0
;
k
<
3
;
k
++
)
{
float
center_i
=
ci
->
loc
[
k
];
float
center_j
=
cj
->
loc
[
k
];
dx
[
k
]
=
fabs
(
center_i
-
center_j
);
}
if
((
dx
[
0
]
<=
min_dist
)
&&
(
dx
[
1
]
<=
min_dist
)
&&
(
dx
[
2
]
<=
min_dist
))
return
1
;
else
return
0
;
}
/**
* @brief Compute the interactions between all particles in a cell leaf
...
...
@@ -820,7 +850,7 @@ static inline void iact_pair_pc(struct cell *ci, struct cell *cj, struct cell *l
break
;
}
if
(
are_neighbours
(
cp
,
cj
)
)
{
if
(
are_neighbours
_different_size
(
cp
,
cj
)
)
{
/* Now interact this subcell with all subcells of cj */
for
(
cps
=
cj
->
firstchild
;
cps
!=
cj
->
sibling
;
cps
=
cps
->
sibling
)
{
...
...
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