Ignore:
Timestamp:
Nov 27, 2012, 8:35:34 AM (12 years ago)
Author:
Frederik Heber <heber@…>
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:
c9f9bb
Parents:
0398bd
git-author:
Frederik Heber <heber@…> (08/27/12 12:12:59)
git-committer:
Frederik Heber <heber@…> (11/27/12 08:35:34)
Message:

createMatrixNrLookup() now just needs vector<JobId_t>.

  • sumUpChargeDensity(), putResultsintoMatrices(), and printReceivedMPQCResults() likewise.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FragmentationAction/FragmentationAutomationAction.cpp

    r0398bd r995e2f  
    198198/** Creates a lookup from FragmentJob::id to the true fragment  number.
    199199 *
    200  * @param results result with job ids
     200 * @param jobids vector with job ids
    201201 * @param MatrixNrLookup Lookup up-map, filled on return
    202202 * @param FragmentCounter total number of fragments on return
    203203 */
    204204void createMatrixNrLookup(
    205     const std::vector<FragmentResult::ptr> &results,
     205    const std::vector<JobId_t> &jobids,
    206206    std::map< JobId_t, size_t > &MatrixNrLookup,
    207207    size_t &FragmentCounter)
     
    210210  MatrixNrLookup.clear();
    211211  FragmentCounter = 0;
    212   {
    213     // bring ids in order ...
    214     typedef std::map< JobId_t, FragmentResult::ptr> IdResultMap_t;
    215     IdResultMap_t IdResultMap;
    216     for (std::vector<FragmentResult::ptr>::const_iterator iter = results.begin();
    217         iter != results.end(); ++iter) {
    218   #ifndef NDEBUG
    219       std::pair< IdResultMap_t::iterator, bool> inserter =
    220   #endif
    221       IdResultMap.insert( make_pair((*iter)->getId(), *iter) );
    222       ASSERT( inserter.second,
    223           "ExtractMPQCDataFromResults() - two results have same id "
    224           +toString((*iter)->getId())+".");
    225     }
    226     // ... and fill lookup
    227     for(IdResultMap_t::const_iterator iter = IdResultMap.begin();
    228         iter != IdResultMap.end(); ++iter)
    229       MatrixNrLookup.insert( make_pair(iter->first, FragmentCounter++) );
     212  for (std::vector<JobId_t>::const_iterator iter = jobids.begin();
     213      iter != jobids.end(); ++iter) {
     214#ifndef NDEBUG
     215    std::pair< std::map< JobId_t, size_t >::iterator, bool> inserter =
     216#endif
     217        MatrixNrLookup.insert( std::make_pair(*iter, FragmentCounter++) );
     218    ASSERT( inserter.second,
     219        "createMatrixNrLookup() - two results have same id "
     220        +toString(*iter)+".");
    230221  }
    231222  LOG(1, "INFO: There are " << FragmentCounter << " fragments.");
     
    234225/** Place results from FragmentResult into EnergyMatrix and ForceMatrix.
    235226 *
    236  * @param results results with ids to associate with fragment number
     227 * @param jobids jobids with ids to associate with fragment number
    237228 * @param fragmentData MPQCData resulting from the jobs
    238229 * @param MatrixNrLookup Lookup up-map from job id to fragment number
     
    244235 */
    245236bool putResultsintoMatrices(
    246     const std::vector<FragmentResult::ptr> &results,
     237    const std::vector<JobId_t> &jobids,
    247238    const std::vector<MPQCData> &fragmentData,
    248239    std::map< JobId_t, size_t > &MatrixNrLookup,
     
    252243    ForceMatrix &Force)
    253244{
    254   ASSERT( results.size() == fragmentData.size(),
    255       "printReceivedMPQCResults() - results and fragmentData differ in size.");
     245  ASSERT( jobids.size() == fragmentData.size(),
     246      "putResultsintoMatrices() - jobids and fragmentData differ in size.");
    256247  std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
    257   std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin();
    258   for (; dataiter != fragmentData.end(); ++dataiter, ++resultiter) {
     248  std::vector<JobId_t>::const_iterator iditer = jobids.begin();
     249  for (; dataiter != fragmentData.end(); ++dataiter, ++iditer) {
    259250    const MPQCData &extractedData = *dataiter;
    260251    // place results into EnergyMatrix ...
     
    264255      matrix[0].resize(1, extractedData.energies.total);
    265256      if (!Energy.AddMatrix(
    266           std::string("MPQCJob ")+toString((*resultiter)->getId()),
     257          std::string("MPQCJob ")+toString(*iditer),
    267258          matrix,
    268           MatrixNrLookup[(*resultiter)->getId()])) {
     259          MatrixNrLookup[*iditer])) {
    269260        ELOG(1, "Adding energy matrix failed.");
    270261        return false;
     
    285276      }
    286277      if (!Force.AddMatrix(
    287           std::string("MPQCJob ")+toString((*resultiter)->getId()),
     278          std::string("MPQCJob ")+toString(*iditer),
    288279          matrix,
    289           MatrixNrLookup[(*resultiter)->getId()])) {
     280          MatrixNrLookup[*iditer])) {
    290281        ELOG(1, "Adding force matrix failed.");
    291282        return false;
     
    310301/** Print MPQCData from received results.
    311302 *
    312  * @param results results with ids to associate with fragment number
     303 * @param jobids jobids with ids to associate with fragment number
    313304 * @param fragmentData MPQCData resulting from the jobs
    314305 * @param KeySetFilename filename with keysets to associate forces correctly
     
    318309 */
    319310bool sumUpChargeDensity(
    320     const std::vector<FragmentResult::ptr> &results,
     311    const std::vector<JobId_t> &jobids,
    321312    const std::vector<MPQCData> &fragmentData,
    322313    const std::string &KeySetFilename,
     
    327318  std::map< JobId_t, size_t > MatrixNrLookup;
    328319  size_t FragmentCounter = 0;
    329   createMatrixNrLookup(results, MatrixNrLookup, FragmentCounter);
     320  createMatrixNrLookup(jobids, MatrixNrLookup, FragmentCounter);
    330321
    331322  // initialise keysets
     
    344335  // create the map of all keysets
    345336  SubsetMap::ptr subsetmap(new SubsetMap(*container));
    346 
    347   // create a vector of all job ids
    348   std::vector<JobId_t> jobids(results.size(), JobId::IllegalJob);
    349   std::transform(results.begin(), results.end(), jobids.begin(),
    350       boost::bind(&FragmentResult::getId,
    351           boost::bind(&FragmentResult::ptr::operator->, _1)));
    352337
    353338  /// convert all MPQCData to MPQCDataMap_t
     
    374359 */
    375360bool printReceivedMPQCResults(
    376     const std::vector<FragmentResult::ptr> &results,
     361    const std::vector<JobId_t> &jobids,
    377362    const std::vector<MPQCData> &fragmentData,
    378363    const std::string &KeySetFilename,
     
    383368  std::map< JobId_t, size_t > MatrixNrLookup;
    384369  size_t FragmentCounter = 0;
    385   createMatrixNrLookup(results, MatrixNrLookup, FragmentCounter);
     370  createMatrixNrLookup(jobids, MatrixNrLookup, FragmentCounter);
    386371
    387372  // place results into maps
    388373  EnergyMatrix Energy;
    389374  ForceMatrix Force;
    390   if (!putResultsintoMatrices(results, fragmentData, MatrixNrLookup, FragmentCounter, NoAtoms, Energy, Force))
     375  if (!putResultsintoMatrices(jobids, fragmentData, MatrixNrLookup, FragmentCounter, NoAtoms, Energy, Force))
    391376    return false;
    392377
     
    418403  // create the map of all keysets
    419404  SubsetMap::ptr subsetmap(new SubsetMap(*container));
    420 
    421   // create a vector of all job ids
    422   std::vector<JobId_t> jobids(results.size(), JobId::IllegalJob);
    423   std::transform(results.begin(), results.end(), jobids.begin(),
    424       boost::bind(&FragmentResult::getId,
    425           boost::bind(&FragmentResult::ptr::operator->, _1)));
    426405
    427406  /// convert all MPQCData to MPQCDataMap_t
     
    536515    SamplingGrid &full_sample)
    537516{
    538   // create lookup from job nr to fragment number
    539   std::map< JobId_t, size_t > MatrixNrLookup;
    540   size_t FragmentCounter = 0;
    541   createMatrixNrLookup(fragmentresults, MatrixNrLookup, FragmentCounter);
    542 
    543   // initialise keysets
    544   KeySetsContainer KeySet;
    545   KeySetsContainer ForceKeySet;
    546   {
    547     // else needs keysets without hydrogens
    548     std::stringstream filename;
    549     filename << FRAGMENTPREFIX << KEYSETFILE;
    550     if (!KeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false;
    551   }
    552 
    553   {
    554     // forces need keysets including hydrogens
    555     std::stringstream filename;
    556     filename << FRAGMENTPREFIX << FORCESFILE;
    557     if (!ForceKeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false;
    558   }
    559 
    560   /// prepare for OrthogonalSummation
    561 
    562   // convert KeySetContainer to IndexSetContainer
    563   IndexSetContainer::ptr container(new IndexSetContainer(KeySet));
    564   // create the map of all keysets
    565   SubsetMap::ptr subsetmap(new SubsetMap(*container));
    566 
    567517  // create a vector of all job ids from short-range
    568518  std::vector<JobId_t> jobids(fragmentresults.size(), JobId::IllegalJob);
     
    570520      boost::bind(&FragmentResult::getId,
    571521          boost::bind(&FragmentResult::ptr::operator->, _1)));
     522
     523  // create lookup from job nr to fragment number
     524  std::map< JobId_t, size_t > MatrixNrLookup;
     525  size_t FragmentCounter = 0;
     526  createMatrixNrLookup(jobids, MatrixNrLookup, FragmentCounter);
     527
     528  // initialise keysets
     529  KeySetsContainer KeySet;
     530  KeySetsContainer ForceKeySet;
     531  {
     532    // else needs keysets without hydrogens
     533    std::stringstream filename;
     534    filename << FRAGMENTPREFIX << KEYSETFILE;
     535    if (!KeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false;
     536  }
     537
     538  {
     539    // forces need keysets including hydrogens
     540    std::stringstream filename;
     541    filename << FRAGMENTPREFIX << FORCESFILE;
     542    if (!ForceKeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false;
     543  }
     544
     545  /// prepare for OrthogonalSummation
     546
     547  // convert KeySetContainer to IndexSetContainer
     548  IndexSetContainer::ptr container(new IndexSetContainer(KeySet));
     549  // create the map of all keysets
     550  SubsetMap::ptr subsetmap(new SubsetMap(*container));
    572551
    573552  /// convert all MPQCData to MPQCDataMap_t
     
    805784      "FragmentationFragmentationAutomationAction::performCall() - please load the full molecule into the World before.");
    806785
     786  // create a vector of all job ids
     787  std::vector<JobId_t> jobids(MPQCresults.size(), JobId::IllegalJob);
     788  std::transform(MPQCresults.begin(), MPQCresults.end(), jobids.begin(),
     789      boost::bind(&FragmentResult::getId,
     790          boost::bind(&FragmentResult::ptr::operator->, _1)));
     791
    807792  // obtain combined charge density
    808793  LOG(1, "INFO: Parsing fragment files from " << params.path.get() << ".");
     
    810795  Fragment full_fragment;
    811796  sumUpChargeDensity(
    812       MPQCresults,
     797      jobids,
    813798      fragmentData,
    814799      params.path.get(),
     
    858843    LOG(1, "INFO: Parsing fragment files from " << params.path.get() << ".");
    859844    printReceivedMPQCResults(
    860         MPQCresults,
     845        jobids,
    861846        fragmentData,
    862847        params.path.get(),
Note: See TracChangeset for help on using the changeset viewer.