Changeset bd6bfa for src


Ignore:
Timestamp:
Jun 1, 2010, 7:28:15 AM (15 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:
acf800
Parents:
1b9321
Message:

Fixes after first,last removal.

  • BUGFIX: molecule::OutputGraphInfoPerBond() - had removal loop, not go-through-each-loop.
  • BUGFIX: MoleculeListClass::~MoleculeListClass() - did falsely destroy molecules too although this is done by World.
  • new function MoleculeListClass::erase() - handles signing off molecule as observer and removes from list.
  • FIX: MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs()
    • all molecules are removed from MoleculeListClass and also from World.
    • all bonds are removed, by going through all atoms of World.
    • molecule::getAtomCount() - calls doCountAtoms() which re-numbers and -labels atoms. This confused stuff.
  • TESTFIX: Molecules/6 and Molecules/7 had wrong (old) ordering in their test.conf
Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/bondgraph.cpp

    r1b9321 rbd6bfa  
    8888{
    8989  Info FunctionInfo(__func__);
    90 bool status = true;
     90  bool status = true;
    9191
    9292  if (mol->empty()) // only construct if molecule is not empty
  • src/molecule.hpp

    r1b9321 rbd6bfa  
    380380  bool StoreForcesFile(char *path, int *SortIndex);
    381381  void insert(molecule *mol);
     382  void erase(molecule *mol);
    382383  molecule * ReturnIndex(int index);
    383384  bool OutputConfigForListOfFragments(config *configuration, int *SortIndex);
  • src/molecule_graph.cpp

    r1b9321 rbd6bfa  
    6767    performCriticalExit();
    6868  };
     69  doCountAtoms();
    6970
    7071  // skip header
     
    632633  DoLog(1) && (Log() << Verbose(1) << "Final graph info for each bond is:" << endl);
    633634  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
    634     for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     635    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
    635636      if ((*BondRunner)->leftatom == *AtomRunner) {
    636637        Binder = *BondRunner;
  • src/moleculelist.cpp

    r1b9321 rbd6bfa  
    4040MoleculeListClass::~MoleculeListClass()
    4141{
    42   DoLog(3) && (Log() << Verbose(3) << this << ": Freeing ListOfMolcules." << endl);
    43   for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
    44     DoLog(4) && (Log() << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl);
    45     world->destroyMolecule(*ListRunner);
    46   }
    47   DoLog(4) && (Log() << Verbose(4) << "Freeing ListOfMolecules." << endl);
     42  DoLog(4) && (Log() << Verbose(4) << "Clearing ListOfMolecules." << endl);
     43  for(MoleculeList::iterator MolRunner = ListOfMolecules.begin(); MolRunner != ListOfMolecules.end(); ++MolRunner)
     44    (*MolRunner)->signOff(this);
    4845  ListOfMolecules.clear(); // empty list
    4946};
     
    5148/** Insert a new molecule into the list and set its number.
    5249 * \param *mol molecule to add to list.
    53  * \return true - add successful
    5450 */
    5551void MoleculeListClass::insert(molecule *mol)
     
    5955  ListOfMolecules.push_back(mol);
    6056  mol->signOn(this);
     57};
     58
     59/** Erases a molecule from the list.
     60 * \param *mol molecule to add to list.
     61 */
     62void MoleculeListClass::erase(molecule *mol)
     63{
     64  OBSERVE;
     65  mol->signOff(this);
     66  ListOfMolecules.remove(mol);
    6167};
    6268
     
    742748void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration)
    743749{
     750  // 0a. remove all present molecules
     751  vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
     752  for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
     753    erase(*MolRunner);
     754    World::getInstance().destroyMolecule(*MolRunner);
     755  }
     756  // 0b. remove all bonds
    744757  molecule *mol = World::getInstance().createMolecule();
    745   bond *Binder = NULL;
    746   // 0. gather all atoms into single molecule
    747   for (MoleculeList::iterator MolRunner = ListOfMolecules.begin(); !ListOfMolecules.empty(); MolRunner = ListOfMolecules.begin()) {
    748     // shift all atoms to new molecule
    749     for (molecule::iterator iter = (*MolRunner)->begin(); (*MolRunner)->empty(); iter = (*MolRunner)->begin()) {
    750       DoLog(3) && (Log() << Verbose(3) << "Re-linking " << (*iter) << "..." << endl);
    751       (*iter)->father = (*iter);
    752       mol->AddAtom((*iter));    // counting starts at 1
    753       (*MolRunner)->erase(iter);
    754     }
    755     // remove all bonds
    756     for(molecule::iterator AtomRunner = (*MolRunner)->begin(); AtomRunner != (*MolRunner)->end(); ++AtomRunner)
    757       for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
    758         delete(*BondRunner);
    759     // remove the molecule
    760     World::getInstance().destroyMolecule(*MolRunner);
    761     ListOfMolecules.erase(MolRunner);
     758  vector <atom *> allatoms = World::getInstance().getAllAtoms();
     759  for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
     760    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     761      delete(*BondRunner);
     762    mol->AddAtom(*AtomRunner);
    762763  }
    763764
     
    816817  // 4c. relocate atoms to new molecules and remove from Leafs
    817818  for (molecule::iterator iter = mol->begin(); !mol->empty(); iter = mol->begin()) {
    818     if (((*iter)->nr <0) || ((*iter)->nr >= mol->getAtomCount())) {
    819       DoeLog(0) && (eLog()<< Verbose(0) << "Index of atom " << **iter << " is invalid!" << endl);
     819    const int count = mol->getAtomCount();
     820    if (((*iter)->nr <0) || ((*iter)->nr >= count)) {
     821      DoeLog(0) && (eLog()<< Verbose(0) << "Index " << (*iter)->nr << " of atom " << **iter << " in molecule of " << count << " atoms is invalid!" << endl);
    820822      performCriticalExit();
    821823    }
    822     FragmentCounter = MolMap[(*iter)->nr];
    823     if (FragmentCounter != 0) {
     824    const int Index = MolMap[(*iter)->nr];
     825    if (Index != 0) {
    824826      DoLog(3) && (Log() << Verbose(3) << "Re-linking " << **iter << "..." << endl);
    825       molecules[FragmentCounter-1]->AddAtom((*iter));    // counting starts at 1
     827      molecules[Index-1]->AddAtom((*iter));    // counting starts at 1
    826828      mol->erase(iter);
    827829    } else {
Note: See TracChangeset for help on using the changeset viewer.