Ignore:
Timestamp:
Sep 18, 2014, 6:24:51 PM (11 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, Candidate_v1.7.0, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
46ce1c
Parents:
7a7b34
git-author:
Frederik Heber <heber@…> (08/16/14 22:56:59)
git-committer:
Frederik Heber <heber@…> (09/18/14 18:24:51)
Message:

Changed how trajectories are stored, not as vecor but as map.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Atom/atom_bondedparticle.cpp

    r7a7b34 r8cc22f  
    5252BondedParticle::BondedParticle()
    5353{
    54   ListOfBonds.push_back(BondList());
     54  ListOfBonds.insert( std::make_pair(0, emptyList) );
    5555};
    5656
     
    5959BondedParticle::~BondedParticle()
    6060{
    61   removeAllBonds();
     61  for(BondTrajectory_t::iterator iter = ListOfBonds.begin(); !ListOfBonds.empty();
     62      iter = ListOfBonds.begin()) {
     63    removeAllBonds(iter->first);
     64    ListOfBonds.erase(iter);
     65  }
    6266};
    6367
     
    220224}
    221225
    222 /** Removes all bonds in all timesteps and their instances, too.
     226/** Removes all bonds in current timestep and their instances, too.
    223227 *
    224228 */
    225229void BondedParticle::removeAllBonds()
    226230{
    227   for (size_t index = 0; index < ListOfBonds.size(); ++index)
    228     removeAllBonds(index);
     231  removeAllBonds(WorldTime::getTime());
    229232}
    230233
     
    236239{
    237240  //LOG(3,"INFO: Clearing all bonds of " << *this << ": " << ListOfBonds[_step]);
    238   for (BondList::iterator iter = (ListOfBonds[_step]).begin();
    239       !(ListOfBonds[_step]).empty();
    240       iter = (ListOfBonds[_step]).begin()) {
    241     //LOG(3,"INFO: Clearing bond (" << *iter << ") " << *(*iter) << " of list " << &ListOfBonds);
    242     atom * const Other = (*iter)->GetOtherAtom(this);
    243     ASSERT( Other != NULL,
    244         "BondedParticle::removeAllBonds() - cannot find bond partner for "
    245         +toString(**iter)+".");
    246     Other->UnregisterBond(_step, *iter);
    247     UnregisterBond(_step, *iter);
    248   }
     241  BondTrajectory_t::iterator listiter = ListOfBonds.find(_step);
     242  if (listiter != ListOfBonds.end())
     243    for (BondList::iterator iter = listiter->second.begin();
     244        !listiter->second.empty();
     245        iter = listiter->second.begin()) {
     246      //LOG(3,"INFO: Clearing bond (" << *iter << ") " << *(*iter) << " of list " << &ListOfBonds);
     247      atom * const Other = (*iter)->GetOtherAtom(this);
     248      ASSERT( Other != NULL,
     249          "BondedParticle::removeAllBonds() - cannot find bond partner for "
     250          +toString(**iter)+".");
     251      Other->UnregisterBond(_step, *iter);
     252      UnregisterBond(_step, *iter);
     253    }
    249254}
    250255
     
    260265    if (Binder->Contains(this)) {
    261266      //LOG(3,"INFO: Registering bond "<< *Binder << " with atom " << *this << " at step " << _step);
    262       if (ListOfBonds.size() <= _step)
    263         ListOfBonds.resize(_step+1);
    264       ListOfBonds[_step].push_back(Binder);
     267      std::pair< BondTrajectory_t::iterator, bool> inserter =
     268          ListOfBonds.insert( std::make_pair( _step, BondList(1, Binder)) );
     269      if (!inserter.second)
     270        inserter.first->second.push_back(Binder);
    265271      if (WorldTime::getTime() == _step)
    266272        NOTIFY(AtomObservable::BondsAdded);
     
    290296      OBSERVE;
    291297      //LOG(0,"INFO: Unregistering bond "<< *Binder << " from list " << &ListOfBonds << " of atom " << *this << " at step " << step);
     298      BondTrajectory_t::iterator listiter = ListOfBonds.find(_step);
     299      if (listiter != ListOfBonds.end()) {
    292300#ifndef NDEBUG
    293       BondList::const_iterator iter =
    294           std::find(ListOfBonds[_step].begin(), ListOfBonds[_step].end(), Binder);
    295       ASSERT( iter != ListOfBonds[_step].end(),
    296           "BondedParticle::UnregisterBond() - "+toString(*Binder)+" not contained at "
    297           +toString(_step));
     301        BondList::const_iterator iter =
     302            std::find(listiter->second.begin(), listiter->second.end(), Binder);
     303        ASSERT( iter != listiter->second.end(),
     304            "BondedParticle::UnregisterBond() - "+toString(*Binder)+" not contained at "
     305            +toString(_step));
    298306#endif
    299       Binder->removeAtom(this);
    300       ListOfBonds[_step].remove(Binder);
    301       if (WorldTime::getTime() == _step)
    302         NOTIFY(AtomObservable::BondsRemoved);
    303       status = true;
     307        Binder->removeAtom(this);
     308        listiter->second.remove(Binder);
     309        if (WorldTime::getTime() == _step)
     310          NOTIFY(AtomObservable::BondsRemoved);
     311        status = true;
     312      }
    304313    } else {
    305314      ELOG(1, *Binder << " does not contain " << *this << ".");
     
    328337{
    329338  int step = -1;
    330   int tempstep = 0;
    331   for(std::vector<BondList>::const_iterator iter = ListOfBonds.begin();
    332       iter != ListOfBonds.end();
    333       ++iter,++tempstep) {
    334     for (BondList::const_iterator bonditer = iter->begin();
    335         bonditer != iter->end();
     339  for(BondTrajectory_t::const_iterator listiter = ListOfBonds.begin();
     340      listiter != ListOfBonds.end();
     341      ++listiter) {
     342    for (BondList::const_iterator bonditer = listiter->second.begin();
     343        bonditer != listiter->second.end();
    336344        ++bonditer) {
    337345      if ((*bonditer) == Binder) {
    338         step = tempstep;
     346        step = listiter->first;
    339347        break;
    340348      }
Note: See TracChangeset for help on using the changeset viewer.