Changeset 05a2c5 for src


Ignore:
Timestamp:
May 8, 2017, 2:00:10 PM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
ForceAnnealing_goodresults, ForceAnnealing_tocheck
Children:
c1446cd
Parents:
f97bcc
git-author:
Frederik Heber <heber@…> (03/23/17 17:11:47)
git-committer:
Frederik Heber <frederik.heber@…> (05/08/17 14:00:10)
Message:

FIX: Fixing the use of the trajectories that were changed to maps.

  • as the atom's trajectories are now stored inside a map, i.e. not every step necessarily needs to be present, there will still some places in the code that were meant for the old vector storing.
  • Atom::UpdateStep() updates the current step, not the future step.
  • AtomInfo::append/removeTrajectoryStep() now no longer ASSERT that the step is not the current one. Due to the trajectory in map concept (with current it simply sought by lower_bound()) this is no longer necessary.
  • HydrogenPool no longer adds all trajectory steps till current time.
  • World has commented out code for also copying the current atom positions in case a new time step is added, but this is not used as so far we do not recognize whether it is a new time step ... and also it is not really necessary.
Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Atom/atom.cpp

    rf97bcc r05a2c5  
    103103  LOG(4,"atom::UpdateStep() called.");
    104104  // append to position, velocity and force vector
    105   AtomInfo::AppendTrajectoryStep(WorldTime::getTime()+1);
     105  AtomInfo::AppendTrajectoryStep(WorldTime::getTime());
    106106  // append to ListOfBonds vector
    107   BondedParticleInfo::AppendTrajectoryStep(WorldTime::getTime()+1);
     107  BondedParticleInfo::AppendTrajectoryStep(WorldTime::getTime());
    108108}
    109109
  • src/Atom/atom_atominfo.cpp

    rf97bcc r05a2c5  
    9191void AtomInfo::AppendTrajectoryStep(const unsigned int _step)
    9292{
    93   ASSERT (WorldTime::getTime() != _step,
    94       "AtomInfo::AppendTrajectoryStep() - cannot append current time step.");
    9593  NOTIFY(TrajectoryChanged);
    9694  AtomicPosition.insert( std::make_pair(_step, zeroVec) );
     
    105103void AtomInfo::removeTrajectoryStep(const unsigned int _step)
    106104{
    107   ASSERT (WorldTime::getTime() != _step,
    108       "AtomInfo::removeTrajectoryStep() - cannot remove current time step.");
    109105  NOTIFY(TrajectoryChanged);
    110106  AtomicPosition.erase(_step);
  • src/Fragmentation/Exporters/HydrogenPool.cpp

    rf97bcc r05a2c5  
    9191      +" from pool is already in use.");
    9292  LOG(3, "DEBUG: Leasing " << *Walker << ".");
    93   UpdateSteps(Walker);
    9493  HydrogenInUse.insert( std::make_pair( Walker->getId(), Walker) );
    9594  HydrogenQueue.pop_front();
    9695
    9796  return Walker;
    98 }
    99 
    100 void HydrogenPool::UpdateSteps(atom * _atom) const
    101 {
    102   // make sure we are up to current time step
    103   const size_t CurrentTime = WorldTime::getTime();
    104   for (size_t step = _atom->getTrajectorySize(); step <= CurrentTime; ++step)
    105     _atom->UpdateStep(step);
    10697}
    10798
  • src/Fragmentation/Exporters/HydrogenPool.hpp

    rf97bcc r05a2c5  
    7373  void cleanup();
    7474
    75   /** Helper function to make sure \a _atom is up to current time step.
    76    *
    77    * \param _atom atom to bring trajectory size up to speed
    78    */
    79   void UpdateSteps(atom * _atom) const;
    80 
    81 
    8275private:
    8376  //!> typedef for the deque of available hydrogens.
  • src/World.cpp

    rf97bcc r05a2c5  
    221221}
    222222
    223 bool areBondsPresent(const unsigned int _step)
     223static bool areBondsPresent(const unsigned int _step)
    224224{
    225225  bool status = false;
     
    229229    const atom * const Walker = *iter;
    230230    status |= !Walker->getListOfBondsAtStep(_step).empty();
     231  }
     232
     233  return status;
     234}
     235
     236static bool areAtomsPresent(const unsigned int _step)
     237{
     238  bool status = false;
     239
     240  for (World::AtomConstIterator iter = const_cast<const World &>(World::getInstance()).getAtomIter();
     241      (!status) && (iter != const_cast<const World &>(World::getInstance()).atomEnd()); ++iter) {
     242    const atom * const Walker = *iter;
     243    status |= (Walker->getTrajectorySize() >= _step);
    231244  }
    232245
     
    259272}
    260273
    261 static void copyAtoms(const unsigned int _srcstep, const unsigned int _deststep)
    262 {
    263   for (World::AtomIterator iter = World::getInstance().getAtomIter();
    264       iter != World::getInstance().atomEnd(); ++iter) {
    265     atom * const Walker = *iter;
    266     Walker->UpdateStep(_deststep);
    267     Walker->setPositionAtStep(_deststep, Walker->getPositionAtStep(_srcstep));
    268     Walker->setAtomicVelocityAtStep(_deststep, Walker->getAtomicVelocityAtStep(_srcstep));
    269     Walker->setAtomicForceAtStep(_deststep, Walker->getAtomicForceAtStep(_srcstep));
    270   }
    271 }
     274//static void copyAtoms(const unsigned int _srcstep, const unsigned int _deststep)
     275//{
     276//  for (World::AtomIterator iter = World::getInstance().getAtomIter();
     277//      iter != World::getInstance().atomEnd(); ++iter) {
     278//    atom * const Walker = *iter;
     279//    Walker->UpdateStep(_deststep);
     280//    Walker->setPositionAtStep(_deststep, Walker->getPositionAtStep(_srcstep));
     281//    Walker->setAtomicVelocityAtStep(_deststep, Walker->getAtomicVelocityAtStep(_srcstep));
     282//    Walker->setAtomicForceAtStep(_deststep, Walker->getAtomicForceAtStep(_srcstep));
     283//  }
     284//}
    272285
    273286void World::setTime(const unsigned int _step)
     
    276289    const unsigned int oldstep = WorldTime::getTime();
    277290
    278     copyAtoms(oldstep, _step);
     291//    if (!areAtomsPresent(_step))
     292//      copyAtoms(oldstep, _step);
     293
    279294    // 1. copy bond graph (such not each addBond causes GUI update)
    280295    if (!areBondsPresent(_step)) {
Note: See TracChangeset for help on using the changeset viewer.