Ignore:
Timestamp:
Oct 18, 2009, 2:51:38 PM (16 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, Candidate_v1.7.0, 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:
174e0e
Parents:
b8b75d
git-author:
Frederik Heber <heber@…> (10/18/09 14:15:37)
git-committer:
Frederik Heber <heber@…> (10/18/09 14:51:38)
Message:

Huge refactoring: molecule::ListOfBondsPerAtom and molecule::NumberOfBondsPerAtom removed, atom::ListOfBonds introduced. Unit Test for ListOfBonds manipulation introduced.

  • changes to builder.cpp: removed CreateListOfBondsPerAtom() calls, as the creation of the global arrays is not necessary anymore
  • changes to LinkedCell: LinkedCell::CheckBounds(int[NDIM]) does not admonish out of bonds as this is not desired for the local offset which may become out of bounds.
  • changes to lists.hpp templates: BUGFIX: unlink() now sets ->next and ->previous to NULL, cleanup() uses removedwithoutcheck()
  • new templates for molecule.hpp: SumPerAtom() allows for summation of the return value of atom:...() member fiunctions. This is needed e.g. for atom::CorrectBondDegree()

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_fragmentation.cpp

    rb8b75d r266237  
    3131int molecule::GuesstimateFragmentCount(ofstream *out, int order)
    3232{
    33   int c = 0;
     33  size_t c = 0;
    3434  int FragmentCount;
    3535  // get maximum bond degree
     
    3737  while (Walker->next != end) {
    3838    Walker = Walker->next;
    39     c = (NumberOfBondsPerAtom[Walker->nr] > c) ? NumberOfBondsPerAtom[Walker->nr] : c;
     39    c = (Walker->ListOfBonds.size() > c) ? Walker->ListOfBonds.size() : c;
    4040  }
    4141  FragmentCount = NoNonHydrogen*(1 << (c*order));
     
    564564
    565565  // ===== 1. Check whether bond structure is same as stored in files ====
    566 
    567   // fill the adjacency list
    568   CreateListOfBondsPerAtom(out);
    569566
    570567  // create lookup table for Atom::nr
     
    630627      MolecularWalker = MolecularWalker->next;
    631628      *out << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl;
    632       //MolecularWalker->Leaf->OutputListOfBonds(out);  // output ListOfBondsPerAtom for debugging
     629      //MolecularWalker->Leaf->OutputListOfBonds(out);  // output atom::ListOfBonds for debugging
    633630      if (MolecularWalker->Leaf->first->next != MolecularWalker->Leaf->last) {
    634631        // call BOSSANOVA method
     
    879876    if (SonList[FatherOfRunner->nr] != NULL)  {  // check if this, our father, is present in list
    880877      // create all bonds
    881       for (int i=0;i<mol->NumberOfBondsPerAtom[FatherOfRunner->nr];i++) { // go through every bond of father
    882         OtherFather = mol->ListOfBondsPerAtom[FatherOfRunner->nr][i]->GetOtherAtom(FatherOfRunner);
     878      for (BondList::const_iterator BondRunner = FatherOfRunner->ListOfBonds.begin(); BondRunner != FatherOfRunner->ListOfBonds.end(); (++BondRunner)) {
     879        OtherFather = (*BondRunner)->GetOtherAtom(FatherOfRunner);
    883880//        *out << Verbose(2) << "Father " << *FatherOfRunner << " of son " << *SonList[FatherOfRunner->nr] << " is bound to " << *OtherFather;
    884881        if (SonList[OtherFather->nr] != NULL) {
     
    887884//            *out << Verbose(3) << "Adding Bond: ";
    888885//            *out <<
    889             Leaf->AddBond(Runner, SonList[OtherFather->nr], mol->ListOfBondsPerAtom[FatherOfRunner->nr][i]->BondDegree);
     886            Leaf->AddBond(Runner, SonList[OtherFather->nr], (*BondRunner)->BondDegree);
    890887//            *out << "." << endl;
    891888            //NumBonds[Runner->nr]++;
     
    898895#ifdef ADDHYDROGEN
    899896          //*out << Verbose(3) << "Adding Hydrogen to " << Runner->Name << " and a bond in between." << endl;
    900           if(!Leaf->AddHydrogenReplacementAtom(out, mol->ListOfBondsPerAtom[FatherOfRunner->nr][i], Runner, FatherOfRunner, OtherFather, mol->ListOfBondsPerAtom[FatherOfRunner->nr],mol->NumberOfBondsPerAtom[FatherOfRunner->nr], IsAngstroem))
     897          if(!Leaf->AddHydrogenReplacementAtom(out, (*BondRunner), Runner, FatherOfRunner, OtherFather, IsAngstroem))
    901898            exit(1);
    902899#endif
    903           //NumBonds[Runner->nr] += ListOfBondsPerAtom[FatherOfRunner->nr][i]->BondDegree;
     900          //NumBonds[Runner->nr] += Binder->BondDegree;
    904901        }
    905902      }
     
    936933  CreateInducedSubgraphOfFragment(out, this, Leaf, SonList, IsAngstroem);
    937934
    938   Leaf->CreateListOfBondsPerAtom(out);
    939935  //Leaflet->Leaf->ScanForPeriodicCorrection(out);
    940936  Free(&SonList);
     
    981977    if (bit) {  // if bit is set, we add this bond partner
    982978      OtherWalker = BondsSet[j]->rightatom;  // rightatom is always the one more distant, i.e. the one to add
    983       //*out << Verbose(1+verbosity) << "Current Bond is " << ListOfBondsPerAtom[Walker->nr][CurrentCombination] << ", checking on " << *OtherWalker << "." << endl;
     979      //*out << Verbose(1+verbosity) << "Current Bond is " << BondsSet[j] << ", checking on " << *OtherWalker << "." << endl;
    984980      *out << Verbose(2+verbosity) << "Adding " << *OtherWalker << " with nr " << OtherWalker->nr << "." << endl;
    985981      TestKeySetInsert = FragmentSet->insert(OtherWalker->nr);
     
    10891085  NumCombinations = 1 << SetDimension;
    10901086
    1091   // Hier muessen von 1 bis NumberOfBondsPerAtom[Walker->nr] alle Kombinationen
    1092   // von Endstuecken (aus den Bonds) hinzugefuegt werden und fuer verbleibende ANOVAOrder
    1093   // rekursiv GraphCrawler in der naechsten Ebene aufgerufen werden
     1087  // here for all bonds of Walker all combinations of end pieces (from the bonds)
     1088  // have to be added and for the remaining ANOVA order GraphCrawler be called
     1089  // recursively for the next level
    10941090
    10951091  *out << Verbose(1+verbosity) << "Begin of SPFragmentGenerator." << endl;
     
    12581254  atom *OtherWalker = NULL;
    12591255  atom *Predecessor = NULL;
     1256  bond *CurrentEdge = NULL;
    12601257  bond *Binder = NULL;
    1261   bond *CurrentEdge = NULL;
    12621258  int RootKeyNr = FragmentSearch.Root->GetTrueFather()->nr;
    12631259  int RemainingWalkers = -1;
     
    12851281      // go through all its bonds
    12861282      *out << Verbose(1) << "Going through all bonds of Walker." << endl;
    1287       for (int i=0;i<mol->NumberOfBondsPerAtom[AtomKeyNr];i++) {
    1288         Binder = mol->ListOfBondsPerAtom[AtomKeyNr][i];
    1289         OtherWalker = Binder->GetOtherAtom(Walker);
     1283      for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
     1284        OtherWalker = (*Runner)->GetOtherAtom(Walker);
    12901285        if ((RestrictedKeySet.find(OtherWalker->nr) != RestrictedKeySet.end())
    12911286  #ifdef ADDHYDROGEN
     
    12931288  #endif
    12941289                                                              ) {  // skip hydrogens and restrict to fragment
    1295           *out << Verbose(2) << "Current partner is " << *OtherWalker << " with nr " << OtherWalker->nr << " in bond " << *Binder << "." << endl;
     1290          *out << Verbose(2) << "Current partner is " << *OtherWalker << " with nr " << OtherWalker->nr << " in bond " << *(*Runner) << "." << endl;
    12961291          // set the label if not set (and push on root stack as well)
    12971292          if ((OtherWalker != Predecessor) && (OtherWalker->GetTrueFather()->nr > RootKeyNr)) { // only pass through those with label bigger than Root's
     
    17121707        ColorList[Walker->nr] = black;    // mark as explored
    17131708        Walker->x.AddVector(&Translationvector); // translate
    1714         for (int i=0;i<NumberOfBondsPerAtom[Walker->nr];i++) {  // go through all binding partners
    1715           if (ListOfBondsPerAtom[Walker->nr][i] != Binder) {
    1716             OtherWalker = ListOfBondsPerAtom[Walker->nr][i]->GetOtherAtom(Walker);
     1709        for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
     1710          if ((*Runner) != Binder) {
     1711            OtherWalker = (*Runner)->GetOtherAtom(Walker);
    17171712            if (ColorList[OtherWalker->nr] == white) {
    17181713              AtomStack->Push(OtherWalker); // push if yet unexplored
Note: See TracChangeset for help on using the changeset viewer.