Changes in / [42af9e:1024cb]
- Files:
-
- 6 added
- 6 deleted
- 55 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FragmentationAction/DepthFirstSearchAction.cpp
r42af9e r1024cb 46 46 molecule * const mol = World::getInstance().getMolecule(MoleculeById(0)); 47 47 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 48 int *MinimumRingSize = new int[mol-> AtomCount];48 int *MinimumRingSize = new int[mol->getAtomCount()]; 49 49 atom ***ListOfLocalAtoms = NULL; 50 50 class StackClass<bond *> *BackEdgeStack = NULL; -
src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp
r42af9e r1024cb 65 65 DoLog(0) && (Log() << Verbose(0) << "Evaluating non-convex envelope of molecule." << Boundary->getId() << endl); 66 66 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); 68 68 start = clock(); 69 69 LCList = new LinkedCell(Boundary, SphereRadius*2.); -
src/Actions/WorldAction/RepeatBoxAction.cpp
r42af9e r1024cb 40 40 molecule *mol = NULL; 41 41 int j = 0; 42 atom *Walker = NULL; 42 43 43 44 dialog->queryVector(NAME, &Repeater, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME)); … … 54 55 Repeater[axis] = 1; 55 56 } 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 59 59 Elements = new const element *[count]; 60 60 vectors = new Vector *[count]; 61 61 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; 67 65 j++; 68 66 } … … 75 73 x += y; // per factor one cell width further 76 74 for (int k=count;k--;) { // go through every atom of the original cell 77 first= World::getInstance().createAtom(); // create a new body78 first->x = (*vectors[k]) + x;79 first->type = Elements[k]; // insert original element80 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, ...) 81 79 } 82 80 } -
src/Helpers/Assert.cpp
r42af9e r1024cb 54 54 55 55 56 57 56 bool _my_assert::check(const bool res, 58 57 const char* condition, … … 63 62 { 64 63 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; 66 65 cout << "Assertion Message: " << message << std::endl; 67 66 while(true){ -
src/Helpers/MemDebug.cpp
r42af9e r1024cb 9 9 #include <cstdlib> 10 10 #include <cstring> 11 #include <boost/thread.hpp> 11 12 12 13 using namespace std; 14 15 #ifndef NDBEGUG 16 #ifndef NO_MEMDEBUG 13 17 14 18 namespace Memory { … … 40 44 }; 41 45 46 boost::mutex memorylock; 47 42 48 // start and end of the doubly-linked list 43 49 entry_t *begin=0; … … 127 133 128 134 void *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); 129 138 130 139 // to avoid allocations of 0 bytes if someone screws up … … 204 213 205 214 void 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 206 223 // get the size for the entry, including alignment 207 224 static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t)); … … 212 229 // let's see if the checksum is still matching 213 230 if(Memory::calcChecksum(&entry->info)!=entry->checksum){ 214 c out<< "Possible memory corruption detected!" << endl;215 c out<< "Trying to recover allocation information..." << endl;216 c out<< "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; 217 234 terminate(); 218 235 } … … 241 258 operator delete(ptr); 242 259 } 260 #endif 261 #endif -
src/Helpers/MemDebug.hpp
r42af9e r1024cb 21 21 * your sourcefiles. 22 22 */ 23 #ifndef NDEBUG 24 #ifndef NO_MEMDEBUG 25 26 #ifndef MEMDEBUG 27 #define MEMDEBUG 28 #endif 23 29 24 30 namespace Memory { … … 56 62 #define new new(__FILE__,__LINE__) 57 63 64 #endif 65 #endif 66 67 68 #ifndef MEMDEBUG 69 // memory debugging was disabled 70 71 namespace Memory { 72 inline void getState(){} 73 74 template <typename T> 75 inline T *ignore(T* ptr){ 76 return ptr; 77 } 78 } 79 80 #endif 58 81 #endif /* MEMDEBUG_HPP_ */ -
src/Legacy/oldmenu.cpp
r42af9e r1024cb 424 424 void oldmenu::RemoveAtoms(molecule *mol) 425 425 { 426 atom * first, *second;426 atom *second; 427 427 int axis; 428 428 double tmp1, tmp2; … … 447 447 break; 448 448 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 } 459 459 } 460 460 break; … … 466 466 Log() << Verbose(0) << "Upper boundary: "; 467 467 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)); 476 474 } 477 475 } … … 516 514 min[i] = 0.; 517 515 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; 522 518 tmp1 = 0.; 523 if (first != second) {524 x = first->x - second->x;519 if (first != (*iter)) { 520 x = first->x - (*iter)->x; 525 521 tmp1 = x.Norm(); 526 522 } 527 523 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; 529 525 } 530 526 for (int i=MAX_ELEMENTS;i--;) … … 755 751 Log() << Verbose(0) << "State the factor: "; 756 752 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 761 755 Elements = new const element *[count]; 762 756 vectors = new Vector *[count]; 763 757 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; 769 761 j++; 770 762 } … … 1025 1017 return; 1026 1018 } 1027 atom *Walker = mol->start;1028 1019 1029 1020 // generate some KeySets 1030 1021 Log() << Verbose(0) << "Generating KeySets." << endl; 1031 KeySet TestSets[mol-> AtomCount+1];1022 KeySet TestSets[mol->getAtomCount()+1]; 1032 1023 i=1; 1033 while (Walker->next != mol->end) { 1034 Walker = Walker->next; 1024 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1035 1025 for (int j=0;j<i;j++) { 1036 TestSets[j].insert( Walker->nr);1026 TestSets[j].insert((*iter)->nr); 1037 1027 } 1038 1028 i++; … … 1040 1030 Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl; 1041 1031 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 } 1045 1040 } 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 } 1050 1043 1051 1044 // constructing Graph structure … … 1055 1048 // insert KeySets into Subgraphs 1056 1049 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++) { 1058 1051 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.))); 1059 1052 } 1060 1053 Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl; 1061 1054 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.))); 1063 1056 if (test2.second) { 1064 1057 Log() << Verbose(1) << "Insertion worked?!" << endl; -
src/Makefile.am
r42af9e r1024cb 115 115 Descriptors/MoleculeIdDescriptor.cpp 116 116 117 117 118 118 DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \ 119 119 Descriptors/AtomIdDescriptor.hpp \ … … 157 157 Line.cpp \ 158 158 linkedcell.cpp \ 159 lists.cpp \160 159 log.cpp \ 161 160 logger.cpp \ … … 170 169 periodentafel.cpp \ 171 170 Plane.cpp \ 171 Space.cpp \ 172 172 tesselation.cpp \ 173 173 tesselationhelpers.cpp \ 174 174 triangleintersectionlist.cpp \ 175 vector.cpp \ 176 vector_ops.cpp \ 175 177 verbose.cpp \ 176 vector_ops.cpp \177 178 World.cpp 178 179 … … 220 221 # the following files are no longer used: 221 222 # memoryallocator.hpp \ 223 # memoryallocator.cpp \ 222 224 # memoryusageobserver.hpp \ 223 225 # memoryusageobserver.cpp -
src/Patterns/Cacheable.hpp
r42af9e r1024cb 28 28 owner(_owner) 29 29 {} 30 virtual T getValue()=0;30 virtual T& getValue()=0; 31 31 virtual void invalidate()=0; 32 32 virtual bool isValid()=0; … … 46 46 {} 47 47 48 virtual T getValue(){48 virtual T& getValue(){ 49 49 // set the state to valid 50 50 State::owner->switchState(State::owner->validState); … … 72 72 {} 73 73 74 virtual T getValue(){74 virtual T& getValue(){ 75 75 return content; 76 76 } … … 100 100 {} 101 101 102 virtual T getValue(){102 virtual T& getValue(){ 103 103 ASSERT(0,"Cannot get a value from a Cacheable after it's Observable has died"); 104 104 // we have to return a grossly invalid reference, because no value can be produced anymore … … 134 134 void subjectKilled(Observable *subject); 135 135 private: 136 137 136 void switchState(state_ptr newState); 138 137 … … 144 143 145 144 Observable *owner; 146 147 145 boost::function<T()> recalcMethod; 148 146 … … 221 219 222 220 const bool isValid() const; 223 const T operator*() const;221 const T& operator*() const; 224 222 225 223 // methods implemented for base-class Observer … … 237 235 238 236 template<typename T> 239 const T Cacheable<T>::operator*() const{237 const T& Cacheable<T>::operator*() const{ 240 238 return recalcMethod(); 241 239 } -
src/Patterns/Observer.cpp
r42af9e r1024cb 82 82 Observable::_Observable_protector::_Observable_protector(Observable *_protege) : 83 83 protege(_protege) 84 { 85 start_observer_internal(protege); 86 } 87 88 Observable::_Observable_protector::_Observable_protector(const _Observable_protector &dest) : 89 protege(dest.protege) 84 90 { 85 91 start_observer_internal(protege); … … 189 195 ASSERT(callTable.count(this),"SignOff called for an Observable without Observers."); 190 196 callees_t &callees = callTable[this]; 197 191 198 callees_t::iterator iter; 192 199 callees_t::iterator deliter; -
src/Patterns/Observer.hpp
r42af9e r1024cb 36 36 typedef Notification *const Notification_ptr; 37 37 38 template<class _Set> 39 class ObservedIterator; 40 38 41 /** 39 42 * An Observer is notified by all Observed objects, when anything changes. … … 53 56 friend class Observable; 54 57 friend class Notification; 58 template<class> friend class ObservedIterator; 59 55 60 public: 56 61 Observer(); … … 152 157 static std::set<Observable*> busyObservables; 153 158 154 155 159 //! @cond 156 160 // Structure for RAII-Style notification … … 164 168 public: 165 169 _Observable_protector(Observable *); 170 _Observable_protector(const _Observable_protector&); 166 171 ~_Observable_protector(); 167 172 private: -
src/Plane.cpp
r42af9e r1024cb 91 91 offset = normalVector->ScalarProduct(_offsetVector); 92 92 } 93 94 /** 95 * copy constructor 96 */ 97 Plane::Plane(const Plane& plane) : 98 normalVector(new Vector(*plane.normalVector)), 99 offset(plane.offset) 100 {} 101 93 102 94 103 Plane::~Plane() -
src/Plane.hpp
r42af9e r1024cb 26 26 Plane(const Vector &_normalVector, double _offset) throw(ZeroVectorException); 27 27 Plane(const Vector &_normalVector, const Vector &_offsetVector) throw(ZeroVectorException); 28 Plane(const Plane& plane); 28 29 virtual ~Plane(); 29 30 -
src/analysis_bonds.cpp
r42af9e r1024cb 26 26 Mean = 0.; 27 27 28 atom *Walker = mol->start;29 28 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(); 33 31 if (Max < count) 34 32 Max = count; … … 58 56 59 57 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) { 66 62 const double distance = (*BondRunner)->GetDistanceSquared(); 67 63 if (Min > distance) … … 126 122 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL) 127 123 { 128 atom *Walker = NULL;129 atom *Runner = NULL;130 124 int count = 0; 131 125 int OtherHydrogens = 0; … … 133 127 bool InterfaceFlag = false; 134 128 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)) { 144 136 // check distance 145 const double distance = Runner->x.DistanceSquared(Walker->x);137 const double distance = (*Runner)->x.DistanceSquared((*Walker)->x); 146 138 if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means different atoms 147 139 // on other atom(Runner) we check for bond to interface element and … … 151 143 OtherHydrogens = 0; 152 144 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); 155 147 // if hydrogen, check angle to be greater(!) than 30 degrees 156 148 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); 158 150 OtherHydrogenFlag = OtherHydrogenFlag && (angle > M_PI*(30./180.) + MYEPSILON); 159 151 Otherangle += angle; … … 176 168 if (InterfaceFlag && OtherHydrogenFlag) { 177 169 // 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); 180 172 if (OtherAtom->type->Z == 1) { 181 173 // 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); 184 176 count++; 185 177 break; … … 205 197 int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second) 206 198 { 207 atom *Walker = NULL;208 199 int count = 0; 209 200 210 201 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 matches215 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)) { 218 209 count++; 219 210 DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl); … … 240 231 bool MatchFlag[2]; 241 232 bool result = false; 242 atom *Walker = NULL;243 233 const element * ElementArray[2]; 244 234 ElementArray[0] = first; … … 246 236 247 237 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 matches238 molecule::iterator Walker = (*MolWalker)->begin(); 239 for(;Walker!=(*MolWalker)->end();++Walker){ 240 atom *theAtom = *Walker; 241 if (theAtom->type == second) { // first element matches 252 242 for (int i=0;i<2;i++) 253 243 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); 256 246 for (int i=0;i<2;i++) 257 247 if ((!MatchFlag[i]) && (OtherAtom->type == ElementArray[i])) { -
src/analysis_correlation.cpp
r42af9e r1024cb 40 40 } 41 41 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++){ 43 43 if ((*MolWalker)->ActiveFlag) { 44 44 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++){ 51 50 if ((*MolOtherWalker)->ActiveFlag) { 52 51 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)) ) ); 62 59 } 60 } 63 61 } 62 } 64 63 } 65 64 } 66 65 } 67 66 } 68 67 } 69 68 return outmap; 70 69 }; … … 101 100 double * FullInverseMatrix = InverseMatrix(FullMatrix); 102 101 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; 109 106 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 110 107 // go through every range in xyz and get distance … … 117 114 if ((*MolOtherWalker)->ActiveFlag) { 118 115 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; 126 121 periodicOtherX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 127 122 // go through every range in xyz and get distance … … 132 127 checkOtherX.MatrixMultiplication(FullMatrix); 133 128 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)) ) ); 136 131 } 137 132 } … … 169 164 if ((*MolWalker)->ActiveFlag) { 170 165 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()); 177 170 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) ) ); 179 172 } 180 173 } … … 211 204 double * FullInverseMatrix = InverseMatrix(FullMatrix); 212 205 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; 219 210 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 220 211 // go through every range in xyz and get distance … … 226 217 distance = checkX.distance(*point); 227 218 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) ) ); 229 220 } 230 221 } … … 261 252 if ((*MolWalker)->ActiveFlag) { 262 253 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); 269 258 distance = Intersections.GetSmallestDistance(); 270 259 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) ) ); 272 261 } 273 262 } … … 314 303 double * FullInverseMatrix = InverseMatrix(FullMatrix); 315 304 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; 322 309 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 323 310 // go through every range in xyz and get distance … … 337 324 } 338 325 // 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) ) ); 340 327 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; 341 328 } -
src/atom.cpp
r42af9e r1024cb 59 59 atom::~atom() 60 60 { 61 unlink(this);62 61 }; 63 62 -
src/bondgraph.cpp
r42af9e r1024cb 90 90 bool status = true; 91 91 92 if (mol-> start->next == mol->end) // only construct if molecule is not empty92 if (mol->empty()) // only construct if molecule is not empty 93 93 return false; 94 94 … … 124 124 max_distance = 0.; 125 125 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; 131 129 } 132 130 max_distance *= 2.; -
src/boundary.cpp
r42af9e r1024cb 139 139 { 140 140 Info FunctionInfo(__func__); 141 atom *Walker = NULL;142 141 PointMap PointsOnBoundary; 143 142 LineMap LinesOnBoundary; … … 165 164 166 165 // 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); 171 168 ProjectedVector.ProjectOntoPlane(AxisVector); 172 169 … … 182 179 angle = 2. * M_PI - angle; 183 180 } 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)))); 186 183 if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity 187 184 DoLog(2) && (Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl); 188 185 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); 190 187 const double ProjectedVectorNorm = ProjectedVector.NormSquared(); 191 188 if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) { 192 189 BoundaryTestPair.first->second.first = ProjectedVectorNorm; 193 BoundaryTestPair.first->second.second = Walker;190 BoundaryTestPair.first->second.second = (*iter); 194 191 DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl); 195 192 } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) { 196 helper = Walker->x - (*MolCenter); 193 helper = (*iter)->x; 194 helper -= *MolCenter; 197 195 const double oldhelperNorm = helper.NormSquared(); 198 196 helper = BoundaryTestPair.first->second.second->x - (*MolCenter); 199 197 if (helper.NormSquared() < oldhelperNorm) { 200 BoundaryTestPair.first->second.second = Walker;198 BoundaryTestPair.first->second.second = (*iter); 201 199 DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl); 202 200 } else { … … 620 618 for (TriangleMap::iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++) 621 619 { // 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)); 627 625 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)); 632 628 const double h = x.Norm(); // distance of CoG to triangle 633 629 const double PyramidVolume = (1. / 3.) * G * h; // this formula holds for _all_ pyramids (independent of n-edge base or (not) centered peak) … … 697 693 int repetition[NDIM] = { 1, 1, 1 }; 698 694 int TotalNoClusters = 1; 699 atom *Walker = NULL;700 695 double totalmass = 0.; 701 696 double clustervolume = 0.; … … 721 716 722 717 // 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; 727 720 } 728 721 DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl); … … 806 799 Vector Inserter; 807 800 double FillIt = false; 808 atom *Walker = NULL;809 801 bond *Binder = NULL; 810 802 double phi[NDIM]; … … 813 805 814 806 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) 815 if ((*ListRunner)-> AtomCount> 0) {807 if ((*ListRunner)->getAtomCount() > 0) { 816 808 DoLog(1) && (Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl); 817 809 LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list … … 831 823 } 832 824 833 filler->CountAtoms(); 834 atom * CopyAtoms[filler->AtomCount]; 825 atom * CopyAtoms[filler->getAtomCount()]; 835 826 836 827 // calculate filler grid in [0,1]^3 … … 857 848 858 849 // go through all atoms 859 for (int i=0;i<filler-> AtomCount;i++)850 for (int i=0;i<filler->getAtomCount();i++) 860 851 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){ 864 853 865 854 // create atomic random translation vector ... … … 885 874 886 875 // ... and put at new position 887 Inserter = Walker->x;876 Inserter = (*iter)->x; 888 877 if (DoRandomRotation) 889 878 Inserter.MatrixMultiplication(Rotations); … … 909 898 DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl); 910 899 // 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); 915 904 } else { 916 905 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; 918 907 continue; 919 908 } … … 954 943 bool TesselationFailFlag = false; 955 944 945 mol->getAtomCount(); 946 956 947 if (TesselStruct == NULL) { 957 948 DoLog(1) && (Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl); … … 1025 1016 // // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles 1026 1017 // //->InsertStraddlingPoints(mol, LCList); 1027 // mol->GoToFirst();1018 // for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1028 1019 // class TesselPoint *Runner = NULL; 1029 // while (!mol->IsEnd()) { 1030 // Runner = mol->GetPoint(); 1020 // Runner = *iter; 1031 1021 // Log() << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl; 1032 1022 // if (!->IsInnerPoint(Runner, LCList)) { … … 1036 1026 // Log() << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl; 1037 1027 // } 1038 // mol->GoToNext();1039 1028 // } 1040 1029 … … 1045 1034 status = CheckListOfBaselines(TesselStruct); 1046 1035 1036 cout << "before correction" << endl; 1037 1047 1038 // store before correction 1048 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");1039 StoreTrianglesinFile(mol, TesselStruct, filename, ""); 1049 1040 1050 1041 // // correct degenerated polygons … … 1056 1047 // write final envelope 1057 1048 CalculateConcavityPerBoundaryPoint(TesselStruct); 1058 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, ""); 1049 cout << "after correction" << endl; 1050 StoreTrianglesinFile(mol, TesselStruct, filename, ""); 1059 1051 1060 1052 if (freeLC) -
src/builder.cpp
r42af9e r1024cb 865 865 866 866 mol->CountAtoms(); // recount atoms 867 if (mol-> AtomCount!= 0) { // if there is more than none868 count = mol-> AtomCount; // is changed becausing of adding, thus has to be stored away beforehand867 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 869 869 Elements = new element *[count]; 870 870 vectors = new Vector *[count]; … … 1296 1296 // generate some KeySets 1297 1297 DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl); 1298 KeySet TestSets[mol-> AtomCount+1];1298 KeySet TestSets[mol->getAtomCount()+1]; 1299 1299 i=1; 1300 1300 while (Walker->next != mol->end) { … … 1307 1307 DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl); 1308 1308 KeySetTestPair test; 1309 test = TestSets[mol-> AtomCount-1].insert(Walker->nr);1309 test = TestSets[mol->getAtomCount()-1].insert(Walker->nr); 1310 1310 if (test.second) { 1311 1311 DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl); … … 1313 1313 DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl); 1314 1314 } 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); 1317 1317 1318 1318 // constructing Graph structure … … 1322 1322 // insert KeySets into Subgraphs 1323 1323 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++) { 1325 1325 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.))); 1326 1326 } 1327 1327 DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl); 1328 1328 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.))); 1330 1330 if (test2.second) { 1331 1331 DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl); … … 1714 1714 if (first->type != NULL) { 1715 1715 mol->AddAtom(first); // add to molecule 1716 if ((configPresent == empty) && (mol-> AtomCount!= 0))1716 if ((configPresent == empty) && (mol->getAtomCount() != 0)) 1717 1717 configPresent = present; 1718 1718 } else … … 1732 1732 DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl); 1733 1733 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 1734 int *MinimumRingSize = new int[mol-> AtomCount];1734 int *MinimumRingSize = new int[mol->getAtomCount()]; 1735 1735 atom ***ListOfLocalAtoms = NULL; 1736 1736 class StackClass<bond *> *BackEdgeStack = NULL; … … 1880 1880 int counter = 0; 1881 1881 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())) { 1883 1883 Boundary = *BigFinder; 1884 1884 } … … 1939 1939 performCriticalExit(); 1940 1940 } else { 1941 mol->getAtomCount(); 1941 1942 SaveFlag = true; 1942 1943 DoLog(1) && (Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl); … … 2042 2043 int counter = 0; 2043 2044 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())) { 2046 2046 Boundary = *BigFinder; 2047 2047 } 2048 2048 counter++; 2049 2049 } 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); 2051 2051 start = clock(); 2052 2052 LCList = new LinkedCell(Boundary, atof(argv[argptr])*2.); … … 2115 2115 case 'R': 2116 2116 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]))) { 2118 2118 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); 2120 2120 performCriticalExit(); 2121 2121 } else { 2122 2122 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); 2135 2135 } 2136 } else {2137 DoeLog(1) && (eLog()<< Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl);2138 2136 } 2139 argptr+= 2;2137 argptr+=4; 2140 2138 } 2141 2139 break; … … 2262 2260 performCriticalExit(); 2263 2261 } else { 2262 mol->getAtomCount(); 2264 2263 SaveFlag = true; 2265 2264 DoLog(1) && (Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl); … … 2381 2380 faktor = 1; 2382 2381 } 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 2386 2384 Elements = new const element *[count]; 2387 2385 vectors = new Vector *[count]; 2388 2386 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; 2394 2390 j++; 2395 2391 } … … 2458 2454 { 2459 2455 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; 2460 2459 Vector x, y, z, n; 2461 2460 ifstream test; … … 2481 2480 // need to init the history before any action is created 2482 2481 ActionHistory::init(); 2482 2483 // In the interactive mode, we can leave the user the choice in case of error 2484 ASSERT_DO(Assert::Ask); 2483 2485 2484 2486 // from this moment on, we need to be sure to deeinitialize in the correct order -
src/config.cpp
r42af9e r1024cb 1548 1548 int AtomNo = -1; 1549 1549 int MolNo = 0; 1550 atom *Walker = NULL;1551 1550 FILE *f = NULL; 1552 1551 … … 1561 1560 fprintf(f, "# Created by MoleCuilder\n"); 1562 1561 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++) { 1565 1563 int *elementNo = new int[MAX_ELEMENTS]; 1566 1564 for (int i=0;i<MAX_ELEMENTS;i++) 1567 1565 elementNo[i] = 0; 1568 1566 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 1573 1570 fprintf(f, 1574 1571 "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 */ 1576 1573 name, /* atom name */ 1577 (* Runner)->name, /* residue name */1574 (*MolRunner)->name, /* residue name */ 1578 1575 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1579 1576 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 */ 1585 1582 "0", /* segment identifier */ 1586 Walker->type->symbol, /* element symbol */1583 (*iter)->type->symbol, /* element symbol */ 1587 1584 "0"); /* charge */ 1588 1585 AtomNo++; … … 1604 1601 { 1605 1602 int AtomNo = -1; 1606 atom *Walker = NULL;1607 1603 FILE *f = NULL; 1608 1604 … … 1621 1617 fprintf(f, "# Created by MoleCuilder\n"); 1622 1618 1623 Walker = mol->start;1624 1619 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 1629 1623 fprintf(f, 1630 1624 "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 */ 1632 1626 name, /* atom name */ 1633 1627 mol->name, /* residue name */ 1634 1628 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1635 1629 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 */ 1641 1635 "0", /* segment identifier */ 1642 Walker->type->symbol, /* element symbol */1636 (*iter)->type->symbol, /* element symbol */ 1643 1637 "0"); /* charge */ 1644 1638 AtomNo++; … … 1658 1652 bool config::SaveTREMOLO(const char * const filename, const molecule * const mol) const 1659 1653 { 1660 atom *Walker = NULL;1661 1654 ofstream *output = NULL; 1662 1655 stringstream * const fname = new stringstream; … … 1671 1664 1672 1665 // scan maximum number of neighbours 1673 Walker = mol->start;1674 1666 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(); 1678 1669 if (MaxNeighbours < count) 1679 1670 MaxNeighbours = count; 1680 1671 } 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"; 1688 1677 *output << mol->name << "\t"; 1689 1678 *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++) 1696 1685 *output << "-\t"; 1697 1686 *output << endl; … … 1714 1703 { 1715 1704 Info FunctionInfo(__func__); 1716 atom *Walker = NULL;1717 1705 ofstream *output = NULL; 1718 1706 stringstream * const fname = new stringstream; … … 1729 1717 int MaxNeighbours = 0; 1730 1718 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(); 1735 1721 if (MaxNeighbours < count) 1736 1722 MaxNeighbours = count; 1737 1723 } 1738 1724 } 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; 1740 1726 1741 1727 // create global to local id map … … 1745 1731 int AtomNo = 1; 1746 1732 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++) ); 1751 1735 } 1752 1736 MolCounter++; … … 1760 1744 int AtomNo = 0; 1761 1745 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"; 1767 1749 *output << (*MolWalker)->name << "\t"; 1768 1750 *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++) 1775 1757 *output << "-\t"; 1776 1758 *output << endl; … … 1813 1795 if (output == NULL) 1814 1796 strcpy(filename,"main_pcp_linux"); 1815 Log() << Verbose(0) << "Saving as pdb input ";1797 Log() << Verbose(0) << "Saving as pdb input ... " << endl; 1816 1798 if (SavePDB(filename, molecules)) 1817 Log() << Verbose(0) << " done." << endl;1799 Log() << Verbose(0) << "\t... done." << endl; 1818 1800 else 1819 Log() << Verbose(0) << " failed." << endl;1801 Log() << Verbose(0) << "\t... failed." << endl; 1820 1802 1821 1803 // then save as tremolo data file … … 1824 1806 if (output == NULL) 1825 1807 strcpy(filename,"main_pcp_linux"); 1826 Log() << Verbose(0) << "Saving as tremolo data input ";1808 Log() << Verbose(0) << "Saving as tremolo data input ... " << endl; 1827 1809 if (SaveTREMOLO(filename, molecules)) 1828 Log() << Verbose(0) << " done." << endl;1810 Log() << Verbose(0) << "\t... done." << endl; 1829 1811 else 1830 Log() << Verbose(0) << " failed." << endl;1812 Log() << Verbose(0) << "\t... failed." << endl; 1831 1813 1832 1814 // translate each to its center and merge all molecules in MoleculeListClass into this molecule … … 1864 1846 output.close(); 1865 1847 output.clear(); 1866 Log() << Verbose(0) << "Saving of config file ";1848 Log() << Verbose(0) << "Saving of config file ... " << endl; 1867 1849 if (Save(filename, periode, mol)) 1868 Log() << Verbose(0) << " successful." << endl;1850 Log() << Verbose(0) << "\t... successful." << endl; 1869 1851 else 1870 Log() << Verbose(0) << " failed." << endl;1852 Log() << Verbose(0) << "\t... failed." << endl; 1871 1853 1872 1854 // and save to xyz file … … 1881 1863 output.open(filename, ios::trunc); 1882 1864 } 1883 Log() << Verbose(0) << "Saving of XYZ file ";1865 Log() << Verbose(0) << "Saving of XYZ file ... " << endl; 1884 1866 if (mol->MDSteps <= 1) { 1885 1867 if (mol->OutputXYZ(&output)) 1886 Log() << Verbose(0) << " successful." << endl;1868 Log() << Verbose(0) << "\t... successful." << endl; 1887 1869 else 1888 Log() << Verbose(0) << " failed." << endl;1870 Log() << Verbose(0) << "\t... failed." << endl; 1889 1871 } else { 1890 1872 if (mol->OutputTrajectoriesXYZ(&output)) 1891 Log() << Verbose(0) << " successful." << endl;1873 Log() << Verbose(0) << "\t... successful." << endl; 1892 1874 else 1893 Log() << Verbose(0) << " failed." << endl;1875 Log() << Verbose(0) << "\t... failed." << endl; 1894 1876 } 1895 1877 output.close(); … … 1901 1883 if (output == NULL) 1902 1884 strcpy(filename,"main_pcp_linux"); 1903 Log() << Verbose(0) << "Saving as mpqc input ";1885 Log() << Verbose(0) << "Saving as mpqc input .. " << endl; 1904 1886 if (SaveMPQC(filename, mol)) 1905 Log() << Verbose(0) << " done." << endl;1887 Log() << Verbose(0) << "\t... done." << endl; 1906 1888 else 1907 Log() << Verbose(0) << " failed." << endl;1889 Log() << Verbose(0) << "\t... failed." << endl; 1908 1890 1909 1891 if (!strcmp(configpath, GetDefaultPath())) { -
src/helpers.cpp
r42af9e r1024cb 180 180 181 181 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 allocate186 * \param failure message which is printed if the allocation fails187 * \return pointer to the allocated memory range, will be NULL if a failure occurred188 */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 207 182 /** 208 183 * Calls exit(255). -
src/helpers.hpp
r42af9e r1024cb 139 139 }; 140 140 141 141 142 /** Frees a two-dimensional array. 142 143 * \param *ptr pointer to array -
src/lists.hpp
r42af9e r1024cb 134 134 }; 135 135 136 /** Returns the first marker in a chain list.137 * \param *me one arbitrary item in chain list138 * \return poiner to first marker139 */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 list150 * \return poiner to last marker151 */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 160 136 #endif /* LISTS_HPP_ */ -
src/molecule.cpp
r42af9e r1024cb 35 35 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero. 36 36 */ 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),37 molecule::molecule(const periodentafel * const teil) : elemente(teil), 38 first(new bond(0, 0, 1, -1)), last(new bond(0, 0, 1, -1)), MDSteps(0), 39 39 BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.), 40 40 ActiveFlag(false), IndexNr(-1), 41 41 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 { 50 44 // init bond chain list 51 45 link(first,last); … … 69 63 delete(first); 70 64 delete(last); 71 end->getWorld()->destroyAtom(end);72 start->getWorld()->destroyAtom(start);73 65 }; 74 66 … … 81 73 const std::string molecule::getName(){ 82 74 return std::string(name); 75 } 76 77 int molecule::getAtomCount() const{ 78 return *AtomCount; 83 79 } 84 80 … … 104 100 stringstream sstr; 105 101 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()]++; 108 104 } 109 105 std::map<atomicNumber_t,unsigned int>::reverse_iterator iter; … … 115 111 } 116 112 113 /************************** Access to the List of Atoms ****************/ 114 115 116 molecule::iterator molecule::begin(){ 117 return molecule::iterator(atoms.begin(),this); 118 } 119 120 molecule::const_iterator molecule::begin() const{ 121 return atoms.begin(); 122 } 123 124 molecule::iterator molecule::end(){ 125 return molecule::iterator(atoms.end(),this); 126 } 127 128 molecule::const_iterator molecule::end() const{ 129 return atoms.end(); 130 } 131 132 bool molecule::empty() const 133 { 134 return (begin() == end()); 135 } 136 137 size_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 145 molecule::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 153 molecule::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 164 molecule::const_iterator molecule::find ( atom *& key ) const 165 { 166 return atoms.find( key ); 167 } 168 169 pair<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 } 117 174 118 175 /** Adds given atom \a *pointer from molecule list. … … 123 180 bool molecule::AddAtom(atom *pointer) 124 181 { 125 bool retval = false;126 182 OBSERVE; 127 183 if (pointer != NULL) { 128 184 pointer->sort = &pointer->nr; 129 pointer->nr = last_atom++; // increase number within molecule130 AtomCount++;131 185 if (pointer->type != NULL) { 132 186 if (ElementsInMolecule[pointer->type->Z] == 0) … … 141 195 } 142 196 } 143 retval = add(pointer, end);144 } 145 return retval;197 insert(pointer); 198 } 199 return true; 146 200 }; 147 201 … … 157 211 if (pointer != NULL) { 158 212 atom *walker = pointer->clone(); 159 stringstream sstr; 160 sstr << pointer->getName(); 161 walker->setName(sstr.str()); 213 walker->setName(pointer->getName()); 162 214 walker->nr = last_atom++; // increase number within molecule 163 add(walker, end);215 insert(walker); 164 216 if ((pointer->type != NULL) && (pointer->type->Z != 1)) 165 217 NoNonHydrogen++; 166 AtomCount++;167 218 retval=walker; 168 219 } … … 575 626 576 627 // copy values 577 copy->CountAtoms();578 628 copy->CountElements(); 579 629 if (first->next != last) { // if adjaceny list is present … … 610 660 { 611 661 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 622 676 return Binder; 623 677 }; … … 693 747 bool molecule::RemoveAtom(atom *pointer) 694 748 { 749 ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom()."); 750 OBSERVE; 695 751 if (ElementsInMolecule[pointer->type->Z] != 0) { // this would indicate an error 696 752 ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element 697 AtomCount--;698 753 } else 699 754 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); … … 701 756 ElementCount--; 702 757 RemoveBonds(pointer); 703 return remove(pointer, start, end); 758 erase(pointer); 759 return true; 704 760 }; 705 761 … … 718 774 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 719 775 ElementCount--; 720 unlink(pointer);776 erase(pointer); 721 777 return true; 722 778 }; … … 727 783 bool molecule::CleanupMolecule() 728 784 { 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)); 730 788 }; 731 789 … … 734 792 * \return pointer to atom or NULL 735 793 */ 736 atom * molecule::FindAtom(int Nr) const{ 737 atom * walker = find(&Nr, start,end); 738 if (walker != NULL) { 794 atom * 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()) { 739 801 //Log() << Verbose(0) << "Found Atom Nr. " << walker->nr << endl; 740 return walker;802 return (*iter); 741 803 } else { 742 804 DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl); … … 868 930 now = time((time_t *)NULL); // Get the system time and put it into 'now' as 'calender time' 869 931 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); 871 933 ActOnAllAtoms( &atom::OutputTrajectoryXYZ, output, step ); 872 934 } … … 885 947 if (output != NULL) { 886 948 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); 888 950 ActOnAllAtoms( &atom::OutputXYZLine, output ); 889 951 return true; … … 895 957 * \param *out output stream for debugging 896 958 */ 897 void molecule::CountAtoms() 898 { 959 int molecule::doCountAtoms() 960 { 961 int res = size(); 899 962 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; 903 972 i++; 904 973 } 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; 928 975 }; 929 976 … … 987 1034 /// first count both their atoms and elements and update lists thereby ... 988 1035 //Log() << Verbose(0) << "Counting atoms, updating list" << endl; 989 CountAtoms();990 OtherMolecule->CountAtoms();991 1036 CountElements(); 992 1037 OtherMolecule->CountElements(); … … 995 1040 /// -# AtomCount 996 1041 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); 999 1044 result = false; 1000 } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount<< endl;1045 } else Log() << Verbose(4) << "AtomCounts match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl; 1001 1046 } 1002 1047 /// -# ElementCount … … 1035 1080 if (result) { 1036 1081 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()]; 1039 1084 SetIndexedArrayForEachAtomTo ( Distances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity); 1040 1085 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++) { 1042 1087 Distances[i] = 0.; 1043 1088 OtherDistances[i] = 0.; … … 1046 1091 /// ... sort each list (using heapsort (o(N log N)) from GSL) 1047 1092 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++) { 1051 1096 PermMap[i] = 0; 1052 1097 OtherPermMap[i] = 0; 1053 1098 } 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++) 1058 1103 PermutationMap[i] = 0; 1059 1104 DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl); 1060 for(int i= AtomCount;i--;)1105 for(int i=getAtomCount();i--;) 1061 1106 PermutationMap[PermMap[i]] = (int) OtherPermMap[i]; 1062 1107 … … 1064 1109 DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl); 1065 1110 flag = 0; 1066 for (int i=0;i< AtomCount;i++) {1111 for (int i=0;i<getAtomCount();i++) { 1067 1112 DoLog(5) && (Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " << threshold << endl); 1068 1113 if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold) … … 1100 1145 int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule) 1101 1146 { 1102 atom *Walker = NULL, *OtherWalker = NULL;1103 1147 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--;) 1106 1150 AtomicMap[i] = -1; 1107 1151 if (OtherMolecule == this) { // same molecule 1108 for (int i= AtomCount;i--;) // no need as -1 means already that there is trivial correspondence1152 for (int i=getAtomCount();i--;) // no need as -1 means already that there is trivial correspondence 1109 1153 AtomicMap[i] = i; 1110 1154 DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl); 1111 1155 } else { 1112 1156 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; 1118 1160 } 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) { 1122 1162 //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; 1127 1167 } 1128 1168 } 1129 DoLog(0) && (Log() << Verbose(0) << AtomicMap[ Walker->nr] << "\t");1169 DoLog(0) && (Log() << Verbose(0) << AtomicMap[(*iter)->nr] << "\t"); 1130 1170 } 1131 1171 DoLog(0) && (Log() << Verbose(0) << endl); … … 1161 1201 void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) const 1162 1202 { 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); 1167 1205 } 1168 1206 }; -
src/molecule.hpp
r42af9e r1024cb 34 34 #include "tesselation.hpp" 35 35 #include "Patterns/Observer.hpp" 36 #include "Patterns/ObservedIterator.hpp" 36 37 #include "Patterns/Cacheable.hpp" 37 38 … … 90 91 friend molecule *NewMolecule(); 91 92 friend void DeleteMolecule(molecule *); 93 92 94 public: 95 typedef std::set<atom*> atomSet; 96 typedef ObservedIterator<atomSet> iterator; 97 typedef atomSet::const_iterator const_iterator; 98 93 99 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 96 103 bond *first; //!< start of bond list 97 104 bond *last; //!< end of bond list 98 105 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() 100 107 int BondCount; //!< number of atoms, brought up-to-date by CountBonds() 101 108 int ElementCount; //!< how many unique elements are therein … … 112 119 private: 113 120 Cacheable<string> formula; 121 Cacheable<int> AtomCount; 114 122 moleculeId_t id; 123 atomSet atoms; //<!set of atoms 115 124 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 116 133 molecule(const periodentafel * const teil); 117 134 virtual ~molecule(); … … 121 138 //getter and setter 122 139 const std::string getName(); 140 int getAtomCount() const; 141 int doCountAtoms(); 123 142 moleculeId_t getId(); 124 143 void setId(moleculeId_t); … … 127 146 std::string calcFormula(); 128 147 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 129 159 130 160 // re-definition of virtual functions from PointCloud … … 132 162 Vector *GetCenter() const ; 133 163 TesselPoint *GetPoint() const ; 134 TesselPoint *GetTerminalPoint() const ;135 164 int GetMaxId() const; 136 165 void GoToNext() const ; 137 void GoToPrevious() const ;138 166 void GoToFirst() const ; 139 void GoToLast() const ;140 167 bool IsEmpty() const ; 141 168 bool IsEnd() const ; … … 232 259 233 260 /// Count and change present atoms' coordination. 234 void CountAtoms();235 261 void CountElements(); 236 262 void CalculateOrbitals(class config &configuration); … … 302 328 bool StoreForcesFile(MoleculeListClass *BondFragments, char *path, int *SortIndex); 303 329 bool CreateMappingLabelsToConfigSequence(int *&SortIndex); 330 bool CreateFatherLookupTable(atom **&LookupTable, int count = 0); 304 331 void BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem); 305 332 /// -# BOSSANOVA … … 330 357 private: 331 358 int last_atom; //!< number given to last atom 332 mutable atom *InternalPointer; //!< internal pointer for PointCloud359 mutable internal_iterator InternalPointer; //!< internal pointer for PointCloud 333 360 }; 334 361 -
src/molecule_dynamics.cpp
r42af9e r1024cb 29 29 gsl_matrix *A = gsl_matrix_alloc(NDIM,NDIM); 30 30 gsl_vector *x = gsl_vector_alloc(NDIM); 31 atom * Runner = mol->start;32 31 atom *Sprinter = NULL; 33 32 Vector trajectory1, trajectory2, normal, TestVector; 34 33 double Norm1, Norm2, tmp, result = 0.; 35 34 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++) 39 37 break; 40 38 // determine normalized trajectories direction vector (n1, n2) … … 43 41 trajectory1.Normalize(); 44 42 Norm1 = trajectory1.Norm(); 45 Sprinter = Params.PermutationMap[ Runner->nr]; // find second target point46 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); 47 45 trajectory2.Normalize(); 48 46 Norm2 = trajectory1.Norm(); 49 47 // check whether either is zero() 50 48 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)); 52 50 } else if (Norm1 < MYEPSILON) { 53 51 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); 55 53 trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything 56 54 trajectory1 -= trajectory2; // project the part in norm direction away 57 55 tmp = trajectory1.Norm(); // remaining norm is distance 58 56 } else if (Norm2 < MYEPSILON) { 59 Sprinter = Params.PermutationMap[ Runner->nr]; // find second target point57 Sprinter = Params.PermutationMap[(*iter)->nr]; // find second target point 60 58 trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep); // copy second offset 61 59 trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything … … 67 65 // Log() << Verbose(0) << " and "; 68 66 // 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)); 70 68 // Log() << Verbose(0) << " with distance " << tmp << "." << endl; 71 69 } 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 "; 73 71 // Log() << Verbose(0) << endl; 74 72 // Log() << Verbose(0) << "First Trajectory: "; … … 86 84 gsl_matrix_set(A, 1, i, trajectory2[i]); 87 85 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])); 89 87 } 90 88 // solve the linear system by Householder transformations … … 97 95 trajectory2.Scale(gsl_vector_get(x,1)); 98 96 normal.Scale(gsl_vector_get(x,2)); 99 TestVector = Runner->Trajectory.R.at(Params.startstep) + trajectory2 + normal97 TestVector = (*iter)->Trajectory.R.at(Params.startstep) + trajectory2 + normal 100 98 - (Walker->Trajectory.R.at(Params.startstep) + trajectory1); 101 99 if (TestVector.Norm() < MYEPSILON) { … … 126 124 { 127 125 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)) { 132 128 // 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 "; 134 130 // Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep); 135 131 // Log() << Verbose(0) << ", penalting." << endl; … … 162 158 // go through every atom 163 159 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) { 167 161 // first term: distance to target 168 Runner = Params.PermutationMap[ Walker->nr]; // find target point169 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))); 170 164 tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem; 171 165 result += Params.PenaltyConstants[0] * tmp; … … 173 167 174 168 // second term: sum of distances to other trajectories 175 result += SumDistanceOfTrajectories( Walker, this, Params);169 result += SumDistanceOfTrajectories((*iter), this, Params); 176 170 177 171 // third term: penalty for equal targets 178 result += PenalizeEqualTargets( Walker, this, Params);172 result += PenalizeEqualTargets((*iter), this, Params); 179 173 } 180 174 … … 216 210 void FillDistanceList(molecule *mol, struct EvaluatePotential &Params) 217 211 { 218 for (int i=mol-> AtomCount; i--;) {212 for (int i=mol->getAtomCount(); i--;) { 219 213 Params.DistanceList[i] = new DistanceMap; // is the distance sorted target list per atom 220 214 Params.DistanceList[i]->clear(); 221 215 } 222 216 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)) ); 231 220 } 232 221 } … … 240 229 void CreateInitialLists(molecule *mol, struct EvaluatePotential &Params) 241 230 { 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); 250 237 } 251 238 }; … … 288 275 void MakeInjectivePermutation(molecule *mol, struct EvaluatePotential &Params) 289 276 { 290 atom *Walker = mol->start;277 molecule::const_iterator iter = mol->begin(); 291 278 DistanceMap::iterator NewBase; 292 279 double Potential = fabs(mol->ConstrainedPotential(Params)); 293 280 281 if (mol->empty()) { 282 eLog() << Verbose(1) << "Molecule is empty." << endl; 283 return; 284 } 294 285 while ((Potential) > Params.PenaltyConstants[2]) { 295 PrintPermutationMap(mol-> AtomCount, Params);296 Walker = Walker->next;297 if ( Walker == mol->end) // round-robin at the end298 Walker = mol->start->next;299 if (Params.DoubleList[Params.DistanceIterators[ Walker->nr]->second->nr] <= 1) // no need to make those injective that aren't286 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 300 291 continue; 301 292 // 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 <=1293 Potential = TryNextNearestNeighbourForInjectivePermutation(mol, (*iter), Potential, Params); 294 } 295 for (int i=mol->getAtomCount(); i--;) // now each single entry in the DoubleList should be <=1 305 296 if (Params.DoubleList[i] > 1) { 306 297 DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl); … … 341 332 double Potential, OldPotential, OlderPotential; 342 333 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()]; 348 339 int round; 349 atom * Walker = NULL, *Runner = NULL, *Sprinter = NULL;340 atom *Sprinter = NULL; 350 341 DistanceMap::iterator Rider, Strider; 351 342 352 343 // set to zero 353 for (int i=0;i< AtomCount;i++) {344 for (int i=0;i<getAtomCount();i++) { 354 345 Params.PermutationMap[i] = NULL; 355 346 Params.DoubleList[i] = 0; … … 380 371 DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl); 381 372 OlderPotential = OldPotential; 373 molecule::const_iterator iter; 382 374 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(); 392 383 break; 393 384 } 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; 395 386 // 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; 400 391 break; 401 392 } 402 Runner = Runner->next;403 393 } 404 if ( Runner != end) { // we found the other source394 if (runner != end()) { // we found the other source 405 395 // 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++) 408 398 if (Rider->second == Sprinter) 409 399 break; 410 if (Rider != Params.DistanceList[ Runner->nr]->end()) { // if we have found one411 //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; 412 402 // exchange both 413 Params.PermutationMap[ Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // put next farther distance into PermutationMap414 Params.PermutationMap[ Runner->nr] = Sprinter; // and hand the old target to its respective owner415 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); 416 406 // calculate the new potential 417 407 //Log() << Verbose(2) << "Checking new potential ..." << endl; … … 419 409 if (Potential > OldPotential) { // we made everything worse! Undo ... 420 410 //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; 422 412 // 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; 424 414 // Undo for Walker 425 Params.DistanceIterators[ Walker->nr] = Strider; // take next farther distance target426 //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; 428 418 } else { 429 Params.DistanceIterators[ Runner->nr] = Rider; // if successful also move the pointer in the iterator list419 Params.DistanceIterators[(*runner)->nr] = Rider; // if successful also move the pointer in the iterator list 430 420 DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl); 431 421 OldPotential = Potential; … … 437 427 //Log() << Verbose(0) << endl; 438 428 } 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); 440 430 exit(255); 441 431 } 442 432 } 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! 444 434 } 445 Params.StepList[ Walker->nr]++; // take next farther distance target435 Params.StepList[(*iter)->nr]++; // take next farther distance target 446 436 } 447 } while ( Walker->next != end);437 } while (++iter != end()); 448 438 } while ((OlderPotential - OldPotential) > 1e-3); 449 439 DoLog(1) && (Log() << Verbose(1) << "done." << endl); … … 451 441 452 442 /// free memory and return with evaluated potential 453 for (int i= AtomCount; i--;)443 for (int i=getAtomCount(); i--;) 454 444 Params.DistanceList[i]->clear(); 455 445 delete[](Params.DistanceList); … … 492 482 // Get the Permutation Map by MinimiseConstrainedPotential 493 483 atom **PermutationMap = NULL; 494 atom * Walker = NULL, *Sprinter = NULL;484 atom *Sprinter = NULL; 495 485 if (!MapByIdentity) 496 486 MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem()); 497 487 else { 498 PermutationMap = new atom *[ AtomCount];488 PermutationMap = new atom *[getAtomCount()]; 499 489 SetIndexedArrayForEachAtomTo( PermutationMap, &atom::nr ); 500 490 } … … 511 501 mol = World::getInstance().createMolecule(); 512 502 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) { 516 504 // add to molecule list 517 Sprinter = mol->AddCopyAtom( Walker);505 Sprinter = mol->AddCopyAtom((*iter)); 518 506 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); 520 508 // add to Trajectories 521 509 //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl; 522 510 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.; 526 514 } 527 515 } … … 531 519 532 520 // 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--; ) 535 523 SortIndex[i] = i; 536 524 status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex); … … 578 566 return false; 579 567 } 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); 582 570 performCriticalExit(); 583 571 return false; … … 585 573 // correct Forces 586 574 Velocity.Zero(); 587 for(int i=0;i< AtomCount;i++)575 for(int i=0;i<getAtomCount();i++) 588 576 for(int d=0;d<NDIM;d++) { 589 577 Velocity[d] += Force.Matrix[0][i][d+5]; 590 578 } 591 for(int i=0;i< AtomCount;i++)579 for(int i=0;i<getAtomCount();i++) 592 580 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()); 594 582 } 595 583 // solve a constrained potential if we are meant to … … 694 682 delta_alpha = 0.; 695 683 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); 697 685 configuration.alpha += delta_alpha*configuration.Deltat; 698 686 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl); -
src/molecule_fragmentation.cpp
r42af9e r1024cb 39 39 int FragmentCount; 40 40 // 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; 45 43 } 46 44 FragmentCount = NoNonHydrogen*(1 << (c*order)); … … 353 351 map<double, pair<int,int> > * ReMapAdaptiveCriteriaListToValue(map<int, pair<double,int> > *AdaptiveCriteriaList, molecule *mol) 354 352 { 355 atom *Walker = mol->start;353 atom *Walker = NULL; 356 354 map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ; 357 355 DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl); … … 385 383 bool MarkUpdateCandidates(bool *AtomMask, map<double, pair<int,int> > &FinalRootCandidates, int Order, molecule *mol) 386 384 { 387 atom *Walker = mol->start;385 atom *Walker = NULL; 388 386 int No = -1; 389 387 bool status = false; … … 429 427 bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path) 430 428 { 431 atom *Walker = start;432 429 bool status = false; 433 430 434 431 // initialize mask list 435 for(int i= AtomCount;i--;)432 for(int i=getAtomCount();i--;) 436 433 AtomMask[i] = false; 437 434 438 435 if (Order < 0) { // adaptive increase of BondOrder per site 439 if (AtomMask[ AtomCount] == true) // break after one step436 if (AtomMask[getAtomCount()] == true) // break after one step 440 437 return false; 441 438 … … 451 448 if (AdaptiveCriteriaList->empty()) { 452 449 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) { 455 451 #ifdef ADDHYDROGEN 456 if ( Walker->type->Z != 1) // skip hydrogen452 if ((*iter)->type->Z != 1) // skip hydrogen 457 453 #endif 458 454 { 459 AtomMask[ Walker->nr] = true; // include all (non-hydrogen) atoms455 AtomMask[(*iter)->nr] = true; // include all (non-hydrogen) atoms 460 456 status = true; 461 457 } … … 472 468 delete[](FinalRootCandidates); 473 469 } 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) { 476 471 #ifdef ADDHYDROGEN 477 if ( Walker->type->Z != 1) // skip hydrogen472 if ((*iter)->type->Z != 1) // skip hydrogen 478 473 #endif 479 474 { 480 AtomMask[ Walker->nr] = true; // include all (non-hydrogen) atoms481 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])) 482 477 status = true; 483 478 } 484 479 } 485 if (( Order == 0) && (AtomMask[AtomCount] == false)) // single stepping, just check480 if ((!Order) && (!AtomMask[getAtomCount()])) // single stepping, just check 486 481 status = true; 487 482 … … 494 489 } 495 490 496 PrintAtomMask(AtomMask, AtomCount); // for debugging491 PrintAtomMask(AtomMask, getAtomCount()); // for debugging 497 492 498 493 return status; … … 510 505 return false; 511 506 } 512 SortIndex = new int[ AtomCount];513 for(int i= AtomCount;i--;)507 SortIndex = new int[getAtomCount()]; 508 for(int i=getAtomCount();i--;) 514 509 SortIndex[i] = -1; 515 510 … … 518 513 519 514 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 */ 526 bool 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; 520 570 }; 521 571 … … 541 591 { 542 592 MoleculeListClass *BondFragments = NULL; 543 int *MinimumRingSize = new int[ AtomCount];593 int *MinimumRingSize = new int[getAtomCount()]; 544 594 int FragmentCounter; 545 595 MoleculeLeafClass *MolecularWalker = NULL; … … 569 619 570 620 // create lookup table for Atom::nr 571 FragmentationToDo = FragmentationToDo && CreateFatherLookupTable( start, end, ListOfAtoms, AtomCount);621 FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, getAtomCount()); 572 622 573 623 // === compare it with adjacency file === … … 579 629 580 630 // 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(); 583 633 MolecularWalker = Subgraphs; 584 634 FragmentCounter = 0; … … 586 636 MolecularWalker = MolecularWalker->next; 587 637 // fill the bond structure of the individually stored subgraphs 588 MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms638 MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms 589 639 DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl); 590 640 LocalBackEdgeStack = new StackClass<bond *> (MolecularWalker->Leaf->BondCount); 591 641 // // check the list of local atoms for debugging 592 642 // 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++) 594 644 // if (ListOfLocalAtoms[FragmentCounter][i] == NULL) 595 645 // Log() << Verbose(0) << "\tNULL"; … … 617 667 // ===== 6b. prepare and go into the adaptive (Order<0), single-step (Order==0) or incremental (Order>0) cycle 618 668 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; 621 671 FragmentationToDo = false; // if CheckOrderAtSite just ones recommends fragmentation, we will save fragments afterwards 622 672 while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, configuration->configpath))) { 623 673 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() 625 675 // ===== 6b. fill RootStack for each subgraph (second adaptivity check) ===== 626 676 Subgraphs->next->FillRootStackForSubgraphs(RootStack, AtomMask, (FragmentCounter = 0)); … … 762 812 bool molecule::ParseOrderAtSiteFromFile(char *path) 763 813 { 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()]; 766 816 bool status; 767 817 int AtomNr, value; … … 769 819 ifstream file; 770 820 771 for(int i=0;i< AtomCount;i++) {821 for(int i=0;i<getAtomCount();i++) { 772 822 OrderArray[i] = 0; 773 823 MaxArray[i] = false; … … 871 921 atom *OtherFather = NULL; 872 922 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();) { 878 929 LonelyFlag = true; 879 FatherOfRunner = Runner->father; 930 FatherOfRunner = (*iter)->father; 931 ASSERT(FatherOfRunner,"Atom without father found"); 880 932 if (SonList[FatherOfRunner->nr] != NULL) { // check if this, our father, is present in list 881 933 // create all bonds … … 888 940 // Log() << Verbose(3) << "Adding Bond: "; 889 941 // Log() << Verbose(0) << 890 Leaf->AddBond( Runner, SonList[OtherFather->nr], (*BondRunner)->BondDegree);942 Leaf->AddBond((*iter), SonList[OtherFather->nr], (*BondRunner)->BondDegree); 891 943 // Log() << Verbose(0) << "." << endl; 892 //NumBonds[ Runner->nr]++;944 //NumBonds[(*iter)->nr]++; 893 945 } else { 894 946 // Log() << Verbose(3) << "Not adding bond, labels in wrong order." << endl; … … 898 950 // Log() << Verbose(0) << ", who has no son in this fragment molecule." << endl; 899 951 #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)) 902 954 exit(1); 903 955 #endif 904 //NumBonds[ Runner->nr] += Binder->BondDegree;956 //NumBonds[(*iter)->nr] += Binder->BondDegree; 905 957 } 906 958 } 907 959 } 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; 913 966 #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 } 916 970 #endif 917 971 } … … 928 982 molecule * molecule::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem) 929 983 { 930 atom **SonList = new atom*[ AtomCount];984 atom **SonList = new atom*[getAtomCount()]; 931 985 molecule *Leaf = World::getInstance().createMolecule(); 932 986 933 for(int i=0;i< AtomCount;i++)987 for(int i=0;i<getAtomCount();i++) 934 988 SonList[i] = NULL; 935 989 … … 1561 1615 FragmentSearch.FragmentSet = new KeySet; 1562 1616 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--;) { 1565 1619 FragmentSearch.ShortestPathList[i] = -1; 1566 1620 } 1567 1621 1568 1622 // Construct the complete KeySet which we need for topmost level only (but for all Roots) 1569 atom *Walker = start;1570 1623 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); 1574 1626 } 1575 1627 … … 1582 1634 RootKeyNr = RootStack.front(); 1583 1635 RootStack.pop_front(); 1584 Walker = FindAtom(RootKeyNr);1636 atom *Walker = FindAtom(RootKeyNr); 1585 1637 // check cyclic lengths 1586 1638 //if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) { … … 1671 1723 Vector Translationvector; 1672 1724 //class StackClass<atom *> *CompStack = NULL; 1673 class StackClass<atom *> *AtomStack = new StackClass<atom *>( AtomCount);1725 class StackClass<atom *> *AtomStack = new StackClass<atom *>(getAtomCount()); 1674 1726 bool flag = true; 1675 1727 1676 1728 DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl); 1677 1729 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++) 1680 1732 ColorList[i] = (enum Shading)0; 1681 1733 while (flag) { 1682 1734 // remove bonds that are beyond bonddistance 1683 for(int i=NDIM;i--;) 1684 Translationvector[i] = 0.; 1735 Translationvector.Zero(); 1685 1736 // scan all bonds 1686 1737 Binder = first; … … 1711 1762 Log() << Verbose(0) << Translationvector << endl; 1712 1763 // apply to all atoms of first component via BFS 1713 for (int i= AtomCount;i--;)1764 for (int i=getAtomCount();i--;) 1714 1765 ColorList[i] = white; 1715 1766 AtomStack->Push(Binder->leftatom); … … 1735 1786 //delete(CompStack); 1736 1787 } 1737 1738 1788 // free allocated space from ReturnFullMatrixforSymmetric() 1739 1789 delete(AtomStack); -
src/molecule_geometry.cpp
r42af9e r1024cb 71 71 72 72 // Log() << Verbose(3) << "Begin of CenterEdge." << endl; 73 atom *ptr = start->next; // start at first in list74 if ( ptr != end) {//list not empty?73 molecule::const_iterator iter = begin(); // start at first in list 74 if (iter != end()) { //list not empty? 75 75 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); 82 81 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); 85 84 } 86 85 } … … 106 105 { 107 106 int Num = 0; 108 atom *ptr = start; // start at first in list107 molecule::const_iterator iter = begin(); // start at first in list 109 108 110 109 Center.Zero(); 111 110 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 115 113 Num++; 116 Center += ptr->x;114 Center += (*iter)->x; 117 115 } 118 116 Center.Scale(-1./Num); // divide through total number (and sign for direction) … … 127 125 Vector * molecule::DetermineCenterOfAll() const 128 126 { 129 atom *ptr = start; // start at first in list127 molecule::const_iterator iter = begin(); // start at first in list 130 128 Vector *a = new Vector(); 131 129 double Num = 0; … … 133 131 a->Zero(); 134 132 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 138 135 Num += 1.; 139 (*a) += ptr->x;136 (*a) += (*iter)->x; 140 137 } 141 138 a->Scale(1./Num); // divide through total mass (and sign for direction) … … 165 162 Vector * molecule::DetermineCenterOfGravity() 166 163 { 167 atom *ptr = start->next; // start at first in list164 molecule::const_iterator iter = begin(); // start at first in list 168 165 Vector *a = new Vector(); 169 166 Vector tmp; … … 172 169 a->Zero(); 173 170 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; 179 175 (*a) += tmp; 180 176 } … … 217 213 void molecule::Scale(const double ** const factor) 218 214 { 219 atom *ptr = start; 220 221 while (ptr->next != end) { 222 ptr = ptr->next; 215 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 223 216 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); 226 219 } 227 220 }; … … 232 225 void molecule::Translate(const Vector *trans) 233 226 { 234 atom *ptr = start; 235 236 while (ptr->next != end) { 237 ptr = ptr->next; 227 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 238 228 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); 241 231 } 242 232 }; … … 274 264 void molecule::DeterminePeriodicCenter(Vector ¢er) 275 265 { 276 atom *Walker = start;277 266 double * const cell_size = World::getInstance().getDomain(); 278 267 double *matrix = ReturnFullMatrixforSymmetric(cell_size); … … 285 274 Center.Zero(); 286 275 flag = true; 287 while (Walker->next != end) { 288 Walker = Walker->next; 276 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 289 277 #ifdef ADDHYDROGEN 290 if ( Walker->type->Z != 1) {278 if ((*iter)->type->Z != 1) { 291 279 #endif 292 Testvector = Walker->x;280 Testvector = (*iter)->x; 293 281 Testvector.MatrixMultiplication(inversematrix); 294 282 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 nothing283 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 297 285 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]; 299 287 if ((fabs(tmp)) > BondDistance) { 300 288 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); 302 290 if (tmp > 0) 303 291 Translationvector[j] -= 1.; … … 313 301 #ifdef ADDHYDROGEN 314 302 // 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; 318 306 Testvector.MatrixMultiplication(inversematrix); 319 307 Testvector += Translationvector; … … 330 318 delete[](inversematrix); 331 319 332 Center.Scale(1./ (double)AtomCount);320 Center.Scale(1./static_cast<double>(getAtomCount())); 333 321 }; 334 322 … … 340 328 void molecule::PrincipalAxisSystem(bool DoRotate) 341 329 { 342 atom *ptr = start; // start at first in list343 330 double InertiaTensor[NDIM*NDIM]; 344 331 Vector *CenterOfGravity = DetermineCenterOfGravity(); … … 351 338 352 339 // 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; 356 342 //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]); 366 352 } 367 353 // print InertiaTensor for debugging … … 401 387 402 388 // 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]); 417 400 } 418 401 // print InertiaTensor for debugging … … 438 421 void molecule::Align(Vector *n) 439 422 { 440 atom *ptr = start;441 423 double alpha, tmp; 442 424 Vector z_axis; … … 449 431 alpha = atan(-n->at(0)/n->at(2)); 450 432 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]; 456 437 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]; 460 441 } 461 442 } … … 467 448 468 449 // rotate on z-y plane 469 ptr = start;470 450 alpha = atan(-n->at(1)/n->at(2)); 471 451 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]; 477 456 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]; 481 460 } 482 461 } … … 502 481 Vector a,b,c,d; 503 482 struct lsq_params *par = (struct lsq_params *)params; 504 atom *ptr = par->mol->start;505 483 506 484 // initialize vectors … … 512 490 b[2] = gsl_vector_get(x,5); 513 491 // 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; 518 495 t = c.ScalarProduct(b); // get direction parameter 519 496 d = t*b; // and create vector -
src/molecule_graph.cpp
r42af9e r1024cb 20 20 #include "World.hpp" 21 21 #include "Helpers/fast_functions.hpp" 22 #include "Helpers/Assert.hpp" 23 22 24 23 25 struct BFSAccounting … … 80 82 flip(atom1, atom2); 81 83 Walker = FindAtom(atom1); 84 ASSERT(Walker,"Could not find an atom with the ID given in dbond file"); 82 85 OtherWalker = FindAtom(atom2); 86 ASSERT(OtherWalker,"Could not find an atom with the ID given in dbond file"); 83 87 AddBond(Walker, OtherWalker); //Add the bond between the two atoms with respective indices. 84 88 } … … 109 113 atom *Walker = NULL; 110 114 atom *OtherWalker = NULL; 111 atom **AtomMap = NULL;112 115 int n[NDIM]; 113 116 double MinDistance, MaxDistance; … … 134 137 135 138 // 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.)) { 140 142 DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl); 141 143 LC = new LinkedCell(this, bonddistance); … … 143 145 // create a list to map Tesselpoint::nr to atom * 144 146 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++; 152 152 } 153 153 … … 161 161 if (List != NULL) { 162 162 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; 165 166 // 3c. check for possible bond between each atom in this and every one in the 27 cells 166 167 for (n[0] = -1; n[0] <= 1; n[0]++) … … 172 173 for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) { 173 174 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; 178 178 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 179 const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size); 179 180 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 180 181 // Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl; … … 196 197 } 197 198 } 198 delete[](AtomMap);199 199 delete (LC); 200 200 DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl); … … 207 207 ActOnAllAtoms( &atom::OutputBondOfAtom ); 208 208 } 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); 210 210 DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl); 211 211 if (free_BG) … … 249 249 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 250 250 } 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); 252 252 } 253 253 DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl); … … 469 469 void DepthFirstSearchAnalysis_Init(struct DFSAccounting &DFS, const molecule * const mol) 470 470 { 471 DFS.AtomStack = new StackClass<atom *> (mol-> AtomCount);471 DFS.AtomStack = new StackClass<atom *> (mol->getAtomCount()); 472 472 DFS.CurrentGraphNr = 0; 473 473 DFS.ComponentNumber = 0; … … 510 510 bond *Binder = NULL; 511 511 512 if ( AtomCount== 0)512 if (getAtomCount() == 0) 513 513 return SubGraphs; 514 514 DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl); 515 515 DepthFirstSearchAnalysis_Init(DFS, this); 516 516 517 DFS.Root = start->next;518 while (DFS.Root != end) { // if there any atoms at all517 for (molecule::const_iterator iter = begin(); iter != end();) { 518 DFS.Root = *iter; 519 519 // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all 520 520 DFS.AtomStack->ClearStack(); … … 556 556 557 557 // 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 on561 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++; 562 562 } 563 563 } … … 864 864 if (MinRingSize != -1) { // if rings are present 865 865 // 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 871 870 Walker = Root; 872 871 873 872 //Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl; 874 CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol-> AtomCount);873 CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->getAtomCount()); 875 874 876 875 } … … 902 901 int MinRingSize = -1; 903 902 904 InitializeBFSAccounting(BFS, AtomCount);903 InitializeBFSAccounting(BFS, getAtomCount()); 905 904 906 905 //Log() << Verbose(1) << "Back edge list - "; … … 1145 1144 CurrentBondsOfAtom = -1; // we count one too far due to line end 1146 1145 // parse into structure 1147 if ((AtomNr >= 0) && (AtomNr < AtomCount)) {1146 if ((AtomNr >= 0) && (AtomNr < getAtomCount())) { 1148 1147 Walker = ListOfAtoms[AtomNr]; 1149 1148 while (!line.eof()) … … 1324 1323 AddedAtomList[Root->nr] = Mol->AddCopyAtom(Root); 1325 1324 1326 BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, AtomCount, AddedAtomList);1325 BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, getAtomCount(), AddedAtomList); 1327 1326 1328 1327 // and go on ... Queue always contains all lightgray vertices … … 1382 1381 // fill parent list with sons 1383 1382 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); 1388 1385 // 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 }; 1394 1389 1395 1390 void BuildInducedSubgraph_Finalize(atom **&ParentList) … … 1402 1397 { 1403 1398 bool status = true; 1404 atom *Walker = NULL;1405 1399 atom *OtherAtom = NULL; 1406 1400 // check each entry of parent list and if ok (one-to-and-onto matching) create bonds 1407 1401 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)) { 1413 1405 status = false; 1414 1406 } 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)); 1417 1409 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); 1420 1412 } 1421 1413 } … … 1440 1432 bool status = true; 1441 1433 atom **ParentList = NULL; 1442 1443 1434 DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl); 1444 BuildInducedSubgraph_Init(ParentList, Father-> AtomCount);1435 BuildInducedSubgraph_Init(ParentList, Father->getAtomCount()); 1445 1436 BuildInducedSubgraph_FillParentList(this, Father, ParentList); 1446 1437 status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList); -
src/molecule_pointcloud.cpp
r42af9e r1024cb 8 8 #include "atom.hpp" 9 9 #include "config.hpp" 10 #include "info.hpp" 10 11 #include "memoryallocator.hpp" 11 12 #include "molecule.hpp" … … 31 32 }; 32 33 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. 35 37 */ 36 TesselPoint *molecule::GetPoint() const38 TesselPoint* molecule::GetPoint() const 37 39 { 38 if ((InternalPointer != start) && (InternalPointer != end)) 39 return InternalPointer; 40 else 41 return NULL; 40 Info FunctionInfo(__func__); 41 return (*InternalPointer); 42 42 }; 43 43 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. 62 46 */ 63 47 void molecule::GoToNext() const 64 48 { 65 if (InternalPointer != end) 66 InternalPointer = InternalPointer->next; 49 Info FunctionInfo(__func__); 50 if (InternalPointer != atoms.end()) 51 InternalPointer++; 67 52 }; 68 53 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. 79 56 */ 80 57 void molecule::GoToFirst() const 81 58 { 82 InternalPointer = start->next; 59 Info FunctionInfo(__func__); 60 InternalPointer = atoms.begin(); 83 61 }; 84 62 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. 94 65 */ 95 66 bool molecule::IsEmpty() const 96 67 { 97 return (start->next == end); 68 Info FunctionInfo(__func__); 69 return (empty()); 98 70 }; 99 71 100 /** Checks whether we are at the last atom101 * \return true - current atom is last one, false - is not last one72 /** PointCloud implementation of IsLast. 73 * Uses atoms and STL stuff. 102 74 */ 103 75 bool molecule::IsEnd() const 104 76 { 105 return (InternalPointer == end); 77 Info FunctionInfo(__func__); 78 return (InternalPointer == atoms.end()); 106 79 }; 80 81 int molecule::GetMaxId() const { 82 return getAtomCount(); 83 } -
src/molecule_template.hpp
r42af9e r1024cb 24 24 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const 25 25 { 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)(); 30 28 } 31 29 }; 32 30 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const 33 31 { 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)(); 38 34 } 39 35 }; … … 41 37 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const 42 38 { 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); 47 41 } 48 42 }; 49 43 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const 50 44 { 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); 55 47 } 56 48 }; 57 49 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&), T &t ) const 58 50 { 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); 63 53 } 64 54 }; 65 55 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const 66 56 { 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); 71 59 } 72 60 }; … … 74 62 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const 75 63 { 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); 80 66 } 81 67 }; 82 68 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const 83 69 { 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); 88 72 } 89 73 }; … … 91 75 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const 92 76 { 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); 97 79 } 98 80 }; 99 81 template <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 100 82 { 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); 105 85 } 106 86 }; … … 112 92 { 113 93 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)(); 118 96 } 119 97 return result; … … 122 100 { 123 101 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)(); 128 104 } 129 105 return result; … … 133 109 { 134 110 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); 139 113 } 140 114 return result; … … 143 117 { 144 118 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); 149 121 } 150 122 return result; … … 157 129 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const 158 130 { 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)); 163 133 } 164 134 }; 165 135 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const 166 136 { 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)); 171 139 } 172 140 }; … … 177 145 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const 178 146 { 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)); 183 149 } 184 150 }; 185 151 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const 186 152 { 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)); 191 155 } 192 156 }; … … 197 161 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const 198 162 { 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)); 204 166 } 205 167 }; 206 168 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const 207 169 { 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)); 213 173 } 214 174 }; 215 175 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const 216 176 { 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)); 222 180 } 223 181 }; 224 182 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const 225 183 { 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)); 231 187 } 232 188 }; … … 234 190 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const 235 191 { 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)); 241 195 } 242 196 }; 243 197 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const 244 198 { 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)); 250 202 } 251 203 }; 252 204 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const 253 205 { 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)); 259 209 } 260 210 }; 261 211 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const 262 212 { 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)); 268 216 } 269 217 }; … … 271 219 template <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 272 220 { 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)); 278 224 } 279 225 }; 280 226 template <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 281 227 { 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)); 287 231 } 288 232 }; 289 233 template <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 290 234 { 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)); 296 238 } 297 239 }; 298 240 template <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 299 241 { 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)); 305 245 } 306 246 }; … … 308 248 template <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 309 249 { 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)); 315 253 } 316 254 }; 317 255 template <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 318 256 { 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)); 324 260 } 325 261 }; 326 262 template <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 327 263 { 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)); 333 267 } 334 268 }; 335 269 template <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 336 270 { 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)); 342 274 } 343 275 }; … … 348 280 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const 349 281 { 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)(); 354 284 } 355 285 }; 356 286 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const 357 287 { 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)(); 362 290 } 363 291 }; … … 365 293 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const 366 294 { 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); 371 297 } 372 298 }; 373 299 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const 374 300 { 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); 379 303 } 380 304 }; … … 382 306 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const 383 307 { 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); 388 310 } 389 311 }; 390 312 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const 391 313 { 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); 396 316 } 397 317 }; … … 399 319 template <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 400 320 { 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); 405 323 } 406 324 }; 407 325 template <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 408 326 { 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); 413 329 } 414 330 }; … … 416 332 template <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 417 333 { 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); 422 336 } 423 337 }; 424 338 template <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 425 339 { 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); 430 342 } 431 343 }; … … 436 348 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const 437 349 { 438 atom *Walker = start;439 350 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); 443 353 } 444 354 }; 445 355 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const 446 356 { 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); 451 359 } 452 360 }; 453 361 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const 454 362 { 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); 459 365 } 460 366 }; … … 462 368 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const 463 369 { 464 atom *Walker = start;465 370 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); 469 373 } 470 374 }; 471 375 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const 472 376 { 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); 477 379 } 478 380 }; 479 381 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const 480 382 { 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); 485 385 } 486 386 }; … … 488 388 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const 489 389 { 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); 494 392 } 495 393 }; 496 394 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const 497 395 { 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); 502 398 } 503 399 }; 504 400 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const 505 401 { 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); 510 404 } 511 405 }; 512 406 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const 513 407 { 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); 518 410 } 519 411 }; 520 412 template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const 521 413 { 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; 527 417 } 528 418 }; … … 530 420 template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const 531 421 { 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; 537 425 } 538 426 }; -
src/moleculelist.cpp
r42af9e r1024cb 20 20 #include "memoryallocator.hpp" 21 21 #include "periodentafel.hpp" 22 #include " World.hpp"22 #include "Helpers/Assert.hpp" 23 23 24 24 #include "Helpers/Assert.hpp" … … 71 71 int Count, Counter, aCounter, bCounter; 72 72 int flag; 73 atom *aWalker = NULL;74 atom *bWalker = NULL;75 73 76 74 // sort each atom list and put the numbers into a list, then go through 77 75 //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()) { 79 82 return -1; 80 83 } else { 81 if ( (**(molecule **) a).AtomCount > (**(molecule **) b).AtomCount)84 if (mol1->getAtomCount() > mol2->getAtomCount()) 82 85 return +1; 83 86 else { 84 Count = (**(molecule **) a).AtomCount;87 Count = mol1->getAtomCount(); 85 88 aList = new int[Count]; 86 89 bList = new int[Count]; 87 90 88 91 // fill the lists 89 aWalker = (**(molecule **) a).start;90 bWalker = (**(molecule **) b).start;91 92 Counter = 0; 92 93 aCounter = 0; 93 94 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) 98 100 aList[Counter] = Count + (aCounter++); 99 101 else 100 aList[Counter] = aWalker->GetTrueFather()->nr;101 if ( bWalker->GetTrueFather() == NULL)102 aList[Counter] = (*aiter)->GetTrueFather()->nr; 103 if ((*biter)->GetTrueFather() == NULL) 102 104 bList[Counter] = Count + (bCounter++); 103 105 else 104 bList[Counter] = bWalker->GetTrueFather()->nr;106 bList[Counter] = (*biter)->GetTrueFather()->nr; 105 107 Counter++; 106 108 } 107 109 // check if AtomCount was for real 108 110 flag = 0; 109 if ((a Walker->next == (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {111 if ((aiter == mol1->end()) && (biter != mol2->end())) { 110 112 flag = -1; 111 113 } else { 112 if ((a Walker->next != (**(molecule **) a).end) && (bWalker->next == (**(molecule **) b).end))114 if ((aiter != mol1->end()) && (biter == mol2->end())) 113 115 flag = 1; 114 116 } … … 144 146 void MoleculeListClass::Enumerate(ostream *out) 145 147 { 146 atom *Walker = NULL;147 148 periodentafel *periode = World::getInstance().getPeriode(); 148 149 std::map<atomicNumber_t,unsigned int> counts; … … 160 161 // count atoms per element and determine size of bounding sphere 161 162 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); 168 167 } 169 168 // 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"; 171 170 172 171 std::map<atomicNumber_t,unsigned int>::reverse_iterator iter; … … 204 203 205 204 // 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)); 213 210 } 214 211 … … 230 227 231 228 // 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)); 238 232 Walker->father = Walker; 239 233 } … … 332 326 333 327 // 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++) 337 330 CopyAtoms[i] = NULL; 338 331 339 332 // for each of the source atoms check whether we are in- or outside and add copy atom 340 atom *Walker = srcmol->start;341 333 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]); 348 339 nr++; 349 340 } else { … … 351 342 } 352 343 } 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."); 354 345 355 346 // go through all bonds and add as well … … 384 375 bool MoleculeListClass::AddHydrogenCorrection(char *path) 385 376 { 386 atom *Walker = NULL;387 atom *Runner = NULL;388 377 bond *Binder = NULL; 389 378 double ***FitConstant = NULL, **correction = NULL; … … 493 482 correction[k][j] = 0.; 494 483 // 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; 505 490 // 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!) 508 493 // 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; 511 496 for (int k = 0; k < a; k++) { 512 497 for (int j = 0; j < b; j++) { … … 586 571 ofstream ForcesFile; 587 572 stringstream line; 588 atom *Walker = NULL;589 573 periodentafel *periode=World::getInstance().getPeriode(); 590 574 … … 599 583 periodentafel::const_iterator elemIter; 600 584 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 607 589 //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"; 609 591 } else 610 592 // otherwise a -1 to indicate an added saturation hydrogen … … 640 622 bool result = true; 641 623 bool intermediateResult = true; 642 atom *Walker = NULL;643 624 Vector BoxDimension; 644 625 char *FragmentNumber = NULL; … … 681 662 // list atoms in fragment for debugging 682 663 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() << " "); 687 666 } 688 667 DoLog(0) && (Log() << Verbose(0) << endl); … … 764 743 { 765 744 molecule *mol = World::getInstance().createMolecule(); 766 atom *Walker = NULL;767 atom *Advancer = NULL;768 745 bond *Binder = NULL; 769 746 bond *Stepper = NULL; … … 771 748 for (MoleculeList::iterator MolRunner = ListOfMolecules.begin(); !ListOfMolecules.empty(); MolRunner = ListOfMolecules.begin()) { 772 749 // 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); 781 755 } 782 756 // remove all bonds … … 832 806 // 4b. create and fill map of which atom is associated to which connected molecule (note, counting starts at 1) 833 807 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++) 836 810 MolMap[i] = 0; 837 811 MoleculeLeafClass *MolecularWalker = Subgraphs; 838 Walker = NULL;839 812 while (MolecularWalker->next != NULL) { 840 813 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; 845 816 } 846 817 FragmentCounter++; … … 848 819 849 820 // 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); 855 824 performCriticalExit(); 856 825 } 857 FragmentCounter = MolMap[ Walker->nr];826 FragmentCounter = MolMap[(*iter)->nr]; 858 827 if (FragmentCounter != 0) { 859 DoLog(3) && (Log() << Verbose(3) << "Re-linking " << * Walker << "..." << endl);860 unlink(Walker);861 mol ecules[FragmentCounter-1]->AddAtom(Walker); // counting starts at 1828 DoLog(3) && (Log() << Verbose(3) << "Re-linking " << **iter << "..." << endl); 829 molecules[FragmentCounter-1]->AddAtom((*iter)); // counting starts at 1 830 mol->erase(iter); 862 831 } 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); 864 833 performCriticalExit(); 865 834 } … … 869 838 while (mol->first->next != mol->last) { 870 839 Binder = mol->first->next; 871 Walker = Binder->leftatom;840 const atom * const Walker = Binder->leftatom; 872 841 unlink(Binder); 873 842 link(Binder,molecules[MolMap[Walker->nr]-1]->last); // counting starts at 1 … … 891 860 int MoleculeListClass::CountAllAtoms() const 892 861 { 893 atom *Walker = NULL;894 862 int AtomNo = 0; 895 863 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(); 901 865 } 902 866 return AtomNo; … … 1073 1037 bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList) 1074 1038 { 1075 atom *Walker = NULL;1076 1039 atom *OtherWalker = NULL; 1077 1040 atom *Father = NULL; … … 1081 1044 DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl); 1082 1045 // fill ListOfLocalAtoms if NULL was given 1083 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference-> AtomCount, FreeList)) {1046 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) { 1084 1047 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl); 1085 1048 return false; … … 1097 1060 } 1098 1061 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(); 1103 1064 AtomNo = Father->nr; // global id of the current walker 1104 1065 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 walker1066 OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker 1106 1067 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); 1109 1070 } 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); 1111 1072 status = false; 1112 1073 } … … 1135 1096 bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter) 1136 1097 { 1137 atom * Walker = NULL, *Father = NULL;1098 atom *Father = NULL; 1138 1099 1139 1100 if (RootStack != NULL) { … … 1141 1102 if (&(RootStack[FragmentCounter]) != NULL) { 1142 1103 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(); 1147 1106 if (AtomMask[Father->nr]) // apply mask 1148 1107 #ifdef ADDHYDROGEN 1149 if ( Walker->type->Z != 1) // skip hydrogen1108 if ((*iter)->type->Z != 1) // skip hydrogen 1150 1109 #endif 1151 RootStack[FragmentCounter].push_front( Walker->nr);1110 RootStack[FragmentCounter].push_front((*iter)->nr); 1152 1111 } 1153 1112 if (next != NULL) … … 1191 1150 1192 1151 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); 1194 1153 FreeList = FreeList && true; 1195 1154 } … … 1215 1174 DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl); 1216 1175 // fill ListOfLocalAtoms if NULL was given 1217 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference-> AtomCount, FreeList)) {1176 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) { 1218 1177 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl); 1219 1178 return false; -
src/tesselation.cpp
r42af9e r1024cb 21 21 #include "Plane.hpp" 22 22 #include "Exceptions/LinearDependenceException.hpp" 23 #include "Helpers/Assert.hpp" 24 25 #include "Helpers/Assert.hpp" 23 26 24 27 class molecule; … … 357 360 // get ascending order of endpoints 358 361 PointMap OrderMap; 359 for (int i = 0; i < 3; i++) 362 for (int i = 0; i < 3; i++) { 360 363 // for all three lines 361 364 for (int j = 0; j < 2; j++) { // for both endpoints … … 363 366 // and we don't care whether insertion fails 364 367 } 368 } 365 369 // set endpoints 366 370 int Counter = 0; … … 371 375 Counter++; 372 376 } 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 379 380 380 381 /** Destructor of BoundaryTriangleSet. … … 682 683 } 683 684 685 /** 686 * gets the Plane defined by the three triangle Basepoints 687 */ 688 Plane 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 696 Vector 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 702 string 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 684 708 /** output operator for BoundaryTriangleSet. 685 709 * \param &ost output stream … … 688 712 ostream &operator <<(ostream &ost, const BoundaryTriangleSet &a) 689 713 { 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) << "]"; 691 715 // ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << "," 692 716 // << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]"; … … 1208 1232 ; 1209 1233 1210 /** PointCloud implementation of GetTerminalPoint.1211 * Uses PointsOnBoundary and STL stuff.1212 */1213 TesselPoint * Tesselation::GetTerminalPoint() const1214 {1215 Info FunctionInfo(__func__);1216 PointMap::const_iterator Runner = PointsOnBoundary.end();1217 Runner--;1218 return (Runner->second->node);1219 }1220 ;1221 1222 1234 /** PointCloud implementation of GoToNext. 1223 1235 * Uses PointsOnBoundary and STL stuff. … … 1231 1243 ; 1232 1244 1233 /** PointCloud implementation of GoToPrevious.1234 * Uses PointsOnBoundary and STL stuff.1235 */1236 void Tesselation::GoToPrevious() const1237 {1238 Info FunctionInfo(__func__);1239 if (InternalPointer != PointsOnBoundary.begin())1240 InternalPointer--;1241 }1242 ;1243 1244 1245 /** PointCloud implementation of GoToFirst. 1245 1246 * Uses PointsOnBoundary and STL stuff. … … 1249 1250 Info FunctionInfo(__func__); 1250 1251 InternalPointer = PointsOnBoundary.begin(); 1251 }1252 ;1253 1254 /** PointCloud implementation of GoToLast.1255 * Uses PointsOnBoundary and STL stuff.1256 */1257 void Tesselation::GoToLast() const1258 {1259 Info FunctionInfo(__func__);1260 InternalPointer = PointsOnBoundary.end();1261 InternalPointer--;1262 1252 } 1263 1253 ; … … 1455 1445 CenterVector.Zero(); 1456 1446 for (int i = 0; i < 3; i++) 1457 CenterVector += (*BTS->endpoints[i]->node->node);1447 CenterVector += BTS->getEndpoint(i); 1458 1448 CenterVector.Scale(1. / 3.); 1459 1449 DoLog(2) && (Log() << Verbose(2) << "CenterVector of base triangle is " << CenterVector << endl); … … 2569 2559 // fill the set of neighbours 2570 2560 TesselPointSet SetOfNeighbours; 2561 2571 2562 SetOfNeighbours.insert(CandidateLine.BaseLine->endpoints[1]->node); 2572 2563 for (TesselPointList::iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); Runner++) … … 4802 4793 if (LastTriangle != NULL) { 4803 4794 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); 4805 4796 NumberName = sstr.str(); 4806 4797 if (DoTecplotOutput) { -
src/tesselation.hpp
r42af9e r1024cb 38 38 class PointCloud; 39 39 class Tesselation; 40 class Plane; 40 41 41 42 /********************************************** definitions *********************************/ … … 166 167 bool IsPresentTupel(const BoundaryTriangleSet * const T) const; 167 168 169 Plane getPlane() const; 170 Vector getEndpoint(int) const; 171 std::string getEndpointName(int) const; 172 168 173 class BoundaryPointSet *endpoints[3]; 169 174 class BoundaryLineSet *lines[3]; … … 171 176 Vector SphereCenter; 172 177 int Nr; 178 179 private: 180 173 181 }; 174 182 … … 236 244 virtual Vector *GetCenter() const { return NULL; }; 237 245 virtual TesselPoint *GetPoint() const { return NULL; }; 238 virtual TesselPoint *GetTerminalPoint() const { return NULL; };239 246 virtual int GetMaxId() const { return 0; }; 240 247 virtual void GoToNext() const {}; 241 virtual void GoToPrevious() const {};242 248 virtual void GoToFirst() const {}; 243 virtual void GoToLast() const {};244 249 virtual bool IsEmpty() const { return true; }; 245 250 virtual bool IsEnd() const { return true; }; … … 355 360 virtual Vector *GetCenter(ofstream *out) const; 356 361 virtual TesselPoint *GetPoint() const; 357 virtual TesselPoint *GetTerminalPoint() const;358 362 virtual void GoToNext() const; 359 virtual void GoToPrevious() const;360 363 virtual void GoToFirst() const; 361 virtual void GoToLast() const;362 364 virtual bool IsEmpty() const; 363 365 virtual bool IsEnd() const; -
src/tesselationhelpers.cpp
r42af9e r1024cb 16 16 #include "vector_ops.hpp" 17 17 #include "verbose.hpp" 18 #include "Plane.hpp" 18 19 19 20 double DetGet(gsl_matrix * const A, const int inPlace) … … 687 688 return -1; 688 689 } 689 distance = x->DistanceTo Plane(triangle->NormalVector, *triangle->endpoints[0]->node->node);690 distance = x->DistanceToSpace(triangle->getPlane()); 690 691 return distance; 691 692 }; … … 837 838 int i=cloud->GetMaxId(); 838 839 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++){ 840 841 LookupList[i] = -1; 842 } 841 843 842 844 // print atom coordinates 843 845 int Counter = 1; 844 846 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) { 846 848 Walker = target->second->node; 847 849 LookupList[Walker->nr] = Counter++; -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
r42af9e r1024cb 66 66 67 67 // check that TestMolecule was correctly constructed 68 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 4 );68 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 69 69 70 70 TestList = World::getInstance().getMolecules(); -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
r42af9e r1024cb 25 25 #include "tesselation.hpp" 26 26 #include "World.hpp" 27 #include "Helpers/Assert.hpp" 27 28 28 29 #include "Helpers/Assert.hpp" … … 39 40 void AnalysisCorrelationToSurfaceUnitTest::setUp() 40 41 { 41 //ASSERT_DO(Assert::Throw);42 ASSERT_DO(Assert::Throw); 42 43 43 44 atom *Walker = NULL; … … 54 55 hydrogen = World::getInstance().getPeriode()->FindElement(1); 55 56 TestSurfaceMolecule = World::getInstance().createMolecule(); 57 56 58 Walker = World::getInstance().createAtom(); 57 59 Walker->type = hydrogen; 58 60 *Walker->node = Vector(1., 0., 1. ); 59 60 TestSurfaceMolecule->AddAtom(Walker); 61 TestSurfaceMolecule->AddAtom(Walker); 62 61 63 Walker = World::getInstance().createAtom(); 62 64 Walker->type = hydrogen; 63 65 *Walker->node = Vector(0., 1., 1. ); 64 66 TestSurfaceMolecule->AddAtom(Walker); 67 65 68 Walker = World::getInstance().createAtom(); 66 69 Walker->type = hydrogen; 67 70 *Walker->node = Vector(1., 1., 0. ); 68 71 TestSurfaceMolecule->AddAtom(Walker); 72 69 73 Walker = World::getInstance().createAtom(); 70 74 Walker->type = hydrogen; … … 73 77 74 78 // check that TestMolecule was correctly constructed 75 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule-> AtomCount, 4 );79 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 ); 76 80 77 81 TestList = World::getInstance().getMolecules(); … … 91 95 *Walker->node = Vector(4., 0., 4. ); 92 96 TestSurfaceMolecule->AddAtom(Walker); 97 93 98 Walker = World::getInstance().createAtom(); 94 99 Walker->type = carbon; 95 100 *Walker->node = Vector(0., 4., 4. ); 96 101 TestSurfaceMolecule->AddAtom(Walker); 102 97 103 Walker = World::getInstance().createAtom(); 98 104 Walker->type = carbon; 99 105 *Walker->node = Vector(4., 4., 0. ); 100 106 TestSurfaceMolecule->AddAtom(Walker); 107 101 108 // add inner atoms 102 109 Walker = World::getInstance().createAtom(); … … 104 111 *Walker->node = Vector(0.5, 0.5, 0.5 ); 105 112 TestSurfaceMolecule->AddAtom(Walker); 113 106 114 TestSurfaceMolecule->ActiveFlag = true; 107 115 TestList->insert(TestSurfaceMolecule); … … 133 141 void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest() 134 142 { 135 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule-> AtomCount);143 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() ); 136 144 CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() ); 137 145 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() ); -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
r42af9e r1024cb 68 68 69 69 // check that TestMolecule was correctly constructed 70 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 4 );70 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 71 71 72 72 TestList = World::getInstance().getMolecules(); -
src/unittests/CountBondsUnitTest.cpp
r42af9e r1024cb 92 92 93 93 // 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 ); 100 96 101 97 // create a small file with table -
src/unittests/LinkedCellUnitTest.cpp
r42af9e r1024cb 60 60 61 61 // 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 ); 65 63 }; 66 64 … … 187 185 { 188 186 // 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) ); 193 189 } 194 190 195 191 // 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); 201 197 202 198 // 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); 208 204 }; 209 205 … … 277 273 size = ListOfPoints->size(); 278 274 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)); 284 278 size--; 285 279 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); … … 296 290 size=ListOfPoints->size(); 297 291 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); 303 295 size--; 304 296 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); … … 316 308 size=ListOfPoints->size(); 317 309 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); 322 312 size--; 323 313 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); … … 345 335 size = ListOfPoints->size(); 346 336 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); 352 340 size--; 353 341 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); -
src/unittests/Makefile.am
r42af9e r1024cb 49 49 noinst_PROGRAMS = $(TESTS) TestRunner 50 50 51 GSLLIBS = ../libgslwrapper.a 52 ALLLIBS = ../libmolecuilder.a ${GSLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB}51 GSLLIBS = ../libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} 52 ALLLIBS = ../libmolecuilder.a ${GSLLIBS} 53 53 54 54 TESTSOURCES = \ … … 182 182 manipulateAtomsTest_LDADD = ${ALLLIBS} 183 183 184 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memory usageobserver.cpp ../memoryusageobserver.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp184 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp 185 185 MemoryAllocatorUnitTest_LDADD = ${ALLLIBS} 186 186 … … 218 218 Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS} 219 219 220 TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memory usageobserver.cpp ../memoryusageobserver.hpp $(TESTSOURCES) $(TESTHEADERS)220 TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp $(TESTSOURCES) $(TESTHEADERS) 221 221 TestRunner_LDADD = ${ALLLIBS} 222 222 -
src/unittests/ObserverTest.cpp
r42af9e r1024cb 11 11 #include <cppunit/extensions/TestFactoryRegistry.h> 12 12 #include <cppunit/ui/text/TestRunner.h> 13 #include <set> 13 14 14 15 #include "Patterns/Observer.hpp" 16 #include "Patterns/ObservedIterator.hpp" 15 17 #include "Helpers/Assert.hpp" 16 18 … … 162 164 bool wasNotified; 163 165 }; 166 167 class ObservableCollection : public Observable { 168 public: 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 200 private: 201 set theSet; 202 }; 203 164 204 165 205 /******************* actuall tests ***************/ … … 173 213 blockObservable = new BlockObservable(); 174 214 notificationObservable = new NotificationObservable(); 215 collection = new ObservableCollection(5); 175 216 176 217 observer1 = new UpdateCountObserver(); … … 181 222 notificationObserver1 = new NotificationObserver(notificationObservable->notification1); 182 223 notificationObserver2 = new NotificationObserver(notificationObservable->notification2); 183 184 224 } 185 225 … … 191 231 delete blockObservable; 192 232 delete notificationObservable; 233 delete collection; 193 234 194 235 delete observer1; … … 277 318 blockObservable->changeMethod2(); 278 319 blockObservable->noChangeMethod(); 320 } 321 322 void 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); 279 354 } 280 355 -
src/unittests/ObserverTest.hpp
r42af9e r1024cb 17 17 class CallObservable; 18 18 class SuperObservable; 19 class ObservableCollection; 19 20 class BlockObservable; 20 21 class NotificationObservable; 21 22 22 23 23 class ObserverTest : public CppUnit::TestFixture … … 29 29 CPPUNIT_TEST ( doesNotifyTest ); 30 30 CPPUNIT_TEST ( doesReportTest ); 31 CPPUNIT_TEST ( iteratorTest ); 31 32 CPPUNIT_TEST ( CircleDetectionTest ); 32 33 CPPUNIT_TEST_SUITE_END(); … … 41 42 void doesNotifyTest(); 42 43 void doesReportTest(); 44 void iteratorTest(); 43 45 void CircleDetectionTest(); 44 46 … … 58 60 SuperObservable *superObservable; 59 61 NotificationObservable *notificationObservable; 62 ObservableCollection *collection; 63 60 64 }; 61 65 -
src/unittests/analysisbondsunittest.cpp
r42af9e r1024cb 25 25 #include "molecule.hpp" 26 26 #include "periodentafel.hpp" 27 #include "World.hpp" 27 28 28 29 #ifdef HAVE_TESTRUNNER … … 76 77 77 78 // check that TestMolecule was correctly constructed 78 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 5 );79 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 5 ); 79 80 80 81 // create a small file with table -
src/unittests/bondgraphunittest.cpp
r42af9e r1024cb 77 77 78 78 // check that TestMolecule was correctly constructed 79 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 4 );79 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 80 80 81 81 // create a small file with table … … 114 114 }; 115 115 116 /** Tests whether setup worked. 117 */ 118 void BondGraphTest::SetupTest() 119 { 120 CPPUNIT_ASSERT_EQUAL (false, TestMolecule->empty()); 121 CPPUNIT_ASSERT_EQUAL ((size_t)4, TestMolecule->size()); 122 }; 123 116 124 /** UnitTest for BondGraphTest::LoadBondLengthTable(). 117 125 */ … … 128 136 void BondGraphTest::ConstructGraphFromTableTest() 129 137 { 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++; 133 141 CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) ); 134 142 CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) ); 135 CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );143 CPPUNIT_ASSERT_EQUAL( true , (*Walker)->IsBondedTo((*Runner)) ); 136 144 }; 137 145 … … 140 148 void BondGraphTest::ConstructGraphFromCovalentRadiiTest() 141 149 { 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 ); 145 154 CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) ); 146 155 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) ); 148 159 }; 149 160 -
src/unittests/bondgraphunittest.hpp
r42af9e r1024cb 22 22 { 23 23 CPPUNIT_TEST_SUITE( BondGraphTest) ; 24 CPPUNIT_TEST ( SetupTest ); 24 25 CPPUNIT_TEST ( LoadTableTest ); 25 26 CPPUNIT_TEST ( ConstructGraphFromTableTest ); … … 30 31 void setUp(); 31 32 void tearDown(); 33 void SetupTest(); 32 34 void LoadTableTest(); 33 35 void ConstructGraphFromTableTest(); -
src/unittests/listofbondsunittest.cpp
r42af9e r1024cb 67 67 68 68 // check that TestMolecule was correctly constructed 69 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 4 );69 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 70 70 }; 71 71 … … 81 81 }; 82 82 83 /** Tests whether setup worked correctly. 84 * 85 */ 86 void ListOfBondsTest::SetupTest() 87 { 88 CPPUNIT_ASSERT_EQUAL( false, TestMolecule->empty() ); 89 CPPUNIT_ASSERT_EQUAL( (size_t)4, TestMolecule->size() ); 90 }; 91 83 92 /** Unit Test of molecule::AddBond() 84 93 * … … 87 96 { 88 97 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; 91 102 CPPUNIT_ASSERT( atom1 != NULL ); 92 103 CPPUNIT_ASSERT( atom2 != NULL ); … … 115 126 { 116 127 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; 119 132 CPPUNIT_ASSERT( atom1 != NULL ); 120 133 CPPUNIT_ASSERT( atom2 != NULL ); … … 141 154 { 142 155 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; 146 162 CPPUNIT_ASSERT( atom1 != NULL ); 147 163 CPPUNIT_ASSERT( atom2 != NULL ); … … 180 196 { 181 197 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; 184 202 CPPUNIT_ASSERT( atom1 != NULL ); 185 203 CPPUNIT_ASSERT( atom2 != NULL ); … … 206 224 { 207 225 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; 210 230 CPPUNIT_ASSERT( atom1 != NULL ); 211 231 CPPUNIT_ASSERT( atom2 != NULL ); … … 231 251 { 232 252 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; 235 257 CPPUNIT_ASSERT( atom1 != NULL ); 236 258 CPPUNIT_ASSERT( atom2 != NULL ); -
src/unittests/listofbondsunittest.hpp
r42af9e r1024cb 20 20 { 21 21 CPPUNIT_TEST_SUITE( ListOfBondsTest) ; 22 CPPUNIT_TEST ( SetupTest ); 22 23 CPPUNIT_TEST ( AddingBondTest ); 23 24 CPPUNIT_TEST ( RemovingBondTest ); … … 31 32 void setUp(); 32 33 void tearDown(); 34 void SetupTest(); 33 35 void AddingBondTest(); 34 36 void RemovingBondTest(); -
src/vector.cpp
r42af9e r1024cb 266 266 * \return distance to plane 267 267 */ 268 double Vector::DistanceTo Plane(const Vector &PlaneNormal, const Vector &PlaneOffset) const269 { 270 return GetDistanceVectorToPlane(PlaneNormal,PlaneOffset).Norm();268 double Vector::DistanceToSpace(const Space &space) const 269 { 270 return space.distance(*this); 271 271 }; 272 272 -
src/vector.hpp
r42af9e r1024cb 40 40 double DistanceSquared(const Vector &y) const; 41 41 Vector GetDistanceVectorToPlane(const Vector &PlaneNormal, const Vector &PlaneOffset) const; 42 double DistanceTo Plane(const Vector &PlaneNormal, const Vector &PlaneOffset) const;42 double DistanceToSpace(const Space& space) const; 43 43 double PeriodicDistance(const Vector &y, const double * const cell_size) const; 44 44 double PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const; -
tests/regression/Domain/5/post/test.conf
r42af9e r1024cb 71 71 Ion_Type2 3 6 1.0 3 3 12.01100000000 Carbon C 72 72 #Ion_TypeNr._Nr.R[0] R[1] R[2] MoveType (0 MoveIon, 1 FixedIon) 73 Ion_Type 2_1 4.891042973 3.275186040 3.1822974330 # molecule nr 074 Ion_Type 2_2 4.266392982 4.158586027 3.1822974330 # molecule nr 175 Ion_Type 2_3 3.641792991 3.2751860403.182297433 0 # molecule nr 276 Ion_Type1_ 1 4.891042973 2.6458860502.381297445 0 # molecule nr 377 Ion_Type1_ 2 4.891042973 2.6458860503.983297422 0 # molecule nr 478 Ion_Type1_ 3 5.336019804 3.9045368783.182297433 0 # molecule nr 579 Ion_Type1_ 4 4.266392982 4.7878860182.381297445 0 # molecule nr 680 Ion_Type1_ 5 4.266392982 4.7878860183.983297422 0 # molecule nr 781 Ion_Type 1_6 3.196816159 3.9045368773.182297433 0 # molecule nr 882 Ion_Type 1_7 3.641792991 2.645886050 2.3812974450 # molecule nr 983 Ion_Type 1_8 3.641792991 2.645886050 3.9832974220 # molecule nr 1073 Ion_Type1_1 4.891042973 2.645886050 2.381297445 0 # molecule nr 0 74 Ion_Type1_2 4.891042973 2.645886050 3.983297422 0 # molecule nr 1 75 Ion_Type1_3 5.336019804 3.904536878 3.182297433 0 # molecule nr 2 76 Ion_Type1_4 4.266392982 4.787886018 2.381297445 0 # molecule nr 3 77 Ion_Type1_5 4.266392982 4.787886018 3.983297422 0 # molecule nr 4 78 Ion_Type1_6 3.196816159 3.904536877 3.182297433 0 # molecule nr 5 79 Ion_Type1_7 3.641792991 2.645886050 2.381297445 0 # molecule nr 6 80 Ion_Type1_8 3.641792991 2.645886050 3.983297422 0 # molecule nr 7 81 Ion_Type2_1 4.891042973 3.275186040 3.182297433 0 # molecule nr 8 82 Ion_Type2_2 4.266392982 4.158586027 3.182297433 0 # molecule nr 9 83 Ion_Type2_3 3.641792991 3.275186040 3.182297433 0 # molecule nr 10 -
tests/regression/Domain/5/pre/test.conf
r42af9e r1024cb 71 71 Ion_Type2 3 6 1.0 3 3 12.01100000000 Carbon C 72 72 #Ion_TypeNr._Nr.R[0] R[1] R[2] MoveType (0 MoveIon, 1 FixedIon) 73 Ion_Type 2_1 9.782085945 3.275186040 3.5358860370 # molecule nr 074 Ion_Type 2_2 8.532785963 4.158586027 3.5358860370 # molecule nr 175 Ion_Type 2_3 7.283585982 3.2751860403.535886037 0 # molecule nr 276 Ion_Type1_ 1 9.782085945 2.6458860502.645886050 0 # molecule nr 377 Ion_Type1_ 2 9.782085945 2.6458860504.425886024 0 # molecule nr 478 Ion_Type1_ 3 10.672039608 3.9045368783.535886037 0 # molecule nr 579 Ion_Type1_ 4 8.532785963 4.7878860182.645886050 0 # molecule nr 680 Ion_Type1_ 5 8.532785963 4.7878860184.425886024 0 # molecule nr 781 Ion_Type 1_6 6.393632318 3.9045368773.535886037 0 # molecule nr 882 Ion_Type 1_7 7.283585982 2.645886050 2.6458860500 # molecule nr 983 Ion_Type 1_8 7.283585982 2.645886050 4.4258860240 # molecule nr 1073 Ion_Type1_1 9.782085945 2.645886050 2.645886050 0 # molecule nr 0 74 Ion_Type1_2 9.782085945 2.645886050 4.425886024 0 # molecule nr 1 75 Ion_Type1_3 10.672039608 3.904536878 3.535886037 0 # molecule nr 2 76 Ion_Type1_4 8.532785963 4.787886018 2.645886050 0 # molecule nr 3 77 Ion_Type1_5 8.532785963 4.787886018 4.425886024 0 # molecule nr 4 78 Ion_Type1_6 6.393632318 3.904536877 3.535886037 0 # molecule nr 5 79 Ion_Type1_7 7.283585982 2.645886050 2.645886050 0 # molecule nr 6 80 Ion_Type1_8 7.283585982 2.645886050 4.425886024 0 # molecule nr 7 81 Ion_Type2_1 9.782085945 3.275186040 3.535886037 0 # molecule nr 8 82 Ion_Type2_2 8.532785963 4.158586027 3.535886037 0 # molecule nr 9 83 Ion_Type2_3 7.283585982 3.275186040 3.535886037 0 # molecule nr 10 -
tests/regression/Domain/6/pre/test.conf
r42af9e r1024cb 71 71 Ion_Type2 3 6 1.0 3 3 12.01100000000 Carbon C 72 72 #Ion_TypeNr._Nr.R[0] R[1] R[2] MoveType (0 MoveIon, 1 FixedIon) 73 Ion_Type 2_1 9.782085945 3.275186040 3.5358860370 # molecule nr 074 Ion_Type 2_2 8.532785963 4.158586027 3.5358860370 # molecule nr 175 Ion_Type 2_3 7.283585982 3.2751860403.535886037 0 # molecule nr 276 Ion_Type1_ 1 9.782085945 2.6458860502.645886050 0 # molecule nr 377 Ion_Type1_ 2 9.782085945 2.6458860504.425886024 0 # molecule nr 478 Ion_Type1_ 3 10.672039608 3.9045368783.535886037 0 # molecule nr 579 Ion_Type1_ 4 8.532785963 4.7878860182.645886050 0 # molecule nr 680 Ion_Type1_ 5 8.532785963 4.7878860184.425886024 0 # molecule nr 781 Ion_Type 1_6 6.393632318 3.9045368773.535886037 0 # molecule nr 882 Ion_Type 1_7 7.283585982 2.645886050 2.6458860500 # molecule nr 983 Ion_Type 1_8 7.283585982 2.645886050 4.4258860240 # molecule nr 1073 Ion_Type1_1 9.782085945 2.645886050 2.645886050 0 # molecule nr 0 74 Ion_Type1_2 9.782085945 2.645886050 4.425886024 0 # molecule nr 1 75 Ion_Type1_3 10.672039608 3.904536878 3.535886037 0 # molecule nr 2 76 Ion_Type1_4 8.532785963 4.787886018 2.645886050 0 # molecule nr 3 77 Ion_Type1_5 8.532785963 4.787886018 4.425886024 0 # molecule nr 4 78 Ion_Type1_6 6.393632318 3.904536877 3.535886037 0 # molecule nr 5 79 Ion_Type1_7 7.283585982 2.645886050 2.645886050 0 # molecule nr 6 80 Ion_Type1_8 7.283585982 2.645886050 4.425886024 0 # molecule nr 7 81 Ion_Type2_1 9.782085945 3.275186040 3.535886037 0 # molecule nr 8 82 Ion_Type2_2 8.532785963 4.158586027 3.535886037 0 # molecule nr 9 83 Ion_Type2_3 7.283585982 3.275186040 3.535886037 0 # molecule nr 10 -
tests/regression/testsuite-domain.at
r42af9e r1024cb 45 45 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf .], 0) 46 46 AT_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]) 47 AT_CHECK([file=test.conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore]) 48 AT_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]) 49 AT_CHECK([file=test.conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore]) 50 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-x.conf], 0) 51 AT_CHECK([../../molecuilder test-x.conf -e ${abs_top_srcdir}/src/ -d 2 1 1], 0, [stdout], [stderr]) 52 AT_CHECK([file=test-x.conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore]) 53 AT_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]) 54 AT_CHECK([file=test-x.conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore]) 55 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-y.conf], 0) 56 AT_CHECK([../../molecuilder test-y.conf -e ${abs_top_srcdir}/src/ -d 1 2 1], 0, [stdout], [stderr]) 57 AT_CHECK([file=test-y.conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore]) 58 AT_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]) 59 AT_CHECK([file=test-y.conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore]) 60 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-z.conf], 0) 61 AT_CHECK([../../molecuilder test-z.conf -e ${abs_top_srcdir}/src/ -d 1 1 2], 0, [stdout], [stderr]) 62 AT_CHECK([file=test-z.conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore]) 63 AT_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]) 64 AT_CHECK([file=test-z.conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore]) 65 #AT_CHECK([/bin/false], 12, [ignore], [ignore]) 57 66 AT_CLEANUP -
tests/regression/testsuite-simple_configuration.at
r42af9e r1024cb 87 87 AT_KEYWORDS([configuration]) 88 88 AT_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]) 89 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -R 7.283585982 3.275186040 3.535886037 7.], 0, [stdout], [stderr]) 90 AT_CHECK([sort -n test.conf.xyz | grep -v "Created by" >test.conf.xyz-sorted], 0, [ignore], [ignore]) 91 AT_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]) 92 AT_CHECK([file=test.conf.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore]) 91 93 AT_CLEANUP
Note:
See TracChangeset
for help on using the changeset viewer.