- Timestamp:
- Apr 10, 2018, 6:43:30 AM (7 years ago)
- Branches:
- AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Exclude_Hydrogens_annealWithBondGraph, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, PythonUI_with_named_parameters, StoppableMakroAction, TremoloParser_IncreasedPrecision
- Children:
- 825d33
- Parents:
- 2f3905
- git-author:
- Frederik Heber <frederik.heber@…> (06/29/17 14:40:12)
- git-committer:
- Frederik Heber <frederik.heber@…> (04/10/18 06:43:30)
- Location:
- src/Dynamics
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Dynamics/BondVectors.cpp
r2f3905 r9861d0 41 41 #include <iterator> 42 42 43 #include "CodePatterns/Assert.hpp" 44 #include "CodePatterns/Log.hpp" 45 43 46 #include "Atom/atom.hpp" 47 #include "Bond/bond.hpp" 44 48 45 BondVectors::mapped_t BondVectors::getBondVectorsAtStep(49 void BondVectors::recalculateBondVectorsAtStep( 46 50 const size_t &_step) const 47 51 { 48 mapped_t returnlist;52 current_mapped_vectors.clear(); 49 53 50 54 ASSERT( !container.empty(), … … 56 60 - current_bond->rightatom->getPositionAtStep(_step); 57 61 BondVector.Normalize(); 58 returnlist.insert( std::make_pair(current_bond, BondVector) );62 current_mapped_vectors.insert( std::make_pair(current_bond, BondVector) ); 59 63 } 60 ASSERT( returnlist.size() == container.size(),64 ASSERT( current_mapped_vectors.size() == container.size(), 61 65 "BondVectors::getBondVectors() - not same amount of bond vectors as bonds?"); 62 66 63 return returnlist; 67 map_is_dirty = false; 68 current_step_for_map = _step; 64 69 } 65 70 … … 76 81 } 77 82 83 std::vector<Vector> BondVectors::getAtomsBondVectorsAtStep( 84 const atom &_walker, 85 const size_t &_step) const 86 { 87 if (map_is_dirty || (current_step_for_map != _step)) 88 recalculateBondVectorsAtStep(_step); 89 90 std::vector<Vector> BondVectors; 91 // gather subset of BondVectors for the current atom 92 const BondList& ListOfBonds = _walker.getListOfBonds(); 93 for(BondList::const_iterator bonditer = ListOfBonds.begin(); 94 bonditer != ListOfBonds.end(); ++bonditer) { 95 const bond::ptr ¤t_bond = *bonditer; 96 const BondVectors::mapped_t::const_iterator bviter = 97 current_mapped_vectors.find(current_bond); 98 ASSERT( bviter != current_mapped_vectors.end(), 99 "ForceAnnealing() - cannot find current_bond ?"); 100 ASSERT( bviter != current_mapped_vectors.end(), 101 "ForceAnnealing - cannot find current bond "+toString(*current_bond) 102 +" in bonds."); 103 BondVectors.push_back(bviter->second); 104 } 105 LOG(4, "DEBUG: BondVectors for atom #" << _walker.getId() << ": " << BondVectors); 106 107 return BondVectors; 108 } -
src/Dynamics/BondVectors.hpp
r2f3905 r9861d0 37 37 typedef std::map<bond::ptr, Vector> mapped_t; 38 38 39 /** Default cstor for class BondVectors. 40 * 41 */ 42 BondVectors(); 43 39 44 /** Prepares the internal container from the bonds of a range of atoms. 40 45 * … … 53 58 * \return const ref to internal container 54 59 */ 55 const container_t& getSorted() const 56 { 57 ASSERT( !container.empty(), 58 "BondVectors::getSorted() - empty internal container, not set properly?"); 59 return container; 60 } 60 const container_t& getSorted() const; 61 61 62 /** Calculates the bond vector for each bond in the internal container and 63 * returns them in same order as the internal container. 62 /** Getter for the Bondvectors. 64 63 * 65 64 * \param _step time step for which the bond vector is request 66 65 * \return a map from bond to bond vector 67 66 */ 68 mapped_tgetBondVectorsAtStep(const size_t &_step) const;67 const mapped_t& getBondVectorsAtStep(const size_t &_step) const; 69 68 70 69 /** Get the position in the internal container for a specific bond. … … 75 74 size_t getIndexForBond(const bond::ptr &_bond) const; 76 75 76 /** Gather the subset of BondVectors for the given atom. 77 * 78 * \param _walker atom to get BondVectors for 79 * \param _step time step for which the bond vector is request 80 */ 81 std::vector<Vector> getAtomsBondVectorsAtStep( 82 const atom &_walker, 83 const size_t &_step) const; 84 85 private: 86 /** Calculates the bond vector for each bond in the internal container. 87 * 88 * \param _step time step for which the bond vector is request 89 */ 90 void recalculateBondVectorsAtStep(const size_t &_step) const; 91 77 92 private: 78 93 //!> internal container for sorted bonds 79 94 container_t container; 95 96 //!> states whether map needs update or not 97 mutable bool map_is_dirty; 98 99 //!> contains the step for which the map was calculated 100 mutable size_t current_step_for_map; 101 102 //!> internal map for bond Bondvector association 103 mutable mapped_t current_mapped_vectors; 80 104 }; 81 105 -
src/Dynamics/BondVectors_impl.hpp
r2f3905 r9861d0 21 21 #include "Atom/atom.hpp" 22 22 23 BondVectors::BondVectors() : 24 map_is_dirty(false), 25 current_step_for_map((size_t)-1) 26 {} 27 23 28 template <class T> 24 29 void BondVectors::setFromAtomRange( … … 36 41 std::sort(container.begin(), container.end()); 37 42 container.erase(std::unique(container.begin(), container.end()), container.end()); 43 map_is_dirty = true; 38 44 } 39 45 46 const BondVectors::mapped_t& 47 BondVectors::getBondVectorsAtStep(const size_t &_step) const 48 { 49 if (map_is_dirty || (current_step_for_map != _step)) 50 recalculateBondVectorsAtStep(_step); 51 return current_mapped_vectors; 52 } 53 54 const BondVectors::container_t& 55 BondVectors::getSorted() const 56 { 57 ASSERT( !container.empty(), 58 "BondVectors::getSorted() - empty internal container, not set properly?"); 59 return container; 60 } 40 61 41 62 #endif /* DYNAMICS_BONDVECTORS_IMPL_HPP_ */ -
src/Dynamics/ForceAnnealing.hpp
r2f3905 r9861d0 301 301 << ", and CurrentStep is " << CurrentStep); 302 302 303 // get all bond vectors for this time step (from the perspective of the304 // bonds taken from the currentStep)305 const BondVectors::mapped_t bondvectors = bv.getBondVectorsAtStep(CurrentStep);306 307 303 for(typename AtomSetMixin<T>::const_iterator iter = AtomicForceManipulator<T>::atoms.begin(); 308 304 iter != AtomicForceManipulator<T>::atoms.end(); ++iter) { … … 317 313 318 314 // gather subset of BondVectors for the current atom 319 std::vector<Vector> BondVectors; 320 for(BondList::const_iterator bonditer = ListOfBonds.begin(); 321 bonditer != ListOfBonds.end(); ++bonditer) { 322 const bond::ptr ¤t_bond = *bonditer; 323 const BondVectors::mapped_t::const_iterator bviter = 324 bondvectors.find(current_bond); 325 ASSERT( bviter != bondvectors.end(), 326 "ForceAnnealing() - cannot find current_bond ?"); 327 ASSERT( bviter != bondvectors.end(), 328 "ForceAnnealing - cannot find current bond "+toString(*current_bond) 329 +" in bonds."); 330 BondVectors.push_back(bviter->second); 331 } 332 LOG(4, "DEBUG: BondVectors for atom #" << walker.getId() << ": " << BondVectors); 315 std::vector<Vector> BondVectors = bv.getAtomsBondVectorsAtStep(walker, CurrentStep); 333 316 334 317 // go through all its bonds and calculate what magnitude is represented
Note:
See TracChangeset
for help on using the changeset viewer.