Changeset 99db9b for src/Analysis


Ignore:
Timestamp:
Jul 24, 2015, 4:44:35 PM (10 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:
fac58f
Parents:
a58c16
git-author:
Frederik Heber <heber@…> (06/02/15 08:32:10)
git-committer:
Frederik Heber <heber@…> (07/24/15 16:44:35)
Message:

Replaced all World::getSelected...() to const version where possible.

  • also added const version of World::getSelectedAtoms().
Location:
src/Analysis
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Analysis/analysis_correlation.cpp

    ra58c16 r99db9b  
    125125 * \return range with [min, max]
    126126 */
    127 range<size_t> getMaximumTrajectoryBounds(const std::vector<atom *> &atoms)
     127range<size_t> getMaximumTrajectoryBounds(const std::vector<const atom *> &atoms)
    128128{
    129129  // get highest trajectory size
     
    133133  size_t max_timesteps = std::numeric_limits<size_t>::min();
    134134  size_t min_timesteps = std::numeric_limits<size_t>::max();
    135   BOOST_FOREACH(atom *_atom, atoms) {
     135  BOOST_FOREACH(const atom *_atom, atoms) {
    136136    if (_atom->getTrajectorySize() > max_timesteps)
    137137      max_timesteps  = _atom->getTrajectorySize();
     
    149149 * \return map with orientation vector for each atomic id given in \a atoms.
    150150 */
    151 std::map<atomId_t, Vector> CalculateZeroAngularDipole(const std::vector<molecule *> &molecules)
     151std::map<atomId_t, Vector> CalculateZeroAngularDipole(const std::vector<const molecule *> &molecules)
    152152{
    153153  // get zero orientation for each molecule.
    154154  LOG(0,"STATUS: Calculating dipoles for current time step ...");
    155155  std::map<atomId_t, Vector> ZeroVector;
    156   BOOST_FOREACH(molecule *_mol, molecules) {
    157     const Vector Dipole =
    158         getDipole(
    159             const_cast<const molecule *>(_mol)->begin(),
    160             const_cast<const molecule *>(_mol)->end());
    161     for(molecule::const_iterator iter = const_cast<const molecule *>(_mol)->begin();
    162         iter != const_cast<const molecule *>(_mol)->end();
    163         ++iter)
     156  BOOST_FOREACH(const molecule *_mol, molecules) {
     157    const Vector Dipole = getDipole(_mol->begin(),_mol->end());
     158    for(molecule::const_iterator iter = _mol->begin(); iter != _mol->end(); ++iter)
    164159      ZeroVector[(*iter)->getId()] = Dipole;
    165160    LOG(2,"INFO: Zero alignment for molecule " << _mol->getId() << " is " << Dipole);
     
    205200  World::getInstance().clearMoleculeSelection();
    206201  World::getInstance().selectAllMolecules(MoleculeByFormula(DipoleFormula));
    207   std::vector<molecule *> molecules = World::getInstance().getSelectedMolecules();
     202  std::vector<const molecule *> molecules =
     203      const_cast<const World &>(World::getInstance()).getSelectedMolecules();
    208204  LOG(1,"INFO: There are " << molecules.size() << " molecules for time step " << timestep << ".");
    209205
     
    212208  size_t i=0;
    213209  size_t Counter_rejections = 0;
    214   BOOST_FOREACH(molecule *_mol, molecules) {
    215     const Vector Dipole =
    216         getDipole(
    217             const_cast<const molecule *>(_mol)->begin(),
    218             const_cast<const molecule *>(_mol)->end());
     210  BOOST_FOREACH(const molecule *_mol, molecules) {
     211    const Vector Dipole = getDipole(_mol->begin(),_mol->end());
    219212    LOG(3,"INFO: Dipole vector at time step " << timestep << " for for molecule "
    220213        << _mol->getId() << " is " << Dipole);
    221214    // check that all atoms are valid (zeroVector known)
    222     molecule::const_iterator iter = const_cast<const molecule *>(_mol)->begin();
    223     for(; iter != const_cast<const molecule *>(_mol)->end(); ++iter) {
     215    molecule::const_iterator iter = _mol->begin();
     216    for(; iter != _mol->end(); ++iter) {
    224217      if (!ZeroVector.count((*iter)->getId()))
    225218        break;
    226219    }
    227     if (iter != const_cast<const molecule *>(_mol)->end()) {
     220    if (iter != _mol->end()) {
    228221      ELOG(2, "Skipping molecule " << _mol->getName() << " as not all atoms have a valid zeroVector.");
    229222      ++Counter_rejections;
    230223      continue;
    231224    } else
    232       iter = const_cast<const molecule *>(_mol)->begin();
     225      iter = _mol->begin();
    233226    std::map<atomId_t, Vector>::const_iterator zeroValue = ZeroVector.find((*iter)->getId()); //due to iter is const
    234227    double angle = 0.;
     
    274267 * \return Map of doubles with values the pair of the two atoms.
    275268 */
    276 DipoleCorrelationMap *DipoleCorrelation(std::vector<molecule *> &molecules)
     269DipoleCorrelationMap *DipoleCorrelation(
     270    const std::vector<const molecule *> &molecules)
    277271{
    278272  Info FunctionInfo(__func__);
     
    286280  }
    287281
    288   for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin();
     282  for (std::vector<const molecule *>::const_iterator MolWalker = molecules.begin();
    289283      MolWalker != molecules.end(); ++MolWalker) {
    290284    LOG(2, "INFO: Current molecule is " << (*MolWalker)->getId() << ".");
    291     const Vector Dipole =
    292         getDipole(
    293             const_cast<const molecule *>(*MolWalker)->begin(),
    294             const_cast<const molecule *>(*MolWalker)->end());
    295     std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker;
    296     for (++MolOtherWalker;
    297         MolOtherWalker != molecules.end();
     285    const Vector Dipole = getDipole((*MolWalker)->begin(), (*MolWalker)->end());
     286    std::vector<const molecule *>::const_iterator MolOtherWalker = MolWalker;
     287    for (++MolOtherWalker; MolOtherWalker != molecules.end();
    298288        ++MolOtherWalker) {
    299289      LOG(2, "INFO: Current other molecule is " << (*MolOtherWalker)->getId() << ".");
    300       const Vector OtherDipole = getDipole(
    301           const_cast<const molecule *>(*MolOtherWalker)->begin(),
    302           const_cast<const molecule *>(*MolOtherWalker)->end());
     290      const Vector OtherDipole = getDipole((*MolOtherWalker)->begin(), (*MolOtherWalker)->end());
    303291      const double angle = Dipole.Angle(OtherDipole) * (180./M_PI);
    304292      LOG(1, "Angle is " << angle << ".");
     
    409397 * \return Map of dobules with values as pairs of atom and the vector
    410398 */
    411 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point )
     399CorrelationToPointMap *CorrelationToPoint(
     400    const std::vector<const molecule *> &molecules,
     401    const std::vector<const element *> &elements,
     402    const Vector *point )
    412403{
    413404  Info FunctionInfo(__func__);
     
    421412  }
    422413
    423   for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
     414  for (std::vector<const molecule *>::const_iterator MolWalker = molecules.begin();
     415      MolWalker != molecules.end();
     416      MolWalker++) {
    424417    LOG(2, "Current molecule is " << *MolWalker << ".");
    425     for (molecule::const_iterator iter = const_cast<const molecule *>(*MolWalker)->begin();
    426         iter != const_cast<const molecule *>(*MolWalker)->end();
    427         ++iter) {
     418    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    428419      LOG(3, "Current atom is " << **iter << ".");
    429420      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     
    453444 * \return Map of dobules with values as pairs of atom and the vector
    454445 */
    455 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] )
     446CorrelationToPointMap *PeriodicCorrelationToPoint(
     447    const std::vector<const molecule *> &molecules,
     448    const std::vector<const element *> &elements,
     449    const Vector *point,
     450    const int ranges[NDIM] )
    456451{
    457452  Info FunctionInfo(__func__);
     
    467462  }
    468463
    469   for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
     464  for (std::vector<const molecule *>::const_iterator MolWalker = molecules.begin();
     465      MolWalker != molecules.end();
     466      MolWalker++) {
    470467    RealSpaceMatrix FullMatrix = World::getInstance().getDomain().getM();
    471468    RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
    472469    LOG(2, "Current molecule is " << *MolWalker << ".");
    473     for (molecule::const_iterator iter = const_cast<const molecule *>(*MolWalker)->begin();
    474         iter != const_cast<const molecule *>(*MolWalker)->end();
    475         ++iter) {
     470    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    476471      LOG(3, "Current atom is " << **iter << ".");
    477472      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     
    509504 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    510505 */
    511 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell_deprecated *LC )
     506CorrelationToSurfaceMap *CorrelationToSurface(
     507    const std::vector<const molecule *> &molecules,
     508    const std::vector<const element *> &elements,
     509    const Tesselation * const Surface,
     510    const LinkedCell_deprecated *LC )
    512511{
    513512  Info FunctionInfo(__func__);
     
    522521  }
    523522
    524   for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
     523  for (std::vector<const molecule *>::const_iterator MolWalker = molecules.begin();
     524      MolWalker != molecules.end();
     525      MolWalker++) {
    525526    LOG(2, "Current molecule is " << (*MolWalker)->name << ".");
    526527    if ((*MolWalker)->empty())
    527528      LOG(2, "\t is empty.");
    528     for (molecule::const_iterator iter = const_cast<const molecule *>(*MolWalker)->begin();
    529         iter != const_cast<const molecule *>(*MolWalker)->end();
    530         ++iter) {
     529    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    531530      LOG(3, "\tCurrent atom is " << *(*iter) << ".");
    532531      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     
    563562 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    564563 */
    565 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell_deprecated *LC, const int ranges[NDIM] )
     564CorrelationToSurfaceMap *PeriodicCorrelationToSurface(
     565    const std::vector<const molecule *> &molecules,
     566    const std::vector<const element *> &elements,
     567    const Tesselation * const Surface,
     568    const LinkedCell_deprecated *LC,
     569    const int ranges[NDIM] )
    566570{
    567571  Info FunctionInfo(__func__);
     
    581585  double ShortestDistance = 0.;
    582586  BoundaryTriangleSet *ShortestTriangle = NULL;
    583   for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
     587  for (std::vector<const molecule *>::const_iterator MolWalker = molecules.begin();
     588      MolWalker != molecules.end();
     589      MolWalker++) {
    584590    RealSpaceMatrix FullMatrix = World::getInstance().getDomain().getM();
    585591    RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
    586592    LOG(2, "Current molecule is " << *MolWalker << ".");
    587     for (molecule::const_iterator iter = const_cast<const molecule *>(*MolWalker)->begin();
    588         iter != const_cast<const molecule *>(*MolWalker)->end();
    589         ++iter) {
     593    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    590594      LOG(3, "Current atom is " << **iter << ".");
    591595      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
  • src/Analysis/analysis_correlation.hpp

    ra58c16 r99db9b  
    6161/********************************************** declarations *******************************/
    6262
    63 range<size_t> getMaximumTrajectoryBounds(const std::vector<atom *> &atoms);
    64 std::map<atomId_t, Vector> CalculateZeroAngularDipole(const std::vector<molecule *> &molecules);
    65 
    66 DipoleAngularCorrelationMap *DipoleAngularCorrelation(const Formula &DipoleFormula, const size_t timestep, const std::map<atomId_t, Vector> &ZeroVector, const enum ResetWorldTime DoTimeReset = DontResetTime);
    67 DipoleCorrelationMap *DipoleCorrelation(std::vector<molecule *> &molecules);
     63range<size_t> getMaximumTrajectoryBounds(
     64    const std::vector<const atom *> &atoms);
     65std::map<atomId_t, Vector> CalculateZeroAngularDipole(
     66    const std::vector<const molecule *> &molecules);
     67
     68DipoleAngularCorrelationMap *DipoleAngularCorrelation(
     69    const Formula &DipoleFormula,
     70    const size_t timestep,
     71    const std::map<atomId_t, Vector> &ZeroVector,
     72    const enum ResetWorldTime DoTimeReset = DontResetTime);
     73DipoleCorrelationMap *DipoleCorrelation(
     74    const std::vector<const molecule *> &molecules);
    6875PairCorrelationMap *PairCorrelation(
    6976    const World::ConstAtomComposite &atoms_first,
    7077    const World::ConstAtomComposite &atoms_second,
    7178    const double max_distance);
    72 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point );
    73 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell_deprecated *LC );
    74 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] );
    75 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell_deprecated *LC, const int ranges[NDIM] );
    76 int GetBin ( const double value, const double BinWidth, const double BinStart );
    77 void OutputCorrelation_Header( ofstream * const file );
    78 void OutputCorrelation_Value( ofstream * const file, BinPairMap::const_iterator &runner );
    79 void OutputDipoleAngularCorrelation_Header( ofstream * const file );
    80 void OutputDipoleAngularCorrelation_Value( ofstream * const file, DipoleAngularCorrelationMap::const_iterator &runner );
    81 void OutputDipoleCorrelation_Header( ofstream * const file );
    82 void OutputDipoleCorrelation_Value( ofstream * const file, DipoleCorrelationMap::const_iterator &runner );
    83 void OutputPairCorrelation_Header( ofstream * const file );
    84 void OutputPairCorrelation_Value( ofstream * const file, PairCorrelationMap::const_iterator &runner );
    85 void OutputCorrelationToPoint_Header( ofstream * const file );
    86 void OutputCorrelationToPoint_Value( ofstream * const file, CorrelationToPointMap::const_iterator &runner );
    87 void OutputCorrelationToSurface_Header( ofstream * const file );
    88 void OutputCorrelationToSurface_Value( ofstream * const file, CorrelationToSurfaceMap::const_iterator &runner );
     79CorrelationToPointMap *CorrelationToPoint(
     80    const std::vector<const molecule *> &molecules,
     81    const std::vector<const element *> &elements,
     82    const Vector *point );
     83CorrelationToSurfaceMap *CorrelationToSurface(
     84    const std::vector<const molecule *> &molecules,
     85    const std::vector<const element *> &elements,
     86    const Tesselation * const Surface,
     87    const LinkedCell_deprecated *LC );
     88CorrelationToPointMap *PeriodicCorrelationToPoint(
     89    const std::vector<const molecule *> &molecules,
     90    const std::vector<const element *> &elements,
     91    const Vector *point, const int ranges[NDIM] );
     92CorrelationToSurfaceMap *PeriodicCorrelationToSurface(
     93    const std::vector<const molecule *> &molecules,
     94    const std::vector<const element *> &elements,
     95    const Tesselation * const Surface,
     96    const LinkedCell_deprecated *LC,
     97    const int ranges[NDIM] );
     98int GetBin (
     99    const double value,
     100    const double BinWidth,
     101    const double BinStart );
     102void OutputCorrelation_Header(
     103    ofstream * const file );
     104void OutputCorrelation_Value(
     105    ofstream * const file,
     106    BinPairMap::const_iterator &runner );
     107void OutputDipoleAngularCorrelation_Header(
     108    ofstream * const file );
     109void OutputDipoleAngularCorrelation_Value(
     110    ofstream * const file,
     111    DipoleAngularCorrelationMap::const_iterator &runner );
     112void OutputDipoleCorrelation_Header(
     113    ofstream * const file );
     114void OutputDipoleCorrelation_Value(
     115    ofstream * const file,
     116    DipoleCorrelationMap::const_iterator &runner );
     117void OutputPairCorrelation_Header(
     118    ofstream * const file );
     119void OutputPairCorrelation_Value(
     120    ofstream * const file,
     121    PairCorrelationMap::const_iterator &runner );
     122void OutputCorrelationToPoint_Header(
     123    ofstream * const file );
     124void OutputCorrelationToPoint_Value(
     125    ofstream * const file,
     126    CorrelationToPointMap::const_iterator &runner );
     127void OutputCorrelationToSurface_Header(
     128    ofstream * const file );
     129void OutputCorrelationToSurface_Value(
     130    ofstream * const file,
     131    CorrelationToSurfaceMap::const_iterator &runner );
    89132
    90133/** Searches for lowest and highest value in a given map of doubles.
  • src/Analysis/unittests/AnalysisCorrelationToPointUnitTest.cpp

    ra58c16 r99db9b  
    105105  // init maps
    106106  World::getInstance().selectAllMolecules(AllMolecules());
    107   allMolecules = World::getInstance().getSelectedMolecules();
     107  allMolecules = const_cast<const World &>(World::getInstance()).getSelectedMolecules();
    108108  CPPUNIT_ASSERT_EQUAL( (size_t) 1, allMolecules.size());
    109109  pointmap = CorrelationToPoint( allMolecules, elements, (const Vector *)point );
  • src/Analysis/unittests/AnalysisCorrelationToPointUnitTest.hpp

    ra58c16 r99db9b  
    4141private:
    4242
    43       std::vector<molecule *> allMolecules;
     43      std::vector<const molecule *> allMolecules;
    4444      molecule *TestMolecule;
    4545      const element *hydrogen;
  • src/Analysis/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    ra58c16 r99db9b  
    145145
    146146  World::getInstance().selectAllMolecules(AllMolecules());
    147   allMolecules = World::getInstance().getSelectedMolecules();
     147  allMolecules = const_cast<const World &>(World::getInstance()).getSelectedMolecules();
    148148  CPPUNIT_ASSERT_EQUAL( (size_t) 2, allMolecules.size());
    149149
  • src/Analysis/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp

    ra58c16 r99db9b  
    4949private:
    5050
    51       std::vector<molecule *> allMolecules;
     51      std::vector<const molecule *> allMolecules;
    5252      molecule *TestSurfaceMolecule;
    5353      const element *hydrogen;
Note: See TracChangeset for help on using the changeset viewer.