Changeset c9f9bb for src/Actions/FragmentationAction
- Timestamp:
- Nov 27, 2012, 8:35:34 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:
- 3dd32f
- Parents:
- 995e2f
- git-author:
- Frederik Heber <heber@…> (08/27/12 11:51:09)
- git-committer:
- Frederik Heber <heber@…> (11/27/12 08:35:34)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FragmentationAction/FragmentationAutomationAction.cpp
r995e2f rc9f9bb 40 40 41 41 #include <boost/mpl/remove.hpp> 42 #include <boost/lambda/lambda.hpp> 42 43 43 44 #include "CodePatterns/Assert.hpp" … … 173 174 void ConvertFragmentResultTo( 174 175 const std::vector<FragmentResult::ptr> &results, 175 std:: vector<T> &fragmentData)176 std::map<JobId_t, T> &fragmentData) 176 177 { 177 178 // extract results 178 179 fragmentData.clear(); 179 fragmentData.reserve(results.size());180 180 181 181 LOG(2, "DEBUG: Parsing now through " << results.size() << " results."); … … 189 189 ia >> extractedData; 190 190 LOG(1, "INFO: extracted data is " << extractedData << "."); 191 fragmentData. push_back(extractedData);191 fragmentData.insert( std::make_pair( (*iter)->getId(), extractedData) ); 192 192 } 193 193 … … 225 225 /** Place results from FragmentResult into EnergyMatrix and ForceMatrix. 226 226 * 227 * @param jobids jobids with ids to associate with fragment number228 227 * @param fragmentData MPQCData resulting from the jobs 229 228 * @param MatrixNrLookup Lookup up-map from job id to fragment number … … 235 234 */ 236 235 bool putResultsintoMatrices( 237 const std::vector<JobId_t> &jobids, 238 const std::vector<MPQCData> &fragmentData, 236 const std::map<JobId_t, MPQCData> &fragmentData, 239 237 std::map< JobId_t, size_t > &MatrixNrLookup, 240 238 const size_t FragmentCounter, … … 243 241 ForceMatrix &Force) 244 242 { 245 ASSERT( jobids.size() == fragmentData.size(), 246 "putResultsintoMatrices() - jobids and fragmentData differ in size."); 247 std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin(); 248 std::vector<JobId_t>::const_iterator iditer = jobids.begin(); 249 for (; dataiter != fragmentData.end(); ++dataiter, ++iditer) { 250 const MPQCData &extractedData = *dataiter; 243 for (std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin(); 244 dataiter != fragmentData.end(); ++dataiter) { 245 const MPQCData &extractedData = dataiter->second; 246 const JobId_t &jobid = dataiter->first; 251 247 // place results into EnergyMatrix ... 252 248 { … … 255 251 matrix[0].resize(1, extractedData.energies.total); 256 252 if (!Energy.AddMatrix( 257 std::string("MPQCJob ")+toString( *iditer),253 std::string("MPQCJob ")+toString(jobid), 258 254 matrix, 259 MatrixNrLookup[ *iditer])) {255 MatrixNrLookup[jobid])) { 260 256 ELOG(1, "Adding energy matrix failed."); 261 257 return false; … … 276 272 } 277 273 if (!Force.AddMatrix( 278 std::string("MPQCJob ")+toString( *iditer),274 std::string("MPQCJob ")+toString(jobid), 279 275 matrix, 280 MatrixNrLookup[ *iditer])) {276 MatrixNrLookup[jobid])) { 281 277 ELOG(1, "Adding force matrix failed."); 282 278 return false; … … 301 297 /** Print MPQCData from received results. 302 298 * 303 * @param jobids jobids with ids to associate with fragment number 304 * @param fragmentData MPQCData resulting from the jobs 299 * @param fragmentData MPQCData resulting from the jobs, each associated to a job 305 300 * @param KeySetFilename filename with keysets to associate forces correctly 306 301 * @param NoAtoms total number of atoms … … 309 304 */ 310 305 bool sumUpChargeDensity( 311 const std::vector<JobId_t> &jobids, 312 const std::vector<MPQCData> &fragmentData, 306 const std::map<JobId_t,MPQCData> &fragmentData, 313 307 const std::string &KeySetFilename, 314 308 SamplingGrid &full_sample, 315 309 Fragment &full_fragment) 316 310 { 311 // create a vector of all job ids 312 std::vector<JobId_t> jobids; 313 std::transform(fragmentData.begin(),fragmentData.end(), 314 std::back_inserter(jobids), 315 boost::bind( &std::map<JobId_t,MPQCData>::value_type::first, boost::lambda::_1 ) 316 ); 317 317 318 // create lookup from job nr to fragment number 318 319 std::map< JobId_t, size_t > MatrixNrLookup; … … 339 340 std::vector<MPQCDataGridMap_t> Result_Grid_fused( 340 341 OrthogonalSumUpPerLevel<MPQCDataGridMap_t, MPQCDataGridVector_t>( 341 fragmentData, jobids,MatrixNrLookup, container, subsetmap));342 fragmentData, MatrixNrLookup, container, subsetmap)); 342 343 std::vector<MPQCDataFragmentMap_t> Result_Fragment_fused( 343 344 OrthogonalSumUpPerLevel<MPQCDataFragmentMap_t, MPQCDataFragmentVector_t>( 344 fragmentData, jobids,MatrixNrLookup, container, subsetmap));345 fragmentData, MatrixNrLookup, container, subsetmap)); 345 346 // obtain full grid 346 347 full_sample = boost::fusion::at_key<MPQCDataFused::sampled_grid>(Result_Grid_fused.back()); … … 352 353 /** Print MPQCData from received results. 353 354 * 354 * @param results results with ids to associate with fragment number 355 * @param fragmentData MPQCData resulting from the jobs 355 * @param fragmentData MPQCData resulting from the jobs, associated to job id 356 356 * @param KeySetFilename filename with keysets to associate forces correctly 357 357 * @param NoAtoms total number of atoms … … 359 359 */ 360 360 bool printReceivedMPQCResults( 361 const std::vector<JobId_t> &jobids, 362 const std::vector<MPQCData> &fragmentData, 361 const std::map<JobId_t, MPQCData> &fragmentData, 363 362 const std::string &KeySetFilename, 364 363 size_t NoAtoms, 365 364 SamplingGrid &full_sample) 366 365 { 366 // create a vector of all job ids 367 std::vector<JobId_t> jobids; 368 std::transform(fragmentData.begin(),fragmentData.end(), 369 std::back_inserter(jobids), 370 boost::bind( &std::map<JobId_t,MPQCData>::value_type::first, boost::lambda::_1 ) 371 ); 372 367 373 // create lookup from job nr to fragment number 368 374 std::map< JobId_t, size_t > MatrixNrLookup; … … 373 379 EnergyMatrix Energy; 374 380 ForceMatrix Force; 375 if (!putResultsintoMatrices( jobids,fragmentData, MatrixNrLookup, FragmentCounter, NoAtoms, Energy, Force))381 if (!putResultsintoMatrices(fragmentData, MatrixNrLookup, FragmentCounter, NoAtoms, Energy, Force)) 376 382 return false; 377 383 … … 412 418 std::vector<MPQCDataEnergyMap_t> Result_Energy_fused( 413 419 OrthogonalSumUpPerLevel<MPQCDataEnergyMap_t, MPQCDataEnergyVector_t>( 414 fragmentData, jobids,MatrixNrLookup, container, subsetmap));420 fragmentData, MatrixNrLookup, container, subsetmap)); 415 421 std::vector<MPQCDataGridMap_t> Result_Grid_fused( 416 422 OrthogonalSumUpPerLevel<MPQCDataGridMap_t, MPQCDataGridVector_t>( 417 fragmentData, jobids,MatrixNrLookup, container, subsetmap));423 fragmentData, MatrixNrLookup, container, subsetmap)); 418 424 std::vector<MPQCDataTimeMap_t> Result_Time_fused( 419 425 SumUpPerLevel<MPQCDataTimeMap_t, MPQCDataTimeVector_t>( 420 fragmentData, jobids,MatrixNrLookup, container, subsetmap));426 fragmentData, MatrixNrLookup, container, subsetmap)); 421 427 422 428 // force has extra converter 423 std:: vector<MPQCDataForceMap_t> MPQCData_Force_fused;429 std::map<JobId_t, MPQCDataForceMap_t> MPQCData_Force_fused; 424 430 convertMPQCDatatoForceMap(fragmentData, ForceKeySet, MPQCData_Force_fused); 425 431 std::vector<MPQCDataForceMap_t> Result_Force_fused(subsetmap->getMaximumSubsetLevel()); … … 427 433 subsetmap, 428 434 MPQCData_Force_fused, 429 jobids,430 435 container->getContainer(), 431 436 MatrixNrLookup, … … 496 501 /** Print MPQCData from received results. 497 502 * 498 * @param fragmentresults results with short-range job ids to associate with fragment number499 * @param longrangeresults results with long-range job ids to associate with fragment number500 503 * @param fragmentData MPQCData resulting from the jobs 501 504 * @param longrangeData VMGData resulting from long-range jobs … … 506 509 */ 507 510 bool printReceivedFullResults( 508 const std::vector<FragmentResult::ptr> &fragmentresults, 509 const std::vector<FragmentResult::ptr> &longrangeresults, 510 const std::vector<MPQCData> &fragmentData, 511 const std::vector<VMGData> &longrangeData, 511 const std::map<JobId_t,MPQCData> &fragmentData, 512 const std::map<JobId_t,VMGData> &longrangeData, 512 513 const VMGData &fullsolutionData, 513 514 const std::string &KeySetFilename, … … 515 516 SamplingGrid &full_sample) 516 517 { 517 // create a vector of all job ids from short-range 518 std::vector<JobId_t> jobids(fragmentresults.size(), JobId::IllegalJob); 519 std::transform(fragmentresults.begin(), fragmentresults.end(), jobids.begin(), 520 boost::bind(&FragmentResult::getId, 521 boost::bind(&FragmentResult::ptr::operator->, _1))); 518 // create a vector of all job ids 519 std::vector<JobId_t> jobids; 520 std::transform(fragmentData.begin(),fragmentData.end(), 521 std::back_inserter(jobids), 522 boost::bind( &std::map<JobId_t,MPQCData>::value_type::first, boost::lambda::_1 ) 523 ); 522 524 523 525 // create lookup from job nr to fragment number … … 555 557 std::vector<MPQCDataEnergyMap_t> Result_Energy_fused( 556 558 OrthogonalSumUpPerLevel<MPQCDataEnergyMap_t, MPQCDataEnergyVector_t>( 557 fragmentData, jobids,MatrixNrLookup, container, subsetmap));559 fragmentData, MatrixNrLookup, container, subsetmap)); 558 560 std::vector<MPQCDataGridMap_t> Result_Grid_fused( 559 561 OrthogonalSumUpPerLevel<MPQCDataGridMap_t, MPQCDataGridVector_t>( 560 fragmentData, jobids,MatrixNrLookup, container, subsetmap));562 fragmentData, MatrixNrLookup, container, subsetmap)); 561 563 std::vector<MPQCDataTimeMap_t> Result_Time_fused( 562 564 SumUpPerLevel<MPQCDataTimeMap_t, MPQCDataTimeVector_t>( 563 fragmentData, jobids,MatrixNrLookup, container, subsetmap));565 fragmentData, MatrixNrLookup, container, subsetmap)); 564 566 std::vector<MPQCDataFragmentMap_t> Result_Fragment_fused( 565 567 OrthogonalSumUpPerLevel<MPQCDataFragmentMap_t, MPQCDataFragmentVector_t>( 566 fragmentData, jobids,MatrixNrLookup, container, subsetmap));568 fragmentData, MatrixNrLookup, container, subsetmap)); 567 569 568 570 // force has extra converter 569 std:: vector<MPQCDataForceMap_t> MPQCData_Force_fused;571 std::map<JobId_t, MPQCDataForceMap_t> MPQCData_Force_fused; 570 572 convertMPQCDatatoForceMap(fragmentData, ForceKeySet, MPQCData_Force_fused); 571 573 std::vector<MPQCDataForceMap_t> Result_Force_fused(subsetmap->getMaximumSubsetLevel()); … … 573 575 subsetmap, 574 576 MPQCData_Force_fused, 575 jobids,576 577 container->getContainer(), 577 578 MatrixNrLookup, … … 580 581 581 582 // obtain full grid 582 std:: vector<VMGDataMap_t> VMGData_Potential_fused;583 std::map<JobId_t, VMGDataMap_t> VMGData_Potential_fused; 583 584 convertDataTo<VMGData, VMGDataMap_t>(longrangeData, VMGData_Potential_fused); 584 585 OrthogonalFullSummator<VMGDataMap_t, VMGDataFused::sampled_potential> potentialSummer( 585 586 subsetmap, 586 587 VMGData_Potential_fused, 587 jobids,588 588 container->getContainer(), 589 589 MatrixNrLookup); … … 592 592 subsetmap, 593 593 VMGData_Potential_fused, 594 jobids,595 594 container->getContainer(), 596 595 MatrixNrLookup); … … 605 604 subsetmap, 606 605 VMGData_Potential_fused, 607 jobids,608 606 container->getContainer(), 609 607 MatrixNrLookup); … … 685 683 FragmentController &controller, 686 684 const FragmentationFragmentationAutomationAction::FragmentationFragmentationAutomationParameters ¶ms, 687 const std:: vector<MPQCData> &fragmentData,685 const std::map<JobId_t, MPQCData> &fragmentData, 688 686 const SamplingGrid &full_sampled_grid, 689 687 const Fragment &full_fragment) … … 692 690 // add one job for each fragment as the short-range correction which we need 693 691 // to subtract from the obtained full potential to get the long-range part only 694 for (std:: vector<MPQCData>::const_iterator iter = fragmentData.begin();692 for (std::map<JobId_t, MPQCData>::const_iterator iter = fragmentData.begin(); 695 693 iter != fragmentData.end(); ++iter) { 696 694 const JobId_t next_id = controller.getAvailableId(); 697 LOG(1, "INFO: Creating VMGJob with " << iter->s ampled_grid.sampled_grid.size()698 << " gridpoints and " << iter-> charges.size() << " particle charges.");695 LOG(1, "INFO: Creating VMGJob with " << iter->second.sampled_grid.sampled_grid.size() 696 << " gridpoints and " << iter->second.charges.size() << " particle charges."); 699 697 FragmentJob::ptr testJob( 700 new VMGJob(next_id, iter->s ampled_grid, iter->positions, iter->charges) );698 new VMGJob(next_id, iter->second.sampled_grid, iter->second.positions, iter->second.charges) ); 701 699 jobs.push_back(testJob); 702 700 } … … 776 774 RunService(io_service, "Requesting short-range results"); 777 775 std::vector<FragmentResult::ptr> MPQCresults = controller.getReceivedResults(); 778 std:: vector<MPQCData> fragmentData;776 std::map<JobId_t, MPQCData> fragmentData; 779 777 ConvertFragmentResultTo<MPQCData>(MPQCresults, fragmentData); 780 778 … … 795 793 Fragment full_fragment; 796 794 sumUpChargeDensity( 797 jobids,798 795 fragmentData, 799 796 params.path.get(), … … 818 815 "FragmentationFragmentationAutomationAction::performCall() - number of MPQCresultd and VMGresults don't match."); 819 816 820 std:: vector<VMGData> longrangeData;817 std::map<JobId_t, VMGData> longrangeData; 821 818 ConvertFragmentResultTo<VMGData>(VMGresults, longrangeData); 822 // remove full solution from vector, has to be treated extra823 VMGData fullsolutionData = longrangeData.back();824 longrangeData. pop_back();819 // remove full solution from map (must be highest id), has to be treated extra 820 VMGData fullsolutionData = (--longrangeData.end())->second; 821 longrangeData.erase(--longrangeData.end()); 825 822 826 823 // Final phase: print result … … 828 825 LOG(1, "INFO: Parsing fragment files from " << params.path.get() << "."); 829 826 printReceivedFullResults( 830 MPQCresults,831 VMGresults,832 827 fragmentData, 833 828 longrangeData, … … 843 838 LOG(1, "INFO: Parsing fragment files from " << params.path.get() << "."); 844 839 printReceivedMPQCResults( 845 jobids,846 840 fragmentData, 847 841 params.path.get(),
Note:
See TracChangeset
for help on using the changeset viewer.