Changes in / [42af9e:1024cb]


Ignore:
Files:
6 added
6 deleted
55 edited

Legend:

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

    r42af9e r1024cb  
    4646    molecule * const mol = World::getInstance().getMolecule(MoleculeById(0));
    4747    MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    48     int *MinimumRingSize = new int[mol->AtomCount];
     48    int *MinimumRingSize = new int[mol->getAtomCount()];
    4949    atom ***ListOfLocalAtoms = NULL;
    5050    class StackClass<bond *> *BackEdgeStack = NULL;
  • src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp

    r42af9e r1024cb  
    6565    DoLog(0) && (Log() << Verbose(0) << "Evaluating non-convex envelope of molecule." << Boundary->getId() << endl);
    6666    DoLog(1) && (Log() << Verbose(1) << "Using rolling ball of radius " << SphereRadius << " and storing tecplot data in " << filename << "." << endl);
    67     DoLog(1) && (Log() << Verbose(1) << "Specified molecule has " << Boundary->AtomCount << " atoms." << endl);
     67    DoLog(1) && (Log() << Verbose(1) << "Specified molecule has " << Boundary->getAtomCount() << " atoms." << endl);
    6868    start = clock();
    6969    LCList = new LinkedCell(Boundary, SphereRadius*2.);
  • src/Actions/WorldAction/RepeatBoxAction.cpp

    r42af9e r1024cb  
    4040  molecule *mol = NULL;
    4141  int j = 0;
     42  atom *Walker = NULL;
    4243
    4344  dialog->queryVector(NAME, &Repeater, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));
     
    5455        Repeater[axis] = 1;
    5556      }
    56       mol->CountAtoms();  // recount atoms
    57       if (mol->AtomCount != 0) {  // if there is more than none
    58         count = mol->AtomCount;   // is changed becausing of adding, thus has to be stored away beforehand
     57      if (mol->getAtomCount() != 0) {  // if there is more than none
     58        count = mol->getAtomCount();   // is changed becausing of adding, thus has to be stored away beforehand
    5959        Elements = new const element *[count];
    6060        vectors = new Vector *[count];
    6161        j = 0;
    62         atom *first = mol->start;
    63         while (first->next != mol->end) {  // make a list of all atoms with coordinates and element
    64           first = first->next;
    65           Elements[j] = first->type;
    66           vectors[j] = &first->x;
     62        for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) {
     63          Elements[j] = (*AtomRunner)->type;
     64          vectors[j] = &(*AtomRunner)->x;
    6765          j++;
    6866        }
     
    7573          x += y; // per factor one cell width further
    7674          for (int k=count;k--;) { // go through every atom of the original cell
    77             first = World::getInstance().createAtom(); // create a new body
    78             first->x = (*vectors[k]) + x;
    79             first->type = Elements[k];  // insert original element
    80             mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
     75            Walker = World::getInstance().createAtom(); // create a new body
     76            Walker->x = (*vectors[k]) + x;
     77            Walker->type = Elements[k];  // insert original element
     78            mol->AddAtom(Walker);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
    8179          }
    8280        }
  • src/Helpers/Assert.cpp

    r42af9e r1024cb  
    5454
    5555
    56 
    5756bool _my_assert::check(const bool res,
    5857                       const char* condition,
     
    6362{
    6463  if(!res){
    65     cout << "Assertion " << condition << " failed in file " << filename << " at line " << line << endl;
     64    cout << "Assertion \"" << condition << "\" failed in file " << filename << " at line " << line << endl;
    6665    cout << "Assertion Message: " << message << std::endl;
    6766    while(true){
  • src/Helpers/MemDebug.cpp

    r42af9e r1024cb  
    99#include <cstdlib>
    1010#include <cstring>
     11#include <boost/thread.hpp>
    1112
    1213using namespace std;
     14
     15#ifndef NDBEGUG
     16#ifndef NO_MEMDEBUG
    1317
    1418namespace Memory {
     
    4044  };
    4145
     46  boost::mutex memorylock;
     47
    4248  // start and end of the doubly-linked list
    4349  entry_t *begin=0;
     
    127133
    128134void *operator new(size_t nbytes,const char* file, int line) throw(std::bad_alloc) {
     135
     136  // we need to lock, so that no one changes the linked list while we are here
     137  boost::mutex::scoped_lock guard(Memory::memorylock);
    129138
    130139  // to avoid allocations of 0 bytes if someone screws up
     
    204213
    205214void operator delete(void *ptr) throw() {
     215  if(!ptr){
     216    cerr << "Warning: Deleting NULL pointer" << endl;
     217    return;
     218  }
     219
     220  // we need to lock, so the linked list does not changed while we are in here
     221  boost::mutex::scoped_lock guard(Memory::memorylock);
     222
    206223  // get the size for the entry, including alignment
    207224  static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t));
     
    212229  // let's see if the checksum is still matching
    213230  if(Memory::calcChecksum(&entry->info)!=entry->checksum){
    214     cout << "Possible memory corruption detected!" << endl;
    215     cout << "Trying to recover allocation information..." << endl;
    216     cout << "Memory was allocated at " << entry->info.file << ":" << entry->info.line << endl;
     231    cerr << "Possible memory corruption detected!" << endl;
     232    cerr << "Trying to recover allocation information..." << endl;
     233    cerr << "Memory was allocated at " << entry->info.file << ":" << entry->info.line << endl;
    217234    terminate();
    218235  }
     
    241258  operator delete(ptr);
    242259}
     260#endif
     261#endif
  • src/Helpers/MemDebug.hpp

    r42af9e r1024cb  
    2121 * your sourcefiles.
    2222 */
     23#ifndef NDEBUG
     24#ifndef NO_MEMDEBUG
     25
     26#ifndef MEMDEBUG
     27#define MEMDEBUG
     28#endif
    2329
    2430namespace Memory {
     
    5662#define new new(__FILE__,__LINE__)
    5763
     64#endif
     65#endif
     66
     67
     68#ifndef MEMDEBUG
     69// memory debugging was disabled
     70
     71namespace Memory {
     72  inline void getState(){}
     73
     74  template <typename T>
     75  inline T *ignore(T* ptr){
     76    return ptr;
     77  }
     78}
     79
     80#endif
    5881#endif /* MEMDEBUG_HPP_ */
  • src/Legacy/oldmenu.cpp

    r42af9e r1024cb  
    424424void oldmenu::RemoveAtoms(molecule *mol)
    425425{
    426   atom *first, *second;
     426  atom *second;
    427427  int axis;
    428428  double tmp1, tmp2;
     
    447447      break;
    448448    case 'b':
    449       second = mol->AskAtom("Enter number of atom as reference point: ");
    450       Log() << Verbose(0) << "Enter radius: ";
    451       cin >> tmp1;
    452       first = mol->start;
    453       second = first->next;
    454       while(second != mol->end) {
    455         first = second;
    456         second = first->next;
    457         if (first->x.DistanceSquared(second->x) > tmp1*tmp1) // distance to first above radius ...
    458           mol->RemoveAtom(first);
     449      {
     450        second = mol->AskAtom("Enter number of atom as reference point: ");
     451        Log() << Verbose(0) << "Enter radius: ";
     452        cin >> tmp1;
     453        molecule::iterator runner;
     454        for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
     455          runner = iter++;
     456          if ((*runner)->x.DistanceSquared((*runner)->x) > tmp1*tmp1) // distance to first above radius ...
     457            mol->RemoveAtom((*runner));
     458        }
    459459      }
    460460      break;
     
    466466      Log() << Verbose(0) << "Upper boundary: ";
    467467      cin >> tmp2;
    468       first = mol->start;
    469       second = first->next;
    470       while(second != mol->end) {
    471         first = second;
    472         second = first->next;
    473         if ((first->x[axis] < tmp1) || (first->x[axis] > tmp2)) {// out of boundary ...
    474           //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
    475           mol->RemoveAtom(first);
     468      molecule::iterator runner;
     469      for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
     470        runner = iter++;
     471        if (((*runner)->x[axis] < tmp1) || ((*runner)->x[axis] > tmp2)) {// out of boundary ...
     472          //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
     473          mol->RemoveAtom((*runner));
    476474        }
    477475      }
     
    516514        min[i] = 0.;
    517515
    518       second = mol->start;
    519       while ((second->next != mol->end)) {
    520         second = second->next; // advance
    521         Z = second->type->Z;
     516      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     517        Z = (*iter)->type->Z;
    522518        tmp1 = 0.;
    523         if (first != second) {
    524           x = first->x - second->x;
     519        if (first != (*iter)) {
     520          x = first->x - (*iter)->x;
    525521          tmp1 = x.Norm();
    526522        }
    527523        if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
    528         //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
     524        //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << ((*iter)->nr << ": " << tmp1 << " a.u." << endl;
    529525      }
    530526      for (int i=MAX_ELEMENTS;i--;)
     
    755751    Log() << Verbose(0) << "State the factor: ";
    756752    cin >> faktor;
    757 
    758     mol->CountAtoms(); // recount atoms
    759     if (mol->AtomCount != 0) {  // if there is more than none
    760       count = mol->AtomCount;  // is changed becausing of adding, thus has to be stored away beforehand
     753    if (mol->getAtomCount() != 0) {  // if there is more than none
     754      count = mol->getAtomCount();  // is changed becausing of adding, thus has to be stored away beforehand
    761755      Elements = new const element *[count];
    762756      vectors = new Vector *[count];
    763757      j = 0;
    764       first = mol->start;
    765       while (first->next != mol->end) { // make a list of all atoms with coordinates and element
    766         first = first->next;
    767         Elements[j] = first->type;
    768         vectors[j] = &first->x;
     758      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     759        Elements[j] = (*iter)->type;
     760        vectors[j] = &(*iter)->x;
    769761        j++;
    770762      }
     
    10251017    return;
    10261018  }
    1027   atom *Walker = mol->start;
    10281019
    10291020  // generate some KeySets
    10301021  Log() << Verbose(0) << "Generating KeySets." << endl;
    1031   KeySet TestSets[mol->AtomCount+1];
     1022  KeySet TestSets[mol->getAtomCount()+1];
    10321023  i=1;
    1033   while (Walker->next != mol->end) {
    1034     Walker = Walker->next;
     1024  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    10351025    for (int j=0;j<i;j++) {
    1036       TestSets[j].insert(Walker->nr);
     1026      TestSets[j].insert((*iter)->nr);
    10371027    }
    10381028    i++;
     
    10401030  Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
    10411031  KeySetTestPair test;
    1042   test = TestSets[mol->AtomCount-1].insert(Walker->nr);
    1043   if (test.second) {
    1044     Log() << Verbose(1) << "Insertion worked?!" << endl;
     1032  molecule::const_iterator iter = mol->begin();
     1033  if (iter != mol->end()) {
     1034    test = TestSets[mol->getAtomCount()-1].insert((*iter)->nr);
     1035    if (test.second) {
     1036      Log() << Verbose(1) << "Insertion worked?!" << endl;
     1037    } else {
     1038      Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
     1039    }
    10451040  } else {
    1046     Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
    1047   }
    1048   TestSets[mol->AtomCount].insert(mol->end->previous->nr);
    1049   TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
     1041    eLog() << Verbose(1) << "No atoms to test double insertion." << endl;
     1042  }
    10501043
    10511044  // constructing Graph structure
     
    10551048  // insert KeySets into Subgraphs
    10561049  Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl;
    1057   for (int j=0;j<mol->AtomCount;j++) {
     1050  for (int j=0;j<mol->getAtomCount();j++) {
    10581051    Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
    10591052  }
    10601053  Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl;
    10611054  GraphTestPair test2;
    1062   test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
     1055  test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.)));
    10631056  if (test2.second) {
    10641057    Log() << Verbose(1) << "Insertion worked?!" << endl;
  • src/Makefile.am

    r42af9e r1024cb  
    115115  Descriptors/MoleculeIdDescriptor.cpp
    116116                                   
    117                                    
     117
    118118DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \
    119119  Descriptors/AtomIdDescriptor.hpp \
     
    157157  Line.cpp \
    158158  linkedcell.cpp \
    159   lists.cpp \
    160159  log.cpp \
    161160  logger.cpp \
     
    170169  periodentafel.cpp \
    171170  Plane.cpp \
     171  Space.cpp \
    172172  tesselation.cpp \
    173173  tesselationhelpers.cpp \
    174174  triangleintersectionlist.cpp \
     175  vector.cpp \
     176  vector_ops.cpp \
    175177  verbose.cpp \
    176   vector_ops.cpp \
    177178  World.cpp
    178179
     
    220221# the following files are no longer used:
    221222#  memoryallocator.hpp \
     223#  memoryallocator.cpp \
    222224#  memoryusageobserver.hpp \
    223225#  memoryusageobserver.cpp
  • src/Patterns/Cacheable.hpp

    r42af9e r1024cb  
    2828        owner(_owner)
    2929        {}
    30       virtual T getValue()=0;
     30      virtual T& getValue()=0;
    3131      virtual void invalidate()=0;
    3232      virtual bool isValid()=0;
     
    4646        {}
    4747
    48       virtual T getValue(){
     48      virtual T& getValue(){
    4949        // set the state to valid
    5050        State::owner->switchState(State::owner->validState);
     
    7272        {}
    7373
    74       virtual T getValue(){
     74      virtual T& getValue(){
    7575        return content;
    7676      }
     
    100100        {}
    101101
    102       virtual T getValue(){
     102      virtual T& getValue(){
    103103        ASSERT(0,"Cannot get a value from a Cacheable after it's Observable has died");
    104104        // we have to return a grossly invalid reference, because no value can be produced anymore
     
    134134    void subjectKilled(Observable *subject);
    135135  private:
    136 
    137136    void switchState(state_ptr newState);
    138137
     
    144143
    145144    Observable *owner;
    146 
    147145    boost::function<T()> recalcMethod;
    148146
     
    221219
    222220    const bool isValid() const;
    223     const T operator*() const;
     221    const T& operator*() const;
    224222
    225223    // methods implemented for base-class Observer
     
    237235
    238236  template<typename T>
    239   const T Cacheable<T>::operator*() const{
     237  const T& Cacheable<T>::operator*() const{
    240238    return recalcMethod();
    241239  }
  • src/Patterns/Observer.cpp

    r42af9e r1024cb  
    8282Observable::_Observable_protector::_Observable_protector(Observable *_protege) :
    8383  protege(_protege)
     84{
     85  start_observer_internal(protege);
     86}
     87
     88Observable::_Observable_protector::_Observable_protector(const _Observable_protector &dest) :
     89    protege(dest.protege)
    8490{
    8591  start_observer_internal(protege);
     
    189195  ASSERT(callTable.count(this),"SignOff called for an Observable without Observers.");
    190196  callees_t &callees = callTable[this];
     197
    191198  callees_t::iterator iter;
    192199  callees_t::iterator deliter;
  • src/Patterns/Observer.hpp

    r42af9e r1024cb  
    3636typedef Notification *const Notification_ptr;
    3737
     38template<class _Set>
     39class ObservedIterator;
     40
    3841/**
    3942 * An Observer is notified by all Observed objects, when anything changes.
     
    5356  friend class Observable;
    5457  friend class Notification;
     58  template<class> friend class ObservedIterator;
     59
    5560public:
    5661  Observer();
     
    152157  static std::set<Observable*> busyObservables;
    153158
    154 
    155159  //! @cond
    156160  // Structure for RAII-Style notification
     
    164168  public:
    165169    _Observable_protector(Observable *);
     170    _Observable_protector(const _Observable_protector&);
    166171    ~_Observable_protector();
    167172  private:
  • src/Plane.cpp

    r42af9e r1024cb  
    9191  offset = normalVector->ScalarProduct(_offsetVector);
    9292}
     93
     94/**
     95 * copy constructor
     96 */
     97Plane::Plane(const Plane& plane) :
     98  normalVector(new Vector(*plane.normalVector)),
     99  offset(plane.offset)
     100{}
     101
    93102
    94103Plane::~Plane()
  • src/Plane.hpp

    r42af9e r1024cb  
    2626  Plane(const Vector &_normalVector, double _offset)  throw(ZeroVectorException);
    2727  Plane(const Vector &_normalVector, const Vector &_offsetVector) throw(ZeroVectorException);
     28  Plane(const Plane& plane);
    2829  virtual ~Plane();
    2930
  • src/analysis_bonds.cpp

    r42af9e r1024cb  
    2626  Mean = 0.;
    2727
    28   atom *Walker = mol->start;
    2928  int AtomCount = 0;
    30   while (Walker->next != mol->end) {
    31     Walker = Walker->next;
    32     const int count = Walker->ListOfBonds.size();
     29  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     30    const int count = (*iter)->ListOfBonds.size();
    3331    if (Max < count)
    3432      Max = count;
     
    5856
    5957  int AtomNo = 0;
    60   atom *Walker = mol->start;
    61   while (Walker->next != mol->end) {
    62     Walker = Walker->next;
    63     if (Walker->type == type1)
    64       for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++)
    65         if ((*BondRunner)->GetOtherAtom(Walker)->type == type2) {
     58  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     59    if ((*iter)->type == type1)
     60      for (BondList::const_iterator BondRunner = (*iter)->ListOfBonds.begin(); BondRunner != (*iter)->ListOfBonds.end(); BondRunner++)
     61        if ((*BondRunner)->GetOtherAtom((*iter))->type == type2) {
    6662          const double distance = (*BondRunner)->GetDistanceSquared();
    6763          if (Min > distance)
     
    126122int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL)
    127123{
    128   atom *Walker = NULL;
    129   atom *Runner = NULL;
    130124  int count = 0;
    131125  int OtherHydrogens = 0;
     
    133127  bool InterfaceFlag = false;
    134128  bool OtherHydrogenFlag = true;
    135   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
    136     Walker = (*MolWalker)->start;
    137     while (Walker->next != (*MolWalker)->end) {
    138       Walker = Walker->next;
    139       for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); MolRunner++) {
    140         Runner = (*MolRunner)->start;
    141         while (Runner->next != (*MolRunner)->end) {
    142           Runner = Runner->next;
    143           if ((Walker->type->Z  == 8) && (Runner->type->Z  == 8)) {
     129  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); ++MolWalker) {
     130    molecule::iterator Walker = (*MolWalker)->begin();
     131    for(;Walker!=(*MolWalker)->end();++Walker){
     132      for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); ++MolRunner) {
     133        molecule::iterator Runner = (*MolRunner)->begin();
     134        for(;Runner!=(*MolRunner)->end();++Runner){
     135          if (((*Walker)->type->Z  == 8) && ((*Runner)->type->Z  == 8)) {
    144136            // check distance
    145             const double distance = Runner->x.DistanceSquared(Walker->x);
     137            const double distance = (*Runner)->x.DistanceSquared((*Walker)->x);
    146138            if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means  different atoms
    147139              // on other atom(Runner) we check for bond to interface element and
     
    151143              OtherHydrogens = 0;
    152144              InterfaceFlag = (InterfaceElement == NULL);
    153               for (BondList::const_iterator BondRunner = Runner->ListOfBonds.begin(); BondRunner != Runner->ListOfBonds.end(); BondRunner++) {
    154                 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Runner);
     145              for (BondList::const_iterator BondRunner = (*Runner)->ListOfBonds.begin(); BondRunner != (*Runner)->ListOfBonds.end(); BondRunner++) {
     146                atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Runner);
    155147                // if hydrogen, check angle to be greater(!) than 30 degrees
    156148                if (OtherAtom->type->Z == 1) {
    157                   const double angle = CalculateAngle(&OtherAtom->x, &Runner->x, &Walker->x);
     149                  const double angle = CalculateAngle(&OtherAtom->x, &(*Runner)->x, &(*Walker)->x);
    158150                  OtherHydrogenFlag = OtherHydrogenFlag && (angle > M_PI*(30./180.) + MYEPSILON);
    159151                  Otherangle += angle;
     
    176168              if (InterfaceFlag && OtherHydrogenFlag) {
    177169                // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule
    178                 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
    179                   atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
     170                for (BondList::const_iterator BondRunner = (*Walker)->ListOfBonds.begin(); BondRunner != (*Walker)->ListOfBonds.end(); BondRunner++) {
     171                  atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Walker);
    180172                  if (OtherAtom->type->Z == 1) {
    181173                    // check angle
    182                     if (CheckHydrogenBridgeBondAngle(Walker, OtherAtom, Runner)) {
    183                       DoLog(1) && (Log() << Verbose(1) << Walker->getName() << ", " << OtherAtom->getName() << " and " << Runner->getName() << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle(&OtherAtom->x, &Walker->x, &Runner->x)*(180./M_PI) << "." << endl);
     174                    if (CheckHydrogenBridgeBondAngle(*Walker, OtherAtom, *Runner)) {
     175                      DoLog(1) && (Log() << Verbose(1) << (*Walker)->getName() << ", " << OtherAtom->getName() << " and " << (*Runner)->getName() << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle(&OtherAtom->x, &(*Walker)->x, &(*Runner)->x)*(180./M_PI) << "." << endl);
    184176                      count++;
    185177                      break;
     
    205197int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second)
    206198{
    207   atom *Walker = NULL;
    208199  int count = 0;
    209200
    210201  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
    211     Walker = (*MolWalker)->start;
    212     while (Walker->next != (*MolWalker)->end) {
    213       Walker = Walker->next;
    214       if ((Walker->type == first) || (Walker->type == second)) {  // first element matches
    215         for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
    216           atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
    217           if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (Walker->nr < OtherAtom->nr)) {
     202    molecule::iterator Walker = (*MolWalker)->begin();
     203    for(;Walker!=(*MolWalker)->end();++Walker){
     204      atom * theAtom = *Walker;
     205      if ((theAtom->type == first) || (theAtom->type == second)) {  // first element matches
     206        for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) {
     207          atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom);
     208          if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (theAtom->nr < OtherAtom->nr)) {
    218209            count++;
    219210            DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl);
     
    240231  bool MatchFlag[2];
    241232  bool result = false;
    242   atom *Walker = NULL;
    243233  const element * ElementArray[2];
    244234  ElementArray[0] = first;
     
    246236
    247237  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
    248     Walker = (*MolWalker)->start;
    249     while (Walker->next != (*MolWalker)->end) {
    250       Walker = Walker->next;
    251       if (Walker->type == second) {  // first element matches
     238    molecule::iterator Walker = (*MolWalker)->begin();
     239    for(;Walker!=(*MolWalker)->end();++Walker){
     240      atom *theAtom = *Walker;
     241      if (theAtom->type == second) {  // first element matches
    252242        for (int i=0;i<2;i++)
    253243          MatchFlag[i] = false;
    254         for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
    255           atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
     244        for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) {
     245          atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom);
    256246          for (int i=0;i<2;i++)
    257247            if ((!MatchFlag[i]) && (OtherAtom->type == ElementArray[i])) {
  • src/analysis_correlation.cpp

    r42af9e r1024cb  
    4040  }
    4141  outmap = new PairCorrelationMap;
    42   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     42  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
    4343    if ((*MolWalker)->ActiveFlag) {
    4444      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    45       atom *Walker = (*MolWalker)->start;
    46       while (Walker->next != (*MolWalker)->end) {
    47         Walker = Walker->next;
    48         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    49         if ((type1 == NULL) || (Walker->type == type1)) {
    50           for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
     45      eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
     46      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     47        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     48        if ((type1 == NULL) || ((*iter)->type == type1)) {
     49          for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
    5150            if ((*MolOtherWalker)->ActiveFlag) {
    5251              DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    53               atom *OtherWalker = (*MolOtherWalker)->start;
    54               while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
    55                 OtherWalker = OtherWalker->next;
    56                 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);
    57                 if (Walker->nr < OtherWalker->nr)
    58                   if ((type2 == NULL) || (OtherWalker->type == type2)) {
    59                     distance = Walker->node->PeriodicDistance(*OtherWalker->node, World::getInstance().getDomain());
    60                     //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
    61                     outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
     52              for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
     53                DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
     54                if ((*iter)->getId() < (*runner)->getId()){
     55                  if ((type2 == NULL) || ((*runner)->type == type2)) {
     56                    distance = (*iter)->node->PeriodicDistance(*(*runner)->node,  World::getInstance().getDomain());
     57                    //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
     58                    outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    6259                  }
     60                }
    6361              }
     62            }
    6463          }
    6564        }
    6665      }
    6766    }
    68 
     67  }
    6968  return outmap;
    7069};
     
    101100      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    102101      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    103       atom *Walker = (*MolWalker)->start;
    104       while (Walker->next != (*MolWalker)->end) {
    105         Walker = Walker->next;
    106         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    107         if ((type1 == NULL) || (Walker->type == type1)) {
    108           periodicX = *(Walker->node);
     102      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     103        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     104        if ((type1 == NULL) || ((*iter)->type == type1)) {
     105          periodicX = *(*iter)->node;
    109106          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    110107          // go through every range in xyz and get distance
     
    117114                  if ((*MolOtherWalker)->ActiveFlag) {
    118115                    DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    119                     atom *OtherWalker = (*MolOtherWalker)->start;
    120                     while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
    121                       OtherWalker = OtherWalker->next;
    122                       DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);
    123                       if (Walker->nr < OtherWalker->nr)
    124                         if ((type2 == NULL) || (OtherWalker->type == type2)) {
    125                           periodicOtherX = *(OtherWalker->node);
     116                    for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
     117                      DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
     118                      if ((*iter)->nr < (*runner)->nr)
     119                        if ((type2 == NULL) || ((*runner)->type == type2)) {
     120                          periodicOtherX = *(*runner)->node;
    126121                          periodicOtherX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    127122                          // go through every range in xyz and get distance
     
    132127                                checkOtherX.MatrixMultiplication(FullMatrix);
    133128                                distance = checkX.distance(checkOtherX);
    134                                 //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
    135                                 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
     129                                //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
     130                                outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    136131                              }
    137132                        }
     
    169164    if ((*MolWalker)->ActiveFlag) {
    170165      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    171       atom *Walker = (*MolWalker)->start;
    172       while (Walker->next != (*MolWalker)->end) {
    173         Walker = Walker->next;
    174         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    175         if ((type == NULL) || (Walker->type == type)) {
    176           distance = Walker->node->PeriodicDistance(*point, World::getInstance().getDomain());
     166      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     167        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     168        if ((type == NULL) || ((*iter)->type == type)) {
     169          distance = (*iter)->node->PeriodicDistance(*point, World::getInstance().getDomain());
    177170          DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    178           outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
     171          outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
    179172        }
    180173      }
     
    211204      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    212205      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    213       atom *Walker = (*MolWalker)->start;
    214       while (Walker->next != (*MolWalker)->end) {
    215         Walker = Walker->next;
    216         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    217         if ((type == NULL) || (Walker->type == type)) {
    218           periodicX = *(Walker->node);
     206      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     207        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     208        if ((type == NULL) || ((*iter)->type == type)) {
     209          periodicX = *(*iter)->node;
    219210          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    220211          // go through every range in xyz and get distance
     
    226217                distance = checkX.distance(*point);
    227218                DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    228                 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
     219                outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
    229220              }
    230221        }
     
    261252    if ((*MolWalker)->ActiveFlag) {
    262253      DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl);
    263       atom *Walker = (*MolWalker)->start;
    264       while (Walker->next != (*MolWalker)->end) {
    265         Walker = Walker->next;
    266         //Log() << Verbose(1) << "Current atom is " << *Walker << "." << endl;
    267         if ((type == NULL) || (Walker->type == type)) {
    268           TriangleIntersectionList Intersections(Walker->node,Surface,LC);
     254      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     255        //Log() << Verbose(3) << "Current atom is " << *(*iter) << "." << endl;
     256        if ((type == NULL) || ((*iter)->type == type)) {
     257          TriangleIntersectionList Intersections((*iter)->node,Surface,LC);
    269258          distance = Intersections.GetSmallestDistance();
    270259          triangle = Intersections.GetClosestTriangle();
    271           outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
     260          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
    272261        }
    273262      }
     
    314303      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    315304      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    316       atom *Walker = (*MolWalker)->start;
    317       while (Walker->next != (*MolWalker)->end) {
    318         Walker = Walker->next;
    319         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    320         if ((type == NULL) || (Walker->type == type)) {
    321           periodicX = *(Walker->node);
     305      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     306        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     307        if ((type == NULL) || ((*iter)->type == type)) {
     308          periodicX = *(*iter)->node;
    322309          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    323310          // go through every range in xyz and get distance
     
    337324              }
    338325          // insert
    339           outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) );
     326          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
    340327          //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
    341328        }
  • src/atom.cpp

    r42af9e r1024cb  
    5959atom::~atom()
    6060{
    61   unlink(this);
    6261};
    6362
  • src/bondgraph.cpp

    r42af9e r1024cb  
    9090bool status = true;
    9191
    92   if (mol->start->next == mol->end) // only construct if molecule is not empty
     92  if (mol->empty()) // only construct if molecule is not empty
    9393    return false;
    9494
     
    124124  max_distance = 0.;
    125125
    126   atom *Runner = mol->start;
    127   while (Runner->next != mol->end) {
    128     Runner = Runner->next;
    129     if (Runner->type->CovalentRadius > max_distance)
    130       max_distance = Runner->type->CovalentRadius;
     126  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     127    if ((*iter)->type->CovalentRadius > max_distance)
     128      max_distance = (*iter)->type->CovalentRadius;
    131129  }
    132130  max_distance *= 2.;
  • src/boundary.cpp

    r42af9e r1024cb  
    139139{
    140140        Info FunctionInfo(__func__);
    141   atom *Walker = NULL;
    142141  PointMap PointsOnBoundary;
    143142  LineMap LinesOnBoundary;
     
    165164
    166165    // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours
    167     Walker = mol->start;
    168     while (Walker->next != mol->end) {
    169       Walker = Walker->next;
    170       ProjectedVector = Walker->x - (*MolCenter);
     166    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     167      ProjectedVector = (*iter)->x - (*MolCenter);
    171168      ProjectedVector.ProjectOntoPlane(AxisVector);
    172169
     
    182179        angle = 2. * M_PI - angle;
    183180      }
    184       DoLog(1) && (Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);
    185       BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, Walker)));
     181    DoLog(1) && (Log() << Verbose(1) << "Inserting " << **iter << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);
     182      BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, (*iter))));
    186183      if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity
    187184        DoLog(2) && (Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl);
    188185        DoLog(2) && (Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl);
    189         DoLog(2) && (Log() << Verbose(2) << "New vector: " << *Walker << endl);
     186        DoLog(2) && (Log() << Verbose(2) << "New vector: " << **iter << endl);
    190187        const double ProjectedVectorNorm = ProjectedVector.NormSquared();
    191188        if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) {
    192189          BoundaryTestPair.first->second.first = ProjectedVectorNorm;
    193           BoundaryTestPair.first->second.second = Walker;
     190          BoundaryTestPair.first->second.second = (*iter);
    194191          DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl);
    195192        } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) {
    196           helper = Walker->x - (*MolCenter);
     193          helper = (*iter)->x;
     194          helper -= *MolCenter;
    197195          const double oldhelperNorm = helper.NormSquared();
    198196          helper = BoundaryTestPair.first->second.second->x - (*MolCenter);
    199197          if (helper.NormSquared() < oldhelperNorm) {
    200             BoundaryTestPair.first->second.second = Walker;
     198            BoundaryTestPair.first->second.second = (*iter);
    201199            DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl);
    202200          } else {
     
    620618  for (TriangleMap::iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++)
    621619    { // go through every triangle, calculate volume of its pyramid with CoG as peak
    622       x = (*runner->second->endpoints[0]->node->node) - (*runner->second->endpoints[1]->node->node);
    623       y = (*runner->second->endpoints[0]->node->node) - (*runner->second->endpoints[2]->node->node);
    624       const double a = sqrt(runner->second->endpoints[0]->node->node->DistanceSquared(*runner->second->endpoints[1]->node->node));
    625       const double b = sqrt(runner->second->endpoints[0]->node->node->DistanceSquared(*runner->second->endpoints[2]->node->node));
    626       const double c = sqrt(runner->second->endpoints[2]->node->node->DistanceSquared(*runner->second->endpoints[1]->node->node));
     620      x = runner->second->getEndpoint(0) - runner->second->getEndpoint(1);
     621      y = runner->second->getEndpoint(0) - runner->second->getEndpoint(2);
     622      const double a = x.Norm();
     623      const double b = y.Norm();
     624      const double c = runner->second->getEndpoint(2).distance(runner->second->getEndpoint(1));
    627625      const double G = sqrt(((a + b + c) * (a + b + c) - 2 * (a * a + b * b + c * c)) / 16.); // area of tesselated triangle
    628       x = Plane(*(runner->second->endpoints[0]->node->node),
    629                 *(runner->second->endpoints[1]->node->node),
    630                 *(runner->second->endpoints[2]->node->node)).getNormal();
    631       x.Scale(runner->second->endpoints[1]->node->node->ScalarProduct(x));
     626      x = runner->second->getPlane().getNormal();
     627      x.Scale(runner->second->getEndpoint(1).ScalarProduct(x));
    632628      const double h = x.Norm(); // distance of CoG to triangle
    633629      const double PyramidVolume = (1. / 3.) * G * h; // this formula holds for _all_ pyramids (independent of n-edge base or (not) centered peak)
     
    697693  int repetition[NDIM] = { 1, 1, 1 };
    698694  int TotalNoClusters = 1;
    699   atom *Walker = NULL;
    700695  double totalmass = 0.;
    701696  double clustervolume = 0.;
     
    721716
    722717  // sum up the atomic masses
    723   Walker = mol->start;
    724   while (Walker->next != mol->end) {
    725       Walker = Walker->next;
    726       totalmass += Walker->type->mass;
     718  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     719      totalmass += (*iter)->type->mass;
    727720  }
    728721  DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl);
     
    806799  Vector Inserter;
    807800  double FillIt = false;
    808   atom *Walker = NULL;
    809801  bond *Binder = NULL;
    810802  double phi[NDIM];
     
    813805
    814806  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++)
    815     if ((*ListRunner)->AtomCount > 0) {
     807    if ((*ListRunner)->getAtomCount() > 0) {
    816808      DoLog(1) && (Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl);
    817809      LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list
     
    831823  }
    832824
    833   filler->CountAtoms();
    834   atom * CopyAtoms[filler->AtomCount];
     825  atom * CopyAtoms[filler->getAtomCount()];
    835826
    836827  // calculate filler grid in [0,1]^3
     
    857848
    858849        // go through all atoms
    859         for (int i=0;i<filler->AtomCount;i++)
     850        for (int i=0;i<filler->getAtomCount();i++)
    860851          CopyAtoms[i] = NULL;
    861         Walker = filler->start;
    862         while (Walker->next != filler->end) {
    863           Walker = Walker->next;
     852        for(molecule::iterator iter = filler->begin(); iter !=filler->end();++filler){
    864853
    865854          // create atomic random translation vector ...
     
    885874
    886875          // ... and put at new position
    887           Inserter = Walker->x;
     876          Inserter = (*iter)->x;
    888877          if (DoRandomRotation)
    889878            Inserter.MatrixMultiplication(Rotations);
     
    909898            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl);
    910899            // copy atom ...
    911             CopyAtoms[Walker->nr] = Walker->clone();
    912             CopyAtoms[Walker->nr]->x = Inserter;
    913             Filling->AddAtom(CopyAtoms[Walker->nr]);
    914             DoLog(4) && (Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl);
     900            CopyAtoms[(*iter)->nr] = (*iter)->clone();
     901            CopyAtoms[(*iter)->nr]->x = Inserter;
     902            Filling->AddAtom(CopyAtoms[(*iter)->nr]);
     903            DoLog(4) && (Log() << Verbose(4) << "Filling atom " << **iter << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[(*iter)->nr]->x) << "." << endl);
    915904          } else {
    916905            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl);
    917             CopyAtoms[Walker->nr] = NULL;
     906            CopyAtoms[(*iter)->nr] = NULL;
    918907            continue;
    919908          }
     
    954943  bool TesselationFailFlag = false;
    955944
     945  mol->getAtomCount();
     946
    956947  if (TesselStruct == NULL) {
    957948    DoLog(1) && (Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl);
     
    10251016//  // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles
    10261017//  //->InsertStraddlingPoints(mol, LCList);
    1027 //  mol->GoToFirst();
     1018//  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    10281019//  class TesselPoint *Runner = NULL;
    1029 //  while (!mol->IsEnd()) {
    1030 //    Runner = mol->GetPoint();
     1020//    Runner = *iter;
    10311021//    Log() << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl;
    10321022//    if (!->IsInnerPoint(Runner, LCList)) {
     
    10361026//      Log() << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl;
    10371027//    }
    1038 //    mol->GoToNext();
    10391028//  }
    10401029
     
    10451034  status = CheckListOfBaselines(TesselStruct);
    10461035
     1036  cout << "before correction" << endl;
     1037
    10471038  // store before correction
    1048   StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");
     1039  StoreTrianglesinFile(mol, TesselStruct, filename, "");
    10491040
    10501041//  // correct degenerated polygons
     
    10561047  // write final envelope
    10571048  CalculateConcavityPerBoundaryPoint(TesselStruct);
    1058   StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");
     1049  cout << "after correction" << endl;
     1050  StoreTrianglesinFile(mol, TesselStruct, filename, "");
    10591051
    10601052  if (freeLC)
  • src/builder.cpp

    r42af9e r1024cb  
    865865
    866866        mol->CountAtoms(); // recount atoms
    867         if (mol->AtomCount != 0) {  // if there is more than none
    868           count = mol->AtomCount;  // is changed becausing of adding, thus has to be stored away beforehand
     867        if (mol->getAtomCount() != 0) {  // if there is more than none
     868          count = mol->getAtomCount();  // is changed becausing of adding, thus has to be stored away beforehand
    869869          Elements = new element *[count];
    870870          vectors = new Vector *[count];
     
    12961296  // generate some KeySets
    12971297  DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl);
    1298   KeySet TestSets[mol->AtomCount+1];
     1298  KeySet TestSets[mol->getAtomCount()+1];
    12991299  i=1;
    13001300  while (Walker->next != mol->end) {
     
    13071307  DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl);
    13081308  KeySetTestPair test;
    1309   test = TestSets[mol->AtomCount-1].insert(Walker->nr);
     1309  test = TestSets[mol->getAtomCount()-1].insert(Walker->nr);
    13101310  if (test.second) {
    13111311    DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
     
    13131313    DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl);
    13141314  }
    1315   TestSets[mol->AtomCount].insert(mol->end->previous->nr);
    1316   TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
     1315  TestSets[mol->getAtomCount()].insert(mol->end->previous->nr);
     1316  TestSets[mol->getAtomCount()].insert(mol->end->previous->previous->previous->nr);
    13171317
    13181318  // constructing Graph structure
     
    13221322  // insert KeySets into Subgraphs
    13231323  DoLog(0) && (Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl);
    1324   for (int j=0;j<mol->AtomCount;j++) {
     1324  for (int j=0;j<mol->getAtomCount();j++) {
    13251325    Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
    13261326  }
    13271327  DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl);
    13281328  GraphTestPair test2;
    1329   test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
     1329  test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.)));
    13301330  if (test2.second) {
    13311331    DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
     
    17141714                if (first->type != NULL) {
    17151715                  mol->AddAtom(first);  // add to molecule
    1716                   if ((configPresent == empty) && (mol->AtomCount != 0))
     1716                  if ((configPresent == empty) && (mol->getAtomCount() != 0))
    17171717                    configPresent = present;
    17181718                } else
     
    17321732                DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
    17331733                MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    1734                 int *MinimumRingSize = new int[mol->AtomCount];
     1734                int *MinimumRingSize = new int[mol->getAtomCount()];
    17351735                atom ***ListOfLocalAtoms = NULL;
    17361736                class StackClass<bond *> *BackEdgeStack = NULL;
     
    18801880                          int counter  = 0;
    18811881                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    1882                             if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
     1882                            if ((Boundary == NULL) || (Boundary->getAtomCount() < (*BigFinder)->getAtomCount())) {
    18831883                              Boundary = *BigFinder;
    18841884                            }
     
    19391939                performCriticalExit();
    19401940              } else {
     1941                mol->getAtomCount();
    19411942                SaveFlag = true;
    19421943                DoLog(1) && (Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl);
     
    20422043                int counter  = 0;
    20432044                for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    2044                   (*BigFinder)->CountAtoms();
    2045                   if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
     2045                  if ((Boundary == NULL) || (Boundary->getAtomCount() < (*BigFinder)->getAtomCount())) {
    20462046                    Boundary = *BigFinder;
    20472047                  }
    20482048                  counter++;
    20492049                }
    2050                 DoLog(1) && (Log() << Verbose(1) << "Biggest molecule has " << Boundary->AtomCount << " atoms." << endl);
     2050                DoLog(1) && (Log() << Verbose(1) << "Biggest molecule has " << Boundary->getAtomCount() << " atoms." << endl);
    20512051                start = clock();
    20522052                LCList = new LinkedCell(Boundary, atof(argv[argptr])*2.);
     
    21152115            case 'R':
    21162116              if (ExitFlag == 0) ExitFlag = 1;
    2117               if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])))  {
     2117              if ((argptr+3 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])))  {
    21182118                ExitFlag = 255;
    2119                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl);
     2119                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <x> <y> <z> <distance>" << endl);
    21202120                performCriticalExit();
    21212121              } else {
    21222122                SaveFlag = true;
    2123                 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl);
    2124                 double tmp1 = atof(argv[argptr+1]);
    2125                 atom *third = mol->FindAtom(atoi(argv[argptr]));
    2126                 atom *first = mol->start;
    2127                 if ((third != NULL) && (first != mol->end)) {
    2128                   atom *second = first->next;
    2129                   while(second != mol->end) {
    2130                     first = second;
    2131                     second = first->next;
    2132                     if (first->x.DistanceSquared(third->x) > tmp1*tmp1) {// distance to first above radius ...
    2133                       mol->RemoveAtom(first);
    2134                     }
     2123                const double radius = atof(argv[argptr+3]);
     2124                Vector point(atof(argv[argptr]),atof(argv[argptr+1]),atof(argv[argptr+2]));
     2125                DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point << " with radius " << radius << "." << endl);
     2126                atom *Walker = NULL;
     2127                molecule::iterator advancer = mol->begin();
     2128                for(molecule::iterator iter = advancer; advancer != mol->end();) {
     2129                  iter = advancer++;
     2130                  if ((*iter)->x.DistanceSquared(point) > radius*radius){ // distance to first above radius ...
     2131                    Walker = (*iter);
     2132                    DoLog(1) && (Log() << Verbose(1) << "Removing atom " << *Walker << "." << endl);
     2133                    mol->RemoveAtom(*(iter));
     2134                    World::getInstance().destroyAtom(Walker);
    21352135                  }
    2136                 } else {
    2137                   DoeLog(1) && (eLog()<< Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl);
    21382136                }
    2139                 argptr+=2;
     2137                argptr+=4;
    21402138              }
    21412139              break;
     
    22622260                performCriticalExit();
    22632261              } else {
     2262                mol->getAtomCount();
    22642263                SaveFlag = true;
    22652264                DoLog(1) && (Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl);
     
    23812380                    faktor = 1;
    23822381                  }
    2383                   mol->CountAtoms();  // recount atoms
    2384                   if (mol->AtomCount != 0) {  // if there is more than none
    2385                     count = mol->AtomCount;   // is changed becausing of adding, thus has to be stored away beforehand
     2382                  if (mol->getAtomCount() != 0) {  // if there is more than none
     2383                    count = mol->getAtomCount();   // is changed becausing of adding, thus has to be stored away beforehand
    23862384                    Elements = new const element *[count];
    23872385                    vectors = new Vector *[count];
    23882386                    j = 0;
    2389                     first = mol->start;
    2390                     while (first->next != mol->end) {  // make a list of all atoms with coordinates and element
    2391                       first = first->next;
    2392                       Elements[j] = first->type;
    2393                       vectors[j] = &first->x;
     2387                    for(molecule::iterator iter = mol->begin();iter!=mol->end();++iter){
     2388                      Elements[j] = (*iter)->type;
     2389                      vectors[j] = &(*iter)->x;
    23942390                      j++;
    23952391                    }
     
    24582454{
    24592455    config *configuration = World::getInstance().getConfig();
     2456    // while we are non interactive, we want to abort from asserts
     2457    //ASSERT_DO(Assert::Abort);
     2458    molecule *mol = NULL;
    24602459    Vector x, y, z, n;
    24612460    ifstream test;
     
    24812480    // need to init the history before any action is created
    24822481    ActionHistory::init();
     2482
     2483    // In the interactive mode, we can leave the user the choice in case of error
     2484    ASSERT_DO(Assert::Ask);
    24832485
    24842486    // from this moment on, we need to be sure to deeinitialize in the correct order
  • src/config.cpp

    r42af9e r1024cb  
    15481548  int AtomNo = -1;
    15491549  int MolNo = 0;
    1550   atom *Walker = NULL;
    15511550  FILE *f = NULL;
    15521551
     
    15611560  fprintf(f, "# Created by MoleCuilder\n");
    15621561
    1563   for (MoleculeList::const_iterator Runner = MolList->ListOfMolecules.begin(); Runner != MolList->ListOfMolecules.end(); Runner++) {
    1564     Walker = (*Runner)->start;
     1562  for (MoleculeList::const_iterator MolRunner = MolList->ListOfMolecules.begin(); MolRunner != MolList->ListOfMolecules.end(); MolRunner++) {
    15651563    int *elementNo = new int[MAX_ELEMENTS];
    15661564    for (int i=0;i<MAX_ELEMENTS;i++)
    15671565      elementNo[i] = 0;
    15681566    AtomNo = 0;
    1569     while (Walker->next != (*Runner)->end) {
    1570       Walker = Walker->next;
    1571       sprintf(name, "%2s%2d",Walker->type->symbol, elementNo[Walker->type->Z]);
    1572       elementNo[Walker->type->Z] = (elementNo[Walker->type->Z]+1) % 100;   // confine to two digits
     1567    for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) {
     1568      sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]);
     1569      elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100;   // confine to two digits
    15731570      fprintf(f,
    15741571             "ATOM %6u %-4s %4s%c%4u    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s\n",
    1575              Walker->nr,                /* atom serial number */
     1572             (*iter)->nr,                /* atom serial number */
    15761573             name,         /* atom name */
    1577              (*Runner)->name,      /* residue name */
     1574             (*MolRunner)->name,      /* residue name */
    15781575             'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
    15791576             MolNo,         /* residue sequence number */
    1580              Walker->node->at(0),                 /* position X in Angstroem */
    1581              Walker->node->at(1),                 /* position Y in Angstroem */
    1582              Walker->node->at(2),                 /* position Z in Angstroem */
    1583              (double)Walker->type->Valence,         /* occupancy */
    1584              (double)Walker->type->NoValenceOrbitals,          /* temperature factor */
     1577             (*iter)->node->at(0),                 /* position X in Angstroem */
     1578             (*iter)->node->at(1),                 /* position Y in Angstroem */
     1579             (*iter)->node->at(2),                 /* position Z in Angstroem */
     1580             (double)(*iter)->type->Valence,         /* occupancy */
     1581             (double)(*iter)->type->NoValenceOrbitals,          /* temperature factor */
    15851582             "0",            /* segment identifier */
    1586              Walker->type->symbol,    /* element symbol */
     1583             (*iter)->type->symbol,    /* element symbol */
    15871584             "0");           /* charge */
    15881585      AtomNo++;
     
    16041601{
    16051602  int AtomNo = -1;
    1606   atom *Walker = NULL;
    16071603  FILE *f = NULL;
    16081604
     
    16211617  fprintf(f, "# Created by MoleCuilder\n");
    16221618
    1623   Walker = mol->start;
    16241619  AtomNo = 0;
    1625   while (Walker->next != mol->end) {
    1626     Walker = Walker->next;
    1627     sprintf(name, "%2s%2d",Walker->type->symbol, elementNo[Walker->type->Z]);
    1628     elementNo[Walker->type->Z] = (elementNo[Walker->type->Z]+1) % 100;   // confine to two digits
     1620  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1621    sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]);
     1622    elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100;   // confine to two digits
    16291623    fprintf(f,
    16301624           "ATOM %6u %-4s %4s%c%4u    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s\n",
    1631            Walker->nr,                /* atom serial number */
     1625           (*iter)->nr,                /* atom serial number */
    16321626           name,         /* atom name */
    16331627           mol->name,      /* residue name */
    16341628           'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
    16351629           0,         /* residue sequence number */
    1636            Walker->node->at(0),                 /* position X in Angstroem */
    1637            Walker->node->at(1),                 /* position Y in Angstroem */
    1638            Walker->node->at(2),                 /* position Z in Angstroem */
    1639            (double)Walker->type->Valence,         /* occupancy */
    1640            (double)Walker->type->NoValenceOrbitals,          /* temperature factor */
     1630           (*iter)->node->at(0),                 /* position X in Angstroem */
     1631           (*iter)->node->at(1),                 /* position Y in Angstroem */
     1632           (*iter)->node->at(2),                 /* position Z in Angstroem */
     1633           (double)(*iter)->type->Valence,         /* occupancy */
     1634           (double)(*iter)->type->NoValenceOrbitals,          /* temperature factor */
    16411635           "0",            /* segment identifier */
    1642            Walker->type->symbol,    /* element symbol */
     1636           (*iter)->type->symbol,    /* element symbol */
    16431637           "0");           /* charge */
    16441638    AtomNo++;
     
    16581652bool config::SaveTREMOLO(const char * const filename, const molecule * const mol) const
    16591653{
    1660   atom *Walker = NULL;
    16611654  ofstream *output = NULL;
    16621655  stringstream * const fname = new stringstream;
     
    16711664
    16721665  // scan maximum number of neighbours
    1673   Walker = mol->start;
    16741666  int MaxNeighbours = 0;
    1675   while (Walker->next != mol->end) {
    1676     Walker = Walker->next;
    1677     const int count = Walker->ListOfBonds.size();
     1667  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1668    const int count = (*iter)->ListOfBonds.size();
    16781669    if (MaxNeighbours < count)
    16791670      MaxNeighbours = count;
    16801671  }
    1681   *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl;
    1682 
    1683   Walker = mol->start;
    1684   while (Walker->next != mol->end) {
    1685     Walker = Walker->next;
    1686     *output << Walker->nr << "\t";
    1687     *output << Walker->getName() << "\t";
     1672  *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl;
     1673
     1674  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1675    *output << (*iter)->nr << "\t";
     1676    *output << (*iter)->getName() << "\t";
    16881677    *output << mol->name << "\t";
    16891678    *output << 0 << "\t";
    1690     *output << Walker->node->at(0) << "\t" << Walker->node->at(1) << "\t" << Walker->node->at(2) << "\t";
    1691     *output << static_cast<double>(Walker->type->Valence) << "\t";
    1692     *output << Walker->type->symbol << "\t";
    1693     for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)
    1694       *output << (*runner)->GetOtherAtom(Walker)->nr << "\t";
    1695     for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++)
     1679    *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t";
     1680    *output << static_cast<double>((*iter)->type->Valence) << "\t";
     1681    *output << (*iter)->type->symbol << "\t";
     1682    for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
     1683      *output << (*runner)->GetOtherAtom(*iter)->nr << "\t";
     1684    for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++)
    16961685      *output << "-\t";
    16971686    *output << endl;
     
    17141703{
    17151704  Info FunctionInfo(__func__);
    1716   atom *Walker = NULL;
    17171705  ofstream *output = NULL;
    17181706  stringstream * const fname = new stringstream;
     
    17291717  int MaxNeighbours = 0;
    17301718  for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
    1731     Walker = (*MolWalker)->start;
    1732     while (Walker->next != (*MolWalker)->end) {
    1733       Walker = Walker->next;
    1734       const int count = Walker->ListOfBonds.size();
     1719    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     1720      const int count = (*iter)->ListOfBonds.size();
    17351721      if (MaxNeighbours < count)
    17361722        MaxNeighbours = count;
    17371723    }
    17381724  }
    1739   *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl;
     1725  *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl;
    17401726
    17411727  // create global to local id map
     
    17451731    int AtomNo = 1;
    17461732    for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
    1747       atom *Walker = (*MolWalker)->start;
    1748       while (Walker->next != (*MolWalker)->end) {
    1749         Walker = Walker->next;
    1750         LocalNotoGlobalNoMap.insert( pair<int,int>(Walker->getId(), AtomNo++) );
     1733      for(molecule::iterator AtomRunner = (*MolWalker)->begin(); AtomRunner != (*MolWalker)->end(); ++AtomRunner) {
     1734        LocalNotoGlobalNoMap.insert( pair<int,int>((*AtomRunner)->getId(), AtomNo++) );
    17511735      }
    17521736      MolCounter++;
     
    17601744    int AtomNo = 0;
    17611745    for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
    1762       Walker = (*MolWalker)->start;
    1763       while (Walker->next != (*MolWalker)->end) {
    1764         Walker = Walker->next;
    1765         *output << LocalNotoGlobalNoMap[ Walker->getId() ] << "\t";
    1766         *output << Walker->getName() << "\t";
     1746      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     1747        *output << LocalNotoGlobalNoMap[ (*iter)->getId() ] << "\t";
     1748        *output << (*iter)->getName() << "\t";
    17671749        *output << (*MolWalker)->name << "\t";
    17681750        *output << MolCounter+1 << "\t";
    1769         *output << Walker->node->at(0) << "\t" << Walker->node->at(1) << "\t" << Walker->node->at(2) << "\t";
    1770         *output << (double)Walker->type->Valence << "\t";
    1771         *output << Walker->type->symbol << "\t";
    1772         for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)
    1773           *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom(Walker)->getId() ] << "\t";
    1774         for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++)
     1751        *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t";
     1752        *output << (double)(*iter)->type->Valence << "\t";
     1753        *output << (*iter)->type->symbol << "\t";
     1754        for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
     1755          *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t";
     1756        for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++)
    17751757          *output << "-\t";
    17761758        *output << endl;
     
    18131795  if (output == NULL)
    18141796    strcpy(filename,"main_pcp_linux");
    1815   Log() << Verbose(0) << "Saving as pdb input ";
     1797  Log() << Verbose(0) << "Saving as pdb input ... " << endl;
    18161798  if (SavePDB(filename, molecules))
    1817     Log() << Verbose(0) << "done." << endl;
     1799    Log() << Verbose(0) << "\t... done." << endl;
    18181800  else
    1819     Log() << Verbose(0) << "failed." << endl;
     1801    Log() << Verbose(0) << "\t... failed." << endl;
    18201802
    18211803  // then save as tremolo data file
     
    18241806  if (output == NULL)
    18251807    strcpy(filename,"main_pcp_linux");
    1826   Log() << Verbose(0) << "Saving as tremolo data input ";
     1808  Log() << Verbose(0) << "Saving as tremolo data input ... " << endl;
    18271809  if (SaveTREMOLO(filename, molecules))
    1828     Log() << Verbose(0) << "done." << endl;
     1810    Log() << Verbose(0) << "\t... done." << endl;
    18291811  else
    1830     Log() << Verbose(0) << "failed." << endl;
     1812    Log() << Verbose(0) << "\t... failed." << endl;
    18311813
    18321814  // translate each to its center and merge all molecules in MoleculeListClass into this molecule
     
    18641846  output.close();
    18651847  output.clear();
    1866   Log() << Verbose(0) << "Saving of config file ";
     1848  Log() << Verbose(0) << "Saving of config file ... " << endl;
    18671849  if (Save(filename, periode, mol))
    1868     Log() << Verbose(0) << "successful." << endl;
     1850    Log() << Verbose(0) << "\t... successful." << endl;
    18691851  else
    1870     Log() << Verbose(0) << "failed." << endl;
     1852    Log() << Verbose(0) << "\t... failed." << endl;
    18711853
    18721854  // and save to xyz file
     
    18811863    output.open(filename, ios::trunc);
    18821864  }
    1883   Log() << Verbose(0) << "Saving of XYZ file ";
     1865  Log() << Verbose(0) << "Saving of XYZ file ... " << endl;
    18841866  if (mol->MDSteps <= 1) {
    18851867    if (mol->OutputXYZ(&output))
    1886       Log() << Verbose(0) << "successful." << endl;
     1868      Log() << Verbose(0) << "\t... successful." << endl;
    18871869    else
    1888       Log() << Verbose(0) << "failed." << endl;
     1870      Log() << Verbose(0) << "\t... failed." << endl;
    18891871  } else {
    18901872    if (mol->OutputTrajectoriesXYZ(&output))
    1891       Log() << Verbose(0) << "successful." << endl;
     1873      Log() << Verbose(0) << "\t... successful." << endl;
    18921874    else
    1893       Log() << Verbose(0) << "failed." << endl;
     1875      Log() << Verbose(0) << "\t... failed." << endl;
    18941876  }
    18951877  output.close();
     
    19011883  if (output == NULL)
    19021884    strcpy(filename,"main_pcp_linux");
    1903   Log() << Verbose(0) << "Saving as mpqc input ";
     1885  Log() << Verbose(0) << "Saving as mpqc input .. " << endl;
    19041886  if (SaveMPQC(filename, mol))
    1905     Log() << Verbose(0) << "done." << endl;
     1887    Log() << Verbose(0) << "\t... done." << endl;
    19061888  else
    1907     Log() << Verbose(0) << "failed." << endl;
     1889    Log() << Verbose(0) << "\t... failed." << endl;
    19081890
    19091891  if (!strcmp(configpath, GetDefaultPath())) {
  • src/helpers.cpp

    r42af9e r1024cb  
    180180
    181181
    182 /** Allocates a memory range using malloc().
    183  * Prints the provided error message in case of a failure.
    184  *
    185  * \param number of memory slices of type X to allocate
    186  * \param failure message which is printed if the allocation fails
    187  * \return pointer to the allocated memory range, will be NULL if a failure occurred
    188  */
    189 template <> char* Malloc<char>(size_t size, const char* output)
    190 {
    191   char* buffer = NULL;
    192   buffer = (char*) malloc(sizeof(char) * (size + 1));
    193   for (size_t i = size; i--;)
    194     buffer[i] = (i % 2 == 0) ? 'p': 'c';
    195   buffer[size] = '\0';
    196 
    197   if (buffer != NULL) {
    198     //MemoryUsageObserver::getInstance()->addMemory(buffer, size);
    199   } else {
    200     Log() << Verbose(0) << "Malloc for datatype " << typeid(char).name()
    201       << " failed - pointer is NULL: " << output << endl;
    202   }
    203 
    204   return buffer;
    205 };
    206 
    207182/**
    208183 * Calls exit(255).
  • src/helpers.hpp

    r42af9e r1024cb  
    139139};
    140140
     141
    141142/** Frees a two-dimensional array.
    142143 * \param *ptr pointer to array
  • src/lists.hpp

    r42af9e r1024cb  
    134134};
    135135
    136 /** Returns the first marker in a chain list.
    137  * \param *me one arbitrary item in chain list
    138  * \return poiner to first marker
    139  */
    140 template <typename X> X *GetFirst(X *me)
    141 {
    142   X *Binder = me;
    143   while(Binder->previous != 0)
    144     Binder = Binder->previous;
    145   return Binder;
    146 };
    147 
    148 /** Returns the last marker in a chain list.
    149  * \param *me one arbitrary item in chain list
    150  * \return poiner to last marker
    151  */
    152 template <typename X> X *GetLast(X *me)
    153 {
    154   X *Binder = me;
    155   while(Binder->next != 0)
    156     Binder = Binder->next;
    157   return Binder;
    158 };
    159 
    160136#endif /* LISTS_HPP_ */
  • src/molecule.cpp

    r42af9e r1024cb  
    3535 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero.
    3636 */
    37 molecule::molecule(const periodentafel * const teil) : elemente(teil), start(World::getInstance().createAtom()), end(World::getInstance().createAtom()),
    38   first(new bond(start, end, 1, -1)), last(new bond(start, end, 1, -1)), MDSteps(0), AtomCount(0),
     37molecule::molecule(const periodentafel * const teil) : elemente(teil),
     38  first(new bond(0, 0, 1, -1)), last(new bond(0, 0, 1, -1)), MDSteps(0),
    3939  BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.),
    4040  ActiveFlag(false), IndexNr(-1),
    4141  formula(this,boost::bind(&molecule::calcFormula,this)),
    42   last_atom(0),
    43   InternalPointer(start)
    44 {
    45   // init atom chain list
    46   start->father = NULL;
    47   end->father = NULL;
    48   link(start,end);
    49 
     42  AtomCount(this,boost::bind(&molecule::doCountAtoms,this)), last_atom(0),  InternalPointer(begin())
     43{
    5044  // init bond chain list
    5145  link(first,last);
     
    6963  delete(first);
    7064  delete(last);
    71   end->getWorld()->destroyAtom(end);
    72   start->getWorld()->destroyAtom(start);
    7365};
    7466
     
    8173const std::string molecule::getName(){
    8274  return std::string(name);
     75}
     76
     77int molecule::getAtomCount() const{
     78  return *AtomCount;
    8379}
    8480
     
    104100  stringstream sstr;
    105101  periodentafel *periode = World::getInstance().getPeriode();
    106   for(atom *Walker = start; Walker != end; Walker = Walker->next) {
    107     counts[Walker->type->getNumber()]++;
     102  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     103    counts[(*iter)->type->getNumber()]++;
    108104  }
    109105  std::map<atomicNumber_t,unsigned int>::reverse_iterator iter;
     
    115111}
    116112
     113/************************** Access to the List of Atoms ****************/
     114
     115
     116molecule::iterator molecule::begin(){
     117  return molecule::iterator(atoms.begin(),this);
     118}
     119
     120molecule::const_iterator molecule::begin() const{
     121  return atoms.begin();
     122}
     123
     124molecule::iterator molecule::end(){
     125  return molecule::iterator(atoms.end(),this);
     126}
     127
     128molecule::const_iterator molecule::end() const{
     129  return atoms.end();
     130}
     131
     132bool molecule::empty() const
     133{
     134  return (begin() == end());
     135}
     136
     137size_t molecule::size() const
     138{
     139  size_t counter = 0;
     140  for (molecule::const_iterator iter = begin(); iter != end (); ++iter)
     141    counter++;
     142  return counter;
     143}
     144
     145molecule::const_iterator molecule::erase( const_iterator loc )
     146{
     147  molecule::const_iterator iter = loc;
     148  iter--;
     149  atoms.erase( loc );
     150  return iter;
     151}
     152
     153molecule::const_iterator molecule::erase( atom *& key )
     154{
     155  cout << "trying to erase atom" << endl;
     156  molecule::const_iterator iter = find(key);
     157  if (iter != end()){
     158    // remove this position and step forward (post-increment)
     159    atoms.erase( iter++ );
     160  }
     161  return iter;
     162}
     163
     164molecule::const_iterator molecule::find ( atom *& key ) const
     165{
     166  return atoms.find( key );
     167}
     168
     169pair<molecule::iterator,bool> molecule::insert ( atom * const key )
     170{
     171  pair<atomSet::iterator,bool> res = atoms.insert(key);
     172  return pair<iterator,bool>(iterator(res.first,this),res.second);
     173}
    117174
    118175/** Adds given atom \a *pointer from molecule list.
     
    123180bool molecule::AddAtom(atom *pointer)
    124181{
    125   bool retval = false;
    126182  OBSERVE;
    127183  if (pointer != NULL) {
    128184    pointer->sort = &pointer->nr;
    129     pointer->nr = last_atom++;  // increase number within molecule
    130     AtomCount++;
    131185    if (pointer->type != NULL) {
    132186      if (ElementsInMolecule[pointer->type->Z] == 0)
     
    141195      }
    142196    }
    143     retval = add(pointer, end);
    144   }
    145   return retval;
     197    insert(pointer);
     198  }
     199  return true;
    146200};
    147201
     
    157211  if (pointer != NULL) {
    158212    atom *walker = pointer->clone();
    159     stringstream sstr;
    160     sstr << pointer->getName();
    161     walker->setName(sstr.str());
     213    walker->setName(pointer->getName());
    162214    walker->nr = last_atom++;  // increase number within molecule
    163     add(walker, end);
     215    insert(walker);
    164216    if ((pointer->type != NULL) && (pointer->type->Z != 1))
    165217      NoNonHydrogen++;
    166     AtomCount++;
    167218    retval=walker;
    168219  }
     
    575626
    576627  // copy values
    577   copy->CountAtoms();
    578628  copy->CountElements();
    579629  if (first->next != last) {  // if adjaceny list is present
     
    610660{
    611661  bond *Binder = NULL;
    612   if ((atom1 != NULL) && (FindAtom(atom1->nr) != NULL) && (atom2 != NULL) && (FindAtom(atom2->nr) != NULL)) {
    613     Binder = new bond(atom1, atom2, degree, BondCount++);
    614     atom1->RegisterBond(Binder);
    615     atom2->RegisterBond(Binder);
    616     if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))
    617       NoNonBonds++;
    618     add(Binder, last);
    619   } else {
    620     DoeLog(1) && (eLog()<< Verbose(1) << "Could not add bond between " << atom1->getName() << " and " << atom2->getName() << " as one or both are not present in the molecule." << endl);
    621   }
     662
     663  // some checks to make sure we are able to create the bond
     664  ASSERT(atom1, "First atom in bond-creation was an invalid pointer");
     665  ASSERT(atom2, "Second atom in bond-creation was an invalid pointer");
     666  ASSERT(FindAtom(atom1->nr),"First atom in bond-creation was not part of molecule");
     667  ASSERT(FindAtom(atom2->nr),"Second atom in bond-creation was not parto of molecule");
     668
     669  Binder = new bond(atom1, atom2, degree, BondCount++);
     670  atom1->RegisterBond(Binder);
     671  atom2->RegisterBond(Binder);
     672  if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))
     673    NoNonBonds++;
     674  add(Binder, last);
     675
    622676  return Binder;
    623677};
     
    693747bool molecule::RemoveAtom(atom *pointer)
    694748{
     749  ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom().");
     750  OBSERVE;
    695751  if (ElementsInMolecule[pointer->type->Z] != 0)  { // this would indicate an error
    696752    ElementsInMolecule[pointer->type->Z]--;  // decrease number of atom of this element
    697     AtomCount--;
    698753  } else
    699754    DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->getName() << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl);
     
    701756    ElementCount--;
    702757  RemoveBonds(pointer);
    703   return remove(pointer, start, end);
     758  erase(pointer);
     759  return true;
    704760};
    705761
     
    718774  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    719775    ElementCount--;
    720   unlink(pointer);
     776  erase(pointer);
    721777  return true;
    722778};
     
    727783bool molecule::CleanupMolecule()
    728784{
    729   return (cleanup(first,last) && cleanup(start,end));
     785  for (molecule::iterator iter = begin(); !empty(); iter = begin())
     786      erase(iter);
     787  return (cleanup(first,last));
    730788};
    731789
     
    734792 * \return pointer to atom or NULL
    735793 */
    736 atom * molecule::FindAtom(int Nr)  const{
    737   atom * walker = find(&Nr, start,end);
    738   if (walker != NULL) {
     794atom * molecule::FindAtom(int Nr)  const
     795{
     796  molecule::const_iterator iter = begin();
     797  for (; iter != end(); ++iter)
     798    if ((*iter)->nr == Nr)
     799      break;
     800  if (iter != end()) {
    739801    //Log() << Verbose(0) << "Found Atom Nr. " << walker->nr << endl;
    740     return walker;
     802    return (*iter);
    741803  } else {
    742804    DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl);
     
    868930    now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
    869931    for (int step=0;step<MDSteps;step++) {
    870       *output << AtomCount << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now);
     932      *output << getAtomCount() << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now);
    871933      ActOnAllAtoms( &atom::OutputTrajectoryXYZ, output, step );
    872934    }
     
    885947  if (output != NULL) {
    886948    now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
    887     *output << AtomCount << "\n\tCreated by molecuilder on " << ctime(&now);
     949    *output << getAtomCount() << "\n\tCreated by molecuilder on " << ctime(&now);
    888950    ActOnAllAtoms( &atom::OutputXYZLine, output );
    889951    return true;
     
    895957 * \param *out output stream for debugging
    896958 */
    897 void molecule::CountAtoms()
    898 {
     959int molecule::doCountAtoms()
     960{
     961  int res = size();
    899962  int i = 0;
    900   atom *Walker = start;
    901   while (Walker->next != end) {
    902     Walker = Walker->next;
     963  NoNonHydrogen = 0;
     964  for (molecule::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
     965    (*iter)->nr = i;   // update number in molecule (for easier referencing in FragmentMolecule lateron)
     966    if ((*iter)->type->Z != 1) // count non-hydrogen atoms whilst at it
     967      NoNonHydrogen++;
     968    stringstream sstr;
     969    sstr << (*iter)->type->symbol << (*iter)->nr+1;
     970    (*iter)->setName(sstr.str());
     971    Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl;
    903972    i++;
    904973  }
    905   if ((AtomCount == 0) || (i != AtomCount)) {
    906     DoLog(3) && (Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl);
    907     AtomCount = i;
    908 
    909     // count NonHydrogen atoms and give each atom a unique name
    910     if (AtomCount != 0) {
    911       i=0;
    912       NoNonHydrogen = 0;
    913       Walker = start;
    914       while (Walker->next != end) {
    915         Walker = Walker->next;
    916         Walker->nr = i;   // update number in molecule (for easier referencing in FragmentMolecule lateron)
    917         if (Walker->type->Z != 1) // count non-hydrogen atoms whilst at it
    918           NoNonHydrogen++;
    919         stringstream sstr;
    920         sstr << Walker->type->symbol << Walker->nr+1;
    921         Walker->setName(sstr.str());
    922         DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->getName() << "." << endl);
    923         i++;
    924       }
    925     } else
    926       DoLog(3) && (Log() << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl);
    927   }
     974  return res;
    928975};
    929976
     
    9871034  /// first count both their atoms and elements and update lists thereby ...
    9881035  //Log() << Verbose(0) << "Counting atoms, updating list" << endl;
    989   CountAtoms();
    990   OtherMolecule->CountAtoms();
    9911036  CountElements();
    9921037  OtherMolecule->CountElements();
     
    9951040  /// -# AtomCount
    9961041  if (result) {
    997     if (AtomCount != OtherMolecule->AtomCount) {
    998       DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl);
     1042    if (getAtomCount() != OtherMolecule->getAtomCount()) {
     1043      DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl);
    9991044      result = false;
    1000     } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
     1045    } else Log() << Verbose(4) << "AtomCounts match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl;
    10011046  }
    10021047  /// -# ElementCount
     
    10351080  if (result) {
    10361081    DoLog(5) && (Log() << Verbose(5) << "Calculating distances" << endl);
    1037     Distances = new double[AtomCount];
    1038     OtherDistances = new double[AtomCount];
     1082    Distances = new double[getAtomCount()];
     1083    OtherDistances = new double[getAtomCount()];
    10391084    SetIndexedArrayForEachAtomTo ( Distances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity);
    10401085    SetIndexedArrayForEachAtomTo ( OtherDistances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity);
    1041     for(int i=0;i<AtomCount;i++) {
     1086    for(int i=0;i<getAtomCount();i++) {
    10421087      Distances[i] = 0.;
    10431088      OtherDistances[i] = 0.;
     
    10461091    /// ... sort each list (using heapsort (o(N log N)) from GSL)
    10471092    DoLog(5) && (Log() << Verbose(5) << "Sorting distances" << endl);
    1048     PermMap = new size_t[AtomCount];
    1049     OtherPermMap = new size_t[AtomCount];
    1050     for(int i=0;i<AtomCount;i++) {
     1093    PermMap = new size_t[getAtomCount()];
     1094    OtherPermMap = new size_t[getAtomCount()];
     1095    for(int i=0;i<getAtomCount();i++) {
    10511096      PermMap[i] = 0;
    10521097      OtherPermMap[i] = 0;
    10531098    }
    1054     gsl_heapsort_index (PermMap, Distances, AtomCount, sizeof(double), CompareDoubles);
    1055     gsl_heapsort_index (OtherPermMap, OtherDistances, AtomCount, sizeof(double), CompareDoubles);
    1056     PermutationMap = new int[AtomCount];
    1057     for(int i=0;i<AtomCount;i++)
     1099    gsl_heapsort_index (PermMap, Distances, getAtomCount(), sizeof(double), CompareDoubles);
     1100    gsl_heapsort_index (OtherPermMap, OtherDistances, getAtomCount(), sizeof(double), CompareDoubles);
     1101    PermutationMap = new int[getAtomCount()];
     1102    for(int i=0;i<getAtomCount();i++)
    10581103      PermutationMap[i] = 0;
    10591104    DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl);
    1060     for(int i=AtomCount;i--;)
     1105    for(int i=getAtomCount();i--;)
    10611106      PermutationMap[PermMap[i]] = (int) OtherPermMap[i];
    10621107
     
    10641109    DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl);
    10651110    flag = 0;
    1066     for (int i=0;i<AtomCount;i++) {
     1111    for (int i=0;i<getAtomCount();i++) {
    10671112      DoLog(5) && (Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " <<  threshold << endl);
    10681113      if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold)
     
    11001145int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule)
    11011146{
    1102   atom *Walker = NULL, *OtherWalker = NULL;
    11031147  DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl);
    1104   int *AtomicMap = new int[AtomCount];
    1105   for (int i=AtomCount;i--;)
     1148  int *AtomicMap = new int[getAtomCount()];
     1149  for (int i=getAtomCount();i--;)
    11061150    AtomicMap[i] = -1;
    11071151  if (OtherMolecule == this) {  // same molecule
    1108     for (int i=AtomCount;i--;) // no need as -1 means already that there is trivial correspondence
     1152    for (int i=getAtomCount();i--;) // no need as -1 means already that there is trivial correspondence
    11091153      AtomicMap[i] = i;
    11101154    DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl);
    11111155  } else {
    11121156    DoLog(4) && (Log() << Verbose(4) << "Map is ");
    1113     Walker = start;
    1114     while (Walker->next != end) {
    1115       Walker = Walker->next;
    1116       if (Walker->father == NULL) {
    1117         AtomicMap[Walker->nr] = -2;
     1157    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     1158      if ((*iter)->father == NULL) {
     1159        AtomicMap[(*iter)->nr] = -2;
    11181160      } else {
    1119         OtherWalker = OtherMolecule->start;
    1120         while (OtherWalker->next != OtherMolecule->end) {
    1121           OtherWalker = OtherWalker->next;
     1161        for (molecule::const_iterator runner = OtherMolecule->begin(); runner != OtherMolecule->end(); ++runner) {
    11221162      //for (int i=0;i<AtomCount;i++) { // search atom
    1123         //for (int j=0;j<OtherMolecule->AtomCount;j++) {
    1124           //Log() << Verbose(4) << "Comparing father " << Walker->father << " with the other one " << OtherWalker->father << "." << endl;
    1125           if (Walker->father == OtherWalker)
    1126             AtomicMap[Walker->nr] = OtherWalker->nr;
     1163        //for (int j=0;j<OtherMolecule->getAtomCount();j++) {
     1164          //Log() << Verbose(4) << "Comparing father " << (*iter)->father << " with the other one " << (*runner)->father << "." << endl;
     1165          if ((*iter)->father == (*runner))
     1166            AtomicMap[(*iter)->nr] = (*runner)->nr;
    11271167        }
    11281168      }
    1129       DoLog(0) && (Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t");
     1169      DoLog(0) && (Log() << Verbose(0) << AtomicMap[(*iter)->nr] << "\t");
    11301170    }
    11311171    DoLog(0) && (Log() << Verbose(0) << endl);
     
    11611201void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) const
    11621202{
    1163   atom *Walker = start;
    1164   while (Walker->next != end) {
    1165     Walker = Walker->next;
    1166     array[(Walker->*index)] = Walker;
     1203  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     1204    array[((*iter)->*index)] = (*iter);
    11671205  }
    11681206};
  • src/molecule.hpp

    r42af9e r1024cb  
    3434#include "tesselation.hpp"
    3535#include "Patterns/Observer.hpp"
     36#include "Patterns/ObservedIterator.hpp"
    3637#include "Patterns/Cacheable.hpp"
    3738
     
    9091  friend molecule *NewMolecule();
    9192  friend void DeleteMolecule(molecule *);
     93
    9294  public:
     95    typedef std::set<atom*> atomSet;
     96    typedef ObservedIterator<atomSet> iterator;
     97    typedef atomSet::const_iterator const_iterator;
     98
    9399    const periodentafel * const elemente; //!< periodic table with each element
    94     atom *start;        //!< start of atom list
    95     atom *end;          //!< end of atom list
     100    // old deprecated atom handling
     101    //atom *start;        //!< start of atom list
     102    //atom *end;          //!< end of atom list
    96103    bond *first;        //!< start of bond list
    97104    bond *last;         //!< end of bond list
    98105    int MDSteps;        //!< The number of MD steps in Trajectories
    99     int AtomCount;          //!< number of atoms, brought up-to-date by CountAtoms()
     106    //int AtomCount;          //!< number of atoms, brought up-to-date by CountAtoms()
    100107    int BondCount;          //!< number of atoms, brought up-to-date by CountBonds()
    101108    int ElementCount;       //!< how many unique elements are therein
     
    112119  private:
    113120    Cacheable<string> formula;
     121    Cacheable<int>    AtomCount;
    114122    moleculeId_t id;
     123    atomSet atoms; //<!set of atoms
    115124  protected:
     125    //void CountAtoms();
     126    /**
     127     * this iterator type should be used for internal variables, \
     128     * since it will not lock
     129     */
     130    typedef atomSet::iterator internal_iterator;
     131
     132
    116133    molecule(const periodentafel * const teil);
    117134    virtual ~molecule();
     
    121138  //getter and setter
    122139  const std::string getName();
     140  int getAtomCount() const;
     141  int doCountAtoms();
    123142  moleculeId_t getId();
    124143  void setId(moleculeId_t);
     
    127146  std::string calcFormula();
    128147
     148  iterator begin();
     149  const_iterator begin() const;
     150  iterator end();
     151  const_iterator end() const;
     152  bool empty() const;
     153  size_t size() const;
     154  const_iterator erase( const_iterator loc );
     155  const_iterator erase( atom *& key );
     156  const_iterator find (  atom *& key ) const;
     157  pair<iterator,bool> insert ( atom * const key );
     158
    129159
    130160  // re-definition of virtual functions from PointCloud
     
    132162  Vector *GetCenter() const ;
    133163  TesselPoint *GetPoint() const ;
    134   TesselPoint *GetTerminalPoint() const ;
    135164  int GetMaxId() const;
    136165  void GoToNext() const ;
    137   void GoToPrevious() const ;
    138166  void GoToFirst() const ;
    139   void GoToLast() const ;
    140167  bool IsEmpty() const ;
    141168  bool IsEnd() const ;
     
    232259
    233260  /// Count and change present atoms' coordination.
    234   void CountAtoms();
    235261  void CountElements();
    236262  void CalculateOrbitals(class config &configuration);
     
    302328  bool StoreForcesFile(MoleculeListClass *BondFragments, char *path, int *SortIndex);
    303329  bool CreateMappingLabelsToConfigSequence(int *&SortIndex);
     330  bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
    304331  void BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem);
    305332  /// -# BOSSANOVA
     
    330357  private:
    331358  int last_atom;      //!< number given to last atom
    332   mutable atom *InternalPointer;  //!< internal pointer for PointCloud
     359  mutable internal_iterator InternalPointer;  //!< internal pointer for PointCloud
    333360};
    334361
  • src/molecule_dynamics.cpp

    r42af9e r1024cb  
    2929  gsl_matrix *A = gsl_matrix_alloc(NDIM,NDIM);
    3030  gsl_vector *x = gsl_vector_alloc(NDIM);
    31   atom * Runner = mol->start;
    3231  atom *Sprinter = NULL;
    3332  Vector trajectory1, trajectory2, normal, TestVector;
    3433  double Norm1, Norm2, tmp, result = 0.;
    3534
    36   while (Runner->next != mol->end) {
    37     Runner = Runner->next;
    38     if (Runner == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++)
     35  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     36    if ((*iter) == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++)
    3937      break;
    4038    // determine normalized trajectories direction vector (n1, n2)
     
    4341    trajectory1.Normalize();
    4442    Norm1 = trajectory1.Norm();
    45     Sprinter = Params.PermutationMap[Runner->nr];   // find second target point
    46     trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Runner->Trajectory.R.at(Params.startstep);
     43    Sprinter = Params.PermutationMap[(*iter)->nr];   // find second target point
     44    trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep);
    4745    trajectory2.Normalize();
    4846    Norm2 = trajectory1.Norm();
    4947    // check whether either is zero()
    5048    if ((Norm1 < MYEPSILON) && (Norm2 < MYEPSILON)) {
    51       tmp = Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.startstep));
     49      tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep));
    5250    } else if (Norm1 < MYEPSILON) {
    5351      Sprinter = Params.PermutationMap[Walker->nr];   // find first target point
    54       trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - Runner->Trajectory.R.at(Params.startstep);
     52      trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep);
    5553      trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything
    5654      trajectory1 -= trajectory2;   // project the part in norm direction away
    5755      tmp = trajectory1.Norm();  // remaining norm is distance
    5856    } else if (Norm2 < MYEPSILON) {
    59       Sprinter = Params.PermutationMap[Runner->nr];   // find second target point
     57      Sprinter = Params.PermutationMap[(*iter)->nr];   // find second target point
    6058      trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep);  // copy second offset
    6159      trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything
     
    6765  //        Log() << Verbose(0) << " and ";
    6866  //        Log() << Verbose(0) << trajectory2;
    69       tmp = Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.startstep));
     67      tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep));
    7068  //        Log() << Verbose(0) << " with distance " << tmp << "." << endl;
    7169    } else { // determine distance by finding minimum distance
    72   //        Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *Runner << " are linear independent ";
     70  //        Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *(*iter) << " are linear independent ";
    7371  //        Log() << Verbose(0) << endl;
    7472  //        Log() << Verbose(0) << "First Trajectory: ";
     
    8684        gsl_matrix_set(A, 1, i, trajectory2[i]);
    8785        gsl_matrix_set(A, 2, i, normal[i]);
    88         gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep)[i] - Runner->Trajectory.R.at(Params.startstep)[i]));
     86        gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep)[i] - (*iter)->Trajectory.R.at(Params.startstep)[i]));
    8987      }
    9088      // solve the linear system by Householder transformations
     
    9795      trajectory2.Scale(gsl_vector_get(x,1));
    9896      normal.Scale(gsl_vector_get(x,2));
    99       TestVector = Runner->Trajectory.R.at(Params.startstep) + trajectory2 + normal
     97      TestVector = (*iter)->Trajectory.R.at(Params.startstep) + trajectory2 + normal
    10098                   - (Walker->Trajectory.R.at(Params.startstep) + trajectory1);
    10199      if (TestVector.Norm() < MYEPSILON) {
     
    126124{
    127125  double result = 0.;
    128   atom * Runner = mol->start;
    129   while (Runner->next != mol->end) {
    130     Runner = Runner->next;
    131     if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[Runner->nr]) && (Walker->nr < Runner->nr)) {
     126  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     127    if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[(*iter)->nr]) && (Walker->nr < (*iter)->nr)) {
    132128  //    atom *Sprinter = PermutationMap[Walker->nr];
    133   //        Log() << Verbose(0) << *Walker << " and " << *Runner << " are heading to the same target at ";
     129  //        Log() << Verbose(0) << *Walker << " and " << *(*iter) << " are heading to the same target at ";
    134130  //        Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep);
    135131  //        Log() << Verbose(0) << ", penalting." << endl;
     
    162158  // go through every atom
    163159  atom *Runner = NULL;
    164   atom *Walker = start;
    165   while (Walker->next != end) {
    166     Walker = Walker->next;
     160  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    167161    // first term: distance to target
    168     Runner = Params.PermutationMap[Walker->nr];   // find target point
    169     tmp = (Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)));
     162    Runner = Params.PermutationMap[(*iter)->nr];   // find target point
     163    tmp = ((*iter)->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)));
    170164    tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem;
    171165    result += Params.PenaltyConstants[0] * tmp;
     
    173167
    174168    // second term: sum of distances to other trajectories
    175     result += SumDistanceOfTrajectories(Walker, this, Params);
     169    result += SumDistanceOfTrajectories((*iter), this, Params);
    176170
    177171    // third term: penalty for equal targets
    178     result += PenalizeEqualTargets(Walker, this, Params);
     172    result += PenalizeEqualTargets((*iter), this, Params);
    179173  }
    180174
     
    216210void FillDistanceList(molecule *mol, struct EvaluatePotential &Params)
    217211{
    218   for (int i=mol->AtomCount; i--;) {
     212  for (int i=mol->getAtomCount(); i--;) {
    219213    Params.DistanceList[i] = new DistanceMap;    // is the distance sorted target list per atom
    220214    Params.DistanceList[i]->clear();
    221215  }
    222216
    223   atom *Runner = NULL;
    224   atom *Walker = mol->start;
    225   while (Walker->next != mol->end) {
    226     Walker = Walker->next;
    227     Runner = mol->start;
    228     while(Runner->next != mol->end) {
    229       Runner = Runner->next;
    230       Params.DistanceList[Walker->nr]->insert( DistancePair(Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)), Runner) );
     217  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     218    for (molecule::const_iterator runner = mol->begin(); runner != mol->end(); ++runner) {
     219      Params.DistanceList[(*iter)->nr]->insert( DistancePair((*iter)->Trajectory.R.at(Params.startstep).distance((*runner)->Trajectory.R.at(Params.endstep)), (*runner)) );
    231220    }
    232221  }
     
    240229void CreateInitialLists(molecule *mol, struct EvaluatePotential &Params)
    241230{
    242   atom *Walker = mol->start;
    243   while (Walker->next != mol->end) {
    244     Walker = Walker->next;
    245     Params.StepList[Walker->nr] = Params.DistanceList[Walker->nr]->begin();    // stores the step to the next iterator that could be a possible next target
    246     Params.PermutationMap[Walker->nr] = Params.DistanceList[Walker->nr]->begin()->second;   // always pick target with the smallest distance
    247     Params.DoubleList[Params.DistanceList[Walker->nr]->begin()->second->nr]++;            // increase this target's source count (>1? not injective)
    248     Params.DistanceIterators[Walker->nr] = Params.DistanceList[Walker->nr]->begin();    // and remember which one we picked
    249     DoLog(2) && (Log() << Verbose(2) << *Walker << " starts with distance " << Params.DistanceList[Walker->nr]->begin()->first << "." << endl);
     231  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     232    Params.StepList[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin();    // stores the step to the next iterator that could be a possible next target
     233    Params.PermutationMap[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin()->second;   // always pick target with the smallest distance
     234    Params.DoubleList[Params.DistanceList[(*iter)->nr]->begin()->second->nr]++;            // increase this target's source count (>1? not injective)
     235    Params.DistanceIterators[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin();    // and remember which one we picked
     236    DoLog(2) && (Log() << Verbose(2) << **iter << " starts with distance " << Params.DistanceList[(*iter)->nr]->begin()->first << "." << endl);
    250237  }
    251238};
     
    288275void MakeInjectivePermutation(molecule *mol, struct EvaluatePotential &Params)
    289276{
    290   atom *Walker = mol->start;
     277  molecule::const_iterator iter = mol->begin();
    291278  DistanceMap::iterator NewBase;
    292279  double Potential = fabs(mol->ConstrainedPotential(Params));
    293280
     281  if (mol->empty()) {
     282    eLog() << Verbose(1) << "Molecule is empty." << endl;
     283    return;
     284  }
    294285  while ((Potential) > Params.PenaltyConstants[2]) {
    295     PrintPermutationMap(mol->AtomCount, Params);
    296     Walker = Walker->next;
    297     if (Walker == mol->end) // round-robin at the end
    298       Walker = mol->start->next;
    299     if (Params.DoubleList[Params.DistanceIterators[Walker->nr]->second->nr] <= 1)  // no need to make those injective that aren't
     286    PrintPermutationMap(mol->getAtomCount(), Params);
     287    iter++;
     288    if (iter == mol->end()) // round-robin at the end
     289      iter = mol->begin();
     290    if (Params.DoubleList[Params.DistanceIterators[(*iter)->nr]->second->nr] <= 1)  // no need to make those injective that aren't
    300291      continue;
    301292    // now, try finding a new one
    302     Potential = TryNextNearestNeighbourForInjectivePermutation(mol, Walker, Potential, Params);
    303   }
    304   for (int i=mol->AtomCount; i--;) // now each single entry in the DoubleList should be <=1
     293    Potential = TryNextNearestNeighbourForInjectivePermutation(mol, (*iter), Potential, Params);
     294  }
     295  for (int i=mol->getAtomCount(); i--;) // now each single entry in the DoubleList should be <=1
    305296    if (Params.DoubleList[i] > 1) {
    306297      DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl);
     
    341332  double Potential, OldPotential, OlderPotential;
    342333  struct EvaluatePotential Params;
    343   Params.PermutationMap = new atom *[AtomCount];
    344   Params.DistanceList = new DistanceMap *[AtomCount];
    345   Params.DistanceIterators = new DistanceMap::iterator[AtomCount];
    346   Params.DoubleList = new int[AtomCount];
    347   Params.StepList = new DistanceMap::iterator[AtomCount];
     334  Params.PermutationMap = new atom *[getAtomCount()];
     335  Params.DistanceList = new DistanceMap *[getAtomCount()];
     336  Params.DistanceIterators = new DistanceMap::iterator[getAtomCount()];
     337  Params.DoubleList = new int[getAtomCount()];
     338  Params.StepList = new DistanceMap::iterator[getAtomCount()];
    348339  int round;
    349   atom *Walker = NULL, *Runner = NULL, *Sprinter = NULL;
     340  atom *Sprinter = NULL;
    350341  DistanceMap::iterator Rider, Strider;
    351342
    352343  // set to zero
    353   for (int i=0;i<AtomCount;i++) {
     344  for (int i=0;i<getAtomCount();i++) {
    354345    Params.PermutationMap[i] = NULL;
    355346    Params.DoubleList[i] = 0;
     
    380371    DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl);
    381372    OlderPotential = OldPotential;
     373    molecule::const_iterator iter;
    382374    do {
    383       Walker = start;
    384       while (Walker->next != end) { // pick one
    385         Walker = Walker->next;
    386         PrintPermutationMap(AtomCount, Params);
    387         Sprinter = Params.DistanceIterators[Walker->nr]->second;   // store initial partner
    388         Strider = Params.DistanceIterators[Walker->nr];  //remember old iterator
    389         Params.DistanceIterators[Walker->nr] = Params.StepList[Walker->nr];
    390         if (Params.DistanceIterators[Walker->nr] == Params.DistanceList[Walker->nr]->end()) {// stop, before we run through the list and still on
    391           Params.DistanceIterators[Walker->nr] == Params.DistanceList[Walker->nr]->begin();
     375      iter = begin();
     376      for (; iter != end(); ++iter) {
     377        PrintPermutationMap(getAtomCount(), Params);
     378        Sprinter = Params.DistanceIterators[(*iter)->nr]->second;   // store initial partner
     379        Strider = Params.DistanceIterators[(*iter)->nr];  //remember old iterator
     380        Params.DistanceIterators[(*iter)->nr] = Params.StepList[(*iter)->nr];
     381        if (Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->end()) {// stop, before we run through the list and still on
     382          Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->begin();
    392383          break;
    393384        }
    394         //Log() << Verbose(2) << "Current Walker: " << *Walker << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[Walker->nr]->second << "." << endl;
     385        //Log() << Verbose(2) << "Current Walker: " << *(*iter) << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[(*iter)->nr]->second << "." << endl;
    395386        // find source of the new target
    396         Runner = start->next;
    397         while(Runner != end) { // find the source whose toes we might be stepping on (Walker's new target should be in use by another already)
    398           if (Params.PermutationMap[Runner->nr] == Params.DistanceIterators[Walker->nr]->second) {
    399             //Log() << Verbose(2) << "Found the corresponding owner " << *Runner << " to " << *PermutationMap[Runner->nr] << "." << endl;
     387        molecule::const_iterator runner = begin();
     388        for (; runner != end(); ++runner) { // find the source whose toes we might be stepping on (Walker's new target should be in use by another already)
     389          if (Params.PermutationMap[(*runner)->nr] == Params.DistanceIterators[(*iter)->nr]->second) {
     390            //Log() << Verbose(2) << "Found the corresponding owner " << *(*runner) << " to " << *PermutationMap[(*runner)->nr] << "." << endl;
    400391            break;
    401392          }
    402           Runner = Runner->next;
    403393        }
    404         if (Runner != end) { // we found the other source
     394        if (runner != end()) { // we found the other source
    405395          // then look in its distance list for Sprinter
    406           Rider = Params.DistanceList[Runner->nr]->begin();
    407           for (; Rider != Params.DistanceList[Runner->nr]->end(); Rider++)
     396          Rider = Params.DistanceList[(*runner)->nr]->begin();
     397          for (; Rider != Params.DistanceList[(*runner)->nr]->end(); Rider++)
    408398            if (Rider->second == Sprinter)
    409399              break;
    410           if (Rider != Params.DistanceList[Runner->nr]->end()) { // if we have found one
    411             //Log() << Verbose(2) << "Current Other: " << *Runner << " with old/next candidate " << *PermutationMap[Runner->nr] << "/" << *Rider->second << "." << endl;
     400          if (Rider != Params.DistanceList[(*runner)->nr]->end()) { // if we have found one
     401            //Log() << Verbose(2) << "Current Other: " << *(*runner) << " with old/next candidate " << *PermutationMap[(*runner)->nr] << "/" << *Rider->second << "." << endl;
    412402            // exchange both
    413             Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // put next farther distance into PermutationMap
    414             Params.PermutationMap[Runner->nr] = Sprinter;  // and hand the old target to its respective owner
    415             PrintPermutationMap(AtomCount, Params);
     403            Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // put next farther distance into PermutationMap
     404            Params.PermutationMap[(*runner)->nr] = Sprinter;  // and hand the old target to its respective owner
     405            PrintPermutationMap(getAtomCount(), Params);
    416406            // calculate the new potential
    417407            //Log() << Verbose(2) << "Checking new potential ..." << endl;
     
    419409            if (Potential > OldPotential) { // we made everything worse! Undo ...
    420410              //Log() << Verbose(3) << "Nay, made the potential worse: " << Potential << " vs. " << OldPotential << "!" << endl;
    421               //Log() << Verbose(3) << "Setting " << *Runner << "'s source to " << *Params.DistanceIterators[Runner->nr]->second << "." << endl;
     411              //Log() << Verbose(3) << "Setting " << *(*runner) << "'s source to " << *Params.DistanceIterators[(*runner)->nr]->second << "." << endl;
    422412              // Undo for Runner (note, we haven't moved the iteration yet, we may use this)
    423               Params.PermutationMap[Runner->nr] = Params.DistanceIterators[Runner->nr]->second;
     413              Params.PermutationMap[(*runner)->nr] = Params.DistanceIterators[(*runner)->nr]->second;
    424414              // Undo for Walker
    425               Params.DistanceIterators[Walker->nr] = Strider;  // take next farther distance target
    426               //Log() << Verbose(3) << "Setting " << *Walker << "'s source to " << *Params.DistanceIterators[Walker->nr]->second << "." << endl;
    427               Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second;
     415              Params.DistanceIterators[(*iter)->nr] = Strider;  // take next farther distance target
     416              //Log() << Verbose(3) << "Setting " << *(*iter) << "'s source to " << *Params.DistanceIterators[(*iter)->nr]->second << "." << endl;
     417              Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second;
    428418            } else {
    429               Params.DistanceIterators[Runner->nr] = Rider;  // if successful also move the pointer in the iterator list
     419              Params.DistanceIterators[(*runner)->nr] = Rider;  // if successful also move the pointer in the iterator list
    430420              DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl);
    431421              OldPotential = Potential;
     
    437427            //Log() << Verbose(0) << endl;
    438428          } else {
    439             DoeLog(1) && (eLog()<< Verbose(1) << *Runner << " was not the owner of " << *Sprinter << "!" << endl);
     429            DoeLog(1) && (eLog()<< Verbose(1) << **runner << " was not the owner of " << *Sprinter << "!" << endl);
    440430            exit(255);
    441431          }
    442432        } else {
    443           Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // new target has no source!
     433          Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // new target has no source!
    444434        }
    445         Params.StepList[Walker->nr]++; // take next farther distance target
     435        Params.StepList[(*iter)->nr]++; // take next farther distance target
    446436      }
    447     } while (Walker->next != end);
     437    } while (++iter != end());
    448438  } while ((OlderPotential - OldPotential) > 1e-3);
    449439  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     
    451441
    452442  /// free memory and return with evaluated potential
    453   for (int i=AtomCount; i--;)
     443  for (int i=getAtomCount(); i--;)
    454444    Params.DistanceList[i]->clear();
    455445  delete[](Params.DistanceList);
     
    492482  // Get the Permutation Map by MinimiseConstrainedPotential
    493483  atom **PermutationMap = NULL;
    494   atom *Walker = NULL, *Sprinter = NULL;
     484  atom *Sprinter = NULL;
    495485  if (!MapByIdentity)
    496486    MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem());
    497487  else {
    498     PermutationMap = new atom *[AtomCount];
     488    PermutationMap = new atom *[getAtomCount()];
    499489    SetIndexedArrayForEachAtomTo( PermutationMap, &atom::nr );
    500490  }
     
    511501    mol = World::getInstance().createMolecule();
    512502    MoleculePerStep->insert(mol);
    513     Walker = start;
    514     while (Walker->next != end) {
    515       Walker = Walker->next;
     503    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    516504      // add to molecule list
    517       Sprinter = mol->AddCopyAtom(Walker);
     505      Sprinter = mol->AddCopyAtom((*iter));
    518506      for (int n=NDIM;n--;) {
    519         Sprinter->x[n] = Walker->Trajectory.R.at(startstep)[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep)[n] - Walker->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
     507        Sprinter->x[n] = (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
    520508        // add to Trajectories
    521509        //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
    522510        if (step < MaxSteps) {
    523           Walker->Trajectory.R.at(step)[n] = Walker->Trajectory.R.at(startstep)[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep)[n] - Walker->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
    524           Walker->Trajectory.U.at(step)[n] = 0.;
    525           Walker->Trajectory.F.at(step)[n] = 0.;
     511          (*iter)->Trajectory.R.at(step)[n] = (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
     512          (*iter)->Trajectory.U.at(step)[n] = 0.;
     513          (*iter)->Trajectory.F.at(step)[n] = 0.;
    526514        }
    527515      }
     
    531519
    532520  // store the list to single step files
    533   int *SortIndex = new int[AtomCount];
    534   for (int i=AtomCount; i--; )
     521  int *SortIndex = new int[getAtomCount()];
     522  for (int i=getAtomCount(); i--; )
    535523    SortIndex[i] = i;
    536524  status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex);
     
    578566      return false;
    579567    }
    580     if (Force.RowCounter[0] != AtomCount) {
    581       DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount << "." << endl);
     568    if (Force.RowCounter[0] != getAtomCount()) {
     569      DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << getAtomCount() << "." << endl);
    582570      performCriticalExit();
    583571      return false;
     
    585573    // correct Forces
    586574    Velocity.Zero();
    587     for(int i=0;i<AtomCount;i++)
     575    for(int i=0;i<getAtomCount();i++)
    588576      for(int d=0;d<NDIM;d++) {
    589577        Velocity[d] += Force.Matrix[0][i][d+5];
    590578      }
    591     for(int i=0;i<AtomCount;i++)
     579    for(int i=0;i<getAtomCount();i++)
    592580      for(int d=0;d<NDIM;d++) {
    593         Force.Matrix[0][i][d+5] -= Velocity[d]/(double)AtomCount;
     581        Force.Matrix[0][i][d+5] -= Velocity[d]/static_cast<double>(getAtomCount());
    594582      }
    595583    // solve a constrained potential if we are meant to
     
    694682      delta_alpha = 0.;
    695683      ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha );
    696       delta_alpha = (delta_alpha - (3.*AtomCount+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass);
     684      delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass);
    697685      configuration.alpha += delta_alpha*configuration.Deltat;
    698686      DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl);
  • src/molecule_fragmentation.cpp

    r42af9e r1024cb  
    3939  int FragmentCount;
    4040  // get maximum bond degree
    41   atom *Walker = start;
    42   while (Walker->next != end) {
    43     Walker = Walker->next;
    44     c = (Walker->ListOfBonds.size() > c) ? Walker->ListOfBonds.size() : c;
     41  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     42    c = ((*iter)->ListOfBonds.size() > c) ? (*iter)->ListOfBonds.size() : c;
    4543  }
    4644  FragmentCount = NoNonHydrogen*(1 << (c*order));
     
    353351map<double, pair<int,int> >  * ReMapAdaptiveCriteriaListToValue(map<int, pair<double,int> > *AdaptiveCriteriaList, molecule *mol)
    354352{
    355   atom *Walker = mol->start;
     353  atom *Walker = NULL;
    356354  map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ;
    357355  DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl);
     
    385383bool MarkUpdateCandidates(bool *AtomMask, map<double, pair<int,int> > &FinalRootCandidates, int Order, molecule *mol)
    386384{
    387   atom *Walker = mol->start;
     385  atom *Walker = NULL;
    388386  int No = -1;
    389387  bool status = false;
     
    429427bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path)
    430428{
    431   atom *Walker = start;
    432429  bool status = false;
    433430
    434431  // initialize mask list
    435   for(int i=AtomCount;i--;)
     432  for(int i=getAtomCount();i--;)
    436433    AtomMask[i] = false;
    437434
    438435  if (Order < 0) { // adaptive increase of BondOrder per site
    439     if (AtomMask[AtomCount] == true)  // break after one step
     436    if (AtomMask[getAtomCount()] == true)  // break after one step
    440437      return false;
    441438
     
    451448    if (AdaptiveCriteriaList->empty()) {
    452449      DoeLog(2) && (eLog()<< Verbose(2) << "Unable to parse file, incrementing all." << endl);
    453       while (Walker->next != end) {
    454         Walker = Walker->next;
     450      for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    455451    #ifdef ADDHYDROGEN
    456         if (Walker->type->Z != 1) // skip hydrogen
     452        if ((*iter)->type->Z != 1) // skip hydrogen
    457453    #endif
    458454        {
    459           AtomMask[Walker->nr] = true;  // include all (non-hydrogen) atoms
     455          AtomMask[(*iter)->nr] = true;  // include all (non-hydrogen) atoms
    460456          status = true;
    461457        }
     
    472468    delete[](FinalRootCandidates);
    473469  } else { // global increase of Bond Order
    474     while (Walker->next != end) {
    475       Walker = Walker->next;
     470    for(molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    476471  #ifdef ADDHYDROGEN
    477       if (Walker->type->Z != 1) // skip hydrogen
     472      if ((*iter)->type->Z != 1) // skip hydrogen
    478473  #endif
    479474      {
    480         AtomMask[Walker->nr] = true;  // include all (non-hydrogen) atoms
    481         if ((Order != 0) && (Walker->AdaptiveOrder < Order)) // && (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]))
     475        AtomMask[(*iter)->nr] = true;  // include all (non-hydrogen) atoms
     476        if ((Order != 0) && ((*iter)->AdaptiveOrder < Order)) // && ((*iter)->AdaptiveOrder < MinimumRingSize[(*iter)->nr]))
    482477          status = true;
    483478      }
    484479    }
    485     if ((Order == 0) && (AtomMask[AtomCount] == false))  // single stepping, just check
     480    if ((!Order) && (!AtomMask[getAtomCount()]))  // single stepping, just check
    486481      status = true;
    487482
     
    494489  }
    495490
    496   PrintAtomMask(AtomMask, AtomCount); // for debugging
     491  PrintAtomMask(AtomMask, getAtomCount()); // for debugging
    497492
    498493  return status;
     
    510505    return false;
    511506  }
    512   SortIndex = new int[AtomCount];
    513   for(int i=AtomCount;i--;)
     507  SortIndex = new int[getAtomCount()];
     508  for(int i=getAtomCount();i--;)
    514509    SortIndex[i] = -1;
    515510
     
    518513
    519514  return true;
     515};
     516
     517
     518
     519/** Creates a lookup table for true father's Atom::Nr -> atom ptr.
     520 * \param *start begin of list (STL iterator, i.e. first item)
     521 * \paran *end end of list (STL iterator, i.e. one past last item)
     522 * \param **Lookuptable pointer to return allocated lookup table (should be NULL on start)
     523 * \param count optional predetermined size for table (otherwise we set the count to highest true father id)
     524 * \return true - success, false - failure
     525 */
     526bool molecule::CreateFatherLookupTable(atom **&LookupTable, int count)
     527{
     528  bool status = true;
     529  int AtomNo;
     530
     531  if (LookupTable != NULL) {
     532    Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl;
     533    return false;
     534  }
     535
     536  // count them
     537  if (count == 0) {
     538    for (molecule::iterator iter = begin(); iter != end(); ++iter) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
     539      count = (count < (*iter)->GetTrueFather()->nr) ? (*iter)->GetTrueFather()->nr : count;
     540    }
     541  }
     542  if (count <= 0) {
     543    Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl;
     544    return false;
     545  }
     546
     547  // allocate and fill
     548  LookupTable = new atom *[count];
     549  if (LookupTable == NULL) {
     550    eLog() << Verbose(0) << "LookupTable memory allocation failed!" << endl;
     551    performCriticalExit();
     552    status = false;
     553  } else {
     554    for (int i=0;i<count;i++)
     555      LookupTable[i] = NULL;
     556    for (molecule::iterator iter = begin(); iter != end(); ++iter) {
     557      AtomNo = (*iter)->GetTrueFather()->nr;
     558      if ((AtomNo >= 0) && (AtomNo < count)) {
     559        //*out << "Setting LookupTable[" << AtomNo << "] to " << *(*iter) << endl;
     560        LookupTable[AtomNo] = (*iter);
     561      } else {
     562        Log() << Verbose(0) << "Walker " << *(*iter) << " exceeded range of nuclear ids [0, " << count << ")." << endl;
     563        status = false;
     564        break;
     565      }
     566    }
     567  }
     568
     569  return status;
    520570};
    521571
     
    541591{
    542592  MoleculeListClass *BondFragments = NULL;
    543   int *MinimumRingSize = new int[AtomCount];
     593  int *MinimumRingSize = new int[getAtomCount()];
    544594  int FragmentCounter;
    545595  MoleculeLeafClass *MolecularWalker = NULL;
     
    569619
    570620  // create lookup table for Atom::nr
    571   FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(start, end, ListOfAtoms, AtomCount);
     621  FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, getAtomCount());
    572622
    573623  // === compare it with adjacency file ===
     
    579629
    580630  // analysis of the cycles (print rings, get minimum cycle length) for each subgraph
    581   for(int i=AtomCount;i--;)
    582     MinimumRingSize[i] = AtomCount;
     631  for(int i=getAtomCount();i--;)
     632    MinimumRingSize[i] = getAtomCount();
    583633  MolecularWalker = Subgraphs;
    584634  FragmentCounter = 0;
     
    586636    MolecularWalker = MolecularWalker->next;
    587637    // fill the bond structure of the individually stored subgraphs
    588   MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false);  // we want to keep the created ListOfLocalAtoms
     638    MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false);  // we want to keep the created ListOfLocalAtoms
    589639    DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    590640    LocalBackEdgeStack = new StackClass<bond *> (MolecularWalker->Leaf->BondCount);
    591641//    // check the list of local atoms for debugging
    592642//    Log() << Verbose(0) << "ListOfLocalAtoms for this subgraph is:" << endl;
    593 //    for (int i=0;i<AtomCount;i++)
     643//    for (int i=0;i<getAtomCount();i++)
    594644//      if (ListOfLocalAtoms[FragmentCounter][i] == NULL)
    595645//        Log() << Verbose(0) << "\tNULL";
     
    617667  // ===== 6b. prepare and go into the adaptive (Order<0), single-step (Order==0) or incremental (Order>0) cycle
    618668  KeyStack *RootStack = new KeyStack[Subgraphs->next->Count()];
    619   AtomMask = new bool[AtomCount+1];
    620   AtomMask[AtomCount] = false;
     669  AtomMask = new bool[getAtomCount()+1];
     670  AtomMask[getAtomCount()] = false;
    621671  FragmentationToDo = false;  // if CheckOrderAtSite just ones recommends fragmentation, we will save fragments afterwards
    622672  while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, configuration->configpath))) {
    623673    FragmentationToDo = FragmentationToDo || CheckOrder;
    624     AtomMask[AtomCount] = true;   // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite()
     674    AtomMask[getAtomCount()] = true;   // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite()
    625675    // ===== 6b. fill RootStack for each subgraph (second adaptivity check) =====
    626676    Subgraphs->next->FillRootStackForSubgraphs(RootStack, AtomMask, (FragmentCounter = 0));
     
    762812bool molecule::ParseOrderAtSiteFromFile(char *path)
    763813{
    764   unsigned char *OrderArray = new unsigned char[AtomCount];
    765   bool *MaxArray = new bool[AtomCount];
     814  unsigned char *OrderArray = new unsigned char[getAtomCount()];
     815  bool *MaxArray = new bool[getAtomCount()];
    766816  bool status;
    767817  int AtomNr, value;
     
    769819  ifstream file;
    770820
    771   for(int i=0;i<AtomCount;i++) {
     821  for(int i=0;i<getAtomCount();i++) {
    772822    OrderArray[i] = 0;
    773823    MaxArray[i] = false;
     
    871921  atom *OtherFather = NULL;
    872922  atom *FatherOfRunner = NULL;
    873   Leaf->CountAtoms();
    874 
    875   atom *Runner = Leaf->start;
    876   while (Runner->next != Leaf->end) {
    877     Runner = Runner->next;
     923
     924#ifdef ADDHYDROGEN
     925  molecule::const_iterator runner;
     926#endif
     927  // we increment the iter just before skipping the hydrogen
     928  for (molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end();) {
    878929    LonelyFlag = true;
    879     FatherOfRunner = Runner->father;
     930    FatherOfRunner = (*iter)->father;
     931    ASSERT(FatherOfRunner,"Atom without father found");
    880932    if (SonList[FatherOfRunner->nr] != NULL)  {  // check if this, our father, is present in list
    881933      // create all bonds
     
    888940//            Log() << Verbose(3) << "Adding Bond: ";
    889941//            Log() << Verbose(0) <<
    890             Leaf->AddBond(Runner, SonList[OtherFather->nr], (*BondRunner)->BondDegree);
     942            Leaf->AddBond((*iter), SonList[OtherFather->nr], (*BondRunner)->BondDegree);
    891943//            Log() << Verbose(0) << "." << endl;
    892             //NumBonds[Runner->nr]++;
     944            //NumBonds[(*iter)->nr]++;
    893945          } else {
    894946//            Log() << Verbose(3) << "Not adding bond, labels in wrong order." << endl;
     
    898950//          Log() << Verbose(0) << ", who has no son in this fragment molecule." << endl;
    899951#ifdef ADDHYDROGEN
    900           //Log() << Verbose(3) << "Adding Hydrogen to " << Runner->Name << " and a bond in between." << endl;
    901           if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), Runner, FatherOfRunner, OtherFather, IsAngstroem))
     952          //Log() << Verbose(3) << "Adding Hydrogen to " << (*iter)->Name << " and a bond in between." << endl;
     953          if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), (*iter), FatherOfRunner, OtherFather, IsAngstroem))
    902954            exit(1);
    903955#endif
    904           //NumBonds[Runner->nr] += Binder->BondDegree;
     956          //NumBonds[(*iter)->nr] += Binder->BondDegree;
    905957        }
    906958      }
    907959    } else {
    908       DoeLog(1) && (eLog()<< Verbose(1) << "Son " << Runner->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl);
    909     }
    910     if ((LonelyFlag) && (Leaf->AtomCount > 1)) {
    911       DoLog(0) && (Log() << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl);
    912     }
     960    DoeLog(1) && (eLog()<< Verbose(1) << "Son " << (*iter)->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl);
     961    }
     962    if ((LonelyFlag) && (Leaf->getAtomCount() > 1)) {
     963      DoLog(0) && (Log() << Verbose(0) << **iter << "has got bonds only to hydrogens!" << endl);
     964    }
     965    ++iter;
    913966#ifdef ADDHYDROGEN
    914     while ((Runner->next != Leaf->end) && (Runner->next->type->Z == 1)) // skip added hydrogen
    915       Runner = Runner->next;
     967    while ((iter != Leaf->end()) && ((*iter)->type->Z == 1)){ // skip added hydrogen
     968      iter++;
     969    }
    916970#endif
    917971  }
     
    928982molecule * molecule::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem)
    929983{
    930   atom **SonList = new atom*[AtomCount];
     984  atom **SonList = new atom*[getAtomCount()];
    931985  molecule *Leaf = World::getInstance().createMolecule();
    932986
    933   for(int i=0;i<AtomCount;i++)
     987  for(int i=0;i<getAtomCount();i++)
    934988    SonList[i] = NULL;
    935989
     
    15611615  FragmentSearch.FragmentSet = new KeySet;
    15621616  FragmentSearch.Root = FindAtom(RootKeyNr);
    1563   FragmentSearch.ShortestPathList = new int[AtomCount];
    1564   for (int i=AtomCount;i--;) {
     1617  FragmentSearch.ShortestPathList = new int[getAtomCount()];
     1618  for (int i=getAtomCount();i--;) {
    15651619    FragmentSearch.ShortestPathList[i] = -1;
    15661620  }
    15671621
    15681622  // Construct the complete KeySet which we need for topmost level only (but for all Roots)
    1569   atom *Walker = start;
    15701623  KeySet CompleteMolecule;
    1571   while (Walker->next != end) {
    1572     Walker = Walker->next;
    1573     CompleteMolecule.insert(Walker->GetTrueFather()->nr);
     1624  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     1625    CompleteMolecule.insert((*iter)->GetTrueFather()->nr);
    15741626  }
    15751627
     
    15821634    RootKeyNr = RootStack.front();
    15831635    RootStack.pop_front();
    1584     Walker = FindAtom(RootKeyNr);
     1636    atom *Walker = FindAtom(RootKeyNr);
    15851637    // check cyclic lengths
    15861638    //if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) {
     
    16711723  Vector Translationvector;
    16721724  //class StackClass<atom *> *CompStack = NULL;
    1673   class StackClass<atom *> *AtomStack = new StackClass<atom *>(AtomCount);
     1725  class StackClass<atom *> *AtomStack = new StackClass<atom *>(getAtomCount());
    16741726  bool flag = true;
    16751727
    16761728  DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl);
    16771729
    1678   ColorList = new enum Shading[AtomCount];
    1679   for (int i=0;i<AtomCount;i++)
     1730  ColorList = new enum Shading[getAtomCount()];
     1731  for (int i=0;i<getAtomCount();i++)
    16801732    ColorList[i] = (enum Shading)0;
    16811733  while (flag) {
    16821734    // remove bonds that are beyond bonddistance
    1683     for(int i=NDIM;i--;)
    1684       Translationvector[i] = 0.;
     1735    Translationvector.Zero();
    16851736    // scan all bonds
    16861737    Binder = first;
     
    17111762      Log() << Verbose(0) << Translationvector <<  endl;
    17121763      // apply to all atoms of first component via BFS
    1713       for (int i=AtomCount;i--;)
     1764      for (int i=getAtomCount();i--;)
    17141765        ColorList[i] = white;
    17151766      AtomStack->Push(Binder->leftatom);
     
    17351786    //delete(CompStack);
    17361787  }
    1737 
    17381788  // free allocated space from ReturnFullMatrixforSymmetric()
    17391789  delete(AtomStack);
  • src/molecule_geometry.cpp

    r42af9e r1024cb  
    7171
    7272//  Log() << Verbose(3) << "Begin of CenterEdge." << endl;
    73   atom *ptr = start->next;  // start at first in list
    74   if (ptr != end) {  //list not empty?
     73  molecule::const_iterator iter = begin();  // start at first in list
     74  if (iter != end()) { //list not empty?
    7575    for (int i=NDIM;i--;) {
    76       max->at(i) = ptr->x[i];
    77       min->at(i) = ptr->x[i];
    78     }
    79     while (ptr->next != end) {  // continue with second if present
    80       ptr = ptr->next;
    81       //ptr->Output(1,1,out);
     76      max->at(i) = (*iter)->x[i];
     77      min->at(i) = (*iter)->x[i];
     78    }
     79    for (; iter != end(); ++iter) {// continue with second if present
     80      //(*iter)->Output(1,1,out);
    8281      for (int i=NDIM;i--;) {
    83         max->at(i) = (max->at(i) < ptr->x[i]) ? ptr->x[i] : max->at(i);
    84         min->at(i) = (min->at(i) > ptr->x[i]) ? ptr->x[i] : min->at(i);
     82        max->at(i) = (max->at(i) < (*iter)->x[i]) ? (*iter)->x[i] : max->at(i);
     83        min->at(i) = (min->at(i) > (*iter)->x[i]) ? (*iter)->x[i] : min->at(i);
    8584      }
    8685    }
     
    106105{
    107106  int Num = 0;
    108   atom *ptr = start;  // start at first in list
     107  molecule::const_iterator iter = begin();  // start at first in list
    109108
    110109  Center.Zero();
    111110
    112   if (ptr->next != end) {   //list not empty?
    113     while (ptr->next != end) {
    114       ptr = ptr->next;
     111  if (iter != end()) {   //list not empty?
     112    for (; iter != end(); ++iter) {  // continue with second if present
    115113      Num++;
    116       Center += ptr->x;
     114      Center += (*iter)->x;
    117115    }
    118116    Center.Scale(-1./Num); // divide through total number (and sign for direction)
     
    127125Vector * molecule::DetermineCenterOfAll() const
    128126{
    129   atom *ptr = start;  // start at first in list
     127  molecule::const_iterator iter = begin();  // start at first in list
    130128  Vector *a = new Vector();
    131129  double Num = 0;
     
    133131  a->Zero();
    134132
    135   if (ptr->next != end) {   //list not empty?
    136     while (ptr->next != end) {
    137       ptr = ptr->next;
     133  if (iter != end()) {   //list not empty?
     134    for (; iter != end(); ++iter) {  // continue with second if present
    138135      Num += 1.;
    139       (*a) += ptr->x;
     136      (*a) += (*iter)->x;
    140137    }
    141138    a->Scale(1./Num); // divide through total mass (and sign for direction)
     
    165162Vector * molecule::DetermineCenterOfGravity()
    166163{
    167   atom *ptr = start->next;  // start at first in list
     164  molecule::const_iterator iter = begin();  // start at first in list
    168165  Vector *a = new Vector();
    169166  Vector tmp;
     
    172169  a->Zero();
    173170
    174   if (ptr != end) {   //list not empty?
    175     while (ptr->next != end) {  // continue with second if present
    176       ptr = ptr->next;
    177       Num += ptr->type->mass;
    178       tmp = ptr->type->mass * ptr->x;
     171  if (iter != end()) {   //list not empty?
     172    for (; iter != end(); ++iter) {  // continue with second if present
     173      Num += (*iter)->type->mass;
     174      tmp = (*iter)->type->mass * (*iter)->x;
    179175      (*a) += tmp;
    180176    }
     
    217213void molecule::Scale(const double ** const factor)
    218214{
    219   atom *ptr = start;
    220 
    221   while (ptr->next != end) {
    222     ptr = ptr->next;
     215  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    223216    for (int j=0;j<MDSteps;j++)
    224       ptr->Trajectory.R.at(j).ScaleAll(*factor);
    225     ptr->x.ScaleAll(*factor);
     217      (*iter)->Trajectory.R.at(j).ScaleAll(*factor);
     218    (*iter)->x.ScaleAll(*factor);
    226219  }
    227220};
     
    232225void molecule::Translate(const Vector *trans)
    233226{
    234   atom *ptr = start;
    235 
    236   while (ptr->next != end) {
    237     ptr = ptr->next;
     227  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    238228    for (int j=0;j<MDSteps;j++)
    239       ptr->Trajectory.R.at(j) += (*trans);
    240     ptr->x += (*trans);
     229      (*iter)->Trajectory.R.at(j) += (*trans);
     230    (*iter)->x += (*trans);
    241231  }
    242232};
     
    274264void molecule::DeterminePeriodicCenter(Vector &center)
    275265{
    276   atom *Walker = start;
    277266  double * const cell_size = World::getInstance().getDomain();
    278267  double *matrix = ReturnFullMatrixforSymmetric(cell_size);
     
    285274    Center.Zero();
    286275    flag = true;
    287     while (Walker->next != end) {
    288       Walker = Walker->next;
     276    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    289277#ifdef ADDHYDROGEN
    290       if (Walker->type->Z != 1) {
     278      if ((*iter)->type->Z != 1) {
    291279#endif
    292         Testvector = Walker->x;
     280        Testvector = (*iter)->x;
    293281        Testvector.MatrixMultiplication(inversematrix);
    294282        Translationvector.Zero();
    295         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    296          if (Walker->nr < (*Runner)->GetOtherAtom(Walker)->nr) // otherwise we shift one to, the other fro and gain nothing
     283        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     284         if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing
    297285            for (int j=0;j<NDIM;j++) {
    298               tmp = Walker->x[j] - (*Runner)->GetOtherAtom(Walker)->x[j];
     286              tmp = (*iter)->x[j] - (*Runner)->GetOtherAtom(*iter)->x[j];
    299287              if ((fabs(tmp)) > BondDistance) {
    300288                flag = false;
    301                 DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << Walker->getName() << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl);
     289                DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << (*iter)->getName() << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl);
    302290                if (tmp > 0)
    303291                  Translationvector[j] -= 1.;
     
    313301#ifdef ADDHYDROGEN
    314302        // now also change all hydrogens
    315         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    316           if ((*Runner)->GetOtherAtom(Walker)->type->Z == 1) {
    317             Testvector = (*Runner)->GetOtherAtom(Walker)->x;
     303        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     304          if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) {
     305            Testvector = (*Runner)->GetOtherAtom((*iter))->x;
    318306            Testvector.MatrixMultiplication(inversematrix);
    319307            Testvector += Translationvector;
     
    330318  delete[](inversematrix);
    331319
    332   Center.Scale(1./(double)AtomCount);
     320  Center.Scale(1./static_cast<double>(getAtomCount()));
    333321};
    334322
     
    340328void molecule::PrincipalAxisSystem(bool DoRotate)
    341329{
    342   atom *ptr = start;  // start at first in list
    343330  double InertiaTensor[NDIM*NDIM];
    344331  Vector *CenterOfGravity = DetermineCenterOfGravity();
     
    351338
    352339  // sum up inertia tensor
    353   while (ptr->next != end) {
    354     ptr = ptr->next;
    355     Vector x = ptr->x;
     340  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     341    Vector x = (*iter)->x;
    356342    //x.SubtractVector(CenterOfGravity);
    357     InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]);
    358     InertiaTensor[1] += ptr->type->mass*(-x[0]*x[1]);
    359     InertiaTensor[2] += ptr->type->mass*(-x[0]*x[2]);
    360     InertiaTensor[3] += ptr->type->mass*(-x[1]*x[0]);
    361     InertiaTensor[4] += ptr->type->mass*(x[0]*x[0] + x[2]*x[2]);
    362     InertiaTensor[5] += ptr->type->mass*(-x[1]*x[2]);
    363     InertiaTensor[6] += ptr->type->mass*(-x[2]*x[0]);
    364     InertiaTensor[7] += ptr->type->mass*(-x[2]*x[1]);
    365     InertiaTensor[8] += ptr->type->mass*(x[0]*x[0] + x[1]*x[1]);
     343    InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]);
     344    InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]);
     345    InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]);
     346    InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]);
     347    InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]);
     348    InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]);
     349    InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]);
     350    InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]);
     351    InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]);
    366352  }
    367353  // print InertiaTensor for debugging
     
    401387
    402388    // sum up inertia tensor
    403     ptr = start;
    404     while (ptr->next != end) {
    405       ptr = ptr->next;
    406       Vector x = ptr->x;
    407       //x.SubtractVector(CenterOfGravity);
    408       InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]);
    409       InertiaTensor[1] += ptr->type->mass*(-x[0]*x[1]);
    410       InertiaTensor[2] += ptr->type->mass*(-x[0]*x[2]);
    411       InertiaTensor[3] += ptr->type->mass*(-x[1]*x[0]);
    412       InertiaTensor[4] += ptr->type->mass*(x[0]*x[0] + x[2]*x[2]);
    413       InertiaTensor[5] += ptr->type->mass*(-x[1]*x[2]);
    414       InertiaTensor[6] += ptr->type->mass*(-x[2]*x[0]);
    415       InertiaTensor[7] += ptr->type->mass*(-x[2]*x[1]);
    416       InertiaTensor[8] += ptr->type->mass*(x[0]*x[0] + x[1]*x[1]);
     389    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     390      Vector x = (*iter)->x;
     391      InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]);
     392      InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]);
     393      InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]);
     394      InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]);
     395      InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]);
     396      InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]);
     397      InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]);
     398      InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]);
     399      InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]);
    417400    }
    418401    // print InertiaTensor for debugging
     
    438421void molecule::Align(Vector *n)
    439422{
    440   atom *ptr = start;
    441423  double alpha, tmp;
    442424  Vector z_axis;
     
    449431  alpha = atan(-n->at(0)/n->at(2));
    450432  DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... ");
    451   while (ptr->next != end) {
    452     ptr = ptr->next;
    453     tmp = ptr->x[0];
    454     ptr->x[0] =  cos(alpha) * tmp + sin(alpha) * ptr->x[2];
    455     ptr->x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x[2];
     433  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     434    tmp = (*iter)->x[0];
     435    (*iter)->x[0] =  cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];
     436    (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];
    456437    for (int j=0;j<MDSteps;j++) {
    457       tmp = ptr->Trajectory.R.at(j)[0];
    458       ptr->Trajectory.R.at(j)[0] =  cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j)[2];
    459       ptr->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j)[2];
     438      tmp = (*iter)->Trajectory.R.at(j)[0];
     439      (*iter)->Trajectory.R.at(j)[0] =  cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2];
     440      (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2];
    460441    }
    461442  }
     
    467448
    468449  // rotate on z-y plane
    469   ptr = start;
    470450  alpha = atan(-n->at(1)/n->at(2));
    471451  DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... ");
    472   while (ptr->next != end) {
    473     ptr = ptr->next;
    474     tmp = ptr->x[1];
    475     ptr->x[1] =  cos(alpha) * tmp + sin(alpha) * ptr->x[2];
    476     ptr->x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x[2];
     452  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     453    tmp = (*iter)->x[1];
     454    (*iter)->x[1] =  cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];
     455    (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];
    477456    for (int j=0;j<MDSteps;j++) {
    478       tmp = ptr->Trajectory.R.at(j)[1];
    479       ptr->Trajectory.R.at(j)[1] =  cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j)[2];
    480       ptr->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j)[2];
     457      tmp = (*iter)->Trajectory.R.at(j)[1];
     458      (*iter)->Trajectory.R.at(j)[1] =  cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2];
     459      (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2];
    481460    }
    482461  }
     
    502481  Vector a,b,c,d;
    503482  struct lsq_params *par = (struct lsq_params *)params;
    504   atom *ptr = par->mol->start;
    505483
    506484  // initialize vectors
     
    512490  b[2] = gsl_vector_get(x,5);
    513491  // go through all atoms
    514   while (ptr != par->mol->end) {
    515     ptr = ptr->next;
    516     if (ptr->type == ((struct lsq_params *)params)->type) { // for specific type
    517       c = ptr->x - a;
     492  for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) {
     493    if ((*iter)->type == ((struct lsq_params *)params)->type) { // for specific type
     494      c = (*iter)->x - a;
    518495      t = c.ScalarProduct(b);           // get direction parameter
    519496      d = t*b;       // and create vector
  • src/molecule_graph.cpp

    r42af9e r1024cb  
    2020#include "World.hpp"
    2121#include "Helpers/fast_functions.hpp"
     22#include "Helpers/Assert.hpp"
     23
    2224
    2325struct BFSAccounting
     
    8082      flip(atom1, atom2);
    8183    Walker = FindAtom(atom1);
     84    ASSERT(Walker,"Could not find an atom with the ID given in dbond file");
    8285    OtherWalker = FindAtom(atom2);
     86    ASSERT(OtherWalker,"Could not find an atom with the ID given in dbond file");
    8387    AddBond(Walker, OtherWalker); //Add the bond between the two atoms with respective indices.
    8488  }
     
    109113  atom *Walker = NULL;
    110114  atom *OtherWalker = NULL;
    111   atom **AtomMap = NULL;
    112115  int n[NDIM];
    113116  double MinDistance, MaxDistance;
     
    134137
    135138  // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering)
    136   CountAtoms();
    137   DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl);
    138 
    139   if ((AtomCount > 1) && (bonddistance > 1.)) {
     139  DoLog(1) && (Log() << Verbose(1) << "AtomCount " << getAtomCount() << " and bonddistance is " << bonddistance << "." << endl);
     140
     141  if ((getAtomCount() > 1) && (bonddistance > 1.)) {
    140142    DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl);
    141143    LC = new LinkedCell(this, bonddistance);
     
    143145    // create a list to map Tesselpoint::nr to atom *
    144146    DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl);
    145     AtomMap = new atom *[AtomCount];
    146     for (int i=0;i<AtomCount;i++)
    147       AtomMap[i] = NULL;
    148     Walker = start;
    149     while (Walker->next != end) {
    150       Walker = Walker->next;
    151       AtomMap[Walker->nr] = Walker;
     147
     148    // set numbers for atoms that can later be used
     149    int i=0;
     150    for(internal_iterator iter = atoms.begin();iter!= atoms.end(); ++iter){
     151      (*iter)->nr = i++;
    152152    }
    153153
     
    161161          if (List != NULL) {
    162162            for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    163               Walker = AtomMap[(*Runner)->nr];
    164 //              Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
     163              Walker = dynamic_cast<atom*>(*Runner);
     164              ASSERT(Walker,"Tesselpoint that was not an atom retrieved from LinkedNode");
     165              //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
    165166              // 3c. check for possible bond between each atom in this and every one in the 27 cells
    166167              for (n[0] = -1; n[0] <= 1; n[0]++)
     
    172173                      for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
    173174                        if ((*OtherRunner)->nr > Walker->nr) {
    174                           OtherWalker = AtomMap[(*OtherRunner)->nr];
    175 //                          Log() << Verbose(0) << "Current other Atom is " << *OtherWalker << "." << endl;
    176                           const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x, cell_size);
    177 //                          Log() << Verbose(1) << "Checking distance " << distance << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
     175                          OtherWalker = dynamic_cast<atom*>(*OtherRunner);
     176                          ASSERT(OtherWalker,"TesselPoint that was not an atom retrieved from LinkedNode");
     177                          //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
    178178                          (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
     179                          const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size);
    179180                          const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
    180181//                          Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl;
     
    196197          }
    197198        }
    198     delete[](AtomMap);
    199199    delete (LC);
    200200    DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl);
     
    207207    ActOnAllAtoms( &atom::OutputBondOfAtom );
    208208  } else
    209     DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl);
     209    DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << getAtomCount() << ", thus no bonds, no connections!." << endl);
    210210  DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl);
    211211  if (free_BG)
     
    249249    DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    250250  } else {
    251     DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl);
     251    DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << getAtomCount() << " atoms." << endl);
    252252  }
    253253  DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl);
     
    469469void DepthFirstSearchAnalysis_Init(struct DFSAccounting &DFS, const molecule * const mol)
    470470{
    471   DFS.AtomStack = new StackClass<atom *> (mol->AtomCount);
     471  DFS.AtomStack = new StackClass<atom *> (mol->getAtomCount());
    472472  DFS.CurrentGraphNr = 0;
    473473  DFS.ComponentNumber = 0;
     
    510510  bond *Binder = NULL;
    511511
    512   if (AtomCount == 0)
     512  if (getAtomCount() == 0)
    513513    return SubGraphs;
    514514  DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl);
    515515  DepthFirstSearchAnalysis_Init(DFS, this);
    516516
    517   DFS.Root = start->next;
    518   while (DFS.Root != end) { // if there any atoms at all
     517  for (molecule::const_iterator iter = begin(); iter != end();) {
     518    DFS.Root = *iter;
    519519    // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all
    520520    DFS.AtomStack->ClearStack();
     
    556556
    557557    // step on to next root
    558     while ((DFS.Root != end) && (DFS.Root->GraphNr != -1)) {
    559       //Log() << Verbose(1) << "Current next subgraph root candidate is " << Root->Name << "." << endl;
    560       if (DFS.Root->GraphNr != -1) // if already discovered, step on
    561         DFS.Root = DFS.Root->next;
     558    while ((iter != end()) && ((*iter)->GraphNr != -1)) {
     559      //Log() << Verbose(1) << "Current next subgraph root candidate is " << (*iter)->Name << "." << endl;
     560      if ((*iter)->GraphNr != -1) // if already discovered, step on
     561        iter++;
    562562    }
    563563  }
     
    864864  if (MinRingSize != -1) { // if rings are present
    865865    // go over all atoms
    866     Root = mol->start;
    867     while (Root->next != mol->end) {
    868       Root = Root->next;
    869 
    870       if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->AtomCount) { // check whether MinimumRingSize is set, if not BFS to next where it is
     866    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     867      Root = *iter;
     868
     869      if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->getAtomCount()) { // check whether MinimumRingSize is set, if not BFS to next where it is
    871870        Walker = Root;
    872871
    873872        //Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl;
    874         CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->AtomCount);
     873        CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->getAtomCount());
    875874
    876875      }
     
    902901  int MinRingSize = -1;
    903902
    904   InitializeBFSAccounting(BFS, AtomCount);
     903  InitializeBFSAccounting(BFS, getAtomCount());
    905904
    906905  //Log() << Verbose(1) << "Back edge list - ";
     
    11451144    CurrentBondsOfAtom = -1; // we count one too far due to line end
    11461145    // parse into structure
    1147     if ((AtomNr >= 0) && (AtomNr < AtomCount)) {
     1146    if ((AtomNr >= 0) && (AtomNr < getAtomCount())) {
    11481147      Walker = ListOfAtoms[AtomNr];
    11491148      while (!line.eof())
     
    13241323    AddedAtomList[Root->nr] = Mol->AddCopyAtom(Root);
    13251324
    1326   BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, AtomCount, AddedAtomList);
     1325  BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, getAtomCount(), AddedAtomList);
    13271326
    13281327  // and go on ... Queue always contains all lightgray vertices
     
    13821381  // fill parent list with sons
    13831382  DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl);
    1384   atom *Walker = mol->start;
    1385   while (Walker->next != mol->end) {
    1386     Walker = Walker->next;
    1387     ParentList[Walker->father->nr] = Walker;
     1383  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1384    ParentList[(*iter)->father->nr] = (*iter);
    13881385    // Outputting List for debugging
    1389     DoLog(4) && (Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl);
    1390   }
    1391 
    1392 }
    1393 ;
     1386    DoLog(4) && (Log() << Verbose(4) << "Son[" << (*iter)->father->nr << "] of " << (*iter)->father << " is " << ParentList[(*iter)->father->nr] << "." << endl);
     1387  }
     1388};
    13941389
    13951390void BuildInducedSubgraph_Finalize(atom **&ParentList)
     
    14021397{
    14031398  bool status = true;
    1404   atom *Walker = NULL;
    14051399  atom *OtherAtom = NULL;
    14061400  // check each entry of parent list and if ok (one-to-and-onto matching) create bonds
    14071401  DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl);
    1408   Walker = Father->start;
    1409   while (Walker->next != Father->end) {
    1410     Walker = Walker->next;
    1411     if (ParentList[Walker->nr] != NULL) {
    1412       if (ParentList[Walker->nr]->father != Walker) {
     1402  for (molecule::const_iterator iter = Father->begin(); iter != Father->end(); ++iter) {
     1403    if (ParentList[(*iter)->nr] != NULL) {
     1404      if (ParentList[(*iter)->nr]->father != (*iter)) {
    14131405        status = false;
    14141406      } else {
    1415         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    1416           OtherAtom = (*Runner)->GetOtherAtom(Walker);
     1407        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     1408          OtherAtom = (*Runner)->GetOtherAtom((*iter));
    14171409          if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond
    1418             DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl);
    1419             mol->AddBond(ParentList[Walker->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);
     1410            DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[(*iter)->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl);
     1411            mol->AddBond(ParentList[(*iter)->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);
    14201412          }
    14211413        }
     
    14401432  bool status = true;
    14411433  atom **ParentList = NULL;
    1442 
    14431434  DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl);
    1444   BuildInducedSubgraph_Init(ParentList, Father->AtomCount);
     1435  BuildInducedSubgraph_Init(ParentList, Father->getAtomCount());
    14451436  BuildInducedSubgraph_FillParentList(this, Father, ParentList);
    14461437  status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList);
  • src/molecule_pointcloud.cpp

    r42af9e r1024cb  
    88#include "atom.hpp"
    99#include "config.hpp"
     10#include "info.hpp"
    1011#include "memoryallocator.hpp"
    1112#include "molecule.hpp"
     
    3132};
    3233
    33 /** Return current atom in the list.
    34  * \return pointer to atom or NULL if none present
     34
     35/** PointCloud implementation of GoPoint
     36 * Uses atoms and STL stuff.
    3537 */
    36 TesselPoint *molecule::GetPoint() const
     38TesselPoint* molecule::GetPoint() const
    3739{
    38   if ((InternalPointer != start) && (InternalPointer != end))
    39     return InternalPointer;
    40   else
    41     return NULL;
     40  Info FunctionInfo(__func__);
     41  return (*InternalPointer);
    4242};
    4343
    44 /** Return pointer to one after last atom in the list.
    45  * \return pointer to end marker
    46  */
    47 TesselPoint *molecule::GetTerminalPoint() const
    48 {
    49   return end;
    50 };
    51 
    52 /** Return the greatest index of all atoms in the list.
    53  * \return greatest index
    54  */
    55 int molecule::GetMaxId() const
    56 {
    57   return last_atom;
    58 };
    59 
    60 /** Go to next atom.
    61  * Stops at last one.
     44/** PointCloud implementation of GoToNext.
     45 * Uses atoms and STL stuff.
    6246 */
    6347void molecule::GoToNext() const
    6448{
    65   if (InternalPointer != end)
    66     InternalPointer = InternalPointer->next;
     49  Info FunctionInfo(__func__);
     50  if (InternalPointer != atoms.end())
     51    InternalPointer++;
    6752};
    6853
    69 /** Go to previous atom.
    70  * Stops at first one.
    71  */
    72 void molecule::GoToPrevious() const
    73 {
    74   if (InternalPointer->previous != start)
    75     InternalPointer = InternalPointer->previous;
    76 };
    77 
    78 /** Goes to first atom.
     54/** PointCloud implementation of GoToFirst.
     55 * Uses atoms and STL stuff.
    7956 */
    8057void molecule::GoToFirst() const
    8158{
    82   InternalPointer = start->next;
     59  Info FunctionInfo(__func__);
     60  InternalPointer = atoms.begin();
    8361};
    8462
    85 /** Goes to last atom.
    86  */
    87 void molecule::GoToLast() const
    88 {
    89   InternalPointer = end->previous;
    90 };
    91 
    92 /** Checks whether we have any atoms in molecule.
    93  * \return true - no atoms, false - not empty
     63/** PointCloud implementation of IsEmpty.
     64 * Uses atoms and STL stuff.
    9465 */
    9566bool molecule::IsEmpty() const
    9667{
    97   return (start->next == end);
     68  Info FunctionInfo(__func__);
     69  return (empty());
    9870};
    9971
    100 /** Checks whether we are at the last atom
    101  * \return true - current atom is last one, false - is not last one
     72/** PointCloud implementation of IsLast.
     73 * Uses atoms and STL stuff.
    10274 */
    10375bool molecule::IsEnd() const
    10476{
    105   return (InternalPointer == end);
     77  Info FunctionInfo(__func__);
     78  return (InternalPointer == atoms.end());
    10679};
     80
     81int molecule::GetMaxId() const {
     82  return getAtomCount();
     83}
  • src/molecule_template.hpp

    r42af9e r1024cb  
    2424template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const
    2525    {
    26   atom *Walker = start;
    27   while (Walker->next != end) {
    28     Walker = Walker->next;
    29     ((Walker->node)->*f)();
     26  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     27    (((*iter)->node)->*f)();
    3028  }
    3129};
    3230template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const
    3331    {
    34   atom *Walker = start;
    35   while (Walker->next != end) {
    36     Walker = Walker->next;
    37     ((Walker->node)->*f)();
     32  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     33    (((*iter)->node)->*f)();
    3834  }
    3935};
     
    4137template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
    4238{
    43   atom *Walker = start;
    44   while (Walker->next != end) {
    45     Walker = Walker->next;
    46     ((Walker->node)->*f)(t);
     39  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     40    (((*iter)->node)->*f)(t);
    4741  }
    4842};
    4943template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const
    5044{
    51   atom *Walker = start;
    52   while (Walker->next != end) {
    53     Walker = Walker->next;
    54     ((Walker->node)->*f)(t);
     45  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     46    (((*iter)->node)->*f)(t);
    5547  }
    5648};
    5749template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&), T &t ) const
    5850{
    59   atom *Walker = start;
    60   while (Walker->next != end) {
    61     Walker = Walker->next;
    62     ((Walker->node)->*f)(t);
     51  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     52    (((*iter)->node)->*f)(t);
    6353  }
    6454};
    6555template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const
    6656{
    67   atom *Walker = start;
    68   while (Walker->next != end) {
    69     Walker = Walker->next;
    70     ((Walker->node)->*f)(t);
     57  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     58    (((*iter)->node)->*f)(t);
    7159  }
    7260};
     
    7462template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
    7563{
    76   atom *Walker = start;
    77   while (Walker->next != end) {
    78     Walker = Walker->next;
    79     ((Walker->node)->*f)(t, u);
     64  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     65    (((*iter)->node)->*f)(t, u);
    8066  }
    8167};
    8268template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const
    8369{
    84   atom *Walker = start;
    85   while (Walker->next != end) {
    86     Walker = Walker->next;
    87     ((Walker->node)->*f)(t, u);
     70  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     71    (((*iter)->node)->*f)(t, u);
    8872  }
    8973};
     
    9175template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const
    9276{
    93   atom *Walker = start;
    94   while (Walker->next != end) {
    95     Walker = Walker->next;
    96     ((Walker->node)->*f)(t, u, v);
     77  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     78    (((*iter)->node)->*f)(t, u, v);
    9779  }
    9880};
    9981template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const
    10082{
    101   atom *Walker = start;
    102   while (Walker->next != end) {
    103     Walker = Walker->next;
    104     ((Walker->node)->*f)(t, u, v);
     83  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     84    (((*iter)->node)->*f)(t, u, v);
    10585  }
    10686};
     
    11292{
    11393  res result = 0;
    114   atom *Walker = start;
    115   while (Walker->next != end) {
    116     Walker = Walker->next;
    117     result += (Walker->*f)();
     94  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     95    result += ((*iter)->*f)();
    11896  }
    11997  return result;
     
    122100{
    123101  res result = 0;
    124   atom *Walker = start;
    125   while (Walker->next != end) {
    126     Walker = Walker->next;
    127     result += (Walker->*f)();
     102  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     103    result += ((*iter)->*f)();
    128104  }
    129105  return result;
     
    133109{
    134110  res result = 0;
    135   atom *Walker = start;
    136   while (Walker->next != end) {
    137     Walker = Walker->next;
    138     result += (Walker->*f)(t);
     111  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     112    result += ((*iter)->*f)(t);
    139113  }
    140114  return result;
     
    143117{
    144118  res result = 0;
    145   atom *Walker = start;
    146   while (Walker->next != end) {
    147     Walker = Walker->next;
    148     result += (Walker->*f)(t);
     119  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     120    result += ((*iter)->*f)(t);
    149121  }
    150122  return result;
     
    157129template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const
    158130{
    159   atom *Walker = start;
    160   while (Walker->next != end) {
    161     Walker = Walker->next;
    162     (*f)(Walker);
     131  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     132    (*f)((*iter));
    163133  }
    164134};
    165135template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const
    166136{
    167   atom *Walker = start;
    168   while (Walker->next != end) {
    169     Walker = Walker->next;
    170     (*f)(Walker);
     137  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     138    (*f)((*iter));
    171139  }
    172140};
     
    177145template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const
    178146{
    179   atom *Walker = start;
    180   while (Walker->next != end) {
    181     Walker = Walker->next;
    182     (copy->*f)(Walker);
     147  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     148    (copy->*f)((*iter));
    183149  }
    184150};
    185151template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const
    186152{
    187   atom *Walker = start;
    188   while (Walker->next != end) {
    189     Walker = Walker->next;
    190     (copy->*f)(Walker);
     153  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     154    (copy->*f)((*iter));
    191155  }
    192156};
     
    197161template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const
    198162{
    199   atom *Walker = start;
    200   while (Walker->next != end) {
    201     Walker = Walker->next;
    202     if ((Walker->*condition)())
    203       (copy->*f)(Walker);
     163  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     164    if (((*iter)->*condition)())
     165      (copy->*f)((*iter));
    204166  }
    205167};
    206168template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const
    207169{
    208   atom *Walker = start;
    209   while (Walker->next != end) {
    210     Walker = Walker->next;
    211     if ((Walker->*condition)())
    212       (copy->*f)(Walker);
     170  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     171    if (((*iter)->*condition)())
     172      (copy->*f)((*iter));
    213173  }
    214174};
    215175template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const
    216176{
    217   atom *Walker = start;
    218   while (Walker->next != end) {
    219     Walker = Walker->next;
    220     if ((Walker->*condition)())
    221       (copy->*f)(Walker);
     177  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     178    if (((*iter)->*condition)())
     179      (copy->*f)((*iter));
    222180  }
    223181};
    224182template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const
    225183{
    226   atom *Walker = start;
    227   while (Walker->next != end) {
    228     Walker = Walker->next;
    229     if ((Walker->*condition)())
    230       (copy->*f)(Walker);
     184  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     185    if (((*iter)->*condition)())
     186      (copy->*f)((*iter));
    231187  }
    232188};
     
    234190template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const
    235191{
    236   atom *Walker = start;
    237   while (Walker->next != end) {
    238     Walker = Walker->next;
    239     if ((Walker->*condition)(t))
    240       (copy->*f)(Walker);
     192  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     193    if (((*iter)->*condition)(t))
     194      (copy->*f)((*iter));
    241195  }
    242196};
    243197template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const
    244198{
    245   atom *Walker = start;
    246   while (Walker->next != end) {
    247     Walker = Walker->next;
    248     if ((Walker->*condition)(t))
    249       (copy->*f)(Walker);
     199  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     200    if (((*iter)->*condition)(t))
     201      (copy->*f)((*iter));
    250202  }
    251203};
    252204template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const
    253205{
    254   atom *Walker = start;
    255   while (Walker->next != end) {
    256     Walker = Walker->next;
    257     if ((Walker->*condition)(t))
    258       (copy->*f)(Walker);
     206  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     207    if (((*iter)->*condition)(t))
     208      (copy->*f)((*iter));
    259209  }
    260210};
    261211template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const
    262212{
    263   atom *Walker = start;
    264   while (Walker->next != end) {
    265     Walker = Walker->next;
    266     if ((Walker->*condition)(t))
    267       (copy->*f)(Walker);
     213  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     214    if (((*iter)->*condition)(t))
     215      (copy->*f)((*iter));
    268216  }
    269217};
     
    271219template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
    272220{
    273   atom *Walker = start;
    274   while (Walker->next != end) {
    275     Walker = Walker->next;
    276     if ((Walker->*condition)(t,u))
    277       (copy->*f)(Walker);
     221  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     222    if (((*iter)->*condition)(t,u))
     223      (copy->*f)((*iter));
    278224  }
    279225};
    280226template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
    281227{
    282   atom *Walker = start;
    283   while (Walker->next != end) {
    284     Walker = Walker->next;
    285     if ((Walker->*condition)(t,u))
    286       (copy->*f)(Walker);
     228  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     229    if (((*iter)->*condition)(t,u))
     230      (copy->*f)((*iter));
    287231  }
    288232};
    289233template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
    290234{
    291   atom *Walker = start;
    292   while (Walker->next != end) {
    293     Walker = Walker->next;
    294     if ((Walker->*condition)(t,u))
    295       (copy->*f)(Walker);
     235  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     236    if (((*iter)->*condition)(t,u))
     237      (copy->*f)((*iter));
    296238  }
    297239};
    298240template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
    299241{
    300   atom *Walker = start;
    301   while (Walker->next != end) {
    302     Walker = Walker->next;
    303     if ((Walker->*condition)(t,u))
    304       (copy->*f)(Walker);
     242  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     243    if (((*iter)->*condition)(t,u))
     244      (copy->*f)((*iter));
    305245  }
    306246};
     
    308248template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
    309249{
    310   atom *Walker = start;
    311   while (Walker->next != end) {
    312     Walker = Walker->next;
    313     if ((Walker->*condition)(t,u,v))
    314       (copy->*f)(Walker);
     250  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     251    if (((*iter)->*condition)(t,u,v))
     252      (copy->*f)((*iter));
    315253  }
    316254};
    317255template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
    318256{
    319   atom *Walker = start;
    320   while (Walker->next != end) {
    321     Walker = Walker->next;
    322     if ((Walker->*condition)(t,u,v))
    323       (copy->*f)(Walker);
     257  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     258    if (((*iter)->*condition)(t,u,v))
     259      (copy->*f)((*iter));
    324260  }
    325261};
    326262template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
    327263{
    328   atom *Walker = start;
    329   while (Walker->next != end) {
    330     Walker = Walker->next;
    331     if ((Walker->*condition)(t,u,v))
    332       (copy->*f)(Walker);
     264  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     265    if (((*iter)->*condition)(t,u,v))
     266      (copy->*f)((*iter));
    333267  }
    334268};
    335269template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
    336270{
    337   atom *Walker = start;
    338   while (Walker->next != end) {
    339     Walker = Walker->next;
    340     if ((Walker->*condition)(t,u,v))
    341       (copy->*f)(Walker);
     271  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     272    if (((*iter)->*condition)(t,u,v))
     273      (copy->*f)((*iter));
    342274  }
    343275};
     
    348280template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const
    349281{
    350   atom *Walker = start;
    351   while (Walker->next != end) {
    352     Walker = Walker->next;
    353     (Walker->*f)();
     282  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     283    ((*iter)->*f)();
    354284  }
    355285};
    356286template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const
    357287{
    358   atom *Walker = start;
    359   while (Walker->next != end) {
    360     Walker = Walker->next;
    361     (Walker->*f)();
     288  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     289    ((*iter)->*f)();
    362290  }
    363291};
     
    365293template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
    366294{
    367   atom *Walker = start;
    368   while (Walker->next != end) {
    369     Walker = Walker->next;
    370     (Walker->*f)(t);
     295  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     296    ((*iter)->*f)(t);
    371297  }
    372298};
    373299template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
    374300{
    375   atom *Walker = start;
    376   while (Walker->next != end) {
    377     Walker = Walker->next;
    378     (Walker->*f)(t);
     301  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     302    ((*iter)->*f)(t);
    379303  }
    380304};
     
    382306template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
    383307{
    384   atom *Walker = start;
    385   while (Walker->next != end) {
    386     Walker = Walker->next;
    387     (Walker->*f)(t, u);
     308  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     309    ((*iter)->*f)(t, u);
    388310  }
    389311};
    390312template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
    391313{
    392   atom *Walker = start;
    393   while (Walker->next != end) {
    394     Walker = Walker->next;
    395     (Walker->*f)(t, u);
     314  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     315    ((*iter)->*f)(t, u);
    396316  }
    397317};
     
    399319template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const
    400320{
    401   atom *Walker = start;
    402   while (Walker->next != end) {
    403     Walker = Walker->next;
    404     (Walker->*f)(t, u, v);
     321  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     322    ((*iter)->*f)(t, u, v);
    405323  }
    406324};
    407325template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const
    408326{
    409   atom *Walker = start;
    410   while (Walker->next != end) {
    411     Walker = Walker->next;
    412     (Walker->*f)(t, u, v);
     327  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     328    ((*iter)->*f)(t, u, v);
    413329  }
    414330};
     
    416332template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const
    417333{
    418   atom *Walker = start;
    419   while (Walker->next != end) {
    420     Walker = Walker->next;
    421     (Walker->*f)(t, u, v, w);
     334  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     335    ((*iter)->*f)(t, u, v, w);
    422336  }
    423337};
    424338template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const
    425339{
    426   atom *Walker = start;
    427   while (Walker->next != end) {
    428     Walker = Walker->next;
    429     (Walker->*f)(t, u, v, w);
     340  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     341    ((*iter)->*f)(t, u, v, w);
    430342  }
    431343};
     
    436348template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const
    437349{
    438   atom *Walker = start;
    439350  int inc = 1;
    440   while (Walker->next != end) {
    441     Walker = Walker->next;
    442     (*Setor) (&array[(Walker->*index)], &inc);
     351  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     352    (*Setor) (&array[((*iter)->*index)], &inc);
    443353  }
    444354};
    445355template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const
    446356{
    447   atom *Walker = start;
    448   while (Walker->next != end) {
    449     Walker = Walker->next;
    450     (*Setor) (&array[(Walker->*index)], &value);
     357  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     358    (*Setor) (&array[((*iter)->*index)], &value);
    451359  }
    452360};
    453361template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const
    454362{
    455   atom *Walker = start;
    456   while (Walker->next != end) {
    457     Walker = Walker->next;
    458     (*Setor) (&array[(Walker->*index)], value);
     363  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     364    (*Setor) (&array[((*iter)->*index)], value);
    459365  }
    460366};
     
    462368template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const
    463369{
    464   atom *Walker = start;
    465370  int inc = 1;
    466   while (Walker->next != end) {
    467     Walker = Walker->next;
    468     (*Setor) (&array[(Walker->type->*index)], &inc);
     371  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     372    (*Setor) (&array[((*iter)->type->*index)], &inc);
    469373  }
    470374};
    471375template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const
    472376{
    473   atom *Walker = start;
    474   while (Walker->next != end) {
    475     Walker = Walker->next;
    476     (*Setor) (&array[(Walker->type->*index)], &value);
     377  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     378    (*Setor) (&array[((*iter)->type->*index)], &value);
    477379  }
    478380};
    479381template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const
    480382{
    481   atom *Walker = start;
    482   while (Walker->next != end) {
    483     Walker = Walker->next;
    484     (*Setor) (&array[(Walker->type->*index)], value);
     383  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     384    (*Setor) (&array[((*iter)->type->*index)], value);
    485385  }
    486386};
     
    488388template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const
    489389{
    490   atom *Walker = start;
    491   while (Walker->next != end) {
    492     Walker = Walker->next;
    493     array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
     390  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     391    array[((*iter)->*index)] = ((*iter)->*Setor) ((*iter)->*value);
    494392  }
    495393};
    496394template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const
    497395{
    498   atom *Walker = start;
    499   while (Walker->next != end) {
    500     Walker = Walker->next;
    501     array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
     396  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     397    array[((*iter)->*index)] = ((*iter)->*Setor) ((*iter)->*value);
    502398  }
    503399};
    504400template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const
    505401{
    506   atom *Walker = start;
    507   while (Walker->next != end) {
    508     Walker = Walker->next;
    509     array[(Walker->*index)] = (Walker->*Setor) (vect);
     402  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     403    array[((*iter)->*index)] = ((*iter)->*Setor) (vect);
    510404  }
    511405};
    512406template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const
    513407{
    514   atom *Walker = start;
    515   while (Walker->next != end) {
    516     Walker = Walker->next;
    517     array[(Walker->*index)] = (Walker->*Setor) (vect);
     408  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     409    array[((*iter)->*index)] = ((*iter)->*Setor) (vect);
    518410  }
    519411};
    520412template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const
    521413{
    522   atom *Walker = start;
    523   while (Walker->next != end) {
    524     Walker = Walker->next;
    525     Walker->*value = array[(Walker->*index)];
    526     //Log() << Verbose(2) << *Walker << " gets " << (Walker->*value); << endl;
     414  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     415    (*iter)->*value = array[((*iter)->*index)];
     416    //Log() << Verbose(2) << *(*iter) << " gets " << ((*iter)->*value); << endl;
    527417  }
    528418};
     
    530420template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const
    531421{
    532   atom *Walker = start;
    533   while (Walker->next != end) {
    534     Walker = Walker->next;
    535     Walker->*ptr = value;
    536     //Log() << Verbose(2) << *Walker << " gets " << (Walker->*ptr) << endl;
     422  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     423    (*iter)->*ptr = value;
     424    //Log() << Verbose(2) << *(*iter) << " gets " << ((*iter)->*ptr) << endl;
    537425  }
    538426};
  • src/moleculelist.cpp

    r42af9e r1024cb  
    2020#include "memoryallocator.hpp"
    2121#include "periodentafel.hpp"
    22 #include "World.hpp"
     22#include "Helpers/Assert.hpp"
    2323
    2424#include "Helpers/Assert.hpp"
     
    7171  int Count, Counter, aCounter, bCounter;
    7272  int flag;
    73   atom *aWalker = NULL;
    74   atom *bWalker = NULL;
    7573
    7674  // sort each atom list and put the numbers into a list, then go through
    7775  //Log() << Verbose(0) << "Comparing fragment no. " << *(molecule **)a << " to " << *(molecule **)b << "." << endl;
    78   if ((**(molecule **) a).AtomCount < (**(molecule **) b).AtomCount) {
     76  // Yes those types are awkward... but check it for yourself it checks out this way
     77  molecule *const *mol1_ptr= static_cast<molecule *const *>(a);
     78  molecule *mol1 = *mol1_ptr;
     79  molecule *const *mol2_ptr= static_cast<molecule *const *>(b);
     80  molecule *mol2 = *mol2_ptr;
     81  if (mol1->getAtomCount() < mol2->getAtomCount()) {
    7982    return -1;
    8083  } else {
    81     if ((**(molecule **) a).AtomCount > (**(molecule **) b).AtomCount)
     84    if (mol1->getAtomCount() > mol2->getAtomCount())
    8285      return +1;
    8386    else {
    84       Count = (**(molecule **) a).AtomCount;
     87      Count = mol1->getAtomCount();
    8588      aList = new int[Count];
    8689      bList = new int[Count];
    8790
    8891      // fill the lists
    89       aWalker = (**(molecule **) a).start;
    90       bWalker = (**(molecule **) b).start;
    9192      Counter = 0;
    9293      aCounter = 0;
    9394      bCounter = 0;
    94       while ((aWalker->next != (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {
    95         aWalker = aWalker->next;
    96         bWalker = bWalker->next;
    97         if (aWalker->GetTrueFather() == NULL)
     95      molecule::const_iterator aiter = mol1->begin();
     96      molecule::const_iterator biter = mol2->begin();
     97      for (;(aiter != mol1->end()) && (biter != mol2->end());
     98          ++aiter, ++biter) {
     99        if ((*aiter)->GetTrueFather() == NULL)
    98100          aList[Counter] = Count + (aCounter++);
    99101        else
    100           aList[Counter] = aWalker->GetTrueFather()->nr;
    101         if (bWalker->GetTrueFather() == NULL)
     102          aList[Counter] = (*aiter)->GetTrueFather()->nr;
     103        if ((*biter)->GetTrueFather() == NULL)
    102104          bList[Counter] = Count + (bCounter++);
    103105        else
    104           bList[Counter] = bWalker->GetTrueFather()->nr;
     106          bList[Counter] = (*biter)->GetTrueFather()->nr;
    105107        Counter++;
    106108      }
    107109      // check if AtomCount was for real
    108110      flag = 0;
    109       if ((aWalker->next == (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {
     111      if ((aiter == mol1->end()) && (biter != mol2->end())) {
    110112        flag = -1;
    111113      } else {
    112         if ((aWalker->next != (**(molecule **) a).end) && (bWalker->next == (**(molecule **) b).end))
     114        if ((aiter != mol1->end()) && (biter == mol2->end()))
    113115          flag = 1;
    114116      }
     
    144146void MoleculeListClass::Enumerate(ostream *out)
    145147{
    146   atom *Walker = NULL;
    147148  periodentafel *periode = World::getInstance().getPeriode();
    148149  std::map<atomicNumber_t,unsigned int> counts;
     
    160161      // count atoms per element and determine size of bounding sphere
    161162      size=0.;
    162       Walker = (*ListRunner)->start;
    163       while (Walker->next != (*ListRunner)->end) {
    164         Walker = Walker->next;
    165         counts[Walker->type->getNumber()]++;
    166         if (Walker->x.DistanceSquared(Origin) > size)
    167           size = Walker->x.DistanceSquared(Origin);
     163      for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     164        counts[(*iter)->type->getNumber()]++;
     165        if ((*iter)->x.DistanceSquared(Origin) > size)
     166          size = (*iter)->x.DistanceSquared(Origin);
    168167      }
    169168      // output Index, Name, number of atoms, chemical formula
    170       (*out) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->AtomCount << "\t";
     169      (*out) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->getAtomCount() << "\t";
    171170
    172171      std::map<atomicNumber_t,unsigned int>::reverse_iterator iter;
     
    204203
    205204  // put all molecules of src into mol
    206   atom *Walker = srcmol->start;
    207   atom *NextAtom = Walker->next;
    208   while (NextAtom != srcmol->end) {
    209     Walker = NextAtom;
    210     NextAtom = Walker->next;
    211     srcmol->UnlinkAtom(Walker);
    212     mol->AddAtom(Walker);
     205  molecule::iterator runner;
     206  for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
     207    runner = iter++;
     208    srcmol->UnlinkAtom((*runner));
     209    mol->AddAtom((*runner));
    213210  }
    214211
     
    230227
    231228  // put all molecules of src into mol
    232   atom *Walker = srcmol->start;
    233   atom *NextAtom = Walker->next;
    234   while (NextAtom != srcmol->end) {
    235     Walker = NextAtom;
    236     NextAtom = Walker->next;
    237     Walker = mol->AddCopyAtom(Walker);
     229  atom *Walker = NULL;
     230  for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
     231    Walker = mol->AddCopyAtom((*iter));
    238232    Walker->father = Walker;
    239233  }
     
    332326
    333327  // prepare index list for bonds
    334   srcmol->CountAtoms();
    335   atom ** CopyAtoms = new atom*[srcmol->AtomCount];
    336   for(int i=0;i<srcmol->AtomCount;i++)
     328  atom ** CopyAtoms = new atom*[srcmol->getAtomCount()];
     329  for(int i=0;i<srcmol->getAtomCount();i++)
    337330    CopyAtoms[i] = NULL;
    338331
    339332  // for each of the source atoms check whether we are in- or outside and add copy atom
    340   atom *Walker = srcmol->start;
    341333  int nr=0;
    342   while (Walker->next != srcmol->end) {
    343     Walker = Walker->next;
    344     DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << *Walker << "." << endl);
    345     if (!TesselStruct->IsInnerPoint(Walker->x, LCList)) {
    346       CopyAtoms[Walker->nr] = Walker->clone();
    347       mol->AddAtom(CopyAtoms[Walker->nr]);
     334  for (molecule::const_iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
     335    DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << **iter << "." << endl);
     336    if (!TesselStruct->IsInnerPoint((*iter)->x, LCList)) {
     337      CopyAtoms[(*iter)->nr] = (*iter)->clone();
     338      mol->AddAtom(CopyAtoms[(*iter)->nr]);
    348339      nr++;
    349340    } else {
     
    351342    }
    352343  }
    353   DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol->AtomCount << " atoms have been merged.");
     344  DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol->getAtomCount() << " atoms have been merged.");
    354345
    355346  // go through all bonds and add as well
     
    384375bool MoleculeListClass::AddHydrogenCorrection(char *path)
    385376{
    386   atom *Walker = NULL;
    387   atom *Runner = NULL;
    388377  bond *Binder = NULL;
    389378  double ***FitConstant = NULL, **correction = NULL;
     
    493482        correction[k][j] = 0.;
    494483    // 2. take every hydrogen that is a saturated one
    495     Walker = (*ListRunner)->start;
    496     while (Walker->next != (*ListRunner)->end) {
    497       Walker = Walker->next;
    498       //Log() << Verbose(1) << "Walker: " << *Walker << " with first bond " << *(Walker->ListOfBonds.begin()) << "." << endl;
    499       if ((Walker->type->Z == 1) && ((Walker->father == NULL)
    500           || (Walker->father->type->Z != 1))) { // if it's a hydrogen
    501         Runner = (*ListRunner)->start;
    502         while (Runner->next != (*ListRunner)->end) {
    503           Runner = Runner->next;
    504           //Log() << Verbose(2) << "Runner: " << *Runner << " with first bond " << *(Walker->ListOfBonds.begin()) << "." << endl;
     484    for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     485      //Log() << Verbose(1) << "(*iter): " << *(*iter) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl;
     486      if (((*iter)->type->Z == 1) && (((*iter)->father == NULL)
     487          || ((*iter)->father->type->Z != 1))) { // if it's a hydrogen
     488        for (molecule::const_iterator runner = (*ListRunner)->begin(); runner != (*ListRunner)->end(); ++runner) {
     489          //Log() << Verbose(2) << "Runner: " << *(*runner) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl;
    505490          // 3. take every other hydrogen that is the not the first and not bound to same bonding partner
    506           Binder = *(Runner->ListOfBonds.begin());
    507           if ((Runner->type->Z == 1) && (Runner->nr > Walker->nr) && (Binder->GetOtherAtom(Runner) != Binder->GetOtherAtom(Walker))) { // (hydrogens have only one bonding partner!)
     491          Binder = *((*runner)->ListOfBonds.begin());
     492          if (((*runner)->type->Z == 1) && ((*runner)->nr > (*iter)->nr) && (Binder->GetOtherAtom((*runner)) != Binder->GetOtherAtom((*iter)))) { // (hydrogens have only one bonding partner!)
    508493            // 4. evaluate the morse potential for each matrix component and add up
    509             distance = Runner->x.distance(Walker->x);
    510             //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *Runner << "<= " << distance << "=>" << *Walker << ":" << endl;
     494            distance = (*runner)->x.distance((*iter)->x);
     495            //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *(*runner) << "<= " << distance << "=>" << *(*iter) << ":" << endl;
    511496            for (int k = 0; k < a; k++) {
    512497              for (int j = 0; j < b; j++) {
     
    586571  ofstream ForcesFile;
    587572  stringstream line;
    588   atom *Walker = NULL;
    589573  periodentafel *periode=World::getInstance().getPeriode();
    590574
     
    599583      periodentafel::const_iterator elemIter;
    600584      for(elemIter=periode->begin();elemIter!=periode->end();++elemIter){
    601           if ((*ListRunner)->ElementsInMolecule[(*elemIter).first]) { // if this element got atoms
    602           Walker = (*ListRunner)->start;
    603           while (Walker->next != (*ListRunner)->end) { // go through every atom of this element
    604             Walker = Walker->next;
    605             if (Walker->type->getNumber() == (*elemIter).first) {
    606               if ((Walker->GetTrueFather() != NULL) && (Walker->GetTrueFather() != Walker)) {// if there is a rea
     585        if ((*ListRunner)->ElementsInMolecule[(*elemIter).first]) { // if this element got atoms
     586          for(molecule::iterator atomIter = (*ListRunner)->begin(); atomIter !=(*ListRunner)->end();++atomIter){
     587            if ((*atomIter)->type->getNumber() == (*elemIter).first) {
     588              if (((*atomIter)->GetTrueFather() != NULL) && ((*atomIter)->GetTrueFather() != (*atomIter))) {// if there is a rea
    607589                //Log() << Verbose(0) << "Walker is " << *Walker << " with true father " << *( Walker->GetTrueFather()) << ", it
    608                 ForcesFile << SortIndex[Walker->GetTrueFather()->nr] << "\t";
     590                ForcesFile << SortIndex[(*atomIter)->GetTrueFather()->nr] << "\t";
    609591              } else
    610592                // otherwise a -1 to indicate an added saturation hydrogen
     
    640622  bool result = true;
    641623  bool intermediateResult = true;
    642   atom *Walker = NULL;
    643624  Vector BoxDimension;
    644625  char *FragmentNumber = NULL;
     
    681662    // list atoms in fragment for debugging
    682663    DoLog(2) && (Log() << Verbose(2) << "Contained atoms: ");
    683     Walker = (*ListRunner)->start;
    684     while (Walker->next != (*ListRunner)->end) {
    685       Walker = Walker->next;
    686       DoLog(0) && (Log() << Verbose(0) << Walker->getName() << " ");
     664    for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     665      DoLog(0) && (Log() << Verbose(0) << (*iter)->getName() << " ");
    687666    }
    688667    DoLog(0) && (Log() << Verbose(0) << endl);
     
    764743{
    765744  molecule *mol = World::getInstance().createMolecule();
    766   atom *Walker = NULL;
    767   atom *Advancer = NULL;
    768745  bond *Binder = NULL;
    769746  bond *Stepper = NULL;
     
    771748  for (MoleculeList::iterator MolRunner = ListOfMolecules.begin(); !ListOfMolecules.empty(); MolRunner = ListOfMolecules.begin()) {
    772749    // shift all atoms to new molecule
    773     Advancer = (*MolRunner)->start->next;
    774     while (Advancer != (*MolRunner)->end) {
    775       Walker = Advancer;
    776       Advancer = Advancer->next;
    777       DoLog(3) && (Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl);
    778       unlink(Walker);
    779       Walker->father = Walker;
    780       mol->AddAtom(Walker);    // counting starts at 1
     750    for (molecule::iterator iter = (*MolRunner)->begin(); (*MolRunner)->empty(); iter = (*MolRunner)->begin()) {
     751      DoLog(3) && (Log() << Verbose(3) << "Re-linking " << (*iter) << "..." << endl);
     752      (*iter)->father = (*iter);
     753      mol->AddAtom((*iter));    // counting starts at 1
     754      (*MolRunner)->erase(iter);
    781755    }
    782756    // remove all bonds
     
    832806  // 4b. create and fill map of which atom is associated to which connected molecule (note, counting starts at 1)
    833807  int FragmentCounter = 0;
    834   int *MolMap = new int[mol->AtomCount];
    835   for (int i=0;i<mol->AtomCount;i++)
     808  int *MolMap = new int[mol->getAtomCount()];
     809  for (int i=0;i<mol->getAtomCount();i++)
    836810    MolMap[i] = 0;
    837811  MoleculeLeafClass *MolecularWalker = Subgraphs;
    838   Walker = NULL;
    839812  while (MolecularWalker->next != NULL) {
    840813    MolecularWalker = MolecularWalker->next;
    841     Walker = MolecularWalker->Leaf->start;
    842     while (Walker->next != MolecularWalker->Leaf->end) {
    843       Walker = Walker->next;
    844       MolMap[Walker->GetTrueFather()->nr] = FragmentCounter+1;
     814    for (molecule::const_iterator iter = MolecularWalker->Leaf->begin(); iter != MolecularWalker->Leaf->end(); ++iter) {
     815      MolMap[(*iter)->GetTrueFather()->nr] = FragmentCounter+1;
    845816    }
    846817    FragmentCounter++;
     
    848819
    849820  // 4c. relocate atoms to new molecules and remove from Leafs
    850   Walker = NULL;
    851   while (mol->start->next != mol->end) {
    852     Walker = mol->start->next;
    853     if ((Walker->nr <0) || (Walker->nr >= mol->AtomCount)) {
    854       DoeLog(0) && (eLog()<< Verbose(0) << "Index of atom " << *Walker << " is invalid!" << endl);
     821  for (molecule::iterator iter = mol->begin(); !mol->empty(); iter = mol->begin()) {
     822    if (((*iter)->nr <0) || ((*iter)->nr >= mol->getAtomCount())) {
     823      DoeLog(0) && (eLog()<< Verbose(0) << "Index of atom " << **iter << " is invalid!" << endl);
    855824      performCriticalExit();
    856825    }
    857     FragmentCounter = MolMap[Walker->nr];
     826    FragmentCounter = MolMap[(*iter)->nr];
    858827    if (FragmentCounter != 0) {
    859       DoLog(3) && (Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl);
    860       unlink(Walker);
    861       molecules[FragmentCounter-1]->AddAtom(Walker);    // counting starts at 1
     828      DoLog(3) && (Log() << Verbose(3) << "Re-linking " << **iter << "..." << endl);
     829      molecules[FragmentCounter-1]->AddAtom((*iter));    // counting starts at 1
     830      mol->erase(iter);
    862831    } else {
    863       DoeLog(0) && (eLog()<< Verbose(0) << "Atom " << *Walker << " not associated to molecule!" << endl);
     832      DoeLog(0) && (eLog()<< Verbose(0) << "Atom " << **iter << " not associated to molecule!" << endl);
    864833      performCriticalExit();
    865834    }
     
    869838  while (mol->first->next != mol->last) {
    870839    Binder = mol->first->next;
    871     Walker = Binder->leftatom;
     840    const atom * const Walker = Binder->leftatom;
    872841    unlink(Binder);
    873842    link(Binder,molecules[MolMap[Walker->nr]-1]->last);   // counting starts at 1
     
    891860int MoleculeListClass::CountAllAtoms() const
    892861{
    893   atom *Walker = NULL;
    894862  int AtomNo = 0;
    895863  for (MoleculeList::const_iterator MolWalker = ListOfMolecules.begin(); MolWalker != ListOfMolecules.end(); MolWalker++) {
    896     Walker = (*MolWalker)->start;
    897     while (Walker->next != (*MolWalker)->end) {
    898       Walker = Walker->next;
    899       AtomNo++;
    900     }
     864    AtomNo += (*MolWalker)->size();
    901865  }
    902866  return AtomNo;
     
    10731037bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList)
    10741038{
    1075   atom *Walker = NULL;
    10761039  atom *OtherWalker = NULL;
    10771040  atom *Father = NULL;
     
    10811044  DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl);
    10821045  // fill ListOfLocalAtoms if NULL was given
    1083   if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
     1046  if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) {
    10841047    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    10851048    return false;
     
    10971060    }
    10981061
    1099     Walker = Leaf->start;
    1100     while (Walker->next != Leaf->end) {
    1101       Walker = Walker->next;
    1102       Father = Walker->GetTrueFather();
     1062    for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
     1063      Father = (*iter)->GetTrueFather();
    11031064      AtomNo = Father->nr; // global id of the current walker
    11041065      for (BondList::const_iterator Runner = Father->ListOfBonds.begin(); Runner != Father->ListOfBonds.end(); (++Runner)) {
    1105         OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom(Walker->GetTrueFather())->nr]; // local copy of current bond partner of walker
     1066        OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker
    11061067        if (OtherWalker != NULL) {
    1107           if (OtherWalker->nr > Walker->nr)
    1108             Leaf->AddBond(Walker, OtherWalker, (*Runner)->BondDegree);
     1068          if (OtherWalker->nr > (*iter)->nr)
     1069            Leaf->AddBond((*iter), OtherWalker, (*Runner)->BondDegree);
    11091070        } else {
    1110           DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom(Walker->GetTrueFather())->nr << "] is NULL!" << endl);
     1071          DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl);
    11111072          status = false;
    11121073        }
     
    11351096bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter)
    11361097{
    1137   atom *Walker = NULL, *Father = NULL;
     1098  atom *Father = NULL;
    11381099
    11391100  if (RootStack != NULL) {
     
    11411102    if (&(RootStack[FragmentCounter]) != NULL) {
    11421103      RootStack[FragmentCounter].clear();
    1143       Walker = Leaf->start;
    1144       while (Walker->next != Leaf->end) { // go through all (non-hydrogen) atoms
    1145         Walker = Walker->next;
    1146         Father = Walker->GetTrueFather();
     1104      for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
     1105        Father = (*iter)->GetTrueFather();
    11471106        if (AtomMask[Father->nr]) // apply mask
    11481107#ifdef ADDHYDROGEN
    1149           if (Walker->type->Z != 1) // skip hydrogen
     1108          if ((*iter)->type->Z != 1) // skip hydrogen
    11501109#endif
    1151           RootStack[FragmentCounter].push_front(Walker->nr);
     1110          RootStack[FragmentCounter].push_front((*iter)->nr);
    11521111      }
    11531112      if (next != NULL)
     
    11911150
    11921151  if ((ListOfLocalAtoms != NULL) && (ListOfLocalAtoms[FragmentCounter] == NULL)) { // allocate and fill list of this fragment/subgraph
    1193     status = status && CreateFatherLookupTable(Leaf->start, Leaf->end, ListOfLocalAtoms[FragmentCounter], GlobalAtomCount);
     1152    status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms[FragmentCounter], GlobalAtomCount);
    11941153    FreeList = FreeList && true;
    11951154  }
     
    12151174  DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl);
    12161175  // fill ListOfLocalAtoms if NULL was given
    1217   if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
     1176  if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) {
    12181177    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    12191178    return false;
  • src/tesselation.cpp

    r42af9e r1024cb  
    2121#include "Plane.hpp"
    2222#include "Exceptions/LinearDependenceException.hpp"
     23#include "Helpers/Assert.hpp"
     24
     25#include "Helpers/Assert.hpp"
    2326
    2427class molecule;
     
    357360  // get ascending order of endpoints
    358361  PointMap OrderMap;
    359   for (int i = 0; i < 3; i++)
     362  for (int i = 0; i < 3; i++) {
    360363    // for all three lines
    361364    for (int j = 0; j < 2; j++) { // for both endpoints
     
    363366      // and we don't care whether insertion fails
    364367    }
     368  }
    365369  // set endpoints
    366370  int Counter = 0;
     
    371375    Counter++;
    372376  }
    373   if (Counter < 3) {
    374     DoeLog(0) && (eLog() << Verbose(0) << "We have a triangle with only two distinct endpoints!" << endl);
    375     performCriticalExit();
    376   }
    377 }
    378 ;
     377  ASSERT(Counter >= 3,"We have a triangle with only two distinct endpoints!");
     378};
     379
    379380
    380381/** Destructor of BoundaryTriangleSet.
     
    682683}
    683684
     685/**
     686 * gets the Plane defined by the three triangle Basepoints
     687 */
     688Plane BoundaryTriangleSet::getPlane() const{
     689  ASSERT(endpoints[0] && endpoints[1] && endpoints[2], "Triangle not fully defined");
     690
     691  return Plane(*endpoints[0]->node->node,
     692               *endpoints[1]->node->node,
     693               *endpoints[2]->node->node);
     694}
     695
     696Vector BoundaryTriangleSet::getEndpoint(int i) const{
     697  ASSERT(i>=0 && i<3,"Index of Endpoint out of Range");
     698
     699  return *endpoints[i]->node->node;
     700}
     701
     702string BoundaryTriangleSet::getEndpointName(int i) const{
     703  ASSERT(i>=0 && i<3,"Index of Endpoint out of Range");
     704
     705  return endpoints[i]->node->getName();
     706}
     707
    684708/** output operator for BoundaryTriangleSet.
    685709 * \param &ost output stream
     
    688712ostream &operator <<(ostream &ost, const BoundaryTriangleSet &a)
    689713{
    690   ost << "[" << a.Nr << "|" << a.endpoints[0]->node->getName() << "," << a.endpoints[1]->node->getName() << "," << a.endpoints[2]->node->getName() << "]";
     714  ost << "[" << a.Nr << "|" << a.getEndpointName(0) << "," << a.getEndpointName(1) << "," << a.getEndpointName(2) << "]";
    691715  //  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << ","
    692716  //      << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]";
     
    12081232;
    12091233
    1210 /** PointCloud implementation of GetTerminalPoint.
    1211  * Uses PointsOnBoundary and STL stuff.
    1212  */
    1213 TesselPoint * Tesselation::GetTerminalPoint() const
    1214 {
    1215   Info FunctionInfo(__func__);
    1216   PointMap::const_iterator Runner = PointsOnBoundary.end();
    1217   Runner--;
    1218   return (Runner->second->node);
    1219 }
    1220 ;
    1221 
    12221234/** PointCloud implementation of GoToNext.
    12231235 * Uses PointsOnBoundary and STL stuff.
     
    12311243;
    12321244
    1233 /** PointCloud implementation of GoToPrevious.
    1234  * Uses PointsOnBoundary and STL stuff.
    1235  */
    1236 void Tesselation::GoToPrevious() const
    1237 {
    1238   Info FunctionInfo(__func__);
    1239   if (InternalPointer != PointsOnBoundary.begin())
    1240     InternalPointer--;
    1241 }
    1242 ;
    1243 
    12441245/** PointCloud implementation of GoToFirst.
    12451246 * Uses PointsOnBoundary and STL stuff.
     
    12491250  Info FunctionInfo(__func__);
    12501251  InternalPointer = PointsOnBoundary.begin();
    1251 }
    1252 ;
    1253 
    1254 /** PointCloud implementation of GoToLast.
    1255  * Uses PointsOnBoundary and STL stuff.
    1256  */
    1257 void Tesselation::GoToLast() const
    1258 {
    1259   Info FunctionInfo(__func__);
    1260   InternalPointer = PointsOnBoundary.end();
    1261   InternalPointer--;
    12621252}
    12631253;
     
    14551445        CenterVector.Zero();
    14561446        for (int i = 0; i < 3; i++)
    1457           CenterVector += (*BTS->endpoints[i]->node->node);
     1447          CenterVector += BTS->getEndpoint(i);
    14581448        CenterVector.Scale(1. / 3.);
    14591449        DoLog(2) && (Log() << Verbose(2) << "CenterVector of base triangle is " << CenterVector << endl);
     
    25692559  // fill the set of neighbours
    25702560  TesselPointSet SetOfNeighbours;
     2561
    25712562  SetOfNeighbours.insert(CandidateLine.BaseLine->endpoints[1]->node);
    25722563  for (TesselPointList::iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); Runner++)
     
    48024793  if (LastTriangle != NULL) {
    48034794    stringstream sstr;
    4804     sstr << "-"<< TrianglesOnBoundary.size() << "-" << LastTriangle->endpoints[0]->node->getName() << "_" << LastTriangle->endpoints[1]->node->getName() << "_" << LastTriangle->endpoints[2]->node->getName();
     4795    sstr << "-"<< TrianglesOnBoundary.size() << "-" << LastTriangle->getEndpointName(0) << "_" << LastTriangle->getEndpointName(1) << "_" << LastTriangle->getEndpointName(2);
    48054796    NumberName = sstr.str();
    48064797    if (DoTecplotOutput) {
  • src/tesselation.hpp

    r42af9e r1024cb  
    3838class PointCloud;
    3939class Tesselation;
     40class Plane;
    4041
    4142/********************************************** definitions *********************************/
     
    166167    bool IsPresentTupel(const BoundaryTriangleSet * const T) const;
    167168
     169    Plane getPlane() const;
     170    Vector getEndpoint(int) const;
     171    std::string getEndpointName(int) const;
     172
    168173    class BoundaryPointSet *endpoints[3];
    169174    class BoundaryLineSet *lines[3];
     
    171176    Vector SphereCenter;
    172177    int Nr;
     178
     179  private:
     180
    173181};
    174182
     
    236244  virtual Vector *GetCenter() const { return NULL; };
    237245  virtual TesselPoint *GetPoint() const { return NULL; };
    238   virtual TesselPoint *GetTerminalPoint() const { return NULL; };
    239246  virtual int GetMaxId() const { return 0; };
    240247  virtual void GoToNext() const {};
    241   virtual void GoToPrevious() const {};
    242248  virtual void GoToFirst() const {};
    243   virtual void GoToLast() const {};
    244249  virtual bool IsEmpty() const { return true; };
    245250  virtual bool IsEnd() const { return true; };
     
    355360    virtual Vector *GetCenter(ofstream *out) const;
    356361    virtual TesselPoint *GetPoint() const;
    357     virtual TesselPoint *GetTerminalPoint() const;
    358362    virtual void GoToNext() const;
    359     virtual void GoToPrevious() const;
    360363    virtual void GoToFirst() const;
    361     virtual void GoToLast() const;
    362364    virtual bool IsEmpty() const;
    363365    virtual bool IsEnd() const;
  • src/tesselationhelpers.cpp

    r42af9e r1024cb  
    1616#include "vector_ops.hpp"
    1717#include "verbose.hpp"
     18#include "Plane.hpp"
    1819
    1920double DetGet(gsl_matrix * const A, const int inPlace)
     
    687688    return -1;
    688689  }
    689   distance = x->DistanceToPlane(triangle->NormalVector, *triangle->endpoints[0]->node->node);
     690  distance = x->DistanceToSpace(triangle->getPlane());
    690691  return distance;
    691692};
     
    837838    int i=cloud->GetMaxId();
    838839    int *LookupList = new int[i];
    839     for (cloud->GoToFirst(), i=0; !cloud->IsEnd(); cloud->GoToNext(), i++)
     840    for (cloud->GoToFirst(), i=0; !cloud->IsEnd(); cloud->GoToNext(), i++){
    840841      LookupList[i] = -1;
     842    }
    841843
    842844    // print atom coordinates
    843845    int Counter = 1;
    844846    TesselPoint *Walker = NULL;
    845     for (PointMap::const_iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); target++) {
     847    for (PointMap::const_iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); ++target) {
    846848      Walker = target->second->node;
    847849      LookupList[Walker->nr] = Counter++;
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r42af9e r1024cb  
    6666
    6767  // check that TestMolecule was correctly constructed
    68   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
     68  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    6969
    7070  TestList = World::getInstance().getMolecules();
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    r42af9e r1024cb  
    2525#include "tesselation.hpp"
    2626#include "World.hpp"
     27#include "Helpers/Assert.hpp"
    2728
    2829#include "Helpers/Assert.hpp"
     
    3940void AnalysisCorrelationToSurfaceUnitTest::setUp()
    4041{
    41   //ASSERT_DO(Assert::Throw);
     42  ASSERT_DO(Assert::Throw);
    4243
    4344  atom *Walker = NULL;
     
    5455  hydrogen = World::getInstance().getPeriode()->FindElement(1);
    5556  TestSurfaceMolecule = World::getInstance().createMolecule();
     57
    5658  Walker = World::getInstance().createAtom();
    5759  Walker->type = hydrogen;
    5860  *Walker->node = Vector(1., 0., 1. );
    59 
    60   TestSurfaceMolecule->AddAtom(Walker);
     61  TestSurfaceMolecule->AddAtom(Walker);
     62
    6163  Walker = World::getInstance().createAtom();
    6264  Walker->type = hydrogen;
    6365  *Walker->node = Vector(0., 1., 1. );
    6466  TestSurfaceMolecule->AddAtom(Walker);
     67
    6568  Walker = World::getInstance().createAtom();
    6669  Walker->type = hydrogen;
    6770  *Walker->node = Vector(1., 1., 0. );
    6871  TestSurfaceMolecule->AddAtom(Walker);
     72
    6973  Walker = World::getInstance().createAtom();
    7074  Walker->type = hydrogen;
     
    7377
    7478  // check that TestMolecule was correctly constructed
    75   CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->AtomCount, 4 );
     79  CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 );
    7680
    7781  TestList = World::getInstance().getMolecules();
     
    9195  *Walker->node = Vector(4., 0., 4. );
    9296  TestSurfaceMolecule->AddAtom(Walker);
     97
    9398  Walker = World::getInstance().createAtom();
    9499  Walker->type = carbon;
    95100  *Walker->node = Vector(0., 4., 4. );
    96101  TestSurfaceMolecule->AddAtom(Walker);
     102
    97103  Walker = World::getInstance().createAtom();
    98104  Walker->type = carbon;
    99105  *Walker->node = Vector(4., 4., 0. );
    100106  TestSurfaceMolecule->AddAtom(Walker);
     107
    101108  // add inner atoms
    102109  Walker = World::getInstance().createAtom();
     
    104111  *Walker->node = Vector(0.5, 0.5, 0.5 );
    105112  TestSurfaceMolecule->AddAtom(Walker);
     113
    106114  TestSurfaceMolecule->ActiveFlag = true;
    107115  TestList->insert(TestSurfaceMolecule);
     
    133141void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest()
    134142{
    135   CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->AtomCount );
     143  CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() );
    136144  CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );
    137145  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
  • src/unittests/AnalysisPairCorrelationUnitTest.cpp

    r42af9e r1024cb  
    6868
    6969  // check that TestMolecule was correctly constructed
    70   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
     70  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    7171
    7272  TestList = World::getInstance().getMolecules();
  • src/unittests/CountBondsUnitTest.cpp

    r42af9e r1024cb  
    9292
    9393  // check that TestMolecule was correctly constructed
    94   CPPUNIT_ASSERT_EQUAL( TestMolecule1->AtomCount, 3 );
    95   Walker = TestMolecule1->start->next;
    96   CPPUNIT_ASSERT( TestMolecule1->end != Walker );
    97   CPPUNIT_ASSERT_EQUAL( TestMolecule2->AtomCount, 3 );
    98   Walker = TestMolecule2->start->next;
    99   CPPUNIT_ASSERT( TestMolecule2->end != Walker );
     94  CPPUNIT_ASSERT_EQUAL( TestMolecule1->getAtomCount(), 3 );
     95  CPPUNIT_ASSERT_EQUAL( TestMolecule2->getAtomCount(), 3 );
    10096
    10197  // create a small file with table
  • src/unittests/LinkedCellUnitTest.cpp

    r42af9e r1024cb  
    6060
    6161  // check that TestMolecule was correctly constructed
    62   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 3*3*3 );
    63   Walker = TestMolecule->start->next;
    64   CPPUNIT_ASSERT( TestMolecule->end != Walker );
     62  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 3*3*3 );
    6563};
    6664
     
    187185{
    188186  // check all atoms
    189   atom *Walker = TestMolecule->start;
    190   while (Walker->next != TestMolecule->end) {
    191     Walker = Walker->next;
    192     CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToNode(Walker) );
     187  for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end();++iter){
     188    CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToNode(*iter) );
    193189  }
    194190
    195191  // check internal vectors, returns false, because this atom is not in LC-list!
    196   Walker = World::getInstance().createAtom();
    197   Walker->setName("test");
    198   Walker->x= Vector(1,1,1);
    199   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(Walker) );
    200   World::getInstance().destroyAtom(Walker);
     192  atom *newAtom = World::getInstance().createAtom();
     193  newAtom->setName("test");
     194  newAtom->x= Vector(1,1,1);
     195  CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) );
     196  World::getInstance().destroyAtom(newAtom);
    201197
    202198  // check out of bounds vectors
    203   Walker = World::getInstance().createAtom();
    204   Walker->setName("test");
    205   Walker->x = Vector(0,-1,0);
    206   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(Walker) );
    207   World::getInstance().destroyAtom(Walker);
     199  newAtom = World::getInstance().createAtom();
     200  newAtom->setName("test");
     201  newAtom->x = Vector(0,-1,0);
     202  CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) );
     203  World::getInstance().destroyAtom(newAtom);
    208204};
    209205
     
    277273  size = ListOfPoints->size();
    278274  CPPUNIT_ASSERT_EQUAL( (size_t)27, size );
    279   Walker = TestMolecule->start;
    280   Walker = TestMolecule->start;
    281   while (Walker->next != TestMolecule->end) {
    282     Walker = Walker->next;
    283     ListOfPoints->remove(Walker);
     275
     276  for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){
     277    ListOfPoints->remove((*iter));
    284278    size--;
    285279    CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
     
    296290  size=ListOfPoints->size();
    297291  CPPUNIT_ASSERT_EQUAL( (size_t)8, size );
    298   Walker = TestMolecule->start;
    299   while (Walker->next != TestMolecule->end) {
    300     Walker = Walker->next;
    301     if ((Walker->x[0] <2) && (Walker->x[1] <2) && (Walker->x[2] <2)) {
    302       ListOfPoints->remove(Walker);
     292  for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){
     293    if (((*iter)->x[0] <2) && ((*iter)->x[1] <2) && ((*iter)->x[2] <2)) {
     294      ListOfPoints->remove(*iter);
    303295      size--;
    304296      CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
     
    316308  size=ListOfPoints->size();
    317309  CPPUNIT_ASSERT_EQUAL( (size_t)27, size );
    318   Walker = TestMolecule->start;
    319   while (Walker->next != TestMolecule->end) {
    320     Walker = Walker->next;
    321     ListOfPoints->remove(Walker);
     310  for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){
     311    ListOfPoints->remove(*iter);
    322312    size--;
    323313    CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
     
    345335  size = ListOfPoints->size();
    346336  CPPUNIT_ASSERT_EQUAL( (size_t)7, size );
    347   Walker = TestMolecule->start;
    348   while (Walker->next != TestMolecule->end) {
    349     Walker = Walker->next;
    350     if ((Walker->x.DistanceSquared(tester) - 1.) < MYEPSILON ) {
    351       ListOfPoints->remove(Walker);
     337  for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){
     338    if (((*iter)->x.DistanceSquared(tester) - 1.) < MYEPSILON ) {
     339      ListOfPoints->remove(*iter);
    352340      size--;
    353341      CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
  • src/unittests/Makefile.am

    r42af9e r1024cb  
    4949noinst_PROGRAMS = $(TESTS) TestRunner
    5050
    51 GSLLIBS = ../libgslwrapper.a
    52 ALLLIBS = ../libmolecuilder.a ${GSLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB}
     51GSLLIBS = ../libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
     52ALLLIBS = ../libmolecuilder.a ${GSLLIBS}
    5353
    5454TESTSOURCES = \
     
    182182manipulateAtomsTest_LDADD = ${ALLLIBS}
    183183
    184 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp
     184MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp
    185185MemoryAllocatorUnitTest_LDADD = ${ALLLIBS}
    186186
     
    218218Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS}
    219219
    220 TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp $(TESTSOURCES) $(TESTHEADERS)
     220TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp $(TESTSOURCES) $(TESTHEADERS)
    221221TestRunner_LDADD = ${ALLLIBS}
    222222
  • src/unittests/ObserverTest.cpp

    r42af9e r1024cb  
    1111#include <cppunit/extensions/TestFactoryRegistry.h>
    1212#include <cppunit/ui/text/TestRunner.h>
     13#include <set>
    1314
    1415#include "Patterns/Observer.hpp"
     16#include "Patterns/ObservedIterator.hpp"
    1517#include "Helpers/Assert.hpp"
    1618
     
    162164  bool wasNotified;
    163165};
     166
     167class ObservableCollection : public Observable {
     168public:
     169  typedef std::set<SimpleObservable*> set;
     170  typedef ObservedIterator<set> iterator;
     171  typedef set::const_iterator const_iterator;
     172
     173  ObservableCollection(int _num) :
     174  num(_num)
     175  {
     176    for(int i=0; i<num; ++i){
     177      SimpleObservable *content = new SimpleObservable();
     178      content->signOn(this);
     179      theSet.insert(content);
     180    }
     181  }
     182
     183  ~ObservableCollection(){
     184    set::iterator iter;
     185    for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){
     186      delete (*iter);
     187    }
     188  }
     189
     190  iterator begin(){
     191    return iterator(theSet.begin(),this);
     192  }
     193
     194  iterator end(){
     195    return iterator(theSet.end(),this);
     196  }
     197
     198  const int num;
     199
     200private:
     201  set theSet;
     202};
     203
    164204
    165205/******************* actuall tests ***************/
     
    173213  blockObservable = new BlockObservable();
    174214  notificationObservable = new NotificationObservable();
     215  collection = new ObservableCollection(5);
    175216
    176217  observer1 = new UpdateCountObserver();
     
    181222  notificationObserver1 = new NotificationObserver(notificationObservable->notification1);
    182223  notificationObserver2 = new NotificationObserver(notificationObservable->notification2);
    183 
    184224}
    185225
     
    191231  delete blockObservable;
    192232  delete notificationObservable;
     233  delete collection;
    193234
    194235  delete observer1;
     
    277318  blockObservable->changeMethod2();
    278319  blockObservable->noChangeMethod();
     320}
     321
     322void ObserverTest::iteratorTest(){
     323  int i = 0;
     324  // test the general iterator methods
     325  for(ObservableCollection::iterator iter=collection->begin(); iter!=collection->end();++iter){
     326    CPPUNIT_ASSERT(i< collection->num);
     327    i++;
     328  }
     329
     330  i=0;
     331  for(ObservableCollection::const_iterator iter=collection->begin(); iter!=collection->end();++iter){
     332    CPPUNIT_ASSERT(i<collection->num);
     333    i++;
     334  }
     335
     336  collection->signOn(observer1);
     337  {
     338    // we construct this out of the loop, so the iterator dies at the end of
     339    // the scope and not the end of the loop (allows more testing)
     340    ObservableCollection::iterator iter;
     341    for(iter=collection->begin(); iter!=collection->end(); ++iter){
     342      (*iter)->changeMethod();
     343    }
     344    // At this point no change should have been propagated
     345    CPPUNIT_ASSERT_EQUAL( 0, observer1->updates);
     346  }
     347  // After the Iterator has died the propagation should take place
     348  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates);
     349
     350  // when using a const_iterator no changes should be propagated
     351  for(ObservableCollection::const_iterator iter = collection->begin(); iter!=collection->end();++iter);
     352  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates);
     353  collection->signOff(observer1);
    279354}
    280355
  • src/unittests/ObserverTest.hpp

    r42af9e r1024cb  
    1717class CallObservable;
    1818class SuperObservable;
     19class ObservableCollection;
    1920class BlockObservable;
    2021class NotificationObservable;
    21 
    2222
    2323class ObserverTest :  public CppUnit::TestFixture
     
    2929  CPPUNIT_TEST ( doesNotifyTest );
    3030  CPPUNIT_TEST ( doesReportTest );
     31  CPPUNIT_TEST ( iteratorTest );
    3132  CPPUNIT_TEST ( CircleDetectionTest );
    3233  CPPUNIT_TEST_SUITE_END();
     
    4142  void doesNotifyTest();
    4243  void doesReportTest();
     44  void iteratorTest();
    4345  void CircleDetectionTest();
    4446
     
    5860  SuperObservable *superObservable;
    5961  NotificationObservable *notificationObservable;
     62  ObservableCollection *collection;
     63
    6064};
    6165
  • src/unittests/analysisbondsunittest.cpp

    r42af9e r1024cb  
    2525#include "molecule.hpp"
    2626#include "periodentafel.hpp"
     27#include "World.hpp"
    2728
    2829#ifdef HAVE_TESTRUNNER
     
    7677
    7778  // check that TestMolecule was correctly constructed
    78   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 5 );
     79  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 5 );
    7980
    8081  // create a small file with table
  • src/unittests/bondgraphunittest.cpp

    r42af9e r1024cb  
    7777
    7878  // check that TestMolecule was correctly constructed
    79   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
     79  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    8080
    8181  // create a small file with table
     
    114114};
    115115
     116/** Tests whether setup worked.
     117 */
     118void BondGraphTest::SetupTest()
     119{
     120  CPPUNIT_ASSERT_EQUAL (false, TestMolecule->empty());
     121  CPPUNIT_ASSERT_EQUAL ((size_t)4, TestMolecule->size());
     122};
     123
    116124/** UnitTest for BondGraphTest::LoadBondLengthTable().
    117125 */
     
    128136void BondGraphTest::ConstructGraphFromTableTest()
    129137{
    130   atom *Walker = TestMolecule->start->next;
    131   atom *Runner = TestMolecule->end->previous;
    132   CPPUNIT_ASSERT( TestMolecule->end != Walker );
     138  molecule::iterator Walker = TestMolecule->begin();
     139  molecule::iterator Runner = TestMolecule->begin();
     140  Runner++;
    133141  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    134142  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    135   CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
     143  CPPUNIT_ASSERT_EQUAL( true , (*Walker)->IsBondedTo((*Runner)) );
    136144};
    137145
     
    140148void BondGraphTest::ConstructGraphFromCovalentRadiiTest()
    141149{
    142   atom *Walker = TestMolecule->start->next;
    143   atom *Runner = TestMolecule->end->previous;
    144   CPPUNIT_ASSERT( TestMolecule->end != Walker );
     150
     151  //atom *Walker = TestMolecule->start->next;
     152  //atom *Runner = TestMolecule->end->previous;
     153  //CPPUNIT_ASSERT( TestMolecule->end != Walker );
    145154  CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) );
    146155  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    147   CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
     156
     157  // this cannot be assured using dynamic IDs
     158  //CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
    148159};
    149160
  • src/unittests/bondgraphunittest.hpp

    r42af9e r1024cb  
    2222{
    2323    CPPUNIT_TEST_SUITE( BondGraphTest) ;
     24    CPPUNIT_TEST ( SetupTest );
    2425    CPPUNIT_TEST ( LoadTableTest );
    2526    CPPUNIT_TEST ( ConstructGraphFromTableTest );
     
    3031      void setUp();
    3132      void tearDown();
     33      void SetupTest();
    3234      void LoadTableTest();
    3335      void ConstructGraphFromTableTest();
  • src/unittests/listofbondsunittest.cpp

    r42af9e r1024cb  
    6767
    6868  // check that TestMolecule was correctly constructed
    69   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
     69  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    7070};
    7171
     
    8181};
    8282
     83/** Tests whether setup worked correctly.
     84 *
     85 */
     86void ListOfBondsTest::SetupTest()
     87{
     88  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->empty() );
     89  CPPUNIT_ASSERT_EQUAL( (size_t)4, TestMolecule->size() );
     90};
     91
    8392/** Unit Test of molecule::AddBond()
    8493 *
     
    8796{
    8897  bond *Binder = NULL;
    89   atom *atom1 = TestMolecule->start->next;
    90   atom *atom2 = atom1->next;
     98  molecule::iterator iter = TestMolecule->begin();
     99  atom *atom1 = *iter;
     100  iter++;
     101  atom *atom2 = *iter;
    91102  CPPUNIT_ASSERT( atom1 != NULL );
    92103  CPPUNIT_ASSERT( atom2 != NULL );
     
    115126{
    116127  bond *Binder = NULL;
    117   atom *atom1 = TestMolecule->start->next;
    118   atom *atom2 = atom1->next;
     128  molecule::iterator iter = TestMolecule->begin();
     129  atom *atom1 = *iter;
     130  iter++;
     131  atom *atom2 = *iter;
    119132  CPPUNIT_ASSERT( atom1 != NULL );
    120133  CPPUNIT_ASSERT( atom2 != NULL );
     
    141154{
    142155  bond *Binder = NULL;
    143   atom *atom1 = TestMolecule->start->next;
    144   atom *atom2 = atom1->next;
    145   atom *atom3 = atom2->next;
     156  molecule::iterator iter = TestMolecule->begin();
     157  atom *atom1 = *iter;
     158  iter++;
     159  atom *atom2 = *iter;
     160  iter++;
     161  atom *atom3 = *iter;
    146162  CPPUNIT_ASSERT( atom1 != NULL );
    147163  CPPUNIT_ASSERT( atom2 != NULL );
     
    180196{
    181197  bond *Binder = NULL;
    182   atom *atom1 = TestMolecule->start->next;
    183   atom *atom2 = atom1->next;
     198  molecule::iterator iter = TestMolecule->begin();
     199  atom *atom1 = *iter;
     200  iter++;
     201  atom *atom2 = *iter;
    184202  CPPUNIT_ASSERT( atom1 != NULL );
    185203  CPPUNIT_ASSERT( atom2 != NULL );
     
    206224{
    207225  bond *Binder = NULL;
    208   atom *atom1 = TestMolecule->start->next;
    209   atom *atom2 = atom1->next;
     226  molecule::iterator iter = TestMolecule->begin();
     227  atom *atom1 = *iter;
     228  iter++;
     229  atom *atom2 = *iter;
    210230  CPPUNIT_ASSERT( atom1 != NULL );
    211231  CPPUNIT_ASSERT( atom2 != NULL );
     
    231251{
    232252  bond *Binder = NULL;
    233   atom *atom1 = TestMolecule->start->next;
    234   atom *atom2 = atom1->next;
     253  molecule::iterator iter = TestMolecule->begin();
     254  atom *atom1 = *iter;
     255  iter++;
     256  atom *atom2 = *iter;
    235257  CPPUNIT_ASSERT( atom1 != NULL );
    236258  CPPUNIT_ASSERT( atom2 != NULL );
  • src/unittests/listofbondsunittest.hpp

    r42af9e r1024cb  
    2020{
    2121    CPPUNIT_TEST_SUITE( ListOfBondsTest) ;
     22    CPPUNIT_TEST ( SetupTest );
    2223    CPPUNIT_TEST ( AddingBondTest );
    2324    CPPUNIT_TEST ( RemovingBondTest );
     
    3132      void setUp();
    3233      void tearDown();
     34      void SetupTest();
    3335      void AddingBondTest();
    3436      void RemovingBondTest();
  • src/vector.cpp

    r42af9e r1024cb  
    266266 * \return distance to plane
    267267 */
    268 double Vector::DistanceToPlane(const Vector &PlaneNormal, const Vector &PlaneOffset) const
    269 {
    270   return GetDistanceVectorToPlane(PlaneNormal,PlaneOffset).Norm();
     268double Vector::DistanceToSpace(const Space &space) const
     269{
     270  return space.distance(*this);
    271271};
    272272
  • src/vector.hpp

    r42af9e r1024cb  
    4040  double DistanceSquared(const Vector &y) const;
    4141  Vector GetDistanceVectorToPlane(const Vector &PlaneNormal, const Vector &PlaneOffset) const;
    42   double DistanceToPlane(const Vector &PlaneNormal, const Vector &PlaneOffset) const;
     42  double DistanceToSpace(const Space& space) const;
    4343  double PeriodicDistance(const Vector &y, const double * const cell_size) const;
    4444  double PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const;
  • tests/regression/Domain/5/post/test.conf

    r42af9e r1024cb  
    7171Ion_Type2       3       6       1.0     3       3       12.01100000000  Carbon  C
    7272#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)
    73 Ion_Type2_1     4.891042973     3.275186040     3.182297433     0 # molecule nr 0
    74 Ion_Type2_2     4.266392982     4.158586027     3.182297433     0 # molecule nr 1
    75 Ion_Type2_3     3.641792991     3.275186040     3.182297433     0 # molecule nr 2
    76 Ion_Type1_1     4.891042973     2.645886050     2.381297445     0 # molecule nr 3
    77 Ion_Type1_2     4.891042973     2.645886050     3.983297422     0 # molecule nr 4
    78 Ion_Type1_3     5.336019804     3.904536878     3.182297433     0 # molecule nr 5
    79 Ion_Type1_4     4.266392982     4.787886018     2.381297445     0 # molecule nr 6
    80 Ion_Type1_5     4.266392982     4.787886018     3.983297422     0 # molecule nr 7
    81 Ion_Type1_6     3.196816159     3.904536877     3.182297433     0 # molecule nr 8
    82 Ion_Type1_7     3.641792991     2.645886050     2.381297445     0 # molecule nr 9
    83 Ion_Type1_8     3.641792991     2.645886050     3.983297422     0 # molecule nr 10
     73Ion_Type1_1     4.891042973     2.645886050     2.381297445     0 # molecule nr 0
     74Ion_Type1_2     4.891042973     2.645886050     3.983297422     0 # molecule nr 1
     75Ion_Type1_3     5.336019804     3.904536878     3.182297433     0 # molecule nr 2
     76Ion_Type1_4     4.266392982     4.787886018     2.381297445     0 # molecule nr 3
     77Ion_Type1_5     4.266392982     4.787886018     3.983297422     0 # molecule nr 4
     78Ion_Type1_6     3.196816159     3.904536877     3.182297433     0 # molecule nr 5
     79Ion_Type1_7     3.641792991     2.645886050     2.381297445     0 # molecule nr 6
     80Ion_Type1_8     3.641792991     2.645886050     3.983297422     0 # molecule nr 7
     81Ion_Type2_1     4.891042973     3.275186040     3.182297433     0 # molecule nr 8
     82Ion_Type2_2     4.266392982     4.158586027     3.182297433     0 # molecule nr 9
     83Ion_Type2_3     3.641792991     3.275186040     3.182297433     0 # molecule nr 10
  • tests/regression/Domain/5/pre/test.conf

    r42af9e r1024cb  
    7171Ion_Type2       3       6       1.0     3       3       12.01100000000  Carbon  C
    7272#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)
    73 Ion_Type2_1     9.782085945     3.275186040     3.535886037     0 # molecule nr 0
    74 Ion_Type2_2     8.532785963     4.158586027     3.535886037     0 # molecule nr 1
    75 Ion_Type2_3     7.283585982     3.275186040     3.535886037     0 # molecule nr 2
    76 Ion_Type1_1     9.782085945     2.645886050     2.645886050     0 # molecule nr 3
    77 Ion_Type1_2     9.782085945     2.645886050     4.425886024     0 # molecule nr 4
    78 Ion_Type1_3     10.672039608    3.904536878     3.535886037     0 # molecule nr 5
    79 Ion_Type1_4     8.532785963     4.787886018     2.645886050     0 # molecule nr 6
    80 Ion_Type1_5     8.532785963     4.787886018     4.425886024     0 # molecule nr 7
    81 Ion_Type1_6     6.393632318     3.904536877     3.535886037     0 # molecule nr 8
    82 Ion_Type1_7     7.283585982     2.645886050     2.645886050     0 # molecule nr 9
    83 Ion_Type1_8     7.283585982     2.645886050     4.425886024     0 # molecule nr 10
     73Ion_Type1_1     9.782085945     2.645886050     2.645886050     0 # molecule nr 0
     74Ion_Type1_2     9.782085945     2.645886050     4.425886024     0 # molecule nr 1
     75Ion_Type1_3     10.672039608    3.904536878     3.535886037     0 # molecule nr 2
     76Ion_Type1_4     8.532785963     4.787886018     2.645886050     0 # molecule nr 3
     77Ion_Type1_5     8.532785963     4.787886018     4.425886024     0 # molecule nr 4
     78Ion_Type1_6     6.393632318     3.904536877     3.535886037     0 # molecule nr 5
     79Ion_Type1_7     7.283585982     2.645886050     2.645886050     0 # molecule nr 6
     80Ion_Type1_8     7.283585982     2.645886050     4.425886024     0 # molecule nr 7
     81Ion_Type2_1     9.782085945     3.275186040     3.535886037     0 # molecule nr 8
     82Ion_Type2_2     8.532785963     4.158586027     3.535886037     0 # molecule nr 9
     83Ion_Type2_3     7.283585982     3.275186040     3.535886037     0 # molecule nr 10
  • tests/regression/Domain/6/pre/test.conf

    r42af9e r1024cb  
    7171Ion_Type2       3       6       1.0     3       3       12.01100000000  Carbon  C
    7272#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)
    73 Ion_Type2_1     9.782085945     3.275186040     3.535886037     0 # molecule nr 0
    74 Ion_Type2_2     8.532785963     4.158586027     3.535886037     0 # molecule nr 1
    75 Ion_Type2_3     7.283585982     3.275186040     3.535886037     0 # molecule nr 2
    76 Ion_Type1_1     9.782085945     2.645886050     2.645886050     0 # molecule nr 3
    77 Ion_Type1_2     9.782085945     2.645886050     4.425886024     0 # molecule nr 4
    78 Ion_Type1_3     10.672039608    3.904536878     3.535886037     0 # molecule nr 5
    79 Ion_Type1_4     8.532785963     4.787886018     2.645886050     0 # molecule nr 6
    80 Ion_Type1_5     8.532785963     4.787886018     4.425886024     0 # molecule nr 7
    81 Ion_Type1_6     6.393632318     3.904536877     3.535886037     0 # molecule nr 8
    82 Ion_Type1_7     7.283585982     2.645886050     2.645886050     0 # molecule nr 9
    83 Ion_Type1_8     7.283585982     2.645886050     4.425886024     0 # molecule nr 10
     73Ion_Type1_1     9.782085945     2.645886050     2.645886050     0 # molecule nr 0
     74Ion_Type1_2     9.782085945     2.645886050     4.425886024     0 # molecule nr 1
     75Ion_Type1_3     10.672039608    3.904536878     3.535886037     0 # molecule nr 2
     76Ion_Type1_4     8.532785963     4.787886018     2.645886050     0 # molecule nr 3
     77Ion_Type1_5     8.532785963     4.787886018     4.425886024     0 # molecule nr 4
     78Ion_Type1_6     6.393632318     3.904536877     3.535886037     0 # molecule nr 5
     79Ion_Type1_7     7.283585982     2.645886050     2.645886050     0 # molecule nr 6
     80Ion_Type1_8     7.283585982     2.645886050     4.425886024     0 # molecule nr 7
     81Ion_Type2_1     9.782085945     3.275186040     3.535886037     0 # molecule nr 8
     82Ion_Type2_2     8.532785963     4.158586027     3.535886037     0 # molecule nr 9
     83Ion_Type2_3     7.283585982     3.275186040     3.535886037     0 # molecule nr 10
  • tests/regression/testsuite-domain.at

    r42af9e r1024cb  
    4545AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf .], 0)
    4646AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -d 1 1 1], 0, [stdout], [stderr])
    47 AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/test.conf], 0, [stdout], [stderr])
    48 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf .], 0)
    49 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -d 2 1 1], 0, [stdout], [stderr])
    50 AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/test-x.conf], 0, [stdout], [stderr])
    51 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf .], 0)
    52 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -d 1 2 1], 0, [stdout], [stderr])
    53 AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/test-y.conf], 0, [stdout], [stderr])
    54 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf .], 0)
    55 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -d 1 1 2], 0, [stdout], [stderr])
    56 AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/test-z.conf], 0, [stdout], [stderr])
     47AT_CHECK([file=test.conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
     48AT_CHECK([file=test.conf.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
     49AT_CHECK([file=test.conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
     50AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-x.conf], 0)
     51AT_CHECK([../../molecuilder test-x.conf -e ${abs_top_srcdir}/src/ -d 2 1 1], 0, [stdout], [stderr])
     52AT_CHECK([file=test-x.conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
     53AT_CHECK([file=test-x.conf.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
     54AT_CHECK([file=test-x.conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
     55AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-y.conf], 0)
     56AT_CHECK([../../molecuilder test-y.conf -e ${abs_top_srcdir}/src/ -d 1 2 1], 0, [stdout], [stderr])
     57AT_CHECK([file=test-y.conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
     58AT_CHECK([file=test-y.conf.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
     59AT_CHECK([file=test-y.conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
     60AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-z.conf], 0)
     61AT_CHECK([../../molecuilder test-z.conf -e ${abs_top_srcdir}/src/ -d 1 1 2], 0, [stdout], [stderr])
     62AT_CHECK([file=test-z.conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
     63AT_CHECK([file=test-z.conf.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
     64AT_CHECK([file=test-z.conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
     65#AT_CHECK([/bin/false], 12, [ignore], [ignore])
    5766AT_CLEANUP
  • tests/regression/testsuite-simple_configuration.at

    r42af9e r1024cb  
    8787AT_KEYWORDS([configuration])
    8888AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.* .], 0)
    89 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -R 2 7.], 0, [stdout], [stderr])
    90 AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
     89AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -R 7.283585982 3.275186040 3.535886037 7.], 0, [stdout], [stderr])
     90AT_CHECK([sort -n test.conf.xyz | grep -v "Created by" >test.conf.xyz-sorted], 0, [ignore], [ignore])
     91AT_CHECK([sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/test.conf.xyz  | grep -v "Created by" >${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/test.conf.xyz-sorted], 0, [ignore], [ignore])
     92AT_CHECK([file=test.conf.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
    9193AT_CLEANUP
Note: See TracChangeset for help on using the changeset viewer.