source: src/Fragmentation/Automation/ResultContainer_impl.hpp@ 2199c2

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 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 SaturateAtoms_findBestMatching 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
Last change on this file since 2199c2 was 7537d1, checked in by Frederik Heber <heber@…>, 9 years ago

Removing setting net force to zero and setting hasForce to true.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 * ResultContainer_impl.hpp
3 *
4 * Created on: Apr 22, 2014
5 * Author: heber
6 */
7
8#ifndef RESULTCONTAINER_IMPL_HPP_
9#define RESULTCONTAINER_IMPL_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include "Fragmentation/Automation/ResultContainer.hpp"
17
18#include "CodePatterns/Assert.hpp"
19#include "CodePatterns/Log.hpp"
20#include "CodePatterns/toString.hpp"
21
22template <typename T>
23void ResultContainer<T>::ConvertFragmentResultTo(
24 const std::vector<FragmentResult::ptr> &results,
25 std::vector<T> &fragmentData) const
26{
27 // extract results
28 fragmentData.clear();
29 fragmentData.reserve(results.size());
30
31 LOG(2, "DEBUG: Parsing now through " << results.size() << " results.");
32 for (std::vector<FragmentResult::ptr>::const_iterator iter = results.begin();
33 iter != results.end(); ++iter) {
34 //LOG(1, "RESULT: job #"+toString((*iter)->getId())+": "+toString((*iter)->result));
35 T extractedData;
36 std::stringstream inputstream((*iter)->result);
37 LOG(2, "DEBUG: First 50 characters FragmentResult's string: "+(*iter)->result.substr(0, 50));
38 boost::archive::text_iarchive ia(inputstream);
39 ia >> extractedData;
40 LOG(1, "INFO: extracted data of #" << (*iter)->getId() << " is " << extractedData << ".");
41 fragmentData.push_back(extractedData);
42 }
43
44 ASSERT( results.size() == fragmentData.size(),
45 "ResultContainer::ConvertFragmentResultTo() - the number of extracted data differs from the number of results.");
46}
47
48template <typename T>
49void ResultContainer<T>::insertResults(
50 const std::vector<FragmentResult::ptr> &fragmentresults,
51 std::vector<T> &fragmentData)
52{
53 std::vector<FragmentResult::ptr>::const_iterator resultiter = fragmentresults.begin();
54 typename std::vector<T>::const_iterator dataiter = fragmentData.begin();
55 for(;resultiter != fragmentresults.end(); ++resultiter, ++dataiter) {
56 const JobId_t _id = (*resultiter)->getId();
57 if ((*resultiter)->exitflag == 0) {
58#ifndef NDEBUG
59 std::pair<typename std::map<JobId_t, T>::iterator, bool> inserter =
60#endif
61 IdData.insert( std::make_pair( _id, *dataiter) );
62 ASSERT( inserter.second,
63 "ResultContainer::insertResults() - result id "
64 +toString(inserter.first->first)+" already present.");
65 }
66 }
67 ASSERT( dataiter == fragmentData.end(),
68 "ResultContainer::insertResults() - fragmentresults and fragmentdata differ in size.");
69}
70
71
72#endif /* RESULTCONTAINER_IMPL_HPP_ */
Note: See TracBrowser for help on using the repository browser.