Changeset f01769 for src/Analysis


Ignore:
Timestamp:
Jul 24, 2015, 4:44:34 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:
a58c16
Parents:
1259df
git-author:
Frederik Heber <heber@…> (06/01/15 16:57:36)
git-committer:
Frederik Heber <heber@…> (07/24/15 16:44:34)
Message:

Replaced World::getAtom() wherever possible by const version.

  • some AtomSet member functions now have const atom ptr instead of atom ptr.
  • molecule can return const and non-const AtomSet.
  • added FromIdToConstAtom to allow iterate through atoms in molecule (which are stored by id, not by ptr) in const fashion.
  • in molecule::isInMolecule() is now const, ::CopyMolecule..() is non-const (because copying involves father atom who is stored non-const).
Location:
src/Analysis
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Analysis/analysis_bonds.cpp

    r1259df rf01769  
    182182    // go through every atom
    183183    typedef std::set<const molecule *> Moleculeset;
    184     for(molecule::const_iterator Walker = (*MolWalker)->begin();
    185         Walker!=(*MolWalker)->end();
     184    for(molecule::const_iterator Walker = const_cast<const molecule *>(*MolWalker)->begin();
     185        Walker != const_cast<const molecule *>(*MolWalker)->end();
    186186        ++Walker) {
    187187      // go through every oxygen
  • src/Analysis/analysis_correlation.cpp

    r1259df rf01769  
    155155  std::map<atomId_t, Vector> ZeroVector;
    156156  BOOST_FOREACH(molecule *_mol, molecules) {
    157     const Vector Dipole = getDipole(_mol->begin(), _mol->end());
    158     for(molecule::const_iterator iter = _mol->begin(); iter != _mol->end(); ++iter)
     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)
    159164      ZeroVector[(*iter)->getId()] = Dipole;
    160165    LOG(2,"INFO: Zero alignment for molecule " << _mol->getId() << " is " << Dipole);
     
    208213  size_t Counter_rejections = 0;
    209214  BOOST_FOREACH(molecule *_mol, molecules) {
    210     const Vector Dipole = getDipole(_mol->begin(), _mol->end());
     215    const Vector Dipole =
     216        getDipole(
     217            const_cast<const molecule *>(_mol)->begin(),
     218            const_cast<const molecule *>(_mol)->end());
    211219    LOG(3,"INFO: Dipole vector at time step " << timestep << " for for molecule "
    212220        << _mol->getId() << " is " << Dipole);
    213221    // check that all atoms are valid (zeroVector known)
    214     molecule::const_iterator iter = _mol->begin();
    215     for(; iter != _mol->end(); ++iter) {
     222    molecule::const_iterator iter = const_cast<const molecule *>(_mol)->begin();
     223    for(; iter != const_cast<const molecule *>(_mol)->end(); ++iter) {
    216224      if (!ZeroVector.count((*iter)->getId()))
    217225        break;
    218226    }
    219     if (iter != _mol->end()) {
     227    if (iter != const_cast<const molecule *>(_mol)->end()) {
    220228      ELOG(2, "Skipping molecule " << _mol->getName() << " as not all atoms have a valid zeroVector.");
    221229      ++Counter_rejections;
    222230      continue;
    223231    } else
    224       iter = _mol->begin();
     232      iter = const_cast<const molecule *>(_mol)->begin();
    225233    std::map<atomId_t, Vector>::const_iterator zeroValue = ZeroVector.find((*iter)->getId()); //due to iter is const
    226234    double angle = 0.;
     
    281289      MolWalker != molecules.end(); ++MolWalker) {
    282290    LOG(2, "INFO: Current molecule is " << (*MolWalker)->getId() << ".");
    283     const Vector Dipole = getDipole((*MolWalker)->begin(), (*MolWalker)->end());
     291    const Vector Dipole =
     292        getDipole(
     293            const_cast<const molecule *>(*MolWalker)->begin(),
     294            const_cast<const molecule *>(*MolWalker)->end());
    284295    std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker;
    285296    for (++MolOtherWalker;
     
    287298        ++MolOtherWalker) {
    288299      LOG(2, "INFO: Current other molecule is " << (*MolOtherWalker)->getId() << ".");
    289       const Vector OtherDipole = getDipole((*MolOtherWalker)->begin(), (*MolOtherWalker)->end());
     300      const Vector OtherDipole = getDipole(
     301          const_cast<const molecule *>(*MolOtherWalker)->begin(),
     302          const_cast<const molecule *>(*MolOtherWalker)->end());
    290303      const double angle = Dipole.Angle(OtherDipole) * (180./M_PI);
    291304      LOG(1, "Angle is " << angle << ".");
     
    410423  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
    411424    LOG(2, "Current molecule is " << *MolWalker << ".");
    412     for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     425    for (molecule::const_iterator iter = const_cast<const molecule *>(*MolWalker)->begin();
     426        iter != const_cast<const molecule *>(*MolWalker)->end();
     427        ++iter) {
    413428      LOG(3, "Current atom is " << **iter << ".");
    414429      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     
    456471    RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
    457472    LOG(2, "Current molecule is " << *MolWalker << ".");
    458     for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     473    for (molecule::const_iterator iter = const_cast<const molecule *>(*MolWalker)->begin();
     474        iter != const_cast<const molecule *>(*MolWalker)->end();
     475        ++iter) {
    459476      LOG(3, "Current atom is " << **iter << ".");
    460477      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     
    509526    if ((*MolWalker)->empty())
    510527      LOG(2, "\t is empty.");
    511     for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     528    for (molecule::const_iterator iter = const_cast<const molecule *>(*MolWalker)->begin();
     529        iter != const_cast<const molecule *>(*MolWalker)->end();
     530        ++iter) {
    512531      LOG(3, "\tCurrent atom is " << *(*iter) << ".");
    513532      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     
    566585    RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
    567586    LOG(2, "Current molecule is " << *MolWalker << ".");
    568     for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     587    for (molecule::const_iterator iter = const_cast<const molecule *>(*MolWalker)->begin();
     588        iter != const_cast<const molecule *>(*MolWalker)->end();
     589        ++iter) {
    569590      LOG(3, "Current atom is " << **iter << ".");
    570591      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
Note: See TracChangeset for help on using the changeset viewer.