Changeset c9bce3e for src/config.cpp


Ignore:
Timestamp:
Nov 4, 2009, 3:08:11 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:
99593f
Parents:
a5551b
Message:

config::Load() refactored: Dissection into connected subgraphs -> MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/config.cpp

    ra5551b rc9bce3e  
    10551055  // 3. parse the molecule in
    10561056  LoadMolecule(mol, FileBuffer, periode, FastParsing);
    1057   //mol->ActiveFlag = true;
    1058   //MolList->insert(mol);
    1059 
    1060   // 4. dissect the molecule into connected subgraphs
    1061   BG->ConstructBondGraph((ofstream *)&cout, mol);
    1062 
    1063   // 5. scan for connected subgraphs
    1064   MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    1065   class StackClass<bond *> *BackEdgeStack = NULL;
    1066   Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, BackEdgeStack);
    1067   delete(BackEdgeStack);
    1068 
    1069   // 6. dissect (the following construct is needed to have the atoms not in the order of the DFS, but in
    1070   // the original one as parsed in)
    1071   // TODO: Optimize this, when molecules just contain pointer list of global atoms!
    1072 
    1073   // 6a. create array of molecules to fill
    1074   const int MolCount = Subgraphs->next->Count();
    1075   molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules");
    1076   for (int i=0;i<MolCount;i++) {
    1077     molecules[i] = (molecule*) new molecule(periode);
    1078     molecules[i]->ActiveFlag = true;
    1079     MolList->insert(molecules[i]);
    1080   }
    1081 
    1082   // 6b. create and fill map of which atom is associated to which connected molecule (note, counting starts at 1)
    1083   int FragmentCounter = 0;
    1084   int *MolMap = Calloc<int>(mol->AtomCount, "config::Load() - *MolMap");
    1085   MoleculeLeafClass *MolecularWalker = Subgraphs;
    1086   atom *Walker = NULL;
    1087   while (MolecularWalker->next != NULL) {
    1088     MolecularWalker = MolecularWalker->next;
    1089     Walker = MolecularWalker->Leaf->start;
    1090     while (Walker->next != MolecularWalker->Leaf->end) {
    1091       Walker = Walker->next;
    1092       MolMap[Walker->GetTrueFather()->nr] = FragmentCounter+1;
    1093     }
    1094     FragmentCounter++;
    1095   }
    1096 
    1097   // 6c. relocate atoms to new molecules and remove from Leafs
    1098   Walker = mol->start;
    1099   while (mol->start->next != mol->end) {
    1100     Walker = mol->start->next;
    1101     if ((Walker->nr <0) || (Walker->nr >= mol->AtomCount)) {
    1102       cerr << "Index of atom " << *Walker << " is invalid!" << endl;
    1103       performCriticalExit();
    1104     }
    1105     FragmentCounter = MolMap[Walker->nr];
    1106     if (FragmentCounter != 0) {
    1107       cout << Verbose(3) << "Re-linking " << *Walker << "..." << endl;
    1108       unlink(Walker);
    1109       molecules[FragmentCounter-1]->AddAtom(Walker);    // counting starts at 1
    1110     } else {
    1111       cerr << "Atom " << *Walker << " not associated to molecule!" << endl;
    1112       performCriticalExit();
    1113     }
    1114   }
    1115   // 6d. we don't need to redo bonds, as they are connected subgraphs and still maintained their ListOfBonds
    1116   // 6e. free Leafs
    1117   MolecularWalker = Subgraphs;
    1118   while (MolecularWalker->next != NULL) {
    1119     MolecularWalker = MolecularWalker->next;
    1120     delete(MolecularWalker->previous);
    1121   }
    1122   delete(MolecularWalker);
     1057
     1058  // 4. split into connected subgraphs
     1059  MolList->DissectMoleculeIntoConnectedSubgraphs((ofstream *)&cout, mol, this);
     1060
    11231061  delete(mol);
    1124   Free(&MolMap);
    1125   Free(&molecules);
    1126   cout << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl;
    1127 
    11281062  delete(FileBuffer);
    11291063};
     1064
    11301065
    11311066/** Initializes config file structure by loading elements from a give file with old pcp syntax.
Note: See TracChangeset for help on using the changeset viewer.