Changeset 458c31


Ignore:
Timestamp:
Mar 1, 2011, 10:16:39 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:
4b5cf8
Parents:
d4a44c
git-author:
Frederik Heber <heber@…> (02/21/11 13:02:57)
git-committer:
Frederik Heber <heber@…> (03/01/11 10:16:39)
Message:

molecule::BondCount is now Cachable and private.

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FragmentationAction/SubgraphDissectionAction.cpp

    rd4a44c r458c31  
    7474  // 0b. remove all bonds and construct a molecule with all atoms
    7575  molecule *mol = World::getInstance().createMolecule();
    76   int BondCount = 0;
    7776  {
    7877    vector <atom *> allatoms = World::getInstance().getAllAtoms();
    7978    for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
    80       const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
    81       BondCount += ListOfBonds.size();
     79//      const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
    8280//      for(BondList::iterator BondRunner = ListOfBonds.begin();
    8381//          !ListOfBonds.empty();
     
    9088
    9189  // 1. create the bond structure of the single molecule
    92   if (BondCount == 0) {
     90  if (mol->getBondCount() == 0) {
    9391    BondGraph *BG = World::getInstance().getBondGraph();
    9492    if (!BG->CreateAdjacencyForMolecule(mol)) {
  • src/molecule.cpp

    rd4a44c r458c31  
    5656molecule::molecule(const periodentafel * const teil) :
    5757  Observable("molecule"),
    58   elemente(teil),  MDSteps(0),  BondCount(0), NoNonHydrogen(0), NoNonBonds(0),
    59   NoCyclicBonds(0),  ActiveFlag(false), IndexNr(-1),
    60   AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0)
     58  elemente(teil),
     59  MDSteps(0),
     60  NoNonHydrogen(0),
     61  NoNonBonds(0),
     62  NoCyclicBonds(0),
     63  ActiveFlag(false),
     64  IndexNr(-1),
     65  AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"),
     66  BondCount(this,boost::bind(&molecule::doCountBonds,this),"BondCount"),
     67  last_atom(0)
    6168{
    6269
     
    8895int molecule::getAtomCount() const{
    8996  return *AtomCount;
     97}
     98
     99int molecule::getBondCount() const{
     100  return *BondCount;
    90101}
    91102
     
    729740  ASSERT(FindAtom(atom2->getNr()),"Second atom in bond-creation was not part of molecule");
    730741
    731   Binder = new bond(atom1, atom2, degree, BondCount++);
     742  Binder = new bond(atom1, atom2, degree, getBondCount());
    732743  atom1->RegisterBond(WorldTime::getTime(), Binder);
    733744  atom2->RegisterBond(WorldTime::getTime(), Binder);
     
    9981009  return res;
    9991010};
     1011
     1012/** Counts the number of present bonds.
     1013 * \return number of bonds
     1014 */
     1015int molecule::doCountBonds() const
     1016{
     1017  unsigned int counter = 0;
     1018  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
     1019    const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     1020    for(BondList::const_iterator BondRunner = ListOfBonds.begin();
     1021        BondRunner != ListOfBonds.end();
     1022        ++BondRunner)
     1023      if ((*BondRunner)->leftatom == *AtomRunner)
     1024        counter++;
     1025  }
     1026  return counter;
     1027}
     1028
    10001029
    10011030/** Returns an index map for two father-son-molecules.
  • src/molecule.hpp

    rd4a44c r458c31  
    9898  //bond *last;         //!< end of bond list
    9999  int MDSteps; //!< The number of MD steps in Trajectories
    100   //int AtomCount;          //!< number of atoms, brought up-to-date by CountAtoms()
    101   int BondCount; //!< number of atoms, brought up-to-date by CountBonds()
    102100  mutable int NoNonHydrogen; //!< number of non-hydrogen atoms in molecule
    103101  mutable int NoNonBonds; //!< number of non-hydrogen bonds in molecule
    104102  mutable int NoCyclicBonds; //!< number of cyclic bonds in molecule, by DepthFirstSearchAnalysis()
    105   //double BondDistance; //!< typical bond distance used in CreateAdjacencyList() and furtheron
    106103  bool ActiveFlag; //!< in a MoleculeListClass used to discern active from inactive molecules
    107104  //Vector Center;      //!< Center of molecule in a global box
     
    111108private:
    112109  Formula formula;
    113   Cacheable<int> AtomCount;
     110  Cacheable<int> AtomCount; //!< number of atoms, brought up-to-date by doCountAtoms()
     111  Cacheable<int> BondCount; //!< number of atoms, brought up-to-date by doCountBonds()
    114112  moleculeId_t id;
    115113  atomSet atoms; //<!list of atoms
     
    131129  int getAtomCount() const;
    132130  int doCountAtoms();
     131  int getBondCount() const;
     132  int doCountBonds() const;
    133133  moleculeId_t getId() const;
    134134  void setId(moleculeId_t);
     
    169169  bool RemoveBonds(atom *BondPartner);
    170170  bool hasBondStructure() const;
    171   unsigned int CountBonds() const;
    172171
    173172  /// Find atoms.
  • src/molecule_graph.cpp

    rd4a44c r458c31  
    149149        delete((*BondRunner));
    150150  }
    151   BondCount = 0;
    152151
    153152  // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering)
     
    214213        }
    215214    delete (LC);
    216     DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule." << endl);
     215    DoLog(1) && (Log() << Verbose(1) << "I detected " << getBondCount() << " bonds in the molecule." << endl);
    217216
    218217    // correct bond degree by comparing valence and bond degree
     
    242241  }
    243242  return false;
    244 }
    245 
    246 /** Counts the number of present bonds.
    247  * \return number of bonds
    248  */
    249 unsigned int molecule::CountBonds() const
    250 {
    251   unsigned int counter = 0;
    252   for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
    253     const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
    254     for(BondList::const_iterator BondRunner = ListOfBonds.begin();
    255         BondRunner != ListOfBonds.end();
    256         ++BondRunner)
    257       if ((*BondRunner)->leftatom == *AtomRunner)
    258         counter++;
    259   }
    260   return counter;
    261243}
    262244
     
    290272  int No = 0, OldNo = -1;
    291273
    292   if (BondCount != 0) {
     274  if (getBondCount() != 0) {
    293275    DoLog(1) && (Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl);
    294276    do {
     
    301283    DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    302284  } else {
    303     DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << getAtomCount() << " atoms." << endl);
     285    DoLog(1) && (Log() << Verbose(1) << "BondCount is " << getBondCount() << ", no bonds between any of the " << getAtomCount() << " atoms." << endl);
    304286  }
    305287  DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl);
     
    561543{
    562544  struct DFSAccounting DFS;
    563   BackEdgeStack = new std::deque<bond *> (BondCount);
     545  BackEdgeStack = new std::deque<bond *> (getBondCount());
    564546  DFS.BackEdgeStack = BackEdgeStack;
    565547  MoleculeLeafClass *SubGraphs = new MoleculeLeafClass(NULL);
  • src/unittests/ListOfBondsUnitTest.cpp

    rd4a44c r458c31  
    227227  // check if removed from molecule
    228228  CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() );
    229   CPPUNIT_ASSERT_EQUAL( (unsigned int)1, TestMolecule->CountBonds() );
     229  CPPUNIT_ASSERT_EQUAL( (int)1, TestMolecule->getBondCount() );
    230230};
    231231
Note: See TracChangeset for help on using the changeset viewer.