diff --git a/image_analysis/structure_refinement/RefinementGPU.cpp b/image_analysis/structure_refinement/RefinementGPU.cpp index 97e31b7b8..a3de9c884 100644 --- a/image_analysis/structure_refinement/RefinementGPU.cpp +++ b/image_analysis/structure_refinement/RefinementGPU.cpp @@ -204,7 +204,7 @@ public: } void SetRestraints(int which, const RestraintSet &set) override { - engine_->SetRestraints(which, set.records, set.plane_atoms, set.slot_start, set.slot_index, set.slots); + engine_->SetRestraints(which, set.records, set.plane_atoms, set.slot_start, set.slot_index, set.n_slots); } double EvaluateRestraints(int which, const std::vector> &xyzb, diff --git a/image_analysis/structure_refinement/RefinementGPU.cu b/image_analysis/structure_refinement/RefinementGPU.cu index 4dde8f429..78d8b1e92 100644 --- a/image_analysis/structure_refinement/RefinementGPU.cu +++ b/image_analysis/structure_refinement/RefinementGPU.cu @@ -625,7 +625,7 @@ double RefinementGPUEngine::Evaluate(std::vector> *grad) { void RefinementGPUEngine::SetRestraints(int which, const std::vector &records, const std::vector &plane_atoms, const std::vector &slot_start, - const std::vector &slot_index, int slots) { + const std::vector &slot_index, int n_slots) { RefinementGPUEngineImpl &e = *impl_; DeviceGuard guard(e.device); RefinementGPUEngineImpl::Restraints &r = e.restraints[which]; @@ -639,7 +639,7 @@ void RefinementGPUEngine::SetRestraints(int which, const std::vector(slots)); + Ensure(r.contrib, r.cap_slots, static_cast(n_slots)); Ensure(r.xyzb, r.cap_xyzb, r.atoms); Ensure(r.grad, r.cap_atoms, r.atoms); if (!r.sum) diff --git a/image_analysis/structure_refinement/RefinementGPUEngine.h b/image_analysis/structure_refinement/RefinementGPUEngine.h index a8b34807a..c3281301b 100644 --- a/image_analysis/structure_refinement/RefinementGPUEngine.h +++ b/image_analysis/structure_refinement/RefinementGPUEngine.h @@ -65,7 +65,7 @@ public: // Restraint set `which` (0 or 1), as RestraintSet holds it. void SetRestraints(int which, const std::vector &records, const std::vector &plane_atoms, - const std::vector &slot_start, const std::vector &slot_index, int slots); + const std::vector &slot_start, const std::vector &slot_index, int n_slots); // The sum of E of set `which` at `xyzb` (x, y, z, B per atom) and dE/d(x, y, z, B) per atom. double EvaluateRestraints(int which, const std::vector> &xyzb, std::vector> *grad); diff --git a/image_analysis/structure_refinement/RefinementRestraints.cpp b/image_analysis/structure_refinement/RefinementRestraints.cpp index 3b79485ef..d1c8e698a 100644 --- a/image_analysis/structure_refinement/RefinementRestraints.cpp +++ b/image_analysis/structure_refinement/RefinementRestraints.cpp @@ -96,25 +96,25 @@ V3 FromImage(const RestraintRecord &r, V3 g) { } // namespace void RestraintSet::Add(RestraintRecord r, int n_atoms_of_r) { - r.slot = slots; - slots += n_atoms_of_r; + r.slot = n_slots; + n_slots += n_atoms_of_r; records.push_back(r); } void RestraintSet::Append(const RestraintSet &other) { const int plane_offset = static_cast(plane_atoms.size()); for (RestraintRecord r : other.records) { - r.slot += slots; + r.slot += n_slots; if (r.kind == static_cast(RestraintKind::Plane)) r.atom[0] += plane_offset; records.push_back(r); } plane_atoms.insert(plane_atoms.end(), other.plane_atoms.begin(), other.plane_atoms.end()); - slots += other.slots; + n_slots += other.n_slots; } void RestraintSet::Finalize(size_t n_atoms) { - slot_atom.assign(slots, -1); + slot_atom.assign(n_slots, -1); for (const RestraintRecord &r : records) { if (r.kind == static_cast(RestraintKind::Plane)) { for (int k = 0; k < r.atom[1]; k++) @@ -136,7 +136,7 @@ void RestraintSet::Finalize(size_t n_atoms) { slot_start[a + 1] += slot_start[a]; slot_index.assign(slot_start[n_atoms], 0); std::vector fill(slot_start.begin(), slot_start.end() - 1); - for (int s = 0; s < slots; s++) + for (int s = 0; s < n_slots; s++) if (slot_atom[s] >= 0) slot_index[fill[slot_atom[s]]++] = s; } diff --git a/image_analysis/structure_refinement/RefinementRestraints.h b/image_analysis/structure_refinement/RefinementRestraints.h index 0fcb13761..64b2e2ce2 100644 --- a/image_analysis/structure_refinement/RefinementRestraints.h +++ b/image_analysis/structure_refinement/RefinementRestraints.h @@ -26,7 +26,7 @@ struct RestraintSet { std::vector records; std::vector plane_atoms; - int slots = 0; + int n_slots = 0; std::vector slot_start; // n_atoms + 1 std::vector slot_index;