Changeset b119a0
- Timestamp:
- Oct 19, 2014, 5:10:16 PM (10 years ago)
- 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, 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:
- 5c8807
- Parents:
- 9e1bfb (diff), 46ce1c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/ForceAnnealingAction.cpp
r9e1bfb rb119a0 79 79 ++iter) { 80 80 atom * const Walker = iter->second; 81 Walker->UpdateSteps();82 81 Walker->setPositionAtStep(CurrentStep+1, 83 82 Walker->getPositionAtStep(CurrentStep)); -
src/Actions/MoleculeAction/VerletIntegrationAction.cpp
r9e1bfb rb119a0 56 56 using namespace MoleCuilder; 57 57 58 enum {58 enum VectorIndexType { 59 59 PositionIndex=0, 60 60 VelocityIndex=1, 61 61 ForceIndex=2, 62 62 MAXINDEX 63 } VectorIndexType;63 }; 64 64 65 65 // and construct the stuff … … 134 134 135 135 // remove current step for all modified atoms 136 removeLastStep(getIdsFromAtomicInfo(state->UndoInfo) );136 removeLastStep(getIdsFromAtomicInfo(state->UndoInfo), CurrentStep); 137 137 138 138 // and set back the old step (forces have been changed) … … 151 151 152 152 // set stored new state 153 addNewStep(state->UndoInfo); 153 size_t CurrentStep = WorldTime::getInstance().getTime()+1; 154 addNewStep(state->UndoInfo, CurrentStep); 154 155 155 156 // add a new time step 156 size_t CurrentStep = WorldTime::getInstance().getTime(); 157 World::getInstance().setTime(CurrentStep+1); 157 World::getInstance().setTime(CurrentStep); 158 158 159 159 // and set positions of the new step -
src/Actions/UndoRedoHelpers.cpp
r9e1bfb rb119a0 181 181 } 182 182 183 void MoleCuilder::removeLastStep(const std::vector<atomId_t> &_atoms )183 void MoleCuilder::removeLastStep(const std::vector<atomId_t> &_atoms, const unsigned int _step) 184 184 { 185 185 for (size_t i=0; i<_atoms.size(); ++i) { 186 186 atom * const _atom = World::getInstance().getAtom(AtomById(_atoms[i])); 187 _atom->removeStep s();188 } 189 } 190 191 void MoleCuilder::addNewStep(const std::vector<AtomicInfo> &_movedatoms )187 _atom->removeStep(_step); 188 } 189 } 190 191 void MoleCuilder::addNewStep(const std::vector<AtomicInfo> &_movedatoms, const unsigned int _step) 192 192 { 193 193 for(size_t i=0; i< _movedatoms.size(); ++i) { 194 194 atom * const _atom = World::getInstance().getAtom(AtomById(_movedatoms[i].getId())); 195 _atom->UpdateStep s();196 } 197 } 198 199 void MoleCuilder::addNewStep(const std::vector<atomId_t> &_ids )195 _atom->UpdateStep(_step); 196 } 197 } 198 199 void MoleCuilder::addNewStep(const std::vector<atomId_t> &_ids, const unsigned int _step) 200 200 { 201 201 for(size_t i=0; i< _ids.size(); ++i) { 202 202 atom * const _atom = World::getInstance().getAtom(AtomById(_ids[i])); 203 _atom->UpdateStep s();203 _atom->UpdateStep(_step); 204 204 } 205 205 } -
src/Actions/UndoRedoHelpers.hpp
r9e1bfb rb119a0 107 107 * 108 108 * @param movedatoms atoms whose last step in time to remove 109 * @param _step which trajectory to remove 109 110 */ 110 void removeLastStep(const std::vector<atomId_t> &movedatoms );111 void removeLastStep(const std::vector<atomId_t> &movedatoms, const unsigned int _step); 111 112 112 113 /** Adds another time step to all \a movedatoms. … … 115 116 * 116 117 * @param _ids atoms whose last step in time to remove 118 * @param _step which trajectory to insert/assign 117 119 */ 118 void addNewStep(const std::vector<atomId_t> &_ids );120 void addNewStep(const std::vector<atomId_t> &_ids, const unsigned int _step); 119 121 120 122 /** Adds another time step to all \a movedatoms. … … 124 126 * 125 127 * @param _movedatoms atoms whose last step in time to remove 128 * @param _step which trajectory to insert/assign 126 129 */ 127 void addNewStep(const std::vector<AtomicInfo> &_movedatoms );130 void addNewStep(const std::vector<AtomicInfo> &_movedatoms, const unsigned int _step); 128 131 129 132 /** Helper function to extract id information from vector of AtomicInfo. -
src/Atom/TesselPoint.cpp
r9e1bfb rb119a0 52 52 {}; 53 53 54 void TesselPoint::UpdateStep s()54 void TesselPoint::UpdateStep(const unsigned int _step) 55 55 { 56 ASSERT(0, "TesselPoint::UpdateStep s() should never be called, TesselPoints don't have trajectories.");57 AtomInfo::AppendTrajectoryStep( );56 ASSERT(0, "TesselPoint::UpdateStep() should never be called, TesselPoints don't have trajectories."); 57 AtomInfo::AppendTrajectoryStep(_step); 58 58 }; 59 59 60 void TesselPoint::removeStep s()60 void TesselPoint::removeStep(const unsigned int _step) 61 61 { 62 ASSERT(0, "TesselPoint::removeStep s() should never be called, TesselPoints don't have trajectories.");63 AtomInfo::removeTrajectoryStep( );62 ASSERT(0, "TesselPoint::removeStep() should never be called, TesselPoints don't have trajectories."); 63 AtomInfo::removeTrajectoryStep(_step); 64 64 }; 65 65 -
src/Atom/TesselPoint.hpp
r9e1bfb rb119a0 37 37 * 38 38 */ 39 virtual void UpdateStep s();39 virtual void UpdateStep(const unsigned int _step); 40 40 41 41 /** Pops the last step in all trajectory vectors. … … 45 45 * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses. 46 46 */ 47 virtual void removeStep s();47 virtual void removeStep(const unsigned int _step); 48 48 49 49 /** Getter for this. -
src/Atom/atom.cpp
r9e1bfb rb119a0 69 69 mol(0) 70 70 { 71 AtomicPosition = pointer->AtomicPosition; // copy trajectory of coordination72 AtomicVelocity = pointer->AtomicVelocity; // copy trajectory of velocity73 AtomicForce = pointer->AtomicForce;74 71 // sign on to global atom change tracker 75 72 AtomObserver::getInstance().AtomInserted(this); … … 93 90 94 91 95 void atom::UpdateStep s()96 { 97 LOG(4,"atom::UpdateStep s() called.");92 void atom::UpdateStep(const unsigned int _step) 93 { 94 LOG(4,"atom::UpdateStep() called."); 98 95 // append to position, velocity and force vector 99 AtomInfo::AppendTrajectoryStep( );96 AtomInfo::AppendTrajectoryStep(WorldTime::getTime()+1); 100 97 // append to ListOfBonds vector 101 BondedParticleInfo::AppendTrajectoryStep( );102 } 103 104 void atom::removeStep s()105 { 106 LOG(4,"atom::removeStep s() called.");98 BondedParticleInfo::AppendTrajectoryStep(WorldTime::getTime()+1); 99 } 100 101 void atom::removeStep(const unsigned int _step) 102 { 103 LOG(4,"atom::removeStep() called."); 107 104 // append to position, velocity and force vector 108 AtomInfo::removeTrajectoryStep( );105 AtomInfo::removeTrajectoryStep(_step); 109 106 // append to ListOfBonds vector 110 BondedParticleInfo::removeTrajectoryStep( );107 BondedParticleInfo::removeTrajectoryStep(_step); 111 108 } 112 109 … … 313 310 atom* NewAtom(atomId_t _id){ 314 311 atom * res = new atom(); 315 // extent trajectory to current time step316 const size_t CurrentTime = WorldTime::getTime();317 for (size_t step = res->getTrajectorySize(); step <= CurrentTime; ++step)318 res->UpdateSteps();319 312 res->setId(_id); 320 313 return res; -
src/Atom/atom.hpp
r9e1bfb rb119a0 65 65 * real functions, \sa AppendTrajectoryStep(), by all necessary subclasses. 66 66 */ 67 virtual void UpdateStep s();67 virtual void UpdateStep(const unsigned int _step); 68 68 69 69 /** Pops the last step in all trajectory vectors. … … 73 73 * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses. 74 74 */ 75 virtual void removeStep s();75 virtual void removeStep(const unsigned int _step); 76 76 77 77 /** Output of a single atom with given numbering. -
src/Atom/atom_atominfo.cpp
r9e1bfb rb119a0 3 3 * Description: creates and alters molecular systems 4 4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved. 5 * Copyright (C) 2014 Frederik Heber. All rights reserved. 5 6 * 6 7 * … … 55 56 charge(0.) 56 57 { 57 AtomicPosition.reserve(1); 58 AtomicPosition.push_back(zeroVec); 59 AtomicVelocity.reserve(1); 60 AtomicVelocity.push_back(zeroVec); 61 AtomicForce.reserve(1); 62 AtomicForce.push_back(zeroVec); 63 64 }; 58 AtomicPosition.insert( std::make_pair(0, zeroVec) ); 59 AtomicVelocity.insert( std::make_pair(0, zeroVec) ); 60 AtomicForce.insert( std::make_pair(0, zeroVec) ); 61 } 65 62 66 63 /** Copy constructor of class AtomInfo. … … 68 65 AtomInfo::AtomInfo(const AtomInfo &_atom) : 69 66 AtomicPosition(_atom.AtomicPosition), 67 AtomicVelocity(_atom.AtomicVelocity), 68 AtomicForce(_atom.AtomicForce), 70 69 AtomicElement(_atom.AtomicElement), 71 70 FixedIon(_atom.FixedIon), 72 71 charge(_atom.charge) 73 72 { 74 AtomicVelocity.reserve(1); 75 AtomicVelocity.push_back(zeroVec); 76 AtomicForce.reserve(1); 77 AtomicForce.push_back(zeroVec); 78 }; 73 } 79 74 80 75 AtomInfo::AtomInfo(const VectorInterface &_v) : … … 83 78 charge(0.) 84 79 { 85 if (AtomicPosition.size() < 1) 86 AtomicPosition.resize(1); 87 AtomicPosition[0] = _v.getPosition(); 88 AtomicVelocity.reserve(1); 89 AtomicVelocity.push_back(zeroVec); 90 AtomicForce.reserve(1); 91 AtomicForce.push_back(zeroVec); 80 AtomicPosition.insert( std::make_pair(0, _v.getPosition()) ); 81 AtomicVelocity.insert( std::make_pair(0, zeroVec) ); 82 AtomicForce.insert( std::make_pair(0, zeroVec) ); 92 83 }; 93 84 … … 98 89 }; 99 90 100 void AtomInfo::AppendTrajectoryStep() 101 { 102 NOTIFY(TrajectoryChanged); 103 AtomicPosition.push_back(zeroVec); 104 AtomicVelocity.push_back(zeroVec); 105 AtomicForce.push_back(zeroVec); 91 void AtomInfo::AppendTrajectoryStep(const unsigned int _step) 92 { 93 if (WorldTime::getTime() == _step) 94 NOTIFY(TrajectoryChanged); 95 AtomicPosition.insert( std::make_pair(_step, zeroVec) ); 96 AtomicVelocity.insert( std::make_pair(_step, zeroVec) ); 97 AtomicForce.insert( std::make_pair(_step, zeroVec) ); 106 98 LOG(5,"AtomInfo::AppendTrajectoryStep() called, size is (" 107 99 << AtomicPosition.size() << "," … … 110 102 } 111 103 112 void AtomInfo::removeTrajectoryStep() 113 { 114 NOTIFY(TrajectoryChanged); 115 AtomicPosition.pop_back(); 116 AtomicVelocity.pop_back(); 117 AtomicForce.pop_back(); 104 void AtomInfo::removeTrajectoryStep(const unsigned int _step) 105 { 106 if (WorldTime::getTime() == _step) 107 NOTIFY(TrajectoryChanged); 108 AtomicPosition.erase(_step); 109 AtomicVelocity.erase(_step); 110 AtomicForce.erase(_step); 118 111 LOG(5,"AtomInfo::removeTrajectoryStep() called, size is (" 119 112 << AtomicPosition.size() << "," … … 141 134 const double& AtomInfo::operator[](size_t i) const 142 135 { 143 ASSERT(AtomicPosition.size() > WorldTime::getTime(), 144 "AtomInfo::operator[]() - Access out of range: " 145 +toString(WorldTime::getTime()) 146 +" not in [0,"+toString(AtomicPosition.size())+")."); 147 return AtomicPosition[WorldTime::getTime()][i]; 136 return atStep(i, WorldTime::getTime()); 148 137 } 149 138 150 139 const double& AtomInfo::at(size_t i) const 151 140 { 152 ASSERT(AtomicPosition.size() > WorldTime::getTime(), 153 "AtomInfo::at() - Access out of range: " 154 +toString(WorldTime::getTime()) 155 +" not in [0,"+toString(AtomicPosition.size())+")."); 156 return AtomicPosition[WorldTime::getTime()].at(i); 141 return atStep(i, WorldTime::getTime()); 157 142 } 158 143 159 144 const double& AtomInfo::atStep(size_t i, unsigned int _step) const 160 145 { 161 ASSERT( AtomicPosition.size() > _step,162 "AtomInfo:: atStep() - Access out of range: "163 +toString(_step)164 +" not in [0,"+toString(AtomicPosition.size())+").");165 return AtomicPosition[_step].at(i);146 ASSERT(!AtomicPosition.empty(), 147 "AtomInfo::operator[]() - AtomicPosition is empty."); 148 VectorTrajectory_t::const_iterator iter = 149 AtomicPosition.lower_bound(_step); 150 return iter->second[i]; 166 151 } 167 152 … … 170 155 OBSERVE; 171 156 NOTIFY(AtomObservable::PositionChanged); 172 ASSERT(AtomicPosition.size() > WorldTime::getTime(), 173 "AtomInfo::set() - Access out of range: " 174 +toString(WorldTime::getTime()) 175 +" not in [0,"+toString(AtomicPosition.size())+")."); 176 AtomicPosition[WorldTime::getTime()].at(i) = value; 157 VectorTrajectory_t::iterator iter = AtomicPosition.find(WorldTime::getTime()); 158 if (iter != AtomicPosition.end()) { 159 iter->second[i] = value; 160 } else { 161 Vector newPos; 162 newPos[i] = value; 163 #ifndef NDEBUG 164 std::pair<VectorTrajectory_t::iterator, bool> inserter = 165 #endif 166 AtomicPosition.insert( std::make_pair(WorldTime::getTime(), newPos) ); 167 ASSERT( inserter.second, 168 "AtomInfo::set() - time step "+toString(WorldTime::getTime()) 169 +" present after all?"); 170 } 171 } 172 173 /** Helps to determine whether the current step really exists or getPosition() has just 174 * delivered the one closest to it in the past. 175 * 176 * \param _step step to check 177 * \param true - step exists, false - step does not exist, getPosition() delivers closest 178 */ 179 bool AtomInfo::isStepPresent(const unsigned int _step) const 180 { 181 VectorTrajectory_t::const_iterator iter = 182 AtomicPosition.find(_step); 183 return iter != AtomicPosition.end(); 177 184 } 178 185 179 186 const Vector& AtomInfo::getPosition() const 180 187 { 181 ASSERT(AtomicPosition.size() > WorldTime::getTime(), 182 "AtomInfo::getPosition() - Access out of range: " 183 +toString(WorldTime::getTime()) 184 +" not in [0,"+toString(AtomicPosition.size())+")."); 185 return AtomicPosition[WorldTime::getTime()]; 188 return getPositionAtStep(WorldTime::getTime()); 186 189 } 187 190 188 191 const Vector& AtomInfo::getPositionAtStep(const unsigned int _step) const 189 192 { 190 ASSERT( _step < AtomicPosition.size(),191 "AtomInfo:: getPositionAtStep() - Access out of range: "192 +toString(_step)193 +" not in [0,"+toString(AtomicPosition.size())+").");194 return AtomicPosition[_step];193 ASSERT(!AtomicPosition.empty(), 194 "AtomInfo::operator[]() - AtomicPosition is empty."); 195 VectorTrajectory_t::const_iterator iter = 196 AtomicPosition.lower_bound(_step); 197 return iter->second; 195 198 } 196 199 … … 207 210 { 208 211 const element *elem = World::getInstance().getPeriode()->FindElement(Z); 209 if (elem != NULL) { 210 OBSERVE; 211 NOTIFY(AtomObservable::ElementChanged); 212 AtomicElement = Z; 213 } 214 } 215 216 //Vector& AtomInfo::getAtomicVelocity() 217 //{ 218 // return AtomicVelocity[0]; 219 //} 220 221 //Vector& AtomInfo::getAtomicVelocity(const int _step) 222 //{ 223 // ASSERT(_step < AtomicVelocity.size(), 224 // "AtomInfo::getAtomicVelocity() - Access out of range."); 225 // return AtomicVelocity[_step]; 226 //} 212 setType(elem); 213 } 227 214 228 215 const Vector& AtomInfo::getAtomicVelocity() const 229 216 { 230 ASSERT(AtomicVelocity.size() > 0, 231 "AtomInfo::getAtomicVelocity() - Access out of range: " 232 +toString(WorldTime::getTime()) 233 +" not in [0,"+toString(AtomicPosition.size())+")."); 234 return AtomicVelocity[WorldTime::getTime()]; 217 return getAtomicVelocityAtStep(WorldTime::getTime()); 235 218 } 236 219 237 220 const Vector& AtomInfo::getAtomicVelocityAtStep(const unsigned int _step) const 238 221 { 239 ASSERT(_step < AtomicVelocity.size(), 240 "AtomInfo::getAtomicVelocity() - Access out of range: " 241 +toString(_step) 242 +" not in [0,"+toString(AtomicPosition.size())+")."); 243 return AtomicVelocity[_step]; 222 ASSERT(!AtomicVelocity.empty(), 223 "AtomInfo::operator[]() - AtomicVelocity is empty."); 224 VectorTrajectory_t::const_iterator iter = 225 AtomicVelocity.lower_bound(_step); 226 // special, we only interpolate between present time steps not into the future 227 if (_step > AtomicVelocity.begin()->first) 228 return zeroVec; 229 else 230 return iter->second; 244 231 } 245 232 246 233 void AtomInfo::setAtomicVelocity(const Vector &_newvelocity) 247 234 { 235 setAtomicVelocityAtStep(WorldTime::getTime(), _newvelocity); 236 } 237 238 void AtomInfo::setAtomicVelocityAtStep(const unsigned int _step, const Vector &_newvelocity) 239 { 248 240 OBSERVE; 249 NOTIFY(AtomObservable::VelocityChanged); 250 ASSERT(WorldTime::getTime() < AtomicVelocity.size(), 251 "AtomInfo::setAtomicVelocity() - Access out of range: " 252 +toString(WorldTime::getTime()) 253 +" not in [0,"+toString(AtomicPosition.size())+")."); 254 AtomicVelocity[WorldTime::getTime()] = _newvelocity; 255 } 256 257 void AtomInfo::setAtomicVelocityAtStep(const unsigned int _step, const Vector &_newvelocity) 258 { 259 OBSERVE; 241 VectorTrajectory_t::iterator iter = AtomicVelocity.find(_step); 242 if (iter != AtomicVelocity.end()) { 243 iter->second = _newvelocity; 244 } else { 245 #ifndef NDEBUG 246 std::pair<VectorTrajectory_t::iterator, bool> inserter = 247 #endif 248 AtomicVelocity.insert( std::make_pair(_step, _newvelocity) ); 249 ASSERT( inserter.second, 250 "AtomInfo::set() - time step "+toString(_step) 251 +" present after all?"); 252 } 260 253 if (WorldTime::getTime() == _step) 261 254 NOTIFY(AtomObservable::VelocityChanged); 262 const unsigned int size = AtomicVelocity.size();263 ASSERT(_step <= size,264 "AtomInfo::setAtomicVelocityAtStep() - Access out of range: "265 +toString(_step)266 +" not in [0,"+toString(size)+"].");267 if(_step < size) {268 AtomicVelocity[_step] = _newvelocity;269 } else if (_step == size) {270 UpdateSteps();271 AtomicVelocity[_step] = _newvelocity;272 }273 255 } 274 256 275 257 const Vector& AtomInfo::getAtomicForce() const 276 258 { 277 ASSERT(WorldTime::getTime() < AtomicForce.size(), 278 "AtomInfo::getAtomicForce() - Access out of range: " 279 +toString(WorldTime::getTime()) 280 +" not in [0,"+toString(AtomicPosition.size())+")."); 281 return AtomicForce[WorldTime::getTime()]; 259 return getAtomicForceAtStep(WorldTime::getTime()); 282 260 } 283 261 284 262 const Vector& AtomInfo::getAtomicForceAtStep(const unsigned int _step) const 285 263 { 286 ASSERT(_step < AtomicForce.size(), 287 "AtomInfo::getAtomicForce() - Access out of range: " 288 +toString(_step) 289 +" not in [0,"+toString(AtomicPosition.size())+")."); 290 return AtomicForce[_step]; 264 ASSERT(!AtomicForce.empty(), 265 "AtomInfo::operator[]() - AtomicForce is empty."); 266 VectorTrajectory_t::const_iterator iter = 267 AtomicForce.lower_bound(_step); 268 // special, we only interpolate between present time steps not into the future 269 if (_step > AtomicForce.begin()->first) 270 return zeroVec; 271 else 272 return iter->second; 291 273 } 292 274 293 275 void AtomInfo::setAtomicForce(const Vector &_newforce) 294 276 { 277 setAtomicForceAtStep(WorldTime::getTime(), _newforce); 278 } 279 280 void AtomInfo::setAtomicForceAtStep(const unsigned int _step, const Vector &_newforce) 281 { 295 282 OBSERVE; 296 NOTIFY(AtomObservable::ForceChanged); 297 ASSERT(WorldTime::getTime() < AtomicForce.size(), 298 "AtomInfo::setAtomicForce() - Access out of range: " 299 +toString(WorldTime::getTime()) 300 +" not in [0,"+toString(AtomicPosition.size())+")."); 301 AtomicForce[WorldTime::getTime()] = _newforce; 302 } 303 304 void AtomInfo::setAtomicForceAtStep(const unsigned int _step, const Vector &_newforce) 305 { 306 OBSERVE; 283 VectorTrajectory_t::iterator iter = AtomicForce.find(_step); 284 if (iter != AtomicForce.end()) { 285 iter->second = _newforce; 286 } else { 287 #ifndef NDEBUG 288 std::pair<VectorTrajectory_t::iterator, bool> inserter = 289 #endif 290 AtomicForce.insert( std::make_pair(_step, _newforce) ); 291 ASSERT( inserter.second, 292 "AtomInfo::set() - time step "+toString(_step) 293 +" present after all?"); 294 } 307 295 if (WorldTime::getTime() == _step) 308 296 NOTIFY(AtomObservable::ForceChanged); 309 const unsigned int size = AtomicForce.size();310 ASSERT(_step <= size,311 "AtomInfo::setAtomicForce() - Access out of range: "312 +toString(_step)313 +" not in [0,"+toString(AtomicPosition.size())+"].");314 if(_step < size) {315 AtomicForce[_step] = _newforce;316 } else if (_step == size) {317 UpdateSteps();318 AtomicForce[_step] = _newforce;319 }320 297 } 321 298 … … 334 311 void AtomInfo::setPosition(const Vector& _vector) 335 312 { 313 setPositionAtStep(WorldTime::getTime(), _vector); 314 } 315 316 void AtomInfo::setPositionAtStep(unsigned int _step, const Vector& _vector) 317 { 336 318 OBSERVE; 337 NOTIFY(AtomObservable::PositionChanged);338 ASSERT(WorldTime::getTime() < AtomicPosition.size(),339 "AtomInfo::setPosition() - Access out of range: "340 +toString(WorldTime::getTime())341 +" not in [0,"+toString(AtomicPosition.size())+")."); 342 AtomicPosition[WorldTime::getTime()] = _vector;343 //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl; 344 } 345 346 void AtomInfo::setPositionAtStep(unsigned int _step, const Vector& _vector)347 { 348 OBSERVE;319 VectorTrajectory_t::iterator iter = AtomicPosition.find(_step); 320 if (iter != AtomicPosition.end()) { 321 iter->second = _vector; 322 } else { 323 #ifndef NDEBUG 324 std::pair<VectorTrajectory_t::iterator, bool> inserter = 325 #endif 326 AtomicPosition.insert( std::make_pair(_step, _vector) ); 327 ASSERT( inserter.second, 328 "AtomInfo::set() - time step "+toString(_step) 329 +" present after all?"); 330 } 349 331 if (WorldTime::getTime() == _step) 350 332 NOTIFY(AtomObservable::PositionChanged); 351 const unsigned int size = AtomicPosition.size();352 ASSERT(_step <= size,353 "AtomInfo::setPosition() - Access out of range: "354 +toString(_step)355 +" not in [0,"+toString(size)+"].");356 if(_step < size) {357 AtomicPosition[_step] = _vector;358 } else if (_step == size) {359 UpdateSteps();360 AtomicPosition[_step] = _vector;361 }362 //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl;363 333 } 364 334 365 335 const VectorInterface& AtomInfo::operator+=(const Vector& b) 366 336 { 367 OBSERVE; 368 NOTIFY(AtomObservable::PositionChanged); 369 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 370 "AtomInfo::operator+=() - Access out of range: " 371 +toString(WorldTime::getTime()) 372 +" not in [0,"+toString(AtomicPosition.size())+")."); 373 AtomicPosition[WorldTime::getTime()] += b; 337 setPosition(getPosition()+b); 374 338 return *this; 375 339 } … … 377 341 const VectorInterface& AtomInfo::operator-=(const Vector& b) 378 342 { 379 OBSERVE; 380 NOTIFY(AtomObservable::PositionChanged); 381 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 382 "AtomInfo::operator-=() - Access out of range: " 383 +toString(WorldTime::getTime()) 384 +" not in [0,"+toString(AtomicPosition.size())+")."); 385 AtomicPosition[WorldTime::getTime()] -= b; 343 setPosition(getPosition()-b); 386 344 return *this; 387 345 } … … 389 347 Vector const AtomInfo::operator+(const Vector& b) const 390 348 { 391 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 392 "AtomInfo::operator+() - Access out of range: " 393 +toString(WorldTime::getTime()) 394 +" not in [0,"+toString(AtomicPosition.size())+")."); 395 Vector a(AtomicPosition[WorldTime::getTime()]); 349 Vector a(getPosition()); 396 350 a += b; 397 351 return a; … … 400 354 Vector const AtomInfo::operator-(const Vector& b) const 401 355 { 402 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 403 "AtomInfo::operator-() - Access out of range: " 404 +toString(WorldTime::getTime()) 405 +" not in [0,"+toString(AtomicPosition.size())+")."); 406 Vector a(AtomicPosition[WorldTime::getTime()]); 356 Vector a(getPosition()); 407 357 a -= b; 408 358 return a; … … 411 361 double AtomInfo::distance(const Vector &point) const 412 362 { 413 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 414 "AtomInfo::distance() - Access out of range: " 415 +toString(WorldTime::getTime()) 416 +" not in [0,"+toString(AtomicPosition.size())+")."); 417 return AtomicPosition[WorldTime::getTime()].distance(point); 363 return getPosition().distance(point); 418 364 } 419 365 420 366 double AtomInfo::DistanceSquared(const Vector &y) const 421 367 { 422 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 423 "AtomInfo::DistanceSquared() - Access out of range: " 424 +toString(WorldTime::getTime()) 425 +" not in [0,"+toString(AtomicPosition.size())+")."); 426 return AtomicPosition[WorldTime::getTime()].DistanceSquared(y); 368 return getPosition().DistanceSquared(y); 427 369 } 428 370 429 371 double AtomInfo::distance(const VectorInterface &_atom) const 430 372 { 431 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 432 "AtomInfo::distance() - Access out of range: " 433 +toString(WorldTime::getTime()) 434 +" not in [0,"+toString(AtomicPosition.size())+")."); 435 return _atom.distance(AtomicPosition[WorldTime::getTime()]); 373 return _atom.distance(getPosition()); 436 374 } 437 375 438 376 double AtomInfo::DistanceSquared(const VectorInterface &_atom) const 439 377 { 440 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 441 "AtomInfo::DistanceSquared() - Access out of range: " 442 +toString(WorldTime::getTime()) 443 +" not in [0,"+toString(AtomicPosition.size())+")."); 444 return _atom.DistanceSquared(AtomicPosition[WorldTime::getTime()]); 378 return _atom.DistanceSquared(getPosition()); 445 379 } 446 380 447 381 VectorInterface &AtomInfo::operator=(const Vector& _vector) 448 382 { 449 OBSERVE; 450 NOTIFY(AtomObservable::PositionChanged); 451 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 452 "AtomInfo::operator=() - Access out of range: " 453 +toString(WorldTime::getTime()) 454 +" not in [0,"+toString(AtomicPosition.size())+")."); 455 AtomicPosition[WorldTime::getTime()] = _vector; 383 setPosition(_vector); 456 384 return *this; 457 385 } … … 459 387 void AtomInfo::ScaleAll(const double *factor) 460 388 { 461 OBSERVE; 462 NOTIFY(AtomObservable::PositionChanged); 463 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 464 "AtomInfo::ScaleAll() - Access out of range: " 465 +toString(WorldTime::getTime()) 466 +" not in [0,"+toString(AtomicPosition.size())+")."); 467 AtomicPosition[WorldTime::getTime()].ScaleAll(factor); 389 Vector temp(getPosition()); 390 temp.ScaleAll(factor); 391 setPosition(temp); 468 392 } 469 393 470 394 void AtomInfo::ScaleAll(const Vector &factor) 471 395 { 472 OBSERVE; 473 NOTIFY(AtomObservable::PositionChanged); 474 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 475 "AtomInfo::ScaleAll() - Access out of range: " 476 +toString(WorldTime::getTime()) 477 +" not in [0,"+toString(AtomicPosition.size())+")."); 478 AtomicPosition[WorldTime::getTime()].ScaleAll(factor); 396 Vector temp(getPosition()); 397 temp.ScaleAll(factor); 398 setPosition(temp); 479 399 } 480 400 481 401 void AtomInfo::Scale(const double factor) 482 402 { 483 OBSERVE; 484 NOTIFY(AtomObservable::PositionChanged); 485 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 486 "AtomInfo::Scale() - Access out of range: " 487 +toString(WorldTime::getTime()) 488 +" not in [0,"+toString(AtomicPosition.size())+")."); 489 AtomicPosition[WorldTime::getTime()].Scale(factor); 403 Vector temp(getPosition()); 404 temp.Scale(factor); 405 setPosition(temp); 490 406 } 491 407 492 408 void AtomInfo::Zero() 493 409 { 494 OBSERVE; 495 NOTIFY(AtomObservable::PositionChanged); 496 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 497 "AtomInfo::Zero() - Access out of range: " 498 +toString(WorldTime::getTime()) 499 +" not in [0,"+toString(AtomicPosition.size())+")."); 500 AtomicPosition[WorldTime::getTime()].Zero(); 410 setPosition(zeroVec); 501 411 } 502 412 503 413 void AtomInfo::One(const double one) 504 414 { 505 OBSERVE; 506 NOTIFY(AtomObservable::PositionChanged); 507 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 508 "AtomInfo::One() - Access out of range: " 509 +toString(WorldTime::getTime()) 510 +" not in [0,"+toString(AtomicPosition.size())+")."); 511 AtomicPosition[WorldTime::getTime()].One(one); 415 setPosition(Vector(one,one,one)); 512 416 } 513 417 514 418 void AtomInfo::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors) 515 419 { 516 OBSERVE; 517 NOTIFY(AtomObservable::PositionChanged); 518 ASSERT(WorldTime::getTime() < AtomicPosition.size(), 519 "AtomInfo::LinearCombinationOfVectors() - Access out of range: " 520 +toString(WorldTime::getTime()) 521 +" not in [0,"+toString(AtomicPosition.size())+")."); 522 AtomicPosition[WorldTime::getTime()].LinearCombinationOfVectors(x1,x2,x3,factors); 420 Vector newPos; 421 newPos.LinearCombinationOfVectors(x1,x2,x3,factors); 422 setPosition(newPos); 523 423 } 524 424 … … 528 428 double AtomInfo::getKineticEnergy(const unsigned int _step) const 529 429 { 530 ASSERT(_step < AtomicPosition.size(), 531 "AtomInfo::getKineticEnergy() - Access out of range: " 532 +toString(WorldTime::getTime()) 533 +" not in [0,"+toString(AtomicPosition.size())+")."); 534 return getMass() * AtomicVelocity[_step].NormSquared(); 430 return getMass() * getAtomicVelocityAtStep(_step).NormSquared(); 535 431 } 536 432 537 433 Vector AtomInfo::getMomentum(const unsigned int _step) const 538 434 { 539 ASSERT(_step < AtomicPosition.size(), 540 "AtomInfo::getMomentum() - Access out of range: " 541 +toString(WorldTime::getTime()) 542 +" not in [0,"+toString(AtomicPosition.size())+")."); 543 return getMass()*AtomicVelocity[_step]; 544 } 545 546 /** Extends the trajectory STL vector to the new size. 547 * Does nothing if \a MaxSteps is smaller than current size. 435 return getMass() * getAtomicVelocityAtStep(_step); 436 } 437 438 /** Decrease the trajectory if given \a MaxSteps is smaller. 439 * Does nothing if \a MaxSteps is larger than current size. 440 * 548 441 * \param MaxSteps 549 442 */ 550 443 void AtomInfo::ResizeTrajectory(size_t MaxSteps) 551 444 { 552 for (;AtomicPosition.size() <= (unsigned int)(MaxSteps);) 553 UpdateSteps(); 445 // mind the reverse ordering due to std::greater, latest time steps are at beginning 446 VectorTrajectory_t::iterator positer = AtomicPosition.lower_bound(MaxSteps); 447 if (positer != AtomicPosition.begin()) { 448 if (positer->first == MaxSteps) 449 --positer; 450 AtomicPosition.erase(AtomicPosition.begin(), positer); 451 } 452 VectorTrajectory_t::iterator veliter = AtomicVelocity.lower_bound(MaxSteps); 453 if (veliter != AtomicVelocity.begin()) { 454 if (veliter->first == MaxSteps) 455 --veliter; 456 AtomicVelocity.erase(AtomicVelocity.begin(), veliter); 457 } 458 VectorTrajectory_t::iterator forceiter = AtomicForce.lower_bound(MaxSteps); 459 if (forceiter != AtomicForce.begin()) { 460 if (forceiter->first == MaxSteps) 461 --forceiter; 462 AtomicForce.erase(AtomicForce.begin(), forceiter); 463 } 554 464 } 555 465 556 466 size_t AtomInfo::getTrajectorySize() const 557 467 { 558 return AtomicPosition.size(); 468 // mind greater comp for map here: first element is latest in time steps! 469 return AtomicPosition.begin()->first+1; 559 470 } 560 471 … … 562 473 { 563 474 return getType()->getMass(); 475 } 476 477 /** Helper function to either insert or assign, depending on the element being 478 * present already. 479 * 480 * \param _trajectory vector of Vectors to assign 481 * \param dest step to insert/assign to 482 * \param _newvalue new Vector value 483 */ 484 void assignTrajectoryElement( 485 std::map<unsigned int, Vector, std::greater<unsigned int> > &_trajectory, 486 const unsigned int dest, 487 const Vector &_newvalue) 488 { 489 std::pair<std::map<unsigned int, Vector, std::greater<unsigned int> >::iterator, bool> inserter = 490 _trajectory.insert( std::make_pair(dest, _newvalue) ); 491 if (!inserter.second) 492 inserter.first->second = _newvalue; 564 493 } 565 494 … … 579 508 } 580 509 581 ASSERT(dest < AtomicPosition.size(), 582 "AtomInfo::CopyStepOnStep() - destination outside of current trajectory array: " 583 +toString(dest) 584 +" not in [0,"+toString(AtomicPosition.size())+")."); 585 ASSERT(src < AtomicPosition.size(), 586 "AtomInfo::CopyStepOnStep() - source outside of current trajectory array: " 587 +toString(src) 588 +" not in [0,"+toString(AtomicPosition.size())+")."); 589 for (int n=NDIM;n--;) { 590 AtomicPosition.at(dest)[n] = AtomicPosition.at(src)[n]; 591 AtomicVelocity.at(dest)[n] = AtomicVelocity.at(src)[n]; 592 AtomicForce.at(dest)[n] = AtomicForce.at(src)[n]; 593 } 510 VectorTrajectory_t::iterator positer = AtomicPosition.find(src); 511 ASSERT( positer != AtomicPosition.end(), 512 "AtomInfo::CopyStepOnStep() - step " 513 +toString(src)+" to copy from not present in AtomicPosition."); 514 VectorTrajectory_t::iterator veliter = AtomicVelocity.find(src); 515 ASSERT( veliter != AtomicVelocity.end(), 516 "AtomInfo::CopyStepOnStep() - step " 517 +toString(src)+" to copy from not present in AtomicVelocity."); 518 VectorTrajectory_t::iterator forceiter = AtomicForce.find(src); 519 ASSERT( forceiter != AtomicForce.end(), 520 "AtomInfo::CopyStepOnStep() - step " 521 +toString(src)+" to copy from not present in AtomicForce."); 522 assignTrajectoryElement(AtomicPosition, dest, positer->second); 523 assignTrajectoryElement(AtomicVelocity, dest, veliter->second); 524 assignTrajectoryElement(AtomicForce, dest, forceiter->second); 594 525 }; 595 526 … … 656 587 }; 657 588 658 //const AtomInfo& operator*=(AtomInfo& a, const double m)659 //{660 // a.Scale(m);661 // return a;662 //}663 //664 //AtomInfo const operator*(const AtomInfo& a, const double m)665 //{666 // AtomInfo copy(a);667 // copy *= m;668 // return copy;669 //}670 //671 //AtomInfo const operator*(const double m, const AtomInfo& a)672 //{673 // AtomInfo copy(a);674 // copy *= m;675 // return copy;676 //}677 678 589 std::ostream & AtomInfo::operator << (std::ostream &ost) const 679 590 { -
src/Atom/atom_atominfo.hpp
r9e1bfb rb119a0 56 56 * real functions, \sa AppendTrajectoryStep(), by all necessary subclasses. 57 57 */ 58 virtual void UpdateStep s()=0;58 virtual void UpdateStep(const unsigned int _step)=0; 59 59 60 60 /** Pops the last step in all trajectory vectors. … … 64 64 * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses. 65 65 */ 66 virtual void removeStep s()=0;66 virtual void removeStep(const unsigned int _step)=0; 67 67 68 68 /** DEPRECATED: Getter for element indicated by AtomicElement. … … 276 276 277 277 // operations for trajectories 278 bool isStepPresent(const unsigned int _step) const; 278 279 void ResizeTrajectory(size_t MaxSteps); 279 280 size_t getTrajectorySize() const; … … 297 298 * vectors. 298 299 */ 299 void AppendTrajectoryStep( );300 void AppendTrajectoryStep(const unsigned int _step); 300 301 301 302 /** Function used by this and inheriting classes to decrease the trajectory 302 303 * vectors by one. 303 304 */ 304 void removeTrajectoryStep( );305 void removeTrajectoryStep(const unsigned int _step); 305 306 306 307 // make these protected only such that deriving atom class still has full 307 308 // access needed for clone and alike 308 std::vector<Vector> AtomicPosition; //!< coordinate vector of atom, giving last position within cell 309 std::vector<Vector> AtomicVelocity; //!< velocity vector of atom, giving last velocity within cell 310 std::vector<Vector> AtomicForce; //!< Force vector of atom, giving last force within cell 309 310 //!> typedef for a vector of Vectors with inverse sorting to make lower_bound return present or last past step 311 typedef std::map<unsigned int, Vector, std::greater<unsigned int> > VectorTrajectory_t; 312 VectorTrajectory_t AtomicPosition; //!< coordinate vector of atom, giving last position within cell 313 VectorTrajectory_t AtomicVelocity; //!< velocity vector of atom, giving last velocity within cell 314 VectorTrajectory_t AtomicForce; //!< Force vector of atom, giving last force within cell 311 315 312 316 private: -
src/Atom/atom_bondedparticle.cpp
r9e1bfb rb119a0 52 52 BondedParticle::BondedParticle() 53 53 { 54 ListOfBonds. push_back(BondList());54 ListOfBonds.insert( std::make_pair(0, emptyList) ); 55 55 }; 56 56 … … 59 59 BondedParticle::~BondedParticle() 60 60 { 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 } 62 66 }; 63 67 … … 220 224 } 221 225 222 /** Removes all bonds in all timestepsand their instances, too.226 /** Removes all bonds in current timestep and their instances, too. 223 227 * 224 228 */ 225 229 void BondedParticle::removeAllBonds() 226 230 { 227 for (size_t index = 0; index < ListOfBonds.size(); ++index) 228 removeAllBonds(index); 231 removeAllBonds(WorldTime::getTime()); 229 232 } 230 233 … … 236 239 { 237 240 //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 } 249 254 } 250 255 … … 260 265 if (Binder->Contains(this)) { 261 266 //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); 265 271 if (WorldTime::getTime() == _step) 266 272 NOTIFY(AtomObservable::BondsAdded); … … 290 296 OBSERVE; 291 297 //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()) { 292 300 #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)); 298 306 #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 } 304 313 } else { 305 314 ELOG(1, *Binder << " does not contain " << *this << "."); … … 328 337 { 329 338 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(); 336 344 ++bonditer) { 337 345 if ((*bonditer) == Binder) { 338 step = tempstep;346 step = listiter->first; 339 347 break; 340 348 } -
src/Atom/atom_bondedparticleinfo.cpp
r9e1bfb rb119a0 57 57 {} 58 58 59 void BondedParticleInfo::AppendTrajectoryStep( )59 void BondedParticleInfo::AppendTrajectoryStep(const unsigned int _step) 60 60 { 61 ListOfBonds. push_back(BondList());61 ListOfBonds.insert( std::make_pair(_step, emptyList) ); 62 62 LOG(5,"BondedParticleInfo::AppendTrajectoryStep() called, size is " << ListOfBonds.size()); 63 63 } 64 64 65 void BondedParticleInfo::removeTrajectoryStep( )65 void BondedParticleInfo::removeTrajectoryStep(const unsigned int _step) 66 66 { 67 ListOfBonds. pop_back();67 ListOfBonds.erase(_step); 68 68 LOG(5,"BondedParticleInfo::removeTrajectoryStep() called, size is " << ListOfBonds.size()); 69 69 } … … 71 71 const BondList& BondedParticleInfo::getListOfBonds() const 72 72 { 73 if(WorldTime::getTime() < ListOfBonds.size()) 74 return ListOfBonds[WorldTime::getTime()]; 75 else 76 return emptyList; 73 return getListOfBondsAtStep(WorldTime::getTime()); 77 74 } 78 79 //BondList& BondedParticleInfo::getListOfBonds()80 //{81 // // todo: here we actually need a container on whose destruction notifiy is emitted, i.e.82 // // similar or simply an ObservedContainer.83 // OBSERVE;84 // NOTIFY(AtomObservable::BondsAdded);85 // const unsigned int size = ListOfBonds.size();86 // ASSERT(WorldTime::getTime() <= size,87 // "BondedParticleInfo::getBondsAtStep() - Access out of range: "88 // +toString(WorldTime::getTime())89 // +" not in [0,"+toString(size)+"].");90 // if (WorldTime::getTime() == size) {91 // UpdateSteps();92 // }93 // return ListOfBonds[WorldTime::getTime()];94 //}95 75 96 76 const BondList& BondedParticleInfo::getListOfBondsAtStep(unsigned int _step) const 97 77 { 98 if(_step < ListOfBonds.size()) 99 return ListOfBonds[_step]; 100 else 101 return emptyList; 78 BondTrajectory_t::const_iterator iter = 79 ListOfBonds.find(_step); 80 if (iter != ListOfBonds.end()) 81 return iter->second; 82 return emptyList; 102 83 } 103 104 //BondList& BondedParticleInfo::getListOfBondsAtStep(unsigned int _step)105 //{106 // const unsigned int size = ListOfBonds.size();107 // ASSERT(_step <= size,108 // "BondedParticleInfo::getBondsAtStep() - Access out of range: "109 // +toString(_step)110 // +" not in [0,"+toString(size)+"].");111 // if (_step == size) {112 // UpdateSteps();113 // }114 // return ListOfBonds[_step];115 //} -
src/Atom/atom_bondedparticleinfo.hpp
r9e1bfb rb119a0 49 49 * real functions, \sa AppendTrajectoryStep(), by all necessary subclasses. 50 50 */ 51 virtual void UpdateSteps()=0; 51 virtual void UpdateStep(const unsigned int _step)=0; 52 53 /** Pops the last step in all trajectory vectors. 54 * 55 * This allows to decrease all trajectories contained in different classes 56 * by one consistently. This is implemented by the topmost class which calls 57 * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses. 58 */ 59 virtual void removeStep(const unsigned int _step)=0; 52 60 53 61 /** Const accessor to ListOfBonds of WorldTime::CurrentTime. … … 87 95 * vector. 88 96 */ 89 void AppendTrajectoryStep( );97 void AppendTrajectoryStep(const unsigned int _step); 90 98 91 99 /** Function used by this and inheriting classes to reduce the ListOfBonds 92 100 * vector by one. 93 101 */ 94 void removeTrajectoryStep( );102 void removeTrajectoryStep(const unsigned int _step); 95 103 96 std::vector<BondList> ListOfBonds; //!< list of all bonds 104 typedef std::map<unsigned int, BondList> BondTrajectory_t; 105 BondTrajectory_t ListOfBonds; //!< list of all bonds 97 106 static BondList emptyList; //!< empty list to return when step is not present 98 107 }; -
src/Atom/unittests/AtomObserverUnitTest.cpp
r9e1bfb rb119a0 130 130 void AtomObserverTest::AtomElementTest() 131 131 { 132 atoms[0]->setType(1); 132 CPPUNIT_ASSERT( atoms[0]->getType()->getAtomicNumber() != 2 ); 133 atoms[0]->setType(2); 133 134 134 135 // check for update -
src/Fragmentation/Exporters/HydrogenPool.cpp
r9e1bfb rb119a0 103 103 const size_t CurrentTime = WorldTime::getTime(); 104 104 for (size_t step = _atom->getTrajectorySize(); step <= CurrentTime; ++step) 105 _atom->UpdateStep s();105 _atom->UpdateStep(step); 106 106 } 107 107 -
src/LinkedCell/unittests/stubs/TesselPointStub.cpp
r9e1bfb rb119a0 43 43 virtual ~TesselPoint(); 44 44 45 virtual void UpdateStep s();45 virtual void UpdateStep(const unsigned int _step); 46 46 47 47 TesselPoint * getTesselPoint(); … … 54 54 {} 55 55 56 void TesselPoint::UpdateStep s()56 void TesselPoint::UpdateStep(const unsigned int _step) 57 57 {} 58 58 -
src/World.cpp
r9e1bfb rb119a0 234 234 if (_step != WorldTime::getTime()) { 235 235 const unsigned int oldstep = WorldTime::getTime(); 236 // set new time 236 237 // 1. copy bond graph (such not each addBond causes GUI update) 238 if (!areBondsPresent(_step)) { 239 // AtomComposite Set = getAllAtoms(); 240 // BG->cleanAdjacencyList(Set); 241 copyBondgraph(oldstep, _step); 242 } 243 244 // 2. set new time 237 245 WorldTime::getInstance().setTime(_step); 246 238 247 // TODO: removed when BondGraph creates the adjacency 239 // 1. remove all of World's molecules248 // 3. remove all of World's molecules 240 249 for (MoleculeIterator iter = getMoleculeIter(); 241 250 getMoleculeIter() != moleculeEnd(); … … 244 253 destroyMolecule(*iter); 245 254 } 246 // 2. copy bond graph 247 if (!areBondsPresent(_step)) { 248 // AtomComposite Set = getAllAtoms(); 249 // BG->cleanAdjacencyList(Set); 250 copyBondgraph(oldstep, _step); 251 } 252 253 // 3. scan for connected subgraphs => molecules 255 256 // 4. scan for connected subgraphs => molecules 254 257 DepthFirstSearchAnalysis DFS; 255 258 DFS(); -
src/molecule_geometry.cpp
r9e1bfb rb119a0 295 295 void molecule::Scale(const double *factor) 296 296 { 297 for (iterator iter = begin(); iter != end(); ++iter) {298 for (size_t j=0;j<(*iter)->getTrajectorySize();j++) {299 Vector temp = (*iter)->getPositionAtStep(j);300 temp.ScaleAll(factor);301 (*iter)->setPositionAtStep(j,temp);302 }303 }297 for (iterator iter = begin(); iter != end(); ++iter) 298 for (size_t j=0;j<(*iter)->getTrajectorySize();j++) 299 if ((*iter)->isStepPresent(j)) { 300 Vector temp = (*iter)->getPositionAtStep(j); 301 temp.ScaleAll(factor); 302 (*iter)->setPositionAtStep(j,temp); 303 } 304 304 }; 305 305 … … 309 309 void molecule::Translate(const Vector &trans) 310 310 { 311 getAtomSet().translate(trans); 311 for (iterator iter = begin(); iter != end(); ++iter) 312 for (size_t j=0;j<(*iter)->getTrajectorySize();j++) 313 if ((*iter)->isStepPresent(j)) 314 (*iter)->setPositionAtStep(j, (*iter)->getPositionAtStep(j) + (trans)); 312 315 }; 313 316
Note:
See TracChangeset
for help on using the changeset viewer.