source: src/Fragmentation/Summation/OrthogonalSumUpPerLevel.hpp@ 0ee9cb3

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex 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_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 0ee9cb3 was 409a05, checked in by Frederik Heber <heber@…>, 9 years ago

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

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * OrthogonalSumUpPerLevel.hpp
3 *
4 * Created on: Aug 27, 2012
5 * Author: heber
6 */
7
8#ifndef ORTHOGONALSUMUPPERLEVEL_HPP_
9#define ORTHOGONALSUMUPPERLEVEL_HPP_
10
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17
18#include <map>
19#include <vector>
20
21#include "Fragmentation/Summation/Converter/DataConverter.hpp"
22#include "Fragmentation/Summation/AllLevelOrthogonalSummator.hpp"
23#include "Fragmentation/Summation/IndexSet.hpp"
24#include "Fragmentation/Summation/IndexSetContainer.hpp"
25#include "Fragmentation/Summation/ZeroInstanceInitializer.hpp"
26
27#include "Fragmentation/Summation/Containers/MPQCData.hpp"
28
29#include <boost/mpl/for_each.hpp>
30
31template <typename TypeMap, typename TypeData, typename TypeVector>
32struct OrthogonalSumUpPerLevel
33{
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
98 std::map<JobId_t, TypeMap> Data_fused;
99 //!> zero instances to use in summation
100 TypeMap ZeroInstances;
101};
102
103
104#endif /* ORTHOGONALSUMUPPERLEVEL_HPP_ */
Note: See TracBrowser for help on using the repository browser.