source: src/Fragmentation/Summation/Converter/DataConverter.hpp@ fbf143

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
Last change on this file since fbf143 was fbf143, checked in by Frederik Heber <heber@…>, 12 years ago

Placed Containers, Converter, and SetValues as subfolders into Summation.

  • also libMolecuilderFragmentationSummation is now a shared library, easing linkage to libMolecuilderJobs, and contains all of the three convenience libraries.
  • libMolecuilderFragmentationSetValues is now again convenience, as contained in ..Summation which in turn is shared.
  • KeySetsContainer right now is the link between lib..Summation and lib.. Fragmentation. Hence, we had to extract the module and change it into a shared library, as it is required by libMolecuilderJobs through ..Summation but also by ..Fragmentation that heavily relies on this container.
  • moved parseKeySetFile down into Fragmentation folder to KeySetsContainer, it is also contained in new shared library libMolecuilderFragmentation_ KeySetsContainer.
  • Property mode set to 100644
File size: 7.4 KB
Line 
1/*
2 * DataConverter.hpp
3 *
4 * Created on: Aug 27, 2012
5 * Author: heber
6 */
7
8#ifndef DATACONVERTER_HPP_
9#define DATACONVERTER_HPP_
10
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17#include <map>
18#include <boost/fusion/sequence.hpp>
19
20#include "CodePatterns/Assert.hpp"
21
22#ifdef HAVE_JOBMARKET
23#include "JobMarket/types.hpp"
24#else
25typedef size_t JobId_t;
26#endif
27
28#include "Fragmentation/KeySetsContainer.hpp"
29#include "Fragmentation/Summation/SetValues/Histogram.hpp"
30#include "Fragmentation/Summation/SetValues/Fragment.hpp"
31#include "Fragmentation/Summation/SetValues/IndexedVectors.hpp"
32
33#include "Fragmentation/Summation/Containers/MPQCData.hpp"
34#include "Fragmentation/Summation/Containers/MPQCDataFused.hpp"
35#include "Fragmentation/Summation/Containers/MPQCDataMap.hpp"
36#ifdef HAVE_VMG
37#include "Fragmentation/Summation/Containers/VMGData.hpp"
38#include "Fragmentation/Summation/Containers/VMGDataFused.hpp"
39#include "Fragmentation/Summation/Containers/VMGDataMap.hpp"
40#endif
41
42template <typename source, typename dest>
43inline void convertDataTo(
44 const std::map<JobId_t, source> &fragmentData,
45 std::map<JobId_t, dest> &MPQCData_fused)
46{
47 MPQCData_fused.clear();
48}
49
50template <>
51inline void convertDataTo<MPQCData, MPQCDataEnergyMap_t>(
52 const std::map<JobId_t, MPQCData> &fragmentData,
53 std::map<JobId_t, MPQCDataEnergyMap_t> &MPQCData_Energy_fused)
54{
55 // energy_t
56 MPQCData_Energy_fused.clear();
57 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
58 dataiter != fragmentData.end(); ++dataiter) {
59 const MPQCData &extractedData = dataiter->second;
60 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
61 MPQCDataEnergyMap_t instance;
62 boost::fusion::at_key<MPQCDataFused::energy_total>(instance) = extractedData.energies.total;
63 boost::fusion::at_key<MPQCDataFused::energy_nuclear_repulsion>(instance) = extractedData.energies.nuclear_repulsion;
64 boost::fusion::at_key<MPQCDataFused::energy_electron_coulomb>(instance) = extractedData.energies.electron_coulomb;
65 boost::fusion::at_key<MPQCDataFused::energy_electron_exchange>(instance) = extractedData.energies.electron_exchange;
66 boost::fusion::at_key<MPQCDataFused::energy_correlation>(instance) = extractedData.energies.correlation;
67 boost::fusion::at_key<MPQCDataFused::energy_overlap>(instance) = extractedData.energies.overlap;
68 boost::fusion::at_key<MPQCDataFused::energy_kinetic>(instance) = extractedData.energies.kinetic;
69 boost::fusion::at_key<MPQCDataFused::energy_hcore>(instance) = extractedData.energies.hcore;
70 boost::fusion::at_key<MPQCDataFused::energy_eigenvalues>(instance) = extractedData.energies.eigenvalues;
71 MPQCData_Energy_fused.insert( std::make_pair(dataiter->first, instance) );
72 }
73}
74
75#ifdef HAVE_VMG
76template <>
77inline void convertDataTo<VMGData, VMGDataMap_t>(
78 const std::map<JobId_t, VMGData> &longrangeData,
79 std::map<JobId_t, VMGDataMap_t> &VMGData_fused)
80{
81 // energy_t
82 VMGData_fused.clear();
83 for(std::map<JobId_t, VMGData>::const_iterator dataiter = longrangeData.begin();
84 dataiter != longrangeData.end(); ++dataiter) {
85 const VMGData &extractedData = dataiter->second;
86 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
87 VMGDataMap_t instance;
88 boost::fusion::at_key<VMGDataFused::sampled_potential>(instance) = extractedData.sampled_potential;
89 boost::fusion::at_key<VMGDataFused::energy_potential>(instance) = extractedData.sampled_potential.integral();
90 boost::fusion::at_key<VMGDataFused::energy_long>(instance) = extractedData.e_long;
91 VMGData_fused.insert( std::make_pair(dataiter->first, instance) );
92 }
93}
94#endif
95
96inline void convertMPQCDatatoForceMap(
97 const std::map<JobId_t, MPQCData> &fragmentData,
98 const KeySetsContainer &ForceKeySet,
99 std::map<JobId_t, MPQCDataForceMap_t> &MPQCData_Force_fused)
100{
101 // forces
102 ASSERT( ForceKeySet.KeySets.size() == fragmentData.size(),
103 "FragmentationAutomationAction::performCall() - indices and fragmentData differ in size.");
104 MPQCData_Force_fused.clear();
105 std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
106 KeySetsContainer::ArrayOfIntVectors::const_iterator arrayiter = ForceKeySet.KeySets.begin();
107 for(;dataiter != fragmentData.end(); ++dataiter, ++arrayiter) {
108 const MPQCData &extractedData = dataiter->second;
109 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
110 MPQCDataForceMap_t instance;
111 // must convert int to index_t
112 IndexedVectors::indices_t indices(arrayiter->begin(), arrayiter->end());
113 boost::fusion::at_key<MPQCDataFused::forces>(instance) =
114 IndexedVectors(indices, extractedData.forces);
115 MPQCData_Force_fused.insert( std::make_pair(dataiter->first, instance) );
116 }
117}
118
119template <>
120inline void convertDataTo<MPQCData, MPQCDataGridMap_t>(
121 const std::map<JobId_t, MPQCData> &fragmentData,
122 std::map<JobId_t, MPQCDataGridMap_t> &MPQCData_Grid_fused)
123{
124 // sampled_grid
125 MPQCData_Grid_fused.clear();
126 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
127 dataiter != fragmentData.end(); ++dataiter) {
128 const MPQCData &extractedData = dataiter->second;
129 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
130 MPQCDataGridMap_t instance;
131 boost::fusion::at_key<MPQCDataFused::sampled_grid>(instance) = extractedData.sampled_grid;
132 MPQCData_Grid_fused.insert( std::make_pair(dataiter->first, instance) );
133 }
134}
135
136template <>
137inline void convertDataTo<MPQCData, MPQCDataFragmentMap_t>(
138 const std::map<JobId_t, MPQCData> &fragmentData,
139 std::map<JobId_t, MPQCDataFragmentMap_t> &MPQCData_Fragment_fused)
140{
141 // fragment
142 MPQCData_Fragment_fused.clear();
143 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
144 dataiter != fragmentData.end(); ++dataiter) {
145 const MPQCData &extractedData = dataiter->second;
146 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
147 MPQCDataFragmentMap_t instance;
148 boost::fusion::at_key<MPQCDataFused::fragment>(instance) =
149 Fragment(extractedData.positions, extractedData.charges);
150 MPQCData_Fragment_fused.insert( std::make_pair(dataiter->first, instance) );
151 }
152}
153
154template <>
155inline void convertDataTo<MPQCData, MPQCDataTimeMap_t>(
156 const std::map<JobId_t, MPQCData> &fragmentData,
157 std::map<JobId_t, MPQCDataTimeMap_t> &MPQCData_Time_fused)
158{
159 // times
160 MPQCData_Time_fused.clear();
161 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
162 dataiter != fragmentData.end(); ++dataiter) {
163 const MPQCData &extractedData = dataiter->second;
164 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
165 MPQCDataTimeMap_t instance;
166 boost::fusion::at_key<MPQCDataFused::times_total_walltime>(instance) = extractedData.times.total_walltime;
167 boost::fusion::at_key<MPQCDataFused::times_total_cputime>(instance) = extractedData.times.total_cputime;
168 boost::fusion::at_key<MPQCDataFused::times_total_flops>(instance) = extractedData.times.total_flops;
169 boost::fusion::at_key<MPQCDataFused::times_gather_walltime>(instance) = extractedData.times.gather_walltime;
170 boost::fusion::at_key<MPQCDataFused::times_gather_cputime>(instance) = extractedData.times.gather_cputime;
171 boost::fusion::at_key<MPQCDataFused::times_gather_flops>(instance) = extractedData.times.gather_flops;
172 MPQCData_Time_fused.insert( std::make_pair(dataiter->first, instance) );
173 }
174}
175
176
177#endif /* DATACONVERTER_HPP_ */
Note: See TracBrowser for help on using the repository browser.