Changeset d24ef58 for src/Actions
- Timestamp:
- Jul 12, 2017, 7:10:31 PM (7 years ago)
- Branches:
- Action_Thermostats, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Exclude_Hydrogens_annealWithBondGraph, Fix_Verbose_Codepatterns, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, Recreated_GuiChecks, StoppableMakroAction, TremoloParser_IncreasedPrecision
- Children:
- bccbe9
- Parents:
- 3b74fa
- git-author:
- Frederik Heber <frederik.heber@…> (05/17/17 11:34:16)
- git-committer:
- Frederik Heber <frederik.heber@…> (07/12/17 19:10:31)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/StretchBondAction.cpp
r3b74fa rd24ef58 35 35 #include <boost/graph/adjacency_list.hpp> 36 36 #include <boost/graph/breadth_first_search.hpp> 37 #include <boost/graph/subgraph.hpp>38 37 39 38 //#include "CodePatterns/MemDebug.hpp" … … 41 40 #include "Actions/MoleculeAction/StretchBondAction.hpp" 42 41 42 #include <boost/bind.hpp> 43 44 #include "CodePatterns/Assert.hpp" 43 45 #include "CodePatterns/Log.hpp" 44 46 #include "CodePatterns/Verbose.hpp" … … 49 51 #include "Bond/bond.hpp" 50 52 #include "Descriptors/AtomIdDescriptor.hpp" 53 #include "Graph/BoostGraphCreator.hpp" 51 54 #include "molecule.hpp" 52 55 #include "World.hpp" … … 85 88 { 86 89 return distance_recorder<DistanceMap>(d); 90 } 91 92 static bool addEdgePredicate( 93 const bond &_bond, 94 const std::vector<atomId_t> &_atomids) 95 { 96 ASSERT(_atomids.size() == (size_t)2, 97 "addEdgePredicate() - atomids must contain exactly two ids."); 98 // do not add selected edge 99 return ((_bond.leftatom->getId() != _atomids[0]) 100 || (_bond.rightatom->getId() != _atomids[1])); 87 101 } 88 102 … … 118 132 // shift either set as desired. If not, then we simply shift each atom, 119 133 // leaving the other positions untouched. 120 typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS,121 boost::no_property, boost::no_property > UndirectedGraph;122 134 123 135 // convert BondGraph into boost::graph 124 UndirectedGraph molgraph(mol->getAtomCount()); 125 size_t no_edges = 0; 126 for(molecule::const_iterator iter = const_cast<const molecule * const>(mol)->begin(); 127 iter != const_cast<const molecule * const>(mol)->end(); ++iter) { 128 LOG(2, "DEBUG: Looking at node " << (*iter)->getId()); 129 const BondList& ListOfBonds = (*iter)->getListOfBonds(); 130 for(BondList::const_iterator bonditer = ListOfBonds.begin(); 131 bonditer != ListOfBonds.end(); ++bonditer) { 132 const unsigned int &leftid = (*bonditer)->leftatom->getId(); 133 const unsigned int &rightid = (*bonditer)->rightatom->getId(); 134 // only add each edge once and do not add selected edge 135 if ((leftid == (*iter)->getId()) 136 && ((leftid != atomids[0]) || (rightid != atomids[1]))) { 137 LOG(1, "DEBUG: ADDING edge " << leftid << " <-> " << rightid); 138 boost::add_edge(leftid, rightid, molgraph); 139 ++no_edges; 140 } else { 141 LOG(1, "DEBUG: Discarding edge " << leftid << " <-> " << rightid); 142 } 143 } 144 } 145 typedef boost::property_map < boost::adjacency_list <>, boost::vertex_index_t >::type index_map_t; 146 index_map_t index_map = boost::get(boost::vertex_index, molgraph); 147 const size_t num_vertices = boost::num_vertices(molgraph); 148 LOG(2, "DEBUG: We have " << num_vertices << " nodes and " << no_edges 149 << " edges in the molecule graph."); 150 136 BoostGraphCreator BGcreator; 137 BGcreator.createFromMolecule(*mol, 138 boost::bind(addEdgePredicate, _1, boost::ref(atomids))); 139 const BoostGraphCreator::UndirectedGraph &molgraph = BGcreator.get(); 140 141 const size_t num_vertices = BGcreator.getNumVertices(); 151 142 std::vector< std::vector<size_t> > distances; 152 143 for (size_t i=0;i<2;++i) { … … 184 175 // go through the molecule and stretch each atom in either set of nodes 185 176 if (bondside_sets[0].empty()) { 177 const BoostGraphCreator::index_map_t index_map = BGcreator.getIndexMap(); 186 178 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { 187 179 const Vector &position = (*iter)->getPosition();
Note:
See TracChangeset
for help on using the changeset viewer.