/* * DataConverter.hpp * * Created on: Aug 27, 2012 * Author: heber */ #ifndef DATACONVERTER_HPP_ #define DATACONVERTER_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include "CodePatterns/Assert.hpp" #ifdef HAVE_JOBMARKET #include "JobMarket/types.hpp" #else typedef size_t JobId_t; #endif #include "Fragmentation/KeySetsContainer.hpp" #include "Fragmentation/Summation/SetValues/Histogram.hpp" #include "Fragmentation/Summation/SetValues/Fragment.hpp" #include "Fragmentation/Summation/SetValues/IndexedVectors.hpp" #include "Fragmentation/Summation/Containers/MPQCData.hpp" #include "Fragmentation/Summation/Containers/MPQCDataFused.hpp" #include "Fragmentation/Summation/Containers/MPQCDataMap.hpp" #ifdef HAVE_VMG #include "Fragmentation/Summation/Containers/VMGData.hpp" #include "Fragmentation/Summation/Containers/VMGDataFused.hpp" #include "Fragmentation/Summation/Containers/VMGDataMap.hpp" #endif template inline void convertDataTo( const std::map &fragmentData, std::map &MPQCData_fused) { MPQCData_fused.clear(); } template <> inline void convertDataTo( const std::map &fragmentData, std::map &MPQCData_Energy_fused) { // energy_t MPQCData_Energy_fused.clear(); for(std::map::const_iterator dataiter = fragmentData.begin(); dataiter != fragmentData.end(); ++dataiter) { const MPQCData &extractedData = dataiter->second; LOG(4, "DEBUG: Current extracted Data is " << extractedData << "."); MPQCDataEnergyMap_t instance; boost::fusion::at_key(instance) = extractedData.energies.total; boost::fusion::at_key(instance) = extractedData.energies.nuclear_repulsion; boost::fusion::at_key(instance) = extractedData.energies.electron_coulomb; boost::fusion::at_key(instance) = extractedData.energies.electron_exchange; boost::fusion::at_key(instance) = extractedData.energies.correlation; boost::fusion::at_key(instance) = extractedData.energies.overlap; boost::fusion::at_key(instance) = extractedData.energies.kinetic; boost::fusion::at_key(instance) = extractedData.energies.hcore; boost::fusion::at_key(instance) = extractedData.energies.eigenvalues; MPQCData_Energy_fused.insert( std::make_pair(dataiter->first, instance) ); } } #ifdef HAVE_VMG template <> inline void convertDataTo( const std::map &longrangeData, std::map &VMGData_fused) { // energy_t VMGData_fused.clear(); for(std::map::const_iterator dataiter = longrangeData.begin(); dataiter != longrangeData.end(); ++dataiter) { const VMGData &extractedData = dataiter->second; LOG(4, "DEBUG: Current extracted Data is " << extractedData << "."); VMGDataMap_t instance; boost::fusion::at_key(instance) = extractedData.sampled_potential; boost::fusion::at_key(instance) = extractedData.sampled_potential.integral(); boost::fusion::at_key(instance) = extractedData.e_long; VMGData_fused.insert( std::make_pair(dataiter->first, instance) ); } } #endif inline void convertMPQCDatatoForceMap( const std::map &fragmentData, const KeySetsContainer &ForceKeySet, std::map &MPQCData_Force_fused) { // forces ASSERT( ForceKeySet.KeySets.size() == fragmentData.size(), "FragmentationAutomationAction::performCall() - indices and fragmentData differ in size."); MPQCData_Force_fused.clear(); std::map::const_iterator dataiter = fragmentData.begin(); KeySetsContainer::ArrayOfIntVectors::const_iterator arrayiter = ForceKeySet.KeySets.begin(); for(;dataiter != fragmentData.end(); ++dataiter, ++arrayiter) { const MPQCData &extractedData = dataiter->second; LOG(4, "DEBUG: Current extracted Data is " << extractedData << "."); MPQCDataForceMap_t instance; // must convert int to index_t IndexedVectors::indices_t indices(arrayiter->begin(), arrayiter->end()); boost::fusion::at_key(instance) = IndexedVectors(indices, extractedData.forces); MPQCData_Force_fused.insert( std::make_pair(dataiter->first, instance) ); } } template <> inline void convertDataTo( const std::map &fragmentData, std::map &MPQCData_Grid_fused) { // sampled_grid MPQCData_Grid_fused.clear(); for(std::map::const_iterator dataiter = fragmentData.begin(); dataiter != fragmentData.end(); ++dataiter) { const MPQCData &extractedData = dataiter->second; LOG(4, "DEBUG: Current extracted Data is " << extractedData << "."); MPQCDataGridMap_t instance; boost::fusion::at_key(instance) = extractedData.sampled_grid; MPQCData_Grid_fused.insert( std::make_pair(dataiter->first, instance) ); } } template <> inline void convertDataTo( const std::map &fragmentData, std::map &MPQCData_Fragment_fused) { // fragment MPQCData_Fragment_fused.clear(); for(std::map::const_iterator dataiter = fragmentData.begin(); dataiter != fragmentData.end(); ++dataiter) { const MPQCData &extractedData = dataiter->second; LOG(4, "DEBUG: Current extracted Data is " << extractedData << "."); MPQCDataFragmentMap_t instance; boost::fusion::at_key(instance) = Fragment(extractedData.positions, extractedData.charges); MPQCData_Fragment_fused.insert( std::make_pair(dataiter->first, instance) ); } } template <> inline void convertDataTo( const std::map &fragmentData, std::map &MPQCData_Time_fused) { // times MPQCData_Time_fused.clear(); for(std::map::const_iterator dataiter = fragmentData.begin(); dataiter != fragmentData.end(); ++dataiter) { const MPQCData &extractedData = dataiter->second; LOG(4, "DEBUG: Current extracted Data is " << extractedData << "."); MPQCDataTimeMap_t instance; boost::fusion::at_key(instance) = extractedData.times.total_walltime; boost::fusion::at_key(instance) = extractedData.times.total_cputime; boost::fusion::at_key(instance) = extractedData.times.total_flops; boost::fusion::at_key(instance) = extractedData.times.gather_walltime; boost::fusion::at_key(instance) = extractedData.times.gather_cputime; boost::fusion::at_key(instance) = extractedData.times.gather_flops; MPQCData_Time_fused.insert( std::make_pair(dataiter->first, instance) ); } } #endif /* DATACONVERTER_HPP_ */