Skip to content
Permalink
Browse files

Smart pointer refactoring

  • Loading branch information...
psci2195 committed Apr 12, 2019
1 parent 4a342d6 commit 12f00d80ed5112ba02410f857402b7d48f5af3e7
Showing with 10 additions and 12 deletions.
  1. +9 −11 src/core/actor/DipolarBarnesHut.cpp
  2. +1 −1 src/core/actor/DipolarBarnesHut.hpp
@@ -27,27 +27,25 @@

#ifdef DIPOLAR_BARNES_HUT

std::unique_ptr<DipolarBarnesHut> dipolarBarnesHut;

void activate_dipolar_barnes_hut(float epssq, float itolsq) {
delete dipolarBarnesHut;
dipolarBarnesHut = nullptr;
// also necessary on 1 CPU or GPU, does more than just broadcasting
dipole.method = DIPOLAR_BH_GPU;
mpi_bcast_coulomb_params();

dipolarBarnesHut =
new DipolarBarnesHut(espressoSystemInterface, epssq, itolsq);
forceActors.push_back(dipolarBarnesHut);
energyActors.push_back(dipolarBarnesHut);
std::make_unique<DipolarBarnesHut>(espressoSystemInterface, epssq, itolsq);
forceActors.push_back(dipolarBarnesHut.get());
energyActors.push_back(dipolarBarnesHut.get());
}

void deactivate_dipolar_barnes_hut() {
if (dipolarBarnesHut) {
forceActors.remove(dipolarBarnesHut);
energyActors.remove(dipolarBarnesHut);
forceActors.remove(dipolarBarnesHut.get());
energyActors.remove(dipolarBarnesHut.get());
dipolarBarnesHut.reset();
}
delete dipolarBarnesHut;
dipolarBarnesHut = nullptr;
}

DipolarBarnesHut *dipolarBarnesHut = nullptr;

#endif
@@ -101,7 +101,7 @@ class DipolarBarnesHut : public Actor {
void activate_dipolar_barnes_hut(float epssq, float itolsq);
void deactivate_dipolar_barnes_hut();

extern DipolarBarnesHut *dipolarBarnesHut;
extern std::unique_ptr<DipolarBarnesHut> dipolarBarnesHut;

#endif

0 comments on commit 12f00d8

Please sign in to comment.
You can’t perform that action at this time.