Skip to content

Commit f220063

Browse files
Update octree.h
1 parent b46e681 commit f220063

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/gravity/octree.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22
#include "../struct/particle.h"
33
#include <vector>
44

5+
// Forward declaration so bhForce() can accept Octree*
6+
struct Octree;
7+
8+
// Function declaration
59
void bhForce(Octree* node, Particle& p, real theta, real dt);
610

11+
// =========================
12+
// Octree definition
13+
// =========================
714
struct Octree {
815
real cx, cy, cz; // center of mass
916
real m; // total mass
@@ -14,7 +21,8 @@ struct Octree {
1421
Octree* child[8] = {nullptr};
1522

1623
Octree(real X, real Y, real Z, real S)
17-
: x(X), y(Y), z(Z), size(S), m(0), cx(0), cy(0), cz(0) {}
24+
: cx(0), cy(0), cz(0), m(0),
25+
x(X), y(Y), z(Z), size(S) {}
1826

1927
~Octree() {
2028
for (auto c : child) delete c;
@@ -87,6 +95,9 @@ struct Octree {
8795
}
8896
};
8997

98+
// =========================
99+
// Barnes–Hut force function
100+
// =========================
90101
inline void bhForce(Octree* node, Particle& p, real theta, real dt)
91102
{
92103
if (!node || node->m == 0) return;

0 commit comments

Comments
 (0)