Changeset 6d551c for src


Ignore:
Timestamp:
Oct 26, 2012, 1:24:01 PM (13 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:
f96874
Parents:
dbe3b9
git-author:
Frederik Heber <heber@…> (09/07/12 08:47:35)
git-committer:
Frederik Heber <heber@…> (10/26/12 13:24:01)
Message:

ListOfLocalAtoms is now a map, inherited into a distinct class.

  • this is preparatory for allowing arbitrary fragmentation of atoms not only of a single molecule.
Location:
src
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/GraphAction/DepthFirstSearchAction.cpp

    rdbe3b9 r6d551c  
    4040#include "Graph/CyclicStructureAnalysis.hpp"
    4141#include "Graph/DepthFirstSearchAnalysis.hpp"
     42#include "Graph/ListOfLocalAtoms.hpp"
    4243#include "molecule.hpp"
    4344#include "MoleculeLeafClass.hpp"
     
    5657Action::state_ptr GraphDepthFirstSearchAction::performCall() {
    5758  LOG(1, "Depth-First-Search Analysis.");
    58   atom **ListOfAtoms = NULL;
     59  ListOfLocalAtoms_t ListOfAtoms;
    5960  std::deque<bond *> *LocalBackEdgeStack = NULL;
    6061  DepthFirstSearchAnalysis DFS;
     
    6667    while (Subgraphs->next != NULL) {
    6768      Subgraphs = Subgraphs->next;
    68       ListOfAtoms = NULL;
     69      ListOfAtoms.clear();
    6970      Subgraphs->Leaf->FillListOfLocalAtoms(ListOfAtoms, Subgraphs->Leaf->getAtomCount());
    7071      LocalBackEdgeStack = new std::deque<bond *>; // no need to have it Subgraphs->Leaf->BondCount size
     
    7576      Subgraphs->Leaf = NULL;
    7677      delete(Subgraphs->previous);
    77       delete[](ListOfAtoms);  // allocated by FillListOfLocalAtoms
    7878      FragmentCounter++;
    7979    }
  • src/Fragmentation/Fragmentation.cpp

    rdbe3b9 r6d551c  
    5353#include "Graph/BondGraph.hpp"
    5454#include "Graph/CheckAgainstAdjacencyFile.hpp"
     55#include "Graph/ListOfLocalAtoms.hpp"
    5556#include "molecule.hpp"
    5657#include "MoleculeLeafClass.hpp"
     
    106107  Graph TotalGraph;     // graph with all keysets however local numbers
    107108  int TotalNumberOfKeySets = 0;
    108   atom ***ListOfLocalAtoms = NULL;
    109109  bool *AtomMask = NULL;
    110110
     
    161161  // ===== 6a. assign each keyset to its respective subgraph =====
    162162  const int MolCount = World::getInstance().numMolecules();
    163   ListOfLocalAtoms = new atom **[MolCount];
    164   for (int i=0;i<MolCount;i++)
    165     ListOfLocalAtoms[i] = NULL;
    166163  FragmentCounter = 0;
    167   Subgraphs->next->AssignKeySetsToFragment(mol, &ParsedFragmentList, ListOfLocalAtoms, FragmentList, FragmentCounter, true);
    168   delete[](ListOfLocalAtoms);
     164  {
     165    ListOfLocalAtoms_t *ListOfLocalAtoms = new ListOfLocalAtoms_t[MolCount];
     166    Subgraphs->next->AssignKeySetsToFragment(mol, &ParsedFragmentList, ListOfLocalAtoms, FragmentList, FragmentCounter, true);
     167    delete[] ListOfLocalAtoms;
     168  }
    169169
    170170  // ===== 6b. prepare and go into the adaptive (Order<0), single-step (Order==0) or incremental (Order>0) cycle
  • src/Graph/DepthFirstSearchAnalysis.cpp

    rdbe3b9 r6d551c  
    4848#include "Descriptors/AtomDescriptor.hpp"
    4949#include "Descriptors/MoleculeDescriptor.hpp"
     50#include "Graph/ListOfLocalAtoms.hpp"
    5051#include "molecule.hpp"
    5152#include "MoleculeLeafClass.hpp"
     
    121122
    122123
    123 bool DepthFirstSearchAnalysis::PickLocalBackEdges(atom **ListOfLocalAtoms, std::deque<bond *> *&LocalStack) const
     124bool DepthFirstSearchAnalysis::PickLocalBackEdges(const ListOfLocalAtoms_t &ListOfLocalAtoms, std::deque<bond *> *&LocalStack) const
    124125{
    125126  bool status = true;
     
    133134
    134135  do { // go through all bonds and push local ones
    135     Walker = ListOfLocalAtoms[Binder->leftatom->getNr()]; // get one atom in the reference molecule
     136    const ListOfLocalAtoms_t::const_iterator leftiter = ListOfLocalAtoms.find(Binder->leftatom->getNr());
     137    ASSERT( leftiter != ListOfLocalAtoms.end(),
     138        "DepthFirstSearchAnalysis::PickLocalBackEdges() - could not find atom id "
     139        +toString(Binder->leftatom->getNr())+" in ListOfLocalAtoms.");
     140    Walker = leftiter->second; // get one atom in the reference molecule
    136141    if (Walker != NULL) { // if this Walker exists in the subgraph ...
    137142      const BondList& ListOfBonds = Walker->getListOfBonds();
     
    140145          ++Runner) {
    141146        OtherAtom = (*Runner)->GetOtherAtom(Walker);
    142         if (OtherAtom == ListOfLocalAtoms[(*Runner)->rightatom->getNr()]) { // found the bond
     147        const ListOfLocalAtoms_t::const_iterator rightiter = ListOfLocalAtoms.find((*Runner)->rightatom->getNr());
     148        if (OtherAtom == rightiter->second) { // found the bond
    143149          LocalStack->push_front((*Runner));
    144150          LOG(3, "INFO: Found local edge " << *(*Runner) << ".");
  • src/Graph/DepthFirstSearchAnalysis.hpp

    rdbe3b9 r6d551c  
    2020class atom;
    2121class bond;
     22class ListOfLocalAtoms_t;
    2223class MoleculeLeafClass;
    2324class molecule;
     
    6667   * Reference is the internal BackEdgeStack.
    6768   *
    68    * \param **ListOfLocalAtoms array of father atom::nr to local atom::nr (reverse of atom::father)
     69   * \param ListOfLocalAtoms array of father atom::nr to local atom::nr (reverse of atom::father)
    6970   * \param *LocalStack stack to be filled
    7071   * \return true - everything ok, false - ReferenceStack was empty
    7172   */
    72   bool PickLocalBackEdges(atom **ListOfLocalAtoms, std::deque<bond *> *&LocalStack) const;
     73  bool PickLocalBackEdges(const ListOfLocalAtoms_t &ListOfLocalAtoms, std::deque<bond *> *&LocalStack) const;
    7374
    7475  /** Getter for BackEdgeStack.
  • src/Graph/Makefile.am

    rdbe3b9 r6d551c  
    1818        Graph/ConnectedSubgraph.hpp \
    1919        Graph/CyclicStructureAnalysis.hpp \
    20         Graph/DepthFirstSearchAnalysis.hpp
     20        Graph/DepthFirstSearchAnalysis.hpp \
     21        Graph/ListOfLocalAtoms.hpp
    2122
    2223
  • src/MoleculeLeafClass.cpp

    rdbe3b9 r6d551c  
    4343#include "Fragmentation/Graph.hpp"
    4444#include "Fragmentation/KeySet.hpp"
     45#include "Graph/ListOfLocalAtoms.hpp"
    4546#include "molecule.hpp"
    4647
     
    153154 * \param *reference reference molecule with the bond structure to be copied
    154155 * \param *KeySetList list with all keysets
    155  * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
     156 * \param *ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
    156157 * \param **&FragmentList list to be allocated and returned
    157158 * \param &FragmentCounter counts the fragments as we move along the list
     
    159160 * \retuen true - success, false - failure
    160161 */
    161 bool MoleculeLeafClass::AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList)
     162bool MoleculeLeafClass::AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, ListOfLocalAtoms_t *&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList)
    162163{
    163164  bool status = true;
     
    210211  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
    211212    // free the index lookup list
    212     delete[](ListOfLocalAtoms[FragmentCounter]);
     213    (ListOfLocalAtoms[FragmentCounter]).clear();
    213214  }
    214215  LOG(1, "End of AssignKeySetsToFragment.");
  • src/MoleculeLeafClass.hpp

    rdbe3b9 r6d551c  
    1818class atom;
    1919class Graph;
     20class ListOfLocalAtoms_t;
    2021class molecule;
    2122
     
    3940  bool AddLeaf(molecule *ptr, MoleculeLeafClass *Previous);
    4041  bool FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter, const enum HydrogenSaturation saturation);
    41   bool AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList = false);
     42  bool AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, ListOfLocalAtoms_t *&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList = false);
    4243  void TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph);
    4344  int Count() const;
  • src/molecule.hpp

    rdbe3b9 r6d551c  
    4747class Graph;
    4848class LinkedCell_deprecated;
     49class ListOfLocalAtoms_t;
    4950class molecule;
    5051class MoleculeLeafClass;
     
    292293  bool StoreBondsToFile(std::string filename, std::string path = "");
    293294  bool StoreAdjacencyToFile(std::string filename, std::string path = "");
    294   bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
     295  bool CreateFatherLookupTable(ListOfLocalAtoms_t &LookupTable, int count = 0);
    295296
    296297  // Recognize doubly appearing molecules in a list of them
    297298  int * GetFatherSonAtomicMap(molecule *OtherMolecule);
    298   bool FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList = false);
    299   bool FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount);
     299  bool FillBondStructureFromReference(const molecule * const reference, ListOfLocalAtoms_t &ListOfLocalAtoms, bool FreeList = false);
     300  bool FillListOfLocalAtoms(ListOfLocalAtoms_t &ListOfLocalAtoms, const int GlobalAtomCount);
    300301
    301302  // Output routines.
  • src/molecule_graph.cpp

    rdbe3b9 r6d551c  
    4848#include "Element/element.hpp"
    4949#include "Graph/BondGraph.hpp"
     50#include "Graph/ListOfLocalAtoms.hpp"
    5051#include "Helpers/defs.hpp"
    5152#include "Helpers/helpers.hpp"
     
    6162 * Calls this routine in each MoleculeLeafClass::next subgraph if it's not NULL.
    6263 * \param *reference reference molecule with the bond structure to be copied
    63  * \param **&ListOfLocalAtoms Lookup table for this subgraph and index of each atom in \a *reference, may be NULL on start, then it is filled
    64  * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
     64 * \param ListOfLocalAtoms Lookup table for this subgraph and index of each atom in \a *reference, may be NULL on start, then it is filled
     65 * \param FreeList true - ListOfLocalAtoms is free'd before return, false - it is not
    6566 * \return true - success, false - failure
    6667 */
    67 bool molecule::FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList)
     68bool molecule::FillBondStructureFromReference(const molecule * const reference, ListOfLocalAtoms_t &ListOfLocalAtoms, bool FreeList)
    6869{
    6970  bool status = true;
     
    9192          ++Runner) {
    9293        atom * const OtherAtom = (*Runner)->GetOtherAtom((*iter)->GetTrueFather());
    93         atom * const OtherWalker = ListOfLocalAtoms[OtherAtom->getNr()]; // local copy of current bond partner of walker
     94        const ListOfLocalAtoms_t::const_iterator localiter = ListOfLocalAtoms.find(OtherAtom->getNr());
     95        ASSERT( localiter != ListOfLocalAtoms.end(),
     96            "molecule::FillBondStructureFromReference() - could not find id"
     97            +toString(OtherAtom->getNr())+" in ListOfLocalAtoms.");
     98        atom * const OtherWalker = localiter->second; // local copy of current bond partner of walker
    9499        if (OtherWalker != NULL) {
    95100          if (OtherWalker->getNr() > (*iter)->getNr())
     
    103108  }
    104109
    105   if ((FreeList) && (ListOfLocalAtoms != NULL)) {
     110  if ((FreeList) && (!ListOfLocalAtoms.empty())) {
    106111    // free the index lookup list
    107     delete[](ListOfLocalAtoms);
     112    ListOfLocalAtoms.clear();
    108113  }
    109114  LOG(1, "End of FillBondStructureFromReference.");
     
    227232
    228233/** Fills a lookup list of father's Atom::nr -> atom for each subgraph.
    229  * \param **&ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
     234 * \param ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
    230235 * \param GlobalAtomCount number of atoms in the complete molecule
    231236 * \return true - success, false - failure (ListOfLocalAtoms != NULL)
    232237 */
    233 bool molecule::FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount)
     238bool molecule::FillListOfLocalAtoms(ListOfLocalAtoms_t &ListOfLocalAtoms, const int GlobalAtomCount)
    234239{
    235240  bool status = true;
    236241
    237   if (ListOfLocalAtoms == NULL) { // allocate and fill list of this fragment/subgraph
     242  if (ListOfLocalAtoms.empty()) { // allocate and fill list of this fragment/subgraph
    238243    status = status && CreateFatherLookupTable(ListOfLocalAtoms, GlobalAtomCount);
    239244  } else
     
    251256 * \return true - success, false - failure
    252257 */
    253 bool molecule::CreateFatherLookupTable(atom **&LookupTable, int count)
     258bool molecule::CreateFatherLookupTable(ListOfLocalAtoms_t &LookupTable, int count)
    254259{
    255260  bool status = true;
    256261  int AtomNo;
    257262
    258   if (LookupTable != NULL) {
    259     ELOG(1, "Pointer for Lookup table is not NULL! Aborting ...");
     263  if (!LookupTable.empty()) {
     264    ELOG(1, "Pointer for Lookup table is not empty! Aborting ...");
    260265    return false;
    261266  }
     
    273278
    274279  // allocate and fill
    275   LookupTable = new atom *[count+1];
    276   if (LookupTable == NULL) {
    277     ELOG(0, "LookupTable memory allocation failed!");
    278     performCriticalExit();
    279     status = false;
    280   } else {
    281     for (int i=0;i<=count;i++)
    282       LookupTable[i] = NULL;
    283     for (molecule::iterator iter = begin(); iter != end(); ++iter) {
    284       AtomNo = (*iter)->GetTrueFather()->getNr();
    285       if ((AtomNo >= 0) && (AtomNo <= count)) {
    286         LOG(3, "DEBUG: Setting LookupTable[" << AtomNo << "] to " << *(*iter));
    287         LookupTable[AtomNo] = (*iter);
    288       } else {
    289         ELOG(1, "Walker " << *(*iter) << " exceeded range of nuclear ids [0, " << count << "].");
    290         status = false;
    291         break;
    292       }
     280  for (int i=0;i<=count;i++)
     281    LookupTable[i] = NULL;
     282  for (molecule::iterator iter = begin(); iter != end(); ++iter) {
     283    AtomNo = (*iter)->GetTrueFather()->getNr();
     284    if ((AtomNo >= 0) && (AtomNo <= count)) {
     285      LOG(3, "DEBUG: Setting LookupTable[" << AtomNo << "] to " << *(*iter));
     286      LookupTable[AtomNo] = (*iter);
     287    } else {
     288      ELOG(1, "Walker " << *(*iter) << " exceeded range of nuclear ids [0, " << count << "].");
     289      status = false;
     290      break;
    293291    }
    294292  }
Note: See TracChangeset for help on using the changeset viewer.