Skip to content

Commit

Permalink
NBodyICs: clearing velocities
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsevecek committed May 8, 2024
1 parent 13248de commit efa0701
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
8 changes: 7 additions & 1 deletion core/post/Analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,16 @@ Vector Post::getAngularFrequency(ArrayView<const Float> m,
};

if (idxs) {
if (idxs.size() == 1) {
return Vector(0);
}
for (Size i : idxs) {
functor(i);
}
} else {
if (r.size() == 1) {
return Vector(0);
}
for (Size i = 0; i < r.size(); ++i) {
functor(i);
}
Expand Down Expand Up @@ -435,7 +441,7 @@ Optional<Float> Post::getSphericity(IScheduler& scheduler, const Storage& storag
}

if (area == 0._f) {
// sphericity undefined
// sphericity undefined
return NOTHING;
}

Expand Down
6 changes: 3 additions & 3 deletions core/run/jobs/InitialConditionJobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,12 @@ void KeplerianVelocityIc::evaluate(const RunSettings& UNUSED(global), IRunCallba
for (Size i = 0; i < r.size(); ++i) {
const Float v_kepl = sqrt(Constants::gravity * m_source / getLength(r[i]));
const Vector dir = getNormalized(cross(Vector::unit(Z), r[i]));
v[i] = v_source + dir * v_kepl;
v[i] = clearH(v_source + dir * v_kepl);
}
for (Attractor& a : orbiting.getAttractors()) {
const Float v_kepl = sqrt(Constants::gravity * m_source / getLength(a.position));
const Vector dir = getNormalized(cross(Vector::unit(Z), a.position));
a.velocity = v_source + dir * v_kepl;
a.velocity = clearH(v_source + dir * v_kepl);
}
}

Expand Down Expand Up @@ -1017,7 +1017,7 @@ void NBodyIc::evaluate(const RunSettings& global, IRunCallbacks& callbacks) {
const Vector dir = getNormalized(Vector(positions[i][Y], -positions[i][X], 0._f));
Vector v_random = sampleSphere(velocityDispersion, 0.333_f, *rng);
v_random[Z] *= heightScale;
velocities[i] = dir * v_kepl + v_random;
velocities[i] = clearH(dir * v_kepl + v_random);
}

Storage storage(makeAuto<NullMaterial>(BodySettings::getDefaults()));
Expand Down
3 changes: 0 additions & 3 deletions gui/windows/GridPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,6 @@ void GridPage::updateAsync(const Storage& storage,
Storage lr;
for (Size i = 0; i < fragmentCnt; ++i) {
const Storage fragment = getter.getComponent(i);
if (fragment.getParticleCnt() < 2) {
break;
}
if (i == 0) {
lr = fragment.clone(VisitorEnum::ALL_BUFFERS);
}
Expand Down

0 comments on commit efa0701

Please sign in to comment.