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

Candidate_v1.6.1
Last change on this file was 6829d2, checked in by Frederik Heber <heber@…>, 8 years ago

MPQCData additionally stores the atomic number per nuclei.

  • in case of DoSampleValenceOnly the charge does not represent the atomic number and moreover it is no longer unique. However, we need this unique association for fitting potentials to the fragment results.
  • TESTFIX: set all tests to XFAIL that parse either fragmentation results or homologies.
  • TESTFIX: needed to adapt HomologyContainerUnitTest which uses FragmentStub.
  • TESTFIX: needed to adapt FragmentUnitTest.
  • Property mode set to 100644
File size: 8.6 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/Eigenvalues.hpp"
30#include "Fragmentation/Summation/SetValues/Histogram.hpp"
31#include "Fragmentation/Summation/SetValues/Fragment.hpp"
32#include "Fragmentation/Summation/SetValues/IndexedVectors.hpp"
33
34#include "Fragmentation/Summation/Containers/MPQCData.hpp"
35#include "Fragmentation/Summation/Containers/MPQCDataFused.hpp"
36#include "Fragmentation/Summation/Containers/MPQCDataMap.hpp"
37#ifdef HAVE_VMG
38#include "Fragmentation/Summation/Containers/VMGData.hpp"
39#include "Fragmentation/Summation/Containers/VMGDataFused.hpp"
40#include "Fragmentation/Summation/Containers/VMGDataMap.hpp"
41#endif
42
43template <typename source, typename dest>
44inline void convertDataTo(
45 const std::map<JobId_t, source> &fragmentData,
46 std::map<JobId_t, dest> &MPQCData_fused)
47{
48 MPQCData_fused.clear();
49}
50
51template <>
52inline void convertDataTo<MPQCData, MPQCDataEnergyMap_t>(
53 const std::map<JobId_t, MPQCData> &fragmentData,
54 std::map<JobId_t, MPQCDataEnergyMap_t> &MPQCData_Energy_fused)
55{
56 // energy_t
57 MPQCData_Energy_fused.clear();
58 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
59 dataiter != fragmentData.end(); ++dataiter) {
60 const MPQCData &extractedData = dataiter->second;
61 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
62 MPQCDataEnergyMap_t instance;
63 boost::fusion::at_key<MPQCDataFused::energy_total>(instance) = extractedData.energies.total;
64 boost::fusion::at_key<MPQCDataFused::energy_nuclear_repulsion>(instance) = extractedData.energies.nuclear_repulsion;
65 boost::fusion::at_key<MPQCDataFused::energy_electron_coulomb>(instance) = extractedData.energies.electron_coulomb;
66 boost::fusion::at_key<MPQCDataFused::energy_electron_exchange>(instance) = extractedData.energies.electron_exchange;
67 boost::fusion::at_key<MPQCDataFused::energy_correlation>(instance) = extractedData.energies.correlation;
68 boost::fusion::at_key<MPQCDataFused::energy_overlap>(instance) = extractedData.energies.overlap;
69 boost::fusion::at_key<MPQCDataFused::energy_kinetic>(instance) = extractedData.energies.kinetic;
70 boost::fusion::at_key<MPQCDataFused::energy_hcore>(instance) = extractedData.energies.hcore;
71 boost::fusion::at_key<MPQCDataFused::energy_eigenvalues>(instance) = extractedData.energies.eigenvalues;
72 boost::fusion::at_key<MPQCDataFused::energy_eigenhistogram>(instance) = extractedData.energies.eigenvalues;
73 MPQCData_Energy_fused.insert( std::make_pair(dataiter->first, instance) );
74 }
75}
76
77#ifdef HAVE_VMG
78template <>
79inline void convertDataTo<VMGData, VMGDataMap_t>(
80 const std::map<JobId_t, VMGData> &longrangeData,
81 std::map<JobId_t, VMGDataMap_t> &VMGData_fused)
82{
83 // energy_t
84 VMGData_fused.clear();
85 for(std::map<JobId_t, VMGData>::const_iterator dataiter = longrangeData.begin();
86 dataiter != longrangeData.end(); ++dataiter) {
87 const VMGData &extractedData = dataiter->second;
88 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
89 VMGDataMap_t instance;
90 boost::fusion::at_key<VMGDataFused::nuclei_long>(instance) = extractedData.nuclei_long;
91 boost::fusion::at_key<VMGDataFused::electron_long>(instance) = extractedData.electron_long;
92 VMGData_fused.insert( std::make_pair(dataiter->first, instance) );
93 }
94}
95
96template <>
97inline void convertDataTo<VMGData, VMGDataGridMap_t>(
98 const std::map<JobId_t, VMGData> &longrangeData,
99 std::map<JobId_t, VMGDataGridMap_t> &VMGData_fused)
100{
101 // energy_t
102 VMGData_fused.clear();
103 for(std::map<JobId_t, VMGData>::const_iterator dataiter = longrangeData.begin();
104 dataiter != longrangeData.end(); ++dataiter) {
105 const VMGData &extractedData = dataiter->second;
106 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
107 VMGDataGridMap_t instance;
108 boost::fusion::at_key<VMGDataFused::sampled_potential>(instance) = extractedData.sampled_potential;
109 boost::fusion::at_key<VMGDataFused::both_sampled_potential>(instance) = extractedData.both_sampled_potential;
110 VMGData_fused.insert( std::make_pair(dataiter->first, instance) );
111 }
112}
113#endif
114
115template <class datatype, class dataforcemap, class dataforcefused>
116inline void convertDatatoForceMap(
117 const std::map<JobId_t, datatype> &fragmentData,
118 const KeySetsContainer &ForceKeySet,
119 std::map<JobId_t, dataforcemap> &Data_Force_fused)
120{
121 // forces
122 ASSERT( ForceKeySet.KeySets.size() == fragmentData.size(),
123 "FragmentationAutomationAction::performCall() - indices and fragmentData differ in size.");
124 Data_Force_fused.clear();
125 typename std::map<JobId_t, datatype>::const_iterator dataiter = fragmentData.begin();
126 KeySetsContainer::ArrayOfIntVectors::const_iterator arrayiter = ForceKeySet.KeySets.begin();
127 for(;dataiter != fragmentData.end(); ++dataiter, ++arrayiter) {
128 const datatype &extractedData = dataiter->second;
129 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
130 dataforcemap instance;
131 // must convert int to index_t
132 if (DoLog(5)) {
133 std::stringstream output;
134 for (KeySetsContainer::IntVector::const_iterator outiter = arrayiter->begin();
135 outiter != arrayiter->end(); ++outiter) {
136 output << *outiter << "\t";
137 }
138 LOG(5, "DEBUG: indices are " << output.str());
139 }
140 IndexedVectors::indices_t indices(arrayiter->begin(), arrayiter->end());
141 boost::fusion::at_key<typename dataforcefused::forces>(instance) =
142 IndexedVectors(indices, extractedData.forces);
143 Data_Force_fused.insert( std::make_pair(dataiter->first, instance) );
144 }
145}
146
147template <>
148inline void convertDataTo<MPQCData, MPQCDataGridMap_t>(
149 const std::map<JobId_t, MPQCData> &fragmentData,
150 std::map<JobId_t, MPQCDataGridMap_t> &MPQCData_Grid_fused)
151{
152 // sampled_grid
153 MPQCData_Grid_fused.clear();
154 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
155 dataiter != fragmentData.end(); ++dataiter) {
156 const MPQCData &extractedData = dataiter->second;
157 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
158 MPQCDataGridMap_t instance;
159 boost::fusion::at_key<MPQCDataFused::sampled_grid>(instance) = extractedData.sampled_grid;
160 MPQCData_Grid_fused.insert( std::make_pair(dataiter->first, instance) );
161 }
162}
163
164template <>
165inline void convertDataTo<MPQCData, MPQCDataFragmentMap_t>(
166 const std::map<JobId_t, MPQCData> &fragmentData,
167 std::map<JobId_t, MPQCDataFragmentMap_t> &MPQCData_Fragment_fused)
168{
169 // fragment
170 MPQCData_Fragment_fused.clear();
171 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
172 dataiter != fragmentData.end(); ++dataiter) {
173 const MPQCData &extractedData = dataiter->second;
174 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
175 MPQCDataFragmentMap_t instance;
176 boost::fusion::at_key<MPQCDataFused::fragment>(instance) =
177 Fragment(extractedData.positions, extractedData.atomicnumbers, extractedData.charges);
178 MPQCData_Fragment_fused.insert( std::make_pair(dataiter->first, instance) );
179 }
180}
181
182template <>
183inline void convertDataTo<MPQCData, MPQCDataTimeMap_t>(
184 const std::map<JobId_t, MPQCData> &fragmentData,
185 std::map<JobId_t, MPQCDataTimeMap_t> &MPQCData_Time_fused)
186{
187 // times
188 MPQCData_Time_fused.clear();
189 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
190 dataiter != fragmentData.end(); ++dataiter) {
191 const MPQCData &extractedData = dataiter->second;
192 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
193 MPQCDataTimeMap_t instance;
194 boost::fusion::at_key<MPQCDataFused::times_total_walltime>(instance) = extractedData.times.total_walltime;
195 boost::fusion::at_key<MPQCDataFused::times_total_cputime>(instance) = extractedData.times.total_cputime;
196 boost::fusion::at_key<MPQCDataFused::times_total_flops>(instance) = extractedData.times.total_flops;
197 boost::fusion::at_key<MPQCDataFused::times_gather_walltime>(instance) = extractedData.times.gather_walltime;
198 boost::fusion::at_key<MPQCDataFused::times_gather_cputime>(instance) = extractedData.times.gather_cputime;
199 boost::fusion::at_key<MPQCDataFused::times_gather_flops>(instance) = extractedData.times.gather_flops;
200 MPQCData_Time_fused.insert( std::make_pair(dataiter->first, instance) );
201 }
202}
203
204
205#endif /* DATACONVERTER_HPP_ */
Note: See TracBrowser for help on using the repository browser.