Changeset 0f9726 for src


Ignore:
Timestamp:
Nov 7, 2017, 7:34:56 AM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
ForceAnnealing_with_BondGraph_continued_betteresults
Children:
38ac25
Parents:
5a289c
git-author:
Frederik Heber <frederik.heber@…> (08/03/17 10:46:48)
git-committer:
Frederik Heber <frederik.heber@…> (11/07/17 07:34:56)
Message:

atom::removeStep() extended to removing interval of steps.

  • AtomInfo::removeTrajectorySteps() and BondedParticle::removeTrajectorySteps() changed and all calls adapted.
Location:
src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/MoleculeAction/VerletIntegrationAction.cpp

    r5a289c r0f9726  
    134134
    135135  // remove current step for all modified atoms
    136   removeLastStep(getIdsFromAtomicInfo(state->UndoInfo), CurrentStep+1);
     136  removeSteps(getIdsFromAtomicInfo(state->UndoInfo), CurrentStep+1, CurrentStep+1);
    137137
    138138  // and set back the old step (forces have been changed)
  • src/Actions/UndoRedoHelpers.cpp

    r5a289c r0f9726  
    219219}
    220220
    221 void MoleCuilder::removeLastStep(const std::vector<atomId_t> &_atoms, const unsigned int _step)
    222 {
    223   for (size_t i=0; i<_atoms.size(); ++i) {
    224     atom * const _atom = World::getInstance().getAtom(AtomById(_atoms[i]));
    225     _atom->removeStep(_step);
     221void MoleCuilder::removeSteps(
     222    const std::vector<atomId_t> &movedatoms,
     223    const unsigned int _firststep,
     224    const unsigned int _laststep)
     225{
     226  for (std::vector<atomId_t>::const_iterator iter = movedatoms.begin();
     227      iter != movedatoms.end(); ++iter) {
     228    atom * const _atom = World::getInstance().getAtom(AtomById(*iter));
     229    _atom->removeSteps(_firststep, _laststep);
    226230  }
    227231}
  • src/Actions/UndoRedoHelpers.hpp

    r5a289c r0f9726  
    111111  void RemoveMoleculesWithAtomsByIds(const std::vector<moleculeId_t> &ids);
    112112
    113   /** Removes the last time step for all \a movedatoms
     113  /** Removes the time steps in given interval for all \a movedatoms.
    114114   *
    115    * @param movedatoms atoms whose last step in time to remove
    116    * @param _step which trajectory to remove
     115   * @param movedatoms atoms whose steps in [\a _firststep, \a _laststep] in time to remove
     116   * @param _firststep first step in interval to be removed
     117   * @param _laststep last step in interval to be removed
    117118   */
    118   void removeLastStep(const std::vector<atomId_t> &movedatoms, const unsigned int _step);
     119  void removeSteps(
     120      const std::vector<atomId_t> &movedatoms,
     121      const unsigned int _firststep,
     122      const unsigned int _laststep);
    119123
    120124  /** Adds another time step to all \a movedatoms.
  • src/Atom/TesselPoint.cpp

    r5a289c r0f9726  
    5858};
    5959
    60 void TesselPoint::removeStep(const unsigned int _step)
     60void TesselPoint::removeSteps(const unsigned int _firststep, const unsigned int _laststep)
    6161{
    62   ASSERT(0, "TesselPoint::removeStep() should never be called, TesselPoints don't have trajectories.");
    63   AtomInfo::removeTrajectoryStep(_step);
     62  ASSERT(0, "TesselPoint::removeSteps() should never be called, TesselPoints don't have trajectories.");
     63  AtomInfo::removeTrajectorySteps(_firststep, _laststep);
    6464};
    6565
  • src/Atom/TesselPoint.hpp

    r5a289c r0f9726  
    4343   * This allows to decrease all trajectories contained in different classes
    4444   * by one consistently. This is implemented by the topmost class which calls
    45    * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses.
     45   * the real functions, \sa removeTrajectorySteps(), by all necessary subclasses.
     46   *
     47   * \param _firststep first step in interval to be removed
     48   * \param _laststep last step in interval to be removed
    4649   */
    47   virtual void removeStep(const unsigned int _step);
     50  virtual void removeSteps(const unsigned int _firststep, const unsigned int _laststep);
    4851
    4952  /** Getter for this.
  • src/Atom/atom.cpp

    r5a289c r0f9726  
    108108}
    109109
    110 void atom::removeStep(const unsigned int _step)
    111 {
    112   LOG(4,"atom::removeStep() called.");
     110void atom::removeSteps(const unsigned int _firststep, const unsigned int _laststep)
     111{
     112  LOG(4,"atom::removeSteps() called.");
    113113  // append to position, velocity and force vector
    114   AtomInfo::removeTrajectoryStep(_step);
     114  AtomInfo::removeTrajectorySteps(_firststep, _laststep);
    115115  // append to ListOfBonds vector
    116   BondedParticleInfo::removeTrajectoryStep(_step);
     116  BondedParticleInfo::removeTrajectorySteps(_firststep, _laststep);
    117117}
    118118
  • src/Atom/atom.hpp

    r5a289c r0f9726  
    7979   * This allows to decrease all trajectories contained in different classes
    8080   * by one consistently. This is implemented by the topmost class which calls
    81    * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses.
    82    */
    83   virtual void removeStep(const unsigned int _step);
     81   * the real functions, \sa removeTrajectorySteps(), by all necessary subclasses.
     82   *
     83   * \param _firststep first step in interval to be removed
     84   * \param _laststep last step in interval to be removed
     85   */
     86  virtual void removeSteps(const unsigned int _firststep, const unsigned int _laststep);
    8487
    8588  /** Output of a single atom with given numbering.
  • src/Atom/atom_atominfo.cpp

    r5a289c r0f9726  
    101101}
    102102
    103 void AtomInfo::removeTrajectoryStep(const unsigned int _step)
     103void AtomInfo::eraseInTrajctory(
     104    VectorTrajectory_t &_trajectory,
     105    const unsigned int _firststep, const unsigned int _laststep)
     106{
     107  const VectorTrajectory_t::iterator firstiter = _trajectory.lower_bound(_firststep);
     108  const VectorTrajectory_t::iterator lastiter = _trajectory.upper_bound(_laststep);
     109  _trajectory.erase(firstiter, lastiter);
     110}
     111
     112void AtomInfo::removeTrajectorySteps(const unsigned int _firststep, const unsigned int _laststep)
    104113{
    105114  NOTIFY(TrajectoryChanged);
    106   AtomicPosition.erase(_step);
    107   AtomicVelocity.erase(_step);
    108   AtomicForce.erase(_step);
    109   LOG(5,"AtomInfo::removeTrajectoryStep() called, size is ("
     115  eraseInTrajctory(AtomicPosition, _firststep, _laststep);
     116  eraseInTrajctory(AtomicVelocity, _firststep, _laststep);
     117  eraseInTrajctory(AtomicForce, _firststep, _laststep);
     118  LOG(5,"AtomInfo::removeTrajectorySteps() called, size is ("
    110119      << AtomicPosition.size() << ","
    111120      << AtomicVelocity.size() << ","
  • src/Atom/atom_atominfo.hpp

    r5a289c r0f9726  
    5858  virtual void UpdateStep(const unsigned int _step)=0;
    5959
    60   /** Pops the last step in all trajectory vectors.
     60  /** Pops all steps in the interval [\a _firststep, \a _laststep] in all trajectory vectors.
    6161   *
    6262   * This allows to decrease all trajectories contained in different classes
    6363   * by one consistently. This is implemented by the topmost class which calls
    64    * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses.
    65    */
    66   virtual void removeStep(const unsigned int _step)=0;
     64   * the real functions, \sa removeTrajectorySteps(), by all necessary subclasses.
     65   *
     66   * \param _firststep first step in interval to be removed
     67   * \param _laststep last step in interval to be removed
     68   */
     69  virtual void removeSteps(const unsigned int _firststep, const unsigned int _laststep)=0;
    6770
    6871  /** DEPRECATED: Getter for element indicated by AtomicElement.
     
    314317  /** Function used by this and inheriting classes to decrease the trajectory
    315318   * vectors by one.
    316    */
    317   void removeTrajectoryStep(const unsigned int _step);
     319   *
     320   * \param _firststep first step in interval to be removed
     321   * \param _laststep last step in interval to be removed
     322   */
     323  void removeTrajectorySteps(const unsigned int _firststep, const unsigned int _laststep);
    318324
    319325  // make these protected only such that deriving atom class still has full
     
    325331  VectorTrajectory_t AtomicVelocity;       //!< velocity vector of atom, giving last velocity within cell
    326332  VectorTrajectory_t AtomicForce;       //!< Force vector of atom, giving last force within cell
     333
     334  /** Helper function to avoid an interval of steps in VectorTrajectory_t.
     335   *
     336   * \param  _trajectory trajectory to remove in
     337   * \param _firststep first step in interval to be removed
     338   * \param _laststep last step in interval to be removed
     339   */
     340  static void eraseInTrajctory(
     341      VectorTrajectory_t &_trajectory,
     342      const unsigned int _firststep, const unsigned int _laststep);
    327343
    328344private:
  • src/Atom/atom_bondedparticleinfo.cpp

    r5a289c r0f9726  
    5151}
    5252
    53 void BondedParticleInfo::removeTrajectoryStep(const unsigned int _step)
     53void BondedParticleInfo::removeTrajectorySteps(const unsigned int _firststep, const unsigned int _laststep)
    5454{
    55   ListOfBonds.erase(_step);
    56   LOG(5,"BondedParticleInfo::removeTrajectoryStep() called, size is " << ListOfBonds.size());
     55  const BondTrajectory_t::iterator firstiter = ListOfBonds.lower_bound(_firststep);
     56  const BondTrajectory_t::iterator lastiter = ListOfBonds.upper_bound(_laststep);
     57  ListOfBonds.erase(firstiter, lastiter);
     58  LOG(5,"BondedParticleInfo::removeTrajectorySteps() called, size is " << ListOfBonds.size());
    5759}
    5860
  • src/Atom/atom_bondedparticleinfo.hpp

    r5a289c r0f9726  
    5252   * This allows to decrease all trajectories contained in different classes
    5353   * by one consistently. This is implemented by the topmost class which calls
    54    * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses.
     54   * the real functions, \sa removeTrajectorySteps(), by all necessary subclasses.
     55   *
     56   * \param _firststep first step in interval to be removed
     57   * \param _laststep last step in interval to be removed
    5558   */
    56   virtual void removeStep(const unsigned int _step)=0;
     59  virtual void removeSteps(const unsigned int _firststep, const unsigned int _laststep)=0;
    5760
    5861  /** Const accessor to ListOfBonds of WorldTime::CurrentTime.
     
    131134  /** Function used by this and inheriting classes to reduce the ListOfBonds
    132135   * vector by one.
     136   *
     137   * \param _firststep first step in interval to be removed
     138   * \param _laststep last step in interval to be removed
    133139   */
    134   void removeTrajectoryStep(const unsigned int _step);
     140  void removeTrajectorySteps(const unsigned int _firststep, const unsigned int _laststep);
    135141
    136142  typedef std::map<unsigned int, BondList> BondTrajectory_t;
Note: See TracChangeset for help on using the changeset viewer.