Changeset 5197e5
- Timestamp:
- Dec 3, 2012, 9:50:01 AM (12 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:
- 3aa8a5
- Parents:
- 0fad93
- git-author:
- Frederik Heber <heber@…> (09/21/12 12:11:23)
- git-committer:
- Frederik Heber <heber@…> (12/03/12 09:50:01)
- Location:
- src/Graph
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Graph/AdjacencyList.cpp
r0fad93 r5197e5 58 58 NonMatchNumber(0) 59 59 { 60 bool status = ParseIn InternalMap(File);60 bool status = ParseIntoMap(File, InternalAtomBondMap); 61 61 if (!status) // remove map if failed to parse 62 62 InternalAtomBondMap.clear(); … … 66 66 {} 67 67 68 /** Parses the bond partners of each atom from an external file into \a AtomBondMap.68 /** Parses the bond partners of each atom from an external file into \a atombondmap. 69 69 * 70 70 * @param File file to parse 71 * @param &atombondmap map to parse into 71 72 * @return true - everything ok, false - error while parsing 72 73 */ 73 bool AdjacencyList::ParseIn InternalMap(std::istream &File)74 bool AdjacencyList::ParseIntoMap(std::istream &File, AtomBondMap &atombondmap) 74 75 { 75 76 if (File.fail()) { … … 78 79 } 79 80 80 InternalAtomBondMap.clear();81 atombondmap.clear(); 81 82 char buffer[MAXSTRINGSIZE]; 82 83 int tmp; … … 97 98 while (line >> ws >> tmp) { 98 99 LOG(3, "INFO: Recognized bond partner " << tmp-1 << " for " << WalkerId << "."); 99 InternalAtomBondMap.insert( std::make_pair(WalkerId, tmp-1) );100 atombondmap.insert( std::make_pair(WalkerId, tmp-1) ); 100 101 } 101 102 } else { … … 111 112 /** Fills the InternalAtomBondMap from the atoms given by the two iterators. 112 113 * 114 * @param &atombondmap map to create 113 115 * @param atomids set of atomic ids to check (must be global ids, i.e. from atom::getId()) 114 116 */ 115 void AdjacencyList::Create ExternalMap(const atomids_t &atomids)116 { 117 ExternalAtomBondMap.clear();117 void AdjacencyList::CreateMap(const atomids_t &atomids, AtomBondMap &atombondmap) 118 { 119 atombondmap.clear(); 118 120 // go through each atom in the list 119 121 for (atomids_t::const_iterator iter = atomids.begin(); iter != atomids.end(); ++iter) { 120 122 const atomId_t WalkerId = *iter; 121 123 ASSERT(WalkerId != (size_t)-1, 122 "AdjacencyList::Create ExternalMap() - Walker has no id.");124 "AdjacencyList::CreateMap() - Walker has no id."); 123 125 const atom *Walker = World::getInstance().getAtom(AtomById(WalkerId)); 124 126 ASSERT( Walker != NULL, 125 "AdjacencyList::Create ExternalMap() - Walker id "+toString(*iter)127 "AdjacencyList::CreateMap() - Walker id "+toString(*iter) 126 128 +" is not associated to any of World's atoms."); 127 129 const BondList& ListOfBonds = Walker->getListOfBonds(); … … 132 134 const atomId_t id = (*Runner)->GetOtherAtom(Walker)->getId(); 133 135 ASSERT(id != (size_t)-1, 134 "AdjacencyList::Create ExternalMap() - OtherAtom has not id.");135 ExternalAtomBondMap.insert( std::make_pair(WalkerId, id) );136 "AdjacencyList::CreateMap() - OtherAtom has not id."); 137 atombondmap.insert( std::make_pair(WalkerId, id) ); 136 138 } 137 139 } … … 146 148 147 149 // parse in external map 148 Create ExternalMap(atomids);150 CreateMap(atomids, ExternalAtomBondMap); 149 151 150 152 bool status = CompareInternalExternalMap(); -
src/Graph/AdjacencyList.hpp
r0fad93 r5197e5 56 56 ValuesSet getValues(const AtomBondRange&_range) const; 57 57 58 void Create ExternalMap(const atomids_t &atoms);59 bool ParseIn InternalMap(std::istream &File);58 void CreateMap(const atomids_t &atoms, AtomBondMap &atombondmap); 59 bool ParseIntoMap(std::istream &File, AtomBondMap &atombondmap); 60 60 bool CompareInternalExternalMap(); 61 61 }; -
src/Graph/unittests/AdjacencyListUnitTest.cpp
r0fad93 r5197e5 161 161 } 162 162 163 /** Unit tests for AdjacencyList::Create ExternalMap().164 * 165 */ 166 void AdjacencyListTest::Create ExternalMapTest()163 /** Unit tests for AdjacencyList::CreateMap(). 164 * 165 */ 166 void AdjacencyListTest::CreateMapTest() 167 167 { 168 168 std::stringstream input; 169 169 AdjacencyList fileChecker(input); 170 fileChecker.Create ExternalMap(atomIds);170 fileChecker.CreateMap(atomIds, fileChecker.ExternalAtomBondMap); 171 171 172 172 // check size (it's 8*2 + 2*1 = 18 keys) … … 190 190 } 191 191 192 /** Unit tests for AdjacencyList::ParseIn InternalMap().193 * 194 */ 195 void AdjacencyListTest::ParseIn InternalMapTest()192 /** Unit tests for AdjacencyList::ParseIntoMap(). 193 * 194 */ 195 void AdjacencyListTest::ParseIntoMapTest() 196 196 { 197 197 std::stringstream input(adjacencyfile); 198 198 AdjacencyList fileChecker(input); 199 199 std::vector<atomId_t> noids; 200 fileChecker.Create ExternalMap(noids);200 fileChecker.CreateMap(noids, fileChecker.ExternalAtomBondMap); 201 201 202 202 // check size (it's 8*2 + 2*1 = 18 keys) … … 232 232 233 233 // parse in external map 234 fileChecker.Create ExternalMap(atomIds);234 fileChecker.CreateMap(atomIds, fileChecker.ExternalAtomBondMap); 235 235 236 236 // assert equality after parsing -
src/Graph/unittests/AdjacencyListUnitTest.hpp
r0fad93 r5197e5 30 30 { 31 31 CPPUNIT_TEST_SUITE( AdjacencyListTest ); 32 CPPUNIT_TEST ( Create ExternalMapTest );33 CPPUNIT_TEST ( ParseIn InternalMapTest );32 CPPUNIT_TEST ( CreateMapTest ); 33 CPPUNIT_TEST ( ParseIntoMapTest ); 34 34 CPPUNIT_TEST ( CompareInternalExternalMapTest ); 35 35 CPPUNIT_TEST ( CheckAgainstSubsetTest ); … … 40 40 void tearDown(); 41 41 42 void Create ExternalMapTest();43 void ParseIn InternalMapTest();42 void CreateMapTest(); 43 void ParseIntoMapTest(); 44 44 void CompareInternalExternalMapTest(); 45 45 void CheckAgainstSubsetTest();
Note:
See TracChangeset
for help on using the changeset viewer.