Ignore:
Timestamp:
Sep 14, 2016, 6:43:45 PM (9 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.