Changeset 409a05 for src/Fragmentation


Ignore:
Timestamp:
Sep 14, 2016, 6:43:45 PM (8 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, 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_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
Children:
b5134a
Parents:
da098d2
git-author:
Frederik Heber <heber@…> (06/12/16 08:18:50)
git-committer:
Frederik Heber <heber@…> (09/14/16 18:43:45)
Message:

..SumUpPerLevel are now functors that allow to set the zero instance of a specific type.

Location:
src/Fragmentation/Summation
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Summation/Containers/FragmentationChargeDensity.cpp

    rda098d2 r409a05  
    8181
    8282  /// convert all MPQCData to MPQCDataMap_t
    83   OrthogonalSumUpPerLevel<MPQCDataGridMap_t, MPQCData, MPQCDataGridVector_t>(
    84       fragmentData, MatrixNrLookup, container, subsetmap,
     83  OrthogonalSumUpPerLevel<MPQCDataGridMap_t, MPQCData, MPQCDataGridVector_t> gridsummation(
     84      fragmentData);
     85  // and sum up
     86  gridsummation(MatrixNrLookup, container, subsetmap,
    8587      Result_Grid_fused, Result_perIndexSet_Grid);
    8688}
  • src/Fragmentation/Summation/Containers/FragmentationLongRangeResults.cpp

    rda098d2 r409a05  
    113113        "FragmentationLongRangeResults::FragmentationLongRangeResults() - ForceKeySet's KeySets and fragmentData differ in size.");
    114114
    115     OrthogonalSumUpPerLevel<MPQCDataGridMap_t, MPQCData, MPQCDataGridVector_t>(
    116         fragmentData, MPQCMatrixNrLookup, container, subsetmap,
    117         Result_Grid_fused, Result_perIndexSet_Grid);
     115    OrthogonalSumUpPerLevel<MPQCDataGridMap_t, MPQCData, MPQCDataGridVector_t>
     116        chargesummation(fragmentData);
     117    chargesummation(MPQCMatrixNrLookup, container, subsetmap, Result_Grid_fused,
     118        Result_perIndexSet_Grid);
    118119
    119120    // multiply each short-range potential with the respective charge
     
    124125    }
    125126    // then sum up
    126     OrthogonalSumUpPerLevel<VMGDataMap_t, VMGData, VMGDataVector_t>(
    127         longrangeData, VMGMatrixNrLookup, container, subsetmap,
     127    OrthogonalSumUpPerLevel<VMGDataMap_t, VMGData, VMGDataVector_t> vmgsummation(
     128        longrangeData);
     129    vmgsummation(VMGMatrixNrLookup, container, subsetmap,
    128130        Result_LongRange_fused, Result_perIndexSet_LongRange);
    129131
     
    163165
    164166    // then sum up
    165     OrthogonalSumUpPerLevel<VMGDataGridMap_t, VMGData, VMGDataGridVector_t>(
    166         longrangeData, VMGMatrixNrLookup, container, subsetmap,
     167    OrthogonalSumUpPerLevel<VMGDataGridMap_t, VMGData, VMGDataGridVector_t> vmggridsummation(
     168        longrangeData);
     169    vmggridsummation(VMGMatrixNrLookup, container, subsetmap,
    167170        Result_GridLongRange_fused, Result_perIndexSet_LongRange_Grid);
    168171
  • src/Fragmentation/Summation/Containers/FragmentationShortRangeResults.cpp

    rda098d2 r409a05  
    9797        "FragmentationShortRangeResults::FragmentationShortRangeResults() - ForceKeySet's KeySets and fragmentData differ in size.");
    9898
    99     OrthogonalSumUpPerLevel<MPQCDataEnergyMap_t, MPQCData, MPQCDataEnergyVector_t>(
    100         fragmentData, MPQCMatrixNrLookup, container, subsetmap,
     99    OrthogonalSumUpPerLevel<MPQCDataEnergyMap_t, MPQCData, MPQCDataEnergyVector_t> mpqcenergysummation(
     100        fragmentData);
     101    mpqcenergysummation(MPQCMatrixNrLookup, container, subsetmap,
    101102        Result_Energy_fused, Result_perIndexSet_Energy);
    102     OrthogonalSumUpPerLevel<MPQCDataFragmentMap_t, MPQCData, MPQCDataFragmentVector_t>(
    103         fragmentData, MPQCMatrixNrLookup, container, subsetmap,
     103    OrthogonalSumUpPerLevel<MPQCDataFragmentMap_t, MPQCData, MPQCDataFragmentVector_t> mpqcfragmentsummation(
     104        fragmentData);
     105    mpqcfragmentsummation(MPQCMatrixNrLookup, container, subsetmap,
    104106        Result_Fragment_fused, Result_perIndexSet_Fragment);
    105     SumUpPerLevel<MPQCDataTimeMap_t, MPQCData, MPQCDataTimeVector_t>(
    106         fragmentData, MPQCMatrixNrLookup, container, subsetmap,
     107    SumUpPerLevel<MPQCDataTimeMap_t, MPQCData, MPQCDataTimeVector_t> mpqctimesummation(
     108        fragmentData);
     109    mpqctimesummation(MPQCMatrixNrLookup, container, subsetmap,
    107110        Result_Time_fused, Result_perIndexSet_Time);
    108111
  • src/Fragmentation/Summation/OrthogonalSumUpPerLevel.hpp

    rda098d2 r409a05  
    3030
    3131template <typename TypeMap, typename TypeData, typename TypeVector>
    32 void OrthogonalSumUpPerLevel(
    33     const std::map<JobId_t, TypeData> &fragmentData,
    34     const std::map< JobId_t, size_t > &MatrixNrLookup,
    35     const IndexSetContainer::ptr &container,
    36     SubsetMap::ptr &subsetmap,
    37     std::vector<TypeMap> &levelresults,
    38     std::map<IndexSet::ptr, std::pair<TypeMap, TypeMap> > &keysetresults
    39     )
     32struct OrthogonalSumUpPerLevel
    4033{
    41   // place data into boost::fusion::map instance
     34  /** Constructor of class OrthogonalSumUpPerLevel.
     35   *
     36   * This prepares all the data by converting them into boost::fusion::map
     37   * format and also initializes the default zero instances used as base
     38   * in the summation.
     39   *
     40   * \param _fragmentData data to sum up per job
     41   */
     42  OrthogonalSumUpPerLevel(const std::map<JobId_t, TypeData> &_fragmentData)
     43  {
     44    // place data into boost::fusion::map instance
     45    convertDataTo<TypeData, TypeMap>(_fragmentData, Data_fused);
     46
     47    // initialize zero instance map
     48    ZeroInstanceInitializer<TypeMap> initZeroInstance(ZeroInstances);
     49    boost::mpl::for_each<TypeVector>(boost::ref(initZeroInstance));
     50  }
     51
     52  /** Setter for a specific zero value for the given \a MapValue type.
     53   *
     54   * \param _zeroinstance zero instance to set for type \a MapValue
     55   */
     56  template <typename MapKey>
     57  void setZeroInstance(
     58      const typename boost::fusion::result_of::value_at_key<TypeMap, MapKey>::type &_zeroinstance)
     59  {
     60    boost::fusion::at_key<MapKey>(ZeroInstances) = _zeroinstance;
     61  }
     62
     63  /** Perform the actual orthogonal summation for each type in \a TypeMap,
     64   * given by \a TypeVector.
     65   *
     66   * i.e. we boost::fusion::for_each over each type in \a TypeVector and perform
     67   * an AllLevelSummator on the type.
     68   *
     69   * \param MatrixNrLookup lookup from job number to a consecutive index in a vector, starting at 0
     70   * \param container container of all indexsets
     71   * \param subsetmap map with all subsets for each indexset
     72   * \param levelresults after summation contains results for each level
     73   * \param keysetresults after summation contains results for each keyset
     74   */
     75  void operator()(
     76      const std::map< JobId_t, size_t > &MatrixNrLookup,
     77      const IndexSetContainer::ptr &container,
     78      SubsetMap::ptr &subsetmap,
     79      std::vector<TypeMap> &levelresults,
     80      std::map<IndexSet::ptr, std::pair<TypeMap, TypeMap> > &keysetresults
     81      )
     82  {
     83    // instantiate summator
     84    levelresults.resize(subsetmap->getMaximumSetLevel());
     85    AllLevelOrthogonalSummator<TypeMap> Summer(
     86                subsetmap,
     87                Data_fused,
     88                container->getContainer(),
     89                MatrixNrLookup,
     90                levelresults,
     91                keysetresults,
     92                ZeroInstances);
     93    // sum up for each type key in TypeVector
     94    boost::mpl::for_each<TypeVector>(boost::ref(Summer));
     95  }
     96
     97  //!> map with all jobs placed into boost::fusion::maps
    4298  std::map<JobId_t, TypeMap> Data_fused;
    43   convertDataTo<TypeData, TypeMap>(fragmentData, Data_fused);
    44 
    45   // initialize zero instance map
     99  //!> zero instances to use in summation
    46100  TypeMap ZeroInstances;
    47   ZeroInstanceInitializer<TypeMap> initZeroInstance(ZeroInstances);
    48   boost::mpl::for_each<TypeVector>(boost::ref(initZeroInstance));
    49 
    50   // instantiate summator
    51   levelresults.resize(subsetmap->getMaximumSetLevel());
    52   AllLevelOrthogonalSummator<TypeMap> Summer(
    53               subsetmap,
    54               Data_fused,
    55               container->getContainer(),
    56               MatrixNrLookup,
    57               levelresults,
    58               keysetresults,
    59               ZeroInstances);
    60   // sum up for each type key in TypeVector
    61   boost::mpl::for_each<TypeVector>(boost::ref(Summer));
    62 }
     101};
    63102
    64103
  • src/Fragmentation/Summation/SumUpPerLevel.hpp

    rda098d2 r409a05  
    2828
    2929template <typename TypeMap, typename TypeData, typename TypeVector>
    30 void SumUpPerLevel(
    31     const std::map<JobId_t, TypeData> &fragmentData,
    32     const std::map< JobId_t, size_t > &MatrixNrLookup,
    33     const IndexSetContainer::ptr &container,
    34     SubsetMap::ptr &subsetmap,
    35     std::vector<TypeMap> &levelresults,
    36     std::map<IndexSet::ptr, std::pair<TypeMap, TypeMap> > &keysetresults
    37     )
     30struct SumUpPerLevel
    3831{
    39   // place data into boost::fusion::map instance
     32  SumUpPerLevel(const std::map<JobId_t, TypeData> &fragmentData)
     33  {
     34    // place data into boost::fusion::map instance
     35    convertDataTo<TypeData, TypeMap>(fragmentData, Data_fused);
     36
     37    // initialize zero instance map
     38    ZeroInstanceInitializer<TypeMap> initZeroInstance(ZeroInstances);
     39    boost::mpl::for_each<TypeVector>(boost::ref(initZeroInstance));
     40  }
     41
     42  /** Setter for a specific zero value for the given \a MapValue type.
     43   *
     44   * \param _zeroinstance zero instance to set for type \a MapValue
     45   */
     46  template <typename MapKey>
     47  void setZeroInstance(
     48      const typename boost::fusion::result_of::value_at_key<TypeMap, MapKey>::type &_zeroinstance)
     49  {
     50    boost::fusion::at_key<MapKey>(ZeroInstances) = _zeroinstance;
     51  }
     52
     53  /** Perform the actual summation for each type in \a TypeMap, given by
     54   * \a TypeVector.
     55   *
     56   * i.e. we boost::fusion::for_each over each type in \a TypeVector and perform
     57   * an AllLevelSummator on the type.
     58   *
     59   * \param MatrixNrLookup lookup from job number to a consecutive index in a vector, starting at 0
     60   * \param container container of all indexsets
     61   * \param subsetmap map with all subsets for each indexset
     62   * \param levelresults after summation contains results for each level
     63   * \param keysetresults after summation contains results for each keyset
     64   */
     65  void operator()(
     66      const std::map< JobId_t, size_t > &MatrixNrLookup,
     67      const IndexSetContainer::ptr &container,
     68      SubsetMap::ptr &subsetmap,
     69      std::vector<TypeMap> &levelresults,
     70      std::map<IndexSet::ptr, std::pair<TypeMap, TypeMap> > &keysetresults
     71      )
     72  {
     73    // instantiate summator
     74    levelresults.resize(subsetmap->getMaximumSetLevel());
     75    AllLevelSummator<TypeMap> Summer(
     76                subsetmap,
     77                Data_fused,
     78                container->getContainer(),
     79                MatrixNrLookup,
     80                levelresults,
     81                keysetresults,
     82                ZeroInstances);
     83    // sum up for each type key in TypeVector
     84    boost::mpl::for_each<TypeVector>(boost::ref(Summer));
     85  }
     86
     87  //!> map with all jobs placed into boost::fusion::maps
    4088  std::map<JobId_t, TypeMap> Data_fused;
    41   convertDataTo<TypeData, TypeMap>(fragmentData, Data_fused);
    42 
    43   // initialize zero instance map
     89  //!> zero instances to use in summation
    4490  TypeMap ZeroInstances;
    45   ZeroInstanceInitializer<TypeMap> initZeroInstance(ZeroInstances);
    46   boost::mpl::for_each<TypeVector>(boost::ref(initZeroInstance));
    47 
    48   // instantiate summator
    49   levelresults.resize(subsetmap->getMaximumSetLevel());
    50   AllLevelSummator<TypeMap> Summer(
    51               subsetmap,
    52               Data_fused,
    53               container->getContainer(),
    54               MatrixNrLookup,
    55               levelresults,
    56               keysetresults,
    57               ZeroInstances);
    58   // sum up for each type key in TypeVector
    59   boost::mpl::for_each<TypeVector>(boost::ref(Summer));
    60 }
    61 
     91};
    6292
    6393#endif /* SUMUPPERLEVEL_HPP_ */
Note: See TracChangeset for help on using the changeset viewer.