Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/World.cpp

    r09f615 r388ddd  
    194194}
    195195
     196bool areBondsPresent(const unsigned int _step)
     197{
     198  bool status = false;
     199
     200  for (World::AtomConstIterator iter = const_cast<const World &>(World::getInstance()).getAtomIter();
     201      (!status) && (iter != const_cast<const World &>(World::getInstance()).atomEnd()); ++iter) {
     202    const atom * const Walker = *iter;
     203    status |= !Walker->getListOfBondsAtStep(_step).empty();
     204  }
     205
     206  return status;
     207}
     208
     209void copyBondgraph(const unsigned int _srcstep, const unsigned int _deststep)
     210{
     211  // gather all bonds from _srcstep
     212  std::set<bond *> SetOfBonds;
     213  for (World::AtomConstIterator iter = const_cast<const World &>(World::getInstance()).getAtomIter();
     214      iter != const_cast<const World &>(World::getInstance()).atomEnd(); ++iter) {
     215    const atom * const Walker = *iter;
     216    const BondList bonds = Walker->getListOfBondsAtStep(_srcstep);
     217    BOOST_FOREACH( bond::ptr bondptr, bonds) {
     218      SetOfBonds.insert(bondptr.get());
     219    }
     220  }
     221  LOG(4, "DEBUG: We gathered " << SetOfBonds.size() << " bonds in total.");
     222
     223  // copy bond to new time step
     224  for (std::set<bond *>::const_iterator bonditer = SetOfBonds.begin();
     225      bonditer != SetOfBonds.end(); ++bonditer) {
     226    const atom * const Walker = (*bonditer)->leftatom;
     227    const atom * const OtherWalker = (*bonditer)->rightatom;
     228    const_cast<atom *>(Walker)->addBond(_deststep, const_cast<atom *>(OtherWalker));
     229  }
     230}
     231
    196232void World::setTime(const unsigned int _step)
    197233{
    198234  if (_step != WorldTime::getTime()) {
     235    const unsigned int oldstep = WorldTime::getTime();
    199236    // set new time
    200237    WorldTime::getInstance().setTime(_step);
     
    207244      destroyMolecule(*iter);
    208245    }
    209     // 2. (re-)create bondgraph
    210     AtomComposite Set = getAllAtoms();
    211     BG->CreateAdjacency(Set);
     246    // 2. copy bond graph
     247    if (!areBondsPresent(_step)) {
     248//      AtomComposite Set = getAllAtoms();
     249//      BG->cleanAdjacencyList(Set);
     250      copyBondgraph(oldstep, _step);
     251    }
    212252
    213253    // 3. scan for connected subgraphs => molecules
     
    839879  delete configuration;
    840880  delete Thermostats;
    841   delete homologies;
    842881}
    843882
Note: See TracChangeset for help on using the changeset viewer.