Ignore:
Timestamp:
Apr 15, 2013, 10:28:25 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:
503acc1
Parents:
4f44ae
git-author:
Frederik Heber <heber@…> (03/04/13 14:14:10)
git-committer:
Frederik Heber <heber@…> (04/15/13 10:28:25)
Message:

Outsourced parsing of fragment files into ParseFragmentJobsAction from FragmentationAutomationAction.

File:
1 edited

Legend:

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

    r4f44ae rbae7bc  
    6060#include "Fragmentation/Automation/FragmentationResults.hpp"
    6161#include "Fragmentation/Automation/MPQCFragmentController.hpp"
    62 #include "Fragmentation/Automation/parseKeySetFile.hpp"
    6362#include "Fragmentation/Automation/VMGDebugGridFragmentController.hpp"
    6463#include "Fragmentation/Automation/VMGFragmentController.hpp"
     
    224223 *
    225224 * @param fragmentData MPQCData resulting from the jobs, associated to job id
    226  * @param KeySetFilename filename with keysets to associate forces correctly
     225 * @param MatrixNrLookup map with enumerated jobids
     226 * @param KeySet KeySets of all (non-hydrogen) atoms
     227 * @param ForceKeySet KeySets of all atoms except those added by saturation
    227228 * @param NoAtoms total number of atoms
    228  * @param full_sample summed up charge from fragments on return
    229229 */
    230230bool printReceivedMPQCResults(
    231231    const std::map<JobId_t, MPQCData> &fragmentData,
    232     const std::string &KeySetFilename,
     232    const std::map< JobId_t, size_t > MatrixNrLookup,
     233    KeySetsContainer KeySet,
     234    const KeySetsContainer &ForceKeySet,
    233235    size_t NoAtoms)
    234236{
    235   // create a vector of all job ids
    236   std::vector<JobId_t> jobids;
    237   std::transform(fragmentData.begin(),fragmentData.end(),
    238       std::back_inserter(jobids),
    239       boost::bind( &std::map<JobId_t,MPQCData>::value_type::first, boost::lambda::_1 )
    240   );
    241 
    242   // create lookup from job nr to fragment number
    243   size_t FragmentCounter = 0;
    244   const std::map< JobId_t, size_t > MatrixNrLookup=
    245       createMatrixNrLookup(jobids, FragmentCounter);
     237  size_t FragmentCounter = MatrixNrLookup.size();
    246238
    247239  // place results into maps
     
    253245  if (!Energy.InitialiseIndices()) return false;
    254246
    255   if (!Force.ParseIndices(KeySetFilename.c_str())) return false;
    256 
    257   // initialise keysets
    258   KeySetsContainer KeySet;
    259   parseKeySetFile(KeySet, KeySetFilename, FragmentCounter, NonHydrogenKeySets);
    260   KeySetsContainer ForceKeySet;
    261   parseKeySetFile(ForceKeySet, KeySetFilename, FragmentCounter, HydrogenKeySets);
     247  if (!Force.ParseIndices(ForceKeySet)) return false;
    262248
    263249  // combine all found data
     
    295281
    296282  return true;
     283}
     284
     285/** Print MPQCData from received results.
     286 *
     287 * @param fragmentData MPQCData resulting from the jobs, associated to job id
     288 * @param KeySetFilename filename with keysets to associate forces correctly
     289 * @param NoAtoms total number of atoms
     290 */
     291bool printReceivedMPQCResults(
     292    const std::map<JobId_t, MPQCData> &fragmentData,
     293    const std::string &KeySetFilename,
     294    size_t NoAtoms)
     295{
     296  // create a vector of all job ids
     297  std::vector<JobId_t> jobids;
     298  std::transform(fragmentData.begin(),fragmentData.end(),
     299      std::back_inserter(jobids),
     300      boost::bind( &std::map<JobId_t,MPQCData>::value_type::first, boost::lambda::_1 )
     301  );
     302
     303  // create lookup from job nr to fragment number
     304  size_t FragmentCounter = 0;
     305  const std::map< JobId_t, size_t > MatrixNrLookup =
     306      createMatrixNrLookup(jobids, FragmentCounter);
     307
     308  // initialise keysets
     309  KeySetsContainer KeySet;
     310  parseKeySetFile(KeySet, KeySetFilename, FragmentCounter, NonHydrogenKeySets);
     311  KeySetsContainer ForceKeySet;
     312  parseKeySetFile(ForceKeySet, KeySetFilename, FragmentCounter, HydrogenKeySets);
     313
     314  return printReceivedMPQCResults(
     315      fragmentData,
     316      MatrixNrLookup,
     317      KeySet,
     318      ForceKeySet,
     319      NoAtoms);
     320}
     321
     322/** Print MPQCData from received results.
     323 *
     324 * @param fragmentData MPQCData resulting from the jobs, associated to job id
     325 * @param KeySet KeySets of all (non-hydrogen) atoms
     326 * @param ForceKeySet KeySets of all atoms except those added by saturation
     327 * @param NoAtoms total number of atoms
     328 */
     329bool printReceivedMPQCResults(
     330    const std::map<JobId_t, MPQCData> &fragmentData,
     331    const KeySetsContainer &KeySet,
     332    const KeySetsContainer &ForceKeySet,
     333    size_t NoAtoms)
     334{
     335  // create a vector of all job ids
     336  std::vector<JobId_t> jobids;
     337  std::transform(fragmentData.begin(),fragmentData.end(),
     338      std::back_inserter(jobids),
     339      boost::bind( &std::map<JobId_t,MPQCData>::value_type::first, boost::lambda::_1 )
     340  );
     341
     342  // create lookup from job nr to fragment number
     343  size_t FragmentCounter = 0;
     344  const std::map< JobId_t, size_t > MatrixNrLookup =
     345      createMatrixNrLookup(jobids, FragmentCounter);
     346
     347  return printReceivedMPQCResults(
     348      fragmentData,
     349      MatrixNrLookup,
     350      KeySet,
     351      ForceKeySet,
     352      NoAtoms);
    297353}
    298354
     
    382438bool appendToHomologyFile(
    383439    const boost::filesystem::path &homology_file,
    384     const FragmentationResults &results,
    385     const std::string &KeySetFilename)
     440    const FragmentationResults &results)
    386441{
    387442  /// read homology container (if present)
     
    479534  // TODO: Have io_service run in second thread and merge with current again eventually
    480535
    481   // check some things prior to work
    482   enum OutputType_t {
    483     ToFiles,
    484     ToJobs,
    485     ToNone
    486   };
    487   enum OutputType_t outputtype = ToNone;
    488   if (params.jobfiles.get().size() != 0) {
    489     // we got no job files, hence we use FragmentJobQueue
    490     if (params.path.get().size() == 0) {
    491       ELOG(1, "Missing path to fragment files.");
    492       return Action::failure;
    493     }
    494     outputtype = ToFiles;
    495 
    496     // parse in fragment-jobs if given
    497     if(!FragmentJobQueue::getInstance().addJobsFromFiles(
    498         params.jobfiles.get(),
    499         params.level.get()))
    500       return Action::failure;
    501   } else {
    502     if (params.path.get().size() != 0) {
    503       ELOG(2, "Path to fragment given although we use FragmentJobQueue.");
    504     }
    505     outputtype = ToJobs;
    506   }
    507 
    508536  size_t Exitflag = 0;
    509537  std::map<JobId_t, MPQCData> fragmentData;
     
    537565  FragmentationChargeDensity summedChargeDensity(
    538566      fragmentData,
    539       params.path.get());
     567      FragmentJobQueue::getInstance().getKeySets());
    540568  const std::vector<SamplingGrid> full_sample = summedChargeDensity.getFullSampledGrid();
    541 
    542569  LOG(1, "INFO: There are " << fragmentData.size() << " short-range and "
    543570      << full_sample.size() << " level-wise long-range jobs.");
     
    587614      fragmentData,
    588615      longrangeData,
    589       params.path.get());
     616      FragmentJobQueue::getInstance().getKeySets(),
     617      FragmentJobQueue::getInstance().getFullKeySets());
    590618  results(
    591619      fragmentData,
     
    593621      fullsolutionData,
    594622      full_sample);
    595   {
    596     LOG(1, "INFO: Parsing fragment files from " << params.path.get() << ".");
    597     printReceivedFullResults(results);
    598   }
     623  printReceivedFullResults(results);
    599624
    600625  // append all keysets to homology file
     
    603628    if (homology_file.string() != "") {
    604629      LOG(1, "INFO: Appending HomologyGraphs to file " << homology_file.string() << ".");
    605       if (!appendToHomologyFile(homology_file, results, params.path.get()))
     630      if (!appendToHomologyFile(homology_file, results))
    606631        Exitflag = 1;
    607632    }
     
    630655    printReceivedMPQCResults(
    631656        fragmentData,
    632         params.path.get(),
    633         getNoAtomsFromAdjacencyFile(params.path.get()));
     657        FragmentJobQueue::getInstance().getKeySets(),
     658        FragmentJobQueue::getInstance().getFullKeySets(),
     659        World::getInstance().getAllAtoms().size()));
    634660  }
    635661#endif
     662
     663  // now clear all present jobs as we are done
     664  FragmentJobQueue::getInstance().clear();
    636665
    637666  return (Exitflag == 0) ? Action::success : Action::failure;
Note: See TracChangeset for help on using the changeset viewer.