source: src/Fragmentation/Summation/writeIndexedTable.hpp@ 8eafd6

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests 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_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 FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes 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 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 8eafd6 was c8d13f5, checked in by Frederik Heber <heber@…>, 11 years ago

Summed up results are now handed-over to FragmentationResultContainer by AnalyseFragmentationResultsAction.

  • we do not use fusion::maps here but write out real maps with IndexSet::ptr to MPQCData (but we fill in only energy_t.total so far).
  • TESTFIX: index was not written and tab/newline-hiccup in .._IndexedEnergy.dat
  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 * writeIndexedTable.hpp
3 *
4 * Created on: Sep 28, 2013
5 * Author: heber
6 */
7
8#ifndef WRITEINDEXEDTABLE_HPP_
9#define WRITEINDEXEDTABLE_HPP_
10
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17#include <boost/mpl/for_each.hpp>
18
19#include <string>
20#include <sstream>
21#include <vector>
22
23#include "Fragmentation/Summation/HeaderPrinter.hpp"
24#include "Fragmentation/Summation/ValuePrinter.hpp"
25
26/** Templated functor to write from a given vector of results the
27 * table per keyset with decent header line.
28 *
29 * @param results vector of results of MapType
30 * @param MaxLevel print values up till this level
31 * @return string of the resulting table
32 */
33template <typename MapType, typename VectorType, int numprecision=10>
34struct writeIndexedTable{
35 std::string operator()(
36 const std::map<IndexSet::ptr, std::pair<MapType,MapType> > &results,
37 const size_t MaxLevel,
38 const size_t StartLevel=1)
39 {
40 typedef std::map<IndexSet::ptr, std::pair<MapType,MapType> > maptype_t;
41 std::stringstream resultstream;
42
43 /// create header line for energy
44 resultstream << "index\tlevel\tkeyset";
45 {
46 HeaderPrinter header("_value");
47 boost::mpl::for_each<VectorType>(boost::ref(header));
48 resultstream << header.get();
49 }
50 {
51 HeaderPrinter header("_contribution");
52 boost::mpl::for_each<VectorType>(boost::ref(header));
53 resultstream << header.get();
54 }
55 resultstream << std::endl;
56
57 /// print values per line
58 if (MaxLevel >= StartLevel) {
59 ASSERT( results.size() >= (MaxLevel-StartLevel),
60 "writeIndexedTable<M,V>() - results has insufficient size.");
61 size_t index = 0;
62 for (typename maptype_t::const_iterator resultiter = results.begin();
63 resultiter != results.end(); ++resultiter, ++index) {
64 resultstream << index << "\t" << resultiter->first->size() << "\t" << "{";
65 for (IndexSet::const_iterator keyiter = resultiter->first->begin();
66 keyiter != resultiter->first->end(); ++keyiter)
67 resultstream << ( keyiter != resultiter->first->begin() ? "," : "") << *keyiter;
68 resultstream << "}";
69 {
70 ValuePrinter<MapType, numprecision> values(resultiter->second.first);
71 boost::mpl::for_each<VectorType>(boost::ref(values));
72 resultstream << values.get();
73 }
74 {
75 ValuePrinter<MapType, numprecision> values(resultiter->second.second);
76 boost::mpl::for_each<VectorType>(boost::ref(values));
77 resultstream << values.get();
78 }
79 resultstream << std::endl;
80 }
81 } else {
82 ELOG(2, "writeIndexedTable does not output as MaxLevel(" << MaxLevel
83 << ") < StartLevel(" << StartLevel << ".");
84 }
85 return resultstream.str();
86 }
87};
88
89
90#endif /* WRITEINDEXEDTABLE_HPP_ */
Note: See TracBrowser for help on using the repository browser.