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:
995e2f
Parents:
302345
git-author:
Frederik Heber <heber@…> (08/27/12 12:31:31)
git-committer:
Frederik Heber <heber@…> (11/27/12 08:35:34)
Message:

Moved ConvertDataTo and ..SumUpPerLevel into distinct header files.

File:
1 edited

Legend:

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

    r302345 r0398bd  
    5959#include "Fragmentation/KeySet.hpp"
    6060#include "Fragmentation/KeySetsContainer.hpp"
    61 #include "Fragmentation/Summation/AllLevelOrthogonalSummator.hpp"
    62 #include "Fragmentation/Summation/AllLevelSummator.hpp"
     61#include "Fragmentation/Summation/OrthogonalSumUpPerLevel.hpp"
     62#include "Fragmentation/Summation/SumUpPerLevel.hpp"
    6363#include "Fragmentation/Summation/OrthogonalFullSummator.hpp"
    6464#include "Fragmentation/Summation/OrthogonalSummation.hpp"
     
    308308  return true;
    309309}
    310 
    311 template <typename source, typename dest>
    312 void convertDataTo(
    313     const std::vector<source> &fragmentData,
    314     std::vector<dest> &MPQCData_fused)
    315 {
    316   MPQCData_fused.clear();
    317 }
    318 
    319 template <>
    320 void convertDataTo<MPQCData, MPQCDataEnergyMap_t>(
    321     const std::vector<MPQCData> &fragmentData,
    322     std::vector<MPQCDataEnergyMap_t> &MPQCData_Energy_fused)
    323 {
    324   // energy_t
    325   MPQCData_Energy_fused.clear();
    326   MPQCData_Energy_fused.reserve(fragmentData.size());
    327   for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
    328       dataiter != fragmentData.end(); ++dataiter) {
    329     const MPQCData &extractedData = *dataiter;
    330     LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
    331     MPQCDataEnergyMap_t instance;
    332     boost::fusion::at_key<MPQCDataFused::energy_total>(instance) = extractedData.energies.total;
    333     boost::fusion::at_key<MPQCDataFused::energy_nuclear_repulsion>(instance) = extractedData.energies.nuclear_repulsion;
    334     boost::fusion::at_key<MPQCDataFused::energy_electron_coulomb>(instance) = extractedData.energies.electron_coulomb;
    335     boost::fusion::at_key<MPQCDataFused::energy_electron_exchange>(instance) = extractedData.energies.electron_exchange;
    336     boost::fusion::at_key<MPQCDataFused::energy_correlation>(instance) = extractedData.energies.correlation;
    337     boost::fusion::at_key<MPQCDataFused::energy_overlap>(instance) = extractedData.energies.overlap;
    338     boost::fusion::at_key<MPQCDataFused::energy_kinetic>(instance) = extractedData.energies.kinetic;
    339     boost::fusion::at_key<MPQCDataFused::energy_hcore>(instance) = extractedData.energies.hcore;
    340     boost::fusion::at_key<MPQCDataFused::energy_eigenvalues>(instance) = extractedData.energies.eigenvalues;
    341     MPQCData_Energy_fused.push_back(instance);
    342   }
    343 }
    344 
    345 template <>
    346 void convertDataTo<VMGData, VMGDataMap_t>(
    347     const std::vector<VMGData> &longrangeData,
    348     std::vector<VMGDataMap_t> &VMGData_fused)
    349 {
    350   // energy_t
    351   VMGData_fused.clear();
    352   VMGData_fused.reserve(longrangeData.size());
    353   for(std::vector<VMGData>::const_iterator dataiter = longrangeData.begin();
    354       dataiter != longrangeData.end(); ++dataiter) {
    355     const VMGData &extractedData = *dataiter;
    356     LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
    357     VMGDataMap_t instance;
    358     boost::fusion::at_key<VMGDataFused::sampled_potential>(instance) = extractedData.sampled_potential;
    359     boost::fusion::at_key<VMGDataFused::energy_potential>(instance) = extractedData.sampled_potential.integral();
    360     boost::fusion::at_key<VMGDataFused::energy_long>(instance) = extractedData.e_long;
    361     VMGData_fused.push_back(instance);
    362   }
    363 }
    364 
    365 void convertMPQCDatatoForceMap(
    366     const std::vector<MPQCData> &fragmentData,
    367     const KeySetsContainer &ForceKeySet,
    368     std::vector<MPQCDataForceMap_t> &MPQCData_Force_fused)
    369 {
    370   // forces
    371   ASSERT( ForceKeySet.KeySets.size() == fragmentData.size(),
    372       "FragmentationAutomationAction::performCall() - indices and fragmentData differ in size.");
    373   MPQCData_Force_fused.clear();
    374   MPQCData_Force_fused.reserve(fragmentData.size());
    375   std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
    376   KeySetsContainer::ArrayOfIntVectors::const_iterator arrayiter = ForceKeySet.KeySets.begin();
    377   for(;dataiter != fragmentData.end(); ++dataiter, ++arrayiter) {
    378     const MPQCData &extractedData = *dataiter;
    379     LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
    380     MPQCDataForceMap_t instance;
    381     // must convert int to index_t
    382     IndexedVectors::indices_t indices(arrayiter->begin(), arrayiter->end());
    383     boost::fusion::at_key<MPQCDataFused::forces>(instance) =
    384         IndexedVectors(indices, extractedData.forces);
    385     MPQCData_Force_fused.push_back(instance);
    386   }
    387 }
    388 
    389 template <>
    390 void convertDataTo<MPQCData, MPQCDataGridMap_t>(
    391     const std::vector<MPQCData> &fragmentData,
    392     std::vector<MPQCDataGridMap_t> &MPQCData_Grid_fused)
    393 {
    394   // sampled_grid
    395   MPQCData_Grid_fused.clear();
    396   MPQCData_Grid_fused.reserve(fragmentData.size());
    397   for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
    398       dataiter != fragmentData.end(); ++dataiter) {
    399     const MPQCData &extractedData = *dataiter;
    400     LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
    401     MPQCDataGridMap_t instance;
    402     boost::fusion::at_key<MPQCDataFused::sampled_grid>(instance) = extractedData.sampled_grid;
    403     MPQCData_Grid_fused.push_back(instance);
    404   }
    405 }
    406 
    407 template <>
    408 void convertDataTo<MPQCData, MPQCDataFragmentMap_t>(
    409     const std::vector<MPQCData> &fragmentData,
    410     std::vector<MPQCDataFragmentMap_t> &MPQCData_Fragment_fused)
    411 {
    412   // fragment
    413   MPQCData_Fragment_fused.clear();
    414   MPQCData_Fragment_fused.reserve(fragmentData.size());
    415   for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
    416       dataiter != fragmentData.end(); ++dataiter) {
    417     const MPQCData &extractedData = *dataiter;
    418     LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
    419     MPQCDataFragmentMap_t instance;
    420     boost::fusion::at_key<MPQCDataFused::fragment>(instance) =
    421         Fragment(extractedData.positions, extractedData.charges);
    422     MPQCData_Fragment_fused.push_back(instance);
    423   }
    424 }
    425 
    426 template <>
    427 void convertDataTo<MPQCData, MPQCDataTimeMap_t>(
    428     const std::vector<MPQCData> &fragmentData,
    429     std::vector<MPQCDataTimeMap_t> &MPQCData_Time_fused)
    430 {
    431   // times
    432   MPQCData_Time_fused.clear();
    433   MPQCData_Time_fused.reserve(fragmentData.size());
    434   for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
    435       dataiter != fragmentData.end(); ++dataiter) {
    436     const MPQCData &extractedData = *dataiter;
    437     LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
    438     MPQCDataTimeMap_t instance;
    439     boost::fusion::at_key<MPQCDataFused::times_walltime>(instance) = extractedData.times.walltime;
    440     boost::fusion::at_key<MPQCDataFused::times_cputime>(instance) = extractedData.times.cputime;
    441     boost::fusion::at_key<MPQCDataFused::times_flops>(instance) = extractedData.times.flops;
    442     MPQCData_Time_fused.push_back(instance);
    443   }
    444 }
    445 
    446 template <typename TypeMap, typename TypeVector>
    447 std::vector<TypeMap> SumUpPerLevel(
    448     const std::vector<MPQCData> &fragmentData,
    449     const std::vector<JobId_t> &jobids,
    450     std::map< JobId_t, size_t > &MatrixNrLookup,
    451     const IndexSetContainer::ptr &container,
    452     SubsetMap::ptr &subsetmap
    453     )
    454 {
    455   // place data into boost::fusion::map instance
    456   std::vector<TypeMap> MPQCData_fused;
    457   convertDataTo<MPQCData, TypeMap>(fragmentData, MPQCData_fused);
    458   // instantiate summator
    459   std::vector<TypeMap> Result_fused(subsetmap->getMaximumSubsetLevel());
    460   AllLevelSummator<TypeMap> Summer(
    461               subsetmap,
    462               MPQCData_fused,
    463               jobids,
    464               container->getContainer(),
    465               MatrixNrLookup,
    466               Result_fused);
    467   // sum up for each type key in TypeVector
    468   boost::mpl::for_each<TypeVector>(boost::ref(Summer));
    469   return Result_fused;
    470 }
    471 
    472 template <typename TypeMap, typename TypeVector>
    473 std::vector<TypeMap> OrthogonalSumUpPerLevel(
    474     const std::vector<MPQCData> &fragmentData,
    475     const std::vector<JobId_t> &jobids,
    476     std::map< JobId_t, size_t > &MatrixNrLookup,
    477     const IndexSetContainer::ptr &container,
    478     SubsetMap::ptr &subsetmap
    479     )
    480 {
    481   // place data into boost::fusion::map instance
    482   std::vector<TypeMap> MPQCData_fused;
    483   convertDataTo<MPQCData, TypeMap>(fragmentData, MPQCData_fused);
    484   // instantiate summator
    485   std::vector<TypeMap> Result_fused(subsetmap->getMaximumSubsetLevel());
    486   AllLevelOrthogonalSummator<TypeMap> Summer(
    487               subsetmap,
    488               MPQCData_fused,
    489               jobids,
    490               container->getContainer(),
    491               MatrixNrLookup,
    492               Result_fused);
    493   // sum up for each type key in TypeVector
    494   boost::mpl::for_each<TypeVector>(boost::ref(Summer));
    495   return Result_fused;
    496 }
    497 
    498310/** Print MPQCData from received results.
    499311 *
     
    552364  return true;
    553365}
    554 
    555366
    556367/** Print MPQCData from received results.
Note: See TracChangeset for help on using the changeset viewer.