Ignore:
Timestamp:
Apr 3, 2012, 8:00:19 AM (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:
e791dc
Parents:
08a0f52
git-author:
Frederik Heber <heber@…> (03/13/12 17:37:53)
git-committer:
Frederik Heber <heber@…> (04/03/12 08:00:19)
Message:

FIX: Rewrite of BondGraph's CreateAdjacency() and getMaxPossibleBondDistance().

  • getMaxPossibleBondDistance() is not templated anymore but expects simply a set of atomicNumber_t.
  • new helper function BondGraph::getElementSetFromNumbers() which converts a set of atomicNumber_t into a set of elements.
  • createAdjacency now prepares initially the set of atomicNumber_t and from it the set of elements such that no further element lookups are necessary except once for each atom's element.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Graph/BondGraph.hpp

    r08a0f52 r108968  
    1919
    2020#include <iosfwd>
     21#include <set>
    2122
    2223#include <boost/serialization/array.hpp>
     
    7576  void CleanupBondLengthTable();
    7677
     78  /** Internal helper to convert a set of atomicNumber_t to element refs.
     79   *
     80   * @param Set set of atomicNumber_t
     81   * @return set of element refs
     82   */
     83  std::set< const element *> getElementSetFromNumbers(const std::set<atomicNumber_t> &Set) const;
     84
    7785  /** Determines the maximum of all element::CovalentRadius for elements present in \a &Set.
    7886   *
     
    8088   * e.g. to be used for LinkedCell_deprecated or others.
    8189   *
    82    * \param &Set AtomSetMixin with all particles to consider
    83    */
    84   template <class container_type,
    85             class iterator_type,
    86             class const_iterator_type>
     90   * \param &PresentElements set of elements whose maximal pair to find
     91   */
    8792  double getMaxPossibleBondDistance(
    88       const AtomSetMixin<container_type,iterator_type,const_iterator_type> &Set) const
     93      const std::set< const element *> &PresentElements) const
    8994  {
    9095    double max_distance = 0.;
    91     // get all elements
    92     std::set< const element *> PresentElements;
    93     for(const_iterator_type AtomRunner = Set.begin(); AtomRunner != Set.end(); ++AtomRunner) {
    94       PresentElements.insert( (*AtomRunner)->getType() );
    95     }
     96
    9697    // create all element combinations
    9798    for (std::set< const element *>::const_iterator iter = PresentElements.begin();
     
    114115   * e.g. to be used for LinkedCell_deprecated or others.
    115116   *
    116    * \param &Set AtomSetMixin with all particles to consider
    117    */
    118   template <class container_type,
    119             class iterator_type,
    120             class const_iterator_type>
     117   * \param Walker element first element in the pair
     118   * \param &PresentElements set of elements whose maximal pair to find
     119   */
    121120  double getMaxPossibleBondDistance(
    122121      const element * const Walker,
    123       const AtomSetMixin<container_type,iterator_type,const_iterator_type> &Set) const
     122      const std::set< const element *> &PresentElements) const
    124123  {
    125124    double max_distance = 0.;
    126     // get all elements
    127     std::set< const element *> PresentElements;
    128     for(const_iterator_type AtomRunner = Set.begin(); AtomRunner != Set.end(); ++AtomRunner) {
    129       PresentElements.insert( (*AtomRunner)->getType() );
    130     }
     125
    131126    // create all element combinations
    132127    for (std::set< const element *>::const_iterator iter = PresentElements.begin();
     
    182177    cleanAdjacencyList(Set);
    183178
     179    // gather set of all present elements
     180    std::set<atomicNumber_t> elements;
     181    for(typename AtomSetMixin<container_type,iterator_type,const_iterator_type>::iterator iter = Set.begin();
     182        iter != Set.end(); ++iter) {
     183      const atom * const Walker = dynamic_cast<const atom *>(*iter);
     184      ASSERT(Walker != NULL,
     185          "BondGraph::CreateAdjacency() - TesselPoint "
     186          +(*iter)->getName()+" that was not an atom retrieved from given set");
     187      elements.insert( Walker->getElementNo() );
     188    }
     189    // get all elements
     190    std::set< const element *> PresentElements = getElementSetFromNumbers(elements);
     191
    184192    // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering)
    185193    const unsigned int counter = Set.size();
    186194    if (counter > 1) {
    187195      LOG(1, "STATUS: Setting max bond distance.");
    188       LinkedCell::LinkedCell_View LC = getLinkedCell(getMaxPossibleBondDistance(Set));
     196      LinkedCell::LinkedCell_View LC = getLinkedCell(getMaxPossibleBondDistance(PresentElements));
    189197
    190198      LOG(1, "STATUS: Creating LinkedCell structure for given " << counter << " atoms.");
     
    205213        // obtain all possible neighbors
    206214        LinkedCell::LinkedList ListOfNeighbors = LC.getAllNeighbors(
    207             getMaxPossibleBondDistance(Walker->getType(), Set),
     215            getMaxPossibleBondDistance(Walker->getType(), PresentElements),
    208216            Walker->getPosition());
    209217        if (!ListOfNeighbors.empty()) {
Note: See TracChangeset for help on using the changeset viewer.