Ignore:
Timestamp:
Nov 12, 2017, 8:48:39 AM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
ForceAnnealing_with_BondGraph_continued_betteresults
Children:
1f244c
Parents:
fd0b4a
git-author:
Frederik Heber <frederik.heber@…> (06/29/17 14:40:12)
git-committer:
Frederik Heber <frederik.heber@…> (11/12/17 08:48:39)
Message:

BondVectors now return subset of BondVectors for a given atom.

  • functionality extracted from ForceAnnealing::annealWithBondgraph().
  • also the mapped_t type is now kept up-to-date internally as we need it for returning the subset efficiently over a number of atoms, e.g. all in the given range.
  • also moved a few simple implementations over to _impl module.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Dynamics/BondVectors.cpp

    rfd0b4a r24430b  
    4141#include <iterator>
    4242
     43#include "CodePatterns/Assert.hpp"
     44#include "CodePatterns/Log.hpp"
     45
    4346#include "Atom/atom.hpp"
     47#include "Bond/bond.hpp"
    4448
    45 BondVectors::mapped_t BondVectors::getBondVectorsAtStep(
     49void BondVectors::recalculateBondVectorsAtStep(
    4650    const size_t &_step) const
    4751{
    48   mapped_t returnlist;
     52  current_mapped_vectors.clear();
    4953
    5054  ASSERT( !container.empty(),
     
    5660        - current_bond->rightatom->getPositionAtStep(_step);
    5761    BondVector.Normalize();
    58     returnlist.insert( std::make_pair(current_bond, BondVector) );
     62    current_mapped_vectors.insert( std::make_pair(current_bond, BondVector) );
    5963  }
    60   ASSERT( returnlist.size() == container.size(),
     64  ASSERT( current_mapped_vectors.size() == container.size(),
    6165      "BondVectors::getBondVectors() - not same amount of bond vectors as bonds?");
    6266
    63   return returnlist;
     67  map_is_dirty = false;
     68  current_step_for_map = _step;
    6469}
    6570
     
    7681}
    7782
     83std::vector<Vector> BondVectors::getAtomsBondVectorsAtStep(
     84    const atom &_walker,
     85    const size_t &_step) const
     86{
     87  if (map_is_dirty || (current_step_for_map != _step))
     88    recalculateBondVectorsAtStep(_step);
     89
     90  std::vector<Vector> BondVectors;
     91  // gather subset of BondVectors for the current atom
     92  const BondList& ListOfBonds = _walker.getListOfBonds();
     93  for(BondList::const_iterator bonditer = ListOfBonds.begin();
     94      bonditer != ListOfBonds.end(); ++bonditer) {
     95    const bond::ptr &current_bond = *bonditer;
     96    const BondVectors::mapped_t::const_iterator bviter =
     97        current_mapped_vectors.find(current_bond);
     98    ASSERT( bviter != current_mapped_vectors.end(),
     99        "ForceAnnealing() - cannot find current_bond ?");
     100    ASSERT( bviter != current_mapped_vectors.end(),
     101        "ForceAnnealing - cannot find current bond "+toString(*current_bond)
     102        +" in bonds.");
     103    BondVectors.push_back(bviter->second);
     104  }
     105  LOG(4, "DEBUG: BondVectors for atom #" << _walker.getId() << ": " << BondVectors);
     106
     107  return BondVectors;
     108}
Note: See TracChangeset for help on using the changeset viewer.