Ignore:
Timestamp:
Sep 30, 2016, 3:51:12 PM (9 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Add_FitFragmentPartialChargesAction, Fix_ChargeSampling_PBC, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ParseParticles_split_forward_backward_Actions
Children:
49e803
Parents:
257bd3
git-author:
Frederik Heber <heber@…> (09/27/16 09:58:43)
git-committer:
Frederik Heber <heber@…> (09/30/16 15:51:12)
Message:

FIX: BondedParticleInfo::MaxOrder and ::AdapativeOrder are now stored per trajectory step.

  • adapted uses in AdaptivityMap and Fragmentation as members are now protected.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Atom/atom_bondedparticleinfo.cpp

    r257bd3 ree19b7  
    4545BondList BondedParticleInfo::emptyList;
    4646
    47 /** Constructor of class BondedParticleInfo.
    48  */
    49 BondedParticleInfo::BondedParticleInfo() :
    50   AdaptiveOrder(0),
    51   MaxOrder(0)
    52 {}
    53 
    54 /** Destructor of class BondedParticleInfo.
    55  */
    56 BondedParticleInfo::~BondedParticleInfo()
    57 {}
    58 
    5947void BondedParticleInfo::AppendTrajectoryStep(const unsigned int _step)
    6048{
     
    7462}
    7563
     64template <class List_t>
     65void setEntryInList(
     66    List_t &_list,
     67    const typename List_t::key_type _step,
     68    const typename List_t::mapped_type &_value)
     69{
     70  typename List_t::iterator iter =
     71    _list.find(_step);
     72  if (iter != _list.end())
     73    iter->second = _value;
     74  else
     75    _list.insert( std::make_pair(_step, _value) );
     76}
     77
     78template <class List_t>
     79const typename List_t::mapped_type& getEntryInList(
     80    const List_t &_list,
     81    const typename List_t::key_type _step,
     82    const typename List_t::mapped_type &_empty)
     83{
     84  typename List_t::const_iterator iter =
     85    _list.find(_step);
     86  if (iter != _list.end())
     87    return iter->second;
     88  return _empty;
     89}
     90
    7691const BondList& BondedParticleInfo::getListOfBondsAtStep(unsigned int _step) const
    7792{
    78   BondTrajectory_t::const_iterator iter =
    79     ListOfBonds.find(_step);
    80   if (iter != ListOfBonds.end())
    81     return iter->second;
    82   return emptyList;
     93  return getEntryInList<BondTrajectory_t>(ListOfBonds, _step, emptyList);
    8394}
     95
     96const unsigned char& BondedParticleInfo::getMaxOrder() const
     97{
     98  return getMaxOrder(WorldTime::getTime());
     99}
     100
     101const unsigned char& BondedParticleInfo::getMaxOrder(unsigned int _step) const
     102{
     103  static unsigned char emptyOrder=0;
     104  return getEntryInList<OrderTrajectory_t>(MaxOrder, _step, emptyOrder);
     105}
     106
     107void BondedParticleInfo::setMaxOrder(unsigned char _value)
     108{
     109  setMaxOrder(WorldTime::getTime(), _value);
     110}
     111
     112void BondedParticleInfo::setMaxOrder(unsigned int _step, const unsigned char _value)
     113{
     114  setEntryInList<OrderTrajectory_t>(MaxOrder, _step, _value);
     115}
     116
     117const unsigned char& BondedParticleInfo::getAdaptiveOrder() const
     118{
     119  return getAdaptiveOrder(WorldTime::getTime());
     120}
     121
     122const unsigned char& BondedParticleInfo::getAdaptiveOrder(unsigned int _step) const
     123{
     124  static unsigned char emptyOrder=0;
     125  return getEntryInList<OrderTrajectory_t>(AdaptiveOrder, _step, emptyOrder);
     126}
     127
     128void BondedParticleInfo::setAdaptiveOrder(unsigned char _value)
     129{
     130  setAdaptiveOrder(WorldTime::getTime(), _value);
     131}
     132
     133void BondedParticleInfo::setAdaptiveOrder(unsigned int _step, const unsigned char _value)
     134{
     135  setEntryInList<OrderTrajectory_t>(AdaptiveOrder, _step, _value);
     136}
     137
Note: See TracChangeset for help on using the changeset viewer.