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
1dc6966f
Commit
1dc6966f
authored
11 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
fixed same bug, yet in a different place.
parent
3ee481c2
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.c
+54
-53
54 additions, 53 deletions
examples/test_bh.c
with
54 additions
and
53 deletions
examples/test_bh.c
+
54
−
53
View file @
1dc6966f
...
@@ -353,68 +353,69 @@ void iact_pair ( struct cell *ci , struct cell *cj ) {
...
@@ -353,68 +353,69 @@ void iact_pair ( struct cell *ci , struct cell *cj ) {
for
(
k
=
j
+
1
;
k
<
8
;
k
++
)
for
(
k
=
j
+
1
;
k
<
8
;
k
++
)
iact_pair
(
ci
->
progeny
[
j
]
,
cj
->
progeny
[
k
]
);
iact_pair
(
ci
->
progeny
[
j
]
,
cj
->
progeny
[
k
]
);
/*
Otherwise, compute interaction
s. */
/*
Get the minimum distance between both cell
s. */
else
{
for
(
r2
=
0
.
0
,
k
=
0
;
k
<
3
;
k
++
)
{
dx
[
k
]
=
fabs
(
ci
->
loc
[
k
]
-
cj
->
loc
[
k
]
);
/* Get the minimum distance between both cells. */
if
(
dx
[
k
]
>
0
)
for
(
r2
=
0
.
0
,
k
=
0
;
k
<
3
;
k
++
)
{
dx
[
k
]
-=
ci
->
h
[
k
];
dx
[
k
]
=
fabs
(
ci
->
loc
[
k
]
-
cj
->
loc
[
k
]
)
;
r2
+=
dx
[
k
]
*
dx
[
k
];
if
(
dx
[
k
]
>
0
)
}
dx
[
k
]
-=
ci
->
h
[
k
];
r2
+=
dx
[
k
]
*
dx
[
k
];
/* Sufficiently well-separated? */
}
if
(
r2
/
ci
->
h
[
0
]
>
dist_min
*
dist_min
)
{
/*
Sufficiently well-separated?
*/
/*
Compute the center of mass interactions.
*/
i
f
(
r2
/
ci
->
h
[
0
]
<
dist_min
*
dist_min
)
{
i
act_pair_pc
(
ci
,
cj
);
iact_pair_pc
(
cj
,
ci
);
/* Compute the center of mass interactions. */
iact_pair_pc
(
ci
,
cj
);
}
iact_pair_pc
(
cj
,
ci
);
/* Recurse? */
}
else
if
(
ci
->
split
&&
cj
->
split
)
for
(
j
=
0
;
j
<
8
;
j
++
)
/* Otherwise, do direct interactions. */
for
(
k
=
j
+
1
;
k
<
8
;
k
++
)
else
{
iact_pair
(
ci
->
progeny
[
j
]
,
cj
->
progeny
[
k
]
);
/* Loop over all particles..
. */
/* Otherwise, do direct interactions
. */
for
(
i
=
0
;
i
<
count_i
;
i
++
)
{
else
{
/* Init the ith particle's data. */
/* Loop over all particles... */
for
(
k
=
0
;
k
<
3
;
k
++
)
{
for
(
i
=
0
;
i
<
count_i
;
i
++
)
{
xi
[
k
]
=
parts_i
[
i
].
x
[
k
];
ai
[
k
]
=
0
.
0
;
/* Init the ith particle's data. */
}
for
(
k
=
0
;
k
<
3
;
k
++
)
{
mi
=
parts_i
[
i
].
mass
;
xi
[
k
]
=
parts_i
[
i
].
x
[
k
];
ai
[
k
]
=
0
.
0
;
}
mi
=
parts_i
[
i
].
mass
;
/* Loop over every following particle. */
/* Loop over every following particle. */
for
(
j
=
0
;
j
<
count_j
;
j
++
)
{
for
(
j
=
0
;
j
<
count_j
;
j
++
)
{
/* Compute the pairwise distance. */
/* Compute the pairwise distance. */
for
(
r2
=
0
.
0
,
k
=
0
;
k
<
3
;
k
++
)
{
for
(
r2
=
0
.
0
,
k
=
0
;
k
<
3
;
k
++
)
{
dx
[
k
]
=
xi
[
k
]
-
parts_j
[
j
].
x
[
k
];
dx
[
k
]
=
xi
[
k
]
-
parts_j
[
j
].
x
[
k
];
r2
+=
dx
[
k
]
*
dx
[
k
];
r2
+=
dx
[
k
]
*
dx
[
k
];
}
}
/* Apply the gravitational acceleration. */
/* Apply the gravitational acceleration. */
ir
=
1
.
0
/
sqrt
(
r2
);
ir
=
1
.
0
/
sqrt
(
r2
);
w
=
const_G
*
ir
*
ir
*
ir
;
w
=
const_G
*
ir
*
ir
*
ir
;
mj
=
parts_j
[
j
].
mass
;
mj
=
parts_j
[
j
].
mass
;
for
(
k
=
0
;
k
<
3
;
k
++
)
{
for
(
k
=
0
;
k
<
3
;
k
++
)
{
parts_j
[
j
].
a
[
k
]
+=
w
*
dx
[
k
]
*
mi
;
parts_j
[
j
].
a
[
k
]
+=
w
*
dx
[
k
]
*
mi
;
ai
[
k
]
-=
w
*
dx
[
k
]
*
mj
;
ai
[
k
]
-=
w
*
dx
[
k
]
*
mj
;
}
}
}
/* loop over every other particle. */
}
/* loop over every other particle. */
/* Store the accumulated acceleration on the ith part. */
/* Store the accumulated acceleration on the ith part. */
for
(
k
=
0
;
k
<
3
;
k
++
)
for
(
k
=
0
;
k
<
3
;
k
++
)
parts_i
[
i
].
a
[
k
]
+=
ai
[
k
];
parts_i
[
i
].
a
[
k
]
+=
ai
[
k
];
}
/* loop over all particles. */
}
/* loop over all particles. */
}
/* otherwise, compute interactions directly. */
}
/* otherwise, compute interactions directly. */
}
/* otherwise, compute interactions. */
}
}
...
...
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