Ignore:
Timestamp:
Feb 3, 2011, 9:51:19 AM (14 years ago)
Author:
Frederik Heber <heber@…>
Branches:
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
Children:
b25fa3
Parents:
cd7a87
git-author:
Frederik Heber <heber@…> (12/30/10 11:10:50)
git-committer:
Frederik Heber <heber@…> (02/03/11 09:51:19)
Message:

Refactored Output..Correlation...() code into a single templated one.

  • template function OutputCorrelationMap() that accepts two function pointers for header and value to print the map's specifics.
  • all other function have been refactored into these two output functions per CorrelationMap type.

TESTFIXES:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/analysis_correlation.cpp

    rcd7a87 r92e5cb  
    108108  outmap = new DipoleAngularCorrelationMap;
    109109  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin();
    110       MolWalker != molecules.end();) {
     110      MolWalker != molecules.end(); ++MolWalker) {
    111111    DoLog(2) && (Log()<< Verbose(2) << "Current molecule is "
    112112        << (*MolWalker)->getId() << "." << endl);
    113113    const Vector Dipole = getDipole((*MolWalker)->begin(), (*MolWalker)->end());
    114     for (std::vector<molecule *>::const_iterator MolOtherWalker = ++MolWalker;
     114    std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker;
     115    for (++MolOtherWalker;
    115116        MolOtherWalker != molecules.end();
    116         MolOtherWalker++) {
     117        ++MolOtherWalker) {
    117118      DoLog(2) && (Log() << Verbose(2) << "Current other molecule is "
    118119          << (*MolOtherWalker)->getId() << "." << endl);
     
    469470int GetBin ( const double value, const double BinWidth, const double BinStart )
    470471{
    471   Info FunctionInfo(__func__);
     472  //Info FunctionInfo(__func__);
    472473  int bin =(int) (floor((value - BinStart)/BinWidth));
    473474  return (bin);
     
    475476
    476477
    477 /** Prints correlation (double, int) pairs to file.
    478  * \param *file file to write to
    479  * \param *map map to write
    480  */
    481 void OutputCorrelation( ofstream * const file, const BinPairMap * const map )
    482 {
    483   Info FunctionInfo(__func__);
    484   *file << "BinStart\tCount" << endl;
    485   for (BinPairMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
    486     *file << setprecision(8) << runner->first << "\t" << runner->second << endl;
    487   }
    488 };
    489 
    490 /** Prints correlation (double, (atom*,atom*) ) pairs to file.
    491  * \param *file file to write to
    492  * \param *map map to write
    493  */
    494 void OutputDipoleAngularCorrelation( ofstream * const file, const DipoleAngularCorrelationMap * const map )
    495 {
    496   Info FunctionInfo(__func__);
    497   *file << "BinStart\tMolecule1\tMolecule2" << endl;
    498   for (DipoleAngularCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
    499     *file << setprecision(8) << runner->first << "\t" << runner->second.first->getId() << "\t" << runner->second.second->getId() << endl;
    500   }
    501 };
    502 
    503 /** Prints correlation (double, (atom*,atom*) ) pairs to file.
    504  * \param *file file to write to
    505  * \param *map map to write
    506  */
    507 void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map )
    508 {
    509   Info FunctionInfo(__func__);
    510   *file << "BinStart\tAtom1\tAtom2" << endl;
    511   for (PairCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
    512     *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
    513   }
    514 };
    515 
    516 /** Prints correlation (double, int) pairs to file.
    517  * \param *file file to write to
    518  * \param *map map to write
    519  */
    520 void OutputCorrelationToPoint( ofstream * const file, const CorrelationToPointMap * const map )
    521 {
    522   Info FunctionInfo(__func__);
    523   *file << "BinStart\tAtom::x[i]-point.x[i]" << endl;
    524   for (CorrelationToPointMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
    525     *file << runner->first;
    526     for (int i=0;i<NDIM;i++)
    527       *file << "\t" << setprecision(8) << (runner->second.first->at(i) - runner->second.second->at(i));
    528     *file << endl;
    529   }
    530 };
    531 
    532 /** Prints correlation (double, int) pairs to file.
    533  * \param *file file to write to
    534  * \param *map map to write
    535  */
    536 void OutputCorrelationToSurface( ofstream * const file, const CorrelationToSurfaceMap * const map )
    537 {
    538   Info FunctionInfo(__func__);
    539   *file << "BinStart\tTriangle" << endl;
    540   if (!map->empty())
    541     for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
    542       *file << setprecision(8) << runner->first << "\t";
    543       *file << *(runner->second.first) << "\t";
    544       *file << *(runner->second.second) << endl;
    545     }
    546 };
    547 
     478/** Adds header part that is unique to BinPairMap.
     479 *
     480 * @param file stream to print to
     481 */
     482void OutputCorrelation_Header( ofstream * const file )
     483{
     484  *file << "\tCount";
     485};
     486
     487/** Prints values stored in BinPairMap iterator.
     488 *
     489 * @param file stream to print to
     490 * @param runner iterator pointing at values to print
     491 */
     492void OutputCorrelation_Value( ofstream * const file, BinPairMap::const_iterator &runner )
     493{
     494  *file << runner->second;
     495};
     496
     497
     498/** Adds header part that is unique to DipoleAngularCorrelationMap.
     499 *
     500 * @param file stream to print to
     501 */
     502void OutputDipoleAngularCorrelation_Header( ofstream * const file )
     503{
     504  *file << "\tAtom1\tAtom2";
     505};
     506
     507/** Prints values stored in DipoleAngularCorrelationMap iterator.
     508 *
     509 * @param file stream to print to
     510 * @param runner iterator pointing at values to print
     511 */
     512void OutputDipoleAngularCorrelation_Value( ofstream * const file, DipoleAngularCorrelationMap::const_iterator &runner )
     513{
     514  *file << runner->second.first->getId() << "\t" << runner->second.second->getId();
     515};
     516
     517
     518/** Adds header part that is unique to PairCorrelationMap.
     519 *
     520 * @param file stream to print to
     521 */
     522void OutputPairCorrelation_Header( ofstream * const file )
     523{
     524  *file << "\tAtom1\tAtom2";
     525};
     526
     527/** Prints values stored in PairCorrelationMap iterator.
     528 *
     529 * @param file stream to print to
     530 * @param runner iterator pointing at values to print
     531 */
     532void OutputPairCorrelation_Value( ofstream * const file, PairCorrelationMap::const_iterator &runner )
     533{
     534  *file << *(runner->second.first) << "\t" << *(runner->second.second);
     535};
     536
     537
     538/** Adds header part that is unique to CorrelationToPointMap.
     539 *
     540 * @param file stream to print to
     541 */
     542void OutputCorrelationToPoint_Header( ofstream * const file )
     543{
     544  *file << "\tAtom::x[i]-point.x[i]";
     545};
     546
     547/** Prints values stored in CorrelationToPointMap iterator.
     548 *
     549 * @param file stream to print to
     550 * @param runner iterator pointing at values to print
     551 */
     552void OutputCorrelationToPoint_Value( ofstream * const file, CorrelationToPointMap::const_iterator &runner )
     553{
     554  for (int i=0;i<NDIM;i++)
     555    *file << "\t" << setprecision(8) << (runner->second.first->at(i) - runner->second.second->at(i));
     556};
     557
     558
     559/** Adds header part that is unique to CorrelationToSurfaceMap.
     560 *
     561 * @param file stream to print to
     562 */
     563void OutputCorrelationToSurface_Header( ofstream * const file )
     564{
     565  *file << "\tTriangle";
     566};
     567
     568/** Prints values stored in CorrelationToSurfaceMap iterator.
     569 *
     570 * @param file stream to print to
     571 * @param runner iterator pointing at values to print
     572 */
     573void OutputCorrelationToSurface_Value( ofstream * const file, CorrelationToSurfaceMap::const_iterator &runner )
     574{
     575  *file << *(runner->second.first) << "\t" << *(runner->second.second);
     576};
Note: See TracChangeset for help on using the changeset viewer.