Changes in / [992fd7:257c77]
- Files:
-
- 219 added
- 61 deleted
- 144 edited
Legend:
- Unmodified
- Added
- Removed
-
configure.ac
r992fd7 r257c77 27 27 28 28 # Boost libraries 29 AX_BOOST_BASE([1. 33.1])30 #AX_BOOST_PROGRAM_OPTIONS29 AX_BOOST_BASE([1.40]) 30 AX_BOOST_PROGRAM_OPTIONS 31 31 #AX_BOOST_FOREACH 32 32 #AX_BOOST_FILESYSTEM 33 33 AX_BOOST_THREAD 34 #AX_BOOST_PROGRAM_OPTIONS35 34 #AX_BOOST_SERIALIZATION 36 35 … … 99 98 100 99 # test suite 101 AC_CONFIG_TESTDIR(tests) 102 AC_CONFIG_FILES([tests/atlocal tests/Makefile]) 103 AC_CONFIG_FILES([tests/Tesselations/Makefile tests/Tesselations/defs]) 104 AC_CONFIG_FILES([tests/molecuilder], [chmod +x tests/molecuilder]) 105 AC_CONFIG_FILES([doc/molecuilder.xml]) 106 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile src/unittests/Makefile]) 100 AC_CONFIG_TESTDIR(tests/regression) 101 AC_CONFIG_FILES([ 102 tests/Makefile 103 tests/regression/atlocal 104 tests/regression/Makefile]) 105 AC_CONFIG_FILES([tests/regression/molecuilder], [chmod +x tests/regression/molecuilder]) 106 AC_CONFIG_FILES([ 107 tests/Tesselations/Makefile 108 tests/Tesselations/defs]) 109 AC_CONFIG_FILES([ 110 doc/molecuilder.xml]) 111 AC_CONFIG_FILES([ 112 Makefile 113 doc/Makefile 114 src/Makefile 115 src/Actions/Makefile 116 src/UIElements/Makefile 117 src/unittests/Makefile]) 107 118 AC_OUTPUT -
src/Actions/Action.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <string> … … 15 17 using namespace std; 16 18 19 Action::state_ptr getEmptyState() { 20 return Action::state_ptr(Memory::ignore(new ActionState())); 21 } 22 17 23 // An empty state to indicate success 18 Action::state_ptr Action::success = Action::state_ptr(Memory::ignore(new ActionState()));19 Action::state_ptr Action::failure = Action::state_ptr(Memory::ignore(new ActionState()));24 Action::state_ptr Action::success = getEmptyState(); 25 Action::state_ptr Action::failure = getEmptyState(); 20 26 21 27 Action::Action(std::string _name,bool _doRegister) : -
src/Actions/ActionHistory.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "ActionHistory.hpp" -
src/Actions/ActionRegistry.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Actions/ActionRegistry.hpp" … … 37 39 } 38 40 41 bool ActionRegistry::isActionByNamePresent(const std::string name){ 42 map<const string,Action*>::iterator iter; 43 iter = actionMap.find(name); 44 return iter!=actionMap.end(); 45 } 46 39 47 void ActionRegistry::registerAction(Action* action){ 40 48 pair<map<const string,Action*>::iterator,bool> ret; … … 43 51 } 44 52 53 void ActionRegistry::unregisterAction(Action* action){ 54 actionMap.erase(action->getName()); 55 } 56 57 std::map<const std::string,Action*>::iterator ActionRegistry::getBeginIter() 58 { 59 return actionMap.begin(); 60 } 61 62 std::map<const std::string,Action*>::iterator ActionRegistry::getEndIter() 63 { 64 return actionMap.end(); 65 } 66 45 67 CONSTRUCT_SINGLETON(ActionRegistry) -
src/Actions/ActionRegistry.hpp
r992fd7 r257c77 21 21 public: 22 22 Action* getActionByName(const std::string); 23 bool isActionByNamePresent(const std::string name); 23 24 void registerAction(Action*); 25 void unregisterAction(Action*); 26 27 std::map<const std::string,Action*>::iterator getBeginIter(); 28 std::map<const std::string,Action*>::iterator getEndIter(); 24 29 25 30 private: -
src/Actions/ActionSequence.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Actions/ActionSequence.hpp" -
src/Actions/ErrorAction.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <iostream> -
src/Actions/MakroAction.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <string> -
src/Actions/ManipulateAtomsProcess.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "ManipulateAtomsProcess.hpp" -
src/Actions/MethodAction.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <iostream> -
src/Actions/Process.cpp
r992fd7 r257c77 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "Process.hpp" 9 11 … … 11 13 12 14 Process::Process(int _maxSteps, std::string _name, bool _doRegister) : 15 Observable("Process"), 13 16 Action(_name,_doRegister), 14 17 maxSteps(_maxSteps), -
src/Descriptors/AtomDescriptor.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Descriptors/AtomDescriptor.hpp" -
src/Descriptors/AtomIdDescriptor.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "AtomIdDescriptor.hpp" -
src/Descriptors/AtomTypeDescriptor.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Descriptors/AtomTypeDescriptor.hpp" -
src/Descriptors/MoleculeDescriptor.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Descriptors/MoleculeDescriptor.hpp" -
src/Descriptors/MoleculeIdDescriptor.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "MoleculeIdDescriptor.hpp" -
src/Exceptions/CustomException.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "CustomException.hpp" -
src/Exceptions/LinearDependenceException.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "LinearDependenceException.hpp" -
src/Exceptions/MathException.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "MathException.hpp" -
src/Exceptions/SkewException.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "SkewException.hpp" -
src/Exceptions/ZeroVectorException.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "ZeroVectorException.hpp" -
src/Helpers/Assert.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Helpers/Assert.hpp" … … 46 48 using namespace Assert; 47 49 50 #ifndef NDEBUG 51 48 52 Action _my_assert::defaultAction = Ask; 49 53 std::vector<Assert::hook_t> _my_assert::hooks; … … 52 56 const char* _wrapper::message_ptr = "source pointer did not point to object of desired type"; 53 57 const char* _wrapper::message_ref = "source reference did not contain object of desired type"; 54 55 58 56 59 … … 63 66 { 64 67 if(!res){ 65 cout << "Assertion " << condition <<" failed in file " << filename << " at line " << line << endl;68 cout << "Assertion \"" << condition << "\" failed in file " << filename << " at line " << line << endl; 66 69 cout << "Assertion Message: " << message << std::endl; 67 70 while(true){ … … 123 126 return ActionNames[defaultAction]; 124 127 } 128 129 #endif 130 -
src/Helpers/MemDebug.cpp
r992fd7 r257c77 6 6 */ 7 7 8 #ifndef NDBEGUG 9 #ifndef NO_MEMDEBUG 10 8 11 #include <iostream> 9 12 #include <cstdlib> … … 11 14 #include <boost/thread.hpp> 12 15 16 #ifdef __GNUC__ 17 #include <execinfo.h> 18 #include <cxxabi.h> 19 #endif 20 13 21 using namespace std; 14 22 15 #ifndef NDBEGUG 16 #ifndef NO_MEMDEBUG 23 // we need our own low level mutexex, since we cannot assure the time of construction and destruction 24 // otherwise 25 #if defined(unix) || defined(__unix) 26 27 #include <pthread.h> 28 #include <cassert> 29 #define mutex_t pthread_mutex_t 30 #define mutex_init PTHREAD_MUTEX_INITIALIZER 31 #define mutex_lock(mtx) \ 32 do{\ 33 int res = pthread_mutex_lock(&(mtx));\ 34 assert(!res && "Could not lock mutex!");\ 35 }while(0) 36 37 #define mutex_unlock(mtx) \ 38 do{\ 39 int res = pthread_mutex_unlock(&(mtx));\ 40 assert(!res && "Could not unlock mutex!");\ 41 }while(0) 42 43 #else 44 # error "No thread structure defined for this plattform..." 45 #endif 17 46 18 47 namespace Memory { … … 34 63 char file[length+1]; 35 64 int line; 65 #ifdef __GNUC__ // function tracking only works with GCC 66 // function names can get looooong 67 enum {length2 = 256}; 68 char function[length2+1]; 69 #endif 36 70 size_t nbytes; 37 71 bool isUsed; … … 44 78 }; 45 79 46 boost::mutex memorylock; 80 81 mutex_t memorylock = mutex_init; 47 82 48 83 // start and end of the doubly-linked list … … 96 131 for(entry_t *pos=begin;pos;pos=pos->next){ 97 132 cout << "\nChunk of " << pos->info.nbytes << " bytes" << " still available" << endl; 133 #ifdef __GNUC__ 134 cout << "Chunk reserved at: " << pos->info.function 135 << " (" << pos->info.file << ":" << pos->info.line << ")" << endl; 136 #else 98 137 cout << "Chunk reserved at: " << pos->info.file << ":" << pos->info.line << endl; 99 } 138 #endif 139 } 140 } 141 142 // Adds an entry to the linked list 143 void addEntry(entry_t *entry){ 144 // check if the entry is already in the list 145 if(!entry->isIgnored) 146 return; 147 148 mutex_lock(Memory::memorylock); 149 150 entry->next=0; // the created block is last in the list 151 entry->prev=Memory::end; // the created block is last in the list 152 if(!Memory::begin){ 153 // the list was empty... start a new one 154 Memory::begin=entry; 155 } 156 else { 157 // other blocks present... we can add to the last one 158 Memory::end->next=entry; 159 } 160 Memory::end=entry; 161 162 // update some global info 163 Memory::state += entry->info.nbytes; 164 if(Memory::state>Memory::max){ 165 Memory::max = Memory::state; 166 } 167 ++Memory::allocs; 168 // done with the list... it is safe to unlock now 169 mutex_unlock(Memory::memorylock); 170 entry->isIgnored = false; 100 171 } 101 172 … … 105 176 return; 106 177 178 mutex_lock(memorylock); 107 179 if(entry->prev){ 108 180 entry->prev->next = entry->next; … … 120 192 end = entry->prev; 121 193 } 194 Memory::state -= entry->info.nbytes; 195 mutex_unlock(memorylock); 122 196 entry->isIgnored = true; 123 Memory::state -= entry->info.nbytes; 197 124 198 } 125 199 … … 130 204 deleteEntry(entry); 131 205 } 132 } 133 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); 206 207 #ifdef __GNUC__ 208 // this function let's us find the caller's name 209 char* getCaller(){ 210 // stack looks like this: 211 // getCaller(); 212 // operator new(); 213 // function_we_are_looking_for(); <- 214 const size_t max_depth = 3; 215 void* stack_addrs[max_depth]; 216 size_t stack_depth; 217 char **stack_strings=0; 218 const char *func_name=0; 219 const char *toplevel = "Global scope"; 220 char *retval=0; 221 222 // get the backtrace, depth three 223 stack_depth = backtrace(stack_addrs,max_depth); 224 stack_strings = backtrace_symbols(stack_addrs, stack_depth); 225 // used later for demangling 226 // reserved here, so we can free it unconditionally 227 char *dm_function = static_cast<char*>(malloc(entry_t::info_t::length2)); 228 if(!dm_function){ 229 // malloc failed... we are out of luck 230 throw std::bad_alloc(); 231 } 232 233 // see if we found our function name 234 if(stack_depth==max_depth){ 235 // find the mangled function name 236 char *begin = stack_strings[max_depth-1]; 237 // function name starts with a ( 238 while(*begin && *begin!='(') ++begin; 239 char *end=begin; 240 while(*end && *end!='+') ++end; 241 242 // see if we found our function name 243 if(*begin && *end){ 244 *begin++ = 0; 245 *end = 0; 246 // use the C++ demangler 247 248 size_t sz = entry_t::info_t::length2; 249 int status; 250 char *func_ret = abi::__cxa_demangle(begin, dm_function, &sz, &status); 251 if(func_ret){ 252 // abi might have realloced... 253 dm_function = func_ret; 254 func_name = dm_function; 255 } 256 else{ 257 // demangling failed... get the function name without demangling 258 func_name = begin; 259 } 260 } 261 else{ 262 // function name not found... get the whole line 263 func_name = stack_strings[max_depth-1]; 264 } 265 266 } 267 else{ 268 func_name = toplevel; 269 } 270 271 // now we copy the desired function name 272 if((retval = static_cast<char*>(malloc(strlen(func_name)+1)))){ 273 // we know that the string will fit, so strcpy is safe here 274 strcpy(retval,func_name); 275 } 276 else{ 277 free(stack_strings); // malloc()ed by backtrace_symbols 278 free(dm_function); 279 // uh-uh ... seems we are out of luck for allocations now 280 throw std::bad_alloc(); 281 } 282 free(dm_function); 283 free(stack_strings); // malloc()ed by backtrace_symbols 284 return retval; 285 } 286 #endif 287 } 288 289 #ifdef __GNUC__ 290 291 void *operator new(size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc) { 138 292 139 293 // to avoid allocations of 0 bytes if someone screws up … … 153 307 } 154 308 155 // we got the space, so update the global info 156 Memory::state += nbytes; 157 if(Memory::state>Memory::max){ 158 Memory::max = Memory::state; 159 } 160 Memory::allocs++; 309 // build the entry in front of the space 310 Memory::entry_t *entry = (Memory::entry_t*) res; 311 memset(res,0,entrySpace); 312 entry->info.nbytes = nbytes; 313 entry->info.isUsed = true; 314 strncpy(entry->info.file,file,Memory::entry_t::info_t::length); 315 entry->info.file[Memory::entry_t::info_t::length] = '\0'; 316 entry->info.line=line; 317 strncpy(entry->info.function,func,Memory::entry_t::info_t::length2); 318 entry->info.function[Memory::entry_t::info_t::length2] = '\0'; 319 // the space starts behind the info 320 entry->info.location = (char*)res + entrySpace; 321 322 // mark the block as not in the list (will be changed by addEntry) 323 entry->isIgnored = true; 324 Memory::addEntry(entry); 325 326 // get the checksum... 327 entry->checksum = Memory::calcChecksum(&entry->info); 328 329 // ok, space is prepared... the user can have it. 330 // the rest (constructor, deleting when something is thrown etc) 331 // is handled automatically 332 return entry->info.location; 333 } 334 335 #else 336 337 void *operator new(size_t nbytes,const char* file, int line) throw(std::bad_alloc) { 338 339 // to avoid allocations of 0 bytes if someone screws up 340 // allocation with 0 byte size are undefined behavior, so we are 341 // free to handle it this way 342 if(!nbytes) { 343 nbytes = 1; 344 } 345 346 // get the size of the entry, including alignment 347 static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t)); 348 349 void *res; 350 if(!(res=malloc(entrySpace + nbytes))){ 351 // new must throw, when space is low 352 throw std::bad_alloc(); 353 } 161 354 162 355 // build the entry in front of the space … … 171 364 entry->info.location = (char*)res + entrySpace; 172 365 173 // add the entry at the end of the list 174 entry->next=0; // the created block is last in the list 175 entry->prev=Memory::end; // the created block is last in the list 176 if(!Memory::begin){ 177 // the list was empty... start a new one 178 Memory::begin=entry; 179 } 180 else { 181 // other blocks present... we can add to the last one 182 Memory::end->next=entry; 183 } 184 Memory::end=entry; 366 // mark the block as not in the list (will be changed by addEntry) 367 entry->isIgnored = true; 368 Memory::addEntry(entry); 185 369 186 370 // get the checksum... … … 196 380 } 197 381 382 #endif 383 198 384 void *operator new(size_t nbytes) throw(std::bad_alloc) { 199 385 // Just forward to the other operator, when we do not know from 200 386 // where the allocation came 387 #ifdef __GNUC__ 388 // this might throw bad_alloc 389 char *caller = Memory::getCaller(); 390 void* retval = 0; 391 392 // if this throws, we have to clean up the caller anyway 393 try{ 394 retval = operator new(nbytes,"Unknown",0,caller); 395 } 396 catch(...) 397 { 398 free(caller); // malloc()ed by Memory::getCaller(); 399 throw; 400 } 401 free(caller); // malloc()ed by Memory::getCaller(); 402 return retval; 403 #else 201 404 return operator new(nbytes,"Unknown",0); 202 } 405 #endif 406 } 407 408 #ifdef __GNUC__ 409 410 void *operator new[] (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc) { 411 // The difference between new and new[] is just for compiler bookkeeping. 412 return operator new(nbytes,file,line,func); 413 } 414 415 #else 203 416 204 417 void *operator new[] (size_t nbytes,const char* file, int line) throw(std::bad_alloc) { … … 207 420 } 208 421 422 #endif 423 209 424 void *operator new[] (size_t nbytes) throw(std::bad_alloc) { 210 425 // Forward again 426 #ifdef __GNUC__ 427 // this might throw bad_alloc 428 char *caller = Memory::getCaller(); 429 void *retval=0; 430 431 // if this throws, we have to clean up the caller anyway 432 try{ 433 retval = operator new[] (nbytes,"Unknown",0,caller); 434 } 435 catch(...) 436 { 437 free(caller); // malloc()ed by Memory::getCaller(); 438 throw; 439 } 440 free(caller); // malloc()ed by Memory::getCaller(); 441 return retval; 442 #else 211 443 return operator new[] (nbytes,"Unknown",0); 444 #endif 212 445 } 213 446 … … 217 450 return; 218 451 } 219 220 // we need to lock, so the linked list does not changed while we are in here221 boost::mutex::scoped_lock guard(Memory::memorylock);222 452 223 453 // get the size for the entry, including alignment -
src/Helpers/MemDebug.hpp
r992fd7 r257c77 28 28 #endif 29 29 30 #include <cstdlib>31 30 #include <new> 31 32 // some light header files, that do weird new stuff and therefore need 33 // to be loaded before the define 34 #include <string> 35 #include <boost/optional.hpp> 36 #include <boost/shared_ptr.hpp> 37 #include <boost/function.hpp> 38 #include <boost/program_options.hpp> 39 32 40 33 41 namespace Memory { … … 53 61 } 54 62 } 55 63 #ifdef __GNUC__ 64 void *operator new (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc); 65 void *operator new[] (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc); 66 #else 56 67 void *operator new (size_t nbytes,const char* file, int line) throw(std::bad_alloc); 57 68 void *operator new[] (size_t nbytes,const char* file, int line) throw(std::bad_alloc); 69 #endif 58 70 void operator delete (void *ptr,const char*, int) throw(); 59 71 void operator delete[] (void *ptr,const char*, int) throw(); 72 73 60 74 61 75 /** … … 63 77 * version that allows tracking. 64 78 */ 79 #ifdef __GNUC__ 80 #define new new(__FILE__,__LINE__,__PRETTY_FUNCTION__) 81 #else 65 82 #define new new(__FILE__,__LINE__) 83 #endif 66 84 67 85 #endif 68 86 #endif 69 87 88 89 #ifdef NDEBUG 90 #undef MEMDEBUG 91 #endif 70 92 71 93 #ifndef MEMDEBUG -
src/Legacy/oldmenu.cpp
r992fd7 r257c77 6 6 * 7 7 */ 8 9 #include "Helpers/MemDebug.hpp" 8 10 9 11 #include "Legacy/oldmenu.hpp" … … 36 38 #include "Menu/DisplayMenuItem.hpp" 37 39 #include "Menu/SubMenuItem.hpp" 40 #include "Actions/MapOfActions.hpp" 38 41 #include "Actions/MethodAction.hpp" 39 42 #include "Actions/ErrorAction.hpp" … … 84 87 Dialog *dialog = UIFactory::getInstance().makeDialog(); 85 88 first = World::getInstance().createAtom(); 89 std::vector<element *> elements; 86 90 dialog->queryVector("Please enter coordinates: ",&first->x,World::getInstance().getDomain(), false); 87 dialog->queryElement("Please choose element: ",& first->type);91 dialog->queryElement("Please choose element: ",&elements); 88 92 if(dialog->display()){ 89 mol->AddAtom(first); // add to molecule 93 if (elements.size() == 1) { 94 first->type = elements.at(0); 95 mol->AddAtom(first); // add to molecule 96 } else { 97 DoeLog(1) && (eLog() << Verbose(1) << "Unequal to one element given for element of new atom." << endl); 98 } 90 99 } 91 100 else{ … … 424 433 void oldmenu::RemoveAtoms(molecule *mol) 425 434 { 426 atom * first, *second;435 atom *second; 427 436 int axis; 428 437 double tmp1, tmp2; … … 447 456 break; 448 457 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);458 { 459 second = mol->AskAtom("Enter number of atom as reference point: "); 460 Log() << Verbose(0) << "Enter radius: "; 461 cin >> tmp1; 462 molecule::iterator runner; 463 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) { 464 runner = iter++; 465 if ((*runner)->x.DistanceSquared((*runner)->x) > tmp1*tmp1) // distance to first above radius ... 466 mol->RemoveAtom((*runner)); 467 } 459 468 } 460 469 break; … … 466 475 Log() << Verbose(0) << "Upper boundary: "; 467 476 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); 477 molecule::iterator runner; 478 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) { 479 runner = iter++; 480 if (((*runner)->x[axis] < tmp1) || ((*runner)->x[axis] > tmp2)) {// out of boundary ... 481 //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl; 482 mol->RemoveAtom((*runner)); 476 483 } 477 484 } … … 516 523 min[i] = 0.; 517 524 518 second = mol->start; 519 while ((second->next != mol->end)) { 520 second = second->next; // advance 521 Z = second->type->Z; 525 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 526 Z = (*iter)->type->Z; 522 527 tmp1 = 0.; 523 if (first != second) {524 x = first->x - second->x;528 if (first != (*iter)) { 529 x = first->x - (*iter)->x; 525 530 tmp1 = x.Norm(); 526 531 } 527 532 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;533 //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << ((*iter)->nr << ": " << tmp1 << " a.u." << endl; 529 534 } 530 535 for (int i=MAX_ELEMENTS;i--;) … … 609 614 Log() << Verbose(0) << "What's the desired bond order: "; 610 615 cin >> Order1; 611 if (mol-> first->next != mol->last) { // there are bonds616 if (mol->hasBondStructure()) { 612 617 start = clock(); 613 618 mol->FragmentMolecule(Order1, configuration); … … 755 760 Log() << Verbose(0) << "State the factor: "; 756 761 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 762 if (mol->getAtomCount() != 0) { // if there is more than none 763 count = mol->getAtomCount(); // is changed becausing of adding, thus has to be stored away beforehand 761 764 Elements = new const element *[count]; 762 765 vectors = new Vector *[count]; 763 766 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; 767 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 768 Elements[j] = (*iter)->type; 769 vectors[j] = &(*iter)->x; 769 770 j++; 770 771 } … … 783 784 } 784 785 } 785 if (mol-> first->next != mol->last) // if connect matrix is present already, redo it786 if (mol->hasBondStructure()) 786 787 mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 787 788 // free memory … … 909 910 molecule *srcmol = NULL, *destmol = NULL; 910 911 Dialog *dialog = UIFactory::getInstance().makeDialog(); 911 dialog->queryMolecule(" Enter index of destination molecule: ",&destmol, molecules);912 dialog->queryMolecule(" Enter index of source molecule to add from: ",&srcmol, molecules);912 dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id")); 913 dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id")); 913 914 if(dialog->display()) { 914 915 molecules->SimpleAdd(srcmol, destmol); … … 923 924 molecule *srcmol = NULL, *destmol = NULL; 924 925 Dialog *dialog = UIFactory::getInstance().makeDialog(); 925 dialog->queryMolecule(" Enter index of matrix molecule (the variable one): ",&srcmol,molecules);926 dialog->queryMolecule(" Enter index of molecule to merge into (the fixed one): ",&destmol,molecules);926 dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id")); 927 dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id")); 927 928 if(dialog->display()) { 928 929 molecules->EmbedMerge(destmol, srcmol); … … 1025 1026 return; 1026 1027 } 1027 atom *Walker = mol->start;1028 1028 1029 1029 // generate some KeySets 1030 1030 Log() << Verbose(0) << "Generating KeySets." << endl; 1031 KeySet TestSets[mol-> AtomCount+1];1031 KeySet TestSets[mol->getAtomCount()+1]; 1032 1032 i=1; 1033 while (Walker->next != mol->end) { 1034 Walker = Walker->next; 1033 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1035 1034 for (int j=0;j<i;j++) { 1036 TestSets[j].insert( Walker->nr);1035 TestSets[j].insert((*iter)->nr); 1037 1036 } 1038 1037 i++; … … 1040 1039 Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl; 1041 1040 KeySetTestPair test; 1042 test = TestSets[mol->AtomCount-1].insert(Walker->nr); 1043 if (test.second) { 1044 Log() << Verbose(1) << "Insertion worked?!" << endl; 1041 molecule::const_iterator iter = mol->begin(); 1042 if (iter != mol->end()) { 1043 test = TestSets[mol->getAtomCount()-1].insert((*iter)->nr); 1044 if (test.second) { 1045 Log() << Verbose(1) << "Insertion worked?!" << endl; 1046 } else { 1047 Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl; 1048 } 1045 1049 } 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); 1050 eLog() << Verbose(1) << "No atoms to test double insertion." << endl; 1051 } 1050 1052 1051 1053 // constructing Graph structure … … 1055 1057 // insert KeySets into Subgraphs 1056 1058 Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl; 1057 for (int j=0;j<mol-> AtomCount;j++) {1059 for (int j=0;j<mol->getAtomCount();j++) { 1058 1060 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.))); 1059 1061 } 1060 1062 Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl; 1061 1063 GraphTestPair test2; 1062 test2 = Subgraphs.insert(GraphPair (TestSets[mol-> AtomCount],pair<int, double>(counter++, 1.)));1064 test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.))); 1063 1065 if (test2.second) { 1064 1066 Log() << Verbose(1) << "Insertion worked?!" << endl; -
src/Line.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Line.hpp" -
src/Makefile.am
r992fd7 r257c77 1 # PLEASE adhere to the alphabetical ordering in this Makefile! 2 # Also indentation by a single tab 3 4 SUBDIRS = Actions UIElements 5 1 6 # this includes source files that need to be present at multiple points 2 HELPERSOURCE = Helpers/Assert.cpp \ 3 Helpers/MemDebug.cpp 7 HELPERSOURCE = \ 8 Helpers/Assert.cpp \ 9 Helpers/MemDebug.cpp 4 10 5 ATOMSOURCE = atom.cpp atom_atominfo.cpp atom_bondedparticle.cpp atom_bondedparticleinfo.cpp atom_graphnode.cpp atom_graphnodeinfo.cpp atom_particleinfo.cpp atom_trajectoryparticle.cpp atom_trajectoryparticleinfo.cpp 6 ATOMHEADER = atom.hpp atom_atominfo.hpp atom_bondedparticle.hpp atom_bondedparticleinfo.hpp atom_graphnode.hpp atom_graphnodeinfo.hpp atom_particleinfo.hpp atom_trajectoryparticle.hpp atom_trajectoryparticleinfo.hpp 7 8 LINALGSOURCE = ${HELPERSOURCE} \ 9 gslmatrix.cpp \ 10 gslvector.cpp \ 11 linearsystemofequations.cpp \ 12 Space.cpp \ 13 vector.cpp 11 ATOMSOURCE = \ 12 atom.cpp \ 13 atom_atominfo.cpp \ 14 atom_bondedparticle.cpp \ 15 atom_bondedparticleinfo.cpp \ 16 atom_graphnode.cpp \ 17 atom_graphnodeinfo.cpp \ 18 atom_particleinfo.cpp \ 19 atom_trajectoryparticle.cpp \ 20 atom_trajectoryparticleinfo.cpp 21 ATOMHEADER = \ 22 atom.hpp \ 23 atom_atominfo.hpp \ 24 atom_bondedparticle.hpp \ 25 atom_bondedparticleinfo.hpp \ 26 atom_graphnode.hpp \ 27 atom_graphnodeinfo.hpp \ 28 atom_particleinfo.hpp \ 29 atom_trajectoryparticle.hpp \ 30 atom_trajectoryparticleinfo.hpp 31 32 LINALGSOURCE = \ 33 ${HELPERSOURCE} \ 34 gslmatrix.cpp \ 35 gslvector.cpp \ 36 linearsystemofequations.cpp \ 37 Space.cpp \ 38 vector.cpp 14 39 15 40 LINALGHEADER = gslmatrix.hpp \ 16 17 18 19 41 gslvector.hpp \ 42 linearsystemofequations.hpp \ 43 Space.hpp \ 44 vector.hpp 20 45 21 22 ANALYSISSOURCE = analysis_bonds.cpp analysis_correlation.cpp 23 ANALYSISHEADER = analysis_bonds.hpp analysis_correlation.hpp 24 25 ACTIONSSOURCE = Actions/Action.cpp \ 26 Actions/ActionHistory.cpp \ 27 Actions/ActionRegistry.cpp \ 28 Actions/ActionSequence.cpp \ 29 Actions/MakroAction.cpp \ 30 Actions/ManipulateAtomsProcess.cpp \ 31 Actions/MethodAction.cpp \ 32 Actions/Process.cpp 33 34 ACTIONSHEADER = Actions/Action.hpp \ 35 Actions/ActionHistory.hpp \ 36 Actions/ActionRegistry.hpp \ 37 Actions/ActionSequence.hpp \ 38 Actions/Calculation.hpp \ 39 Actions/Calculation_impl.hpp \ 40 Actions/MakroAction.hpp \ 41 Actions/ManipulateAtomsProcess.hpp \ 42 Actions/MethodAction.hpp \ 43 Actions/Process.hpp 44 45 46 # All actions that need user interaction go here 47 MENUACTIONSSOURCE = Actions/ErrorAction.cpp Actions/small_actions.cpp 48 MENUACTIONSHEADER = Actions/ErrorAction.hpp Actions/small_actions.hpp 49 50 PATTERNSOURCE = Patterns/Observer.cpp 51 PATTERNHEADER = Patterns/Cacheable.hpp \ 52 Patterns/Observer.hpp \ 53 Patterns/Singleton.hpp 54 55 VIEWSOURCE = Views/View.cpp Views/StringView.cpp Views/MethodStringView.cpp Views/StreamStringView.cpp 56 VIEWHEADER = Views/View.hpp Views/StringView.hpp Views/MethodStringView.hpp Views/StreamStringView.hpp 57 58 MENUSOURCE = Menu/Menu.cpp Menu/TextMenu.cpp Menu/MenuItem.cpp Menu/SubMenuItem.cpp Menu/ActionMenuItem.cpp Menu/SeperatorItem.cpp Menu/DisplayMenuItem.cpp 59 MENUHEADER = Menu/Menu.hpp Menu/TextMenu.hpp Menu/MenuItem.hpp Menu/SubMenuItem.hpp Menu/ActionMenuItem.hpp Menu/SeperatorItem.hpp Menu/DisplayMenuItem.hpp 60 61 UISOURCE = ${MENUACTIONSSOURCE} ${VIEWSOURCE} ${MENUSOURCE} UIElements/UIFactory.cpp UIElements/TextUIFactory.cpp UIElements/MainWindow.cpp UIElements/TextWindow.cpp UIElements/Dialog.cpp UIElements/TextDialog.cpp UIElements/TextStatusIndicator.cpp 62 UIHEADER = ${MENUACTIONSHEADER} ${VIEWHEADER} ${MENUHEADER} UIElements/UIFactory.hpp UIElements/TextUIFactory.hpp UIElements/MainWindow.hpp UIElements/TextWindow.hpp UIElements/Dialog.hpp UIElements/TextDialog.hpp UIElements/TextStatusIndicator.hpp 46 ANALYSISSOURCE = \ 47 analysis_bonds.cpp \ 48 analysis_correlation.cpp 49 ANALYSISHEADER = \ 50 analysis_bonds.hpp \ 51 analysis_correlation.hpp 52 53 ACTIONSSOURCE = \ 54 Actions/Action.cpp \ 55 Actions/ActionHistory.cpp \ 56 Actions/ActionRegistry.cpp \ 57 Actions/ActionSequence.cpp \ 58 Actions/ErrorAction.cpp \ 59 Actions/MakroAction.cpp \ 60 Actions/ManipulateAtomsProcess.cpp \ 61 Actions/MethodAction.cpp \ 62 Actions/Process.cpp 63 64 ACTIONSHEADER = \ 65 ${ANALYSISACTIONHEADER} \ 66 ${ATOMACTIONHEADER} \ 67 ${CMDACTIONHEADER} \ 68 ${FRAGMENTATIONACTIONHEADER} \ 69 ${MOLECULEACTIONHEADER} \ 70 ${PARSERACTIONHEADER} \ 71 ${TESSELATIONACTIONHEADER} \ 72 ${WORLDACTIONHEADER} \ 73 Actions/Action.hpp \ 74 Actions/ActionHistory.hpp \ 75 Actions/ActionRegistry.hpp \ 76 Actions/ActionSequence.hpp \ 77 Actions/Calculation.hpp \ 78 Actions/Calculation_impl.hpp \ 79 Actions/ErrorAction.hpp \ 80 Actions/MakroAction.hpp \ 81 Actions/ManipulateAtomsProcess.hpp \ 82 Actions/MapOfActions.hpp \ 83 Actions/MethodAction.hpp \ 84 Actions/Process.hpp 85 86 87 PARSERSOURCE = \ 88 Parser/ChangeTracker.cpp \ 89 Parser/FormatParser.cpp \ 90 Parser/TremoloParser.cpp \ 91 Parser/XyzParser.cpp 92 PARSERHEADER = \ 93 Parser/ChangeTracker.hpp \ 94 Parser/FormatParser.hpp \ 95 Parser/TremoloParser.hpp \ 96 Parser/XyzParser.hpp 97 98 PATTERNSOURCE = \ 99 Patterns/Observer.cpp 100 PATTERNHEADER = \ 101 Patterns/Cacheable.hpp \ 102 Patterns/Observer.hpp \ 103 Patterns/Singleton.hpp 63 104 64 105 # all these files are only used for legacy reasons while the transition is in progress … … 70 111 QTUIMOC_HEADER = UIElements/QT4/QTDialog.hpp \ 71 112 UIElements/QT4/QTMainWindow.hpp \ 72 Menu/QT4/QTMenu.hpp \73 Views/QT4/QTWorldView.hpp \74 Views/QT4/GLMoleculeView.hpp \75 Views/QT4/QTMoleculeView.hpp \76 Views/QT4/QTStatusBar.hpp113 UIElements/Menu/QT4/QTMenu.hpp \ 114 UIElements/Views/QT4/QTWorldView.hpp \ 115 UIElements/Views/QT4/GLMoleculeView.hpp \ 116 UIElements/Views/QT4/QTMoleculeView.hpp \ 117 UIElements/Views/QT4/QTStatusBar.hpp 77 118 78 119 QTUIMOC_TARGETS = QTMainWindow.moc.cpp \ … … 85 126 86 127 DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp \ 87 Descriptors/AtomIdDescriptor.cpp \ 88 Descriptors/AtomTypeDescriptor.cpp \ 89 Descriptors/MoleculeDescriptor.cpp \ 90 Descriptors/MoleculeIdDescriptor.cpp 128 Descriptors/AtomIdDescriptor.cpp \ 129 Descriptors/AtomTypeDescriptor.cpp \ 130 Descriptors/MoleculeDescriptor.cpp \ 131 Descriptors/MoleculeIdDescriptor.cpp \ 132 Descriptors/MoleculeNameDescriptor.cpp \ 133 Descriptors/MoleculePtrDescriptor.cpp 91 134 92 135 93 136 DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \ 94 Descriptors/AtomIdDescriptor.hpp \ 95 Descriptors/AtomTypeDescriptor.hpp \ 96 Descriptors/MoleculeDescriptor.hpp \ 97 Descriptors/MoleculeIdDescriptor.hpp 137 Descriptors/AtomIdDescriptor.hpp \ 138 Descriptors/AtomTypeDescriptor.hpp \ 139 Descriptors/MoleculeDescriptor.hpp \ 140 Descriptors/MoleculeIdDescriptor.hpp \ 141 Descriptors/MoleculeNameDescriptor.hpp \ 142 Descriptors/MoleculePtrDescriptor.hpp 98 143 99 144 EXCEPTIONSOURCE = Exceptions/CustomException.cpp \ … … 113 158 UIElements/QT4/QTDialog.cpp \ 114 159 UIElements/QT4/QTUIFactory.cpp \ 115 Menu/QT4/QTMenu.cpp \116 Views/QT4/QTWorldView.cpp \117 Views/QT4/GLMoleculeView.cpp \118 Views/QT4/QTMoleculeView.cpp \119 Views/QT4/QTStatusBar.cpp160 UIElements/Menu/QT4/QTMenu.cpp \ 161 UIElements/Views/QT4/QTWorldView.cpp \ 162 UIElements/Views/QT4/GLMoleculeView.cpp \ 163 UIElements/Views/QT4/QTMoleculeView.cpp \ 164 UIElements/Views/QT4/QTStatusBar.cpp 120 165 121 166 QTUIHEADER = ${QTUIMOC_HEADER} UIElements/QT4/QTUIFactory.hpp … … 123 168 QTUI_DEFS = 124 169 125 126 SOURCE = ${ANALYSISSOURCE} \ 127 ${ATOMSOURCE} \ 128 ${PATTERNSOURCE} \ 129 ${ACTIONSSOURCE} \ 130 ${DESCRIPTORSOURCE} \ 131 ${HELPERSOURCE} \ 132 ${LEGACYSOURCE} \ 133 ${EXCEPTIONSOURCE} \ 134 bond.cpp \ 135 bondgraph.cpp \ 136 boundary.cpp \ 137 config.cpp \ 138 element.cpp \ 139 ellipsoid.cpp \ 140 errorlogger.cpp \ 141 graph.cpp \ 142 helpers.cpp \ 143 info.cpp \ 144 leastsquaremin.cpp \ 145 Line.cpp \ 146 linkedcell.cpp \ 147 lists.cpp \ 148 log.cpp \ 149 logger.cpp \ 150 memoryusageobserver.cpp \ 151 moleculelist.cpp \ 152 molecule.cpp \ 153 molecule_dynamics.cpp \ 154 molecule_fragmentation.cpp \ 155 molecule_geometry.cpp \ 156 molecule_graph.cpp \ 157 molecule_pointcloud.cpp \ 158 parser.cpp \ 159 periodentafel.cpp \ 160 Plane.cpp \ 161 tesselation.cpp \ 162 tesselationhelpers.cpp \ 163 triangleintersectionlist.cpp \ 164 verbose.cpp \ 165 vector_ops.cpp \ 166 World.cpp 167 168 HEADER = ${ANALYSISHEADER}\ 169 ${ATOMHEADER} \ 170 ${PATTERNHEADER} \ 171 ${DESCRIPTORHEADER} \ 172 ${EXCEPTIONHEADER} \ 173 ${LEGACYHEADER} \ 174 bond.hpp \ 175 bondgraph.hpp \ 176 boundary.hpp \ 177 config.hpp \ 178 defs.hpp \ 179 element.hpp \ 180 ellipsoid.hpp \ 181 errorlogger.hpp \ 182 graph.hpp \ 183 helpers.hpp \ 184 info.hpp \ 185 leastsquaremin.hpp \ 186 Line.hpp \ 187 linkedcell.hpp \ 188 lists.hpp \ 189 log.hpp \ 190 logger.hpp \ 191 memoryallocator.hpp \ 192 memoryusageobserver.hpp \ 193 molecule.hpp \ 194 molecule_template.hpp \ 195 parser.hpp \ 196 Plane.hpp \ 197 periodentafel.hpp \ 198 stackclass.hpp \ 199 tesselation.hpp \ 200 tesselationhelpers.hpp \ 201 triangleintersectionlist.hpp \ 202 verbose.hpp \ 203 World.hpp 170 SOURCE = \ 171 ${ANALYSISSOURCE} \ 172 ${ACTIONSSOURCE} \ 173 ${ATOMSOURCE} \ 174 ${PATTERNSOURCE} \ 175 ${PARSERSOURCE} \ 176 ${DESCRIPTORSOURCE} \ 177 ${HELPERSOURCE} \ 178 ${LEGACYSOURCE} \ 179 ${EXCEPTIONSOURCE} \ 180 bond.cpp \ 181 bondgraph.cpp \ 182 boundary.cpp \ 183 CommandLineParser.cpp \ 184 config.cpp \ 185 element.cpp \ 186 elements_db.cpp \ 187 ellipsoid.cpp \ 188 errorlogger.cpp \ 189 graph.cpp \ 190 helpers.cpp \ 191 info.cpp \ 192 leastsquaremin.cpp \ 193 Line.cpp \ 194 linkedcell.cpp \ 195 log.cpp \ 196 logger.cpp \ 197 moleculelist.cpp \ 198 molecule.cpp \ 199 molecule_dynamics.cpp \ 200 molecule_fragmentation.cpp \ 201 molecule_geometry.cpp \ 202 molecule_graph.cpp \ 203 molecule_pointcloud.cpp \ 204 parser.cpp \ 205 periodentafel.cpp \ 206 Plane.cpp \ 207 Space.cpp \ 208 tesselation.cpp \ 209 tesselationhelpers.cpp \ 210 triangleintersectionlist.cpp \ 211 vector.cpp \ 212 vector_ops.cpp \ 213 verbose.cpp \ 214 World.cpp 215 216 HEADER = \ 217 ${ANALYSISHEADER} \ 218 ${ACTIONSHEADER} \ 219 ${ATOMHEADER} \ 220 ${PARSERHEADER} \ 221 ${PATTERNHEADER} \ 222 ${DESCRIPTORHEADER} \ 223 ${EXCEPTIONHEADER} \ 224 ${LEGACYHEADER} \ 225 bond.hpp \ 226 bondgraph.hpp \ 227 boundary.hpp \ 228 CommandLineParser.hpp \ 229 config.hpp \ 230 defs.hpp \ 231 element.hpp \ 232 elements_db.hpp \ 233 ellipsoid.hpp \ 234 errorlogger.hpp \ 235 graph.hpp \ 236 helpers.hpp \ 237 info.hpp \ 238 leastsquaremin.hpp \ 239 Line.hpp \ 240 linkedcell.hpp \ 241 lists.hpp \ 242 log.hpp \ 243 logger.hpp \ 244 molecule.hpp \ 245 molecule_template.hpp \ 246 parser.hpp \ 247 periodentafel.hpp \ 248 Plane.hpp \ 249 stackclass.hpp \ 250 tesselation.hpp \ 251 tesselationhelpers.hpp \ 252 triangleintersectionlist.hpp \ 253 verbose.hpp \ 254 vector_ops.hpp \ 255 World.hpp 256 257 # the following files are no longer used: 258 # memoryallocator.hpp \ 259 # memoryallocator.cpp \ 260 # memoryusageobserver.hpp \ 261 # memoryusageobserver.cpp 204 262 205 263 BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB) 206 264 GUI_LIBS = ${QT_LDADD} ${QT_LIB_GUI} -lQtOpenGL ${GLU_LIBS} 207 INCLUDES = -I$(top_srcdir)/src/unittests 265 INCLUDES = -I$(top_srcdir)/src/unittests -I$(top_srcdir)/src/Actions -I$(top_srcdir)/src/UIElements 208 266 209 267 noinst_LIBRARIES = libmolecuilder.a libgslwrapper.a libmenu.a … … 224 282 molecuilder_SOURCES = ${LEGACYSOURCE} builder.cpp 225 283 molecuilder_SOURCES += $(srcdir)/version.c 226 molecuilder_LDADD = libmolecuilder.a libgslwrapper.a libmenu.a ${BOOST_THREAD_LIB}284 molecuilder_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB} 227 285 228 286 #Stuff for building the GUI using QT … … 231 289 molecuildergui_CXXFLAGS = ${QT_CXXFLAGS} ${GLU_CXXFLAGS} -DUSE_GUI_QT 232 290 molecuildergui_LDFLAGS = $(BOOST_LIB) ${QT_LDFLAGS} ${GLU_LDFLAGS} 233 molecuildergui_LDADD = libmolecuilder.a libgslwrapper.a libmenu.a ${BOOST_THREAD_LIB}${GUI_LIBS}291 molecuildergui_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB} ${GUI_LIBS} 234 292 235 293 joiner_SOURCES = joiner.cpp datacreator.cpp parser.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp -
src/Patterns/Cacheable.hpp
r992fd7 r257c77 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; … … 35 35 return busy; 36 36 } 37 virtual std::string getName()=0; 37 38 protected: 38 39 bool busy; … … 46 47 {} 47 48 48 virtual T getValue(){49 virtual T& getValue(){ 49 50 // set the state to valid 50 51 State::owner->switchState(State::owner->validState); … … 64 65 // nothing to do when entering this 65 66 } 67 68 virtual std::string getName(){ 69 return "invalid"; 70 } 66 71 }; 67 72 … … 72 77 {} 73 78 74 virtual T getValue(){79 virtual T& getValue(){ 75 80 return content; 76 81 } … … 90 95 State::busy = false; 91 96 } 97 98 virtual std::string getName(){ 99 return "valid"; 100 } 92 101 private: 93 102 T content; … … 100 109 {} 101 110 102 virtual T getValue(){111 virtual T& getValue(){ 103 112 ASSERT(0,"Cannot get a value from a Cacheable after it's Observable has died"); 104 113 // we have to return a grossly invalid reference, because no value can be produced anymore … … 118 127 // nothing to do when entering this state 119 128 } 129 130 virtual std::string getName(){ 131 return "destroyed"; 132 } 120 133 }; 121 134 … … 124 137 125 138 public: 126 Cacheable(Observable *_owner, boost::function<T()> _recalcMethod );139 Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name); 127 140 virtual ~Cacheable(); 128 141 … … 134 147 void subjectKilled(Observable *subject); 135 148 private: 136 137 149 void switchState(state_ptr newState); 138 150 … … 144 156 145 157 Observable *owner; 146 147 158 boost::function<T()> recalcMethod; 148 159 … … 153 164 154 165 template<typename T> 155 Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod) : 166 Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name) : 167 Observer(name + "(Cached)"), 156 168 owner(_owner), 157 169 recalcMethod(_recalcMethod) … … 208 220 void Cacheable<T>::switchState(state_ptr newState){ 209 221 ASSERT(!state->isBusy(),"LOOP DETECTED: Cacheable state switched while recalculating.\nDid the recalculation trigger the Observable?"); 222 #ifdef LOG_OBSERVER 223 observerLog().addMessage() << "## Cacheable " << observerLog().getName(this) << " changed state (" << state->getName() 224 << "->" << newState->getName() << ")" << std::endl; 225 #endif 210 226 state = newState; 211 227 state->enter(); … … 217 233 { 218 234 public: 219 Cacheable(Observable *_owner, boost::function<T()> _recalcMethod );235 Cacheable(Observable *_owner, boost::function<T()> _recalcMethod,std::string name); 220 236 virtual ~Cacheable(); 221 237 … … 232 248 233 249 template<typename T> 234 Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod) : 250 Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name) : 251 Observer(name), 235 252 recalcMethod(_recalcMethod) 236 253 {} -
src/Patterns/Observer.cpp
r992fd7 r257c77 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "Observer.hpp" 9 11 … … 12 14 13 15 #include "Helpers/Assert.hpp" 16 #include "Helpers/MemDebug.hpp" 14 17 15 18 using namespace std; … … 43 46 // if no entry for this observable is found, an new one is created 44 47 // by the STL and initialized to 0 (see STL documentation) 48 #ifdef LOG_OBSERVER 49 observerLog().addMessage(depth[publisher]) << ">> Locking " << observerLog().getName(publisher) << endl; 50 #endif 45 51 depth[publisher]++; 46 52 } … … 60 66 // if zero is reached all observed blocks are done and we can 61 67 // start to notify our observers 62 if(--(depth[publisher])){} 68 --depth[publisher]; 69 #ifdef LOG_OBSERVER 70 observerLog().addMessage(depth[publisher]) << "<< Unlocking " << observerLog().getName(publisher) << endl; 71 #endif 72 if(depth[publisher]){} 63 73 else{ 64 74 publisher->notifyAll(); … … 82 92 Observable::_Observable_protector::_Observable_protector(Observable *_protege) : 83 93 protege(_protege) 94 { 95 start_observer_internal(protege); 96 } 97 98 Observable::_Observable_protector::_Observable_protector(const _Observable_protector &dest) : 99 protege(dest.protege) 84 100 { 85 101 start_observer_internal(protege); … … 117 133 callees_t::iterator iter; 118 134 for(iter=callees.begin();iter!=callees.end();++iter){ 135 #ifdef LOG_OBSERVER 136 observerLog().addMessage() << "-> Sending update from " << observerLog().getName(this) 137 << " to " << observerLog().getName((*iter).second) 138 << " (priority=" << (*iter).first << ")"<< endl; 139 #endif 119 140 (*iter).second->update(this); 120 141 } … … 159 180 // we do not need to publish all the changes at each time we are called 160 181 if(depth.find(this)==depth.end()) { 182 #ifdef LOG_OBSERVER 183 observerLog().addMessage() << "-* Update from " << observerLog().getName(publisher) 184 << " propagated by " << observerLog().getName(this) << endl; 185 #endif 161 186 notifyAll(); 187 } 188 else{ 189 #ifdef LOG_OBSERVER 190 observerLog().addMessage() << "-| Update from " << observerLog().getName(publisher) 191 << " not propagated by " << observerLog().getName(this) << endl; 192 #endif 162 193 } 163 194 } … … 171 202 void Observable::signOn(Observer *target,int priority) { 172 203 ASSERT(priority>=-20 && priority<=+20, "Priority out of range [-20:+20] when signing on Observer"); 204 #ifdef LOG_OBSERVER 205 observerLog().addMessage() << "@@ Signing on " << observerLog().getName(target) << " to " << observerLog().getName(this) << endl; 206 #endif 173 207 bool res = false; 174 208 callees_t &callees = callTable[this]; … … 188 222 void Observable::signOff(Observer *target) { 189 223 ASSERT(callTable.count(this),"SignOff called for an Observable without Observers."); 224 #ifdef LOG_OBSERVER 225 observerLog().addMessage() << "** Signing off " << observerLog().getName(target) << " from " << observerLog().getName(this) << endl; 226 #endif 190 227 callees_t &callees = callTable[this]; 228 191 229 callees_t::iterator iter; 192 230 callees_t::iterator deliter; … … 231 269 /** Constructor for class Observable. 232 270 */ 233 Observable::Observable() 234 {} 271 Observable::Observable(string name) : 272 Observer(Observer::BaseConstructor()) 273 { 274 #ifdef LOG_OBSERVER 275 observerLog().addName(this,name); 276 observerLog().addMessage() << "++ Creating Observable " << observerLog().getName(this) << endl; 277 #endif 278 } 235 279 236 280 /** Destructor for class Observable. … … 239 283 Observable::~Observable() 240 284 { 285 #ifdef LOG_OBSERVER 286 observerLog().addMessage() << "-- Destroying Observable " << observerLog().getName(this) << endl; 287 #endif 241 288 if(callTable.count(this)) { 242 289 // delete all entries for this observable … … 252 299 /** Constructor for class Observer. 253 300 */ 254 Observer::Observer() 255 {} 301 Observer::Observer(string name) 302 { 303 #ifdef LOG_OBSERVER 304 observerLog().addName(this,name); 305 observerLog().addMessage() << "++ Creating Observer " << observerLog().getName(this) << endl; 306 #endif 307 } 308 309 /** 310 * Base Constructor for class Observer 311 * 312 * only called from Observable Constructor 313 */ 314 Observer::Observer(Observer::BaseConstructor){ 315 #ifdef LOG_OBSERVER 316 observerLog().addObservable(this); 317 #endif 318 } 256 319 257 320 /** Destructor for class Observer. 258 321 */ 259 322 Observer::~Observer() 260 {} 323 { 324 #ifdef LOG_OBSERVER 325 if(!observerLog().isObservable(this)){ 326 observerLog().addMessage() << "-- Destroying Observer " << observerLog().getName(this) << endl; 327 } 328 #endif 329 } 261 330 262 331 /** … … 289 358 } 290 359 } 360 361 #ifdef LOG_OBSERVER 362 363 /************************* Methods to do logging of the Observer Mechanism *********/ 364 365 // The log needs to exist fairly early, so we make it construct on first use, 366 // and never destroy it 367 ObserverLog &observerLog(){ 368 // yes, this memory is never freed... we need it around for the whole programm, 369 // so no freeing is possible 370 static ObserverLog *theLog = Memory::ignore(new ObserverLog()); 371 return *theLog; 372 } 373 374 375 ObserverLog::ObserverLog() : 376 count (0) 377 {} 378 379 ObserverLog::~ObserverLog(){} 380 381 string ObserverLog::getLog(){return log.str();} 382 383 std::string ObserverLog::getName(void* obj){ 384 return names[obj]; 385 } 386 387 bool ObserverLog::isObservable(void* obj){ 388 return observables.count(obj); 389 } 390 391 void ObserverLog::addName(void* obj , string name){ 392 stringstream sstr; 393 sstr << name << "_" << count++; 394 names[obj] = sstr.str(); 395 } 396 397 void ObserverLog::addObservable(void* obj){ 398 observables.insert(obj); 399 } 400 401 void ObserverLog::deleteName(void* obj){ 402 names.erase(obj); 403 } 404 405 void ObserverLog::deleteObservable(void* obj){ 406 observables.erase(obj); 407 } 408 409 stringstream &ObserverLog::addMessage(int depth){ 410 for(int i=depth;i--;) 411 log << " "; 412 return log; 413 } 414 415 #endif -
src/Patterns/Observer.hpp
r992fd7 r257c77 11 11 #include <map> 12 12 #include <set> 13 #include <string> 14 #include <sstream> 13 15 14 16 /** … … 28 30 */ 29 31 32 // Deactivate any logging when we are not in debug mode 33 #ifdef NDEBUG 34 #undef LOG_OBSERVER 35 #endif 36 30 37 class Observable; 31 38 class Notification; … … 35 42 // identification process 36 43 typedef Notification *const Notification_ptr; 44 45 template<class _Set> 46 class ObservedIterator; 37 47 38 48 /** … … 53 63 friend class Observable; 54 64 friend class Notification; 55 public: 56 Observer(); 65 template<class> friend class ObservedIterator; 66 67 // indicates the constructor called from Observables 68 struct BaseConstructor{}; 69 70 public: 71 Observer(BaseConstructor); 72 Observer(std::string); 57 73 virtual ~Observer(); 58 74 … … 86 102 class Observable : public Observer { 87 103 public: 88 Observable( );104 Observable(std::string _name); 89 105 virtual ~Observable(); 90 106 … … 152 168 static std::set<Observable*> busyObservables; 153 169 154 155 170 //! @cond 156 171 // Structure for RAII-Style notification … … 164 179 public: 165 180 _Observable_protector(Observable *); 181 _Observable_protector(const _Observable_protector&); 166 182 ~_Observable_protector(); 167 183 private: … … 187 203 }; 188 204 205 #ifdef LOG_OBSERVER 206 207 /** 208 * This class is used to log the working of the observer mechanism 209 * 210 * TODO: make this conditional dependent on compiler Flag. 211 */ 212 class ObserverLog{ 213 friend class Observable; 214 friend class Observer; 215 template <typename> friend class Cacheable; 216 public: 217 ObserverLog(); 218 ~ObserverLog(); 219 std::string getLog(); // get everything that has been logged 220 std::string getName(void*); // get the name of an actor 221 bool isObservable(void*); 222 private: 223 int count; // number to reference each actor in this framework 224 std::map<void*,std::string> names; // List of names assigned to actors 225 std::set<void*> observables; // List of pointers to Observables. Needed to distinguish Observers and Observables 226 void addName(void*, std::string); // Assign a name to an Actor 227 void addObservable(void*); 228 void deleteName(void*); // delete the name of an Actor 229 void deleteObservable(void*); 230 std::stringstream &addMessage(int depth=0); // Add a Message to the logging 231 std::stringstream log; // The internal log object 232 }; 233 234 ObserverLog &observerLog(); 235 236 #endif 237 189 238 // extra macro is necessary to work with __LINE__ 190 239 #define PASTE(a,b) PASTE_HELPER(a,b) -
src/Plane.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Plane.hpp" -
src/Space.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Space.hpp" -
src/UIElements/Dialog.cpp
r992fd7 r257c77 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include <cassert> 9 11 10 #include "UIElements/Dialog.hpp" 11 12 #include "Dialog.hpp" 13 14 #include "atom.hpp" 15 #include "element.hpp" 16 #include "molecule.hpp" 12 17 #include "vector.hpp" 13 18 … … 46 51 retval &= (*iter)->handle(); 47 52 // if any query fails (is canceled), we can end the handling process 48 if(!retval) 53 if(!retval) { 54 DoeLog(1) && (eLog() << Verbose(1) << "The following query failed: " << (**iter).getTitle() << "." << endl); 49 55 break; 56 } 50 57 } 51 58 return retval; … … 62 69 63 70 // Base class 64 Dialog::Query::Query(string _title) : 65 title(_title) 71 Dialog::Query::Query(string _title, string _description) : 72 title(_title), 73 description(_description) 66 74 {} 67 75 … … 72 80 } 73 81 82 const std::string Dialog::Query::getDescription() const{ 83 return description; 84 } 85 // empty Queries 86 87 Dialog::EmptyQuery::EmptyQuery(string title, std::string description) : 88 Query(title, description) 89 {} 90 91 Dialog::EmptyQuery::~EmptyQuery() {} 92 93 void Dialog::EmptyQuery::setResult() { 94 } 95 74 96 // Int Queries 75 97 76 Dialog::IntQuery::IntQuery(string title,int *_target ) :77 Query(title ), target(_target)98 Dialog::IntQuery::IntQuery(string title,int *_target, std::string description) : 99 Query(title, description), target(_target) 78 100 {} 79 101 … … 84 106 } 85 107 108 // Int Queries 109 110 Dialog::BooleanQuery::BooleanQuery(string title,bool *_target, std::string description) : 111 Query(title, description), target(_target) 112 {} 113 114 Dialog::BooleanQuery::~BooleanQuery() {} 115 116 void Dialog::BooleanQuery::setResult() { 117 *target = tmp; 118 } 119 86 120 // String Queries 87 121 88 Dialog::StringQuery::StringQuery(string title,string *_target) : 89 Query(title), 90 target(_target), 91 tmp("") 122 Dialog::StringQuery::StringQuery(string title,string *_target, std::string _description) : 123 Query(title, _description), target(_target) 92 124 {} 93 125 … … 100 132 // Double Queries 101 133 102 Dialog::DoubleQuery::DoubleQuery(string title,double *_target ) :103 Query(title ), target(_target)134 Dialog::DoubleQuery::DoubleQuery(string title,double *_target, std::string _description) : 135 Query(title, _description), target(_target) 104 136 {} 105 137 … … 111 143 112 144 145 // Atom Queries 146 147 Dialog::AtomQuery::AtomQuery(string title, atom **_target, std::string _description) : 148 Query(title, _description), 149 tmp(0), 150 target(_target) 151 152 {} 153 154 Dialog::AtomQuery::~AtomQuery() {} 155 156 void Dialog::AtomQuery::setResult() { 157 *target = tmp; 158 } 159 113 160 // Molecule Queries 114 161 115 Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, MoleculeListClass *_molecules) :116 Query(title ),162 Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, std::string _description) : 163 Query(title, _description), 117 164 tmp(0), 118 molecules(_molecules),119 165 target(_target) 120 166 … … 129 175 // Vector Queries 130 176 131 Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check ) :132 Query(title ),177 Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description) : 178 Query(title, _description), 133 179 cellSize(_cellSize), 134 180 check(_check), 135 181 target(_target) 136 182 { 137 tmp = new Vector();183 tmp = new Vector(); 138 184 } 139 185 … … 147 193 } 148 194 195 // Box Queries 196 197 Dialog::BoxQuery::BoxQuery(std::string title, double ** const _cellSize, std::string _description) : 198 Query(title, _description), 199 target(_cellSize) 200 { 201 tmp = new double[6]; 202 } 203 204 Dialog::BoxQuery::~BoxQuery() 205 { 206 delete[] tmp; 207 } 208 209 void Dialog::BoxQuery::setResult() { 210 for (int i=0;i<6;i++) { 211 (*target)[i] = tmp[i]; 212 } 213 } 214 149 215 // Element Queries 150 Dialog::ElementQuery::ElementQuery(std::string title, const element **_target) : 151 Query(title), 152 tmp(0), 216 Dialog::ElementQuery::ElementQuery(std::string title, std::vector<element *> *_target, std::string _description) : 217 Query(title, _description), 153 218 target(_target) 154 219 {} … … 157 222 158 223 void Dialog::ElementQuery::setResult(){ 159 *target= tmp;160 } 224 *target=elements; 225 } -
src/UIElements/Dialog.hpp
r992fd7 r257c77 11 11 #include<string> 12 12 #include<list> 13 #include<vector> 13 14 14 class MoleculeListClass; 15 class atom; 16 class element; 15 17 class molecule; 16 18 class Vector; 17 class element;18 19 19 20 class Dialog … … 23 24 virtual ~Dialog(); 24 25 25 virtual void queryInt(const char *, int *)=0; 26 virtual void queryDouble(const char*,double *)=0; 27 virtual void queryString(const char*, std::string *)=0; 28 virtual void queryMolecule(const char*,molecule**,MoleculeListClass*)=0; 29 virtual void queryVector(const char*,Vector *,const double *const,bool)=0; 30 virtual void queryElement(const char*,const element **)=0; 26 virtual void queryEmpty(const char *, std::string = "")=0; 27 virtual void queryBoolean(const char *, bool *, std::string = "")=0; 28 virtual void queryInt(const char *, int *, std::string = "")=0; 29 virtual void queryDouble(const char*,double *, std::string = "")=0; 30 virtual void queryString(const char*, std::string *, std::string = "")=0; 31 virtual void queryAtom(const char*,atom**,std::string = "")=0; 32 virtual void queryMolecule(const char*,molecule**, std::string = "")=0; 33 virtual void queryVector(const char*,Vector *,const double *const,bool, std::string = "")=0; 34 virtual void queryBox(const char*,double ** const, std::string = "")=0; 35 virtual void queryElement(const char*, std::vector<element *> *, std::string = "")=0; 31 36 32 37 virtual bool display(); … … 48 53 //base class for all queries 49 54 class Query { 55 friend class Dialog; 50 56 public: 51 Query(std::string _title );57 Query(std::string _title, std::string _description = ""); 52 58 virtual ~Query(); 53 59 virtual bool handle()=0; … … 55 61 protected: 56 62 const std::string getTitle() const; 63 const std::string getDescription() const; 57 64 private: 58 std::string title; 65 std::string title; //!< short title of the query 66 std::string description; //!< longer description for tooltips or for help 67 }; 68 69 // Empty Query is just meant for showing text, such as version, help, initial message or alike 70 class EmptyQuery : public Query { 71 public: 72 EmptyQuery(std::string title, std::string _description = ""); 73 virtual ~EmptyQuery(); 74 virtual bool handle()=0; 75 virtual void setResult(); 59 76 }; 60 77 61 78 //Specialized classes for certain types. GUI-Types are not specialized at this time 79 class BooleanQuery : public Query { 80 public: 81 BooleanQuery(std::string title,bool *_target, std::string _description = ""); 82 virtual ~BooleanQuery(); 83 virtual bool handle()=0; 84 virtual void setResult(); 85 protected: 86 bool tmp; 87 private: 88 bool *target; 89 }; 90 62 91 class IntQuery : public Query { 63 92 public: 64 IntQuery(std::string title,int *_target );93 IntQuery(std::string title,int *_target, std::string _description = ""); 65 94 virtual ~IntQuery(); 66 95 virtual bool handle()=0; … … 74 103 class DoubleQuery : public Query { 75 104 public: 76 DoubleQuery(std::string title,double *_target );105 DoubleQuery(std::string title,double *_target, std::string _description = ""); 77 106 virtual ~DoubleQuery(); 78 107 virtual bool handle()=0; … … 86 115 class StringQuery : public Query { 87 116 public: 88 StringQuery(std::string title,std::string *_target );117 StringQuery(std::string title,std::string *_target, std::string _description = ""); 89 118 virtual ~StringQuery(); 90 119 virtual bool handle()=0; … … 96 125 }; 97 126 98 99 127 class MoleculeQuery : public Query { 100 128 public: 101 MoleculeQuery(std::string title, molecule **_target, MoleculeListClass *_molecules);129 MoleculeQuery(std::string title, molecule **_target, std::string _description = ""); 102 130 virtual ~MoleculeQuery(); 103 131 virtual bool handle()=0; … … 105 133 protected: 106 134 molecule *tmp; 107 MoleculeListClass *molecules;108 135 private: 109 136 molecule **target; 110 137 }; 111 138 139 class AtomQuery : public Query { 140 public: 141 AtomQuery(std::string title, atom **_target, std::string _description = ""); 142 virtual ~AtomQuery(); 143 virtual bool handle()=0; 144 virtual void setResult(); 145 protected: 146 atom *tmp; 147 private: 148 atom **target; 149 }; 150 112 151 class VectorQuery : public Query { 113 152 public: 114 VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check );153 VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = ""); 115 154 virtual ~VectorQuery(); 116 155 virtual bool handle()=0; … … 124 163 }; 125 164 165 class BoxQuery : public Query { 166 public: 167 BoxQuery(std::string title,double ** const _cellSize, std::string _description = ""); 168 virtual ~BoxQuery(); 169 virtual bool handle()=0; 170 virtual void setResult(); 171 protected: 172 double *tmp; 173 private: 174 double **target; 175 }; 176 126 177 class ElementQuery : public Query { 127 178 public: 128 ElementQuery(std::string title, const element**_target);179 ElementQuery(std::string title, std::vector<element *> *_target, std::string _description = ""); 129 180 virtual ~ElementQuery(); 130 181 virtual bool handle()=0; 131 182 virtual void setResult(); 132 183 protected: 133 const element *tmp;184 std::vector<element *> elements; 134 185 private: 135 const element **target;186 std::vector<element *> * const target; 136 187 }; 137 188 … … 143 194 }; 144 195 196 145 197 #endif /* DIALOG_HPP_ */ -
src/UIElements/MainWindow.cpp
r992fd7 r257c77 6 6 */ 7 7 8 #include "UIElements/MainWindow.hpp"9 8 #include "Helpers/MemDebug.hpp" 9 10 #include "MainWindow.hpp" 10 11 11 12 MainWindow::MainWindow() -
src/UIElements/MainWindow.hpp
r992fd7 r257c77 25 25 }; 26 26 27 /**28 * The type of menuPopulators29 */30 typedef void (*MenuMaker)(Menu*,MoleculeListClass*, config*, periodentafel*);31 32 /**33 * This contains all Functions that are used to create the menus.34 * Needs a specific funtion for each menu. All populators will be called35 * by the UIFactory upon creation of the main menu. Thus the actuall construction36 * of the Menus can be kept independent of the concrete type of UI that is being37 * built.38 */39 struct menuPopulaters{40 MenuMaker MakeEditMoleculesMenu;41 };42 27 43 28 #endif /* MAINWINDOW_HPP_ */ -
src/UIElements/QT4/QTDialog.cpp
r992fd7 r257c77 21 21 #include <Qt/qcombobox.h> 22 22 23 #include "Helpers/MemDebug.hpp" 24 23 25 #include "World.hpp" 24 26 #include "periodentafel.hpp" … … 26 28 #include "element.hpp" 27 29 #include "molecule.hpp" 28 #include " Helpers/MemDebug.hpp"30 #include "Descriptors/MoleculeIdDescriptor.hpp" 29 31 30 32 … … 76 78 /************************** Query Infrastructure ************************/ 77 79 78 void QTDialog::queryInt(const char *title, int *target) 80 void QTDialog::queryEmpty(char const*, string){ 81 // TODO 82 ASSERT(false, "Not implemented yet"); 83 } 84 85 void QTDialog::queryBoolean(char const*, bool*,string){ 86 // TODO 87 ASSERT(false, "Not implemented yet"); 88 } 89 90 void QTDialog::queryAtom(char const*, atom**, string){ 91 // TODO 92 ASSERT(false, "Not implemented yet"); 93 } 94 95 void QTDialog::queryBox(char const*, double**, string){ 96 // TODO 97 ASSERT(false, "Not implemented yet"); 98 } 99 100 101 void QTDialog::queryInt(const char *title, int *target,string) 79 102 { 80 103 registerQuery(new IntQTQuery(title,target,inputLayout,this)); 81 104 } 82 105 83 void QTDialog::queryDouble(const char* title, double* target ){106 void QTDialog::queryDouble(const char* title, double* target,string){ 84 107 registerQuery(new DoubleQTQuery(title,target,inputLayout,this)); 85 108 } 86 109 87 void QTDialog::queryString(const char* title, std::string *target )110 void QTDialog::queryString(const char* title, std::string *target,string) 88 111 { 89 112 registerQuery(new StringQTQuery(title,target,inputLayout,this)); 90 113 } 91 114 92 void QTDialog::queryMolecule(const char *title,molecule **target, MoleculeListClass *molecules)93 { 94 registerQuery(new MoleculeQTQuery(title,target, molecules,inputLayout,this));95 } 96 97 void QTDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check ) {115 void QTDialog::queryMolecule(const char *title,molecule **target,string) 116 { 117 registerQuery(new MoleculeQTQuery(title,target,inputLayout,this)); 118 } 119 120 void QTDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check,string) { 98 121 registerQuery(new VectorQTQuery(title,target,cellSize,check,inputLayout,this)); 99 122 } 100 123 101 void QTDialog::queryElement(const char* title, const element **target){124 void QTDialog::queryElement(const char* title, std::vector<element *> *target,string){ 102 125 registerQuery(new ElementQTQuery(title,target,inputLayout,this)); 103 126 } … … 189 212 } 190 213 191 QTDialog::MoleculeQTQuery::MoleculeQTQuery(string _title, molecule **_target, MoleculeListClass *_molecules, QBoxLayout *_parent,QTDialog *_dialog) : 192 Dialog::MoleculeQuery(_title,_target,_molecules), 193 parent(_parent) 194 { 195 MoleculeList::iterator iter; 214 QTDialog::MoleculeQTQuery::MoleculeQTQuery(string _title, molecule **_target, QBoxLayout *_parent,QTDialog *_dialog) : 215 Dialog::MoleculeQuery(_title,_target), 216 parent(_parent) 217 { 196 218 thisLayout = new QHBoxLayout(); 197 219 titleLabel = new QLabel(QString(getTitle().c_str())); 198 220 inputBox = new QComboBox(); 199 221 // add all molecules to the combo box 200 for(iter = molecules->ListOfMolecules.begin(); 201 iter != molecules->ListOfMolecules.end(); 222 vector<molecule*> molecules = World::getInstance().getAllMolecules(); 223 for(vector<molecule*>::iterator iter = molecules.begin(); 224 iter != molecules.end(); 202 225 ++iter) { 203 226 stringstream sstr; … … 209 232 thisLayout->addWidget(inputBox); 210 233 211 pipe = new MoleculeQTQueryPipe(&tmp,_dialog,inputBox ,_molecules);234 pipe = new MoleculeQTQueryPipe(&tmp,_dialog,inputBox); 212 235 pipe->update(inputBox->currentIndex()); 213 236 connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); … … 263 286 264 287 265 QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, const element **_target, QBoxLayout *_parent, QTDialog *_dialog) :288 QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, vector<element *> *_target, QBoxLayout *_parent, QTDialog *_dialog) : 266 289 Dialog::ElementQuery(_title,_target), 267 290 parent(_parent) … … 283 306 thisLayout->addWidget(inputBox); 284 307 285 pipe = new ElementQTQueryPipe(& tmp,_dialog,inputBox);308 pipe = new ElementQTQueryPipe(&elements,_dialog,inputBox); 286 309 pipe->update(inputBox->currentIndex()); 287 310 connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); … … 338 361 } 339 362 340 MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox , MoleculeListClass *_molecules) :363 MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox) : 341 364 content(_content), 342 365 dialog(_dialog), 343 theBox(_theBox), 344 molecules(_molecules) 366 theBox(_theBox) 345 367 {} 346 368 … … 351 373 QVariant data = theBox->itemData(newIndex); 352 374 int idx = data.toInt(); 353 (*content) = molecules->ReturnIndex(idx);354 dialog->update(); 355 } 356 357 ElementQTQueryPipe::ElementQTQueryPipe( const element **_content, QTDialog *_dialog, QComboBox *_theBox) :375 (*content) = World::getInstance().getMolecule(MoleculeById(idx)); 376 dialog->update(); 377 } 378 379 ElementQTQueryPipe::ElementQTQueryPipe(std::vector<element *> *_content, QTDialog *_dialog, QComboBox *_theBox) : 358 380 content(_content), 359 381 dialog(_dialog), 360 382 theBox(_theBox) 361 {} 383 { 384 content->resize(1); 385 } 362 386 363 387 ElementQTQueryPipe::~ElementQTQueryPipe() … … 367 391 QVariant data = theBox->itemData(newIndex); 368 392 int idx = data.toInt(); 369 (*content) = World::getInstance().getPeriode()->FindElement(idx);370 dialog->update(); 371 } 372 393 (*content)[0] = World::getInstance().getPeriode()->FindElement(idx); 394 dialog->update(); 395 } 396 -
src/UIElements/QT4/QTDialog.hpp
r992fd7 r257c77 35 35 virtual ~QTDialog(); 36 36 37 virtual void queryInt(const char *, int *); 38 virtual void queryString(const char*, std::string *); 39 virtual void queryDouble(const char*,double *); 40 virtual void queryMolecule(const char*,molecule**,MoleculeListClass*); 41 virtual void queryVector(const char*,Vector *,const double *const,bool); 42 virtual void queryElement(const char*,const element **); 37 virtual void queryEmpty(const char*, std::string); 38 virtual void queryBoolean(const char *, bool *, std::string = ""); 39 virtual void queryInt(const char *, int *,std::string = ""); 40 virtual void queryDouble(const char*,double *,std::string = ""); 41 virtual void queryString(const char*, std::string *,std::string = ""); 42 virtual void queryAtom(const char*,atom**,std::string = ""); 43 virtual void queryMolecule(const char*,molecule**,std::string = ""); 44 virtual void queryVector(const char*,Vector *,const double *const,bool,std::string = ""); 45 virtual void queryBox(const char*,double ** const, std::string = ""); 46 virtual void queryElement(const char*,std::vector<element *> *_target,std::string = ""); 43 47 44 48 virtual bool display(); … … 91 95 class MoleculeQTQuery : public Dialog::MoleculeQuery { 92 96 public: 93 MoleculeQTQuery(std::string _title, molecule **_target, MoleculeListClass *_molecules,QBoxLayout *_parent,QTDialog *_dialog);97 MoleculeQTQuery(std::string _title, molecule **_target, QBoxLayout *_parent,QTDialog *_dialog); 94 98 virtual ~MoleculeQTQuery(); 95 99 virtual bool handle(); … … 122 126 class ElementQTQuery : public Dialog::ElementQuery { 123 127 public: 124 ElementQTQuery(std::string _title, const element **_target, QBoxLayout *_parent, QTDialog *_dialog);128 ElementQTQuery(std::string _title, std::vector<element *> *_target, QBoxLayout *_parent, QTDialog *_dialog); 125 129 virtual ~ElementQTQuery(); 126 130 virtual bool handle(); … … 193 197 Q_OBJECT 194 198 public: 195 MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox , MoleculeListClass *_molecules);199 MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox); 196 200 virtual ~MoleculeQTQueryPipe(); 197 201 … … 201 205 private: 202 206 molecule **content; 203 MoleculeListClass *molecules;204 207 QTDialog *dialog; 205 208 QComboBox *theBox; … … 210 213 Q_OBJECT 211 214 public: 212 ElementQTQueryPipe( const element **_content, QTDialog *_dialog, QComboBox *_theBox);215 ElementQTQueryPipe(std::vector<element *> *_content, QTDialog *_dialog, QComboBox *_theBox); 213 216 virtual ~ElementQTQueryPipe(); 214 217 … … 217 220 218 221 private: 219 const element **content;222 std::vector<element *> *content; 220 223 QTDialog *dialog; 221 224 QComboBox *theBox; -
src/UIElements/QT4/QTMainWindow.cpp
r992fd7 r257c77 29 29 using namespace std; 30 30 31 QTMainWindow::QTMainWindow( menuPopulaters populaters,MoleculeListClass *molecules, config *configuration, periodentafel *periode, char *ConfigFileName,QApplication *_theApp) :31 QTMainWindow::QTMainWindow(QApplication *_theApp) : 32 32 theApp(_theApp) 33 33 { … … 35 35 QSplitter *splitter2 = new QSplitter (Qt::Vertical, splitter1 ); 36 36 37 worldDisplay = new QTWorldView( molecules,splitter2);37 worldDisplay = new QTWorldView(splitter2); 38 38 39 39 moleculeDisplay = new QTMoleculeView(); … … 48 48 statusBar = new QTStatusBar(this); 49 49 setStatusBar(statusBar); 50 51 editMoleculesMenu = new QTMenu("Edit Molecules");52 populaters.MakeEditMoleculesMenu(editMoleculesMenu,molecules,configuration,periode);53 menuBar()->addMenu(editMoleculesMenu);54 50 55 51 connect(worldDisplay,SIGNAL(moleculeSelected(molecule*)),moleculeDisplay,SLOT(moleculeSelected(molecule*))); -
src/UIElements/QT4/QTMainWindow.hpp
r992fd7 r257c77 24 24 25 25 public: 26 QTMainWindow(menuPopulaters populaters,MoleculeListClass *molecules, config *configuration, 27 periodentafel *periode, char *ConfigFileName, QApplication *_theApp); 26 QTMainWindow(QApplication *_theApp); 28 27 virtual ~QTMainWindow(); 29 28 -
src/UIElements/QT4/QTUIFactory.cpp
r992fd7 r257c77 41 41 } 42 42 43 MainWindow* QTUIFactory::makeMainWindow( menuPopulaters populaters,MoleculeListClass *molecules, config *configuration, periodentafel *periode, char *ConfigFileName) {44 return new QTMainWindow( populaters,molecules,configuration,periode,ConfigFileName,app);43 MainWindow* QTUIFactory::makeMainWindow() { 44 return new QTMainWindow(app); 45 45 } 46 46 -
src/UIElements/QT4/QTUIFactory.hpp
r992fd7 r257c77 21 21 22 22 virtual Dialog* makeDialog(); 23 virtual MainWindow* makeMainWindow( menuPopulaters,MoleculeListClass *, config *, periodentafel *, char *);23 virtual MainWindow* makeMainWindow(); 24 24 25 25 struct description : public UIFactory::factoryDescription { -
src/UIElements/UIFactory.cpp
r992fd7 r257c77 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 8 9 9 10 #include <utility> -
src/UIElements/UIFactory.hpp
r992fd7 r257c77 11 11 class MainWindow; 12 12 class Dialog; 13 14 class MoleculeListClass; 15 class config; 16 class periodentafel; 17 18 struct menuPopulaters; 13 class DialogDescription; 19 14 20 15 #include "Patterns/Singleton.hpp" … … 39 34 * Produce some kind of main window, of whichever type was chosen when the factory was created 40 35 */ 41 virtual MainWindow* makeMainWindow( menuPopulaters,MoleculeListClass *, config *, periodentafel *, char *)=0;36 virtual MainWindow* makeMainWindow()=0; 42 37 43 38 /** -
src/World.cpp
r992fd7 r257c77 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "World.hpp" 9 11 10 12 #include "atom.hpp" 13 #include "config.hpp" 11 14 #include "molecule.hpp" 12 15 #include "periodentafel.hpp" … … 27 30 } 28 31 32 config *&World::getConfig(){ 33 return configuration; 34 } 35 29 36 // Atoms 30 37 … … 55 62 } 56 63 64 std::vector<molecule*> World::getAllMolecules(){ 65 return getAllMolecules(AllMolecules()); 66 } 67 57 68 int World::numMolecules(){ 58 69 return molecules_deprecated->ListOfMolecules.size(); … … 70 81 } 71 82 72 char *World::getDefaultName() {83 std::string World::getDefaultName() { 73 84 return defaultName; 74 85 } 75 86 76 void World::setDefaultName( char *name)87 void World::setDefaultName(std::string name) 77 88 { 78 delete[](defaultName); 79 const int length = strlen(name); 80 defaultName = new char[length+2]; 81 if (length < MAXSTRINGSIZE) 82 strncpy(defaultName, name, length); 83 else 84 strcpy(defaultName, "none"); 89 defaultName = name; 85 90 }; 86 91 92 int World::getExitFlag() { 93 return ExitFlag; 94 } 95 96 void World::setExitFlag(int flag) { 97 if (ExitFlag < flag) 98 ExitFlag = flag; 99 } 87 100 88 101 /******************** Methods to change World state *********************/ … … 114 127 115 128 double *World::cell_size = NULL; 116 char *World::defaultName = NULL;117 129 118 130 atom *World::createAtom(){ … … 266 278 267 279 World::World() : 280 Observable("World"), 268 281 periode(new periodentafel), 282 configuration(new config), 283 ExitFlag(0), 269 284 atoms(), 270 285 currAtomId(0), … … 280 295 cell_size[4] = 0.; 281 296 cell_size[5] = 20.; 282 defaultName = new char[MAXSTRINGSIZE]; 283 strcpy(defaultName, "none"); 297 defaultName = "none"; 284 298 molecules_deprecated->signOn(this); 285 299 } … … 289 303 molecules_deprecated->signOff(this); 290 304 delete[] cell_size; 291 delete[] defaultName;292 305 delete molecules_deprecated; 293 306 delete periode; 307 delete configuration; 294 308 MoleculeSet::iterator molIter; 295 309 for(molIter=molecules.begin();molIter!=molecules.end();++molIter){ -
src/World.hpp
r992fd7 r257c77 30 30 31 31 // forward declarations 32 class config; 32 33 class periodentafel; 33 34 class MoleculeListClass; … … 75 76 76 77 /** 78 * returns the configuration for the world. 79 */ 80 config *&getConfig(); 81 82 /** 77 83 * returns the first atom that matches a given descriptor. 78 84 * Do not rely on ordering for descriptors that match more than one atom. … … 109 115 */ 110 116 std::vector<molecule*> getAllMolecules(MoleculeDescriptor descriptor); 117 std::vector<molecule*> getAllMolecules(); 111 118 112 119 /** … … 128 135 * get the default name 129 136 */ 130 char *getDefaultName();137 std::string getDefaultName(); 131 138 132 139 /** 133 140 * set the default name 134 141 */ 135 void setDefaultName(char * name); 142 void setDefaultName(std::string name); 143 144 /* 145 * get the ExitFlag 146 */ 147 int getExitFlag(); 148 149 /* 150 * set the ExitFlag 151 */ 152 void setExitFlag(int flag); 136 153 137 154 /***** Methods to work with the World *****/ … … 234 251 235 252 periodentafel *periode; 253 config *configuration; 236 254 static double *cell_size; 237 static char *defaultName; 255 std::string defaultName; 256 int ExitFlag; 238 257 public: 239 258 AtomSet atoms; -
src/analysis_bonds.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "analysis_bonds.hpp" … … 26 28 Mean = 0.; 27 29 28 atom *Walker = mol->start;29 30 int AtomCount = 0; 30 while (Walker->next != mol->end) { 31 Walker = Walker->next; 32 const int count = Walker->ListOfBonds.size(); 31 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 32 const int count = (*iter)->ListOfBonds.size(); 33 33 if (Max < count) 34 34 Max = count; … … 51 51 * \param &Max maximum distance on return, 0 if no bond between the two elements 52 52 */ 53 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, element *type1,element *type2, double &Min, double &Mean, double &Max)53 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max) 54 54 { 55 55 Min = 2e+6; … … 58 58 59 59 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) { 60 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 61 if ((*iter)->type == type1) 62 for (BondList::const_iterator BondRunner = (*iter)->ListOfBonds.begin(); BondRunner != (*iter)->ListOfBonds.end(); BondRunner++) 63 if ((*BondRunner)->GetOtherAtom((*iter))->type == type2) { 66 64 const double distance = (*BondRunner)->GetDistanceSquared(); 67 65 if (Min > distance) … … 124 122 * \param *InterfaceElement or NULL 125 123 */ 126 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, element * InterfaceElement = NULL) 127 { 128 atom *Walker = NULL; 129 atom *Runner = NULL; 124 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL) 125 { 130 126 int count = 0; 131 127 int OtherHydrogens = 0; … … 133 129 bool InterfaceFlag = false; 134 130 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)) { 131 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); ++MolWalker) { 132 molecule::iterator Walker = (*MolWalker)->begin(); 133 for(;Walker!=(*MolWalker)->end();++Walker){ 134 for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); ++MolRunner) { 135 molecule::iterator Runner = (*MolRunner)->begin(); 136 for(;Runner!=(*MolRunner)->end();++Runner){ 137 if (((*Walker)->type->Z == 8) && ((*Runner)->type->Z == 8)) { 144 138 // check distance 145 const double distance = Runner->x.DistanceSquared(Walker->x);139 const double distance = (*Runner)->x.DistanceSquared((*Walker)->x); 146 140 if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means different atoms 147 141 // on other atom(Runner) we check for bond to interface element and … … 151 145 OtherHydrogens = 0; 152 146 InterfaceFlag = (InterfaceElement == NULL); 153 for (BondList::const_iterator BondRunner = Runner->ListOfBonds.begin(); BondRunner != Runner->ListOfBonds.end(); BondRunner++) {154 atom * const OtherAtom = (*BondRunner)->GetOtherAtom( Runner);147 for (BondList::const_iterator BondRunner = (*Runner)->ListOfBonds.begin(); BondRunner != (*Runner)->ListOfBonds.end(); BondRunner++) { 148 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Runner); 155 149 // if hydrogen, check angle to be greater(!) than 30 degrees 156 150 if (OtherAtom->type->Z == 1) { 157 const double angle = CalculateAngle(&OtherAtom->x, & Runner->x, &Walker->x);151 const double angle = CalculateAngle(&OtherAtom->x, &(*Runner)->x, &(*Walker)->x); 158 152 OtherHydrogenFlag = OtherHydrogenFlag && (angle > M_PI*(30./180.) + MYEPSILON); 159 153 Otherangle += angle; … … 176 170 if (InterfaceFlag && OtherHydrogenFlag) { 177 171 // 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);172 for (BondList::const_iterator BondRunner = (*Walker)->ListOfBonds.begin(); BondRunner != (*Walker)->ListOfBonds.end(); BondRunner++) { 173 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Walker); 180 174 if (OtherAtom->type->Z == 1) { 181 175 // 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);176 if (CheckHydrogenBridgeBondAngle(*Walker, OtherAtom, *Runner)) { 177 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 178 count++; 185 179 break; … … 205 199 int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second) 206 200 { 207 atom *Walker = NULL;208 201 int count = 0; 209 202 210 203 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)) {204 molecule::iterator Walker = (*MolWalker)->begin(); 205 for(;Walker!=(*MolWalker)->end();++Walker){ 206 atom * theAtom = *Walker; 207 if ((theAtom->type == first) || (theAtom->type == second)) { // first element matches 208 for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) { 209 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom); 210 if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (theAtom->nr < OtherAtom->nr)) { 218 211 count++; 219 212 DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl); … … 240 233 bool MatchFlag[2]; 241 234 bool result = false; 242 atom *Walker = NULL;243 235 const element * ElementArray[2]; 244 236 ElementArray[0] = first; … … 246 238 247 239 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 matches240 molecule::iterator Walker = (*MolWalker)->begin(); 241 for(;Walker!=(*MolWalker)->end();++Walker){ 242 atom *theAtom = *Walker; 243 if (theAtom->type == second) { // first element matches 252 244 for (int i=0;i<2;i++) 253 245 MatchFlag[i] = false; 254 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {255 atom * const OtherAtom = (*BondRunner)->GetOtherAtom( Walker);246 for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) { 247 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom); 256 248 for (int i=0;i<2;i++) 257 249 if ((!MatchFlag[i]) && (OtherAtom->type == ElementArray[i])) { -
src/analysis_bonds.hpp
r992fd7 r257c77 31 31 32 32 void GetMaxMinMeanBondCount(const molecule * const mol, double &Min, double &Mean, double &Max); 33 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, element *type1,element *type2, double &Min, double &Mean, double &Max);33 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max); 34 34 35 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, element * InterfaceElement);35 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, const element * InterfaceElement); 36 36 int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second); 37 37 int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third); -
src/analysis_correlation.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <iostream> … … 23 25 /** Calculates the pair correlation between given elements. 24 26 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si)) 25 * \param *out output stream for debugging 26 * \param *molecules list of molecules structure 27 * \param *type1 first element or NULL (if any element) 28 * \param *type2 second element or NULL (if any element) 27 * \param *molecules list of molecules structure 28 * \param &elements vector of elements to correlate 29 29 * \return Map of doubles with values the pair of the two atoms. 30 30 */ 31 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2)31 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements) 32 32 { 33 33 Info FunctionInfo(__func__); 34 34 PairCorrelationMap *outmap = NULL; 35 35 double distance = 0.; 36 double *domain = World::getInstance().getDomain(); 36 37 37 38 if (molecules->ListOfMolecules.empty()) { … … 39 40 return outmap; 40 41 } 42 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 43 (*MolWalker)->doCountAtoms(); 44 45 // create all possible pairs of elements 46 set <pair<element *, element *> > PairsOfElements; 47 if (elements.size() >= 2) { 48 for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1) 49 for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2) 50 if (type1 != type2) { 51 PairsOfElements.insert( pair<element *, element*>(*type1,*type2) ); 52 DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl); 53 } 54 } else if (elements.size() == 1) { // one to all are valid 55 element *elemental = *elements.begin(); 56 PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) ); 57 PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) ); 58 } else { // all elements valid 59 PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) ); 60 } 61 41 62 outmap = new PairCorrelationMap; 42 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 63 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){ 43 64 if ((*MolWalker)->ActiveFlag) { 44 65 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++) 51 if ((*MolOtherWalker)->ActiveFlag) { 52 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) ) ); 66 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 67 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 68 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 69 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){ 70 if ((*MolOtherWalker)->ActiveFlag) { 71 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 72 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 73 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 74 if ((*iter)->getId() < (*runner)->getId()){ 75 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 76 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 77 distance = (*iter)->node->PeriodicDistance(*(*runner)->node, domain); 78 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 79 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); 62 80 } 63 81 } 82 } 64 83 } 65 84 } 66 85 } 67 86 } 68 87 } 69 88 return outmap; 70 89 }; … … 72 91 /** Calculates the pair correlation between given elements. 73 92 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si)) 74 * \param *out output stream for debugging 75 * \param *molecules list of molecules structure 76 * \param *type1 first element or NULL (if any element) 77 * \param *type2 second element or NULL (if any element) 93 * \param *molecules list of molecules structure 94 * \param &elements vector of elements to correlate 78 95 * \param ranges[NDIM] interval boundaries for the periodic images to scan also 79 96 * \return Map of doubles with values the pair of the two atoms. 80 97 */ 81 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2, const int ranges[NDIM] )98 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] ) 82 99 { 83 100 Info FunctionInfo(__func__); … … 95 112 return outmap; 96 113 } 114 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 115 (*MolWalker)->doCountAtoms(); 116 117 // create all possible pairs of elements 118 set <pair<element *, element *> > PairsOfElements; 119 if (elements.size() >= 2) { 120 for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1) 121 for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2) 122 if (type1 != type2) { 123 PairsOfElements.insert( pair<element *, element*>(*type1,*type2) ); 124 DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl); 125 } 126 } else if (elements.size() == 1) { // one to all are valid 127 element *elemental = *elements.begin(); 128 PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) ); 129 PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) ); 130 } else { // all elements valid 131 PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) ); 132 } 133 97 134 outmap = new PairCorrelationMap; 98 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 135 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){ 99 136 if ((*MolWalker)->ActiveFlag) { 100 137 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 101 138 double * FullInverseMatrix = InverseMatrix(FullMatrix); 102 139 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); 109 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 110 // go through every range in xyz and get distance 111 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 112 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 113 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 114 checkX = Vector(n[0], n[1], n[2]) + periodicX; 115 checkX.MatrixMultiplication(FullMatrix); 116 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++) 117 if ((*MolOtherWalker)->ActiveFlag) { 118 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); 140 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 141 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 142 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 143 periodicX = *(*iter)->node; 144 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 145 // go through every range in xyz and get distance 146 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 147 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 148 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 149 checkX = Vector(n[0], n[1], n[2]) + periodicX; 150 checkX.MatrixMultiplication(FullMatrix); 151 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){ 152 if ((*MolOtherWalker)->ActiveFlag) { 153 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 154 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 155 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 156 if ((*iter)->getId() < (*runner)->getId()){ 157 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 158 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 159 periodicOtherX = *(*runner)->node; 126 160 periodicOtherX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 127 161 // go through every range in xyz and get distance … … 132 166 checkOtherX.MatrixMultiplication(FullMatrix); 133 167 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) ) );168 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 169 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); 136 170 } 137 171 } 172 } 138 173 } 174 } 139 175 } 140 176 } 141 142 }143 Free(&FullMatrix);144 Free(&FullInverseMatrix);145 177 } 178 delete[](FullMatrix); 179 delete[](FullInverseMatrix); 180 } 181 } 146 182 147 183 return outmap; … … 149 185 150 186 /** Calculates the distance (pair) correlation between a given element and a point. 151 * \param *out output stream for debugging 152 * \param *molecules list of molecules structure 153 * \param *type element or NULL (if any element) 187 * \param *molecules list of molecules structure 188 * \param &elements vector of elements to correlate with point 154 189 * \param *point vector to the correlation point 155 190 * \return Map of dobules with values as pairs of atom and the vector 156 191 */ 157 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point )192 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point ) 158 193 { 159 194 Info FunctionInfo(__func__); 160 195 CorrelationToPointMap *outmap = NULL; 161 196 double distance = 0.; 197 double *cell_size = World::getInstance().getDomain(); 162 198 163 199 if (molecules->ListOfMolecules.empty()) { … … 165 201 return outmap; 166 202 } 203 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 204 (*MolWalker)->doCountAtoms(); 167 205 outmap = new CorrelationToPointMap; 168 206 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 169 207 if ((*MolWalker)->ActiveFlag) { 170 208 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()); 177 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) ) ); 179 } 209 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 210 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 211 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 212 if ((*type == NULL) || ((*iter)->type == *type)) { 213 distance = (*iter)->node->PeriodicDistance(*point, cell_size); 214 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 215 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) ); 216 } 180 217 } 181 218 } … … 185 222 186 223 /** Calculates the distance (pair) correlation between a given element, all its periodic images and a point. 187 * \param *out output stream for debugging 188 * \param *molecules list of molecules structure 189 * \param *type element or NULL (if any element) 224 * \param *molecules list of molecules structure 225 * \param &elements vector of elements to correlate to point 190 226 * \param *point vector to the correlation point 191 227 * \param ranges[NDIM] interval boundaries for the periodic images to scan also 192 228 * \return Map of dobules with values as pairs of atom and the vector 193 229 */ 194 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] )230 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] ) 195 231 { 196 232 Info FunctionInfo(__func__); … … 205 241 return outmap; 206 242 } 243 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 244 (*MolWalker)->doCountAtoms(); 207 245 outmap = new CorrelationToPointMap; 208 246 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) … … 211 249 double * FullInverseMatrix = InverseMatrix(FullMatrix); 212 250 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); 219 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 220 // go through every range in xyz and get distance 221 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 222 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 223 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 224 checkX = Vector(n[0], n[1], n[2]) + periodicX; 225 checkX.MatrixMultiplication(FullMatrix); 226 distance = checkX.distance(*point); 227 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) ) ); 229 } 230 } 231 } 232 Free(&FullMatrix); 233 Free(&FullInverseMatrix); 251 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 252 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 253 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 254 if ((*type == NULL) || ((*iter)->type == *type)) { 255 periodicX = *(*iter)->node; 256 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 257 // go through every range in xyz and get distance 258 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 259 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 260 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 261 checkX = Vector(n[0], n[1], n[2]) + periodicX; 262 checkX.MatrixMultiplication(FullMatrix); 263 distance = checkX.distance(*point); 264 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 265 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) ); 266 } 267 } 268 } 269 delete[](FullMatrix); 270 delete[](FullInverseMatrix); 234 271 } 235 272 … … 238 275 239 276 /** Calculates the distance (pair) correlation between a given element and a surface. 240 * \param *out output stream for debugging 241 * \param *molecules list of molecules structure 242 * \param *type element or NULL (if any element) 277 * \param *molecules list of molecules structure 278 * \param &elements vector of elements to correlate to surface 243 279 * \param *Surface pointer to Tesselation class surface 244 280 * \param *LC LinkedCell structure to quickly find neighbouring atoms 245 281 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 246 282 */ 247 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC )283 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC ) 248 284 { 249 285 Info FunctionInfo(__func__); … … 257 293 return outmap; 258 294 } 295 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 296 (*MolWalker)->doCountAtoms(); 259 297 outmap = new CorrelationToSurfaceMap; 260 298 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 261 299 if ((*MolWalker)->ActiveFlag) { 262 300 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); 269 distance = Intersections.GetSmallestDistance(); 270 triangle = Intersections.GetClosestTriangle(); 271 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) ); 272 } 273 } 274 } else 301 if ((*MolWalker)->empty()) 302 DoLog(1) && (1) && (Log() << Verbose(1) << "\t is empty." << endl); 303 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 304 DoLog(1) && (Log() << Verbose(1) << "\tCurrent atom is " << *(*iter) << "." << endl); 305 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 306 if ((*type == NULL) || ((*iter)->type == *type)) { 307 TriangleIntersectionList Intersections((*iter)->node,Surface,LC); 308 distance = Intersections.GetSmallestDistance(); 309 triangle = Intersections.GetClosestTriangle(); 310 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) ); 311 } 312 } 313 } else { 275 314 DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl); 315 } 276 316 277 317 return outmap; … … 283 323 * axis an integer from [ -ranges[i], ranges[i] ] onto it and multiply with the domain matrix to bring it back into 284 324 * the real space. Then, we Tesselation::FindClosestTriangleToPoint() and DistanceToTrianglePlane(). 285 * \param *out output stream for debugging 286 * \param *molecules list of molecules structure 287 * \param *type element or NULL (if any element) 325 * \param *molecules list of molecules structure 326 * \param &elements vector of elements to correlate to surface 288 327 * \param *Surface pointer to Tesselation class surface 289 328 * \param *LC LinkedCell structure to quickly find neighbouring atoms … … 291 330 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 292 331 */ 293 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )332 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ) 294 333 { 295 334 Info FunctionInfo(__func__); … … 306 345 return outmap; 307 346 } 347 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 348 (*MolWalker)->doCountAtoms(); 308 349 outmap = new CorrelationToSurfaceMap; 309 350 double ShortestDistance = 0.; … … 314 355 double * FullInverseMatrix = InverseMatrix(FullMatrix); 315 356 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);322 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3323 // go through every range in xyz and get distance324 ShortestDistance = -1.;325 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)326 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)327 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {328 checkX = Vector(n[0], n[1], n[2]) + periodicX;329 checkX.MatrixMultiplication(FullMatrix);330 TriangleIntersectionList Intersections(&checkX,Surface,LC);331 distance = Intersections.GetSmallestDistance();332 triangle = Intersections.GetClosestTriangle();333 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {334 ShortestDistance = distance;335 ShortestTriangle = triangle;357 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 358 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 359 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 360 if ((*type == NULL) || ((*iter)->type == *type)) { 361 periodicX = *(*iter)->node; 362 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 363 // go through every range in xyz and get distance 364 ShortestDistance = -1.; 365 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 366 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 367 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 368 checkX = Vector(n[0], n[1], n[2]) + periodicX; 369 checkX.MatrixMultiplication(FullMatrix); 370 TriangleIntersectionList Intersections(&checkX,Surface,LC); 371 distance = Intersections.GetSmallestDistance(); 372 triangle = Intersections.GetClosestTriangle(); 373 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) { 374 ShortestDistance = distance; 375 ShortestTriangle = triangle; 376 } 336 377 } 337 } 338 // insert 339 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) ); 340 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; 341 } 342 } 343 Free(&FullMatrix); 344 Free(&FullInverseMatrix); 378 // insert 379 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) ); 380 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; 381 } 382 } 383 delete[](FullMatrix); 384 delete[](FullInverseMatrix); 345 385 } 346 386 -
src/analysis_correlation.hpp
r992fd7 r257c77 45 45 /********************************************** declarations *******************************/ 46 46 47 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2);48 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point );49 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC );50 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2, const int ranges[NDIM] );51 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] );52 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );47 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements); 48 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point ); 49 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC ); 50 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] ); 51 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] ); 52 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ); 53 53 int GetBin ( const double value, const double BinWidth, const double BinStart ); 54 54 void OutputCorrelation( ofstream * const file, const BinPairMap * const map ); -
src/analyzer.cpp
r992fd7 r257c77 7 7 8 8 //============================ INCLUDES =========================== 9 10 #include "Helpers/MemDebug.hpp" 9 11 10 12 #include <cstring> … … 75 77 return 1; 76 78 } else { 77 dir = Malloc<char>(strlen(argv[2]) + 2, "main: *dir");79 dir = new char[strlen(argv[2]) + 2]; 78 80 strcpy(dir, "/"); 79 81 strcat(dir, argv[2]); … … 82 84 if (argc > 4) { 83 85 DoLog(0) && (Log() << Verbose(0) << "Loading periodentafel." << endl); 84 periode = Malloc<periodentafel>(1, "main - periode");86 periode = new periodentafel; 85 87 periode->LoadPeriodentafel(argv[4]); 86 88 } … … 558 560 // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++ 559 561 delete(periode); 560 Free(&dir);562 delete[](dir); 561 563 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 562 564 return 0; -
src/atom.cpp
r992fd7 r257c77 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 #include "atom.hpp" … … 14 16 #include "vector.hpp" 15 17 #include "World.hpp" 18 #include "molecule.hpp" 16 19 17 20 /************************************* Functions for class atom *************************************/ … … 21 24 */ 22 25 atom::atom() : 23 previous(NULL), next(NULL), father(this), sort(&nr)26 father(this), sort(&nr), mol(0) 24 27 { 25 28 node = &x; // TesselPoint::x can only be referenced from here … … 29 32 */ 30 33 atom::atom(atom *pointer) : 31 ParticleInfo(pointer), 32 previous(NULL), next(NULL), father(pointer), sort(&nr) 34 ParticleInfo(pointer),father(pointer), sort(&nr) 33 35 { 34 36 type = pointer->type; // copy element of atom … … 37 39 FixedIon = pointer->FixedIon; 38 40 node = &x; 41 mol = 0; 39 42 }; 40 43 41 44 atom *atom::clone(){ 42 45 atom *res = new atom(this); 43 res->previous=0;44 res->next=0;45 46 res->father = this; 46 47 res->sort = &res->nr; … … 50 51 res->FixedIon = FixedIon; 51 52 res->node = &x; 53 res->mol = 0; 52 54 World::getInstance().registerAtom(res); 53 55 return res; … … 59 61 atom::~atom() 60 62 { 61 unlink(this); 63 removeFromMolecule(); 64 for(BondList::iterator iter=ListOfBonds.begin(); iter!=ListOfBonds.end();){ 65 // deleting the bond will invalidate the iterator !!! 66 bond *bond =*(iter++); 67 delete(bond); 68 } 62 69 }; 63 70 … … 272 279 { 273 280 if (ComponentNr != NULL) 274 Free(&ComponentNr);275 ComponentNr = Malloc<int>(ListOfBonds.size()+1, "atom::InitComponentNumbers: *ComponentNr");281 delete[](ComponentNr); 282 ComponentNr = new int[ListOfBonds.size()+1]; 276 283 for (int i=ListOfBonds.size()+1;i--;) 277 284 ComponentNr[i] = -1; … … 312 319 } 313 320 321 void atom::setMolecule(molecule *_mol){ 322 // take this atom from the old molecule 323 removeFromMolecule(); 324 mol = _mol; 325 if(!mol->containsAtom(this)){ 326 mol->AddAtom(this); 327 } 328 } 329 330 void atom::removeFromMolecule(){ 331 if(mol){ 332 if(mol->containsAtom(this)){ 333 mol->erase(this); 334 } 335 mol=0; 336 } 337 } 338 339 314 340 atom* NewAtom(atomId_t _id){ 315 341 atom * res =new atom(); -
src/atom.hpp
r992fd7 r257c77 34 34 class Vector; 35 35 class World; 36 class molecule; 36 37 37 38 /********************************************** declarations *******************************/ … … 44 45 friend void DeleteAtom(atom*); 45 46 public: 46 atom *previous; //!< previous atom in molecule list47 atom *next; //!< next atom in molecule list48 47 atom *father; //!< In many-body bond order fragmentations points to originating atom 49 48 int *sort; //!< sort criteria … … 89 88 virtual void setId(atomId_t); 90 89 90 void setMolecule(molecule*); 91 void removeFromMolecule(); 92 91 93 protected: 94 92 95 /** 93 96 * Protected constructor to ensure construction of atoms through the world. … … 108 111 virtual ~atom(); 109 112 private: 113 molecule *mol; // !< the molecule this atom belongs to 110 114 World* world; 111 115 atomId_t id; -
src/atom_atominfo.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "periodentafel.hpp" -
src/atom_bondedparticle.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom.hpp" … … 74 76 *BondFile << nr << "\t" << (*Runner)->GetOtherAtom(this)->nr << "\n"; 75 77 }; 78 79 /** 80 * Adds a bond between this bonded particle and another. Does nothing if this 81 * bond already exists. 82 * 83 * \param bonding partner 84 */ 85 void BondedParticle::addBond(BondedParticle* Partner) { 86 if (IsBondedTo(Partner)) { 87 return; 88 } 89 90 bond* newBond = new bond((atom*) this, (atom*) Partner, 1, 0); 91 RegisterBond(newBond); 92 Partner->RegisterBond(newBond); 93 } 76 94 77 95 /** Puts a given bond into atom::ListOfBonds. -
src/atom_bondedparticle.hpp
r992fd7 r257c77 37 37 virtual ~BondedParticle(); 38 38 39 void addBond(BondedParticle* Partner); 39 40 bool RegisterBond(bond *Binder); 40 41 bool UnregisterBond(bond *Binder); -
src/atom_bondedparticleinfo.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom_bondedparticleinfo.hpp" -
src/atom_graphnode.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom_graphnode.hpp" -
src/atom_graphnodeinfo.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom_graphnodeinfo.hpp" … … 17 19 GraphNodeInfo::~GraphNodeInfo() 18 20 { 19 Free<int>(&ComponentNr, "atom::~atom: *ComponentNr");21 delete[](ComponentNr); 20 22 }; -
src/atom_particleinfo.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom_particleinfo.hpp" -
src/atom_trajectoryparticle.cpp
r992fd7 r257c77 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "atom.hpp" 9 11 #include "atom_trajectoryparticle.hpp" 10 12 #include "config.hpp" 11 13 #include "element.hpp" 14 #include "info.hpp" 12 15 #include "log.hpp" 13 16 #include "parser.hpp" … … 71 74 void TrajectoryParticle::ResizeTrajectory(int MaxSteps) 72 75 { 76 Info FunctionInfo(__func__); 73 77 if (Trajectory.R.size() <= (unsigned int)(MaxSteps)) { 74 //Log() << Verbose(0) << "Increasing size for trajectory array of " << keyword << " to " << (MaxSteps+1) << "." << endl;78 DoLog(0) && (Log() << Verbose(0) << "Increasing size for trajectory array of " << nr << " from " << Trajectory.R.size() << " to " << (MaxSteps+1) << "." << endl); 75 79 Trajectory.R.resize(MaxSteps+1); 76 80 Trajectory.U.resize(MaxSteps+1); -
src/atom_trajectoryparticleinfo.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom_trajectoryparticleinfo.hpp" -
src/bond.cpp
r992fd7 r257c77 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 #include "atom.hpp" … … 15 17 /** Empty Constructor for class bond. 16 18 */ 17 bond::bond() : leftatom(NULL), rightatom(NULL), previous(NULL), next(NULL), HydrogenBond(0), BondDegree(0), nr(-1), Cyclic(false), Type(Undetermined), Used(white) 19 bond::bond() 20 : leftatom(NULL), rightatom(NULL), previous(NULL), next(NULL), HydrogenBond(0), 21 BondDegree(0), nr(-1), Cyclic(false), Type(Undetermined), Used(white) 18 22 { 19 23 }; … … 25 29 * \param number increasing index 26 30 */ 27 bond::bond(atom *left, atom *right, const int degree, const int number) : leftatom(left), rightatom(right), previous(NULL), next(NULL), HydrogenBond(0), BondDegree(degree), nr(number), Cyclic(false), Type(Undetermined), Used(white) 31 bond::bond(atom *left, atom *right, const int degree, const int number) 32 : leftatom(left), rightatom(right), previous(NULL), next(NULL), HydrogenBond(0), 33 BondDegree(degree), nr(number), Cyclic(false), Type(Undetermined), Used(white) 28 34 { 29 35 if ((left != NULL) && (right != NULL)) { -
src/bondgraph.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <iostream> … … 88 90 { 89 91 Info FunctionInfo(__func__); 90 bool status = true;92 bool status = true; 91 93 92 if (mol-> start->next == mol->end) // only construct if molecule is not empty94 if (mol->empty()) // only construct if molecule is not empty 93 95 return false; 94 96 … … 124 126 max_distance = 0.; 125 127 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; 128 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 129 if ((*iter)->type->CovalentRadius > max_distance) 130 max_distance = (*iter)->type->CovalentRadius; 131 131 } 132 132 max_distance *= 2.; -
src/bondgraph.hpp
r992fd7 r257c77 27 27 28 28 class molecule; 29 class periodentafel;29 class BondedParticle; 30 30 class MatrixContainer; 31 31 -
src/boundary.cpp
r992fd7 r257c77 3 3 * Implementations and super-function for envelopes 4 4 */ 5 6 #include "Helpers/MemDebug.hpp" 5 7 6 8 #include "World.hpp" … … 139 141 { 140 142 Info FunctionInfo(__func__); 141 atom *Walker = NULL;142 143 PointMap PointsOnBoundary; 143 144 LineMap LinesOnBoundary; … … 165 166 166 167 // 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); 168 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 169 ProjectedVector = (*iter)->x - (*MolCenter); 171 170 ProjectedVector.ProjectOntoPlane(AxisVector); 172 171 … … 182 181 angle = 2. * M_PI - angle; 183 182 } 184 DoLog(1) && (Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);185 BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, Walker)));183 DoLog(1) && (Log() << Verbose(1) << "Inserting " << **iter << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl); 184 BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, (*iter)))); 186 185 if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity 187 186 DoLog(2) && (Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl); 188 187 DoLog(2) && (Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl); 189 DoLog(2) && (Log() << Verbose(2) << "New vector: " << * Walker << endl);188 DoLog(2) && (Log() << Verbose(2) << "New vector: " << **iter << endl); 190 189 const double ProjectedVectorNorm = ProjectedVector.NormSquared(); 191 190 if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) { 192 191 BoundaryTestPair.first->second.first = ProjectedVectorNorm; 193 BoundaryTestPair.first->second.second = Walker;192 BoundaryTestPair.first->second.second = (*iter); 194 193 DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl); 195 194 } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) { 196 helper = Walker->x - (*MolCenter); 195 helper = (*iter)->x; 196 helper -= *MolCenter; 197 197 const double oldhelperNorm = helper.NormSquared(); 198 198 helper = BoundaryTestPair.first->second.second->x - (*MolCenter); 199 199 if (helper.NormSquared() < oldhelperNorm) { 200 BoundaryTestPair.first->second.second = Walker;200 BoundaryTestPair.first->second.second = (*iter); 201 201 DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl); 202 202 } else { … … 226 226 do { // do as long as we still throw one out per round 227 227 flag = false; 228 Boundaries::iterator left = BoundaryPoints[axis].end(); 229 Boundaries::iterator right = BoundaryPoints[axis].end(); 230 for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) { 228 Boundaries::iterator left = BoundaryPoints[axis].begin(); 229 Boundaries::iterator right = BoundaryPoints[axis].begin(); 230 Boundaries::iterator runner = BoundaryPoints[axis].begin(); 231 bool LoopOnceDone = false; 232 while (!LoopOnceDone) { 233 runner = right; 234 right++; 231 235 // set neighbours correctly 232 236 if (runner == BoundaryPoints[axis].begin()) { … … 236 240 } 237 241 left--; 238 right = runner;239 right++;240 242 if (right == BoundaryPoints[axis].end()) { 241 243 right = BoundaryPoints[axis].begin(); 244 LoopOnceDone = true; 242 245 } 243 246 // check distance … … 279 282 DoLog(1) && (Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl); 280 283 BoundaryPoints[axis].erase(runner); 284 runner = right; 281 285 flag = true; 282 286 } … … 359 363 360 364 // 4. Store triangles in tecplot file 361 if (filename != NULL) { 362 if (DoTecplotOutput) { 363 string OutputName(filename); 364 OutputName.append("_intermed"); 365 OutputName.append(TecplotSuffix); 366 ofstream *tecplot = new ofstream(OutputName.c_str()); 367 WriteTecplotFile(tecplot, TesselStruct, mol, 0); 368 tecplot->close(); 369 delete(tecplot); 370 } 371 if (DoRaster3DOutput) { 372 string OutputName(filename); 373 OutputName.append("_intermed"); 374 OutputName.append(Raster3DSuffix); 375 ofstream *rasterplot = new ofstream(OutputName.c_str()); 376 WriteRaster3dFile(rasterplot, TesselStruct, mol); 377 rasterplot->close(); 378 delete(rasterplot); 379 } 380 } 365 StoreTrianglesinFile(mol, TesselStruct, filename, "_intermed"); 381 366 382 367 // 3d. check all baselines whether the peaks of the two adjacent triangles with respect to center of baseline are convex, if not, make the baseline between the two peaks and baseline endpoints become the new peaks … … 397 382 TesselStruct->FlipBaseline(line); 398 383 DoLog(1) && (Log() << Verbose(1) << "INFO: Correction of concave baselines worked." << endl); 384 LineRunner = TesselStruct->LinesOnBoundary.begin(); // LineRunner may have been erase if line was deleted from LinesOnBoundary 399 385 } 400 386 } … … 409 395 410 396 // 4. Store triangles in tecplot file 411 if (filename != NULL) { 412 if (DoTecplotOutput) { 413 string OutputName(filename); 414 OutputName.append(TecplotSuffix); 415 ofstream *tecplot = new ofstream(OutputName.c_str()); 416 WriteTecplotFile(tecplot, TesselStruct, mol, 0); 417 tecplot->close(); 418 delete(tecplot); 419 } 420 if (DoRaster3DOutput) { 421 string OutputName(filename); 422 OutputName.append(Raster3DSuffix); 423 ofstream *rasterplot = new ofstream(OutputName.c_str()); 424 WriteRaster3dFile(rasterplot, TesselStruct, mol); 425 rasterplot->close(); 426 delete(rasterplot); 427 } 428 } 429 397 StoreTrianglesinFile(mol, TesselStruct, filename, ""); 430 398 431 399 // free reference lists … … 678 646 /** Creates multiples of the by \a *mol given cluster and suspends them in water with a given final density. 679 647 * We get cluster volume by VolumeOfConvexEnvelope() and its diameters by GetDiametersOfCluster() 648 * TODO: Here, we need a VolumeOfGeneralEnvelope (i.e. non-convex one) 680 649 * \param *out output stream for debugging 681 650 * \param *configuration needed for path to store convex envelope file … … 695 664 int repetition[NDIM] = { 1, 1, 1 }; 696 665 int TotalNoClusters = 1; 697 atom *Walker = NULL;698 666 double totalmass = 0.; 699 667 double clustervolume = 0.; … … 706 674 GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem); 707 675 BoundaryPoints = GetBoundaryPoints(mol, TesselStruct); 708 LinkedCell LCList(mol, 10.); 709 FindConvexBorder(mol, TesselStruct, &LCList, NULL); 676 LinkedCell *LCList = new LinkedCell(mol, 10.); 677 FindConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, NULL); 678 delete (LCList); 679 710 680 711 681 // some preparations beforehand … … 719 689 720 690 // sum up the atomic masses 721 Walker = mol->start; 722 while (Walker->next != mol->end) { 723 Walker = Walker->next; 724 totalmass += Walker->type->mass; 691 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 692 totalmass += (*iter)->type->mass; 725 693 } 726 694 DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl); … … 804 772 Vector Inserter; 805 773 double FillIt = false; 806 atom *Walker = NULL;807 774 bond *Binder = NULL; 808 775 double phi[NDIM]; … … 811 778 812 779 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) 813 if ((*ListRunner)-> AtomCount> 0) {780 if ((*ListRunner)->getAtomCount() > 0) { 814 781 DoLog(1) && (Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl); 815 782 LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list … … 822 789 filler->CenterEdge(&Inserter); 823 790 filler->Center.Zero(); 791 const int FillerCount = filler->getAtomCount(); 824 792 DoLog(2) && (Log() << Verbose(2) << "INFO: Filler molecule has the following bonds:" << endl); 825 Binder = filler->first; 826 while(Binder->next != filler->last) { 827 Binder = Binder->next; 828 DoLog(2) && (Log() << Verbose(2) << " " << *Binder << endl); 829 } 830 831 filler->CountAtoms(); 832 atom * CopyAtoms[filler->AtomCount]; 793 for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner) 794 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 795 if ((*BondRunner)->leftatom == *AtomRunner) 796 DoLog(2) && (Log() << Verbose(2) << " " << *(*BondRunner) << endl); 797 798 atom * CopyAtoms[FillerCount]; 833 799 834 800 // calculate filler grid in [0,1]^3 … … 855 821 856 822 // go through all atoms 857 for (int i=0;i< filler->AtomCount;i++)823 for (int i=0;i<FillerCount;i++) 858 824 CopyAtoms[i] = NULL; 859 Walker = filler->start; 860 while (Walker->next != filler->end) { 861 Walker = Walker->next; 825 for(molecule::const_iterator iter = filler->begin(); iter !=filler->end();++iter){ 862 826 863 827 // create atomic random translation vector ... … … 883 847 884 848 // ... and put at new position 885 Inserter = Walker->x;849 Inserter = (*iter)->x; 886 850 if (DoRandomRotation) 887 851 Inserter.MatrixMultiplication(Rotations); … … 907 871 DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl); 908 872 // copy atom ... 909 CopyAtoms[ Walker->nr] = Walker->clone();910 CopyAtoms[ Walker->nr]->x = Inserter;911 Filling->AddAtom(CopyAtoms[ Walker->nr]);912 DoLog(4) && (Log() << Verbose(4) << "Filling atom " << * Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl);873 CopyAtoms[(*iter)->nr] = (*iter)->clone(); 874 CopyAtoms[(*iter)->nr]->x = Inserter; 875 Filling->AddAtom(CopyAtoms[(*iter)->nr]); 876 DoLog(4) && (Log() << Verbose(4) << "Filling atom " << **iter << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[(*iter)->nr]->x) << "." << endl); 913 877 } else { 914 878 DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl); 915 CopyAtoms[ Walker->nr] = NULL;879 CopyAtoms[(*iter)->nr] = NULL; 916 880 continue; 917 881 } 918 882 } 919 883 // go through all bonds and add as well 920 Binder = filler->first; 921 while(Binder->next != filler->last) { 922 Binder = Binder->next; 923 if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) { 924 Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl; 925 Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree); 926 } 927 } 884 for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner) 885 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 886 if ((*BondRunner)->leftatom == *AtomRunner) { 887 Binder = (*BondRunner); 888 if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) { 889 Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl; 890 Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree); 891 } 892 } 928 893 } 929 Free(&M);930 Free(&MInverse);894 delete[](M); 895 delete[](MInverse); 931 896 932 897 return Filling; … … 952 917 bool TesselationFailFlag = false; 953 918 919 mol->getAtomCount(); 920 954 921 if (TesselStruct == NULL) { 955 922 DoLog(1) && (Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl); … … 1023 990 // // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles 1024 991 // //->InsertStraddlingPoints(mol, LCList); 1025 // mol->GoToFirst();992 // for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1026 993 // class TesselPoint *Runner = NULL; 1027 // while (!mol->IsEnd()) { 1028 // Runner = mol->GetPoint(); 994 // Runner = *iter; 1029 995 // Log() << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl; 1030 996 // if (!->IsInnerPoint(Runner, LCList)) { … … 1034 1000 // Log() << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl; 1035 1001 // } 1036 // mol->GoToNext();1037 1002 // } 1038 1003 … … 1043 1008 status = CheckListOfBaselines(TesselStruct); 1044 1009 1010 cout << "before correction" << endl; 1011 1045 1012 // store before correction 1046 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");1013 StoreTrianglesinFile(mol, TesselStruct, filename, ""); 1047 1014 1048 1015 // // correct degenerated polygons … … 1054 1021 // write final envelope 1055 1022 CalculateConcavityPerBoundaryPoint(TesselStruct); 1056 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, ""); 1023 cout << "after correction" << endl; 1024 StoreTrianglesinFile(mol, TesselStruct, filename, ""); 1057 1025 1058 1026 if (freeLC) -
src/builder.cpp
r992fd7 r257c77 47 47 */ 48 48 49 #include "Helpers/MemDebug.hpp" 49 50 50 51 #include <boost/bind.hpp> … … 53 54 54 55 #include <cstring> 56 #include <cstdlib> 55 57 56 58 #include "analysis_bonds.hpp" … … 60 62 #include "bondgraph.hpp" 61 63 #include "boundary.hpp" 64 #include "CommandLineParser.hpp" 62 65 #include "config.hpp" 63 66 #include "element.hpp" … … 71 74 #include "periodentafel.hpp" 72 75 #include "UIElements/UIFactory.hpp" 73 #include "UIElements/TextUIFactory.hpp" 76 #include "UIElements/TextUI/TextUIFactory.hpp" 77 #include "UIElements/CommandLineUI/CommandLineUIFactory.hpp" 74 78 #ifdef USE_GUI_QT 75 79 #include "UIElements/QT4/QTUIFactory.hpp" … … 80 84 #include "Actions/ActionRegistry.hpp" 81 85 #include "Actions/ActionHistory.hpp" 86 #include "Actions/MapOfActions.hpp" 82 87 #include "Actions/MethodAction.hpp" 83 #include "Actions/ small_actions.hpp"88 #include "Actions/MoleculeAction/ChangeNameAction.hpp" 84 89 #include "World.hpp" 85 90 #include "version.h" 86 91 #include "World.hpp" 87 #include "Helpers/MemDebug.hpp" 92 88 93 89 94 /********************************************* Subsubmenu routine ************************************/ … … 459 464 mol->Mirror((const Vector *)&n); 460 465 }; 461 >>>>>>> MenuRefactoring:molecuilder/src/builder.cpp462 466 463 467 /** Submenu for removing the atoms from the molecule. … … 867 871 868 872 mol->CountAtoms(); // recount atoms 869 if (mol-> AtomCount!= 0) { // if there is more than none870 count = mol-> AtomCount; // is changed becausing of adding, thus has to be stored away beforehand873 if (mol->getAtomCount() != 0) { // if there is more than none 874 count = mol->getAtomCount(); // is changed becausing of adding, thus has to be stored away beforehand 871 875 Elements = new element *[count]; 872 876 vectors = new Vector *[count]; … … 1298 1302 // generate some KeySets 1299 1303 DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl); 1300 KeySet TestSets[mol-> AtomCount+1];1304 KeySet TestSets[mol->getAtomCount()+1]; 1301 1305 i=1; 1302 1306 while (Walker->next != mol->end) { … … 1309 1313 DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl); 1310 1314 KeySetTestPair test; 1311 test = TestSets[mol-> AtomCount-1].insert(Walker->nr);1315 test = TestSets[mol->getAtomCount()-1].insert(Walker->nr); 1312 1316 if (test.second) { 1313 1317 DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl); … … 1315 1319 DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl); 1316 1320 } 1317 TestSets[mol-> AtomCount].insert(mol->end->previous->nr);1318 TestSets[mol-> AtomCount].insert(mol->end->previous->previous->previous->nr);1321 TestSets[mol->getAtomCount()].insert(mol->end->previous->nr); 1322 TestSets[mol->getAtomCount()].insert(mol->end->previous->previous->previous->nr); 1319 1323 1320 1324 // constructing Graph structure … … 1324 1328 // insert KeySets into Subgraphs 1325 1329 DoLog(0) && (Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl); 1326 for (int j=0;j<mol-> AtomCount;j++) {1330 for (int j=0;j<mol->getAtomCount();j++) { 1327 1331 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.))); 1328 1332 } 1329 1333 DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl); 1330 1334 GraphTestPair test2; 1331 test2 = Subgraphs.insert(GraphPair (TestSets[mol-> AtomCount],pair<int, double>(counter++, 1.)));1335 test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.))); 1332 1336 if (test2.second) { 1333 1337 DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl); … … 1484 1488 1485 1489 /** Parses the command line options. 1490 * Note that this function is from now on transitional. All commands that are not passed 1491 * here are handled by CommandLineParser and the actions of CommandLineUIFactory. 1486 1492 * \param argc argument count 1487 1493 * \param **argv arguments array … … 1491 1497 * \param *ConfigFileName pointer to config file name in **argv 1492 1498 * \param *PathToDatabases pointer to db's path in **argv 1499 * \param &ArgcList list of arguments that we do not parse here 1493 1500 * \return exit code (0 - successful, all else - something's wrong) 1494 1501 */ 1495 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode, \1496 config& configuration, char * &ConfigFileName)1502 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode, 1503 config& configuration, char **ConfigFileName, set<int> &ArgcList) 1497 1504 { 1498 1505 Vector x,y,z,n; // coordinates for absolute point in cell volume … … 1512 1519 molecule *mol = NULL; 1513 1520 string BondGraphFileName("\n"); 1514 int verbosity = 0; 1515 strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1); 1521 bool DatabasePathGiven = false; 1516 1522 1517 1523 if (argc > 1) { // config file specified as option … … 1526 1532 case 'H': 1527 1533 case '?': 1528 DoLog(0) && (Log() << Verbose(0) << "MoleCuilder suite" << endl << "==================" << endl << endl); 1529 DoLog(0) && (Log() << Verbose(0) << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl); 1530 DoLog(0) && (Log() << Verbose(0) << "or simply " << argv[0] << " without arguments for interactive session." << endl); 1531 DoLog(0) && (Log() << Verbose(0) << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl); 1532 DoLog(0) && (Log() << Verbose(0) << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl); 1533 DoLog(0) && (Log() << Verbose(0) << "\t-b xx xy xz yy yz zz\tCenter atoms in domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl); 1534 DoLog(0) && (Log() << Verbose(0) << "\t-B xx xy xz yy yz zz\tBound atoms by domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl); 1535 DoLog(0) && (Log() << Verbose(0) << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl); 1536 DoLog(0) && (Log() << Verbose(0) << "\t-C <type> [params] <output> <bin output> <BinWidth> <BinStart> <BinEnd>\tPair Correlation analysis." << endl); 1537 DoLog(0) && (Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl); 1538 DoLog(0) && (Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl); 1539 DoLog(0) && (Log() << Verbose(0) << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl); 1540 DoLog(0) && (Log() << Verbose(0) << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl); 1541 DoLog(0) && (Log() << Verbose(0) << "\t-f <dist> <order>\tFragments the molecule in BOSSANOVA manner (with/out rings compressed) and stores config files in same dir as config (return code 0 - fragmented, 2 - no fragmentation necessary)." << endl); 1542 DoLog(0) && (Log() << Verbose(0) << "\t-F <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl); 1543 DoLog(0) && (Log() << Verbose(0) << "\t-FF <MaxDistance> <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl); 1544 DoLog(0) && (Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl); 1545 DoLog(0) && (Log() << Verbose(0) << "\t-h/-H/-?\tGive this help screen." << endl); 1546 DoLog(0) && (Log() << Verbose(0) << "\t-I\t Dissect current system of molecules into a set of disconnected (subgraphs of) molecules." << endl); 1547 DoLog(0) && (Log() << Verbose(0) << "\t-j\t<path> Store all bonds to file." << endl); 1548 DoLog(0) && (Log() << Verbose(0) << "\t-J\t<path> Store adjacency per atom to file." << endl); 1549 DoLog(0) && (Log() << Verbose(0) << "\t-L <step0> <step1> <prefix>\tStore a linear interpolation between two configurations <step0> and <step1> into single config files with prefix <prefix> and as Trajectories into the current config file." << endl); 1550 DoLog(0) && (Log() << Verbose(0) << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl); 1551 DoLog(0) && (Log() << Verbose(0) << "\t-M <basis>\tSetting basis to store to MPQC config files." << endl); 1552 DoLog(0) && (Log() << Verbose(0) << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl); 1553 DoLog(0) && (Log() << Verbose(0) << "\t-N <radius> <file>\tGet non-convex-envelope." << endl); 1554 DoLog(0) && (Log() << Verbose(0) << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl); 1555 DoLog(0) && (Log() << Verbose(0) << "\t-O\tCenter atoms in origin." << endl); 1556 DoLog(0) && (Log() << Verbose(0) << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl); 1557 DoLog(0) && (Log() << Verbose(0) << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl); 1558 DoLog(0) && (Log() << Verbose(0) << "\t-r <id>\t\tRemove an atom with given id." << endl); 1559 DoLog(0) && (Log() << Verbose(0) << "\t-R <id> <radius>\t\tRemove all atoms out of sphere around a given one." << endl); 1560 DoLog(0) && (Log() << Verbose(0) << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl); 1561 DoLog(0) && (Log() << Verbose(0) << "\t-S <file> Store temperatures from the config file in <file>." << endl); 1562 DoLog(0) && (Log() << Verbose(0) << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl); 1563 DoLog(0) && (Log() << Verbose(0) << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl); 1564 DoLog(0) && (Log() << Verbose(0) << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl); 1565 DoLog(0) && (Log() << Verbose(0) << "\t-v\t\tsets verbosity (more is more)." << endl); 1566 DoLog(0) && (Log() << Verbose(0) << "\t-V\t\tGives version information." << endl); 1567 DoLog(0) && (Log() << Verbose(0) << "\t-X\t\tset default name of a molecule." << endl); 1568 DoLog(0) && (Log() << Verbose(0) << "Note: config files must not begin with '-' !" << endl); 1569 return (1); 1534 ArgcList.insert(argptr-1); 1535 return(1); 1570 1536 break; 1571 1537 case 'v': 1572 while (argv[argptr-1][verbosity+1] == 'v') { 1573 verbosity++; 1538 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1539 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying verbosity: -v <level>" << endl); 1540 performCriticalExit(); 1541 } else { 1542 setVerbosity(atoi(argv[argptr])); 1543 ArgcList.insert(argptr-1); 1544 ArgcList.insert(argptr); 1545 argptr++; 1574 1546 } 1575 setVerbosity(verbosity);1576 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl);1577 1547 break; 1578 1548 case 'V': 1579 DoLog(0) && (Log() << Verbose(0) << argv[0] << " " << VERSIONSTRING << endl); 1580 DoLog(0) && (Log() << Verbose(0) << "Build your own molecule position set." << endl); 1581 return (1); 1549 ArgcList.insert(argptr-1); 1550 return(1); 1582 1551 break; 1583 1552 case 'B': 1584 1553 if (ExitFlag == 0) ExitFlag = 1; 1585 if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) { 1586 ExitFlag = 255; 1587 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl); 1554 if ((argptr+5 >= argc)) { 1555 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for setting Box: -B <xx> <<xy> <<xz> <yy> <yz> <zz>" << endl); 1588 1556 performCriticalExit(); 1589 1557 } else { 1590 SaveFlag = true;1591 j = -1;1592 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);1593 double * const cell_size = World::getInstance().getDomain();1594 for (int i=0;i<6;i++) {1595 cell_size[i] = atof(argv[argptr+i]);1596 }1558 ArgcList.insert(argptr-1); 1559 ArgcList.insert(argptr); 1560 ArgcList.insert(argptr+1); 1561 ArgcList.insert(argptr+2); 1562 ArgcList.insert(argptr+3); 1563 ArgcList.insert(argptr+4); 1564 ArgcList.insert(argptr+5); 1597 1565 argptr+=6; 1598 1566 } … … 1603 1571 performCriticalExit(); 1604 1572 } else { 1605 DoLog(0) && (Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl);1606 strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1);1573 ArgcList.insert(argptr-1); 1574 ArgcList.insert(argptr); 1607 1575 argptr+=1; 1608 1576 } … … 1613 1581 performCriticalExit(); 1614 1582 } else { 1615 BondGraphFileName = argv[argptr]; 1616 DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl); 1583 ArgcList.insert(argptr-1); 1584 ArgcList.insert(argptr); 1585 argptr+=1; 1586 } 1587 break; 1588 case 'M': 1589 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1590 ExitFlag = 255; 1591 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -M <basis name>" << endl); 1592 performCriticalExit(); 1593 } else { 1594 ArgcList.insert(argptr-1); 1595 ArgcList.insert(argptr); 1617 1596 argptr+=1; 1618 1597 } 1619 1598 break; 1620 1599 case 'n': 1621 DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl); 1622 configuration.FastParsing = true; 1600 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1601 ExitFlag = 255; 1602 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting fast-parsing: -n <0/1>" << endl); 1603 performCriticalExit(); 1604 } else { 1605 ArgcList.insert(argptr-1); 1606 ArgcList.insert(argptr); 1607 argptr+=1; 1608 } 1623 1609 break; 1624 1610 case 'X': 1625 { 1626 World::getInstance().setDefaultName(argv[argptr]); 1627 DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << *World::getInstance().getDefaultName() << "." << endl); 1611 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1612 ExitFlag = 255; 1613 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting default molecule name: -X <name>" << endl); 1614 performCriticalExit(); 1615 } else { 1616 ArgcList.insert(argptr-1); 1617 ArgcList.insert(argptr); 1618 argptr+=1; 1628 1619 } 1629 1620 break; … … 1636 1627 } while (argptr < argc); 1637 1628 1638 // 3a. Parse the element database1639 if (periode->LoadPeriodentafel(configuration.databasepath)) {1640 DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);1641 //periode->Output();1642 } else {1643 DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);1644 return 1;1645 }1646 1629 // 3b. Find config file name and parse if possible, also BondGraphFileName 1647 1630 if (argv[1][0] != '-') { … … 1657 1640 } else { 1658 1641 DoLog(0) && (Log() << Verbose(0) << "Empty configuration file." << endl); 1659 ConfigFileName = argv[1];1642 strcpy(*ConfigFileName, argv[1]); 1660 1643 configPresent = empty; 1661 1644 output.close(); … … 1663 1646 } else { 1664 1647 test.close(); 1665 ConfigFileName = argv[1];1648 strcpy(*ConfigFileName, argv[1]); 1666 1649 DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... "); 1667 switch (configuration.TestSyntax( ConfigFileName, periode)) {1650 switch (configuration.TestSyntax(*ConfigFileName, periode)) { 1668 1651 case 1: 1669 1652 DoLog(0) && (Log() << Verbose(0) << "new syntax." << endl); 1670 configuration.Load( ConfigFileName, BondGraphFileName, periode, molecules);1653 configuration.Load(*ConfigFileName, BondGraphFileName, periode, molecules); 1671 1654 configPresent = present; 1672 1655 break; 1673 1656 case 0: 1674 1657 DoLog(0) && (Log() << Verbose(0) << "old syntax." << endl); 1675 configuration.LoadOld( ConfigFileName, BondGraphFileName, periode, molecules);1658 configuration.LoadOld(*ConfigFileName, BondGraphFileName, periode, molecules); 1676 1659 configPresent = present; 1677 1660 break; … … 1694 1677 mol = World::getInstance().createMolecule(); 1695 1678 mol->ActiveFlag = true; 1696 if ( ConfigFileName != NULL)1697 mol->SetNameFromFilename( ConfigFileName);1679 if (*ConfigFileName != NULL) 1680 mol->SetNameFromFilename(*ConfigFileName); 1698 1681 molecules->insert(mol); 1699 }1700 if (configuration.BG == NULL) {1701 configuration.BG = new BondGraph(configuration.GetIsAngstroem());1702 if ((!BondGraphFileName.empty()) && (configuration.BG->LoadBondLengthTable(BondGraphFileName))) {1703 DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);1704 } else {1705 DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);1706 }1707 1682 } 1708 1683 … … 1734 1709 case 'a': 1735 1710 if (ExitFlag == 0) ExitFlag = 1; 1736 if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3]))) {1711 if ((argptr+4 >= argc) || (argv[argptr][0] == '-')) { 1737 1712 ExitFlag = 255; 1738 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for adding atom: -a <element><x> <y> <z>" << endl);1713 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for adding atom: -a <Z> --position <x> <y> <z>" << endl); 1739 1714 performCriticalExit(); 1740 1715 } else { 1741 SaveFlag = true; 1742 Log() << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), "; 1743 first = World::getInstance().createAtom(); 1744 first->type = periode->FindElement(atoi(argv[argptr])); 1745 if (first->type != NULL) 1746 DoLog(2) && (Log() << Verbose(2) << "found element " << first->type->name << endl); 1747 for (int i=NDIM;i--;) 1748 first->x[i] = atof(argv[argptr+1+i]); 1749 if (first->type != NULL) { 1750 mol->AddAtom(first); // add to molecule 1751 if ((configPresent == empty) && (mol->AtomCount != 0)) 1752 configPresent = present; 1753 } else 1754 DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl); 1755 argptr+=4; 1716 ArgcList.insert(argptr-1); 1717 ArgcList.insert(argptr); 1718 ArgcList.insert(argptr+1); 1719 ArgcList.insert(argptr+2); 1720 ArgcList.insert(argptr+3); 1721 ArgcList.insert(argptr+4); 1722 argptr+=5; 1756 1723 } 1757 1724 break; … … 1762 1729 if (configPresent == present) { 1763 1730 switch(argv[argptr-1][1]) { 1764 case 'M': 1731 case 'D': 1732 if (ExitFlag == 0) ExitFlag = 1; 1765 1733 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1766 1734 ExitFlag = 255; 1767 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl);1735 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for depth-first-search analysis: -D <max. bond distance>" << endl); 1768 1736 performCriticalExit(); 1769 1737 } else { 1770 configuration.basis = argv[argptr];1771 DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl);1738 ArgcList.insert(argptr-1); 1739 ArgcList.insert(argptr); 1772 1740 argptr+=1; 1773 1741 } 1774 break;1775 case 'D':1776 if (ExitFlag == 0) ExitFlag = 1;1777 {1778 DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);1779 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis1780 int *MinimumRingSize = new int[mol->AtomCount];1781 atom ***ListOfLocalAtoms = NULL;1782 class StackClass<bond *> *BackEdgeStack = NULL;1783 class StackClass<bond *> *LocalBackEdgeStack = NULL;1784 mol->CreateAdjacencyList(atof(argv[argptr]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);1785 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);1786 if (Subgraphs != NULL) {1787 int FragmentCounter = 0;1788 while (Subgraphs->next != NULL) {1789 Subgraphs = Subgraphs->next;1790 Subgraphs->FillBondStructureFromReference(mol, FragmentCounter, ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms1791 LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);1792 Subgraphs->Leaf->PickLocalBackEdges(ListOfLocalAtoms[FragmentCounter], BackEdgeStack, LocalBackEdgeStack);1793 Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);1794 delete(LocalBackEdgeStack);1795 delete(Subgraphs->previous);1796 FragmentCounter++;1797 }1798 delete(Subgraphs);1799 for (int i=0;i<FragmentCounter;i++)1800 Free(&ListOfLocalAtoms[i]);1801 Free(&ListOfLocalAtoms);1802 }1803 delete(BackEdgeStack);1804 delete[](MinimumRingSize);1805 }1806 //argptr+=1;1807 1742 break; 1808 1743 case 'I': 1809 1744 DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl); 1810 // @TODO rather do the dissection afterwards 1811 molecules->DissectMoleculeIntoConnectedSubgraphs(periode, &configuration); 1812 mol = NULL; 1813 if (molecules->ListOfMolecules.size() != 0) { 1814 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 1815 if ((*ListRunner)->ActiveFlag) { 1816 mol = *ListRunner; 1817 break; 1818 } 1819 } 1820 if ((mol == NULL) && (!molecules->ListOfMolecules.empty())) { 1821 mol = *(molecules->ListOfMolecules.begin()); 1822 if (mol != NULL) 1823 mol->ActiveFlag = true; 1824 } 1745 ArgcList.insert(argptr-1); 1746 argptr+=0; 1825 1747 break; 1826 1748 case 'C': 1827 1749 { 1828 int ranges[3] = {1, 1, 1};1829 bool periodic = (argv[argptr-1][2] =='p');1830 1750 if (ExitFlag == 0) ExitFlag = 1; 1831 if ((argptr >= argc)) {1751 if ((argptr+11 >= argc)) { 1832 1752 ExitFlag = 255; 1833 1753 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C[p] <type: E/P/S> [more params] <output> <bin output> <BinStart> <BinEnd>" << endl); … … 1836 1756 switch(argv[argptr][0]) { 1837 1757 case 'E': 1838 { 1839 if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (!IsValidNumber(argv[argptr+2])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-')) { 1840 ExitFlag = 255; 1841 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C E <Z1> <Z2> <output> <bin output>" << endl); 1842 performCriticalExit(); 1843 } else { 1844 ofstream output(argv[argptr+3]); 1845 ofstream binoutput(argv[argptr+4]); 1846 const double BinStart = atof(argv[argptr+5]); 1847 const double BinEnd = atof(argv[argptr+6]); 1848 1849 const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1])); 1850 const element *elemental2 = periode->FindElement((const int) atoi(argv[argptr+2])); 1851 PairCorrelationMap *correlationmap = NULL; 1852 if (periodic) 1853 correlationmap = PeriodicPairCorrelation(molecules, elemental, elemental2, ranges); 1854 else 1855 correlationmap = PairCorrelation(molecules, elemental, elemental2); 1856 //OutputCorrelationToSurface(&output, correlationmap); 1857 BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd ); 1858 OutputCorrelation ( &binoutput, binmap ); 1859 output.close(); 1860 binoutput.close(); 1861 delete(binmap); 1862 delete(correlationmap); 1863 argptr+=7; 1864 } 1865 } 1758 ArgcList.insert(argptr-1); 1759 ArgcList.insert(argptr); 1760 ArgcList.insert(argptr+1); 1761 ArgcList.insert(argptr+2); 1762 ArgcList.insert(argptr+3); 1763 ArgcList.insert(argptr+4); 1764 ArgcList.insert(argptr+5); 1765 ArgcList.insert(argptr+6); 1766 ArgcList.insert(argptr+7); 1767 ArgcList.insert(argptr+8); 1768 ArgcList.insert(argptr+9); 1769 ArgcList.insert(argptr+10); 1770 ArgcList.insert(argptr+11); 1771 argptr+=12; 1866 1772 break; 1867 1773 1868 1774 case 'P': 1869 { 1870 if ((argptr+8 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+7])) || (!IsValidNumber(argv[argptr+8])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-') || (argv[argptr+5][0] == '-') || (argv[argptr+6][0] == '-')) { 1871 ExitFlag = 255; 1872 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C P <Z1> <x> <y> <z> <output> <bin output>" << endl); 1873 performCriticalExit(); 1874 } else { 1875 ofstream output(argv[argptr+5]); 1876 ofstream binoutput(argv[argptr+6]); 1877 const double BinStart = atof(argv[argptr+7]); 1878 const double BinEnd = atof(argv[argptr+8]); 1879 1880 const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1])); 1881 Vector *Point = new Vector((const double) atof(argv[argptr+1]),(const double) atof(argv[argptr+2]),(const double) atof(argv[argptr+3])); 1882 CorrelationToPointMap *correlationmap = NULL; 1883 if (periodic) 1884 correlationmap = PeriodicCorrelationToPoint(molecules, elemental, Point, ranges); 1885 else 1886 correlationmap = CorrelationToPoint(molecules, elemental, Point); 1887 //OutputCorrelationToSurface(&output, correlationmap); 1888 BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd ); 1889 OutputCorrelation ( &binoutput, binmap ); 1890 output.close(); 1891 binoutput.close(); 1892 delete(Point); 1893 delete(binmap); 1894 delete(correlationmap); 1895 argptr+=9; 1896 } 1897 } 1775 ArgcList.insert(argptr-1); 1776 ArgcList.insert(argptr); 1777 ArgcList.insert(argptr+1); 1778 ArgcList.insert(argptr+2); 1779 ArgcList.insert(argptr+3); 1780 ArgcList.insert(argptr+4); 1781 ArgcList.insert(argptr+5); 1782 ArgcList.insert(argptr+6); 1783 ArgcList.insert(argptr+7); 1784 ArgcList.insert(argptr+8); 1785 ArgcList.insert(argptr+9); 1786 ArgcList.insert(argptr+10); 1787 ArgcList.insert(argptr+11); 1788 ArgcList.insert(argptr+12); 1789 ArgcList.insert(argptr+13); 1790 ArgcList.insert(argptr+14); 1791 argptr+=15; 1898 1792 break; 1899 1793 1900 1794 case 'S': 1901 { 1902 if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-')) { 1903 ExitFlag = 255; 1904 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C S <Z> <output> <bin output> <BinWidth> <BinStart> <BinEnd>" << endl); 1905 performCriticalExit(); 1906 } else { 1907 ofstream output(argv[argptr+2]); 1908 ofstream binoutput(argv[argptr+3]); 1909 const double radius = 4.; 1910 const double BinWidth = atof(argv[argptr+4]); 1911 const double BinStart = atof(argv[argptr+5]); 1912 const double BinEnd = atof(argv[argptr+6]); 1913 double LCWidth = 20.; 1914 if (BinEnd > 0) { 1915 if (BinEnd > 2.*radius) 1916 LCWidth = BinEnd; 1917 else 1918 LCWidth = 2.*radius; 1919 } 1920 1921 // get the boundary 1922 class molecule *Boundary = NULL; 1923 class Tesselation *TesselStruct = NULL; 1924 const LinkedCell *LCList = NULL; 1925 // find biggest molecule 1926 int counter = 0; 1927 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 1928 if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) { 1929 Boundary = *BigFinder; 1930 } 1931 counter++; 1932 } 1933 bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives"); 1934 counter = 0; 1935 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 1936 Actives[counter++] = (*BigFinder)->ActiveFlag; 1937 (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true; 1938 } 1939 LCList = new LinkedCell(Boundary, LCWidth); 1940 const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1])); 1941 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL); 1942 CorrelationToSurfaceMap *surfacemap = NULL; 1943 if (periodic) 1944 surfacemap = PeriodicCorrelationToSurface( molecules, elemental, TesselStruct, LCList, ranges); 1945 else 1946 surfacemap = CorrelationToSurface( molecules, elemental, TesselStruct, LCList); 1947 OutputCorrelationToSurface(&output, surfacemap); 1948 // check whether radius was appropriate 1949 { 1950 double start; double end; 1951 GetMinMax( surfacemap, start, end); 1952 if (LCWidth < end) 1953 DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl); 1954 } 1955 BinPairMap *binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd ); 1956 OutputCorrelation ( &binoutput, binmap ); 1957 output.close(); 1958 binoutput.close(); 1959 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) 1960 (*BigFinder)->ActiveFlag = Actives[counter++]; 1961 Free(&Actives); 1962 delete(LCList); 1963 delete(TesselStruct); 1964 delete(binmap); 1965 delete(surfacemap); 1966 argptr+=7; 1967 } 1968 } 1795 ArgcList.insert(argptr-1); 1796 ArgcList.insert(argptr); 1797 ArgcList.insert(argptr+1); 1798 ArgcList.insert(argptr+2); 1799 ArgcList.insert(argptr+3); 1800 ArgcList.insert(argptr+4); 1801 ArgcList.insert(argptr+5); 1802 ArgcList.insert(argptr+6); 1803 ArgcList.insert(argptr+7); 1804 ArgcList.insert(argptr+8); 1805 ArgcList.insert(argptr+9); 1806 ArgcList.insert(argptr+10); 1807 ArgcList.insert(argptr+11); 1808 ArgcList.insert(argptr+12); 1809 ArgcList.insert(argptr+13); 1810 ArgcList.insert(argptr+14); 1811 argptr+=15; 1969 1812 break; 1970 1813 … … 1980 1823 case 'E': 1981 1824 if (ExitFlag == 0) ExitFlag = 1; 1982 if ((argptr+ 1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) {1825 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr]))) { 1983 1826 ExitFlag = 255; 1984 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl);1827 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> --element <Z>" << endl); 1985 1828 performCriticalExit(); 1986 1829 } else { 1987 SaveFlag = true;1988 DoLog(1) && (Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl);1989 first = mol->FindAtom(atoi(argv[argptr]));1990 first->type = periode->FindElement(atoi(argv[argptr+1]));1991 argptr+= 2;1830 ArgcList.insert(argptr-1); 1831 ArgcList.insert(argptr); 1832 ArgcList.insert(argptr+1); 1833 ArgcList.insert(argptr+2); 1834 argptr+=3; 1992 1835 } 1993 1836 break; 1994 1837 case 'F': 1995 1838 if (ExitFlag == 0) ExitFlag = 1; 1996 MaxDistance = -1; 1997 if (argv[argptr-1][2] == 'F') { // option is -FF? 1998 // fetch first argument as max distance to surface 1999 MaxDistance = atof(argv[argptr++]); 2000 DoLog(0) && (Log() << Verbose(0) << "Filling with maximum layer distance of " << MaxDistance << "." << endl); 2001 } 2002 if ((argptr+7 >=argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (!IsValidNumber(argv[argptr+7]))) { 1839 if ((argptr+12 >= argc) || (argv[argptr][0] == '-')) { 2003 1840 ExitFlag = 255; 2004 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for filling box with water: -F <xyz of filler> <dist_x> <dist_y> <dist_z> <boundary> <randatom> <randmol> <DoRotate>" << endl);1841 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for filling with molecule: -F <filler xyz file> --MaxDistance <distance or -1> --distances <x> <y> <z> --lengths <surface> <randatm> <randmol> --DoRotate <0/1>" << endl); 2005 1842 performCriticalExit(); 2006 1843 } else { 2007 SaveFlag = true; 2008 DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules." << endl); 2009 // construct water molecule 2010 molecule *filler = World::getInstance().createMolecule(); 2011 if (!filler->AddXYZFile(argv[argptr])) { 2012 DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << argv[argptr] << "." << endl); 2013 } 2014 filler->SetNameFromFilename(argv[argptr]); 2015 configuration.BG->ConstructBondGraph(filler); 2016 molecule *Filling = NULL; 2017 atom *second = NULL, *third = NULL; 2018 first = World::getInstance().createAtom(); 2019 first->type = periode->FindElement(1); 2020 first->x = Vector(0.441, -0.143, 0.); 2021 filler->AddAtom(first); 2022 second = World::getInstance().createAtom(); 2023 second->type = periode->FindElement(1); 2024 second->x = Vector(-0.464, 1.137, 0.0); 2025 filler->AddAtom(second); 2026 third = World::getInstance().createAtom(); 2027 third->type = periode->FindElement(8); 2028 third->x = Vector(-0.464, 0.177, 0.); 2029 filler->AddAtom(third); 2030 filler->AddBond(first, third, 1); 2031 filler->AddBond(second, third, 1); 2032 // call routine 2033 double distance[NDIM]; 2034 for (int i=0;i<NDIM;i++) 2035 distance[i] = atof(argv[argptr+i+1]); 2036 Filling = FillBoxWithMolecule(molecules, filler, configuration, MaxDistance, distance, atof(argv[argptr+4]), atof(argv[argptr+5]), atof(argv[argptr+6]), atoi(argv[argptr+7])); 2037 if (Filling != NULL) { 2038 Filling->ActiveFlag = false; 2039 molecules->insert(Filling); 2040 } 2041 World::getInstance().destroyMolecule(filler); 2042 argptr+=6; 1844 ArgcList.insert(argptr-1); 1845 ArgcList.insert(argptr); 1846 ArgcList.insert(argptr+1); 1847 ArgcList.insert(argptr+2); 1848 ArgcList.insert(argptr+3); 1849 ArgcList.insert(argptr+4); 1850 ArgcList.insert(argptr+5); 1851 ArgcList.insert(argptr+6); 1852 ArgcList.insert(argptr+7); 1853 ArgcList.insert(argptr+8); 1854 ArgcList.insert(argptr+9); 1855 ArgcList.insert(argptr+10); 1856 ArgcList.insert(argptr+11); 1857 ArgcList.insert(argptr+12); 1858 argptr+=13; 2043 1859 } 2044 1860 break; 2045 1861 case 'A': 1862 if (ExitFlag == 0) ExitFlag = 1; 1863 if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) { 1864 ExitFlag =255; 1865 DoeLog(0) && (eLog()<< Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile> --molecule-by-id <molecule_id>" << endl); 1866 performCriticalExit(); 1867 } else { 1868 ArgcList.insert(argptr-1); 1869 ArgcList.insert(argptr); 1870 ArgcList.insert(argptr+1); 1871 ArgcList.insert(argptr+2); 1872 argptr+=3; 1873 } 1874 break; 1875 1876 case 'J': 1877 if (ExitFlag == 0) ExitFlag = 1; 1878 if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) { 1879 ExitFlag =255; 1880 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of adjacency file: -J <path> --molecule-by-id <molecule_id>" << endl); 1881 performCriticalExit(); 1882 } else { 1883 ArgcList.insert(argptr-1); 1884 ArgcList.insert(argptr); 1885 ArgcList.insert(argptr+1); 1886 ArgcList.insert(argptr+2); 1887 argptr+=3; 1888 } 1889 break; 1890 1891 case 'j': 2046 1892 if (ExitFlag == 0) ExitFlag = 1; 2047 1893 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 2048 1894 ExitFlag =255; 2049 DoeLog(0) && (eLog()<< Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl);1895 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of bonds file: -j <path> --molecule-by-id <molecule_id>" << endl); 2050 1896 performCriticalExit(); 2051 1897 } else { 2052 DoLog(0) && (Log() << Verbose(0) << "Parsing bonds from " << argv[argptr] << "." << endl);2053 ifstream *input = new ifstream(argv[argptr]);2054 mol->CreateAdjacencyListFromDbondFile(input);2055 input->close();2056 argptr+= 1;2057 } 2058 break; 2059 2060 case ' J':2061 if (ExitFlag == 0) ExitFlag = 1; 2062 if ((argptr >= argc) || (argv[argptr][0] == '-')){2063 ExitFlag = 255;2064 DoeLog(0) && (eLog()<< Verbose(0) << " Missing path of adjacency file: -j <path>" << endl);1898 ArgcList.insert(argptr-1); 1899 ArgcList.insert(argptr); 1900 ArgcList.insert(argptr+1); 1901 ArgcList.insert(argptr+2); 1902 argptr+=3; 1903 } 1904 break; 1905 1906 case 'N': 1907 if (ExitFlag == 0) ExitFlag = 1; 1908 if ((argptr+4 >= argc) || (argv[argptr][0] == '-')){ 1909 ExitFlag = 255; 1910 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -N <molecule_id> --sphere-radius <radius> --nonconvex-file <output prefix>" << endl); 2065 1911 performCriticalExit(); 2066 1912 } else { 2067 DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << argv[argptr] << "." << endl); 2068 configuration.BG->ConstructBondGraph(mol); 2069 mol->StoreAdjacencyToFile(NULL, argv[argptr]); 2070 argptr+=1; 2071 } 2072 break; 2073 2074 case 'j': 2075 if (ExitFlag == 0) ExitFlag = 1; 2076 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 2077 ExitFlag =255; 2078 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of bonds file: -j <path>" << endl); 1913 ArgcList.insert(argptr-1); 1914 ArgcList.insert(argptr); 1915 ArgcList.insert(argptr+1); 1916 ArgcList.insert(argptr+2); 1917 ArgcList.insert(argptr+3); 1918 ArgcList.insert(argptr+4); 1919 argptr+=5; 1920 } 1921 break; 1922 case 'S': 1923 if (ExitFlag == 0) ExitFlag = 1; 1924 if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) { 1925 ExitFlag = 255; 1926 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file> --molecule-by-id 0" << endl); 2079 1927 performCriticalExit(); 2080 1928 } else { 2081 DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << argv[argptr] << "." << endl);2082 configuration.BG->ConstructBondGraph(mol);2083 mol->StoreBondsToFile(NULL, argv[argptr]);2084 argptr+=1;2085 }2086 break;2087 2088 case ' N':2089 if (ExitFlag == 0) ExitFlag = 1; 2090 if ((argptr+ 1 >= argc) || (argv[argptr+1][0] == '-')){1929 ArgcList.insert(argptr-1); 1930 ArgcList.insert(argptr); 1931 ArgcList.insert(argptr+1); 1932 ArgcList.insert(argptr+2); 1933 argptr+=3; 1934 } 1935 break; 1936 case 'L': 1937 if (ExitFlag == 0) ExitFlag = 1; 1938 if ((argptr+8 >= argc) || (argv[argptr][0] == '-')) { 2091 1939 ExitFlag = 255; 2092 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl);1940 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for linear interpolation: -L <prefix> --start-step <step0> --end-step <step1> --molecule-by-id 0 --id-mapping <0/1>" << endl); 2093 1941 performCriticalExit(); 2094 1942 } else { 2095 class Tesselation *T = NULL; 2096 const LinkedCell *LCList = NULL; 2097 molecule * Boundary = NULL; 2098 //string filename(argv[argptr+1]); 2099 //filename.append(".csv"); 2100 DoLog(0) && (Log() << Verbose(0) << "Evaluating non-convex envelope of biggest molecule."); 2101 DoLog(1) && (Log() << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl); 2102 // find biggest molecule 2103 int counter = 0; 2104 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 2105 (*BigFinder)->CountAtoms(); 2106 if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) { 2107 Boundary = *BigFinder; 2108 } 2109 counter++; 2110 } 2111 DoLog(1) && (Log() << Verbose(1) << "Biggest molecule has " << Boundary->AtomCount << " atoms." << endl); 2112 start = clock(); 2113 LCList = new LinkedCell(Boundary, atof(argv[argptr])*2.); 2114 if (!FindNonConvexBorder(Boundary, T, LCList, atof(argv[argptr]), argv[argptr+1])) 2115 ExitFlag = 255; 2116 //FindDistributionOfEllipsoids(T, &LCList, N, number, filename.c_str()); 2117 end = clock(); 2118 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl); 2119 delete(LCList); 2120 delete(T); 2121 argptr+=2; 2122 } 2123 break; 2124 case 'S': 2125 if (ExitFlag == 0) ExitFlag = 1; 2126 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1943 ArgcList.insert(argptr-1); 1944 ArgcList.insert(argptr); 1945 ArgcList.insert(argptr+1); 1946 ArgcList.insert(argptr+2); 1947 ArgcList.insert(argptr+3); 1948 ArgcList.insert(argptr+4); 1949 ArgcList.insert(argptr+5); 1950 ArgcList.insert(argptr+6); 1951 ArgcList.insert(argptr+7); 1952 ArgcList.insert(argptr+8); 1953 argptr+=9; 1954 } 1955 break; 1956 case 'P': 1957 if (ExitFlag == 0) ExitFlag = 1; 1958 if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) { 2127 1959 ExitFlag = 255; 2128 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl);1960 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file> --molecule-by-id <molecule_id>" << endl); 2129 1961 performCriticalExit(); 2130 1962 } else { 2131 DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl); 2132 ofstream *output = new ofstream(argv[argptr], ios::trunc); 2133 if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps)) 2134 DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl); 2135 else 2136 DoLog(2) && (Log() << Verbose(2) << "File stored." << endl); 2137 output->close(); 2138 delete(output); 2139 argptr+=1; 2140 } 2141 break; 2142 case 'L': 2143 if (ExitFlag == 0) ExitFlag = 1; 2144 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1963 ArgcList.insert(argptr-1); 1964 ArgcList.insert(argptr); 1965 ArgcList.insert(argptr+1); 1966 ArgcList.insert(argptr+2); 1967 argptr+=3; 1968 } 1969 break; 1970 case 'R': 1971 if (ExitFlag == 0) ExitFlag = 1; 1972 if ((argptr+4 >= argc) || (argv[argptr][0] == '-')) { 2145 1973 ExitFlag = 255; 2146 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -L <step0> <step1> <prefix> <identity mapping?>" << endl);1974 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <distance> --position <x> <y> <z>" << endl); 2147 1975 performCriticalExit(); 2148 1976 } else { 2149 SaveFlag = true; 2150 DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << argv[argptr] << " and " << argv[argptr+1] << "." << endl); 2151 if (atoi(argv[argptr+3]) == 1) 2152 DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl); 2153 if (!mol->LinearInterpolationBetweenConfiguration(atoi(argv[argptr]), atoi(argv[argptr+1]), argv[argptr+2], configuration, atoi(argv[argptr+3])) == 1 ? true : false) 2154 DoLog(2) && (Log() << Verbose(2) << "Could not store " << argv[argptr+2] << " files." << endl); 2155 else 2156 DoLog(2) && (Log() << Verbose(2) << "Steps created and " << argv[argptr+2] << " files stored." << endl); 2157 argptr+=4; 2158 } 2159 break; 2160 case 'P': 2161 if (ExitFlag == 0) ExitFlag = 1; 2162 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1977 ArgcList.insert(argptr-1); 1978 ArgcList.insert(argptr); 1979 ArgcList.insert(argptr+1); 1980 ArgcList.insert(argptr+2); 1981 ArgcList.insert(argptr+3); 1982 ArgcList.insert(argptr+4); 1983 argptr+=5; 1984 } 1985 break; 1986 case 't': 1987 if (ExitFlag == 0) ExitFlag = 1; 1988 if ((argptr+4 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 2163 1989 ExitFlag = 255; 2164 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl);1990 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z> --molecule-by-id <molecule_id> --periodic <0/1>" << endl); 2165 1991 performCriticalExit(); 2166 1992 } else { 2167 SaveFlag = true; 2168 DoLog(1) && (Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl); 2169 if (!mol->VerletForceIntegration(argv[argptr], configuration)) 2170 DoLog(2) && (Log() << Verbose(2) << "File not found." << endl); 2171 else 2172 DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl); 2173 argptr+=1; 2174 } 2175 break; 2176 case 'R': 2177 if (ExitFlag == 0) ExitFlag = 1; 2178 if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) { 2179 ExitFlag = 255; 2180 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl); 2181 performCriticalExit(); 2182 } else { 2183 SaveFlag = true; 2184 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl); 2185 double tmp1 = atof(argv[argptr+1]); 2186 atom *third = mol->FindAtom(atoi(argv[argptr])); 2187 atom *first = mol->start; 2188 if ((third != NULL) && (first != mol->end)) { 2189 atom *second = first->next; 2190 while(second != mol->end) { 2191 first = second; 2192 second = first->next; 2193 if (first->x.DistanceSquared(third->x) > tmp1*tmp1) // distance to first above radius ... 2194 mol->RemoveAtom(first); 2195 } 2196 } else { 2197 DoeLog(1) && (eLog()<< Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl); 2198 } 2199 argptr+=2; 2200 } 2201 break; 2202 case 't': 1993 ArgcList.insert(argptr-1); 1994 ArgcList.insert(argptr); 1995 ArgcList.insert(argptr+1); 1996 ArgcList.insert(argptr+2); 1997 ArgcList.insert(argptr+3); 1998 ArgcList.insert(argptr+4); 1999 ArgcList.insert(argptr+5); 2000 ArgcList.insert(argptr+6); 2001 argptr+=7; 2002 } 2003 break; 2004 case 's': 2203 2005 if (ExitFlag == 0) ExitFlag = 1; 2204 2006 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 2205 ExitFlag = 255;2206 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl);2207 performCriticalExit();2208 } else {2209 if (ExitFlag == 0) ExitFlag = 1;2210 SaveFlag = true;2211 DoLog(1) && (Log() << Verbose(1) << "Translating all ions by given vector." << endl);2212 for (int i=NDIM;i--;)2213 x[i] = atof(argv[argptr+i]);2214 mol->Translate((const Vector *)&x);2215 argptr+=3;2216 }2217 break;2218 case 'T':2219 if (ExitFlag == 0) ExitFlag = 1;2220 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {2221 ExitFlag = 255;2222 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl);2223 performCriticalExit();2224 } else {2225 if (ExitFlag == 0) ExitFlag = 1;2226 SaveFlag = true;2227 DoLog(1) && (Log() << Verbose(1) << "Translating all ions periodically by given vector." << endl);2228 for (int i=NDIM;i--;)2229 x[i] = atof(argv[argptr+i]);2230 mol->TranslatePeriodically((const Vector *)&x);2231 argptr+=3;2232 }2233 break;2234 case 's':2235 if (ExitFlag == 0) ExitFlag = 1;2236 if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {2237 2007 ExitFlag = 255; 2238 2008 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl); 2239 2009 performCriticalExit(); 2240 2010 } else { 2241 SaveFlag = true; 2242 j = -1; 2243 DoLog(1) && (Log() << Verbose(1) << "Scaling all ion positions by factor." << endl); 2244 factor = new double[NDIM]; 2245 factor[0] = atof(argv[argptr]); 2246 factor[1] = atof(argv[argptr+1]); 2247 factor[2] = atof(argv[argptr+2]); 2248 mol->Scale((const double ** const)&factor); 2249 double * const cell_size = World::getInstance().getDomain(); 2250 for (int i=0;i<NDIM;i++) { 2251 j += i+1; 2252 x[i] = atof(argv[NDIM+i]); 2253 cell_size[j]*=factor[i]; 2254 } 2255 delete[](factor); 2011 ArgcList.insert(argptr-1); 2012 ArgcList.insert(argptr); 2013 ArgcList.insert(argptr+1); 2014 ArgcList.insert(argptr+2); 2256 2015 argptr+=3; 2257 2016 } … … 2264 2023 performCriticalExit(); 2265 2024 } else { 2266 SaveFlag = true; 2267 j = -1; 2268 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl); 2269 double * const cell_size = World::getInstance().getDomain(); 2270 for (int i=0;i<6;i++) { 2271 cell_size[i] = atof(argv[argptr+i]); 2272 } 2273 // center 2274 mol->CenterInBox(); 2025 ArgcList.insert(argptr-1); 2026 ArgcList.insert(argptr); 2027 ArgcList.insert(argptr+1); 2028 ArgcList.insert(argptr+2); 2029 ArgcList.insert(argptr+3); 2030 ArgcList.insert(argptr+4); 2031 ArgcList.insert(argptr+5); 2275 2032 argptr+=6; 2276 2033 } … … 2283 2040 performCriticalExit(); 2284 2041 } else { 2285 SaveFlag = true; 2286 j = -1; 2287 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl); 2288 double * const cell_size = World::getInstance().getDomain(); 2289 for (int i=0;i<6;i++) { 2290 cell_size[i] = atof(argv[argptr+i]); 2291 } 2292 // center 2293 mol->BoundInBox(); 2042 ArgcList.insert(argptr-1); 2043 ArgcList.insert(argptr); 2044 ArgcList.insert(argptr+1); 2045 ArgcList.insert(argptr+2); 2046 ArgcList.insert(argptr+3); 2047 ArgcList.insert(argptr+4); 2048 ArgcList.insert(argptr+5); 2294 2049 argptr+=6; 2295 2050 } … … 2302 2057 performCriticalExit(); 2303 2058 } else { 2304 SaveFlag = true; 2305 j = -1; 2306 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl); 2307 // make every coordinate positive 2308 mol->CenterEdge(&x); 2309 // update Box of atoms by boundary 2310 mol->SetBoxDimension(&x); 2311 // translate each coordinate by boundary 2312 double * const cell_size = World::getInstance().getDomain(); 2313 j=-1; 2314 for (int i=0;i<NDIM;i++) { 2315 j += i+1; 2316 x[i] = atof(argv[argptr+i]); 2317 cell_size[j] += x[i]*2.; 2318 } 2319 mol->Translate((const Vector *)&x); 2059 ArgcList.insert(argptr-1); 2060 ArgcList.insert(argptr); 2061 ArgcList.insert(argptr+1); 2062 ArgcList.insert(argptr+2); 2320 2063 argptr+=3; 2321 2064 } … … 2323 2066 case 'O': 2324 2067 if (ExitFlag == 0) ExitFlag = 1; 2325 SaveFlag = true; 2326 DoLog(1) && (Log() << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl); 2327 x.Zero(); 2328 mol->CenterEdge(&x); 2329 mol->SetBoxDimension(&x); 2068 ArgcList.insert(argptr-1); 2330 2069 argptr+=0; 2331 2070 break; … … 2337 2076 performCriticalExit(); 2338 2077 } else { 2339 SaveFlag = true; 2340 DoLog(1) && (Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl); 2341 atom *first = mol->FindAtom(atoi(argv[argptr])); 2342 mol->RemoveAtom(first); 2078 ArgcList.insert(argptr-1); 2079 ArgcList.insert(argptr); 2343 2080 argptr+=1; 2344 2081 } … … 2346 2083 case 'f': 2347 2084 if (ExitFlag == 0) ExitFlag = 1; 2348 if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {2085 if ((argptr+1 >= argc) || (argv[argptr][0] == '-')) { 2349 2086 ExitFlag = 255; 2350 2087 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl); 2351 2088 performCriticalExit(); 2352 2089 } else { 2353 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl); 2354 DoLog(0) && (Log() << Verbose(0) << "Creating connection matrix..." << endl); 2355 start = clock(); 2356 mol->CreateAdjacencyList(atof(argv[argptr]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 2357 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl); 2358 if (mol->first->next != mol->last) { 2359 ExitFlag = mol->FragmentMolecule(atoi(argv[argptr+1]), &configuration); 2360 } 2361 end = clock(); 2362 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl); 2363 argptr+=2; 2090 ArgcList.insert(argptr-1); 2091 ArgcList.insert(argptr); 2092 ArgcList.insert(argptr+1); 2093 ArgcList.insert(argptr+2); 2094 ArgcList.insert(argptr+3); 2095 ArgcList.insert(argptr+4); 2096 argptr+=5; 2364 2097 } 2365 2098 break; … … 2374 2107 SaveFlag = true; 2375 2108 DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl); 2109 mol->PrincipalAxisSystem((bool)j); 2376 2110 } else 2377 DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);2378 mol->PrincipalAxisSystem((bool)j);2111 ArgcList.insert(argptr-1); 2112 argptr+=0; 2379 2113 break; 2380 2114 case 'o': 2381 2115 if (ExitFlag == 0) ExitFlag = 1; 2382 if ((argptr+ 1>= argc) || (argv[argptr][0] == '-')){2116 if ((argptr+4 >= argc) || (argv[argptr][0] == '-')){ 2383 2117 ExitFlag = 255; 2384 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o < convex output file> <non-convexoutput file>" << endl);2118 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <molecule_id> --output-file <output file> --output-file <binned output file>" << endl); 2385 2119 performCriticalExit(); 2386 2120 } else { 2387 class Tesselation *TesselStruct = NULL; 2388 const LinkedCell *LCList = NULL; 2389 DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope."); 2390 DoLog(1) && (Log() << Verbose(1) << "Storing tecplot convex data in " << argv[argptr] << "." << endl); 2391 DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << argv[argptr+1] << "." << endl); 2392 LCList = new LinkedCell(mol, 10.); 2393 //FindConvexBorder(mol, LCList, argv[argptr]); 2394 FindNonConvexBorder(mol, TesselStruct, LCList, 5., argv[argptr+1]); 2395 // RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]); 2396 double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, argv[argptr]); 2397 double clustervolume = VolumeOfConvexEnvelope(TesselStruct, &configuration); 2398 DoLog(0) && (Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl); 2399 DoLog(0) && (Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl); 2400 delete(TesselStruct); 2401 delete(LCList); 2402 argptr+=2; 2121 ArgcList.insert(argptr-1); 2122 ArgcList.insert(argptr); 2123 ArgcList.insert(argptr+1); 2124 ArgcList.insert(argptr+2); 2125 ArgcList.insert(argptr+3); 2126 ArgcList.insert(argptr+4); 2127 argptr+=5; 2403 2128 } 2404 2129 break; … … 2421 2146 performCriticalExit(); 2422 2147 } else { 2423 double density; 2424 SaveFlag = true; 2425 DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water."); 2426 density = atof(argv[argptr++]); 2427 if (density < 1.0) { 2428 DoeLog(1) && (eLog()<< Verbose(1) << "Density must be greater than 1.0g/cm^3 !" << endl); 2429 density = 1.3; 2430 } 2431 // for(int i=0;i<NDIM;i++) { 2432 // repetition[i] = atoi(argv[argptr++]); 2433 // if (repetition[i] < 1) 2434 // DoeLog(1) && (eLog()<< Verbose(1) << "repetition value must be greater 1!" << endl); 2435 // repetition[i] = 1; 2436 // } 2437 PrepareClustersinWater(&configuration, mol, volume, density); // if volume == 0, will calculate from ConvexEnvelope 2148 ArgcList.insert(argptr-1); 2149 ArgcList.insert(argptr); 2150 argptr+=1; 2438 2151 } 2439 2152 break; … … 2445 2158 performCriticalExit(); 2446 2159 } else { 2447 SaveFlag = true; 2448 double * const cell_size = World::getInstance().getDomain(); 2449 for (int axis = 1; axis <= NDIM; axis++) { 2450 int faktor = atoi(argv[argptr++]); 2451 int count; 2452 const element ** Elements; 2453 Vector ** vectors; 2454 if (faktor < 1) { 2455 DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor mus be greater than 1!" << endl); 2456 faktor = 1; 2457 } 2458 mol->CountAtoms(); // recount atoms 2459 if (mol->AtomCount != 0) { // if there is more than none 2460 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand 2461 Elements = new const element *[count]; 2462 vectors = new Vector *[count]; 2463 j = 0; 2464 first = mol->start; 2465 while (first->next != mol->end) { // make a list of all atoms with coordinates and element 2466 first = first->next; 2467 Elements[j] = first->type; 2468 vectors[j] = &first->x; 2469 j++; 2470 } 2471 if (count != j) 2472 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl); 2473 x.Zero(); 2474 y.Zero(); 2475 y[abs(axis)-1] = cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude 2476 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times 2477 x += y; // per factor one cell width further 2478 for (int k=count;k--;) { // go through every atom of the original cell 2479 first = World::getInstance().createAtom(); // create a new body 2480 first->x = (*vectors[k]) + x; 2481 first->type = Elements[k]; // insert original element 2482 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 2483 } 2484 } 2485 // free memory 2486 delete[](Elements); 2487 delete[](vectors); 2488 // correct cell size 2489 if (axis < 0) { // if sign was negative, we have to translate everything 2490 x =(-(faktor-1)) * y; 2491 mol->Translate(&x); 2492 } 2493 cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor; 2494 } 2495 } 2160 ArgcList.insert(argptr-1); 2161 ArgcList.insert(argptr); 2162 ArgcList.insert(argptr+1); 2163 ArgcList.insert(argptr+2); 2164 argptr+=3; 2496 2165 } 2497 2166 break; … … 2505 2174 } while (argptr < argc); 2506 2175 if (SaveFlag) 2507 configuration.SaveAll( ConfigFileName, periode, molecules);2176 configuration.SaveAll(*ConfigFileName, periode, molecules); 2508 2177 } else { // no arguments, hence scan the elements db 2509 2178 if (periode->LoadPeriodentafel(configuration.databasepath)) … … 2516 2185 }; 2517 2186 2518 /***************************************** Functions used to build all menus **********************/2519 2520 void populateEditMoleculesMenu(Menu* editMoleculesMenu,MoleculeListClass *molecules, config *configuration, periodentafel *periode){2521 // build the EditMoleculesMenu2522 Action *createMoleculeAction = new MethodAction("createMoleculeAction",boost::bind(&MoleculeListClass::createNewMolecule,molecules,periode));2523 new ActionMenuItem('c',"create new molecule",editMoleculesMenu,createMoleculeAction);2524 2525 Action *loadMoleculeAction = new MethodAction("loadMoleculeAction",boost::bind(&MoleculeListClass::loadFromXYZ,molecules,periode));2526 new ActionMenuItem('l',"load molecule from xyz file",editMoleculesMenu,loadMoleculeAction);2527 2528 Action *changeFilenameAction = new ChangeMoleculeNameAction(molecules);2529 new ActionMenuItem('n',"change molecule's name",editMoleculesMenu,changeFilenameAction);2530 2531 Action *giveFilenameAction = new MethodAction("giveFilenameAction",boost::bind(&MoleculeListClass::setMoleculeFilename,molecules));2532 new ActionMenuItem('N',"give molecules filename",editMoleculesMenu,giveFilenameAction);2533 2534 Action *parseAtomsAction = new MethodAction("parseAtomsAction",boost::bind(&MoleculeListClass::parseXYZIntoMolecule,molecules));2535 new ActionMenuItem('p',"parse atoms in xyz file into molecule",editMoleculesMenu,parseAtomsAction);2536 2537 Action *eraseMoleculeAction = new MethodAction("eraseMoleculeAction",boost::bind(&MoleculeListClass::eraseMolecule,molecules));2538 new ActionMenuItem('r',"remove a molecule",editMoleculesMenu,eraseMoleculeAction);2539 2540 }2541 2542 2543 2187 /********************************************** Main routine **************************************/ 2544 2188 2545 void cleanUp(config *configuration){ 2546 UIFactory::purgeInstance(); 2189 void cleanUp(){ 2547 2190 World::purgeInstance(); 2548 delete(configuration);2549 Log() << Verbose(0) << "Maximum of allocated memory: "2550 << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl;2551 Log() << Verbose(0) << "Remaining non-freed memory: "2552 << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;2553 MemoryUsageObserver::purgeInstance();2554 2191 logger::purgeInstance(); 2555 2192 errorLogger::purgeInstance(); 2193 UIFactory::purgeInstance(); 2194 MapOfActions::purgeInstance(); 2195 CommandLineParser::purgeInstance(); 2556 2196 ActionRegistry::purgeInstance(); 2557 2197 ActionHistory::purgeInstance(); 2198 #ifdef LOG_OBSERVER 2199 cout << observerLog().getLog(); 2200 #endif 2558 2201 Memory::getState(); 2559 2202 } … … 2561 2204 int main(int argc, char **argv) 2562 2205 { 2206 config *configuration = World::getInstance().getConfig(); 2207 // while we are non interactive, we want to abort from asserts 2208 //ASSERT_DO(Assert::Abort); 2563 2209 molecule *mol = NULL; 2564 config *configuration = new config;2565 2210 Vector x, y, z, n; 2566 2211 ifstream test; 2567 2212 ofstream output; 2568 2213 string line; 2569 char *ConfigFileName = NULL; 2570 int j; 2571 2214 char **Arguments = NULL; 2215 int ArgcSize = 0; 2216 int ExitFlag = 0; 2217 bool ArgumentsCopied = false; 2218 char *ConfigFileName = new char[MAXSTRINGSIZE]; 2219 2220 // print version check whether arguments are present at all 2572 2221 cout << ESPACKVersion << endl; 2222 if (argc < 2) { 2223 cout << "Obtain help with " << argv[0] << " -h." << endl; 2224 cleanUp(); 2225 Memory::getState(); 2226 return(1); 2227 } 2228 2573 2229 2574 2230 setVerbosity(0); 2575 2231 // need to init the history before any action is created 2576 2232 ActionHistory::init(); 2577 /* structure of ParseCommandLineOptions will be refactored later */ 2578 j = ParseCommandLineOptions(argc, argv, World::getInstance().getMolecules(), World::getInstance().getPeriode(), *configuration, ConfigFileName); 2579 switch (j){ 2580 case 255: 2581 case 2: 2582 case 1: 2583 cleanUp(configuration); 2584 return (j == 1 ? 0 : j); 2585 default: 2586 break; 2233 2234 // In the interactive mode, we can leave the user the choice in case of error 2235 ASSERT_DO(Assert::Ask); 2236 2237 // from this moment on, we need to be sure to deeinitialize in the correct order 2238 // this is handled by the cleanup function 2239 atexit(cleanUp); 2240 2241 // Parse command line options and if present create respective UI 2242 { 2243 set<int> ArgcList; 2244 ArgcList.insert(0); // push back program! 2245 ArgcList.insert(1); // push back config file name 2246 // handle arguments by ParseCommandLineOptions() 2247 ExitFlag = ParseCommandLineOptions(argc,argv,World::getInstance().getMolecules(),World::getInstance().getPeriode(),*World::getInstance().getConfig(), &ConfigFileName, ArgcList); 2248 World::getInstance().setExitFlag(ExitFlag); 2249 // copy all remaining arguments to a new argv 2250 Arguments = new char *[ArgcList.size()]; 2251 cout << "The following arguments are handled by CommandLineParser: "; 2252 for (set<int>::iterator ArgcRunner = ArgcList.begin(); ArgcRunner != ArgcList.end(); ++ArgcRunner) { 2253 Arguments[ArgcSize] = new char[strlen(argv[*ArgcRunner])+2]; 2254 strcpy(Arguments[ArgcSize], argv[*ArgcRunner]); 2255 cout << " " << argv[*ArgcRunner]; 2256 ArgcSize++; 2257 } 2258 cout << endl; 2259 ArgumentsCopied = true; 2260 // handle remaining arguments by CommandLineParser 2261 MapOfActions::getInstance().AddOptionsToParser(); 2262 map <std::string, std::string> ShortFormToActionMap = MapOfActions::getInstance().getShortFormToActionMap(); 2263 CommandLineParser::getInstance().Run(ArgcSize,Arguments, ShortFormToActionMap); 2264 if (!CommandLineParser::getInstance().isEmpty()) { 2265 DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl); 2266 UIFactory::registerFactory(new CommandLineUIFactory::description()); 2267 UIFactory::makeUserInterface("CommandLine"); 2268 } else { 2269 #ifdef USE_GUI_QT 2270 DoLog(0) && (Log() << Verbose(0) << "Setting UI to QT4." << endl); 2271 UIFactory::registerFactory(new QTUIFactory::description()); 2272 UIFactory::makeUserInterface("QT4"); 2273 #else 2274 DoLog(0) && (Log() << Verbose(0) << "Setting UI to Text." << endl); 2275 cout << ESPACKVersion << endl; 2276 UIFactory::registerFactory(new TextUIFactory::description()); 2277 UIFactory::makeUserInterface("Text"); 2278 #endif 2279 } 2587 2280 } 2588 if(World::getInstance().numMolecules() == 0){2589 mol = World::getInstance().createMolecule();2590 World::getInstance().getMolecules()->insert(mol);2591 if(World::getInstance().getDomain()[0] == 0.){2592 Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl;2593 for(int i = 0;i < 6;i++){2594 Log() << Verbose(1) << "Cell size" << i << ": ";2595 cin >> World::getInstance().getDomain()[i];2596 }2597 }2598 mol->ActiveFlag = true;2599 }2600 2281 2601 2282 { 2602 setVerbosity(0); 2603 2604 menuPopulaters populaters; 2605 populaters.MakeEditMoleculesMenu = populateEditMoleculesMenu; 2606 2607 UIFactory::registerFactory(new TextUIFactory::description()); 2608 #ifdef USE_GUI_QT 2609 UIFactory::registerFactory(new QTUIFactory::description()); 2610 UIFactory::makeUserInterface("QT4"); 2611 #else 2612 cout << ESPACKVersion << endl; 2613 UIFactory::makeUserInterface("Text"); 2614 #endif 2615 2616 2617 MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow(populaters,World::getInstance().getMolecules(), configuration, World::getInstance().getPeriode(), ConfigFileName); 2283 MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow(); 2618 2284 mainWindow->display(); 2619 2620 2285 delete mainWindow; 2621 2286 } 2622 2287 2623 if(World::getInstance().getPeriode()->StorePeriodentafel(configuration->databasepath)) 2624 Log() << Verbose(0) << "Saving of elements.db successful." << endl; 2625 2626 else 2627 Log() << Verbose(0) << "Saving of elements.db failed." << endl; 2628 2629 cleanUp(configuration); 2630 2631 return (0); 2288 Log() << Verbose(0) << "Saving to " << ConfigFileName << "." << endl; 2289 World::getInstance().getConfig()->SaveAll(ConfigFileName, World::getInstance().getPeriode(), World::getInstance().getMolecules()); 2290 2291 // free the new argv 2292 if (ArgumentsCopied) { 2293 for (int i=0; i<ArgcSize;i++) 2294 delete[](Arguments[i]); 2295 delete[](Arguments); 2296 } 2297 delete[](ConfigFileName); 2298 2299 ExitFlag = World::getInstance().getExitFlag(); 2300 return (ExitFlag == 1 ? 0 : ExitFlag); 2632 2301 } 2633 2302 -
src/config.cpp
r992fd7 r257c77 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 #include <stdio.h> … … 14 16 #include "element.hpp" 15 17 #include "helpers.hpp" 18 #include "info.hpp" 16 19 #include "lists.hpp" 17 20 #include "log.hpp" … … 93 96 return; 94 97 } else 95 buffer = Malloc<char*>(NoLines, "ConfigFileBuffer::ConfigFileBuffer: **buffer");98 buffer = new char *[NoLines]; 96 99 97 100 // scan each line and put into buffer … … 99 102 int i; 100 103 do { 101 buffer[lines] = Malloc<char>(MAXSTRINGSIZE, "ConfigFileBuffer::ConfigFileBuffer: *buffer[]");104 buffer[lines] = new char[MAXSTRINGSIZE]; 102 105 file->getline(buffer[lines], MAXSTRINGSIZE-1); 103 106 i = strlen(buffer[lines]); … … 119 122 { 120 123 for(int i=0;i<NoLines;++i) 121 Free(&buffer[i]);122 Free(&buffer);123 Free(&LineMapping);124 delete[](buffer[i]); 125 delete[](buffer); 126 delete[](LineMapping); 124 127 } 125 128 … … 129 132 void ConfigFileBuffer::InitMapping() 130 133 { 131 LineMapping = Malloc<int>(NoLines, "ConfigFileBuffer::InitMapping: *LineMapping");134 LineMapping = new int[NoLines]; 132 135 for (int i=0;i<NoLines;i++) 133 136 LineMapping[i] = i; … … 179 182 MaxLevel(5), RiemannTensor(0), LevRFactor(0), RiemannLevel(0), Lev0Factor(2), RTActualUse(0), AddPsis(0), RCut(20.), StructOpt(0), IsAngstroem(1), RelativeCoord(0), 180 183 MaxTypes(0) { 181 mainname = Malloc<char>(MAXSTRINGSIZE,"config constructor: mainname");182 defaultpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: defaultpath");183 pseudopotpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: pseudopotpath");184 databasepath = Malloc<char>(MAXSTRINGSIZE,"config constructor: databasepath");185 configpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: configpath");186 configname = Malloc<char>(MAXSTRINGSIZE,"config constructor: configname");184 mainname = new char[MAXSTRINGSIZE]; 185 defaultpath = new char[MAXSTRINGSIZE]; 186 pseudopotpath = new char[MAXSTRINGSIZE]; 187 databasepath = new char[MAXSTRINGSIZE]; 188 configpath = new char[MAXSTRINGSIZE]; 189 configname = new char[MAXSTRINGSIZE]; 187 190 strcpy(mainname,"pcp"); 188 191 strcpy(defaultpath,"not specified"); … … 199 202 config::~config() 200 203 { 201 Free(&mainname);202 Free(&defaultpath);203 Free(&pseudopotpath);204 Free(&databasepath);205 Free(&configpath);206 Free(&configname);207 Free(&ThermostatImplemented);204 delete[](mainname); 205 delete[](defaultpath); 206 delete[](pseudopotpath); 207 delete[](databasepath); 208 delete[](configpath); 209 delete[](configname); 210 delete[](ThermostatImplemented); 208 211 for (int j=0;j<MaxThermostats;j++) 209 Free(&ThermostatNames[j]);210 Free(&ThermostatNames);212 delete[](ThermostatNames[j]); 213 delete[](ThermostatNames); 211 214 212 215 if (BG != NULL) … … 218 221 void config::InitThermostats() 219 222 { 220 ThermostatImplemented = Malloc<int>(MaxThermostats, "config constructor: *ThermostatImplemented");221 ThermostatNames = Malloc<char*>(MaxThermostats, "config constructor: *ThermostatNames");223 ThermostatImplemented = new int[MaxThermostats]; 224 ThermostatNames = new char *[MaxThermostats]; 222 225 for (int j=0;j<MaxThermostats;j++) 223 ThermostatNames[j] = Malloc<char>(12, "config constructor: ThermostatNames[]");226 ThermostatNames[j] = new char[12]; 224 227 225 228 strcpy(ThermostatNames[0],"None"); … … 242 245 void config::ParseThermostats(class ConfigFileBuffer * const fb) 243 246 { 244 char * const thermo = Malloc<char>(12, "IonsInitRead: thermo");247 char * const thermo = new char[12]; 245 248 const int verbose = 0; 246 249 … … 309 312 Thermostat = None; 310 313 } 311 Free(thermo);314 delete[](thermo); 312 315 }; 313 316 … … 1547 1550 int AtomNo = -1; 1548 1551 int MolNo = 0; 1549 atom *Walker = NULL;1550 1552 FILE *f = NULL; 1551 1553 … … 1560 1562 fprintf(f, "# Created by MoleCuilder\n"); 1561 1563 1562 for (MoleculeList::const_iterator Runner = MolList->ListOfMolecules.begin(); Runner != MolList->ListOfMolecules.end(); Runner++) { 1563 Walker = (*Runner)->start; 1564 int *elementNo = Calloc<int>(MAX_ELEMENTS, "config::SavePDB - elementNo"); 1564 for (MoleculeList::const_iterator MolRunner = MolList->ListOfMolecules.begin(); MolRunner != MolList->ListOfMolecules.end(); MolRunner++) { 1565 int *elementNo = new int[MAX_ELEMENTS]; 1566 for (int i=0;i<MAX_ELEMENTS;i++) 1567 elementNo[i] = 0; 1565 1568 AtomNo = 0; 1566 while (Walker->next != (*Runner)->end) { 1567 Walker = Walker->next; 1568 sprintf(name, "%2s%2d",Walker->type->symbol, elementNo[Walker->type->Z]); 1569 elementNo[Walker->type->Z] = (elementNo[Walker->type->Z]+1) % 100; // confine to two digits 1569 for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) { 1570 sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]); 1571 elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100; // confine to two digits 1570 1572 fprintf(f, 1571 1573 "ATOM %6u %-4s %4s%c%4u %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%2s\n", 1572 Walker->nr, /* atom serial number */1574 (*iter)->nr, /* atom serial number */ 1573 1575 name, /* atom name */ 1574 (* Runner)->name, /* residue name */1576 (*MolRunner)->name, /* residue name */ 1575 1577 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1576 1578 MolNo, /* residue sequence number */ 1577 Walker->node->at(0), /* position X in Angstroem */1578 Walker->node->at(1), /* position Y in Angstroem */1579 Walker->node->at(2), /* position Z in Angstroem */1580 (double) Walker->type->Valence, /* occupancy */1581 (double) Walker->type->NoValenceOrbitals, /* temperature factor */1579 (*iter)->node->at(0), /* position X in Angstroem */ 1580 (*iter)->node->at(1), /* position Y in Angstroem */ 1581 (*iter)->node->at(2), /* position Z in Angstroem */ 1582 (double)(*iter)->type->Valence, /* occupancy */ 1583 (double)(*iter)->type->NoValenceOrbitals, /* temperature factor */ 1582 1584 "0", /* segment identifier */ 1583 Walker->type->symbol, /* element symbol */1585 (*iter)->type->symbol, /* element symbol */ 1584 1586 "0"); /* charge */ 1585 1587 AtomNo++; 1586 1588 } 1587 Free(&elementNo);1589 delete[](elementNo); 1588 1590 MolNo++; 1589 1591 } … … 1601 1603 { 1602 1604 int AtomNo = -1; 1603 atom *Walker = NULL;1604 1605 FILE *f = NULL; 1605 1606 1606 int *elementNo = Calloc<int>(MAX_ELEMENTS, "config::SavePDB - elementNo"); 1607 int *elementNo = new int[MAX_ELEMENTS]; 1608 for (int i=0;i<MAX_ELEMENTS;i++) 1609 elementNo[i] = 0; 1607 1610 char name[MAXSTRINGSIZE]; 1608 1611 strncpy(name, filename, MAXSTRINGSIZE-1); … … 1611 1614 if (f == NULL) { 1612 1615 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl); 1613 Free(&elementNo);1616 delete[](elementNo); 1614 1617 return false; 1615 1618 } 1616 1619 fprintf(f, "# Created by MoleCuilder\n"); 1617 1620 1618 Walker = mol->start;1619 1621 AtomNo = 0; 1620 while (Walker->next != mol->end) { 1621 Walker = Walker->next; 1622 sprintf(name, "%2s%2d",Walker->type->symbol, elementNo[Walker->type->Z]); 1623 elementNo[Walker->type->Z] = (elementNo[Walker->type->Z]+1) % 100; // confine to two digits 1622 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1623 sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]); 1624 elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100; // confine to two digits 1624 1625 fprintf(f, 1625 1626 "ATOM %6u %-4s %4s%c%4u %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%2s\n", 1626 Walker->nr, /* atom serial number */1627 (*iter)->nr, /* atom serial number */ 1627 1628 name, /* atom name */ 1628 1629 mol->name, /* residue name */ 1629 1630 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1630 1631 0, /* residue sequence number */ 1631 Walker->node->at(0), /* position X in Angstroem */1632 Walker->node->at(1), /* position Y in Angstroem */1633 Walker->node->at(2), /* position Z in Angstroem */1634 (double) Walker->type->Valence, /* occupancy */1635 (double) Walker->type->NoValenceOrbitals, /* temperature factor */1632 (*iter)->node->at(0), /* position X in Angstroem */ 1633 (*iter)->node->at(1), /* position Y in Angstroem */ 1634 (*iter)->node->at(2), /* position Z in Angstroem */ 1635 (double)(*iter)->type->Valence, /* occupancy */ 1636 (double)(*iter)->type->NoValenceOrbitals, /* temperature factor */ 1636 1637 "0", /* segment identifier */ 1637 Walker->type->symbol, /* element symbol */1638 (*iter)->type->symbol, /* element symbol */ 1638 1639 "0"); /* charge */ 1639 1640 AtomNo++; 1640 1641 } 1641 1642 fclose(f); 1642 Free(&elementNo);1643 delete[](elementNo); 1643 1644 1644 1645 return true; … … 1653 1654 bool config::SaveTREMOLO(const char * const filename, const molecule * const mol) const 1654 1655 { 1655 atom *Walker = NULL;1656 1656 ofstream *output = NULL; 1657 1657 stringstream * const fname = new stringstream; … … 1666 1666 1667 1667 // scan maximum number of neighbours 1668 Walker = mol->start;1669 1668 int MaxNeighbours = 0; 1670 while (Walker->next != mol->end) { 1671 Walker = Walker->next; 1672 const int count = Walker->ListOfBonds.size(); 1669 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1670 const int count = (*iter)->ListOfBonds.size(); 1673 1671 if (MaxNeighbours < count) 1674 1672 MaxNeighbours = count; 1675 1673 } 1676 *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl; 1677 1678 Walker = mol->start; 1679 while (Walker->next != mol->end) { 1680 Walker = Walker->next; 1681 *output << Walker->nr << "\t"; 1682 *output << Walker->getName() << "\t"; 1674 *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl; 1675 1676 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1677 *output << (*iter)->nr << "\t"; 1678 *output << (*iter)->getName() << "\t"; 1683 1679 *output << mol->name << "\t"; 1684 1680 *output << 0 << "\t"; 1685 *output << Walker->node->at(0) << "\t" << Walker->node->at(1) << "\t" << Walker->node->at(2) << "\t";1686 *output << static_cast<double>( Walker->type->Valence) << "\t";1687 *output << Walker->type->symbol << "\t";1688 for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)1689 *output << (*runner)->GetOtherAtom( Walker)->nr << "\t";1690 for(int i= Walker->ListOfBonds.size(); i < MaxNeighbours; i++)1681 *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t"; 1682 *output << static_cast<double>((*iter)->type->Valence) << "\t"; 1683 *output << (*iter)->type->symbol << "\t"; 1684 for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++) 1685 *output << (*runner)->GetOtherAtom(*iter)->nr << "\t"; 1686 for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++) 1691 1687 *output << "-\t"; 1692 1688 *output << endl; … … 1708 1704 bool config::SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const 1709 1705 { 1710 atom *Walker = NULL;1706 Info FunctionInfo(__func__); 1711 1707 ofstream *output = NULL; 1712 1708 stringstream * const fname = new stringstream; … … 1723 1719 int MaxNeighbours = 0; 1724 1720 for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) { 1725 Walker = (*MolWalker)->start; 1726 while (Walker->next != (*MolWalker)->end) { 1727 Walker = Walker->next; 1728 const int count = Walker->ListOfBonds.size(); 1721 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 1722 const int count = (*iter)->ListOfBonds.size(); 1729 1723 if (MaxNeighbours < count) 1730 1724 MaxNeighbours = count; 1731 1725 } 1732 1726 } 1733 *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl;1727 *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl; 1734 1728 1735 1729 // create global to local id map 1736 int **LocalNotoGlobalNoMap = Calloc<int *>(MolList->ListOfMolecules.size(), "config::SaveTREMOLO - **LocalNotoGlobalNoMap");1730 map<int, int> LocalNotoGlobalNoMap; 1737 1731 { 1738 int MolCounter = 0;1739 int AtomNo = 0;1732 unsigned int MolCounter = 0; 1733 int AtomNo = 1; 1740 1734 for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) { 1741 LocalNotoGlobalNoMap[MolCounter] = Calloc<int>(MolList->CountAllAtoms(), "config::SaveTREMOLO - *LocalNotoGlobalNoMap[]"); 1742 1743 (*MolWalker)->SetIndexedArrayForEachAtomTo( LocalNotoGlobalNoMap[MolCounter], &atom::nr, IncrementalAbsoluteValue, &AtomNo); 1744 1735 for(molecule::iterator AtomRunner = (*MolWalker)->begin(); AtomRunner != (*MolWalker)->end(); ++AtomRunner) { 1736 LocalNotoGlobalNoMap.insert( pair<int,int>((*AtomRunner)->getId(), AtomNo++) ); 1737 } 1745 1738 MolCounter++; 1746 1739 } 1740 ASSERT(MolCounter == MolList->ListOfMolecules.size(), "SaveTREMOLO: LocalNotoGlobalNoMap[] has not been correctly initialized for each molecule"); 1747 1741 } 1748 1742 … … 1752 1746 int AtomNo = 0; 1753 1747 for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) { 1754 Walker = (*MolWalker)->start; 1755 while (Walker->next != (*MolWalker)->end) { 1756 Walker = Walker->next; 1757 *output << AtomNo+1 << "\t"; 1758 *output << Walker->getName() << "\t"; 1748 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 1749 *output << LocalNotoGlobalNoMap[ (*iter)->getId() ] << "\t"; 1750 *output << (*iter)->getName() << "\t"; 1759 1751 *output << (*MolWalker)->name << "\t"; 1760 1752 *output << MolCounter+1 << "\t"; 1761 *output << Walker->node->at(0) << "\t" << Walker->node->at(1) << "\t" << Walker->node->at(2) << "\t";1762 *output << (double) Walker->type->Valence << "\t";1763 *output << Walker->type->symbol << "\t";1764 for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)1765 *output << LocalNotoGlobalNoMap[ MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ]+1<< "\t";1766 for(int i= Walker->ListOfBonds.size(); i < MaxNeighbours; i++)1753 *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t"; 1754 *output << (double)(*iter)->type->Valence << "\t"; 1755 *output << (*iter)->type->symbol << "\t"; 1756 for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++) 1757 *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t"; 1758 for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++) 1767 1759 *output << "-\t"; 1768 1760 *output << endl; … … 1778 1770 delete(output); 1779 1771 delete(fname); 1780 for(size_t i=0;i<MolList->ListOfMolecules.size(); i++)1781 Free(&LocalNotoGlobalNoMap[i]);1782 Free(&LocalNotoGlobalNoMap);1783 1772 1784 1773 return true; … … 1808 1797 if (output == NULL) 1809 1798 strcpy(filename,"main_pcp_linux"); 1810 Log() << Verbose(0) << "Saving as pdb input ";1799 Log() << Verbose(0) << "Saving as pdb input ... " << endl; 1811 1800 if (SavePDB(filename, molecules)) 1812 Log() << Verbose(0) << " done." << endl;1801 Log() << Verbose(0) << "\t... done." << endl; 1813 1802 else 1814 Log() << Verbose(0) << " failed." << endl;1803 Log() << Verbose(0) << "\t... failed." << endl; 1815 1804 1816 1805 // then save as tremolo data file … … 1819 1808 if (output == NULL) 1820 1809 strcpy(filename,"main_pcp_linux"); 1821 Log() << Verbose(0) << "Saving as tremolo data input ";1810 Log() << Verbose(0) << "Saving as tremolo data input ... " << endl; 1822 1811 if (SaveTREMOLO(filename, molecules)) 1823 Log() << Verbose(0) << " done." << endl;1812 Log() << Verbose(0) << "\t... done." << endl; 1824 1813 else 1825 Log() << Verbose(0) << " failed." << endl;1814 Log() << Verbose(0) << "\t... failed." << endl; 1826 1815 1827 1816 // translate each to its center and merge all molecules in MoleculeListClass into this molecule … … 1859 1848 output.close(); 1860 1849 output.clear(); 1861 Log() << Verbose(0) << "Saving of config file ";1850 Log() << Verbose(0) << "Saving of config file ... " << endl; 1862 1851 if (Save(filename, periode, mol)) 1863 Log() << Verbose(0) << " successful." << endl;1852 Log() << Verbose(0) << "\t... successful." << endl; 1864 1853 else 1865 Log() << Verbose(0) << " failed." << endl;1854 Log() << Verbose(0) << "\t... failed." << endl; 1866 1855 1867 1856 // and save to xyz file … … 1876 1865 output.open(filename, ios::trunc); 1877 1866 } 1878 Log() << Verbose(0) << "Saving of XYZ file ";1867 Log() << Verbose(0) << "Saving of XYZ file ... " << endl; 1879 1868 if (mol->MDSteps <= 1) { 1880 1869 if (mol->OutputXYZ(&output)) 1881 Log() << Verbose(0) << " successful." << endl;1870 Log() << Verbose(0) << "\t... successful." << endl; 1882 1871 else 1883 Log() << Verbose(0) << " failed." << endl;1872 Log() << Verbose(0) << "\t... failed." << endl; 1884 1873 } else { 1885 1874 if (mol->OutputTrajectoriesXYZ(&output)) 1886 Log() << Verbose(0) << " successful." << endl;1875 Log() << Verbose(0) << "\t... successful." << endl; 1887 1876 else 1888 Log() << Verbose(0) << " failed." << endl;1877 Log() << Verbose(0) << "\t... failed." << endl; 1889 1878 } 1890 1879 output.close(); … … 1896 1885 if (output == NULL) 1897 1886 strcpy(filename,"main_pcp_linux"); 1898 Log() << Verbose(0) << "Saving as mpqc input ";1887 Log() << Verbose(0) << "Saving as mpqc input .. " << endl; 1899 1888 if (SaveMPQC(filename, mol)) 1900 Log() << Verbose(0) << " done." << endl;1889 Log() << Verbose(0) << "\t... done." << endl; 1901 1890 else 1902 Log() << Verbose(0) << " failed." << endl;1891 Log() << Verbose(0) << "\t... failed." << endl; 1903 1892 1904 1893 if (!strcmp(configpath, GetDefaultPath())) { … … 1938 1927 char *dummy1 = NULL; 1939 1928 char *dummy = NULL; 1940 char * const free_dummy = Malloc<char>(256, "config::ParseForParameter: *free_dummy"); // pointers in the line that is read in per step1929 char free_dummy[MAXSTRINGSIZE]; // pointers in the line that is read in per step 1941 1930 dummy1 = free_dummy; 1942 1931 … … 1954 1943 if (file->eof()) { 1955 1944 if ((critical) && (found == 0)) { 1956 Free(free_dummy);1957 1945 //Error(InitReading, name); 1958 1946 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); … … 1962 1950 file->clear(); 1963 1951 file->seekg(file_position, ios::beg); // rewind to start position 1964 Free(free_dummy);1965 1952 return 0; 1966 1953 } … … 1993 1980 dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword) 1994 1981 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name); 1995 //Free((void **)&free_dummy);1996 1982 //Error(FileOpenParams, NULL); 1997 1983 } else { … … 2014 2000 if (file->eof()) { 2015 2001 if ((critical) && (found == 0)) { 2016 Free(free_dummy);2017 2002 //Error(InitReading, name); 2018 2003 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); … … 2022 2007 file->clear(); 2023 2008 file->seekg(file_position, ios::beg); // rewind to start position 2024 Free(free_dummy);2025 2009 return 0; 2026 2010 } … … 2063 2047 if (critical) { 2064 2048 if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name); 2065 Free(free_dummy);2066 2049 //return 0; 2067 2050 exit(255); … … 2071 2054 file->clear(); 2072 2055 file->seekg(file_position, ios::beg); // rewind to start position 2073 Free(free_dummy);2074 2056 return 0; 2075 2057 } … … 2084 2066 file->seekg(file_position, ios::beg); // rewind to start position 2085 2067 } 2086 Free(free_dummy);2087 2068 return 0; 2088 2069 } … … 2140 2121 if ((type >= row_int) && (verbose)) 2141 2122 fprintf(stderr,"\n"); 2142 Free(free_dummy);2143 2123 if (!sequential) { 2144 2124 file->clear(); … … 2221 2201 dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword) 2222 2202 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name); 2223 //Free(&free_dummy);2224 2203 //Error(FileOpenParams, NULL); 2225 2204 } else { -
src/datacreator.cpp
r992fd7 r257c77 6 6 7 7 //============================ INCLUDES =========================== 8 9 #include "Helpers/MemDebug.hpp" 8 10 9 11 #include "datacreator.hpp" -
src/element.cpp
r992fd7 r257c77 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 #include <iomanip> -
src/elements.db
-
Property mode
changed from
100755
to100644
r992fd7 r257c77 2 2 #Element Name Symbol Period Group Block Atomic Number AtomicWeight Covalent Radius vdW Radius 3 3 Hydrogen H 1 1 s 1 1.008 0.23 1.09 4 Helium He 1 18 p 2 4.003 1.5 0 1.404 Helium He 1 18 p 2 4.003 1.5 1.4 5 5 Lithium Li 2 1 s 3 6.941 0.68 1.82 6 Beryllium Be 2 2 s 4 9.012 0.35 2 .007 Boron B 2 13 p 5 10.811 0.83 2 .008 Carbon C 2 14 p 6 12.011 0.68 1.7 06 Beryllium Be 2 2 s 4 9.012 0.35 2 7 Boron B 2 13 p 5 10.811 0.83 2 8 Carbon C 2 14 p 6 12.011 0.68 1.7 9 9 Nitrogen N 2 15 p 7 14.007 0.68 1.55 10 10 Oxygen O 2 16 p 8 15.999 0.68 1.52 11 11 Fluorine F 2 17 p 9 18.998 0.64 1.47 12 Neon Ne 2 18 p 10 20.18 0 1.501.5412 Neon Ne 2 18 p 10 20.18 1.5 1.54 13 13 Sodium Na 3 1 s 11 22.991 0.97 2.27 14 Magnesium Mg 3 2 s 12 24.305 1.1 01.7315 Aluminium Al 3 13 p 13 26.982 1.35 2 .0016 Silicon Si 3 14 p 14 28.086 1.2 0 2.1017 Phosphorus P 3 15 p 15 30.974 1.05 1.8 018 Sulphur S 3 16 p 16 32.066 1.02 1.8 014 Magnesium Mg 3 2 s 12 24.305 1.1 1.73 15 Aluminium Al 3 13 p 13 26.982 1.35 2 16 Silicon Si 3 14 p 14 28.086 1.2 2.1 17 Phosphorus P 3 15 p 15 30.974 1.05 1.8 18 Sulphur S 3 16 p 16 32.066 1.02 1.8 19 19 Chlorine Cl 3 17 p 17 35.453 0.99 1.75 20 20 Argon Ar 3 18 p 18 39.948 1.51 1.88 21 21 Potassium K 4 1 s 19 39.098 1.33 2.75 22 Calcium Ca 4 2 s 20 40.078 0.99 2 .0023 Scandium Sc 4 3 d 21 44.956 1.44 2 .0024 Titanium Ti 4 4 d 22 47.867 1.47 2 .0025 Vanadium V 4 5 d 23 50.942 1.33 2 .0026 Chromium Cr 4 6 d 24 51.996 1.35 2 .0027 Manganese Mn 4 7 d 25 54.938 1.35 2 .0028 Iron Fe 4 8 d 26 55.845 1.34 2 .0029 Cobalt Co 4 9 d 27 58.933 1.33 2 .0030 Nickel Ni 4 10 d 28 58.693 1.5 01.6331 Copper Cu 4 11 d 29 63.546 1.52 1.4 032 Zinc Zn 4 12 d 30 65.39 01.45 1.3922 Calcium Ca 4 2 s 20 40.078 0.99 2 23 Scandium Sc 4 3 d 21 44.956 1.44 2 24 Titanium Ti 4 4 d 22 47.867 1.47 2 25 Vanadium V 4 5 d 23 50.942 1.33 2 26 Chromium Cr 4 6 d 24 51.996 1.35 2 27 Manganese Mn 4 7 d 25 54.938 1.35 2 28 Iron Fe 4 8 d 26 55.845 1.34 2 29 Cobalt Co 4 9 d 27 58.933 1.33 2 30 Nickel Ni 4 10 d 28 58.693 1.5 1.63 31 Copper Cu 4 11 d 29 63.546 1.52 1.4 32 Zinc Zn 4 12 d 30 65.39 1.45 1.39 33 33 Gallium Ga 4 13 p 31 69.723 1.22 1.87 34 Germanium Ge 4 14 p 32 72.61 0 1.17 2.0034 Germanium Ge 4 14 p 32 72.61 1.17 2 35 35 Arsenic As 4 15 p 33 74.922 1.21 1.85 36 Selenium Se 4 16 p 34 78.96 0 1.22 1.9036 Selenium Se 4 16 p 34 78.96 1.22 1.9 37 37 Bromine Br 4 17 p 35 79.904 1.21 1.85 38 Krypton Kr 4 18 p 36 83.8 00 1.502.0239 Rubidium Rb 5 1 s 37 85.468 1.47 2 .0040 Strontium Sr 5 2 s 38 87.62 0 1.12 2.0041 Yttrium Y 5 3 d 39 88.906 1.78 2 .0042 Zirconium Zr 5 4 d 40 91.224 1.56 2 .0043 Niobium Nb 5 5 d 41 92.906 1.48 2 .0044 Molybdenum Mo 5 6 d 42 95.94 0 1.47 2.0045 Technetium Tc 5 7 d 43 98 1.35 2 .0046 Ruthenium Ru 5 8 d 44 101.07 0 1.40 2.0047 Rhodium Rh 5 9 d 45 102.906 1.45 2 .0048 Palladium Pd 5 10 d 46 106.42 0 1.501.6338 Krypton Kr 4 18 p 36 83.8 1.5 2.02 39 Rubidium Rb 5 1 s 37 85.468 1.47 2 40 Strontium Sr 5 2 s 38 87.62 1.12 2 41 Yttrium Y 5 3 d 39 88.906 1.78 2 42 Zirconium Zr 5 4 d 40 91.224 1.56 2 43 Niobium Nb 5 5 d 41 92.906 1.48 2 44 Molybdenum Mo 5 6 d 42 95.94 1.47 2 45 Technetium Tc 5 7 d 43 98 1.35 2 46 Ruthenium Ru 5 8 d 44 101.07 1.4 2 47 Rhodium Rh 5 9 d 45 102.906 1.45 2 48 Palladium Pd 5 10 d 46 106.42 1.5 1.63 49 49 Silver Ag 5 11 d 47 107.868 1.59 1.72 50 50 Cadmium Cd 5 12 d 48 112.411 1.69 1.58 51 51 Indium In 5 13 p 49 114.818 1.63 1.93 52 52 Tin Sn 5 14 p 50 118.71 1.46 2.17 53 Antimony Sb 5 15 p 51 121.760 1.46 2.00 54 Tellurium Te 5 16 p 52 127.600 1.47 2.06 55 Iodine I 5 17 p 53 126.904 1.40 1.98 56 Xenon Xe 5 18 p 54 131.290 1.50 2.16 57 Caesium Cs 6 1 s 55 132.905 1.67 2.00 58 Barium Ba 6 2 s 56 137.327 1.34 2.00 59 Lutetium Lu 6 3 d 71 174.967 1.72 2.00 60 Hafnium Hf 6 4 d 72 178.490 1.57 2.00 61 Tantalum Ta 6 5 d 73 180.948 1.43 2.00 62 Tungsten W 6 6 d 74 183.840 1.37 2.00 63 Rhenium Re 6 7 d 75 186.207 1.35 2.00 64 Osmium Os 6 8 d 76 190.230 1.37 2.00 65 Iridium Ir 6 9 d 77 192.217 1.32 2.00 66 Platinum Pt 6 10 d 78 195.078 1.50 1.72 67 Gold Au 6 11 d 79 196.967 1.50 1.66 68 Mercury Hg 6 12 d 80 200.590 1.70 1.55 53 Antimony Sb 5 15 p 51 121.76 1.46 2 54 Tellurium Te 5 16 p 52 127.6 1.47 2.06 55 Iodine I 5 17 p 53 126.904 1.4 1.98 56 Xenon Xe 5 18 p 54 131.29 1.5 2.16 57 Caesium Cs 6 1 s 55 132.905 1.67 2 58 Barium Ba 6 2 s 56 137.327 1.34 2 59 Lanthanum La 6Lan 19 f 57 138.906 1.87 2 60 Cerium Ce 6Lan 19 f 58 140.116 1.83 2 61 Praseodymium Pr 6Lan 19 f 59 140.908 1.82 2 62 Neodymium Nd 6Lan 19 f 60 144.24 1.81 2 63 Promethium Pm 6Lan 19 f 61 145 1.8 2 64 Samarium Sm 6Lan 19 f 62 150.36 1.8 2 65 Europium Eu 6Lan 19 f 63 151.964 1.99 2 66 Gadolinium Gd 6Lan 19 f 64 157.25 1.79 2 67 Terbium Tb 6Lan 19 f 65 158.925 1.76 2 68 Dysprosium Dy 6Lan 19 f 66 162.5 1.75 2 69 Holmium Ho 6Lan 19 f 67 164.93 1.74 2 70 Erbium Er 6Lan 19 f 68 167.26 1.73 2 71 Thulium Tm 6Lan 19 f 69 168.934 1.72 2 72 Ytterbium Yb 6Lan 19 f 70 173.04 1.94 2 73 Lutetium Lu 6 3 d 71 174.967 1.72 2 74 Hafnium Hf 6 4 d 72 178.49 1.57 2 75 Tantalum Ta 6 5 d 73 180.948 1.43 2 76 Tungsten W 6 6 d 74 183.84 1.37 2 77 Rhenium Re 6 7 d 75 186.207 1.35 2 78 Osmium Os 6 8 d 76 190.23 1.37 2 79 Iridium Ir 6 9 d 77 192.217 1.32 2 80 Platinum Pt 6 10 d 78 195.078 1.5 1.72 81 Gold Au 6 11 d 79 196.967 1.5 1.66 82 Mercury Hg 6 12 d 80 200.59 1.7 1.55 69 83 Thallium Tl 6 13 p 81 204.383 1.55 1.96 70 Lead Pb 6 14 p 82 207.200 1.54 2.02 71 Bismuth Bi 6 15 p 83 208.980 1.54 2.00 72 Polonium Po 6 16 p 84 210 1.68 2.00 73 Astatine At 6 17 p 85 210 1.21 2.00 74 Radon Rn 6 18 p 86 222 1.50 2.00 75 Cerium Ce 6Lan 19 f 58 140.116 1.83 2.00 76 Dysprosium Dy 6Lan 19 f 66 162.500 1.75 2.00 77 Erbium Er 6Lan 19 f 68 167.260 1.73 2.00 78 Europium Eu 6Lan 19 f 63 151.964 1.99 2.00 79 Gadolinium Gd 6Lan 19 f 64 157.250 1.79 2.00 80 Holmium Ho 6Lan 19 f 67 164.930 1.74 2.00 81 Lanthanum La 6Lan 19 f 57 138.906 1.87 2.00 82 Neodymium Nd 6Lan 19 f 60 144.240 1.81 2.00 83 Promethium Pm 6Lan 19 f 61 145 1.80 2.00 84 Praseodymium Pr 6Lan 19 f 59 140.908 1.82 2.00 85 Samarium Sm 6Lan 19 f 62 150.360 1.80 2.00 86 Terbium Tb 6Lan 19 f 65 158.925 1.76 2.00 87 Thulium Tm 6Lan 19 f 69 168.934 1.72 2.00 88 Ytterbium Yb 6Lan 19 f 70 173.040 1.94 2.00 89 Francium Fr 7 1 s 87 223 1.50 2.00 90 Radium Ra 7 2 s 88 226 1.90 2.00 91 Lawrencium Lr 7 3 d 103 262 1.50 2.00 92 Rutherfordium Rf 7 4 d 104 261 1.50 2.00 93 Dubnium Db 7 5 d 105 262 1.50 2.00 94 Seaborgium Sg 7 6 d 106 266 1.50 2.00 95 Bohrium Bh 7 7 d 107 264 1.50 2.00 96 Hassium Hs 7 8 d 108 269 1.50 2.00 97 Meitnerium Mt 7 9 d 109 268 1.50 2.00 98 Darmstadtium Ds 7 10 d 110 271 1.50 2.00 99 Actinium Ac 7Act 20 f 89 227 1.88 2.00 100 Americium Am 7Act 20 f 95 243 1.51 2.00 101 Berkelium Bk 7Act 20 f 97 247 1.54 2.00 102 Californium Cf 7Act 20 f 98 251 1.83 2.00 103 Curium Cm 7Act 20 f 96 247 0.99 2.00 104 Einsteinium Es 7Act 20 f 99 252 1.50 2.00 105 Fermium Fm 7Act 20 f 100 257 1.50 2.00 106 Mendelevium Md 7Act 20 f 101 258 1.50 2.00 107 Nobelium No 7Act 20 f 102 259 1.50 2.00 108 Neptunium Np 7Act 20 f 93 237 1.55 2.00 109 Protactinium Pa 7Act 20 f 91 231.036 1.61 2.00 110 Plutonium Pu 7Act 20 f 94 244 1.53 2.00 111 Thorium Th 7Act 20 f 90 232.038 1.79 2.00 84 Lead Pb 6 14 p 82 207.2 1.54 2.02 85 Bismuth Bi 6 15 p 83 208.98 1.54 2 86 Polonium Po 6 16 p 84 210 1.68 2 87 Astatine At 6 17 p 85 210 1.21 2 88 Radon Rn 6 18 p 86 222 1.5 2 89 Francium Fr 7 1 s 87 223 1.5 2 90 Radium Ra 7 2 s 88 226 1.9 2 91 Actinium Ac 7Act 20 f 89 227 1.88 2 92 Thorium Th 7Act 20 f 90 232.038 1.79 2 93 Protactinium Pa 7Act 20 f 91 231.036 1.61 2 112 94 Uranium U 7Act 20 f 92 238.029 1.58 1.86 95 Neptunium Np 7Act 20 f 93 237 1.55 2 96 Plutonium Pu 7Act 20 f 94 244 1.53 2 97 Americium Am 7Act 20 f 95 243 1.51 2 98 Curium Cm 7Act 20 f 96 247 0.99 2 99 Berkelium Bk 7Act 20 f 97 247 1.54 2 100 Californium Cf 7Act 20 f 98 251 1.83 2 101 Einsteinium Es 7Act 20 f 99 252 1.5 2 102 Fermium Fm 7Act 20 f 100 257 1.5 2 103 Mendelevium Md 7Act 20 f 101 258 1.5 2 104 Nobelium No 7Act 20 f 102 259 1.5 2 105 Lawrencium Lr 7 3 d 103 262 1.5 2 106 Rutherfordium Rf 7 4 d 104 261 1.5 2 107 Dubnium Db 7 5 d 105 262 1.5 2 108 Seaborgium Sg 7 6 d 106 266 1.5 2 109 Bohrium Bh 7 7 d 107 264 1.5 2 110 Hassium Hs 7 8 d 108 269 1.5 2 111 Meitnerium Mt 7 9 d 109 268 1.5 2 112 Darmstadtium Ds 7 10 d 110 271 1.5 2 -
Property mode
changed from
-
src/ellipsoid.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <gsl/gsl_multimin.h> -
src/errorlogger.cpp
r992fd7 r257c77 5 5 * Author: metzler 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <fstream> -
src/graph.cpp
r992fd7 r257c77 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 using namespace std; -
src/gslmatrix.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 using namespace std; -
src/gslvector.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <cassert> -
src/helpers.cpp
r992fd7 r257c77 4 4 */ 5 5 6 #include "Helpers/MemDebug.hpp" 6 7 7 8 #include "helpers.hpp" … … 58 59 int CountLinesinFile(ifstream &InputFile) 59 60 { 60 char *buffer = Malloc<char>(MAXSTRINGSIZE, "CountLinesinFile: *buffer");61 char *buffer = new char[MAXSTRINGSIZE]; 61 62 int lines=0; 62 63 … … 70 71 } 71 72 InputFile.seekg(PositionMarker, ios::beg); 72 Free(&buffer);73 delete[](buffer); 73 74 return lines; 74 75 }; … … 90 91 } 91 92 // allocate string 92 returnstring = Malloc<char>(order + 2, "FixedDigitNumber: *returnstring");93 returnstring = new char[order + 2]; 93 94 // terminate and fill string array from end backward 94 95 returnstring[order] = '\0'; … … 122 123 double * ReturnFullMatrixforSymmetric(const double * const symm) 123 124 { 124 double *matrix = Malloc<double>(NDIM * NDIM, "molecule::ReturnFullMatrixforSymmetric: *matrix");125 double *matrix = new double[NDIM * NDIM]; 125 126 matrix[0] = symm[0]; 126 127 matrix[1] = symm[1]; … … 140 141 double * InverseMatrix( const double * const A) 141 142 { 142 double *B = Malloc<double>(NDIM * NDIM, "Vector::InverseMatrix: *B");143 double *B = new double[NDIM * NDIM]; 143 144 double detA = RDET3(A); 144 145 double detAReci; … … 180 181 181 182 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 183 /** 208 * Frees all memory registered by the memory observer and calls exit(225) afterwards.184 * Calls exit(255). 209 185 */ 210 186 void performCriticalExit() { 211 map<void*, size_t> pointers = MemoryUsageObserver::getInstance()->getPointersToAllocatedMemory();212 for (map<void*, size_t>::iterator runner = pointers.begin(); runner != pointers.end(); runner++) {213 Free(((void**) &runner->first));214 }215 216 187 exit(255); 217 188 } -
src/helpers.hpp
r992fd7 r257c77 97 97 98 98 if (LookupTable != NULL) { 99 Do Log(0) && (Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl);99 DoeLog(0) && (eLog() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl); 100 100 return false; 101 101 } … … 110 110 } 111 111 if (count <= 0) { 112 Do Log(0) && (Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl);112 DoeLog(1) && (eLog() << Verbose(1) << "Count of lookup list is 0 or less." << endl); 113 113 return false; 114 114 } 115 115 116 116 // allocate and fill 117 LookupTable = Calloc<T*>(count, "CreateFatherLookupTable - **LookupTable");117 LookupTable = new T*[count]; 118 118 if (LookupTable == NULL) { 119 119 DoeLog(0) && (eLog()<< Verbose(0) << "LookupTable memory allocation failed!" << endl); … … 129 129 LookupTable[AtomNo] = Walker; 130 130 } else { 131 Do Log(0) && (Log() << Verbose(0) << "Walker " << *Walker << " exceeded range of nuclear ids [0, " << count << ")." << endl);131 DoeLog(2) && (eLog() << Verbose(2) << "Walker " << *Walker << " exceeded range of nuclear ids [0, " << count << ")." << endl); 132 132 status = false; 133 133 break; … … 138 138 return status; 139 139 }; 140 140 141 141 142 /** Frees a two-dimensional array. -
src/info.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "info.hpp" -
src/joiner.cpp
r992fd7 r257c77 7 7 8 8 //============================ INCLUDES =========================== 9 10 #include "Helpers/MemDebug.hpp" 9 11 10 12 #include <cstring> … … 58 60 return 1; 59 61 } else { 60 dir = Malloc<char>(strlen(argv[2]) + 2, "main: *dir");62 dir = new char[strlen(argv[2]) + 2]; 61 63 strcpy(dir, "/"); 62 64 strcat(dir, argv[2]); … … 243 245 // exit 244 246 delete(periode); 245 Free(&dir);247 delete[](dir); 246 248 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 247 249 return 0; -
src/leastsquaremin.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <iostream> -
src/linearsystemofequations.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "defs.hpp" -
src/linkedcell.cpp
r992fd7 r257c77 5 5 */ 6 6 7 #include "Helpers/MemDebug.hpp" 7 8 8 9 #include "atom.hpp" -
src/lists.hpp
r992fd7 r257c77 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/log.cpp
r992fd7 r257c77 5 5 * Author: metzler 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "logger.hpp" -
src/logger.cpp
r992fd7 r257c77 5 5 * Author: metzler 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <fstream> -
src/memoryusageobserver.cpp
r992fd7 r257c77 4 4 * This class represents a Singleton for observing memory usage. 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 #include <cstdlib> -
src/molecule.cpp
r992fd7 r257c77 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 #include <cstring> … … 35 37 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero. 36 38 */ 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), 39 BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.), 40 ActiveFlag(false), IndexNr(-1), 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 50 // init bond chain list 51 link(first,last); 39 molecule::molecule(const periodentafel * const teil) : 40 Observable("molecule"), 41 elemente(teil), MDSteps(0), BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), 42 NoCyclicBonds(0), BondDistance(0.), ActiveFlag(false), IndexNr(-1), 43 formula(this,boost::bind(&molecule::calcFormula,this),"formula"), 44 AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0), InternalPointer(begin()) 45 { 52 46 53 47 // other stuff 54 48 for(int i=MAX_ELEMENTS;i--;) 55 49 ElementsInMolecule[i] = 0; 56 strcpy(name,World::getInstance().getDefaultName() );50 strcpy(name,World::getInstance().getDefaultName().c_str()); 57 51 }; 58 52 … … 67 61 { 68 62 CleanupMolecule(); 69 delete(first);70 delete(last);71 end->getWorld()->destroyAtom(end);72 start->getWorld()->destroyAtom(start);73 63 }; 74 64 … … 81 71 const std::string molecule::getName(){ 82 72 return std::string(name); 73 } 74 75 int molecule::getAtomCount() const{ 76 return *AtomCount; 83 77 } 84 78 … … 104 98 stringstream sstr; 105 99 periodentafel *periode = World::getInstance().getPeriode(); 106 for (atom *Walker = start; Walker != end; Walker = Walker->next) {107 counts[ Walker->type->getNumber()]++;100 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 101 counts[(*iter)->type->getNumber()]++; 108 102 } 109 103 std::map<atomicNumber_t,unsigned int>::reverse_iterator iter; … … 115 109 } 116 110 111 /************************** Access to the List of Atoms ****************/ 112 113 114 molecule::iterator molecule::begin(){ 115 return molecule::iterator(atoms.begin(),this); 116 } 117 118 molecule::const_iterator molecule::begin() const{ 119 return atoms.begin(); 120 } 121 122 molecule::iterator molecule::end(){ 123 return molecule::iterator(atoms.end(),this); 124 } 125 126 molecule::const_iterator molecule::end() const{ 127 return atoms.end(); 128 } 129 130 bool molecule::empty() const 131 { 132 return (begin() == end()); 133 } 134 135 size_t molecule::size() const 136 { 137 size_t counter = 0; 138 for (molecule::const_iterator iter = begin(); iter != end (); ++iter) 139 counter++; 140 return counter; 141 } 142 143 molecule::const_iterator molecule::erase( const_iterator loc ) 144 { 145 molecule::const_iterator iter = loc; 146 iter--; 147 atom* atom = *loc; 148 atoms.erase( loc ); 149 atom->removeFromMolecule(); 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 atoms.erase( iter++ ); 159 key->removeFromMolecule(); 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 } 174 175 bool molecule::containsAtom(atom* key){ 176 return atoms.count(key); 177 } 117 178 118 179 /** Adds given atom \a *pointer from molecule list. … … 123 184 bool molecule::AddAtom(atom *pointer) 124 185 { 125 bool retval = false;126 186 OBSERVE; 127 187 if (pointer != NULL) { 128 188 pointer->sort = &pointer->nr; 129 pointer->nr = last_atom++; // increase number within molecule130 AtomCount++;131 189 if (pointer->type != NULL) { 132 190 if (ElementsInMolecule[pointer->type->Z] == 0) … … 141 199 } 142 200 } 143 retval = add(pointer, end); 144 } 145 return retval; 201 insert(pointer); 202 pointer->setMolecule(this); 203 } 204 return true; 146 205 }; 147 206 … … 157 216 if (pointer != NULL) { 158 217 atom *walker = pointer->clone(); 159 stringstream sstr; 160 sstr << pointer->getName(); 161 walker->setName(sstr.str()); 218 walker->setName(pointer->getName()); 162 219 walker->nr = last_atom++; // increase number within molecule 163 add(walker, end);220 insert(walker); 164 221 if ((pointer->type != NULL) && (pointer->type->Z != 1)) 165 222 NoNonHydrogen++; 166 AtomCount++;167 223 retval=walker; 168 224 } … … 242 298 Orthovector1.MatrixMultiplication(matrix); 243 299 InBondvector -= Orthovector1; // subtract just the additional translation 244 Free(&matrix);300 delete[](matrix); 245 301 bondlength = InBondvector.Norm(); 246 302 // Log() << Verbose(4) << "Corrected InBondvector is now: "; … … 251 307 InBondvector.Normalize(); 252 308 // get typical bond length and store as scale factor for later 309 ASSERT(TopOrigin->type != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given."); 253 310 BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1]; 254 311 if (BondRescale == -1) { … … 472 529 break; 473 530 } 474 Free(&matrix);531 delete[](matrix); 475 532 476 533 // Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl; … … 555 612 556 613 // copy all bonds 557 bond *Binder = first;614 bond *Binder = NULL; 558 615 bond *NewBond = NULL; 559 while(Binder->next != last) { 560 Binder = Binder->next; 561 562 // get the pendant atoms of current bond in the copy molecule 563 copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->leftatom, (const atom **)&LeftAtom ); 564 copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->rightatom, (const atom **)&RightAtom ); 565 566 NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree); 567 NewBond->Cyclic = Binder->Cyclic; 568 if (Binder->Cyclic) 569 copy->NoCyclicBonds++; 570 NewBond->Type = Binder->Type; 571 } 616 for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 617 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin()) 618 if ((*BondRunner)->leftatom == *AtomRunner) { 619 Binder = (*BondRunner); 620 621 // get the pendant atoms of current bond in the copy molecule 622 copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->leftatom, (const atom **)&LeftAtom ); 623 copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->rightatom, (const atom **)&RightAtom ); 624 625 NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree); 626 NewBond->Cyclic = Binder->Cyclic; 627 if (Binder->Cyclic) 628 copy->NoCyclicBonds++; 629 NewBond->Type = Binder->Type; 630 } 572 631 // correct fathers 573 632 ActOnAllAtoms( &atom::CorrectFather ); 574 633 575 634 // copy values 576 copy->CountAtoms();577 635 copy->CountElements(); 578 if ( first->next != last) { // if adjaceny list is present636 if (hasBondStructure()) { // if adjaceny list is present 579 637 copy->BondDistance = BondDistance; 580 638 } … … 608 666 bond * molecule::AddBond(atom *atom1, atom *atom2, int degree) 609 667 { 668 OBSERVE; 610 669 bond *Binder = NULL; 611 if ((atom1 != NULL) && (FindAtom(atom1->nr) != NULL) && (atom2 != NULL) && (FindAtom(atom2->nr) != NULL)) { 612 Binder = new bond(atom1, atom2, degree, BondCount++); 613 atom1->RegisterBond(Binder); 614 atom2->RegisterBond(Binder); 615 if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1)) 616 NoNonBonds++; 617 add(Binder, last); 618 } else { 619 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); 620 } 670 671 // some checks to make sure we are able to create the bond 672 ASSERT(atom1, "First atom in bond-creation was an invalid pointer"); 673 ASSERT(atom2, "Second atom in bond-creation was an invalid pointer"); 674 ASSERT(FindAtom(atom1->nr),"First atom in bond-creation was not part of molecule"); 675 ASSERT(FindAtom(atom2->nr),"Second atom in bond-creation was not parto of molecule"); 676 677 Binder = new bond(atom1, atom2, degree, BondCount++); 678 atom1->RegisterBond(Binder); 679 atom2->RegisterBond(Binder); 680 if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1)) 681 NoNonBonds++; 682 621 683 return Binder; 622 684 }; … … 630 692 { 631 693 //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl); 632 pointer->leftatom->RegisterBond(pointer); 633 pointer->rightatom->RegisterBond(pointer); 634 removewithoutcheck(pointer); 694 delete(pointer); 635 695 return true; 636 696 }; … … 692 752 bool molecule::RemoveAtom(atom *pointer) 693 753 { 754 ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom()."); 755 OBSERVE; 694 756 if (ElementsInMolecule[pointer->type->Z] != 0) { // this would indicate an error 695 757 ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element 696 AtomCount--;697 758 } else 698 759 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); … … 700 761 ElementCount--; 701 762 RemoveBonds(pointer); 702 return remove(pointer, start, end); 763 erase(pointer); 764 return true; 703 765 }; 704 766 … … 717 779 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 718 780 ElementCount--; 719 unlink(pointer);781 erase(pointer); 720 782 return true; 721 783 }; … … 726 788 bool molecule::CleanupMolecule() 727 789 { 728 return (cleanup(first,last) && cleanup(start,end)); 790 for (molecule::iterator iter = begin(); !empty(); iter = begin()) 791 erase(iter); 729 792 }; 730 793 … … 733 796 * \return pointer to atom or NULL 734 797 */ 735 atom * molecule::FindAtom(int Nr) const{ 736 atom * walker = find(&Nr, start,end); 737 if (walker != NULL) { 798 atom * molecule::FindAtom(int Nr) const 799 { 800 molecule::const_iterator iter = begin(); 801 for (; iter != end(); ++iter) 802 if ((*iter)->nr == Nr) 803 break; 804 if (iter != end()) { 738 805 //Log() << Verbose(0) << "Found Atom Nr. " << walker->nr << endl; 739 return walker;806 return (*iter); 740 807 } else { 741 808 DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl); … … 867 934 now = time((time_t *)NULL); // Get the system time and put it into 'now' as 'calender time' 868 935 for (int step=0;step<MDSteps;step++) { 869 *output << AtomCount<< "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now);936 *output << getAtomCount() << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now); 870 937 ActOnAllAtoms( &atom::OutputTrajectoryXYZ, output, step ); 871 938 } … … 884 951 if (output != NULL) { 885 952 now = time((time_t *)NULL); // Get the system time and put it into 'now' as 'calender time' 886 *output << AtomCount<< "\n\tCreated by molecuilder on " << ctime(&now);953 *output << getAtomCount() << "\n\tCreated by molecuilder on " << ctime(&now); 887 954 ActOnAllAtoms( &atom::OutputXYZLine, output ); 888 955 return true; … … 894 961 * \param *out output stream for debugging 895 962 */ 896 void molecule::CountAtoms() 897 { 963 int molecule::doCountAtoms() 964 { 965 int res = size(); 898 966 int i = 0; 899 atom *Walker = start; 900 while (Walker->next != end) { 901 Walker = Walker->next; 967 NoNonHydrogen = 0; 968 for (molecule::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) { 969 (*iter)->nr = i; // update number in molecule (for easier referencing in FragmentMolecule lateron) 970 if ((*iter)->type->Z != 1) // count non-hydrogen atoms whilst at it 971 NoNonHydrogen++; 972 stringstream sstr; 973 sstr << (*iter)->type->symbol << (*iter)->nr+1; 974 (*iter)->setName(sstr.str()); 975 DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl); 902 976 i++; 903 977 } 904 if ((AtomCount == 0) || (i != AtomCount)) { 905 DoLog(3) && (Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl); 906 AtomCount = i; 907 908 // count NonHydrogen atoms and give each atom a unique name 909 if (AtomCount != 0) { 910 i=0; 911 NoNonHydrogen = 0; 912 Walker = start; 913 while (Walker->next != end) { 914 Walker = Walker->next; 915 Walker->nr = i; // update number in molecule (for easier referencing in FragmentMolecule lateron) 916 if (Walker->type->Z != 1) // count non-hydrogen atoms whilst at it 917 NoNonHydrogen++; 918 stringstream sstr; 919 sstr << Walker->type->symbol << Walker->nr+1; 920 Walker->setName(sstr.str()); 921 DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->getName() << "." << endl); 922 i++; 923 } 924 } else 925 DoLog(3) && (Log() << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl); 926 } 978 return res; 927 979 }; 928 980 … … 986 1038 /// first count both their atoms and elements and update lists thereby ... 987 1039 //Log() << Verbose(0) << "Counting atoms, updating list" << endl; 988 CountAtoms();989 OtherMolecule->CountAtoms();990 1040 CountElements(); 991 1041 OtherMolecule->CountElements(); … … 994 1044 /// -# AtomCount 995 1045 if (result) { 996 if ( AtomCount != OtherMolecule->AtomCount) {997 DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount<< endl);1046 if (getAtomCount() != OtherMolecule->getAtomCount()) { 1047 DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl); 998 1048 result = false; 999 } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount<< endl;1049 } else Log() << Verbose(4) << "AtomCounts match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl; 1000 1050 } 1001 1051 /// -# ElementCount … … 1034 1084 if (result) { 1035 1085 DoLog(5) && (Log() << Verbose(5) << "Calculating distances" << endl); 1036 Distances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances");1037 OtherDistances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances");1086 Distances = new double[getAtomCount()]; 1087 OtherDistances = new double[getAtomCount()]; 1038 1088 SetIndexedArrayForEachAtomTo ( Distances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity); 1039 1089 SetIndexedArrayForEachAtomTo ( OtherDistances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity); 1090 for(int i=0;i<getAtomCount();i++) { 1091 Distances[i] = 0.; 1092 OtherDistances[i] = 0.; 1093 } 1040 1094 1041 1095 /// ... sort each list (using heapsort (o(N log N)) from GSL) 1042 1096 DoLog(5) && (Log() << Verbose(5) << "Sorting distances" << endl); 1043 PermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermMap"); 1044 OtherPermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *OtherPermMap"); 1045 gsl_heapsort_index (PermMap, Distances, AtomCount, sizeof(double), CompareDoubles); 1046 gsl_heapsort_index (OtherPermMap, OtherDistances, AtomCount, sizeof(double), CompareDoubles); 1047 PermutationMap = Calloc<int>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermutationMap"); 1097 PermMap = new size_t[getAtomCount()]; 1098 OtherPermMap = new size_t[getAtomCount()]; 1099 for(int i=0;i<getAtomCount();i++) { 1100 PermMap[i] = 0; 1101 OtherPermMap[i] = 0; 1102 } 1103 gsl_heapsort_index (PermMap, Distances, getAtomCount(), sizeof(double), CompareDoubles); 1104 gsl_heapsort_index (OtherPermMap, OtherDistances, getAtomCount(), sizeof(double), CompareDoubles); 1105 PermutationMap = new int[getAtomCount()]; 1106 for(int i=0;i<getAtomCount();i++) 1107 PermutationMap[i] = 0; 1048 1108 DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl); 1049 for(int i= AtomCount;i--;)1109 for(int i=getAtomCount();i--;) 1050 1110 PermutationMap[PermMap[i]] = (int) OtherPermMap[i]; 1051 1111 … … 1053 1113 DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl); 1054 1114 flag = 0; 1055 for (int i=0;i< AtomCount;i++) {1115 for (int i=0;i<getAtomCount();i++) { 1056 1116 DoLog(5) && (Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " << threshold << endl); 1057 1117 if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold) … … 1060 1120 1061 1121 // free memory 1062 Free(&PermMap);1063 Free(&OtherPermMap);1064 Free(&Distances);1065 Free(&OtherDistances);1122 delete[](PermMap); 1123 delete[](OtherPermMap); 1124 delete[](Distances); 1125 delete[](OtherDistances); 1066 1126 if (flag) { // if not equal 1067 Free(&PermutationMap);1127 delete[](PermutationMap); 1068 1128 result = false; 1069 1129 } … … 1089 1149 int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule) 1090 1150 { 1091 atom *Walker = NULL, *OtherWalker = NULL;1092 1151 DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl); 1093 int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap");1094 for (int i= AtomCount;i--;)1152 int *AtomicMap = new int[getAtomCount()]; 1153 for (int i=getAtomCount();i--;) 1095 1154 AtomicMap[i] = -1; 1096 1155 if (OtherMolecule == this) { // same molecule 1097 for (int i= AtomCount;i--;) // no need as -1 means already that there is trivial correspondence1156 for (int i=getAtomCount();i--;) // no need as -1 means already that there is trivial correspondence 1098 1157 AtomicMap[i] = i; 1099 1158 DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl); 1100 1159 } else { 1101 1160 DoLog(4) && (Log() << Verbose(4) << "Map is "); 1102 Walker = start; 1103 while (Walker->next != end) { 1104 Walker = Walker->next; 1105 if (Walker->father == NULL) { 1106 AtomicMap[Walker->nr] = -2; 1161 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 1162 if ((*iter)->father == NULL) { 1163 AtomicMap[(*iter)->nr] = -2; 1107 1164 } else { 1108 OtherWalker = OtherMolecule->start; 1109 while (OtherWalker->next != OtherMolecule->end) { 1110 OtherWalker = OtherWalker->next; 1165 for (molecule::const_iterator runner = OtherMolecule->begin(); runner != OtherMolecule->end(); ++runner) { 1111 1166 //for (int i=0;i<AtomCount;i++) { // search atom 1112 //for (int j=0;j<OtherMolecule-> AtomCount;j++) {1113 //Log() << Verbose(4) << "Comparing father " << Walker->father << " with the other one " << OtherWalker->father << "." << endl;1114 if ( Walker->father == OtherWalker)1115 AtomicMap[ Walker->nr] = OtherWalker->nr;1167 //for (int j=0;j<OtherMolecule->getAtomCount();j++) { 1168 //Log() << Verbose(4) << "Comparing father " << (*iter)->father << " with the other one " << (*runner)->father << "." << endl; 1169 if ((*iter)->father == (*runner)) 1170 AtomicMap[(*iter)->nr] = (*runner)->nr; 1116 1171 } 1117 1172 } 1118 DoLog(0) && (Log() << Verbose(0) << AtomicMap[ Walker->nr] << "\t");1173 DoLog(0) && (Log() << Verbose(0) << AtomicMap[(*iter)->nr] << "\t"); 1119 1174 } 1120 1175 DoLog(0) && (Log() << Verbose(0) << endl); … … 1150 1205 void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) const 1151 1206 { 1152 atom *Walker = start; 1153 while (Walker->next != end) { 1154 Walker = Walker->next; 1155 array[(Walker->*index)] = Walker; 1207 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 1208 array[((*iter)->*index)] = (*iter); 1156 1209 } 1157 1210 }; -
src/molecule.hpp
r992fd7 r257c77 34 34 #include "tesselation.hpp" 35 35 #include "Patterns/Observer.hpp" 36 #include "Patterns/ObservedIterator.hpp" 36 37 #include "Patterns/Cacheable.hpp" 38 39 #include "Descriptors/MoleculeDescriptor_impl.hpp" 37 40 38 41 /****************************************** forward declarations *****************************/ … … 88 91 friend molecule *NewMolecule(); 89 92 friend void DeleteMolecule(molecule *); 93 90 94 public: 95 typedef std::set<atom*> atomSet; 96 typedef ObservedIterator<atomSet> iterator; 97 typedef atomSet::const_iterator const_iterator; 98 91 99 const periodentafel * const elemente; //!< periodic table with each element 92 atom *start; //!< start of atom list 93 atom *end; //!< end of atom list 94 bond *first; //!< start of bond list 95 bond *last; //!< end of bond list 100 // old deprecated atom handling 101 //atom *start; //!< start of atom list 102 //atom *end; //!< end of atom list 103 //bond *first; //!< start of bond list 104 //bond *last; //!< end of bond list 96 105 int MDSteps; //!< The number of MD steps in Trajectories 97 int AtomCount; //!< number of atoms, brought up-to-date by CountAtoms()106 //int AtomCount; //!< number of atoms, brought up-to-date by CountAtoms() 98 107 int BondCount; //!< number of atoms, brought up-to-date by CountBonds() 99 108 int ElementCount; //!< how many unique elements are therein … … 110 119 private: 111 120 Cacheable<string> formula; 121 Cacheable<int> AtomCount; 112 122 moleculeId_t id; 123 atomSet atoms; //<!set of atoms 113 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 114 133 molecule(const periodentafel * const teil); 115 134 virtual ~molecule(); … … 119 138 //getter and setter 120 139 const std::string getName(); 140 int getAtomCount() const; 141 int doCountAtoms(); 121 142 moleculeId_t getId(); 122 143 void setId(moleculeId_t); … … 125 146 std::string calcFormula(); 126 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 bool containsAtom(atom* key); 159 127 160 128 161 // re-definition of virtual functions from PointCloud … … 130 163 Vector *GetCenter() const ; 131 164 TesselPoint *GetPoint() const ; 132 TesselPoint *GetTerminalPoint() const ;133 165 int GetMaxId() const; 134 166 void GoToNext() const ; 135 void GoToPrevious() const ;136 167 void GoToFirst() const ; 137 void GoToLast() const ;138 168 bool IsEmpty() const ; 139 169 bool IsEnd() const ; … … 224 254 bool RemoveBond(bond *pointer); 225 255 bool RemoveBonds(atom *BondPartner); 256 bool hasBondStructure(); 257 unsigned int CountBonds() const; 226 258 227 259 /// Find atoms. … … 230 262 231 263 /// Count and change present atoms' coordination. 232 void CountAtoms();233 264 void CountElements(); 234 265 void CalculateOrbitals(class config &configuration); … … 247 278 Vector * DetermineCenterOfGravity(); 248 279 Vector * DetermineCenterOfAll() const; 280 Vector * DetermineCenterOfBox() const; 249 281 void SetNameFromFilename(const char *filename); 250 282 void SetBoxDimension(Vector *dim); … … 299 331 bool StoreForcesFile(MoleculeListClass *BondFragments, char *path, int *SortIndex); 300 332 bool CreateMappingLabelsToConfigSequence(int *&SortIndex); 333 bool CreateFatherLookupTable(atom **&LookupTable, int count = 0); 301 334 void BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem); 302 335 /// -# BOSSANOVA … … 327 360 private: 328 361 int last_atom; //!< number given to last atom 329 mutable atom *InternalPointer; //!< internal pointer for PointCloud362 mutable internal_iterator InternalPointer; //!< internal pointer for PointCloud 330 363 }; 331 364 … … 348 381 bool StoreForcesFile(char *path, int *SortIndex); 349 382 void insert(molecule *mol); 383 void erase(molecule *mol); 350 384 molecule * ReturnIndex(int index); 351 385 bool OutputConfigForListOfFragments(config *configuration, int *SortIndex); -
src/molecule_dynamics.cpp
r992fd7 r257c77 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "World.hpp" 9 11 #include "atom.hpp" 10 12 #include "config.hpp" 11 13 #include "element.hpp" 14 #include "info.hpp" 12 15 #include "log.hpp" 13 16 #include "memoryallocator.hpp" … … 28 31 gsl_matrix *A = gsl_matrix_alloc(NDIM,NDIM); 29 32 gsl_vector *x = gsl_vector_alloc(NDIM); 30 atom * Runner = mol->start;31 33 atom *Sprinter = NULL; 32 34 Vector trajectory1, trajectory2, normal, TestVector; 33 35 double Norm1, Norm2, tmp, result = 0.; 34 36 35 while (Runner->next != mol->end) { 36 Runner = Runner->next; 37 if (Runner == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++) 37 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 38 if ((*iter) == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++) 38 39 break; 39 40 // determine normalized trajectories direction vector (n1, n2) … … 42 43 trajectory1.Normalize(); 43 44 Norm1 = trajectory1.Norm(); 44 Sprinter = Params.PermutationMap[ Runner->nr]; // find second target point45 trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Runner->Trajectory.R.at(Params.startstep);45 Sprinter = Params.PermutationMap[(*iter)->nr]; // find second target point 46 trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep); 46 47 trajectory2.Normalize(); 47 48 Norm2 = trajectory1.Norm(); 48 49 // check whether either is zero() 49 50 if ((Norm1 < MYEPSILON) && (Norm2 < MYEPSILON)) { 50 tmp = Walker->Trajectory.R.at(Params.startstep).distance( Runner->Trajectory.R.at(Params.startstep));51 tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep)); 51 52 } else if (Norm1 < MYEPSILON) { 52 53 Sprinter = Params.PermutationMap[Walker->nr]; // find first target point 53 trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - Runner->Trajectory.R.at(Params.startstep);54 trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep); 54 55 trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything 55 56 trajectory1 -= trajectory2; // project the part in norm direction away 56 57 tmp = trajectory1.Norm(); // remaining norm is distance 57 58 } else if (Norm2 < MYEPSILON) { 58 Sprinter = Params.PermutationMap[ Runner->nr]; // find second target point59 Sprinter = Params.PermutationMap[(*iter)->nr]; // find second target point 59 60 trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep); // copy second offset 60 61 trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything … … 66 67 // Log() << Verbose(0) << " and "; 67 68 // Log() << Verbose(0) << trajectory2; 68 tmp = Walker->Trajectory.R.at(Params.startstep).distance( Runner->Trajectory.R.at(Params.startstep));69 tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep)); 69 70 // Log() << Verbose(0) << " with distance " << tmp << "." << endl; 70 71 } else { // determine distance by finding minimum distance 71 // Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << * Runner<< " are linear independent ";72 // Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *(*iter) << " are linear independent "; 72 73 // Log() << Verbose(0) << endl; 73 74 // Log() << Verbose(0) << "First Trajectory: "; … … 85 86 gsl_matrix_set(A, 1, i, trajectory2[i]); 86 87 gsl_matrix_set(A, 2, i, normal[i]); 87 gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep)[i] - Runner->Trajectory.R.at(Params.startstep)[i]));88 gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep)[i] - (*iter)->Trajectory.R.at(Params.startstep)[i])); 88 89 } 89 90 // solve the linear system by Householder transformations … … 96 97 trajectory2.Scale(gsl_vector_get(x,1)); 97 98 normal.Scale(gsl_vector_get(x,2)); 98 TestVector = Runner->Trajectory.R.at(Params.startstep) + trajectory2 + normal99 TestVector = (*iter)->Trajectory.R.at(Params.startstep) + trajectory2 + normal 99 100 - (Walker->Trajectory.R.at(Params.startstep) + trajectory1); 100 101 if (TestVector.Norm() < MYEPSILON) { … … 125 126 { 126 127 double result = 0.; 127 atom * Runner = mol->start; 128 while (Runner->next != mol->end) { 129 Runner = Runner->next; 130 if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[Runner->nr]) && (Walker->nr < Runner->nr)) { 128 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 129 if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[(*iter)->nr]) && (Walker->nr < (*iter)->nr)) { 131 130 // atom *Sprinter = PermutationMap[Walker->nr]; 132 // Log() << Verbose(0) << *Walker << " and " << * Runner<< " are heading to the same target at ";131 // Log() << Verbose(0) << *Walker << " and " << *(*iter) << " are heading to the same target at "; 133 132 // Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep); 134 133 // Log() << Verbose(0) << ", penalting." << endl; … … 161 160 // go through every atom 162 161 atom *Runner = NULL; 163 atom *Walker = start; 164 while (Walker->next != end) { 165 Walker = Walker->next; 162 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 166 163 // first term: distance to target 167 Runner = Params.PermutationMap[ Walker->nr]; // find target point168 tmp = ( Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)));164 Runner = Params.PermutationMap[(*iter)->nr]; // find target point 165 tmp = ((*iter)->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep))); 169 166 tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem; 170 167 result += Params.PenaltyConstants[0] * tmp; … … 172 169 173 170 // second term: sum of distances to other trajectories 174 result += SumDistanceOfTrajectories( Walker, this, Params);171 result += SumDistanceOfTrajectories((*iter), this, Params); 175 172 176 173 // third term: penalty for equal targets 177 result += PenalizeEqualTargets( Walker, this, Params);174 result += PenalizeEqualTargets((*iter), this, Params); 178 175 } 179 176 … … 189 186 { 190 187 stringstream zeile1, zeile2; 191 int *DoubleList = Calloc<int>(AtomCount, "PrintPermutationMap: *DoubleList"); 188 int *DoubleList = new int[AtomCount]; 189 for(int i=0;i<AtomCount;i++) 190 DoubleList[i] = 0; 192 191 int doubles = 0; 193 192 zeile1 << "PermutationMap: "; … … 203 202 if (doubles >0) 204 203 DoLog(2) && (Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl); 205 Free(&DoubleList);204 delete[](DoubleList); 206 205 // Log() << Verbose(2) << zeile1.str() << endl << zeile2.str() << endl; 207 206 }; … … 213 212 void FillDistanceList(molecule *mol, struct EvaluatePotential &Params) 214 213 { 215 for (int i=mol-> AtomCount; i--;) {214 for (int i=mol->getAtomCount(); i--;) { 216 215 Params.DistanceList[i] = new DistanceMap; // is the distance sorted target list per atom 217 216 Params.DistanceList[i]->clear(); 218 217 } 219 218 220 atom *Runner = NULL; 221 atom *Walker = mol->start; 222 while (Walker->next != mol->end) { 223 Walker = Walker->next; 224 Runner = mol->start; 225 while(Runner->next != mol->end) { 226 Runner = Runner->next; 227 Params.DistanceList[Walker->nr]->insert( DistancePair(Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)), Runner) ); 219 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 220 for (molecule::const_iterator runner = mol->begin(); runner != mol->end(); ++runner) { 221 Params.DistanceList[(*iter)->nr]->insert( DistancePair((*iter)->Trajectory.R.at(Params.startstep).distance((*runner)->Trajectory.R.at(Params.endstep)), (*runner)) ); 228 222 } 229 223 } … … 237 231 void CreateInitialLists(molecule *mol, struct EvaluatePotential &Params) 238 232 { 239 atom *Walker = mol->start; 240 while (Walker->next != mol->end) { 241 Walker = Walker->next; 242 Params.StepList[Walker->nr] = Params.DistanceList[Walker->nr]->begin(); // stores the step to the next iterator that could be a possible next target 243 Params.PermutationMap[Walker->nr] = Params.DistanceList[Walker->nr]->begin()->second; // always pick target with the smallest distance 244 Params.DoubleList[Params.DistanceList[Walker->nr]->begin()->second->nr]++; // increase this target's source count (>1? not injective) 245 Params.DistanceIterators[Walker->nr] = Params.DistanceList[Walker->nr]->begin(); // and remember which one we picked 246 DoLog(2) && (Log() << Verbose(2) << *Walker << " starts with distance " << Params.DistanceList[Walker->nr]->begin()->first << "." << endl); 233 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 234 Params.StepList[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin(); // stores the step to the next iterator that could be a possible next target 235 Params.PermutationMap[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin()->second; // always pick target with the smallest distance 236 Params.DoubleList[Params.DistanceList[(*iter)->nr]->begin()->second->nr]++; // increase this target's source count (>1? not injective) 237 Params.DistanceIterators[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin(); // and remember which one we picked 238 DoLog(2) && (Log() << Verbose(2) << **iter << " starts with distance " << Params.DistanceList[(*iter)->nr]->begin()->first << "." << endl); 247 239 } 248 240 }; … … 285 277 void MakeInjectivePermutation(molecule *mol, struct EvaluatePotential &Params) 286 278 { 287 atom *Walker = mol->start;279 molecule::const_iterator iter = mol->begin(); 288 280 DistanceMap::iterator NewBase; 289 281 double Potential = fabs(mol->ConstrainedPotential(Params)); 290 282 283 if (mol->empty()) { 284 eLog() << Verbose(1) << "Molecule is empty." << endl; 285 return; 286 } 291 287 while ((Potential) > Params.PenaltyConstants[2]) { 292 PrintPermutationMap(mol-> AtomCount, Params);293 Walker = Walker->next;294 if ( Walker == mol->end) // round-robin at the end295 Walker = mol->start->next;296 if (Params.DoubleList[Params.DistanceIterators[ Walker->nr]->second->nr] <= 1) // no need to make those injective that aren't288 PrintPermutationMap(mol->getAtomCount(), Params); 289 iter++; 290 if (iter == mol->end()) // round-robin at the end 291 iter = mol->begin(); 292 if (Params.DoubleList[Params.DistanceIterators[(*iter)->nr]->second->nr] <= 1) // no need to make those injective that aren't 297 293 continue; 298 294 // now, try finding a new one 299 Potential = TryNextNearestNeighbourForInjectivePermutation(mol, Walker, Potential, Params);300 } 301 for (int i=mol-> AtomCount; i--;) // now each single entry in the DoubleList should be <=1295 Potential = TryNextNearestNeighbourForInjectivePermutation(mol, (*iter), Potential, Params); 296 } 297 for (int i=mol->getAtomCount(); i--;) // now each single entry in the DoubleList should be <=1 302 298 if (Params.DoubleList[i] > 1) { 303 299 DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl); … … 338 334 double Potential, OldPotential, OlderPotential; 339 335 struct EvaluatePotential Params; 340 Params.PermutationMap = Calloc<atom*>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.**PermutationMap");341 Params.DistanceList = Malloc<DistanceMap*>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.**DistanceList");342 Params.DistanceIterators = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*DistanceIterators");343 Params.DoubleList = Calloc<int>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*DoubleList");344 Params.StepList = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*StepList");336 Params.PermutationMap = new atom *[getAtomCount()]; 337 Params.DistanceList = new DistanceMap *[getAtomCount()]; 338 Params.DistanceIterators = new DistanceMap::iterator[getAtomCount()]; 339 Params.DoubleList = new int[getAtomCount()]; 340 Params.StepList = new DistanceMap::iterator[getAtomCount()]; 345 341 int round; 346 atom * Walker = NULL, *Runner = NULL, *Sprinter = NULL;342 atom *Sprinter = NULL; 347 343 DistanceMap::iterator Rider, Strider; 344 345 // set to zero 346 for (int i=0;i<getAtomCount();i++) { 347 Params.PermutationMap[i] = NULL; 348 Params.DoubleList[i] = 0; 349 } 348 350 349 351 /// Minimise the potential … … 362 364 DoLog(1) && (Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl); 363 365 MakeInjectivePermutation(this, Params); 364 Free(&Params.DoubleList);366 delete[](Params.DoubleList); 365 367 366 368 // argument minimise the constrained potential in this injective PermutationMap … … 371 373 DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl); 372 374 OlderPotential = OldPotential; 375 molecule::const_iterator iter; 373 376 do { 374 Walker = start; 375 while (Walker->next != end) { // pick one 376 Walker = Walker->next; 377 PrintPermutationMap(AtomCount, Params); 378 Sprinter = Params.DistanceIterators[Walker->nr]->second; // store initial partner 379 Strider = Params.DistanceIterators[Walker->nr]; //remember old iterator 380 Params.DistanceIterators[Walker->nr] = Params.StepList[Walker->nr]; 381 if (Params.DistanceIterators[Walker->nr] == Params.DistanceList[Walker->nr]->end()) {// stop, before we run through the list and still on 382 Params.DistanceIterators[Walker->nr] == Params.DistanceList[Walker->nr]->begin(); 377 iter = begin(); 378 for (; iter != end(); ++iter) { 379 PrintPermutationMap(getAtomCount(), Params); 380 Sprinter = Params.DistanceIterators[(*iter)->nr]->second; // store initial partner 381 Strider = Params.DistanceIterators[(*iter)->nr]; //remember old iterator 382 Params.DistanceIterators[(*iter)->nr] = Params.StepList[(*iter)->nr]; 383 if (Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->end()) {// stop, before we run through the list and still on 384 Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->begin(); 383 385 break; 384 386 } 385 //Log() << Verbose(2) << "Current Walker: " << * Walker << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[Walker->nr]->second << "." << endl;387 //Log() << Verbose(2) << "Current Walker: " << *(*iter) << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[(*iter)->nr]->second << "." << endl; 386 388 // find source of the new target 387 Runner = start->next;388 while(Runner != end) { // 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[Walker->nr]->second) {390 //Log() << Verbose(2) << "Found the corresponding owner " << * Runner << " to " << *PermutationMap[Runner->nr] << "." << endl;389 molecule::const_iterator runner = begin(); 390 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) 391 if (Params.PermutationMap[(*runner)->nr] == Params.DistanceIterators[(*iter)->nr]->second) { 392 //Log() << Verbose(2) << "Found the corresponding owner " << *(*runner) << " to " << *PermutationMap[(*runner)->nr] << "." << endl; 391 393 break; 392 394 } 393 Runner = Runner->next;394 395 } 395 if ( Runner != end) { // we found the other source396 if (runner != end()) { // we found the other source 396 397 // then look in its distance list for Sprinter 397 Rider = Params.DistanceList[ Runner->nr]->begin();398 for (; Rider != Params.DistanceList[ Runner->nr]->end(); Rider++)398 Rider = Params.DistanceList[(*runner)->nr]->begin(); 399 for (; Rider != Params.DistanceList[(*runner)->nr]->end(); Rider++) 399 400 if (Rider->second == Sprinter) 400 401 break; 401 if (Rider != Params.DistanceList[ Runner->nr]->end()) { // if we have found one402 //Log() << Verbose(2) << "Current Other: " << * Runner << " with old/next candidate " << *PermutationMap[Runner->nr] << "/" << *Rider->second << "." << endl;402 if (Rider != Params.DistanceList[(*runner)->nr]->end()) { // if we have found one 403 //Log() << Verbose(2) << "Current Other: " << *(*runner) << " with old/next candidate " << *PermutationMap[(*runner)->nr] << "/" << *Rider->second << "." << endl; 403 404 // exchange both 404 Params.PermutationMap[ Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // put next farther distance into PermutationMap405 Params.PermutationMap[ Runner->nr] = Sprinter; // and hand the old target to its respective owner406 PrintPermutationMap( AtomCount, Params);405 Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // put next farther distance into PermutationMap 406 Params.PermutationMap[(*runner)->nr] = Sprinter; // and hand the old target to its respective owner 407 PrintPermutationMap(getAtomCount(), Params); 407 408 // calculate the new potential 408 409 //Log() << Verbose(2) << "Checking new potential ..." << endl; … … 410 411 if (Potential > OldPotential) { // we made everything worse! Undo ... 411 412 //Log() << Verbose(3) << "Nay, made the potential worse: " << Potential << " vs. " << OldPotential << "!" << endl; 412 //Log() << Verbose(3) << "Setting " << * Runner << "'s source to " << *Params.DistanceIterators[Runner->nr]->second << "." << endl;413 //Log() << Verbose(3) << "Setting " << *(*runner) << "'s source to " << *Params.DistanceIterators[(*runner)->nr]->second << "." << endl; 413 414 // Undo for Runner (note, we haven't moved the iteration yet, we may use this) 414 Params.PermutationMap[ Runner->nr] = Params.DistanceIterators[Runner->nr]->second;415 Params.PermutationMap[(*runner)->nr] = Params.DistanceIterators[(*runner)->nr]->second; 415 416 // Undo for Walker 416 Params.DistanceIterators[ Walker->nr] = Strider; // take next farther distance target417 //Log() << Verbose(3) << "Setting " << * Walker << "'s source to " << *Params.DistanceIterators[Walker->nr]->second << "." << endl;418 Params.PermutationMap[ Walker->nr] = Params.DistanceIterators[Walker->nr]->second;417 Params.DistanceIterators[(*iter)->nr] = Strider; // take next farther distance target 418 //Log() << Verbose(3) << "Setting " << *(*iter) << "'s source to " << *Params.DistanceIterators[(*iter)->nr]->second << "." << endl; 419 Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; 419 420 } else { 420 Params.DistanceIterators[ Runner->nr] = Rider; // if successful also move the pointer in the iterator list421 Params.DistanceIterators[(*runner)->nr] = Rider; // if successful also move the pointer in the iterator list 421 422 DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl); 422 423 OldPotential = Potential; … … 428 429 //Log() << Verbose(0) << endl; 429 430 } else { 430 DoeLog(1) && (eLog()<< Verbose(1) << * Runner << " was not the owner of " << *Sprinter << "!" << endl);431 DoeLog(1) && (eLog()<< Verbose(1) << **runner << " was not the owner of " << *Sprinter << "!" << endl); 431 432 exit(255); 432 433 } 433 434 } else { 434 Params.PermutationMap[ Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // new target has no source!435 Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // new target has no source! 435 436 } 436 Params.StepList[ Walker->nr]++; // take next farther distance target437 Params.StepList[(*iter)->nr]++; // take next farther distance target 437 438 } 438 } while ( Walker->next != end);439 } while (++iter != end()); 439 440 } while ((OlderPotential - OldPotential) > 1e-3); 440 441 DoLog(1) && (Log() << Verbose(1) << "done." << endl); … … 442 443 443 444 /// free memory and return with evaluated potential 444 for (int i= AtomCount; i--;)445 for (int i=getAtomCount(); i--;) 445 446 Params.DistanceList[i]->clear(); 446 Free(&Params.DistanceList);447 Free(&Params.DistanceIterators);447 delete[](Params.DistanceList); 448 delete[](Params.DistanceIterators); 448 449 return ConstrainedPotential(Params); 449 450 }; … … 483 484 // Get the Permutation Map by MinimiseConstrainedPotential 484 485 atom **PermutationMap = NULL; 485 atom * Walker = NULL, *Sprinter = NULL;486 atom *Sprinter = NULL; 486 487 if (!MapByIdentity) 487 488 MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem()); 488 489 else { 489 PermutationMap = Malloc<atom *>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap");490 PermutationMap = new atom *[getAtomCount()]; 490 491 SetIndexedArrayForEachAtomTo( PermutationMap, &atom::nr ); 491 492 } … … 502 503 mol = World::getInstance().createMolecule(); 503 504 MoleculePerStep->insert(mol); 504 Walker = start; 505 while (Walker->next != end) { 506 Walker = Walker->next; 505 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 507 506 // add to molecule list 508 Sprinter = mol->AddCopyAtom( Walker);507 Sprinter = mol->AddCopyAtom((*iter)); 509 508 for (int n=NDIM;n--;) { 510 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);509 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); 511 510 // add to Trajectories 512 511 //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl; 513 512 if (step < MaxSteps) { 514 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);515 Walker->Trajectory.U.at(step)[n] = 0.;516 Walker->Trajectory.F.at(step)[n] = 0.;513 (*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); 514 (*iter)->Trajectory.U.at(step)[n] = 0.; 515 (*iter)->Trajectory.F.at(step)[n] = 0.; 517 516 } 518 517 } … … 522 521 523 522 // store the list to single step files 524 int *SortIndex = Malloc<int>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: *SortIndex");525 for (int i= AtomCount; i--; )523 int *SortIndex = new int[getAtomCount()]; 524 for (int i=getAtomCount(); i--; ) 526 525 SortIndex[i] = i; 527 526 status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex); 527 delete[](SortIndex); 528 528 529 529 // free and return 530 Free(&PermutationMap);530 delete[](PermutationMap); 531 531 delete(MoleculePerStep); 532 532 return status; … … 548 548 bool molecule::VerletForceIntegration(char *file, config &configuration) 549 549 { 550 Info FunctionInfo(__func__); 550 551 ifstream input(file); 551 552 string token; … … 567 568 return false; 568 569 } 569 if (Force.RowCounter[0] != AtomCount) {570 DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount<< "." << endl);570 if (Force.RowCounter[0] != getAtomCount()) { 571 DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << getAtomCount() << "." << endl); 571 572 performCriticalExit(); 572 573 return false; … … 574 575 // correct Forces 575 576 Velocity.Zero(); 576 for(int i=0;i< AtomCount;i++)577 for(int i=0;i<getAtomCount();i++) 577 578 for(int d=0;d<NDIM;d++) { 578 579 Velocity[d] += Force.Matrix[0][i][d+5]; 579 580 } 580 for(int i=0;i< AtomCount;i++)581 for(int i=0;i<getAtomCount();i++) 581 582 for(int d=0;d<NDIM;d++) { 582 Force.Matrix[0][i][d+5] -= Velocity[d]/ (double)AtomCount;583 Force.Matrix[0][i][d+5] -= Velocity[d]/static_cast<double>(getAtomCount()); 583 584 } 584 585 // solve a constrained potential if we are meant to … … 588 589 ConstrainedPotentialEnergy = MinimiseConstrainedPotential(PermutationMap,configuration.DoConstrainedMD, 0, configuration.GetIsAngstroem()); 589 590 EvaluateConstrainedForces(configuration.DoConstrainedMD, 0, PermutationMap, &Force); 590 Free(&PermutationMap);591 delete[](PermutationMap); 591 592 } 592 593 593 594 // and perform Verlet integration for each atom with position, velocity and force vector 594 595 // check size of vectors 595 ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 );596 597 ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps , &configuration, &Force);596 //ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 ); 597 598 ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps+1, &configuration, &Force); 598 599 } 599 600 // correct velocities (rather momenta) so that center of mass remains motionless 600 601 Velocity.Zero(); 601 602 IonMass = 0.; 602 ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps , &IonMass, &Velocity );603 ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps+1, &IonMass, &Velocity ); 603 604 604 605 // correct velocities (rather momenta) so that center of mass remains motionless 605 606 Velocity.Scale(1./IonMass); 606 607 ActualTemp = 0.; 607 ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps , &Velocity );608 ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps+1, &Velocity ); 608 609 Thermostats(configuration, ActualTemp, Berendsen); 609 610 MDSteps++; … … 683 684 delta_alpha = 0.; 684 685 ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha ); 685 delta_alpha = (delta_alpha - (3.* AtomCount+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass);686 delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass); 686 687 configuration.alpha += delta_alpha*configuration.Deltat; 687 688 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl); -
src/molecule_fragmentation.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <cstring> … … 39 41 int FragmentCount; 40 42 // 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; 43 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 44 c = ((*iter)->ListOfBonds.size() > c) ? (*iter)->ListOfBonds.size() : c; 45 45 } 46 46 FragmentCount = NoNonHydrogen*(1 << (c*order)); … … 94 94 GraphTestPair testGraphInsert; 95 95 int NumberOfFragments = 0; 96 char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - filename");96 char filename[MAXSTRINGSIZE]; 97 97 98 98 if (FragmentList == NULL) { // check list pointer … … 106 106 if (InputFile != NULL) { 107 107 // each line represents a new fragment 108 char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - *buffer");108 char buffer[MAXSTRINGSIZE]; 109 109 // 1. parse keysets and insert into temp. graph 110 110 while (!InputFile.eof()) { … … 122 122 InputFile.close(); 123 123 InputFile.clear(); 124 Free(&buffer); 125 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 124 DoLog(1) && (Log() << Verbose(1) << "\t ... done." << endl); 126 125 } else { 127 DoLog(1) && (Log() << Verbose(1) << " File " << filename << " not found." << endl);126 DoLog(1) && (Log() << Verbose(1) << "\t ... File " << filename << " not found." << endl); 128 127 status = false; 129 128 } 130 129 131 Free(&filename);132 130 return status; 133 131 }; … … 148 146 int NumberOfFragments = 0; 149 147 double TEFactor; 150 char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseTEFactorsFile - filename");148 char filename[MAXSTRINGSIZE]; 151 149 152 150 if (FragmentList == NULL) { // check list pointer … … 179 177 } 180 178 181 // free memory182 Free(&filename);183 184 179 return status; 185 180 }; … … 317 312 int No = 0, FragOrder = 0; 318 313 double Value = 0.; 319 char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::CheckOrderAtSite: *buffer");314 char buffer[MAXSTRINGSIZE]; 320 315 sprintf(buffer, "%s/%s%s.dat", path, FRAGMENTPREFIX, ENERGYPERFRAGMENT); 321 316 ifstream InputFile(buffer, ios::in); … … 345 340 InputFile.clear(); 346 341 } 347 Free(&buffer);348 342 349 343 return AdaptiveCriteriaList; … … 359 353 map<double, pair<int,int> > * ReMapAdaptiveCriteriaListToValue(map<int, pair<double,int> > *AdaptiveCriteriaList, molecule *mol) 360 354 { 361 atom *Walker = mol->start;355 atom *Walker = NULL; 362 356 map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ; 363 357 DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl); … … 391 385 bool MarkUpdateCandidates(bool *AtomMask, map<double, pair<int,int> > &FinalRootCandidates, int Order, molecule *mol) 392 386 { 393 atom *Walker = mol->start;387 atom *Walker = NULL; 394 388 int No = -1; 395 389 bool status = false; … … 435 429 bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path) 436 430 { 437 atom *Walker = start;438 431 bool status = false; 439 432 440 433 // initialize mask list 441 for(int i= AtomCount;i--;)434 for(int i=getAtomCount();i--;) 442 435 AtomMask[i] = false; 443 436 444 437 if (Order < 0) { // adaptive increase of BondOrder per site 445 if (AtomMask[ AtomCount] == true) // break after one step438 if (AtomMask[getAtomCount()] == true) // break after one step 446 439 return false; 447 440 … … 457 450 if (AdaptiveCriteriaList->empty()) { 458 451 DoeLog(2) && (eLog()<< Verbose(2) << "Unable to parse file, incrementing all." << endl); 459 while (Walker->next != end) { 460 Walker = Walker->next; 452 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 461 453 #ifdef ADDHYDROGEN 462 if ( Walker->type->Z != 1) // skip hydrogen454 if ((*iter)->type->Z != 1) // skip hydrogen 463 455 #endif 464 456 { 465 AtomMask[ Walker->nr] = true; // include all (non-hydrogen) atoms457 AtomMask[(*iter)->nr] = true; // include all (non-hydrogen) atoms 466 458 status = true; 467 459 } … … 474 466 MarkUpdateCandidates(AtomMask, *FinalRootCandidates, Order, this); 475 467 476 Free(&IndexKeySetList);477 Free(&AdaptiveCriteriaList);478 Free(&FinalRootCandidates);468 delete[](IndexKeySetList); 469 delete[](AdaptiveCriteriaList); 470 delete[](FinalRootCandidates); 479 471 } else { // global increase of Bond Order 480 while (Walker->next != end) { 481 Walker = Walker->next; 472 for(molecule::const_iterator iter = begin(); iter != end(); ++iter) { 482 473 #ifdef ADDHYDROGEN 483 if ( Walker->type->Z != 1) // skip hydrogen474 if ((*iter)->type->Z != 1) // skip hydrogen 484 475 #endif 485 476 { 486 AtomMask[ Walker->nr] = true; // include all (non-hydrogen) atoms487 if ((Order != 0) && ( Walker->AdaptiveOrder < Order)) // && (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]))477 AtomMask[(*iter)->nr] = true; // include all (non-hydrogen) atoms 478 if ((Order != 0) && ((*iter)->AdaptiveOrder < Order)) // && ((*iter)->AdaptiveOrder < MinimumRingSize[(*iter)->nr])) 488 479 status = true; 489 480 } 490 481 } 491 if (( Order == 0) && (AtomMask[AtomCount] == false)) // single stepping, just check482 if ((!Order) && (!AtomMask[getAtomCount()])) // single stepping, just check 492 483 status = true; 493 484 … … 500 491 } 501 492 502 PrintAtomMask(AtomMask, AtomCount); // for debugging493 PrintAtomMask(AtomMask, getAtomCount()); // for debugging 503 494 504 495 return status; … … 516 507 return false; 517 508 } 518 SortIndex = Malloc<int>(AtomCount, "molecule::CreateMappingLabelsToConfigSequence: *SortIndex");519 for(int i= AtomCount;i--;)509 SortIndex = new int[getAtomCount()]; 510 for(int i=getAtomCount();i--;) 520 511 SortIndex[i] = -1; 521 512 … … 524 515 525 516 return true; 517 }; 518 519 520 521 /** Creates a lookup table for true father's Atom::Nr -> atom ptr. 522 * \param *start begin of list (STL iterator, i.e. first item) 523 * \paran *end end of list (STL iterator, i.e. one past last item) 524 * \param **Lookuptable pointer to return allocated lookup table (should be NULL on start) 525 * \param count optional predetermined size for table (otherwise we set the count to highest true father id) 526 * \return true - success, false - failure 527 */ 528 bool molecule::CreateFatherLookupTable(atom **&LookupTable, int count) 529 { 530 bool status = true; 531 int AtomNo; 532 533 if (LookupTable != NULL) { 534 Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl; 535 return false; 536 } 537 538 // count them 539 if (count == 0) { 540 for (molecule::iterator iter = begin(); iter != end(); ++iter) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron 541 count = (count < (*iter)->GetTrueFather()->nr) ? (*iter)->GetTrueFather()->nr : count; 542 } 543 } 544 if (count <= 0) { 545 Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl; 546 return false; 547 } 548 549 // allocate and fill 550 LookupTable = new atom *[count]; 551 if (LookupTable == NULL) { 552 eLog() << Verbose(0) << "LookupTable memory allocation failed!" << endl; 553 performCriticalExit(); 554 status = false; 555 } else { 556 for (int i=0;i<count;i++) 557 LookupTable[i] = NULL; 558 for (molecule::iterator iter = begin(); iter != end(); ++iter) { 559 AtomNo = (*iter)->GetTrueFather()->nr; 560 if ((AtomNo >= 0) && (AtomNo < count)) { 561 //*out << "Setting LookupTable[" << AtomNo << "] to " << *(*iter) << endl; 562 LookupTable[AtomNo] = (*iter); 563 } else { 564 Log() << Verbose(0) << "Walker " << *(*iter) << " exceeded range of nuclear ids [0, " << count << ")." << endl; 565 status = false; 566 break; 567 } 568 } 569 } 570 571 return status; 526 572 }; 527 573 … … 547 593 { 548 594 MoleculeListClass *BondFragments = NULL; 549 int *SortIndex = NULL; 550 int *MinimumRingSize = new int[AtomCount]; 595 int *MinimumRingSize = new int[getAtomCount()]; 551 596 int FragmentCounter; 552 597 MoleculeLeafClass *MolecularWalker = NULL; … … 576 621 577 622 // create lookup table for Atom::nr 578 FragmentationToDo = FragmentationToDo && CreateFatherLookupTable( start, end, ListOfAtoms, AtomCount);623 FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, getAtomCount()); 579 624 580 625 // === compare it with adjacency file === 581 626 FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(configuration->configpath, ListOfAtoms); 582 Free(&ListOfAtoms);627 delete[](ListOfAtoms); 583 628 584 629 // ===== 2. perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs ===== … … 586 631 587 632 // analysis of the cycles (print rings, get minimum cycle length) for each subgraph 588 for(int i= AtomCount;i--;)589 MinimumRingSize[i] = AtomCount;633 for(int i=getAtomCount();i--;) 634 MinimumRingSize[i] = getAtomCount(); 590 635 MolecularWalker = Subgraphs; 591 636 FragmentCounter = 0; … … 598 643 // // check the list of local atoms for debugging 599 644 // Log() << Verbose(0) << "ListOfLocalAtoms for this subgraph is:" << endl; 600 // for (int i=0;i< AtomCount;i++)645 // for (int i=0;i<getAtomCount();i++) 601 646 // if (ListOfLocalAtoms[FragmentCounter][i] == NULL) 602 647 // Log() << Verbose(0) << "\tNULL"; … … 624 669 // ===== 6b. prepare and go into the adaptive (Order<0), single-step (Order==0) or incremental (Order>0) cycle 625 670 KeyStack *RootStack = new KeyStack[Subgraphs->next->Count()]; 626 AtomMask = new bool[ AtomCount+1];627 AtomMask[ AtomCount] = false;671 AtomMask = new bool[getAtomCount()+1]; 672 AtomMask[getAtomCount()] = false; 628 673 FragmentationToDo = false; // if CheckOrderAtSite just ones recommends fragmentation, we will save fragments afterwards 629 674 while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, configuration->configpath))) { 630 675 FragmentationToDo = FragmentationToDo || CheckOrder; 631 AtomMask[ AtomCount] = true; // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite()676 AtomMask[getAtomCount()] = true; // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite() 632 677 // ===== 6b. fill RootStack for each subgraph (second adaptivity check) ===== 633 678 Subgraphs->next->FillRootStackForSubgraphs(RootStack, AtomMask, (FragmentCounter = 0)); … … 640 685 DoLog(1) && (Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl); 641 686 //MolecularWalker->Leaf->OutputListOfBonds(out); // output atom::ListOfBonds for debugging 642 if (MolecularWalker->Leaf-> first->next != MolecularWalker->Leaf->last) {687 if (MolecularWalker->Leaf->hasBondStructure()) { 643 688 // call BOSSANOVA method 644 689 DoLog(0) && (Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl); … … 672 717 delete(Subgraphs); 673 718 } 674 Free(&FragmentList);719 delete[](FragmentList); 675 720 676 721 // ===== 8b. gather keyset lists (graphs) from all subgraphs and transform into MoleculeListClass ===== … … 690 735 if (BondFragments->ListOfMolecules.size() != 0) { 691 736 // create the SortIndex from BFS labels to order in the config file 737 int *SortIndex = NULL; 692 738 CreateMappingLabelsToConfigSequence(SortIndex); 693 739 … … 704 750 StoreKeySetFile(TotalGraph, configuration->configpath); 705 751 706 // store Adjacency file 707 char *filename = Malloc<char> (MAXSTRINGSIZE, "molecule::FragmentMolecule - *filename"); 708 strcpy(filename, FRAGMENTPREFIX); 709 strcat(filename, ADJACENCYFILE); 710 StoreAdjacencyToFile(configuration->configpath, filename); 711 Free(&filename); 752 { 753 // store Adjacency file 754 char filename[MAXSTRINGSIZE]; 755 strcpy(filename, FRAGMENTPREFIX); 756 strcat(filename, ADJACENCYFILE); 757 StoreAdjacencyToFile(configuration->configpath, filename); 758 } 712 759 713 760 // store Hydrogen saturation correction file … … 722 769 // free memory for bond part 723 770 DoLog(1) && (Log() << Verbose(1) << "Freeing bond memory" << endl); 724 Free(&FragmentList); // remove bond molecule from memory 725 Free(&SortIndex); 771 delete[](SortIndex); 726 772 } else { 727 773 DoLog(1) && (Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl); … … 768 814 bool molecule::ParseOrderAtSiteFromFile(char *path) 769 815 { 770 unsigned char *OrderArray = Calloc<unsigned char>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *OrderArray");771 bool *MaxArray = Calloc<bool>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *MaxArray");816 unsigned char *OrderArray = new unsigned char[getAtomCount()]; 817 bool *MaxArray = new bool[getAtomCount()]; 772 818 bool status; 773 819 int AtomNr, value; 774 820 stringstream line; 775 821 ifstream file; 822 823 for(int i=0;i<getAtomCount();i++) { 824 OrderArray[i] = 0; 825 MaxArray[i] = false; 826 } 776 827 777 828 DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl); … … 796 847 SetAtomValueToIndexedArray( MaxArray, &atom::nr, &atom::MaxOrder ); 797 848 798 DoLog(1) && (Log() << Verbose(1) << " done." << endl);849 DoLog(1) && (Log() << Verbose(1) << "\t ... done." << endl); 799 850 status = true; 800 851 } else { 801 DoLog(1) && (Log() << Verbose(1) << " failed to open file " << line.str() << "." << endl);852 DoLog(1) && (Log() << Verbose(1) << "\t ... failed to open file " << line.str() << "." << endl); 802 853 status = false; 803 854 } 804 Free(&OrderArray);805 Free(&MaxArray);855 delete[](OrderArray); 856 delete[](MaxArray); 806 857 807 858 DoLog(1) && (Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl); … … 872 923 atom *OtherFather = NULL; 873 924 atom *FatherOfRunner = NULL; 874 Leaf->CountAtoms(); 875 876 atom *Runner = Leaf->start; 877 while (Runner->next != Leaf->end) { 878 Runner = Runner->next; 925 926 #ifdef ADDHYDROGEN 927 molecule::const_iterator runner; 928 #endif 929 // we increment the iter just before skipping the hydrogen 930 for (molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end();) { 879 931 LonelyFlag = true; 880 FatherOfRunner = Runner->father; 932 FatherOfRunner = (*iter)->father; 933 ASSERT(FatherOfRunner,"Atom without father found"); 881 934 if (SonList[FatherOfRunner->nr] != NULL) { // check if this, our father, is present in list 882 935 // create all bonds … … 889 942 // Log() << Verbose(3) << "Adding Bond: "; 890 943 // Log() << Verbose(0) << 891 Leaf->AddBond( Runner, SonList[OtherFather->nr], (*BondRunner)->BondDegree);944 Leaf->AddBond((*iter), SonList[OtherFather->nr], (*BondRunner)->BondDegree); 892 945 // Log() << Verbose(0) << "." << endl; 893 //NumBonds[ Runner->nr]++;946 //NumBonds[(*iter)->nr]++; 894 947 } else { 895 948 // Log() << Verbose(3) << "Not adding bond, labels in wrong order." << endl; … … 899 952 // Log() << Verbose(0) << ", who has no son in this fragment molecule." << endl; 900 953 #ifdef ADDHYDROGEN 901 //Log() << Verbose(3) << "Adding Hydrogen to " << Runner->Name << " and a bond in between." << endl;902 if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), Runner, FatherOfRunner, OtherFather, IsAngstroem))954 //Log() << Verbose(3) << "Adding Hydrogen to " << (*iter)->Name << " and a bond in between." << endl; 955 if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), (*iter), FatherOfRunner, OtherFather, IsAngstroem)) 903 956 exit(1); 904 957 #endif 905 //NumBonds[ Runner->nr] += Binder->BondDegree;958 //NumBonds[(*iter)->nr] += Binder->BondDegree; 906 959 } 907 960 } 908 961 } else { 909 DoeLog(1) && (eLog()<< Verbose(1) << "Son " << Runner->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl); 910 } 911 if ((LonelyFlag) && (Leaf->AtomCount > 1)) { 912 DoLog(0) && (Log() << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl); 913 } 962 DoeLog(1) && (eLog()<< Verbose(1) << "Son " << (*iter)->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl); 963 } 964 if ((LonelyFlag) && (Leaf->getAtomCount() > 1)) { 965 DoLog(0) && (Log() << Verbose(0) << **iter << "has got bonds only to hydrogens!" << endl); 966 } 967 ++iter; 914 968 #ifdef ADDHYDROGEN 915 while ((Runner->next != Leaf->end) && (Runner->next->type->Z == 1)) // skip added hydrogen 916 Runner = Runner->next; 969 while ((iter != Leaf->end()) && ((*iter)->type->Z == 1)){ // skip added hydrogen 970 iter++; 971 } 917 972 #endif 918 973 } … … 929 984 molecule * molecule::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem) 930 985 { 931 atom **SonList = Calloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList");986 atom **SonList = new atom*[getAtomCount()]; 932 987 molecule *Leaf = World::getInstance().createMolecule(); 988 989 for(int i=0;i<getAtomCount();i++) 990 SonList[i] = NULL; 933 991 934 992 // Log() << Verbose(1) << "Begin of StoreFragmentFromKeyset." << endl; … … 939 997 940 998 //Leaflet->Leaf->ScanForPeriodicCorrection(out); 941 Free(&SonList);999 delete[](SonList); 942 1000 // Log() << Verbose(1) << "End of StoreFragmentFromKeyset." << endl; 943 1001 return Leaf; … … 1084 1142 int bits, TouchedIndex, SubSetDimension, SP, Added; 1085 1143 int SpaceLeft; 1086 int *TouchedList = Malloc<int>(SubOrder + 1, "molecule::SPFragmentGenerator: *TouchedList"); 1087 bond **BondsList = NULL; 1144 int *TouchedList = new int[SubOrder + 1]; 1088 1145 KeySetTestPair TestKeySetInsert; 1089 1146 … … 1124 1181 1125 1182 // then allocate and fill the list 1126 BondsList = Malloc<bond*>(SubSetDimension, "molecule::SPFragmentGenerator: **BondsList");1183 bond *BondsList[SubSetDimension]; 1127 1184 SubSetDimension = FillBondsList(BondsList, FragmentSearch->BondsPerSPList[2*SP], FragmentSearch->BondsPerSPList[2*SP+1], TouchedList, TouchedIndex); 1128 1185 … … 1130 1187 Log() << Verbose(2+verbosity) << "Calling subset generator " << SP << " away from root " << *FragmentSearch->Root << " with sub set dimension " << SubSetDimension << "." << endl; 1131 1188 SPFragmentGenerator(FragmentSearch, SP, BondsList, SubSetDimension, SubOrder-bits); 1132 1133 Free(&BondsList);1134 1189 } 1135 1190 } else { … … 1153 1208 } 1154 1209 } 1155 Free(&TouchedList);1210 delete[](TouchedList); 1156 1211 Log() << Verbose(1+verbosity) << "End of SPFragmentGenerator, " << RootDistance << " away from Root " << *FragmentSearch->Root << " and SubOrder is " << SubOrder << "." << endl; 1157 1212 }; … … 1165 1220 void InitialiseSPList(int Order, struct UniqueFragments &FragmentSearch) 1166 1221 { 1167 FragmentSearch.BondsPerSPList = Malloc<bond*>(Order * 2, "molecule::PowerSetGenerator: ***BondsPerSPList");1168 FragmentSearch.BondsPerSPCount = Malloc<int>(Order, "molecule::PowerSetGenerator: *BondsPerSPCount");1222 FragmentSearch.BondsPerSPList = new bond* [Order * 2]; 1223 FragmentSearch.BondsPerSPCount = new int[Order]; 1169 1224 for (int i=Order;i--;) { 1170 1225 FragmentSearch.BondsPerSPList[2*i] = new bond(); // start node … … 1184 1239 void FreeSPList(int Order, struct UniqueFragments &FragmentSearch) 1185 1240 { 1186 Free(&FragmentSearch.BondsPerSPCount);1241 delete[](FragmentSearch.BondsPerSPCount); 1187 1242 for (int i=Order;i--;) { 1188 1243 delete(FragmentSearch.BondsPerSPList[2*i]); 1189 1244 delete(FragmentSearch.BondsPerSPList[2*i+1]); 1190 1245 } 1191 Free(&FragmentSearch.BondsPerSPList);1246 delete[](FragmentSearch.BondsPerSPList); 1192 1247 }; 1193 1248 … … 1370 1425 int molecule::PowerSetGenerator(int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet) 1371 1426 { 1372 bond **BondsList = NULL;1373 1427 int Counter = FragmentSearch.FragmentCounter; // mark current value of counter 1374 1428 … … 1394 1448 1395 1449 // prepare the subset and call the generator 1396 BondsList = Calloc<bond*>(FragmentSearch.BondsPerSPCount[0], "molecule::PowerSetGenerator: **BondsList"); 1450 bond* BondsList[FragmentSearch.BondsPerSPCount[0]]; 1451 for(int i=0;i<FragmentSearch.BondsPerSPCount[0];i++) 1452 BondsList[i] = NULL; 1397 1453 BondsList[0] = FragmentSearch.BondsPerSPList[0]->next; // on SP level 0 there's only the root bond 1398 1454 1399 1455 SPFragmentGenerator(&FragmentSearch, 0, BondsList, FragmentSearch.BondsPerSPCount[0], Order); 1400 1401 Free(&BondsList);1402 1456 } else { 1403 1457 DoLog(0) && (Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl); … … 1507 1561 } 1508 1562 } 1509 Free(&FragmentLowerOrdersList[RootNr]);1563 delete[](FragmentLowerOrdersList[RootNr]); 1510 1564 RootNr++; 1511 1565 } 1512 Free(&FragmentLowerOrdersList);1566 delete[](FragmentLowerOrdersList); 1513 1567 }; 1514 1568 … … 1549 1603 // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5) 1550 1604 // with all needed lower orders that are subtracted, the other dimension is the BondOrder (i.e. from 1 to 5) 1551 NumMoleculesOfOrder = Calloc<int>(UpgradeCount, "molecule::FragmentBOSSANOVA: *NumMoleculesOfOrder"); 1552 FragmentLowerOrdersList = Calloc<Graph**>(UpgradeCount, "molecule::FragmentBOSSANOVA: ***FragmentLowerOrdersList"); 1605 NumMoleculesOfOrder = new int[UpgradeCount]; 1606 FragmentLowerOrdersList = new Graph**[UpgradeCount]; 1607 1608 for(int i=0;i<UpgradeCount;i++) { 1609 NumMoleculesOfOrder[i] = 0; 1610 FragmentLowerOrdersList[i] = NULL; 1611 } 1553 1612 1554 1613 // initialise the fragments structure … … 1556 1615 FragmentSearch.FragmentSet = new KeySet; 1557 1616 FragmentSearch.Root = FindAtom(RootKeyNr); 1558 FragmentSearch.ShortestPathList = Malloc<int>(AtomCount, "molecule::PowerSetGenerator: *ShortestPathList");1559 for (int i= AtomCount;i--;) {1617 FragmentSearch.ShortestPathList = new int[getAtomCount()]; 1618 for (int i=getAtomCount();i--;) { 1560 1619 FragmentSearch.ShortestPathList[i] = -1; 1561 1620 } 1562 1621 1563 1622 // Construct the complete KeySet which we need for topmost level only (but for all Roots) 1564 atom *Walker = start;1565 1623 KeySet CompleteMolecule; 1566 while (Walker->next != end) { 1567 Walker = Walker->next; 1568 CompleteMolecule.insert(Walker->GetTrueFather()->nr); 1624 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 1625 CompleteMolecule.insert((*iter)->GetTrueFather()->nr); 1569 1626 } 1570 1627 … … 1577 1634 RootKeyNr = RootStack.front(); 1578 1635 RootStack.pop_front(); 1579 Walker = FindAtom(RootKeyNr);1636 atom *Walker = FindAtom(RootKeyNr); 1580 1637 // check cyclic lengths 1581 1638 //if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) { … … 1592 1649 // allocate memory for all lower level orders in this 1D-array of ptrs 1593 1650 NumLevels = 1 << (Order-1); // (int)pow(2,Order); 1594 FragmentLowerOrdersList[RootNr] = Calloc<Graph*>(NumLevels, "molecule::FragmentBOSSANOVA: **FragmentLowerOrdersList[]"); 1651 FragmentLowerOrdersList[RootNr] = new Graph*[NumLevels]; 1652 for (int i=0;i<NumLevels;i++) 1653 FragmentLowerOrdersList[RootNr][i] = NULL; 1595 1654 1596 1655 // create top order where nothing is reduced … … 1628 1687 1629 1688 // cleanup FragmentSearch structure 1630 Free(&FragmentSearch.ShortestPathList);1689 delete[](FragmentSearch.ShortestPathList); 1631 1690 delete(FragmentSearch.FragmentSet); 1632 1691 … … 1641 1700 CombineAllOrderListIntoOne(FragmentList, FragmentLowerOrdersList, RootStack, this); 1642 1701 FreeAllOrdersList(FragmentLowerOrdersList, RootStack, this); 1643 Free(&NumMoleculesOfOrder);1702 delete[](NumMoleculesOfOrder); 1644 1703 1645 1704 DoLog(0) && (Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl); … … 1664 1723 Vector Translationvector; 1665 1724 //class StackClass<atom *> *CompStack = NULL; 1666 class StackClass<atom *> *AtomStack = new StackClass<atom *>( AtomCount);1725 class StackClass<atom *> *AtomStack = new StackClass<atom *>(getAtomCount()); 1667 1726 bool flag = true; 1668 1727 1669 1728 DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl); 1670 1729 1671 ColorList = Calloc<enum Shading>(AtomCount, "molecule::ScanForPeriodicCorrection: *ColorList"); 1730 ColorList = new enum Shading[getAtomCount()]; 1731 for (int i=0;i<getAtomCount();i++) 1732 ColorList[i] = (enum Shading)0; 1672 1733 while (flag) { 1673 1734 // remove bonds that are beyond bonddistance 1674 1735 Translationvector.Zero(); 1675 1736 // scan all bonds 1676 Binder = first;1677 1737 flag = false; 1678 while ((!flag) && (Binder->next != last)) { 1679 Binder = Binder->next; 1680 for (int i=NDIM;i--;) { 1681 tmp = fabs(Binder->leftatom->x[i] - Binder->rightatom->x[i]); 1682 //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl; 1683 if (tmp > BondDistance) { 1684 OtherBinder = Binder->next; // note down binding partner for later re-insertion 1685 unlink(Binder); // unlink bond 1686 DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl); 1687 flag = true; 1688 break; 1738 for(molecule::iterator AtomRunner = begin(); (!flag) && (AtomRunner != end()); ++AtomRunner) 1739 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); (!flag) && (BondRunner != (*AtomRunner)->ListOfBonds.end()); ++BondRunner) { 1740 Binder = (*BondRunner); 1741 for (int i=NDIM;i--;) { 1742 tmp = fabs(Binder->leftatom->x[i] - Binder->rightatom->x[i]); 1743 //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl; 1744 if (tmp > BondDistance) { 1745 OtherBinder = Binder->next; // note down binding partner for later re-insertion 1746 unlink(Binder); // unlink bond 1747 DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl); 1748 flag = true; 1749 break; 1750 } 1689 1751 } 1690 1752 } 1691 }1692 1753 if (flag) { 1693 1754 // create translation vector from their periodically modified distance … … 1701 1762 Log() << Verbose(0) << Translationvector << endl; 1702 1763 // apply to all atoms of first component via BFS 1703 for (int i= AtomCount;i--;)1764 for (int i=getAtomCount();i--;) 1704 1765 ColorList[i] = white; 1705 1766 AtomStack->Push(Binder->leftatom); … … 1727 1788 // free allocated space from ReturnFullMatrixforSymmetric() 1728 1789 delete(AtomStack); 1729 Free(&ColorList);1730 Free(&matrix);1790 delete[](ColorList); 1791 delete[](matrix); 1731 1792 DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl); 1732 1793 }; -
src/molecule_geometry.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom.hpp" … … 17 19 #include "World.hpp" 18 20 #include "Plane.hpp" 21 #include <boost/foreach.hpp> 22 19 23 20 24 /************************************* Functions for class molecule *********************************/ … … 28 32 bool status = true; 29 33 const Vector *Center = DetermineCenterOfAll(); 34 const Vector *CenterBox = DetermineCenterOfBox(); 30 35 double * const cell_size = World::getInstance().getDomain(); 31 36 double *M = ReturnFullMatrixforSymmetric(cell_size); … … 34 39 // go through all atoms 35 40 ActOnAllVectors( &Vector::SubtractVector, *Center); 41 ActOnAllVectors( &Vector::SubtractVector, *CenterBox); 36 42 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 37 43 38 Free(&M);39 Free(&Minv);44 delete[](M); 45 delete[](Minv); 40 46 delete(Center); 41 47 return status; … … 56 62 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 57 63 58 Free(&M);59 Free(&Minv);64 delete[](M); 65 delete[](Minv); 60 66 return status; 61 67 }; … … 70 76 71 77 // Log() << Verbose(3) << "Begin of CenterEdge." << endl; 72 atom *ptr = start->next; // start at first in list73 if ( ptr != end) {//list not empty?78 molecule::const_iterator iter = begin(); // start at first in list 79 if (iter != end()) { //list not empty? 74 80 for (int i=NDIM;i--;) { 75 max->at(i) = ptr->x[i]; 76 min->at(i) = ptr->x[i]; 77 } 78 while (ptr->next != end) { // continue with second if present 79 ptr = ptr->next; 80 //ptr->Output(1,1,out); 81 max->at(i) = (*iter)->x[i]; 82 min->at(i) = (*iter)->x[i]; 83 } 84 for (; iter != end(); ++iter) {// continue with second if present 85 //(*iter)->Output(1,1,out); 81 86 for (int i=NDIM;i--;) { 82 max->at(i) = (max->at(i) < ptr->x[i]) ? ptr->x[i] : max->at(i);83 min->at(i) = (min->at(i) > ptr->x[i]) ? ptr->x[i] : min->at(i);87 max->at(i) = (max->at(i) < (*iter)->x[i]) ? (*iter)->x[i] : max->at(i); 88 min->at(i) = (min->at(i) > (*iter)->x[i]) ? (*iter)->x[i] : min->at(i); 84 89 } 85 90 } … … 105 110 { 106 111 int Num = 0; 107 atom *ptr = start; // start at first in list112 molecule::const_iterator iter = begin(); // start at first in list 108 113 109 114 Center.Zero(); 110 115 111 if (ptr->next != end) { //list not empty? 112 while (ptr->next != end) { // continue with second if present 113 ptr = ptr->next; 116 if (iter != end()) { //list not empty? 117 for (; iter != end(); ++iter) { // continue with second if present 114 118 Num++; 115 Center += ptr->x;119 Center += (*iter)->x; 116 120 } 117 121 Center.Scale(-1./Num); // divide through total number (and sign for direction) … … 126 130 Vector * molecule::DetermineCenterOfAll() const 127 131 { 128 atom *ptr = start->next; // start at first in list 132 molecule::const_iterator iter = begin(); // start at first in list 133 Vector *a = new Vector(); 134 double Num = 0; 135 136 a->Zero(); 137 138 if (iter != end()) { //list not empty? 139 for (; iter != end(); ++iter) { // continue with second if present 140 Num++; 141 (*a) += (*iter)->x; 142 } 143 a->Scale(1./Num); // divide through total mass (and sign for direction) 144 } 145 return a; 146 }; 147 148 /** Returns vector pointing to center of the domain. 149 * \return pointer to center of the domain 150 */ 151 Vector * molecule::DetermineCenterOfBox() const 152 { 153 Vector *a = new Vector(0.5,0.5,0.5); 154 155 const double *cell_size = World::getInstance().getDomain(); 156 double *M = ReturnFullMatrixforSymmetric(cell_size); 157 a->MatrixMultiplication(M); 158 delete[](M); 159 160 return a; 161 }; 162 163 /** Returns vector pointing to center of gravity. 164 * \param *out output stream for debugging 165 * \return pointer to center of gravity vector 166 */ 167 Vector * molecule::DetermineCenterOfGravity() 168 { 169 molecule::const_iterator iter = begin(); // start at first in list 129 170 Vector *a = new Vector(); 130 171 Vector tmp; … … 133 174 a->Zero(); 134 175 135 if (ptr != end) { //list not empty? 136 while (ptr->next != end) { // continue with second if present 137 ptr = ptr->next; 138 Num += 1.; 139 tmp = ptr->x; 176 if (iter != end()) { //list not empty? 177 for (; iter != end(); ++iter) { // continue with second if present 178 Num += (*iter)->type->mass; 179 tmp = (*iter)->type->mass * (*iter)->x; 140 180 (*a) += tmp; 141 181 } 142 182 a->Scale(1./Num); // divide through total mass (and sign for direction) 143 }144 return a;145 };146 147 /** Returns vector pointing to center of gravity.148 * \param *out output stream for debugging149 * \return pointer to center of gravity vector150 */151 Vector * molecule::DetermineCenterOfGravity()152 {153 atom *ptr = start->next; // start at first in list154 Vector *a = new Vector();155 Vector tmp;156 double Num = 0;157 158 a->Zero();159 160 if (ptr != end) { //list not empty?161 while (ptr->next != end) { // continue with second if present162 ptr = ptr->next;163 Num += ptr->type->mass;164 tmp = ptr->type->mass * ptr->x;165 (*a) += tmp;166 }167 a->Scale(-1./Num); // divide through total mass (and sign for direction)168 183 } 169 184 // Log() << Verbose(1) << "Resulting center of gravity: "; … … 203 218 void molecule::Scale(const double ** const factor) 204 219 { 205 atom *ptr = start; 206 207 while (ptr->next != end) { 208 ptr = ptr->next; 220 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 209 221 for (int j=0;j<MDSteps;j++) 210 ptr->Trajectory.R.at(j).ScaleAll(*factor);211 ptr->x.ScaleAll(*factor);222 (*iter)->Trajectory.R.at(j).ScaleAll(*factor); 223 (*iter)->x.ScaleAll(*factor); 212 224 } 213 225 }; … … 218 230 void molecule::Translate(const Vector *trans) 219 231 { 220 atom *ptr = start; 221 222 while (ptr->next != end) { 223 ptr = ptr->next; 232 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 224 233 for (int j=0;j<MDSteps;j++) 225 ptr->Trajectory.R.at(j) += (*trans);226 ptr->x += (*trans);234 (*iter)->Trajectory.R.at(j) += (*trans); 235 (*iter)->x += (*trans); 227 236 } 228 237 }; … … 239 248 240 249 // go through all atoms 241 ActOnAllVectors( &Vector:: SubtractVector, *trans);250 ActOnAllVectors( &Vector::AddVector, *trans); 242 251 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 243 252 244 Free(&M);245 Free(&Minv);253 delete[](M); 254 delete[](Minv); 246 255 }; 247 256 … … 252 261 void molecule::Mirror(const Vector *n) 253 262 { 263 OBSERVE; 254 264 Plane p(*n,0); 255 // TODO: replace with simpler construct (e.g. Boost::foreach) 256 // once the structure of the atom list is fully reworked 257 atom *Walker = start; 258 while (Walker->next != end) { 259 Walker = Walker->next; 260 (*Walker->node) = p.mirrorVector(*Walker->node); 265 BOOST_FOREACH( atom* iter, atoms ){ 266 (*iter->node) = p.mirrorVector(*iter->node); 261 267 } 262 268 }; … … 267 273 void molecule::DeterminePeriodicCenter(Vector ¢er) 268 274 { 269 atom *Walker = start;270 275 double * const cell_size = World::getInstance().getDomain(); 271 276 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 272 double *inversematrix = InverseMatrix( cell_size);277 double *inversematrix = InverseMatrix(matrix); 273 278 double tmp; 274 279 bool flag; … … 278 283 Center.Zero(); 279 284 flag = true; 280 while (Walker->next != end) { 281 Walker = Walker->next; 285 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 282 286 #ifdef ADDHYDROGEN 283 if ( Walker->type->Z != 1) {287 if ((*iter)->type->Z != 1) { 284 288 #endif 285 Testvector = Walker->x;289 Testvector = (*iter)->x; 286 290 Testvector.MatrixMultiplication(inversematrix); 287 291 Translationvector.Zero(); 288 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {289 if ( Walker->nr < (*Runner)->GetOtherAtom(Walker)->nr) // otherwise we shift one to, the other fro and gain nothing292 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 293 if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing 290 294 for (int j=0;j<NDIM;j++) { 291 tmp = Walker->x[j] - (*Runner)->GetOtherAtom(Walker)->x[j];295 tmp = (*iter)->x[j] - (*Runner)->GetOtherAtom(*iter)->x[j]; 292 296 if ((fabs(tmp)) > BondDistance) { 293 297 flag = false; 294 DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << Walker->getName() << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl);298 DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << (*iter)->getName() << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl); 295 299 if (tmp > 0) 296 300 Translationvector[j] -= 1.; … … 306 310 #ifdef ADDHYDROGEN 307 311 // now also change all hydrogens 308 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {309 if ((*Runner)->GetOtherAtom( Walker)->type->Z == 1) {310 Testvector = (*Runner)->GetOtherAtom( Walker)->x;312 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 313 if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) { 314 Testvector = (*Runner)->GetOtherAtom((*iter))->x; 311 315 Testvector.MatrixMultiplication(inversematrix); 312 316 Testvector += Translationvector; … … 320 324 } 321 325 } while (!flag); 322 Free(&matrix);323 Free(&inversematrix);324 325 Center.Scale(1./ (double)AtomCount);326 delete[](matrix); 327 delete[](inversematrix); 328 329 Center.Scale(1./static_cast<double>(getAtomCount())); 326 330 }; 327 331 … … 333 337 void molecule::PrincipalAxisSystem(bool DoRotate) 334 338 { 335 atom *ptr = start; // start at first in list336 339 double InertiaTensor[NDIM*NDIM]; 337 340 Vector *CenterOfGravity = DetermineCenterOfGravity(); … … 344 347 345 348 // sum up inertia tensor 346 while (ptr->next != end) { 347 ptr = ptr->next; 348 Vector x = ptr->x; 349 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 350 Vector x = (*iter)->x; 349 351 //x.SubtractVector(CenterOfGravity); 350 InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]);351 InertiaTensor[1] += ptr->type->mass*(-x[0]*x[1]);352 InertiaTensor[2] += ptr->type->mass*(-x[0]*x[2]);353 InertiaTensor[3] += ptr->type->mass*(-x[1]*x[0]);354 InertiaTensor[4] += ptr->type->mass*(x[0]*x[0] + x[2]*x[2]);355 InertiaTensor[5] += ptr->type->mass*(-x[1]*x[2]);356 InertiaTensor[6] += ptr->type->mass*(-x[2]*x[0]);357 InertiaTensor[7] += ptr->type->mass*(-x[2]*x[1]);358 InertiaTensor[8] += ptr->type->mass*(x[0]*x[0] + x[1]*x[1]);352 InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]); 353 InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]); 354 InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]); 355 InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]); 356 InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]); 357 InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]); 358 InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]); 359 InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]); 360 InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]); 359 361 } 360 362 // print InertiaTensor for debugging … … 394 396 395 397 // sum up inertia tensor 396 ptr = start; 397 while (ptr->next != end) { 398 ptr = ptr->next; 399 Vector x = ptr->x; 400 //x.SubtractVector(CenterOfGravity); 401 InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]); 402 InertiaTensor[1] += ptr->type->mass*(-x[0]*x[1]); 403 InertiaTensor[2] += ptr->type->mass*(-x[0]*x[2]); 404 InertiaTensor[3] += ptr->type->mass*(-x[1]*x[0]); 405 InertiaTensor[4] += ptr->type->mass*(x[0]*x[0] + x[2]*x[2]); 406 InertiaTensor[5] += ptr->type->mass*(-x[1]*x[2]); 407 InertiaTensor[6] += ptr->type->mass*(-x[2]*x[0]); 408 InertiaTensor[7] += ptr->type->mass*(-x[2]*x[1]); 409 InertiaTensor[8] += ptr->type->mass*(x[0]*x[0] + x[1]*x[1]); 398 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 399 Vector x = (*iter)->x; 400 InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]); 401 InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]); 402 InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]); 403 InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]); 404 InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]); 405 InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]); 406 InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]); 407 InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]); 408 InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]); 410 409 } 411 410 // print InertiaTensor for debugging … … 431 430 void molecule::Align(Vector *n) 432 431 { 433 atom *ptr = start;434 432 double alpha, tmp; 435 433 Vector z_axis; … … 442 440 alpha = atan(-n->at(0)/n->at(2)); 443 441 DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... "); 444 while (ptr->next != end) { 445 ptr = ptr->next; 446 tmp = ptr->x[0]; 447 ptr->x[0] = cos(alpha) * tmp + sin(alpha) * ptr->x[2]; 448 ptr->x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x[2]; 442 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 443 tmp = (*iter)->x[0]; 444 (*iter)->x[0] = cos(alpha) * tmp + sin(alpha) * (*iter)->x[2]; 445 (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2]; 449 446 for (int j=0;j<MDSteps;j++) { 450 tmp = ptr->Trajectory.R.at(j)[0];451 ptr->Trajectory.R.at(j)[0] = cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j)[2];452 ptr->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j)[2];447 tmp = (*iter)->Trajectory.R.at(j)[0]; 448 (*iter)->Trajectory.R.at(j)[0] = cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2]; 449 (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2]; 453 450 } 454 451 } … … 460 457 461 458 // rotate on z-y plane 462 ptr = start;463 459 alpha = atan(-n->at(1)/n->at(2)); 464 460 DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... "); 465 while (ptr->next != end) { 466 ptr = ptr->next; 467 tmp = ptr->x[1]; 468 ptr->x[1] = cos(alpha) * tmp + sin(alpha) * ptr->x[2]; 469 ptr->x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x[2]; 461 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 462 tmp = (*iter)->x[1]; 463 (*iter)->x[1] = cos(alpha) * tmp + sin(alpha) * (*iter)->x[2]; 464 (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2]; 470 465 for (int j=0;j<MDSteps;j++) { 471 tmp = ptr->Trajectory.R.at(j)[1];472 ptr->Trajectory.R.at(j)[1] = cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j)[2];473 ptr->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j)[2];466 tmp = (*iter)->Trajectory.R.at(j)[1]; 467 (*iter)->Trajectory.R.at(j)[1] = cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2]; 468 (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2]; 474 469 } 475 470 } … … 495 490 Vector a,b,c,d; 496 491 struct lsq_params *par = (struct lsq_params *)params; 497 atom *ptr = par->mol->start;498 492 499 493 // initialize vectors … … 505 499 b[2] = gsl_vector_get(x,5); 506 500 // go through all atoms 507 while (ptr != par->mol->end) { 508 ptr = ptr->next; 509 if (ptr->type == ((struct lsq_params *)params)->type) { // for specific type 510 c = ptr->x - a; 501 for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) { 502 if ((*iter)->type == ((struct lsq_params *)params)->type) { // for specific type 503 c = (*iter)->x - a; 511 504 t = c.ScalarProduct(b); // get direction parameter 512 505 d = t*b; // and create vector -
src/molecule_graph.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom.hpp" … … 12 14 #include "element.hpp" 13 15 #include "helpers.hpp" 16 #include "info.hpp" 14 17 #include "linkedcell.hpp" 15 18 #include "lists.hpp" … … 19 22 #include "World.hpp" 20 23 #include "Helpers/fast_functions.hpp" 24 #include "Helpers/Assert.hpp" 25 21 26 22 27 struct BFSAccounting … … 54 59 void molecule::CreateAdjacencyListFromDbondFile(ifstream *input) 55 60 { 56 61 Info FunctionInfo(__func__); 57 62 // 1 We will parse bonds out of the dbond file created by tremolo. 58 63 int atom1, atom2; 59 64 atom *Walker, *OtherWalker; 60 61 if (!input) { 62 DoLog(1) && (Log() << Verbose(1) << "Opening silica failed \n"); 65 char line[MAXSTRINGSIZE]; 66 67 if (input->fail()) { 68 DoeLog(0) && (eLog() << Verbose(0) << "Opening of bond file failed \n"); 69 performCriticalExit(); 63 70 }; 64 65 *input >> ws >> atom1; 66 *input >> ws >> atom2; 67 DoLog(1) && (Log() << Verbose(1) << "Scanning file\n"); 71 doCountAtoms(); 72 73 // skip header 74 input->getline(line,MAXSTRINGSIZE); 75 DoLog(1) && (Log() << Verbose(1) << "Scanning file ... \n"); 68 76 while (!input->eof()) // Check whether we read everything already 69 77 { 70 *input >> ws >> atom1; 71 *input >> ws >> atom2; 72 78 input->getline(line,MAXSTRINGSIZE); 79 stringstream zeile(line); 80 zeile >> atom1; 81 zeile >> atom2; 82 83 DoLog(2) && (Log() << Verbose(2) << "Looking for atoms " << atom1 << " and " << atom2 << "." << endl); 73 84 if (atom2 < atom1) //Sort indices of atoms in order 74 85 flip(atom1, atom2); 75 86 Walker = FindAtom(atom1); 87 ASSERT(Walker,"Could not find an atom with the ID given in dbond file"); 76 88 OtherWalker = FindAtom(atom2); 89 ASSERT(OtherWalker,"Could not find an atom with the ID given in dbond file"); 77 90 AddBond(Walker, OtherWalker); //Add the bond between the two atoms with respective indices. 78 91 } … … 103 116 atom *Walker = NULL; 104 117 atom *OtherWalker = NULL; 105 atom **AtomMap = NULL;106 118 int n[NDIM]; 107 119 double MinDistance, MaxDistance; … … 118 130 DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl); 119 131 // remove every bond from the list 120 bond *Binder = NULL; 121 while (last->previous != first) { 122 Binder = last->previous; 123 Binder->leftatom->UnregisterBond(Binder); 124 Binder->rightatom->UnregisterBond(Binder); 125 removewithoutcheck(Binder); 126 } 132 for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 133 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin()) 134 if ((*BondRunner)->leftatom == *AtomRunner) 135 delete((*BondRunner)); 127 136 BondCount = 0; 128 137 129 138 // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering) 130 CountAtoms(); 131 DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl); 132 133 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.)) { 134 142 DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl); 135 143 LC = new LinkedCell(this, bonddistance); … … 137 145 // create a list to map Tesselpoint::nr to atom * 138 146 DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl); 139 AtomMap = Calloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount"); 140 Walker = start;141 while (Walker->next != end) {142 Walker = Walker->next;143 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++; 144 152 } 145 153 … … 153 161 if (List != NULL) { 154 162 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 155 Walker = AtomMap[(*Runner)->nr]; 156 // 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; 157 166 // 3c. check for possible bond between each atom in this and every one in the 27 cells 158 167 for (n[0] = -1; n[0] <= 1; n[0]++) … … 164 173 for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) { 165 174 if ((*OtherRunner)->nr > Walker->nr) { 166 OtherWalker = AtomMap[(*OtherRunner)->nr]; 167 // Log() << Verbose(0) << "Current other Atom is " << *OtherWalker << "." << endl; 168 const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x, cell_size); 169 // 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; 170 178 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 179 const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size); 171 180 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 172 181 // Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl; … … 188 197 } 189 198 } 190 Free(&AtomMap);191 199 delete (LC); 192 200 DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl); … … 199 207 ActOnAllAtoms( &atom::OutputBondOfAtom ); 200 208 } else 201 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); 202 210 DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl); 203 211 if (free_BG) … … 206 214 ; 207 215 216 /** Checks for presence of bonds within atom list. 217 * TODO: more sophisticated check for bond structure (e.g. connected subgraph, ...) 218 * \return true - bonds present, false - no bonds 219 */ 220 bool molecule::hasBondStructure() 221 { 222 for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 223 if (!(*AtomRunner)->ListOfBonds.empty()) 224 return true; 225 return false; 226 } 227 228 /** Counts the number of present bonds. 229 * \return number of bonds 230 */ 231 unsigned int molecule::CountBonds() const 232 { 233 unsigned int counter = 0; 234 for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 235 for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 236 if ((*BondRunner)->leftatom == *AtomRunner) 237 counter++; 238 return counter; 239 } 240 208 241 /** Prints a list of all bonds to \a *out. 209 242 * \param output stream … … 212 245 { 213 246 DoLog(1) && (Log() << Verbose(1) << endl << "From contents of bond chain list:"); 214 bond *Binder = first;215 while (Binder->next != last) {216 Binder = Binder->next;217 DoLog(0) && (Log() << Verbose(0) << *Binder<< "\t" << endl);218 }247 for(molecule::const_iterator AtomRunner = molecule::begin(); AtomRunner != molecule::end(); ++AtomRunner) 248 for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 249 if ((*BondRunner)->leftatom == *AtomRunner) { 250 DoLog(0) && (Log() << Verbose(0) << *(*BondRunner) << "\t" << endl); 251 } 219 252 DoLog(0) && (Log() << Verbose(0) << endl); 220 253 } … … 241 274 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 242 275 } else { 243 DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount<< " atoms." << endl);276 DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << getAtomCount() << " atoms." << endl); 244 277 } 245 278 DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl); … … 260 293 MoleculeLeafClass *Subgraphs = NULL; 261 294 class StackClass<bond *> *BackEdgeStack = NULL; 262 bond *Binder = first; 263 if ((Binder->next != last) && (Binder->next->Type == Undetermined)) { 264 DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl); 265 Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack); 266 while (Subgraphs->next != NULL) { 267 Subgraphs = Subgraphs->next; 268 delete (Subgraphs->previous); 269 } 270 delete (Subgraphs); 271 delete[] (MinimumRingSize); 272 } 273 while (Binder->next != last) { 274 Binder = Binder->next; 275 if (Binder->Cyclic) 276 NoCyclicBonds++; 277 } 295 for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 296 if ((!(*AtomRunner)->ListOfBonds.empty()) && ((*(*AtomRunner)->ListOfBonds.begin())->Type == Undetermined)) { 297 DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl); 298 Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack); 299 while (Subgraphs->next != NULL) { 300 Subgraphs = Subgraphs->next; 301 delete (Subgraphs->previous); 302 } 303 delete (Subgraphs); 304 delete[] (MinimumRingSize); 305 break; 306 } 307 for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 308 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 309 if ((*BondRunner)->leftatom == *AtomRunner) 310 if ((*BondRunner)->Cyclic) 311 NoCyclicBonds++; 278 312 delete (BackEdgeStack); 279 313 return NoCyclicBonds; … … 461 495 void DepthFirstSearchAnalysis_Init(struct DFSAccounting &DFS, const molecule * const mol) 462 496 { 463 DFS.AtomStack = new StackClass<atom *> (mol-> AtomCount);497 DFS.AtomStack = new StackClass<atom *> (mol->getAtomCount()); 464 498 DFS.CurrentGraphNr = 0; 465 499 DFS.ComponentNumber = 0; … … 502 536 bond *Binder = NULL; 503 537 504 if ( AtomCount== 0)538 if (getAtomCount() == 0) 505 539 return SubGraphs; 506 540 DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl); 507 541 DepthFirstSearchAnalysis_Init(DFS, this); 508 542 509 DFS.Root = start->next;510 while (DFS.Root != end) { // if there any atoms at all543 for (molecule::const_iterator iter = begin(); iter != end();) { 544 DFS.Root = *iter; 511 545 // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all 512 546 DFS.AtomStack->ClearStack(); … … 548 582 549 583 // step on to next root 550 while (( DFS.Root != end) && (DFS.Root->GraphNr != -1)) {551 //Log() << Verbose(1) << "Current next subgraph root candidate is " << Root->Name << "." << endl;552 if ( DFS.Root->GraphNr != -1) // if already discovered, step on553 DFS.Root = DFS.Root->next;584 while ((iter != end()) && ((*iter)->GraphNr != -1)) { 585 //Log() << Verbose(1) << "Current next subgraph root candidate is " << (*iter)->Name << "." << endl; 586 if ((*iter)->GraphNr != -1) // if already discovered, step on 587 iter++; 554 588 } 555 589 } … … 573 607 { 574 608 NoCyclicBonds = 0; 575 bond *Binder = first; 576 while (Binder->next != last) { 577 Binder = Binder->next; 578 if (Binder->rightatom->LowpointNr == Binder->leftatom->LowpointNr) { // cyclic ?? 579 Binder->Cyclic = true; 580 NoCyclicBonds++; 581 } 582 } 609 for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 610 for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 611 if ((*BondRunner)->leftatom == *AtomRunner) 612 if ((*BondRunner)->rightatom->LowpointNr == (*BondRunner)->leftatom->LowpointNr) { // cyclic ?? 613 (*BondRunner)->Cyclic = true; 614 NoCyclicBonds++; 615 } 583 616 } 584 617 ; … … 599 632 void molecule::OutputGraphInfoPerBond() const 600 633 { 634 bond *Binder = NULL; 601 635 DoLog(1) && (Log() << Verbose(1) << "Final graph info for each bond is:" << endl); 602 bond *Binder = first; 603 while (Binder->next != last) { 604 Binder = Binder->next; 605 DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <"); 606 DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp."); 607 Binder->leftatom->OutputComponentNumber(); 608 DoLog(0) && (Log() << Verbose(0) << " === "); 609 DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp."); 610 Binder->rightatom->OutputComponentNumber(); 611 DoLog(0) && (Log() << Verbose(0) << ">." << endl); 612 if (Binder->Cyclic) // cyclic ?? 613 DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl); 614 } 636 for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 637 for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 638 if ((*BondRunner)->leftatom == *AtomRunner) { 639 Binder = *BondRunner; 640 DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <"); 641 DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp."); 642 Binder->leftatom->OutputComponentNumber(); 643 DoLog(0) && (Log() << Verbose(0) << " === "); 644 DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp."); 645 Binder->rightatom->OutputComponentNumber(); 646 DoLog(0) && (Log() << Verbose(0) << ">." << endl); 647 if (Binder->Cyclic) // cyclic ?? 648 DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl); 649 } 615 650 } 616 651 ; … … 624 659 { 625 660 BFS.AtomCount = AtomCount; 626 BFS.PredecessorList = Calloc<atom*> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: **PredecessorList");627 BFS.ShortestPathList = Malloc<int> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ShortestPathList");628 BFS.ColorList = Calloc<enum Shading> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ColorList");661 BFS.PredecessorList = new atom*[AtomCount]; 662 BFS.ShortestPathList = new int[AtomCount]; 663 BFS.ColorList = new enum Shading[AtomCount]; 629 664 BFS.BFSStack = new StackClass<atom *> (AtomCount); 630 665 631 for (int i = AtomCount; i--;) 666 for (int i = AtomCount; i--;) { 632 667 BFS.ShortestPathList[i] = -1; 668 BFS.PredecessorList[i] = 0; 669 } 633 670 }; 634 671 … … 639 676 void FinalizeBFSAccounting(struct BFSAccounting &BFS) 640 677 { 641 Free(&BFS.PredecessorList);642 Free(&BFS.ShortestPathList);643 Free(&BFS.ColorList);678 delete[](BFS.PredecessorList); 679 delete[](BFS.ShortestPathList); 680 delete[](BFS.ColorList); 644 681 delete (BFS.BFSStack); 645 682 BFS.AtomCount = 0; … … 854 891 if (MinRingSize != -1) { // if rings are present 855 892 // go over all atoms 856 Root = mol->start; 857 while (Root->next != mol->end) { 858 Root = Root->next; 859 860 if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->AtomCount) { // check whether MinimumRingSize is set, if not BFS to next where it is 893 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 894 Root = *iter; 895 896 if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->getAtomCount()) { // check whether MinimumRingSize is set, if not BFS to next where it is 861 897 Walker = Root; 862 898 863 899 //Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl; 864 CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol-> AtomCount);900 CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->getAtomCount()); 865 901 866 902 } … … 892 928 int MinRingSize = -1; 893 929 894 InitializeBFSAccounting(BFS, AtomCount);930 InitializeBFSAccounting(BFS, getAtomCount()); 895 931 896 932 //Log() << Verbose(1) << "Back edge list - "; … … 966 1002 void molecule::ResetAllBondsToUnused() const 967 1003 { 968 bond *Binder = first; 969 while (Binder->next != last) { 970 Binder = Binder->next; 971 Binder->ResetUsed(); 972 } 1004 for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 1005 for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 1006 if ((*BondRunner)->leftatom == *AtomRunner) 1007 (*BondRunner)->ResetUsed(); 973 1008 } 974 1009 ; … … 1004 1039 line << filename; 1005 1040 AdjacencyFile.open(line.str().c_str(), ios::out); 1006 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " );1041 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl); 1007 1042 if (AdjacencyFile != NULL) { 1008 1043 AdjacencyFile << "m\tn" << endl; 1009 1044 ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile); 1010 1045 AdjacencyFile.close(); 1011 DoLog(1) && (Log() << Verbose(1) << " done." << endl);1046 DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl); 1012 1047 } else { 1013 DoLog(1) && (Log() << Verbose(1) << " failed to open file " << line.str() << "." << endl);1048 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line.str() << "." << endl); 1014 1049 status = false; 1015 1050 } … … 1036 1071 line << filename; 1037 1072 BondFile.open(line.str().c_str(), ios::out); 1038 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " );1073 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl); 1039 1074 if (BondFile != NULL) { 1040 1075 BondFile << "m\tn" << endl; 1041 1076 ActOnAllAtoms(&atom::OutputBonds, &BondFile); 1042 1077 BondFile.close(); 1043 DoLog(1) && (Log() << Verbose(1) << " done." << endl);1078 DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl); 1044 1079 } else { 1045 DoLog(1) && (Log() << Verbose(1) << " failed to open file " << line.str() << "." << endl);1080 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line.str() << "." << endl); 1046 1081 status = false; 1047 1082 } … … 1056 1091 filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE; 1057 1092 File.open(filename.str().c_str(), ios::out); 1058 DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " );1093 DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " << endl); 1059 1094 if (File == NULL) 1060 1095 return false; 1061 1096 1062 1097 // allocate storage structure 1063 CurrentBonds = Calloc<int> (8, "molecule::CheckAdjacencyFileAgainstMolecule - CurrentBonds"); // contains parsed bonds of current atom 1098 CurrentBonds = new int[8]; // contains parsed bonds of current atom 1099 for(int i=0;i<8;i++) 1100 CurrentBonds[i] = 0; 1064 1101 return true; 1065 1102 } … … 1070 1107 File.close(); 1071 1108 File.clear(); 1072 Free(&CurrentBonds);1109 delete[](CurrentBonds); 1073 1110 } 1074 1111 ; … … 1090 1127 NonMatchNumber++; 1091 1128 status = false; 1129 DoeLog(2) && (eLog() << Verbose(2) << id << " can not be found in list." << endl); 1130 } else { 1092 1131 //Log() << Verbose(0) << "[" << id << "]\t"; 1093 } else {1094 //Log() << Verbose(0) << id << "\t";1095 1132 } 1096 1133 } … … 1114 1151 bool status = true; 1115 1152 atom *Walker = NULL; 1116 char *buffer = NULL;1117 1153 int *CurrentBonds = NULL; 1118 1154 int NonMatchNumber = 0; // will number of atoms with differing bond structure 1119 1155 size_t CurrentBondsOfAtom = -1; 1156 const int AtomCount = getAtomCount(); 1120 1157 1121 1158 if (!CheckAdjacencyFileAgainstMolecule_Init(path, File, CurrentBonds)) { … … 1124 1161 } 1125 1162 1126 buffer = Malloc<char> (MAXSTRINGSIZE, "molecule::CheckAdjacencyFileAgainstMolecule: *buffer");1163 char buffer[MAXSTRINGSIZE]; 1127 1164 // Parse the file line by line and count the bonds 1128 1165 while (!File.eof()) { … … 1140 1177 // compare against present bonds 1141 1178 CheckAdjacencyFileAgainstMolecule_CompareBonds(status, NonMatchNumber, Walker, CurrentBondsOfAtom, AtomNr, CurrentBonds, ListOfAtoms); 1142 } 1143 } 1144 Free(&buffer); 1179 } else { 1180 if (AtomNr != -1) 1181 DoeLog(2) && (eLog() << Verbose(2) << AtomNr << " is not valid in the range of ids [" << 0 << "," << AtomCount << ")." << endl); 1182 } 1183 } 1145 1184 CheckAdjacencyFileAgainstMolecule_Finalize(File, CurrentBonds); 1146 1185 … … 1196 1235 BFS.AtomCount = AtomCount; 1197 1236 BFS.BondOrder = BondOrder; 1198 BFS.PredecessorList = Calloc<atom*> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: **PredecessorList");1199 BFS.ShortestPathList = Calloc<int> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ShortestPathList");1200 BFS.ColorList = Malloc<enum Shading> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ColorList");1237 BFS.PredecessorList = new atom*[AtomCount]; 1238 BFS.ShortestPathList = new int[AtomCount]; 1239 BFS.ColorList = new enum Shading[AtomCount]; 1201 1240 BFS.BFSStack = new StackClass<atom *> (AtomCount); 1202 1241 … … 1207 1246 // initialise each vertex as white with no predecessor, empty queue, color Root lightgray 1208 1247 for (int i = AtomCount; i--;) { 1248 BFS.PredecessorList[i] = NULL; 1209 1249 BFS.ShortestPathList[i] = -1; 1210 1250 if ((AddedAtomList != NULL) && (AddedAtomList[i] != NULL)) // mark already present atoms (i.e. Root and maybe others) as visited … … 1213 1253 BFS.ColorList[i] = white; 1214 1254 } 1215 //BFS.ShortestPathList[Root->nr] = 0; // is set due to Calloc()1255 //BFS.ShortestPathList[Root->nr] = 0; // done by Calloc 1216 1256 } 1217 1257 ; … … 1219 1259 void BreadthFirstSearchAdd_Free(struct BFSAccounting &BFS) 1220 1260 { 1221 Free(&BFS.PredecessorList);1222 Free(&BFS.ShortestPathList);1223 Free(&BFS.ColorList);1261 delete[](BFS.PredecessorList); 1262 delete[](BFS.ShortestPathList); 1263 delete[](BFS.ColorList); 1224 1264 delete (BFS.BFSStack); 1225 1265 BFS.AtomCount = 0; … … 1313 1353 AddedAtomList[Root->nr] = Mol->AddCopyAtom(Root); 1314 1354 1315 BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, AtomCount, AddedAtomList);1355 BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, getAtomCount(), AddedAtomList); 1316 1356 1317 1357 // and go on ... Queue always contains all lightgray vertices … … 1360 1400 { 1361 1401 // reset parent list 1362 ParentList = Calloc<atom*> (AtomCount, "molecule::BuildInducedSubgraph_Init: **ParentList"); 1402 ParentList = new atom*[AtomCount]; 1403 for (int i=0;i<AtomCount;i++) 1404 ParentList[i] = NULL; 1363 1405 DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl); 1364 1406 } … … 1369 1411 // fill parent list with sons 1370 1412 DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl); 1371 atom *Walker = mol->start; 1372 while (Walker->next != mol->end) { 1373 Walker = Walker->next; 1374 ParentList[Walker->father->nr] = Walker; 1413 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1414 ParentList[(*iter)->father->nr] = (*iter); 1375 1415 // Outputting List for debugging 1376 DoLog(4) && (Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl); 1377 } 1378 1379 } 1380 ; 1416 DoLog(4) && (Log() << Verbose(4) << "Son[" << (*iter)->father->nr << "] of " << (*iter)->father << " is " << ParentList[(*iter)->father->nr] << "." << endl); 1417 } 1418 }; 1381 1419 1382 1420 void BuildInducedSubgraph_Finalize(atom **&ParentList) 1383 1421 { 1384 Free(&ParentList);1422 delete[](ParentList); 1385 1423 } 1386 1424 ; … … 1389 1427 { 1390 1428 bool status = true; 1391 atom *Walker = NULL;1392 1429 atom *OtherAtom = NULL; 1393 1430 // check each entry of parent list and if ok (one-to-and-onto matching) create bonds 1394 1431 DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl); 1395 Walker = Father->start; 1396 while (Walker->next != Father->end) { 1397 Walker = Walker->next; 1398 if (ParentList[Walker->nr] != NULL) { 1399 if (ParentList[Walker->nr]->father != Walker) { 1432 for (molecule::const_iterator iter = Father->begin(); iter != Father->end(); ++iter) { 1433 if (ParentList[(*iter)->nr] != NULL) { 1434 if (ParentList[(*iter)->nr]->father != (*iter)) { 1400 1435 status = false; 1401 1436 } else { 1402 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {1403 OtherAtom = (*Runner)->GetOtherAtom( Walker);1437 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 1438 OtherAtom = (*Runner)->GetOtherAtom((*iter)); 1404 1439 if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond 1405 DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[ Walker->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl);1406 mol->AddBond(ParentList[ Walker->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);1440 DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[(*iter)->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl); 1441 mol->AddBond(ParentList[(*iter)->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree); 1407 1442 } 1408 1443 } … … 1427 1462 bool status = true; 1428 1463 atom **ParentList = NULL; 1429 1430 1464 DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl); 1431 BuildInducedSubgraph_Init(ParentList, Father-> AtomCount);1465 BuildInducedSubgraph_Init(ParentList, Father->getAtomCount()); 1432 1466 BuildInducedSubgraph_FillParentList(this, Father, ParentList); 1433 1467 status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList); -
src/molecule_pointcloud.cpp
r992fd7 r257c77 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "atom.hpp" 9 11 #include "config.hpp" 12 #include "info.hpp" 10 13 #include "memoryallocator.hpp" 11 14 #include "molecule.hpp" … … 31 34 }; 32 35 33 /** Return current atom in the list. 34 * \return pointer to atom or NULL if none present 36 37 /** PointCloud implementation of GoPoint 38 * Uses atoms and STL stuff. 35 39 */ 36 TesselPoint *molecule::GetPoint() const40 TesselPoint* molecule::GetPoint() const 37 41 { 38 if ((InternalPointer != start) && (InternalPointer != end)) 39 return InternalPointer; 40 else 41 return NULL; 42 return (*InternalPointer); 42 43 }; 43 44 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. 45 /** PointCloud implementation of GoToNext. 46 * Uses atoms and STL stuff. 62 47 */ 63 48 void molecule::GoToNext() const 64 49 { 65 if (InternalPointer != end)66 InternalPointer = InternalPointer->next;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 InternalPointer = atoms.begin(); 83 60 }; 84 61 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 62 /** PointCloud implementation of IsEmpty. 63 * Uses atoms and STL stuff. 94 64 */ 95 65 bool molecule::IsEmpty() const 96 66 { 97 return ( start->next == end);67 return (empty()); 98 68 }; 99 69 100 /** Checks whether we are at the last atom101 * \return true - current atom is last one, false - is not last one70 /** PointCloud implementation of IsLast. 71 * Uses atoms and STL stuff. 102 72 */ 103 73 bool molecule::IsEnd() const 104 74 { 105 return (InternalPointer == end);75 return (InternalPointer == atoms.end()); 106 76 }; 77 78 int molecule::GetMaxId() const { 79 return getAtomCount(); 80 } -
src/molecule_template.hpp
r992fd7 r257c77 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
r992fd7 r257c77 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 #include <cstring> … … 20 22 #include "memoryallocator.hpp" 21 23 #include "periodentafel.hpp" 22 #include "World.hpp" 24 #include "Helpers/Assert.hpp" 25 26 #include "Helpers/Assert.hpp" 23 27 24 28 /*********************************** Functions for class MoleculeListClass *************************/ … … 27 31 */ 28 32 MoleculeListClass::MoleculeListClass(World *_world) : 33 Observable("MoleculeListClass"), 29 34 world(_world) 30 35 { … … 38 43 MoleculeListClass::~MoleculeListClass() 39 44 { 40 DoLog(3) && (Log() << Verbose(3) << this << ": Freeing ListOfMolcules." << endl); 41 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) { 42 DoLog(4) && (Log() << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl); 43 world->destroyMolecule(*ListRunner); 44 } 45 DoLog(4) && (Log() << Verbose(4) << "Freeing ListOfMolecules." << endl); 45 DoLog(4) && (Log() << Verbose(4) << "Clearing ListOfMolecules." << endl); 46 for(MoleculeList::iterator MolRunner = ListOfMolecules.begin(); MolRunner != ListOfMolecules.end(); ++MolRunner) 47 (*MolRunner)->signOff(this); 46 48 ListOfMolecules.clear(); // empty list 47 49 }; … … 49 51 /** Insert a new molecule into the list and set its number. 50 52 * \param *mol molecule to add to list. 51 * \return true - add successful52 53 */ 53 54 void MoleculeListClass::insert(molecule *mol) … … 59 60 }; 60 61 62 /** Erases a molecule from the list. 63 * \param *mol molecule to add to list. 64 */ 65 void MoleculeListClass::erase(molecule *mol) 66 { 67 OBSERVE; 68 mol->signOff(this); 69 ListOfMolecules.remove(mol); 70 }; 71 61 72 /** Compare whether two molecules are equal. 62 73 * \param *a molecule one … … 69 80 int Count, Counter, aCounter, bCounter; 70 81 int flag; 71 atom *aWalker = NULL;72 atom *bWalker = NULL;73 82 74 83 // sort each atom list and put the numbers into a list, then go through 75 84 //Log() << Verbose(0) << "Comparing fragment no. " << *(molecule **)a << " to " << *(molecule **)b << "." << endl; 76 if ((**(molecule **) a).AtomCount < (**(molecule **) b).AtomCount) { 85 // Yes those types are awkward... but check it for yourself it checks out this way 86 molecule *const *mol1_ptr= static_cast<molecule *const *>(a); 87 molecule *mol1 = *mol1_ptr; 88 molecule *const *mol2_ptr= static_cast<molecule *const *>(b); 89 molecule *mol2 = *mol2_ptr; 90 if (mol1->getAtomCount() < mol2->getAtomCount()) { 77 91 return -1; 78 92 } else { 79 if ( (**(molecule **) a).AtomCount > (**(molecule **) b).AtomCount)93 if (mol1->getAtomCount() > mol2->getAtomCount()) 80 94 return +1; 81 95 else { 82 Count = (**(molecule **) a).AtomCount;96 Count = mol1->getAtomCount(); 83 97 aList = new int[Count]; 84 98 bList = new int[Count]; 85 99 86 100 // fill the lists 87 aWalker = (**(molecule **) a).start;88 bWalker = (**(molecule **) b).start;89 101 Counter = 0; 90 102 aCounter = 0; 91 103 bCounter = 0; 92 while ((aWalker->next != (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) { 93 aWalker = aWalker->next; 94 bWalker = bWalker->next; 95 if (aWalker->GetTrueFather() == NULL) 104 molecule::const_iterator aiter = mol1->begin(); 105 molecule::const_iterator biter = mol2->begin(); 106 for (;(aiter != mol1->end()) && (biter != mol2->end()); 107 ++aiter, ++biter) { 108 if ((*aiter)->GetTrueFather() == NULL) 96 109 aList[Counter] = Count + (aCounter++); 97 110 else 98 aList[Counter] = aWalker->GetTrueFather()->nr;99 if ( bWalker->GetTrueFather() == NULL)111 aList[Counter] = (*aiter)->GetTrueFather()->nr; 112 if ((*biter)->GetTrueFather() == NULL) 100 113 bList[Counter] = Count + (bCounter++); 101 114 else 102 bList[Counter] = bWalker->GetTrueFather()->nr;115 bList[Counter] = (*biter)->GetTrueFather()->nr; 103 116 Counter++; 104 117 } 105 118 // check if AtomCount was for real 106 119 flag = 0; 107 if ((a Walker->next == (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {120 if ((aiter == mol1->end()) && (biter != mol2->end())) { 108 121 flag = -1; 109 122 } else { 110 if ((a Walker->next != (**(molecule **) a).end) && (bWalker->next == (**(molecule **) b).end))123 if ((aiter != mol1->end()) && (biter == mol2->end())) 111 124 flag = 1; 112 125 } … … 142 155 void MoleculeListClass::Enumerate(ostream *out) 143 156 { 144 atom *Walker = NULL;145 157 periodentafel *periode = World::getInstance().getPeriode(); 146 158 std::map<atomicNumber_t,unsigned int> counts; … … 158 170 // count atoms per element and determine size of bounding sphere 159 171 size=0.; 160 Walker = (*ListRunner)->start; 161 while (Walker->next != (*ListRunner)->end) { 162 Walker = Walker->next; 163 counts[Walker->type->getNumber()]++; 164 if (Walker->x.DistanceSquared(Origin) > size) 165 size = Walker->x.DistanceSquared(Origin); 172 for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) { 173 counts[(*iter)->type->getNumber()]++; 174 if ((*iter)->x.DistanceSquared(Origin) > size) 175 size = (*iter)->x.DistanceSquared(Origin); 166 176 } 167 177 // output Index, Name, number of atoms, chemical formula 168 (*out) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)-> AtomCount<< "\t";178 (*out) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->getAtomCount() << "\t"; 169 179 170 180 std::map<atomicNumber_t,unsigned int>::reverse_iterator iter; … … 202 212 203 213 // put all molecules of src into mol 204 atom *Walker = srcmol->start; 205 atom *NextAtom = Walker->next; 206 while (NextAtom != srcmol->end) { 207 Walker = NextAtom; 208 NextAtom = Walker->next; 209 srcmol->UnlinkAtom(Walker); 210 mol->AddAtom(Walker); 214 molecule::iterator runner; 215 for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) { 216 runner = iter++; 217 srcmol->UnlinkAtom((*runner)); 218 mol->AddAtom((*runner)); 211 219 } 212 220 … … 228 236 229 237 // put all molecules of src into mol 230 atom *Walker = srcmol->start; 231 atom *NextAtom = Walker->next; 232 while (NextAtom != srcmol->end) { 233 Walker = NextAtom; 234 NextAtom = Walker->next; 235 Walker = mol->AddCopyAtom(Walker); 238 atom *Walker = NULL; 239 for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) { 240 Walker = mol->AddCopyAtom((*iter)); 236 241 Walker->father = Walker; 237 242 } … … 330 335 331 336 // prepare index list for bonds 332 srcmol->CountAtoms(); 333 atom ** CopyAtoms = new atom*[srcmol->AtomCount]; 334 for(int i=0;i<srcmol->AtomCount;i++) 337 atom ** CopyAtoms = new atom*[srcmol->getAtomCount()]; 338 for(int i=0;i<srcmol->getAtomCount();i++) 335 339 CopyAtoms[i] = NULL; 336 340 337 341 // for each of the source atoms check whether we are in- or outside and add copy atom 338 atom *Walker = srcmol->start;339 342 int nr=0; 340 while (Walker->next != srcmol->end) { 341 Walker = Walker->next; 342 DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << *Walker << "." << endl); 343 if (!TesselStruct->IsInnerPoint(Walker->x, LCList)) { 344 CopyAtoms[Walker->nr] = Walker->clone(); 345 mol->AddAtom(CopyAtoms[Walker->nr]); 343 for (molecule::const_iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) { 344 DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << **iter << "." << endl); 345 if (!TesselStruct->IsInnerPoint((*iter)->x, LCList)) { 346 CopyAtoms[(*iter)->nr] = (*iter)->clone(); 347 mol->AddAtom(CopyAtoms[(*iter)->nr]); 346 348 nr++; 347 349 } else { … … 349 351 } 350 352 } 351 DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol-> AtomCount<< " atoms have been merged.");353 DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol->getAtomCount() << " atoms have been merged."); 352 354 353 355 // go through all bonds and add as well 354 bond *Binder = srcmol->first;355 while(Binder->next != srcmol->last) {356 Binder = Binder->next;357 DoLog(3) && (Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl);358 mol->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);359 }356 for(molecule::iterator AtomRunner = srcmol->begin(); AtomRunner != srcmol->end(); ++AtomRunner) 357 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 358 if ((*BondRunner)->leftatom == *AtomRunner) { 359 DoLog(3) && (Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[(*BondRunner)->leftatom->nr] << " and " << *CopyAtoms[(*BondRunner)->rightatom->nr]<< "." << endl); 360 mol->AddBond(CopyAtoms[(*BondRunner)->leftatom->nr], CopyAtoms[(*BondRunner)->rightatom->nr], (*BondRunner)->BondDegree); 361 } 360 362 delete(LCList); 361 363 return true; … … 382 384 bool MoleculeListClass::AddHydrogenCorrection(char *path) 383 385 { 384 atom *Walker = NULL;385 atom *Runner = NULL;386 386 bond *Binder = NULL; 387 387 double ***FitConstant = NULL, **correction = NULL; … … 427 427 428 428 // 0b. allocate memory for constants 429 FitConstant = Calloc<double**>(3, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant");429 FitConstant = new double**[3]; 430 430 for (int k = 0; k < 3; k++) { 431 FitConstant[k] = Calloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]");431 FitConstant[k] = new double*[a]; 432 432 for (int i = a; i--;) { 433 FitConstant[k][i] = Calloc<double>(b, "MoleculeListClass::AddHydrogenCorrection: *FitConstant[][]"); 433 FitConstant[k][i] = new double[b]; 434 for (int j = b; j--;) { 435 FitConstant[k][i][j] = 0.; 436 } 434 437 } 435 438 } … … 477 480 478 481 // 0d. allocate final correction matrix 479 correction = Calloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **correction");482 correction = new double*[a]; 480 483 for (int i = a; i--;) 481 correction[i] = Calloc<double>(b, "MoleculeListClass::AddHydrogenCorrection: *correction[]");484 correction[i] = new double[b]; 482 485 483 486 // 1a. go through every molecule in the list … … 488 491 correction[k][j] = 0.; 489 492 // 2. take every hydrogen that is a saturated one 490 Walker = (*ListRunner)->start; 491 while (Walker->next != (*ListRunner)->end) { 492 Walker = Walker->next; 493 //Log() << Verbose(1) << "Walker: " << *Walker << " with first bond " << *(Walker->ListOfBonds.begin()) << "." << endl; 494 if ((Walker->type->Z == 1) && ((Walker->father == NULL) 495 || (Walker->father->type->Z != 1))) { // if it's a hydrogen 496 Runner = (*ListRunner)->start; 497 while (Runner->next != (*ListRunner)->end) { 498 Runner = Runner->next; 499 //Log() << Verbose(2) << "Runner: " << *Runner << " with first bond " << *(Walker->ListOfBonds.begin()) << "." << endl; 493 for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) { 494 //Log() << Verbose(1) << "(*iter): " << *(*iter) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl; 495 if (((*iter)->type->Z == 1) && (((*iter)->father == NULL) 496 || ((*iter)->father->type->Z != 1))) { // if it's a hydrogen 497 for (molecule::const_iterator runner = (*ListRunner)->begin(); runner != (*ListRunner)->end(); ++runner) { 498 //Log() << Verbose(2) << "Runner: " << *(*runner) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl; 500 499 // 3. take every other hydrogen that is the not the first and not bound to same bonding partner 501 Binder = *( Runner->ListOfBonds.begin());502 if (( Runner->type->Z == 1) && (Runner->nr > Walker->nr) && (Binder->GetOtherAtom(Runner) != Binder->GetOtherAtom(Walker))) { // (hydrogens have only one bonding partner!)500 Binder = *((*runner)->ListOfBonds.begin()); 501 if (((*runner)->type->Z == 1) && ((*runner)->nr > (*iter)->nr) && (Binder->GetOtherAtom((*runner)) != Binder->GetOtherAtom((*iter)))) { // (hydrogens have only one bonding partner!) 503 502 // 4. evaluate the morse potential for each matrix component and add up 504 distance = Runner->x.distance(Walker->x);505 //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << * Runner << "<= " << distance << "=>" << *Walker<< ":" << endl;503 distance = (*runner)->x.distance((*iter)->x); 504 //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *(*runner) << "<= " << distance << "=>" << *(*iter) << ":" << endl; 506 505 for (int k = 0; k < a; k++) { 507 506 for (int j = 0; j < b; j++) { … … 531 530 FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), (*ListRunner)->IndexNr); 532 531 line += FragmentNumber; 533 delete (FragmentNumber);532 delete[] (FragmentNumber); 534 533 line += HCORRECTIONSUFFIX; 535 534 output.open(line.c_str()); … … 542 541 output.close(); 543 542 } 543 for (int i = a; i--;) 544 delete[](correction[i]); 545 delete[](correction); 546 544 547 line = path; 545 548 line.append("/"); … … 556 559 for (int k = 0; k < 3; k++) { 557 560 for (int i = a; i--;) { 558 Free(&FitConstant[k][i]);559 } 560 Free(&FitConstant[k]);561 } 562 Free(&FitConstant);561 delete[](FitConstant[k][i]); 562 } 563 delete[](FitConstant[k]); 564 } 565 delete[](FitConstant); 563 566 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 564 567 return true; … … 577 580 ofstream ForcesFile; 578 581 stringstream line; 579 atom *Walker = NULL;580 582 periodentafel *periode=World::getInstance().getPeriode(); 581 583 … … 590 592 periodentafel::const_iterator elemIter; 591 593 for(elemIter=periode->begin();elemIter!=periode->end();++elemIter){ 592 if ((*ListRunner)->ElementsInMolecule[(*elemIter).first]) { // if this element got atoms 593 Walker = (*ListRunner)->start; 594 while (Walker->next != (*ListRunner)->end) { // go through every atom of this element 595 Walker = Walker->next; 596 if (Walker->type->getNumber() == (*elemIter).first) { 597 if ((Walker->GetTrueFather() != NULL) && (Walker->GetTrueFather() != Walker)) {// if there is a rea 594 if ((*ListRunner)->ElementsInMolecule[(*elemIter).first]) { // if this element got atoms 595 for(molecule::iterator atomIter = (*ListRunner)->begin(); atomIter !=(*ListRunner)->end();++atomIter){ 596 if ((*atomIter)->type->getNumber() == (*elemIter).first) { 597 if (((*atomIter)->GetTrueFather() != NULL) && ((*atomIter)->GetTrueFather() != (*atomIter))) {// if there is a rea 598 598 //Log() << Verbose(0) << "Walker is " << *Walker << " with true father " << *( Walker->GetTrueFather()) << ", it 599 ForcesFile << SortIndex[ Walker->GetTrueFather()->nr] << "\t";599 ForcesFile << SortIndex[(*atomIter)->GetTrueFather()->nr] << "\t"; 600 600 } else 601 601 // otherwise a -1 to indicate an added saturation hydrogen … … 622 622 * \param *configuration standard configuration to attach atoms in fragment molecule to. 623 623 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config 624 * \param DoPeriodic true - call ScanForPeriodicCorrection, false - don't625 * \param DoCentering true - call molecule::CenterEdge(), false - don't626 624 * \return true - success (each file was written), false - something went wrong. 627 625 */ … … 633 631 bool result = true; 634 632 bool intermediateResult = true; 635 atom *Walker = NULL;636 633 Vector BoxDimension; 637 634 char *FragmentNumber = NULL; … … 674 671 // list atoms in fragment for debugging 675 672 DoLog(2) && (Log() << Verbose(2) << "Contained atoms: "); 676 Walker = (*ListRunner)->start; 677 while (Walker->next != (*ListRunner)->end) { 678 Walker = Walker->next; 679 DoLog(0) && (Log() << Verbose(0) << Walker->getName() << " "); 673 for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) { 674 DoLog(0) && (Log() << Verbose(0) << (*iter)->getName() << " "); 680 675 } 681 676 DoLog(0) && (Log() << Verbose(0) << endl); … … 724 719 //outputFragment.close(); 725 720 //outputFragment.clear(); 726 Free(&FragmentNumber);721 delete[](FragmentNumber); 727 722 } 728 723 DoLog(0) && (Log() << Verbose(0) << " done." << endl); … … 756 751 void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration) 757 752 { 753 // 0a. remove all present molecules 754 vector<molecule *> allmolecules = World::getInstance().getAllMolecules(); 755 for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) { 756 erase(*MolRunner); 757 World::getInstance().destroyMolecule(*MolRunner); 758 } 759 // 0b. remove all bonds and construct a molecule with all atoms 758 760 molecule *mol = World::getInstance().createMolecule(); 759 atom *Walker = NULL; 760 atom *Advancer = NULL; 761 bond *Binder = NULL; 762 bond *Stepper = NULL; 763 // 0. gather all atoms into single molecule 764 for (MoleculeList::iterator MolRunner = ListOfMolecules.begin(); !ListOfMolecules.empty(); MolRunner = ListOfMolecules.begin()) { 765 // shift all atoms to new molecule 766 Advancer = (*MolRunner)->start->next; 767 while (Advancer != (*MolRunner)->end) { 768 Walker = Advancer; 769 Advancer = Advancer->next; 770 DoLog(3) && (Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl); 771 unlink(Walker); 772 Walker->father = Walker; 773 mol->AddAtom(Walker); // counting starts at 1 774 } 775 // remove all bonds 776 Stepper = (*MolRunner)->first->next; 777 while (Stepper != (*MolRunner)->last) { 778 Binder = Stepper; 779 Stepper = Stepper->next; 780 delete(Binder); 781 } 782 // remove the molecule 783 World::getInstance().destroyMolecule(*MolRunner); 784 ListOfMolecules.erase(MolRunner); 761 vector <atom *> allatoms = World::getInstance().getAllAtoms(); 762 for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) { 763 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin()) 764 delete(*BondRunner); 765 mol->AddAtom(*AtomRunner); 785 766 } 786 767 … … 810 791 const int MolCount = Subgraphs->next->Count(); 811 792 char number[MAXSTRINGSIZE]; 812 molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules"); 793 molecule **molecules = new molecule *[MolCount]; 794 MoleculeLeafClass *MolecularWalker = Subgraphs; 813 795 for (int i=0;i<MolCount;i++) { 796 MolecularWalker = MolecularWalker->next; 814 797 molecules[i] = World::getInstance().createMolecule(); 815 798 molecules[i]->ActiveFlag = true; … … 819 802 strncat(molecules[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1); 820 803 } 821 DoLog(1) && (Log() << Verbose(1) << "MolName is " << molecules[i]->name << endl); 804 DoLog(1) && (Log() << Verbose(1) << "MolName is " << molecules[i]->name << ", id is " << molecules[i]->getId() << endl); 805 for (molecule::iterator iter = MolecularWalker->Leaf->begin(); iter != MolecularWalker->Leaf->end(); ++iter) { 806 DoLog(1) && (Log() << Verbose(1) << **iter << endl); 807 } 822 808 insert(molecules[i]); 823 809 } … … 825 811 // 4b. create and fill map of which atom is associated to which connected molecule (note, counting starts at 1) 826 812 int FragmentCounter = 0; 827 int *MolMap = Calloc<int>(mol->AtomCount, "config::Load() - *MolMap"); 828 MoleculeLeafClass *MolecularWalker = Subgraphs; 829 Walker = NULL; 813 map<int, atom *> AtomToFragmentMap; 814 MolecularWalker = Subgraphs; 830 815 while (MolecularWalker->next != NULL) { 831 816 MolecularWalker = MolecularWalker->next; 832 Walker = MolecularWalker->Leaf->start; 833 while (Walker->next != MolecularWalker->Leaf->end) { 834 Walker = Walker->next; 835 MolMap[Walker->GetTrueFather()->nr] = FragmentCounter+1; 817 for (molecule::iterator iter = MolecularWalker->Leaf->begin(); !MolecularWalker->Leaf->empty(); iter = MolecularWalker->Leaf->begin()) { 818 atom * Walker = *iter; 819 DoLog(1) && (Log() << Verbose(1) << "Re-linking " << Walker << "..." << endl); 820 MolecularWalker->Leaf->erase(iter); 821 molecules[FragmentCounter]->AddAtom(Walker); // counting starts at 1 836 822 } 837 823 FragmentCounter++; 838 824 } 839 840 // 4c. relocate atoms to new molecules and remove from Leafs 841 Walker = NULL; 842 while (mol->start->next != mol->end) { 843 Walker = mol->start->next; 844 if ((Walker->nr <0) || (Walker->nr >= mol->AtomCount)) { 845 DoeLog(0) && (eLog()<< Verbose(0) << "Index of atom " << *Walker << " is invalid!" << endl); 846 performCriticalExit(); 847 } 848 FragmentCounter = MolMap[Walker->nr]; 849 if (FragmentCounter != 0) { 850 DoLog(3) && (Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl); 851 unlink(Walker); 852 molecules[FragmentCounter-1]->AddAtom(Walker); // counting starts at 1 853 } else { 854 DoeLog(0) && (eLog()<< Verbose(0) << "Atom " << *Walker << " not associated to molecule!" << endl); 855 performCriticalExit(); 856 } 857 } 825 World::getInstance().destroyMolecule(mol); 826 858 827 // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintain their ListOfBonds, but we have to remove them from first..last list 859 Binder = mol->first; 860 while (mol->first->next != mol->last) { 861 Binder = mol->first->next; 862 Walker = Binder->leftatom; 863 unlink(Binder); 864 link(Binder,molecules[MolMap[Walker->nr]-1]->last); // counting starts at 1 865 } 828 // TODO: check whether this is really not needed anymore 866 829 // 4e. free Leafs 867 830 MolecularWalker = Subgraphs; … … 871 834 } 872 835 delete(MolecularWalker); 873 Free(&MolMap); 874 Free(&molecules); 836 delete[](molecules); 875 837 DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl); 876 838 }; … … 882 844 int MoleculeListClass::CountAllAtoms() const 883 845 { 884 atom *Walker = NULL;885 846 int AtomNo = 0; 886 847 for (MoleculeList::const_iterator MolWalker = ListOfMolecules.begin(); MolWalker != ListOfMolecules.end(); MolWalker++) { 887 Walker = (*MolWalker)->start; 888 while (Walker->next != (*MolWalker)->end) { 889 Walker = Walker->next; 890 AtomNo++; 891 } 848 AtomNo += (*MolWalker)->size(); 892 849 } 893 850 return AtomNo; … … 1064 1021 bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList) 1065 1022 { 1066 atom *Walker = NULL;1067 1023 atom *OtherWalker = NULL; 1068 1024 atom *Father = NULL; … … 1072 1028 DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl); 1073 1029 // fill ListOfLocalAtoms if NULL was given 1074 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference-> AtomCount, FreeList)) {1030 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) { 1075 1031 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl); 1076 1032 return false; … … 1080 1036 DoLog(1) && (Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl); 1081 1037 // remove every bond from the list 1082 bond *Binder = NULL; 1083 while (Leaf->last->previous != Leaf->first) { 1084 Binder = Leaf->last->previous; 1085 Binder->leftatom->UnregisterBond(Binder); 1086 Binder->rightatom->UnregisterBond(Binder); 1087 removewithoutcheck(Binder); 1088 } 1089 1090 Walker = Leaf->start; 1091 while (Walker->next != Leaf->end) { 1092 Walker = Walker->next; 1093 Father = Walker->GetTrueFather(); 1038 for(molecule::iterator AtomRunner = Leaf->begin(); AtomRunner != Leaf->end(); ++AtomRunner) 1039 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin()) 1040 if ((*BondRunner)->leftatom == *AtomRunner) 1041 delete((*BondRunner)); 1042 1043 for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) { 1044 Father = (*iter)->GetTrueFather(); 1094 1045 AtomNo = Father->nr; // global id of the current walker 1095 1046 for (BondList::const_iterator Runner = Father->ListOfBonds.begin(); Runner != Father->ListOfBonds.end(); (++Runner)) { 1096 OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom( Walker->GetTrueFather())->nr]; // local copy of current bond partner of walker1047 OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker 1097 1048 if (OtherWalker != NULL) { 1098 if (OtherWalker->nr > Walker->nr)1099 Leaf->AddBond( Walker, OtherWalker, (*Runner)->BondDegree);1049 if (OtherWalker->nr > (*iter)->nr) 1050 Leaf->AddBond((*iter), OtherWalker, (*Runner)->BondDegree); 1100 1051 } else { 1101 DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom( Walker->GetTrueFather())->nr << "] is NULL!" << endl);1052 DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl); 1102 1053 status = false; 1103 1054 } … … 1108 1059 if ((FreeList) && (ListOfLocalAtoms != NULL)) { 1109 1060 // free the index lookup list 1110 Free(&ListOfLocalAtoms[FragmentCounter]);1061 delete[](ListOfLocalAtoms[FragmentCounter]); 1111 1062 if (FragmentCounter == 0) // first fragments frees the initial pointer to list 1112 Free(&ListOfLocalAtoms);1063 delete[](ListOfLocalAtoms); 1113 1064 } 1114 1065 DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl); … … 1126 1077 bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter) 1127 1078 { 1128 atom * Walker = NULL, *Father = NULL;1079 atom *Father = NULL; 1129 1080 1130 1081 if (RootStack != NULL) { … … 1132 1083 if (&(RootStack[FragmentCounter]) != NULL) { 1133 1084 RootStack[FragmentCounter].clear(); 1134 Walker = Leaf->start; 1135 while (Walker->next != Leaf->end) { // go through all (non-hydrogen) atoms 1136 Walker = Walker->next; 1137 Father = Walker->GetTrueFather(); 1085 for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) { 1086 Father = (*iter)->GetTrueFather(); 1138 1087 if (AtomMask[Father->nr]) // apply mask 1139 1088 #ifdef ADDHYDROGEN 1140 if ( Walker->type->Z != 1) // skip hydrogen1089 if ((*iter)->type->Z != 1) // skip hydrogen 1141 1090 #endif 1142 RootStack[FragmentCounter].push_front( Walker->nr);1091 RootStack[FragmentCounter].push_front((*iter)->nr); 1143 1092 } 1144 1093 if (next != NULL) … … 1171 1120 // allocate and set each field to NULL 1172 1121 const int Counter = Count(); 1173 ListOfLocalAtoms = Calloc<atom**>(Counter, "MoleculeLeafClass::FillListOfLocalAtoms - ***ListOfLocalAtoms"); 1122 ASSERT(FragmentCounter < Counter, "FillListOfLocalAtoms: FragmenCounter greater than present fragments."); 1123 ListOfLocalAtoms = new atom**[Counter]; 1174 1124 if (ListOfLocalAtoms == NULL) { 1175 1125 FreeList = FreeList && false; 1176 1126 status = false; 1177 1127 } 1128 for (int i=0;i<Counter;i++) 1129 ListOfLocalAtoms[i] = NULL; 1178 1130 } 1179 1131 1180 1132 if ((ListOfLocalAtoms != NULL) && (ListOfLocalAtoms[FragmentCounter] == NULL)) { // allocate and fill list of this fragment/subgraph 1181 status = status && CreateFatherLookupTable(Leaf->start, Leaf->end,ListOfLocalAtoms[FragmentCounter], GlobalAtomCount);1133 status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms[FragmentCounter], GlobalAtomCount); 1182 1134 FreeList = FreeList && true; 1183 1135 } … … 1203 1155 DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl); 1204 1156 // fill ListOfLocalAtoms if NULL was given 1205 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference-> AtomCount, FreeList)) {1157 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) { 1206 1158 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl); 1207 1159 return false; … … 1211 1163 if (FragmentList == NULL) { 1212 1164 KeySetCounter = Count(); 1213 FragmentList = Calloc<Graph*>(KeySetCounter, "MoleculeLeafClass::AssignKeySetsToFragment - **FragmentList"); 1165 FragmentList = new Graph*[KeySetCounter]; 1166 for (int i=0;i<KeySetCounter;i++) 1167 FragmentList[i] = NULL; 1214 1168 KeySetCounter = 0; 1215 1169 } … … 1245 1199 if ((FreeList) && (ListOfLocalAtoms != NULL)) { 1246 1200 // free the index lookup list 1247 Free(&ListOfLocalAtoms[FragmentCounter]);1201 delete[](ListOfLocalAtoms[FragmentCounter]); 1248 1202 if (FragmentCounter == 0) // first fragments frees the initial pointer to list 1249 Free(&ListOfLocalAtoms);1203 delete[](ListOfLocalAtoms); 1250 1204 } 1251 1205 DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl); -
src/parser.cpp
r992fd7 r257c77 6 6 7 7 // ======================================= INCLUDES ========================================== 8 9 #include "Helpers/MemDebug.hpp" 8 10 9 11 #include <cstring> … … 59 61 MatrixContainer::MatrixContainer() { 60 62 Indices = NULL; 61 Header = Malloc<char*>(1, "MatrixContainer::MatrixContainer: **Header");62 Matrix = Malloc<double**>(1, "MatrixContainer::MatrixContainer: ***Matrix"); // one more each for the total molecule63 RowCounter = Malloc<int>(1, "MatrixContainer::MatrixContainer: *RowCounter");64 ColumnCounter = Malloc<int>(1, "MatrixContainer::MatrixContainer: *ColumnCounter");63 Header = new char*[1]; 64 Matrix = new double**[1]; // one more each for the total molecule 65 RowCounter = new int[1]; 66 ColumnCounter = new int[1]; 65 67 Header[0] = NULL; 66 68 Matrix[0] = NULL; … … 77 79 if ((ColumnCounter != NULL) && (RowCounter != NULL)) { 78 80 for(int j=RowCounter[i]+1;j--;) 79 Free(&Matrix[i][j]);80 Free(&Matrix[i]);81 delete[](Matrix[i][j]); 82 delete[](Matrix[i]); 81 83 } 82 84 } 83 85 if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL)) 84 86 for(int j=RowCounter[MatrixCounter]+1;j--;) 85 Free(&Matrix[MatrixCounter][j]);87 delete[](Matrix[MatrixCounter][j]); 86 88 if (MatrixCounter != 0) 87 Free(&Matrix[MatrixCounter]);88 Free(&Matrix);89 delete[](Matrix[MatrixCounter]); 90 delete[](Matrix); 89 91 } 90 92 if (Indices != NULL) 91 93 for(int i=MatrixCounter+1;i--;) { 92 Free(&Indices[i]);93 } 94 Free(&Indices);94 delete[](Indices[i]); 95 } 96 delete[](Indices); 95 97 96 98 if (Header != NULL) 97 99 for(int i=MatrixCounter+1;i--;) 98 Free(&Header[i]);99 Free(&Header);100 Free(&RowCounter);101 Free(&ColumnCounter);100 delete[](Header[i]); 101 delete[](Header); 102 delete[](RowCounter); 103 delete[](ColumnCounter); 102 104 }; 103 105 … … 112 114 if (Matrix == NULL) { 113 115 DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl); 114 Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");116 Indices = new int*[MatrixCounter + 1]; 115 117 for(int i=MatrixCounter+1;i--;) { 116 Indices[i] = Malloc<int>(RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");118 Indices[i] = new int[RowCounter[i]]; 117 119 for(int j=RowCounter[i];j--;) 118 120 Indices[i][j] = j; … … 122 124 if (MatrixCounter != Matrix->MatrixCounter) 123 125 return false; 124 Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");126 Indices = new int*[MatrixCounter + 1]; 125 127 for(int i=MatrixCounter+1;i--;) { 126 128 if (RowCounter[i] != Matrix->RowCounter[i]) 127 129 return false; 128 Indices[i] = Malloc<int>(Matrix->RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");130 Indices[i] = new int[Matrix->RowCounter[i]]; 129 131 for(int j=Matrix->RowCounter[i];j--;) { 130 132 Indices[i][j] = Matrix->Indices[i][j]; … … 166 168 167 169 // parse header 168 Header[MatrixNr] = Malloc<char>(1024, "MatrixContainer::ParseMatrix: *Header[]");170 Header[MatrixNr] = new char[1024]; 169 171 for (int m=skiplines+1;m--;) 170 172 input.getline(Header[MatrixNr], 1023); … … 205 207 // allocate matrix if it's not zero dimension in one direction 206 208 if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) { 207 Matrix[MatrixNr] = Malloc<double*>(RowCounter[MatrixNr] + 1, "MatrixContainer::ParseMatrix: **Matrix[]");209 Matrix[MatrixNr] = new double*[RowCounter[MatrixNr] + 1]; 208 210 209 211 // parse in each entry for this matrix … … 217 219 strncpy(Header[MatrixNr], line.str().c_str(), 1023); 218 220 for(int j=0;j<RowCounter[MatrixNr];j++) { 219 Matrix[MatrixNr][j] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[][]");221 Matrix[MatrixNr][j] = new double[ColumnCounter[MatrixNr]]; 220 222 input.getline(filename, 1023); 221 223 stringstream lines(filename); … … 227 229 //Log() << Verbose(1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl; 228 230 } 229 Matrix[MatrixNr][ RowCounter[MatrixNr] ] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]");231 Matrix[MatrixNr][ RowCounter[MatrixNr] ] = new double[ColumnCounter[MatrixNr]]; 230 232 for(int j=ColumnCounter[MatrixNr];j--;) 231 233 Matrix[MatrixNr][ RowCounter[MatrixNr] ][j] = 0.; … … 281 283 282 284 DoLog(0) && (Log() << Verbose(0) << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl); 283 Header = ReAlloc<char*>(Header, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: **Header"); // one more each for the total molecule 284 Matrix = ReAlloc<double**>(Matrix, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule 285 RowCounter = ReAlloc<int>(RowCounter, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: *RowCounter"); 286 ColumnCounter = ReAlloc<int>(ColumnCounter, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: *ColumnCounter"); 285 delete[](Header); 286 delete[](Matrix); 287 delete[](RowCounter); 288 delete[](ColumnCounter); 289 Header = new char*[MatrixCounter + 1]; // one more each for the total molecule 290 Matrix = new double**[MatrixCounter + 1]; // one more each for the total molecule 291 RowCounter = new int[MatrixCounter + 1]; 292 ColumnCounter = new int[MatrixCounter + 1]; 287 293 for(int i=MatrixCounter+1;i--;) { 288 294 Matrix[i] = NULL; … … 298 304 if (!ParseMatrix(file.str().c_str(), skiplines, skipcolumns, i)) 299 305 return false; 300 Free(&FragmentNumber);306 delete[](FragmentNumber); 301 307 } 302 308 return true; … … 313 319 { 314 320 MatrixCounter = MCounter; 315 Header = Malloc<char*>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: *Header");316 Matrix = Malloc<double**>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: ***Matrix"); // one more each for the total molecule317 RowCounter = Malloc<int>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: *RowCounter");318 ColumnCounter = Malloc<int>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: *ColumnCounter");321 Header = new char*[MatrixCounter + 1]; 322 Matrix = new double**[MatrixCounter + 1]; // one more each for the total molecule 323 RowCounter = new int[MatrixCounter + 1]; 324 ColumnCounter = new int[MatrixCounter + 1]; 319 325 for(int i=MatrixCounter+1;i--;) { 320 Header[i] = Malloc<char>(1024, "MatrixContainer::AllocateMatrix: *Header[i]");326 Header[i] = new char[1024]; 321 327 strncpy(Header[i], GivenHeader[i], 1023); 322 328 RowCounter[i] = RCounter[i]; 323 329 ColumnCounter[i] = CCounter[i]; 324 Matrix[i] = Malloc<double*>(RowCounter[i] + 1, "MatrixContainer::AllocateMatrix: **Matrix[]");330 Matrix[i] = new double*[RowCounter[i] + 1]; 325 331 for(int j=RowCounter[i]+1;j--;) { 326 Matrix[i][j] = Malloc<double>(ColumnCounter[i], "MatrixContainer::AllocateMatrix: *Matrix[][]");332 Matrix[i][j] = new double[ColumnCounter[i]]; 327 333 for(int k=ColumnCounter[i];k--;) 328 334 Matrix[i][j][k] = 0.; … … 474 480 FragmentNumber = FixedDigitNumber(MatrixCounter, i); 475 481 line << name << FRAGMENTPREFIX << FragmentNumber << "/" << prefix; 476 Free(&FragmentNumber);482 delete[](FragmentNumber); 477 483 output.open(line.str().c_str(), ios::out); 478 484 if (output == NULL) { … … 530 536 { 531 537 DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl); 532 Indices = Malloc<int*>(MatrixCounter + 1, "EnergyMatrix::ParseIndices: **Indices");538 Indices = new int*[MatrixCounter + 1]; 533 539 for(int i=MatrixCounter+1;i--;) { 534 Indices[i] = Malloc<int>(RowCounter[i], "EnergyMatrix::ParseIndices: *Indices[]");540 Indices[i] = new int[RowCounter[i]]; 535 541 for(int j=RowCounter[i];j--;) 536 542 Indices[i][j] = j; … … 589 595 // allocate last plus one matrix 590 596 DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl); 591 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");597 Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1]; 592 598 for(int j=0;j<=RowCounter[MatrixCounter];j++) 593 Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");599 Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]]; 594 600 595 601 // try independently to parse global energysuffix file if present … … 616 622 617 623 DoLog(0) && (Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl); 618 Indices = Malloc<int*>(MatrixCounter + 1, "ForceMatrix::ParseIndices: **Indices");624 Indices = new int*[MatrixCounter + 1]; 619 625 line << name << FRAGMENTPREFIX << FORCESFILE; 620 626 input.open(line.str().c_str(), ios::in); … … 629 635 line.str(filename); 630 636 // parse the values 631 Indices[i] = Malloc<int>(RowCounter[i], "ForceMatrix::ParseIndices: *Indices[]");637 Indices[i] = new int[RowCounter[i]]; 632 638 FragmentNumber = FixedDigitNumber(MatrixCounter, i); 633 639 //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:"; 634 Free(&FragmentNumber);640 delete[](FragmentNumber); 635 641 for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) { 636 642 line >> Indices[i][j]; … … 639 645 //Log() << Verbose(0) << endl; 640 646 } 641 Indices[MatrixCounter] = Malloc<int>(RowCounter[MatrixCounter], "ForceMatrix::ParseIndices: *Indices[]");647 Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]]; 642 648 for(int j=RowCounter[MatrixCounter];j--;) { 643 649 Indices[MatrixCounter][j] = j; … … 725 731 // allocate last plus one matrix 726 732 DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl); 727 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");733 Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1]; 728 734 for(int j=0;j<=RowCounter[MatrixCounter];j++) 729 Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");735 Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]]; 730 736 731 737 // try independently to parse global forcesuffix file if present … … 754 760 755 761 DoLog(0) && (Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl); 756 Indices = Malloc<int*>(MatrixCounter + 1, "HessianMatrix::ParseIndices: **Indices");762 Indices = new int*[MatrixCounter + 1]; 757 763 line << name << FRAGMENTPREFIX << FORCESFILE; 758 764 input.open(line.str().c_str(), ios::in); … … 767 773 line.str(filename); 768 774 // parse the values 769 Indices[i] = Malloc<int>(RowCounter[i], "HessianMatrix::ParseIndices: *Indices[]");775 Indices[i] = new int[RowCounter[i]]; 770 776 FragmentNumber = FixedDigitNumber(MatrixCounter, i); 771 777 //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:"; 772 Free(&FragmentNumber);778 delete[](FragmentNumber); 773 779 for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) { 774 780 line >> Indices[i][j]; … … 777 783 //Log() << Verbose(0) << endl; 778 784 } 779 Indices[MatrixCounter] = Malloc<int>(RowCounter[MatrixCounter], "HessianMatrix::ParseIndices: *Indices[]");785 Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]]; 780 786 for(int j=RowCounter[MatrixCounter];j--;) { 781 787 Indices[MatrixCounter][j] = j; … … 953 959 // allocate last plus one matrix 954 960 DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl); 955 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");961 Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1]; 956 962 for(int j=0;j<=RowCounter[MatrixCounter];j++) 957 Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");963 Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]]; 958 964 959 965 // try independently to parse global forcesuffix file if present … … 985 991 KeySetsContainer::~KeySetsContainer() { 986 992 for(int i=FragmentCounter;i--;) 987 Free(&KeySets[i]);993 delete[](KeySets[i]); 988 994 for(int i=Order;i--;) 989 Free(&OrderSet[i]);990 Free(&KeySets);991 Free(&OrderSet);992 Free(&AtomCounter);993 Free(&FragmentsPerOrder);995 delete[](OrderSet[i]); 996 delete[](KeySets); 997 delete[](OrderSet); 998 delete[](AtomCounter); 999 delete[](FragmentsPerOrder); 994 1000 }; 995 1001 … … 1008 1014 FragmentCounter = FCounter; 1009 1015 DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl); 1010 KeySets = Malloc<int*>(FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets");1016 KeySets = new int*[FragmentCounter]; 1011 1017 for(int i=FragmentCounter;i--;) 1012 1018 KeySets[i] = NULL; … … 1018 1024 } 1019 1025 1020 AtomCounter = Malloc<int>(FragmentCounter, "KeySetsContainer::ParseKeySets: *RowCounter");1026 AtomCounter = new int[FragmentCounter]; 1021 1027 for(int i=0;(i<FragmentCounter) && (!input.eof());i++) { 1022 1028 stringstream line; 1023 1029 AtomCounter[i] = ACounter[i]; 1024 1030 // parse the values 1025 KeySets[i] = Malloc<int>(AtomCounter[i], "KeySetsContainer::ParseKeySets: *KeySets[]");1031 KeySets[i] = new int[AtomCounter[i]]; 1026 1032 for(int j=AtomCounter[i];j--;) 1027 1033 KeySets[i][j] = -1; 1028 1034 FragmentNumber = FixedDigitNumber(FragmentCounter, i); 1029 1035 //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:"; 1030 Free(&FragmentNumber);1036 delete[](FragmentNumber); 1031 1037 input.getline(filename, 1023); 1032 1038 line.str(filename); … … 1062 1068 1063 1069 // scan through all to determine fragments per order 1064 FragmentsPerOrder = Malloc<int>(Order, "KeySetsContainer::ParseManyBodyTerms: *FragmentsPerOrder");1070 FragmentsPerOrder = new int[Order]; 1065 1071 for(int i=Order;i--;) 1066 1072 FragmentsPerOrder[i] = 0; … … 1076 1082 1077 1083 // scan through all to gather indices to each order set 1078 OrderSet = Malloc<int*>(Order, "KeySetsContainer::ParseManyBodyTerms: **OrderSet");1084 OrderSet = new int*[Order]; 1079 1085 for(int i=Order;i--;) 1080 OrderSet[i] = Malloc<int>(FragmentsPerOrder[i], "KeySetsContainer::ParseManyBodyTermsKeySetsContainer::ParseManyBodyTerms: *OrderSet[]");1086 OrderSet[i] = new int[FragmentsPerOrder[i]]; 1081 1087 for(int i=Order;i--;) 1082 1088 FragmentsPerOrder[i] = 0; -
src/periodentafel.cpp
r992fd7 r257c77 5 5 */ 6 6 7 #include "Helpers/MemDebug.hpp" 8 7 9 using namespace std; 8 10 9 11 #include <iomanip> 12 #include <iostream> 10 13 #include <fstream> 11 14 #include <cstring> 12 #include <cassert> 13 15 16 #include "Helpers/Assert.hpp" 14 17 #include "element.hpp" 18 #include "elements_db.hpp" 15 19 #include "helpers.hpp" 16 20 #include "lists.hpp" … … 27 31 */ 28 32 periodentafel::periodentafel() 29 {}; 33 { 34 bool status = true; 35 status = LoadElementsDatabase(new stringstream(elementsDB,ios_base::in)); 36 ASSERT(status, "General element initialization failed"); 37 status = LoadValenceDatabase(new stringstream(valenceDB,ios_base::in)); 38 ASSERT(status, "Valence entry of element initialization failed"); 39 status = LoadOrbitalsDatabase(new stringstream(orbitalsDB,ios_base::in)); 40 ASSERT(status, "Orbitals entry of element initialization failed"); 41 status = LoadHBondAngleDatabase(new stringstream(HbondangleDB,ios_base::in)); 42 ASSERT(status, "HBond angle entry of element initialization failed"); 43 status = LoadHBondLengthsDatabase(new stringstream(HbonddistanceDB,ios_base::in)); 44 ASSERT(status, "HBond distance entry of element initialization failed"); 45 }; 30 46 31 47 /** destructor for class periodentafel 32 48 * Removes every element and afterwards deletes start and end of list. 49 * TODO: Handle when elements have changed and store databases then 33 50 */ 34 51 periodentafel::~periodentafel() … … 39 56 /** Adds element to period table list 40 57 * \param *pointer element to be added 41 * \return true - succeeded, false - does not occur58 * \return iterator to added element 42 59 */ 43 60 periodentafel::iterator periodentafel::AddElement(element * const pointer) 44 61 { 45 62 atomicNumber_t Z = pointer->getNumber(); 46 assert(!elements.count(Z));63 ASSERT(!elements.count(Z), "Element is already present."); 47 64 pointer->sort = &pointer->Z; 48 65 if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS) … … 54 71 /** Removes element from list. 55 72 * \param *pointer element to be removed 56 * \return true - succeeded, false - element not found 57 */ 58 void periodentafel::RemoveElement(element * const pointer) 59 { 60 atomicNumber_t Z = pointer->getNumber(); 61 elements.erase(Z); 73 */ 74 size_t periodentafel::RemoveElement(element * const pointer) 75 { 76 return RemoveElement(pointer->getNumber()); 77 }; 78 79 /** Removes element from list. 80 * \param Z element to be removed 81 */ 82 size_t periodentafel::RemoveElement(atomicNumber_t Z) 83 { 84 return elements.erase(Z); 62 85 }; 63 86 64 87 /** Removes every element from the period table. 65 * \return true - succeeded, false - does not occur66 88 */ 67 89 void periodentafel::CleanupPeriodtable() … … 78 100 * \return pointer to element or NULL if not found 79 101 */ 80 const element *periodentafel::FindElement(atomicNumber_t Z) const102 element * const periodentafel::FindElement(atomicNumber_t Z) const 81 103 { 82 104 const_iterator res = elements.find(Z); … … 89 111 * \return pointer to element 90 112 */ 91 const element *periodentafel::FindElement(const char * const shorthand) const113 element * const periodentafel::FindElement(const char * const shorthand) const 92 114 { 93 115 element *res = 0; … … 102 124 103 125 /** Asks for element number and returns pointer to element 104 */ 105 const element * periodentafel::AskElement() const 106 { 107 const element *walker = NULL; 126 * \return desired element or NULL 127 */ 128 element * const periodentafel::AskElement() const 129 { 130 element * walker = NULL; 108 131 int Z; 109 132 do { … … 118 141 * \return pointer to either present or newly created element 119 142 */ 120 const element * periodentafel::EnterElement() 121 { 122 const element *res = NULL; 143 element * const periodentafel::EnterElement() 144 { 123 145 atomicNumber_t Z = 0; 124 146 DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl); 125 147 cin >> Z; 126 res = FindElement(Z);148 element * const res = FindElement(Z); 127 149 if (!res) { 128 150 // TODO: make this using the constructor 129 element *tmp;130 151 DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl); 131 tmp = new element;152 element *tmp = new element; 132 153 tmp->Z = Z; 133 154 DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl); … … 138 159 cin >> tmp->symbol; 139 160 AddElement(tmp); 140 re s =tmp;161 return tmp; 141 162 } 142 163 return res; … … 204 225 bool periodentafel::LoadPeriodentafel(const char *path) 205 226 { 206 ifstream infile; 207 element *ptr; 208 map<atomicNumber_t,element*> parsedElems; 227 ifstream input; 209 228 bool status = true; 210 229 bool otherstatus = true; … … 212 231 213 232 // fill elements DB 214 snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDELEMENTSDB); 215 infile.open(filename); 216 if (infile != NULL) { 217 infile.getline(header1, MAXSTRINGSIZE); 218 infile.getline(header2, MAXSTRINGSIZE); // skip first two header lines 233 strncpy(filename, path, MAXSTRINGSIZE); 234 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 235 strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename)); 236 input.open(filename); 237 if (!input.fail()) 238 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as elements database." << endl); 239 status = status && LoadElementsDatabase(&input); 240 input.close(); 241 input.clear(); 242 243 // fill valence DB per element 244 strncpy(filename, path, MAXSTRINGSIZE); 245 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 246 strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename)); 247 input.open(filename); 248 if (!input.fail()) 249 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as valence database." << endl); 250 otherstatus = otherstatus && LoadValenceDatabase(&input); 251 input.close(); 252 input.clear(); 253 254 // fill orbitals DB per element 255 strncpy(filename, path, MAXSTRINGSIZE); 256 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 257 strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename)); 258 input.open(filename); 259 if (!input.fail()) 260 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as orbitals database." << endl); 261 otherstatus = otherstatus && LoadOrbitalsDatabase(&input); 262 input.close(); 263 input.clear(); 264 265 // fill H-BondAngle DB per element 266 strncpy(filename, path, MAXSTRINGSIZE); 267 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 268 strncat(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename)); 269 input.open(filename); 270 if (!input.fail()) 271 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond angle database." << endl); 272 otherstatus = otherstatus && LoadHBondAngleDatabase(&input); 273 input.close(); 274 input.clear(); 275 276 // fill H-BondDistance DB per element 277 strncpy(filename, path, MAXSTRINGSIZE); 278 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 279 strncat(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename)); 280 input.open(filename); 281 if (!input.fail()) 282 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond length database." << endl); 283 otherstatus = otherstatus && LoadHBondLengthsDatabase(&input); 284 input.close(); 285 input.clear(); 286 287 if (!otherstatus){ 288 DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl); 289 } 290 291 return status; 292 }; 293 294 /** load the element info. 295 * \param *input stream to parse from 296 * \return true - parsing successful, false - something went wrong 297 */ 298 bool periodentafel::LoadElementsDatabase(istream *input) 299 { 300 bool status = true; 301 int counter = 0; 302 pair< std::map<atomicNumber_t,element*>::iterator, bool > InserterTest; 303 if (!(*input).fail()) { 304 (*input).getline(header1, MAXSTRINGSIZE); 305 (*input).getline(header2, MAXSTRINGSIZE); // skip first two header lines 219 306 DoLog(0) && (Log() << Verbose(0) << "Parsed elements:"); 220 while (! infile.eof()) {307 while (!(*input).eof()) { 221 308 element *neues = new element; 222 infile >> neues->name; 223 //infile >> ws; 224 infile >> neues->symbol; 225 //infile >> ws; 226 infile >> neues->period; 227 //infile >> ws; 228 infile >> neues->group; 229 //infile >> ws; 230 infile >> neues->block; 231 //infile >> ws; 232 infile >> neues->Z; 233 //infile >> ws; 234 infile >> neues->mass; 235 //infile >> ws; 236 infile >> neues->CovalentRadius; 237 //infile >> ws; 238 infile >> neues->VanDerWaalsRadius; 239 //infile >> ws; 240 infile >> ws; 241 DoLog(0) && (Log() << Verbose(0) << " " << neues->symbol); 309 (*input) >> neues->name; 310 //(*input) >> ws; 311 (*input) >> neues->symbol; 312 //(*input) >> ws; 313 (*input) >> neues->period; 314 //(*input) >> ws; 315 (*input) >> neues->group; 316 //(*input) >> ws; 317 (*input) >> neues->block; 318 //(*input) >> ws; 319 (*input) >> neues->Z; 320 //(*input) >> ws; 321 (*input) >> neues->mass; 322 //(*input) >> ws; 323 (*input) >> neues->CovalentRadius; 324 //(*input) >> ws; 325 (*input) >> neues->VanDerWaalsRadius; 326 //(*input) >> ws; 327 (*input) >> ws; 242 328 //neues->Output((ofstream *)&cout); 243 if ((neues->Z > 0) && (neues->Z < MAX_ELEMENTS)) 244 parsedElems[neues->getNumber()] = neues; 245 else { 246 DoLog(0) && (Log() << Verbose(0) << "Could not parse element: "); 247 neues->Output((ofstream *)&cout); 329 if ((neues->getNumber() > 0) && (neues->getNumber() < MAX_ELEMENTS)) { 330 if (elements.count(neues->getNumber())) {// if element already present, remove and delete old one (i.e. replace it) 331 //cout << neues->symbol << " is present already." << endl; 332 element * const Elemental = FindElement(neues->getNumber()); 333 ASSERT(Elemental != NULL, "element should be present but is not??"); 334 *Elemental = *neues; 335 } else { 336 InserterTest = elements.insert(pair <atomicNumber_t,element*> (neues->getNumber(), neues)); 337 ASSERT(InserterTest.second, "Could not insert new element into periodentafel on LoadElementsDatabase()."); 338 } 339 DoLog(0) && (Log() << Verbose(0) << " " << elements[neues->getNumber()]->symbol); 340 counter++; 341 } else { 342 DoeLog(2) && (eLog() << Verbose(2) << "Detected empty line or invalid element in elements db, discarding." << endl); 343 DoLog(0) && (Log() << Verbose(0) << " <?>"); 248 344 delete(neues); 249 345 } 250 346 } 251 347 DoLog(0) && (Log() << Verbose(0) << endl); 252 infile.close(); 253 infile.clear(); 254 } else 348 } else { 349 DoeLog(1) && (eLog() << Verbose(1) << "Could not open the database." << endl); 255 350 status = false; 256 257 // fill valence DB per element 258 snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDVALENCEDB); 259 infile.open(filename); 260 if (infile != NULL) { 261 while (!infile.eof()) { 351 } 352 353 if (counter == 0) 354 status = false; 355 356 return status; 357 } 358 359 /** load the valence info. 360 * \param *input stream to parse from 361 * \return true - parsing successful, false - something went wrong 362 */ 363 bool periodentafel::LoadValenceDatabase(istream *input) 364 { 365 char dummy[MAXSTRINGSIZE]; 366 if (!(*input).fail()) { 367 (*input).getline(dummy, MAXSTRINGSIZE); 368 while (!(*input).eof()) { 262 369 atomicNumber_t Z; 263 infile >> Z; 264 infile >> ws; 265 infile >> parsedElems[Z]->Valence; 266 infile >> ws; 370 (*input) >> Z; 371 ASSERT(elements.count(Z), "Element not present"); 372 (*input) >> ws; 373 (*input) >> elements[Z]->Valence; 374 (*input) >> ws; 267 375 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl; 268 376 } 269 infile.close(); 270 infile.clear(); 271 } else 272 otherstatus = false; 273 274 // fill valence DB per element 275 snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDORBITALDB); 276 infile.open(filename); 277 if (infile != NULL) { 278 while (!infile.eof()) { 377 return true; 378 } else 379 return false; 380 } 381 382 /** load the orbitals info. 383 * \param *input stream to parse from 384 * \return true - parsing successful, false - something went wrong 385 */ 386 bool periodentafel::LoadOrbitalsDatabase(istream *input) 387 { 388 char dummy[MAXSTRINGSIZE]; 389 if (!(*input).fail()) { 390 (*input).getline(dummy, MAXSTRINGSIZE); 391 while (!(*input).eof()) { 279 392 atomicNumber_t Z; 280 infile >> Z; 281 infile >> ws; 282 infile >> parsedElems[Z]->NoValenceOrbitals; 283 infile >> ws; 393 (*input) >> Z; 394 ASSERT(elements.count(Z), "Element not present"); 395 (*input) >> ws; 396 (*input) >> elements[Z]->NoValenceOrbitals; 397 (*input) >> ws; 284 398 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl; 285 399 } 286 infile.close(); 287 infile.clear(); 288 } else 289 otherstatus = false; 290 291 // fill H-BondDistance DB per element 292 snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDHBONDDISTANCEDB); 293 infile.open(filename); 294 if (infile != NULL) { 295 while (!infile.eof()) { 400 return true; 401 } else 402 return false; 403 } 404 405 /** load the hbond angles info. 406 * \param *input stream to parse from 407 * \return true - parsing successful, false - something went wrong 408 */ 409 bool periodentafel::LoadHBondAngleDatabase(istream *input) 410 { 411 char dummy[MAXSTRINGSIZE]; 412 if (!(*input).fail()) { 413 (*input).getline(dummy, MAXSTRINGSIZE); 414 while (!(*input).eof()) { 296 415 atomicNumber_t Z; 297 infile >> Z; 298 ptr = parsedElems[Z]; 299 infile >> ws; 300 infile >> ptr->HBondDistance[0]; 301 infile >> ptr->HBondDistance[1]; 302 infile >> ptr->HBondDistance[2]; 303 infile >> ws; 416 (*input) >> Z; 417 ASSERT(elements.count(Z), "Element not present"); 418 (*input) >> ws; 419 (*input) >> elements[Z]->HBondAngle[0]; 420 (*input) >> elements[Z]->HBondAngle[1]; 421 (*input) >> elements[Z]->HBondAngle[2]; 422 (*input) >> ws; 423 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondAngle[0] << ", " << FindElement((int)tmp)->HBondAngle[1] << ", " << FindElement((int)tmp)->HBondAngle[2] << " degrees bond angle for one, two, three connected hydrogens." << endl; 424 } 425 return true; 426 } else 427 return false; 428 } 429 430 /** load the hbond lengths info. 431 * \param *input stream to parse from 432 * \return true - parsing successful, false - something went wrong 433 */ 434 bool periodentafel::LoadHBondLengthsDatabase(istream *input) 435 { 436 char dummy[MAXSTRINGSIZE]; 437 if (!(*input).fail()) { 438 (*input).getline(dummy, MAXSTRINGSIZE); 439 while (!(*input).eof()) { 440 atomicNumber_t Z; 441 (*input) >> Z; 442 ASSERT(elements.count(Z), "Element not present"); 443 (*input) >> ws; 444 (*input) >> elements[Z]->HBondDistance[0]; 445 (*input) >> elements[Z]->HBondDistance[1]; 446 (*input) >> elements[Z]->HBondDistance[2]; 447 (*input) >> ws; 304 448 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl; 305 449 } 306 infile.close(); 307 infile.clear(); 308 } else 309 otherstatus = false; 310 311 // fill H-BondAngle DB per element 312 snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDHBONDANGLEDB); 313 infile.open(filename); 314 if (infile != NULL) { 315 while (!infile.eof()) { 316 atomicNumber_t Z; 317 infile >> Z; 318 ptr = parsedElems[Z]; 319 infile >> ws; 320 infile >> ptr->HBondAngle[0]; 321 infile >> ptr->HBondAngle[1]; 322 infile >> ptr->HBondAngle[2]; 323 infile >> ws; 324 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondAngle[0] << ", " << FindElement((int)tmp)->HBondAngle[1] << ", " << FindElement((int)tmp)->HBondAngle[2] << " degrees bond angle for one, two, three connected hydrogens." << endl; 325 } 326 infile.close(); 327 } else 328 otherstatus = false; 329 330 if (otherstatus){ 331 map<atomicNumber_t,element*>::iterator iter; 332 for(iter=parsedElems.begin();iter!=parsedElems.end();++iter){ 333 AddElement((*iter).second); 334 } 335 } 336 else{ 337 DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl); 338 map<atomicNumber_t,element*>::iterator iter; 339 for(iter=parsedElems.begin();iter!=parsedElems.end();++iter){ 340 AddElement((*iter).second); 341 } 342 } 343 344 return status; 345 }; 450 return true; 451 } else 452 return false; 453 } 346 454 347 455 /** Stores element list to file. … … 353 461 char filename[MAXSTRINGSIZE]; 354 462 355 snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDELEMENTSDB); 463 strncpy(filename, path, MAXSTRINGSIZE); 464 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 465 strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename)); 356 466 f.open(filename); 357 467 if (f != NULL) { … … 362 472 } 363 473 f.close(); 364 } else365 result = false;366 return result;367 }; 474 return true; 475 } else 476 return result; 477 }; -
src/periodentafel.hpp
r992fd7 r257c77 13 13 #include <iterator> 14 14 15 #include "unittests/periodentafelTest.hpp" 15 16 #include "defs.hpp" 16 17 #include "types.hpp" … … 27 28 class periodentafel { 28 29 /******* Types *********/ 30 friend class periodentafelTest; 29 31 private: 30 32 typedef std::map<atomicNumber_t,element*> elementSet; … … 42 44 43 45 iterator AddElement(element * const pointer); 44 void RemoveElement(element * const pointer); 46 size_t RemoveElement(element * const pointer); 47 size_t RemoveElement(atomicNumber_t); 45 48 void CleanupPeriodtable(); 46 const element *FindElement(atomicNumber_t) const;47 const element *FindElement(const char * const shorthand) const;48 const element *AskElement() const;49 const element *EnterElement();49 element * const FindElement(atomicNumber_t) const; 50 element * const FindElement(const char * const shorthand) const; 51 element * const AskElement() const; 52 element * const EnterElement(); 50 53 51 54 const_iterator begin(); … … 59 62 60 63 private: 64 65 bool LoadElementsDatabase(std::istream *input); 66 bool LoadValenceDatabase(std::istream *input); 67 bool LoadOrbitalsDatabase(std::istream *input); 68 bool LoadHBondAngleDatabase(std::istream *input); 69 bool LoadHBondLengthsDatabase(std::istream *input); 70 61 71 elementSet elements; 62 72 }; -
src/stackclass.hpp
r992fd7 r257c77 50 50 template <typename T> StackClass<T>::StackClass(int dimension) : StackList(NULL), EntryCount(dimension), CurrentLastEntry(0), CurrentFirstEntry(0), NextFreeField(0) 51 51 { 52 StackList = Calloc<T>(EntryCount, "StackClass::StackClass: **StackList"); 52 StackList = new T[EntryCount]; 53 for (int i=0;i<EntryCount;i++) 54 StackList[i] = NULL; 53 55 }; 54 56 … … 57 59 template <typename T> StackClass<T>::~StackClass() 58 60 { 59 Free(&StackList);61 delete[](StackList); 60 62 }; 61 63 -
src/tesselation.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <fstream> … … 22 24 #include "Plane.hpp" 23 25 #include "Exceptions/LinearDependenceException.hpp" 26 #include "Helpers/Assert.hpp" 27 24 28 #include "Helpers/Assert.hpp" 25 29 … … 359 363 // get ascending order of endpoints 360 364 PointMap OrderMap; 361 for (int i = 0; i < 3; i++) 365 for (int i = 0; i < 3; i++) { 362 366 // for all three lines 363 367 for (int j = 0; j < 2; j++) { // for both endpoints … … 365 369 // and we don't care whether insertion fails 366 370 } 371 } 367 372 // set endpoints 368 373 int Counter = 0; … … 373 378 Counter++; 374 379 } 375 if (Counter < 3) { 376 DoeLog(0) && (eLog() << Verbose(0) << "We have a triangle with only two distinct endpoints!" << endl); 377 performCriticalExit(); 378 } 379 } 380 ; 380 ASSERT(Counter >= 3,"We have a triangle with only two distinct endpoints!"); 381 }; 382 381 383 382 384 /** Destructor of BoundaryTriangleSet. … … 1225 1227 ; 1226 1228 1227 /** PointCloud implementation of GetTerminalPoint.1228 * Uses PointsOnBoundary and STL stuff.1229 */1230 TesselPoint * Tesselation::GetTerminalPoint() const1231 {1232 Info FunctionInfo(__func__);1233 PointMap::const_iterator Runner = PointsOnBoundary.end();1234 Runner--;1235 return (Runner->second->node);1236 }1237 ;1238 1239 1229 /** PointCloud implementation of GoToNext. 1240 1230 * Uses PointsOnBoundary and STL stuff. … … 1248 1238 ; 1249 1239 1250 /** PointCloud implementation of GoToPrevious.1251 * Uses PointsOnBoundary and STL stuff.1252 */1253 void Tesselation::GoToPrevious() const1254 {1255 Info FunctionInfo(__func__);1256 if (InternalPointer != PointsOnBoundary.begin())1257 InternalPointer--;1258 }1259 ;1260 1261 1240 /** PointCloud implementation of GoToFirst. 1262 1241 * Uses PointsOnBoundary and STL stuff. … … 1266 1245 Info FunctionInfo(__func__); 1267 1246 InternalPointer = PointsOnBoundary.begin(); 1268 }1269 ;1270 1271 /** PointCloud implementation of GoToLast.1272 * Uses PointsOnBoundary and STL stuff.1273 */1274 void Tesselation::GoToLast() const1275 {1276 Info FunctionInfo(__func__);1277 InternalPointer = PointsOnBoundary.end();1278 InternalPointer--;1279 1247 } 1280 1248 ; … … 1949 1917 RemoveTesselationLine(triangle->lines[i]); 1950 1918 } else { 1951 DoLog(0) && (Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: " );1919 DoLog(0) && (Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: " << endl); 1952 1920 OpenLines.insert(pair<BoundaryLineSet *, CandidateForTesselation *> (triangle->lines[i], NULL)); 1953 1921 for (TriangleMap::iterator TriangleRunner = triangle->lines[i]->triangles.begin(); TriangleRunner != triangle->lines[i]->triangles.end(); TriangleRunner++) 1954 DoLog(0) && (Log() << Verbose(0) << " [" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t");1922 DoLog(0) && (Log() << Verbose(0) << "\t[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t"); 1955 1923 DoLog(0) && (Log() << Verbose(0) << endl); 1956 1924 // for (int j=0;j<2;j++) { … … 2586 2554 // fill the set of neighbours 2587 2555 TesselPointSet SetOfNeighbours; 2556 2588 2557 SetOfNeighbours.insert(CandidateLine.BaseLine->endpoints[1]->node); 2589 2558 for (TesselPointList::iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); Runner++) … … 3005 2974 OldBaseLineNr = Base->Nr; 3006 2975 m = 0; 3007 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) { 3008 DoLog(0) && (Log() << Verbose(0) << "INFO: Deleting triangle " << *(runner->second) << "." << endl); 3009 OldTriangleNrs[m++] = runner->second->Nr; 3010 RemoveTesselationTriangle(runner->second); 2976 // first obtain all triangle to delete ... (otherwise we pull the carpet (Base) from under the for-loop's feet) 2977 list <BoundaryTriangleSet *> TrianglesOfBase; 2978 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); ++runner) 2979 TrianglesOfBase.push_back(runner->second); 2980 // .. then delete each triangle (which deletes the line as well) 2981 for (list <BoundaryTriangleSet *>::iterator runner = TrianglesOfBase.begin(); !TrianglesOfBase.empty(); runner = TrianglesOfBase.begin()) { 2982 DoLog(0) && (Log() << Verbose(0) << "INFO: Deleting triangle " << *(*runner) << "." << endl); 2983 OldTriangleNrs[m++] = (*runner)->Nr; 2984 RemoveTesselationTriangle((*runner)); 2985 TrianglesOfBase.erase(runner); 3011 2986 } 3012 2987 -
src/tesselation.hpp
r992fd7 r257c77 244 244 virtual Vector *GetCenter() const { return NULL; }; 245 245 virtual TesselPoint *GetPoint() const { return NULL; }; 246 virtual TesselPoint *GetTerminalPoint() const { return NULL; };247 246 virtual int GetMaxId() const { return 0; }; 248 247 virtual void GoToNext() const {}; 249 virtual void GoToPrevious() const {};250 248 virtual void GoToFirst() const {}; 251 virtual void GoToLast() const {};252 249 virtual bool IsEmpty() const { return true; }; 253 250 virtual bool IsEnd() const { return true; }; … … 363 360 virtual Vector *GetCenter(ofstream *out) const; 364 361 virtual TesselPoint *GetPoint() const; 365 virtual TesselPoint *GetTerminalPoint() const;366 362 virtual void GoToNext() const; 367 virtual void GoToPrevious() const;368 363 virtual void GoToFirst() const; 369 virtual void GoToLast() const;370 364 virtual bool IsEmpty() const; 371 365 virtual bool IsEnd() const; -
src/tesselationhelpers.cpp
r992fd7 r257c77 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <fstream> … … 786 788 Walker = cloud->GetPoint(); 787 789 *rasterfile << "2" << endl << " "; // 2 is sphere type 788 for (i=0;i<NDIM;i++) 789 *rasterfile << Walker->node->at(i)-center->at(i) << " "; 790 for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates 791 const double tmp = Walker->node->at(j)-center->at(j); 792 *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " "; 793 } 790 794 *rasterfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour 791 795 cloud->GoToNext(); … … 797 801 *rasterfile << "1" << endl << " "; // 1 is triangle type 798 802 for (i=0;i<3;i++) { // print each node 799 for (int j=0;j<NDIM;j++) // and for each node all NDIM coordinates 800 *rasterfile << TriangleRunner->second->endpoints[i]->node->node->at(j)-center->at(j) << " "; 803 for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates 804 const double tmp = TriangleRunner->second->endpoints[i]->node->node->at(j)-center->at(j); 805 *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " "; 806 } 801 807 *rasterfile << "\t"; 802 808 } … … 837 843 } 838 844 *tecplot << "\", N=" << TesselStruct->PointsOnBoundary.size() << ", E=" << TesselStruct->TrianglesOnBoundary.size() << ", DATAPACKING=POINT, ZONETYPE=FETRIANGLE" << endl; 839 int i=cloud->GetMaxId();840 int *LookupList = new int[ i];841 for ( cloud->GoToFirst(), i=0; !cloud->IsEnd(); cloud->GoToNext(), i++)845 const int MaxId=cloud->GetMaxId(); 846 int *LookupList = new int[MaxId]; 847 for (int i=0; i< MaxId ; i++){ 842 848 LookupList[i] = -1; 849 } 843 850 844 851 // print atom coordinates 845 852 int Counter = 1; 846 853 TesselPoint *Walker = NULL; 847 for (PointMap::const_iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); target++) {854 for (PointMap::const_iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); ++target) { 848 855 Walker = target->second->node; 849 856 LookupList[Walker->nr] = Counter++; 850 *tecplot << Walker->node->at(0) << " " << Walker->node->at(1) << " " << Walker->node->at(2) << " " << target->second->value << endl; 857 for (int i=0;i<NDIM;i++) { 858 const double tmp = Walker->node->at(i); 859 *tecplot << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " "; 860 } 861 *tecplot << target->second->value << endl; 851 862 } 852 863 *tecplot << endl; -
src/triangleintersectionlist.cpp
r992fd7 r257c77 8 8 * Author: heber 9 9 */ 10 11 #include "Helpers/MemDebug.hpp" 10 12 11 13 #include "triangleintersectionlist.hpp" -
src/unittests/ActOnAllUnitTest.cpp
r992fd7 r257c77 46 46 // Ref was copy constructed, hence has to be cleaned, too! 47 47 Ref.EmptyList(); 48 MemoryUsageObserver::purgeInstance();49 48 }; 50 49 … … 77 76 78 77 // scaling by three values 79 double *factors = Malloc<double>(NDIM, "ActOnAllTest::ScaleTest - factors");80 double *inverses = Malloc<double>(NDIM, "ActOnAllTest::ScaleTest - inverses");78 double *factors = new double[NDIM]; 79 double *inverses = new double[NDIM]; 81 80 for (int i=0;i<NDIM;++i) { 82 81 factors[i] = 2.; … … 88 87 VL.ActOnAll<Vector,void,const double*>(&Vector::ScaleAll, inverses ); 89 88 CPPUNIT_ASSERT_EQUAL( VL == Ref , true ); 90 Free(factors);91 Free(inverses);89 delete[](factors); 90 delete[](inverses); 92 91 }; 93 92 -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
r992fd7 r257c77 17 17 #include "AnalysisCorrelationToPointUnitTest.hpp" 18 18 19 #include "World.hpp"20 19 #include "atom.hpp" 21 #include "boundary.hpp"22 20 #include "element.hpp" 23 21 #include "molecule.hpp" 24 22 #include "linkedcell.hpp" 25 23 #include "periodentafel.hpp" 26 #include "tesselation.hpp"27 24 #include "World.hpp" 28 25 … … 43 40 TestList = NULL; 44 41 TestMolecule = NULL; 45 hydrogen = NULL;46 tafel = NULL;47 42 pointmap = NULL; 48 43 binmap = NULL; 49 44 point = NULL; 50 45 51 // construct element 52 hydrogen = new element; 53 hydrogen->Z = 1; 54 strcpy(hydrogen->name, "hydrogen"); 55 strcpy(hydrogen->symbol, "H"); 56 57 58 // construct periodentafel 59 tafel = World::getInstance().getPeriode(); 60 tafel->AddElement(hydrogen); 61 46 // construct element list 47 std::vector<element *> elements; 48 hydrogen = World::getInstance().getPeriode()->FindElement(1); 49 CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found"); 50 elements.push_back(hydrogen); 62 51 // construct molecule (tetraeder of hydrogens) 63 52 TestMolecule = World::getInstance().createMolecule(); … … 80 69 81 70 // check that TestMolecule was correctly constructed 82 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 4 );71 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 83 72 84 73 TestList = World::getInstance().getMolecules(); … … 90 79 91 80 // init maps 92 pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, (const element * const)hydrogen, (const Vector *)point );81 pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, elements, (const Vector *)point ); 93 82 binmap = NULL; 94 83 … … 105 94 delete(point); 106 95 World::purgeInstance(); 107 MemoryUsageObserver::purgeInstance();108 96 logger::purgeInstance(); 109 97 }; -
src/unittests/AnalysisCorrelationToPointUnitTest.hpp
r992fd7 r257c77 12 12 13 13 class element; 14 class LinkedCell;15 14 class molecule; 16 15 class MoleculeListClass; 17 class periodentafel;18 class Tesselation;19 16 class Vector; 20 17 … … 41 38 molecule *TestMolecule; 42 39 element *hydrogen; 43 periodentafel *tafel;44 40 45 41 CorrelationToPointMap *pointmap; -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
r992fd7 r257c77 17 17 #include "AnalysisCorrelationToSurfaceUnitTest.hpp" 18 18 19 #include "World.hpp"20 19 #include "atom.hpp" 21 20 #include "boundary.hpp" … … 26 25 #include "tesselation.hpp" 27 26 #include "World.hpp" 27 #include "Helpers/Assert.hpp" 28 28 29 29 #include "Helpers/Assert.hpp" … … 40 40 void AnalysisCorrelationToSurfaceUnitTest::setUp() 41 41 { 42 //ASSERT_DO(Assert::Throw);42 ASSERT_DO(Assert::Throw); 43 43 44 44 atom *Walker = NULL; … … 47 47 TestList = NULL; 48 48 TestSurfaceMolecule = NULL; 49 hydrogen = NULL;50 tafel = NULL;51 49 surfacemap = NULL; 52 50 binmap = NULL; … … 54 52 LC = NULL; 55 53 56 // construct element 57 hydrogen = new element; 58 hydrogen->Z = 1; 59 strcpy(hydrogen->name, "hydrogen"); 60 strcpy(hydrogen->symbol, "H"); 61 carbon = new element; 62 carbon->Z = 6; 63 strcpy(carbon->name, "carbon"); 64 strcpy(carbon->symbol, "C"); 65 66 // construct periodentafel 67 tafel = World::getInstance().getPeriode(); 68 tafel->AddElement(hydrogen); 69 tafel->AddElement(carbon); 54 // prepare element list 55 hydrogen = World::getInstance().getPeriode()->FindElement(1); 56 CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found"); 57 elements.clear(); 70 58 71 59 // construct molecule (tetraeder of hydrogens) base 72 60 TestSurfaceMolecule = World::getInstance().createMolecule(); 61 73 62 Walker = World::getInstance().createAtom(); 74 63 Walker->type = hydrogen; 75 64 *Walker->node = Vector(1., 0., 1. ); 76 77 TestSurfaceMolecule->AddAtom(Walker); 65 TestSurfaceMolecule->AddAtom(Walker); 66 78 67 Walker = World::getInstance().createAtom(); 79 68 Walker->type = hydrogen; 80 69 *Walker->node = Vector(0., 1., 1. ); 81 70 TestSurfaceMolecule->AddAtom(Walker); 71 82 72 Walker = World::getInstance().createAtom(); 83 73 Walker->type = hydrogen; 84 74 *Walker->node = Vector(1., 1., 0. ); 85 75 TestSurfaceMolecule->AddAtom(Walker); 76 86 77 Walker = World::getInstance().createAtom(); 87 78 Walker->type = hydrogen; … … 90 81 91 82 // check that TestMolecule was correctly constructed 92 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule-> AtomCount, 4 );83 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 ); 93 84 94 85 TestList = World::getInstance().getMolecules(); … … 102 93 103 94 // add outer atoms 95 carbon = World::getInstance().getPeriode()->FindElement(6); 104 96 TestSurfaceMolecule = World::getInstance().createMolecule(); 105 97 Walker = World::getInstance().createAtom(); … … 107 99 *Walker->node = Vector(4., 0., 4. ); 108 100 TestSurfaceMolecule->AddAtom(Walker); 101 109 102 Walker = World::getInstance().createAtom(); 110 103 Walker->type = carbon; 111 104 *Walker->node = Vector(0., 4., 4. ); 112 105 TestSurfaceMolecule->AddAtom(Walker); 106 113 107 Walker = World::getInstance().createAtom(); 114 108 Walker->type = carbon; 115 109 *Walker->node = Vector(4., 4., 0. ); 116 110 TestSurfaceMolecule->AddAtom(Walker); 111 117 112 // add inner atoms 118 113 Walker = World::getInstance().createAtom(); … … 120 115 *Walker->node = Vector(0.5, 0.5, 0.5 ); 121 116 TestSurfaceMolecule->AddAtom(Walker); 117 122 118 TestSurfaceMolecule->ActiveFlag = true; 123 119 TestList->insert(TestSurfaceMolecule); … … 141 137 delete(LC); 142 138 World::purgeInstance(); 143 MemoryUsageObserver::purgeInstance();144 139 logger::purgeInstance(); 145 140 }; … … 150 145 void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest() 151 146 { 152 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule-> AtomCount);147 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() ); 153 148 CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() ); 154 149 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() ); … … 160 155 { 161 156 // do the pair correlation 162 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 157 elements.push_back(hydrogen); 158 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 163 159 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 164 160 CPPUNIT_ASSERT( surfacemap != NULL ); … … 169 165 { 170 166 BinPairMap::iterator tester; 171 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 167 elements.push_back(hydrogen); 168 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 172 169 // put pair correlation into bins and check with no range 173 170 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); … … 184 181 { 185 182 BinPairMap::iterator tester; 186 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 183 elements.push_back(hydrogen); 184 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 187 185 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 188 186 // ... and check with [0., 2.] range … … 202 200 { 203 201 BinPairMap::iterator tester; 204 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 202 elements.push_back(carbon); 203 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 205 204 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 206 205 // put pair correlation into bins and check with no range … … 221 220 { 222 221 BinPairMap::iterator tester; 223 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 222 elements.push_back(carbon); 223 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 224 224 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 225 225 // ... and check with [0., 2.] range -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
r992fd7 r257c77 47 47 element *hydrogen; 48 48 element *carbon; 49 periodentafel *tafel;49 std::vector<element *> elements; 50 50 51 51 CorrelationToSurfaceMap *surfacemap; -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
r992fd7 r257c77 44 44 TestList = NULL; 45 45 TestMolecule = NULL; 46 hydrogen = NULL;47 tafel = NULL;48 46 correlationmap = NULL; 49 47 binmap = NULL; 50 48 51 // construct element 52 hydrogen = new element; 53 hydrogen->Z = 1; 54 strcpy(hydrogen->name, "hydrogen"); 55 strcpy(hydrogen->symbol, "H"); 56 57 // construct periodentafel 58 tafel = World::getInstance().getPeriode(); 59 tafel->AddElement(hydrogen); 49 // construct element list 50 std::vector<element *> elements; 51 hydrogen = World::getInstance().getPeriode()->FindElement(1); 52 CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found"); 53 elements.push_back(hydrogen); 54 elements.push_back(hydrogen); 60 55 61 56 // construct molecule (tetraeder of hydrogens) … … 79 74 80 75 // check that TestMolecule was correctly constructed 81 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 4 );76 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 82 77 83 78 TestList = World::getInstance().getMolecules(); … … 86 81 87 82 // init maps 88 correlationmap = PairCorrelation( TestList, hydrogen, hydrogen);83 correlationmap = PairCorrelation( TestList, elements); 89 84 binmap = NULL; 90 85 … … 101 96 // note that all the atoms are cleaned by TestMolecule 102 97 World::purgeInstance(); 103 MemoryUsageObserver::purgeInstance();104 98 logger::purgeInstance(); 105 99 errorLogger::purgeInstance(); -
src/unittests/AnalysisPairCorrelationUnitTest.hpp
r992fd7 r257c77 12 12 13 13 class element; 14 class LinkedCell;15 14 class molecule; 16 15 class MoleculeListClass; 17 class periodentafel;18 class Tesselation;19 16 class Vector; 20 17 … … 41 38 molecule *TestMolecule; 42 39 element *hydrogen; 43 periodentafel *tafel;44 40 45 41 PairCorrelationMap *correlationmap; -
src/unittests/CacheableTest.cpp
r992fd7 r257c77 55 55 56 56 threeNumbers(int _x,int _y, int _z) : 57 Observable("threeNumbers"), 57 58 x(_x),y(_y),z(_z), 58 sum(this,boost::bind(&threeNumbers::calcSum,this) ),59 sum(this,boost::bind(&threeNumbers::calcSum,this),"sum"), 59 60 hasRecalced(false) 60 61 {} … … 81 82 CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum)); 82 83 CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced); 84 numbers->hasRecalced=false; 85 CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum)); 86 #ifndef NO_CACHING 87 CPPUNIT_ASSERT_EQUAL( false, numbers->hasRecalced); 88 #else 89 CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced); 90 #endif 83 91 } -
src/unittests/CountBondsUnitTest.cpp
r992fd7 r257c77 16 16 #include <stdio.h> 17 17 #include <cstring> 18 19 #include "Helpers/Assert.hpp" 18 20 19 21 #include "analysis_bonds.hpp" … … 40 42 { 41 43 atom *Walker = NULL; 42 BG = NULL;43 filename = NULL;44 45 // init private all pointers to zero46 molecules = NULL;47 TestMolecule1 = NULL;48 TestMolecule2 = NULL;49 hydrogen = NULL;50 oxygen = NULL;51 tafel = NULL;52 44 53 45 // construct element 54 hydrogen = new element; 55 hydrogen->Z = 1; 56 hydrogen->CovalentRadius = 0.23; 57 strcpy(hydrogen->name, "hydrogen"); 58 strcpy(hydrogen->symbol, "H"); 59 oxygen = new element; 60 oxygen->Z = 8; 61 oxygen->CovalentRadius = 0.68; 62 strcpy(oxygen->name, "oxygen"); 63 strcpy(oxygen->symbol, "O"); 64 65 // construct periodentafel 66 tafel = World::getInstance().getPeriode(); 67 tafel->AddElement(hydrogen); 68 tafel->AddElement(oxygen); 46 hydrogen = World::getInstance().getPeriode()->FindElement(1); 47 oxygen = World::getInstance().getPeriode()->FindElement(8); 48 CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen"); 49 CPPUNIT_ASSERT(oxygen != NULL && "could not find element oxygen"); 69 50 70 51 // construct molecule (water molecule) 71 52 TestMolecule1 = World::getInstance().createMolecule(); 72 Walker = World::getInstance().createAtom(); 53 CPPUNIT_ASSERT(TestMolecule1 != NULL && "could not create first molecule"); 54 Walker = World::getInstance().createAtom(); 55 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 73 56 Walker->type = hydrogen; 74 57 *Walker->node = Vector(-0.2418, 0.9350, 0. ); 75 58 TestMolecule1->AddAtom(Walker); 76 59 Walker = World::getInstance().createAtom(); 60 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 77 61 Walker->type = hydrogen; 78 62 *Walker->node = Vector(0.9658, 0., 0. ); 79 63 TestMolecule1->AddAtom(Walker); 80 64 Walker = World::getInstance().createAtom(); 65 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 81 66 Walker->type = oxygen; 82 67 *Walker->node = Vector(0., 0., 0. ); … … 84 69 85 70 TestMolecule2 = World::getInstance().createMolecule(); 86 Walker = World::getInstance().createAtom(); 71 CPPUNIT_ASSERT(TestMolecule2 != NULL && "could not create second molecule"); 72 Walker = World::getInstance().createAtom(); 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 87 74 Walker->type = hydrogen; 88 75 *Walker->node = Vector(-0.2418, 0.9350, 0. ); 89 76 TestMolecule2->AddAtom(Walker); 90 77 Walker = World::getInstance().createAtom(); 78 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 91 79 Walker->type = hydrogen; 92 80 *Walker->node = Vector(0.9658, 0., 0. ); 93 81 TestMolecule2->AddAtom(Walker); 94 82 Walker = World::getInstance().createAtom(); 83 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 95 84 Walker->type = oxygen; 96 85 *Walker->node = Vector(0., 0., 0. ); … … 98 87 99 88 molecules = World::getInstance().getMolecules(); 89 CPPUNIT_ASSERT(molecules != NULL && "could not obtain list of molecules"); 100 90 molecules->insert(TestMolecule1); 101 91 molecules->insert(TestMolecule2); 102 92 103 93 // check that TestMolecule was correctly constructed 104 CPPUNIT_ASSERT_EQUAL( TestMolecule1->AtomCount, 3 ); 105 Walker = TestMolecule1->start->next; 106 CPPUNIT_ASSERT( TestMolecule1->end != Walker ); 107 CPPUNIT_ASSERT_EQUAL( TestMolecule2->AtomCount, 3 ); 108 Walker = TestMolecule2->start->next; 109 CPPUNIT_ASSERT( TestMolecule2->end != Walker ); 94 CPPUNIT_ASSERT_EQUAL( TestMolecule1->getAtomCount(), 3 ); 95 CPPUNIT_ASSERT_EQUAL( TestMolecule2->getAtomCount(), 3 ); 110 96 111 97 // create a small file with table 112 98 BG = new BondGraph(true); 99 CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph"); 113 100 114 101 // construct bond graphs … … 126 113 127 114 World::purgeInstance(); 128 MemoryUsageObserver::purgeInstance();129 115 }; 130 116 … … 158 144 { 159 145 double *mirror = new double[3]; 146 CPPUNIT_ASSERT(mirror != NULL && "could not create array of doubles"); 160 147 for (int i=0;i<3;i++) 161 148 mirror[i] = -1.; -
src/unittests/CountBondsUnitTest.hpp
r992fd7 r257c77 39 39 molecule *TestMolecule1; 40 40 molecule *TestMolecule2; 41 element *hydrogen; 42 element *oxygen; 43 periodentafel *tafel; 41 const element *hydrogen; 42 const element *oxygen; 44 43 45 44 BondGraph *BG; -
src/unittests/LinkedCellUnitTest.cpp
r992fd7 r257c77 38 38 atom *Walker = NULL; 39 39 40 // init private all pointers to zero41 TestMolecule = NULL;42 hydrogen = NULL;43 tafel = NULL;44 45 40 // construct element 46 hydrogen = new element; 47 hydrogen->Z = 1; 48 hydrogen->CovalentRadius = 0.23; 49 strcpy(hydrogen->name, "hydrogen"); 50 strcpy(hydrogen->symbol, "H"); 51 52 // construct periodentafel 53 tafel = World::getInstance().getPeriode(); 54 tafel->AddElement(hydrogen); 41 hydrogen = World::getInstance().getPeriode()->FindElement(1); 42 CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen"); 55 43 56 44 // construct molecule (water molecule) 57 45 TestMolecule = World::getInstance().createMolecule(); 46 CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule"); 58 47 for (double x=0.5;x<3;x+=1.) 59 48 for (double y=0.5;y<3;y+=1.) 60 49 for (double z=0.5;z<3;z+=1.) { 61 50 Walker = World::getInstance().createAtom(); 51 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 62 52 Walker->type = hydrogen; 63 53 *Walker->node = Vector(x, y, z ); … … 67 57 // construct linked cell 68 58 LC = new LinkedCell (TestMolecule, 1.); 59 CPPUNIT_ASSERT(LC != NULL && "could not create LinkedCell"); 69 60 70 61 // check that TestMolecule was correctly constructed 71 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 3*3*3 ); 72 Walker = TestMolecule->start->next; 73 CPPUNIT_ASSERT( TestMolecule->end != Walker ); 62 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 3*3*3 ); 74 63 }; 75 64 … … 79 68 delete(LC); 80 69 World::purgeInstance(); 81 MemoryUsageObserver::purgeInstance();82 70 }; 83 71 … … 197 185 { 198 186 // check all atoms 199 atom *Walker = TestMolecule->start; 200 while (Walker->next != TestMolecule->end) { 201 Walker = Walker->next; 202 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) ); 203 189 } 204 190 205 191 // check internal vectors, returns false, because this atom is not in LC-list! 206 Walker= World::getInstance().createAtom();207 Walker->setName("test");208 Walker->x= Vector(1,1,1);209 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode( Walker) );210 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); 211 197 212 198 // check out of bounds vectors 213 Walker= World::getInstance().createAtom();214 Walker->setName("test");215 Walker->x = Vector(0,-1,0);216 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode( Walker) );217 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); 218 204 }; 219 205 … … 287 273 size = ListOfPoints->size(); 288 274 CPPUNIT_ASSERT_EQUAL( (size_t)27, size ); 289 Walker = TestMolecule->start; 290 Walker = TestMolecule->start; 291 while (Walker->next != TestMolecule->end) { 292 Walker = Walker->next; 293 ListOfPoints->remove(Walker); 275 276 for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){ 277 ListOfPoints->remove((*iter)); 294 278 size--; 295 279 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); … … 306 290 size=ListOfPoints->size(); 307 291 CPPUNIT_ASSERT_EQUAL( (size_t)8, size ); 308 Walker = TestMolecule->start; 309 while (Walker->next != TestMolecule->end) { 310 Walker = Walker->next; 311 if ((Walker->x[0] <2) && (Walker->x[1] <2) && (Walker->x[2] <2)) { 312 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); 313 295 size--; 314 296 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); … … 326 308 size=ListOfPoints->size(); 327 309 CPPUNIT_ASSERT_EQUAL( (size_t)27, size ); 328 Walker = TestMolecule->start; 329 while (Walker->next != TestMolecule->end) { 330 Walker = Walker->next; 331 ListOfPoints->remove(Walker); 310 for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){ 311 ListOfPoints->remove(*iter); 332 312 size--; 333 313 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); … … 355 335 size = ListOfPoints->size(); 356 336 CPPUNIT_ASSERT_EQUAL( (size_t)7, size ); 357 Walker = TestMolecule->start; 358 while (Walker->next != TestMolecule->end) { 359 Walker = Walker->next; 360 if ((Walker->x.DistanceSquared(tester) - 1.) < MYEPSILON ) { 361 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); 362 340 size--; 363 341 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); -
src/unittests/LinkedCellUnitTest.hpp
r992fd7 r257c77 48 48 49 49 molecule *TestMolecule; 50 element *hydrogen; 51 periodentafel *tafel; 50 const element *hydrogen; 52 51 LinkedCell *LC; 53 52 }; -
src/unittests/Makefile.am
r992fd7 r257c77 1 # PLEASE adhere to the alphabetical ordering in this Makefile! 2 # Also indentation by a single tab 3 1 4 INCLUDES = -I$(top_srcdir)/src 2 5 … … 31 34 MemoryAllocatorUnitTest \ 32 35 MoleculeDescriptorTest \ 36 ObserverTest \ 37 ParserUnitTest \ 38 periodentafelTest \ 33 39 PlaneUnittest \ 34 ObserverTest \35 40 SingletonTest \ 36 41 StackClassUnitTest \ … … 73 78 memoryusageobserverunittest.cpp \ 74 79 MoleculeDescriptorTest.cpp \ 80 ObserverTest.cpp \ 81 ParserUnitTest.cpp \ 82 periodentafelTest.cpp \ 75 83 PlaneUnittest.cpp \ 76 ObserverTest.cpp \77 84 SingletonTest.cpp \ 78 85 stackclassunittest.cpp \ … … 107 114 memoryusageobserverunittest.hpp \ 108 115 MoleculeDescriptorTest.hpp \ 116 periodentafelTest.hpp \ 109 117 PlaneUnittest.hpp \ 110 118 ObserverTest.hpp \ … … 117 125 118 126 127 ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp 128 ActionSequenceTest_LDADD = ${ALLLIBS} 129 119 130 ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp 120 131 ActOnAllUnitTest_LDADD = ${ALLLIBS} … … 135 146 atomsCalculationTest_LDADD = ${ALLLIBS} 136 147 148 AtomDescriptorTest_SOURCES = UnitTestMain.cpp AtomDescriptorTest.cpp AtomDescriptorTest.hpp 149 AtomDescriptorTest_LDADD = ${ALLLIBS} 150 137 151 BondGraphUnitTest_SOURCES = UnitTestMain.cpp bondgraphunittest.cpp bondgraphunittest.hpp 138 152 BondGraphUnitTest_LDADD = ${ALLLIBS} 139 153 154 CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp 155 CacheableTest_LDADD = ${ALLLIBS} 156 140 157 CountBondsUnitTest_SOURCES = UnitTestMain.cpp CountBondsUnitTest.cpp CountBondsUnitTest.hpp 141 158 CountBondsUnitTest_LDADD = ${ALLLIBS} … … 168 185 LogUnitTest_LDADD = ${ALLLIBS} 169 186 170 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp 187 manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp 188 manipulateAtomsTest_LDADD = ${ALLLIBS} 189 190 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp 171 191 MemoryAllocatorUnitTest_LDADD = ${ALLLIBS} 172 192 173 MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp193 MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp 174 194 MemoryUsageObserverUnitTest_LDADD = ${ALLLIBS} 175 195 … … 177 197 MoleculeDescriptorTest_LDADD = ${ALLLIBS} 178 198 199 ObserverTest_SOURCES = UnitTestMain.cpp ObserverTest.cpp ObserverTest.hpp 200 ObserverTest_LDADD = ${ALLLIBS} 201 202 ParserUnitTest_SOURCES = UnitTestMain.cpp ParserUnitTest.cpp ParserUnitTest.hpp 203 ParserUnitTest_LDADD = ${ALLLIBS} 204 205 periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp 206 periodentafelTest_LDADD = ${ALLLIBS} 207 179 208 PlaneUnittest_SOURCES = UnitTestMain.cpp PlaneUnittest.cpp PlaneUnittest.hpp 180 209 PlaneUnittest_LDADD = ${ALLLIBS} … … 195 224 Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS} 196 225 226 TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp $(TESTSOURCES) $(TESTHEADERS) 227 TestRunner_LDADD = ${ALLLIBS} 228 197 229 VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp 198 230 VectorUnitTest_LDADD = ${ALLLIBS} 199 231 200 ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp201 ActionSequenceTest_LDADD = ${ALLLIBS}202 203 ObserverTest_SOURCES = UnitTestMain.cpp ObserverTest.cpp ObserverTest.hpp204 ObserverTest_LDADD = ${ALLLIBS}205 206 CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp207 CacheableTest_LDADD = ${ALLLIBS}208 209 AtomDescriptorTest_SOURCES = UnitTestMain.cpp AtomDescriptorTest.cpp AtomDescriptorTest.hpp210 AtomDescriptorTest_LDADD = ${ALLLIBS}211 212 manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp213 manipulateAtomsTest_LDADD = ${ALLLIBS}214 215 TestRunner_SOURCES = TestRunnerMain.cpp $(TESTSOURCES) $(TESTHEADERS)216 TestRunner_LDADD = ${ALLLIBS}217 218 232 #AUTOMAKE_OPTIONS = parallel-tests 219 -
src/unittests/ObserverTest.cpp
r992fd7 r257c77 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 … … 31 33 public: 32 34 UpdateCountObserver() : 35 Observer("UpdateCountObserver"), 33 36 updates(0) 34 37 {}; … … 43 46 class SimpleObservable : public Observable { 44 47 public: 48 SimpleObservable() : 49 Observable("SimpleObservable") 50 {} 51 45 52 void changeMethod() { 46 53 OBSERVE; … … 52 59 class CallObservable : public Observable { 53 60 public: 61 CallObservable() : 62 Observable("CallObservable") 63 {} 64 54 65 void changeMethod1() { 55 66 OBSERVE; … … 68 79 class BlockObservable : public Observable { 69 80 public: 81 BlockObservable() : 82 Observable("BlockObservable") 83 {} 84 70 85 void changeMethod1(){ 71 86 OBSERVE; … … 102 117 class SuperObservable : public Observable { 103 118 public: 104 SuperObservable(){ 119 SuperObservable(): 120 Observable("SuperObservable") 121 { 105 122 subObservable = new SimpleObservable(); 106 123 subObservable->signOn(this); … … 121 138 public: 122 139 NotificationObservable() : 123 notification1(new Notification(this)), 124 notification2(new Notification(this)) 140 Observable("NotificationObservable"), 141 notification1(new Notification(this)), 142 notification2(new Notification(this)) 125 143 {} 126 144 … … 147 165 public: 148 166 NotificationObserver(Notification_ptr notification) : 167 Observer("NotificationObserver"), 149 168 requestedNotification(notification), 150 169 wasNotified(false) … … 162 181 bool wasNotified; 163 182 }; 183 184 class ObservableCollection : public Observable { 185 public: 186 typedef std::set<SimpleObservable*> set; 187 typedef ObservedIterator<set> iterator; 188 typedef set::const_iterator const_iterator; 189 190 ObservableCollection(int _num) : 191 Observable("ObservableCollection"), 192 num(_num) 193 { 194 for(int i=0; i<num; ++i){ 195 SimpleObservable *content = new SimpleObservable(); 196 content->signOn(this); 197 theSet.insert(content); 198 } 199 } 200 201 ~ObservableCollection(){ 202 set::iterator iter; 203 for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){ 204 delete (*iter); 205 } 206 } 207 208 iterator begin(){ 209 return iterator(theSet.begin(),this); 210 } 211 212 iterator end(){ 213 return iterator(theSet.end(),this); 214 } 215 216 const int num; 217 218 private: 219 set theSet; 220 }; 221 164 222 165 223 /******************* actuall tests ***************/ … … 173 231 blockObservable = new BlockObservable(); 174 232 notificationObservable = new NotificationObservable(); 233 collection = new ObservableCollection(5); 175 234 176 235 observer1 = new UpdateCountObserver(); … … 181 240 notificationObserver1 = new NotificationObserver(notificationObservable->notification1); 182 241 notificationObserver2 = new NotificationObserver(notificationObservable->notification2); 183 184 242 } 185 243 … … 191 249 delete blockObservable; 192 250 delete notificationObservable; 251 delete collection; 193 252 194 253 delete observer1; … … 277 336 blockObservable->changeMethod2(); 278 337 blockObservable->noChangeMethod(); 338 } 339 340 void ObserverTest::iteratorTest(){ 341 int i = 0; 342 // test the general iterator methods 343 for(ObservableCollection::iterator iter=collection->begin(); iter!=collection->end();++iter){ 344 CPPUNIT_ASSERT(i< collection->num); 345 i++; 346 } 347 348 i=0; 349 for(ObservableCollection::const_iterator iter=collection->begin(); iter!=collection->end();++iter){ 350 CPPUNIT_ASSERT(i<collection->num); 351 i++; 352 } 353 354 collection->signOn(observer1); 355 { 356 // we construct this out of the loop, so the iterator dies at the end of 357 // the scope and not the end of the loop (allows more testing) 358 ObservableCollection::iterator iter; 359 for(iter=collection->begin(); iter!=collection->end(); ++iter){ 360 (*iter)->changeMethod(); 361 } 362 // At this point no change should have been propagated 363 CPPUNIT_ASSERT_EQUAL( 0, observer1->updates); 364 } 365 // After the Iterator has died the propagation should take place 366 CPPUNIT_ASSERT_EQUAL( 1, observer1->updates); 367 368 // when using a const_iterator no changes should be propagated 369 for(ObservableCollection::const_iterator iter = collection->begin(); iter!=collection->end();++iter); 370 CPPUNIT_ASSERT_EQUAL( 1, observer1->updates); 371 collection->signOff(observer1); 279 372 } 280 373 -
src/unittests/ObserverTest.hpp
r992fd7 r257c77 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/SingletonTest.cpp
r992fd7 r257c77 52 52 count1++; 53 53 } 54 // explicit copy constructor to catch if th siis ever called54 // explicit copy constructor to catch if this is ever called 55 55 SingletonStub2(const SingletonStub2&){ 56 56 CPPUNIT_FAIL ( "Copy constructor of Singleton called" ); -
src/unittests/TestRunnerMain.cpp
r992fd7 r257c77 6 6 */ 7 7 8 // include config.h 9 #ifdef HAVE_CONFIG_H 10 #include <config.h> 11 #endif 12 13 #ifdef HAVE_ECUT 8 14 // give the main function its correct name 9 15 #define CPPUNIT_MAIN main 10 11 16 // include the TestRunnerClient file containing the main class 12 17 #include "../../../TestRunnerClient.h" 13 18 #include "../../../TestRunnerClient.cpp" 19 #else 20 #include "UnitTestMain.cpp" 21 #endif 22 -
src/unittests/analysisbondsunittest.cpp
r992fd7 r257c77 25 25 #include "molecule.hpp" 26 26 #include "periodentafel.hpp" 27 #include "World.hpp" 27 28 28 29 #ifdef HAVE_TESTRUNNER … … 40 41 atom *Walker = NULL; 41 42 42 // init private all pointers to zero 43 TestMolecule = NULL; 44 hydrogen = NULL; 45 tafel = NULL; 46 47 // construct element 48 hydrogen = new element; 49 hydrogen->Z = 1; 50 hydrogen->Valence = 1; 51 hydrogen->NoValenceOrbitals = 1; 52 strcpy(hydrogen->name, "hydrogen"); 53 strcpy(hydrogen->symbol, "H"); 54 carbon = new element; 55 carbon->Z = 2; 56 carbon->Valence = 4; 57 carbon->NoValenceOrbitals = 4; 58 strcpy(carbon->name, "carbon"); 59 strcpy(carbon->symbol, "C"); 60 61 62 // construct periodentafel 63 tafel = World::getInstance().getPeriode(); 64 tafel->AddElement(hydrogen); 65 tafel->AddElement(carbon); 43 // get elements 44 hydrogen = World::getInstance().getPeriode()->FindElement(1); 45 carbon = World::getInstance().getPeriode()->FindElement(6); 46 CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen"); 47 CPPUNIT_ASSERT(carbon != NULL && "could not find element carbon"); 66 48 67 49 // construct molecule (tetraeder of hydrogens) 68 50 TestMolecule = World::getInstance().createMolecule(); 51 CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule"); 69 52 Walker = World::getInstance().createAtom(); 53 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 70 54 Walker->type = hydrogen; 71 55 *Walker->node = Vector(1.5, 0., 1.5 ); 72 56 TestMolecule->AddAtom(Walker); 73 57 Walker = World::getInstance().createAtom(); 58 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 74 59 Walker->type = hydrogen; 75 60 *Walker->node = Vector(0., 1.5, 1.5 ); 76 61 TestMolecule->AddAtom(Walker); 77 62 Walker = World::getInstance().createAtom(); 63 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 78 64 Walker->type = hydrogen; 79 65 *Walker->node = Vector(1.5, 1.5, 0. ); 80 66 TestMolecule->AddAtom(Walker); 81 67 Walker = World::getInstance().createAtom(); 68 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 82 69 Walker->type = hydrogen; 83 70 *Walker->node = Vector(0., 0., 0. ); 84 71 TestMolecule->AddAtom(Walker); 85 72 Walker = World::getInstance().createAtom(); 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 86 74 Walker->type = carbon; 87 75 *Walker->node = Vector(0.5, 0.5, 0.5 ); … … 89 77 90 78 // check that TestMolecule was correctly constructed 91 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 5 );79 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 5 ); 92 80 93 81 // create a small file with table 94 82 filename = new string("test.dat"); 83 CPPUNIT_ASSERT(filename != NULL && "could not create string"); 95 84 ofstream test(filename->c_str()); 96 test << ".\tH\tC\n"; 97 test << "H\t1.\t1.2\n"; 98 test << "C\t1.2\t1.5\n"; 85 test << ".\tH\tHe\tLi\tBe\tB\tC\n"; 86 test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n"; 87 test << "He\t1.\t1.\t1.\t1.\t1.\t1.\n"; 88 test << "Li\t1.\t1.\t1.\t1.\t1.\t1.\n"; 89 test << "Be\t1.\t1.\t1.\t1.\t1.\t1.\n"; 90 test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n"; 91 test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n"; 99 92 test.close(); 100 93 BG = new BondGraph(true); 94 CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph"); 101 95 102 96 CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) ); 103 97 CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) ); 104 CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0, 1) );105 CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength( 1,1) );98 CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) ); 99 CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) ); 106 100 107 101 BG->ConstructBondGraph(TestMolecule); -
src/unittests/analysisbondsunittest.hpp
r992fd7 r257c77 34 34 35 35 molecule *TestMolecule; 36 element *hydrogen; 37 element *carbon; 38 periodentafel *tafel; 36 const element *hydrogen; 37 const element *carbon; 39 38 40 39 BondGraph *BG; -
src/unittests/bondgraphunittest.cpp
r992fd7 r257c77 15 15 #include <stdio.h> 16 16 #include <cstring> 17 18 #include "Helpers/Assert.hpp" 17 19 18 20 #include "World.hpp" … … 41 43 atom *Walker = NULL; 42 44 43 // init private all pointers to zero44 TestMolecule = NULL;45 hydrogen = NULL;46 tafel = NULL;47 48 45 // construct element 49 hydrogen = new element; 50 hydrogen->Z = 1; 51 hydrogen->CovalentRadius = 0.23; 52 hydrogen->VanDerWaalsRadius = 1.09; 53 strcpy(hydrogen->name, "hydrogen"); 54 strcpy(hydrogen->symbol, "H"); 55 carbon = new element; 56 carbon->Z = 2; 57 carbon->CovalentRadius = 0.68; 58 carbon->VanDerWaalsRadius = 1.7; 59 strcpy(carbon->name, "carbon"); 60 strcpy(carbon->symbol, "C"); 61 62 63 // construct periodentafel 64 tafel = World::getInstance().getPeriode(); 65 tafel->AddElement(hydrogen); 66 tafel->AddElement(carbon); 46 hydrogen = World::getInstance().getPeriode()->FindElement(1); 47 carbon = World::getInstance().getPeriode()->FindElement(6); 48 CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen"); 49 CPPUNIT_ASSERT(carbon != NULL && "could not find element carbon"); 67 50 68 51 // construct molecule (tetraeder of hydrogens) 69 52 TestMolecule = World::getInstance().createMolecule(); 53 CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule"); 70 54 Walker = World::getInstance().createAtom(); 55 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 71 56 Walker->type = carbon; 72 57 *Walker->node = Vector(1., 0., 1. ); … … 74 59 75 60 Walker = World::getInstance().createAtom(); 61 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 76 62 Walker->type = carbon; 77 63 *Walker->node = Vector(0., 1., 1. ); … … 79 65 80 66 Walker = World::getInstance().createAtom(); 67 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 81 68 Walker->type = carbon; 82 69 *Walker->node = Vector(1., 1., 0. ); … … 84 71 85 72 Walker = World::getInstance().createAtom(); 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 86 74 Walker->type = carbon; 87 75 *Walker->node = Vector(0., 0., 0. ); … … 89 77 90 78 // check that TestMolecule was correctly constructed 91 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 4 );79 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 92 80 93 81 // create a small file with table 94 82 dummyname = new string("dummy.dat"); 83 CPPUNIT_ASSERT(dummyname != NULL && "could not create string"); 95 84 filename = new string("test.dat"); 85 CPPUNIT_ASSERT(filename != NULL && "could not create string"); 96 86 ofstream test(filename->c_str()); 97 test << ".\tH\tC\n"; 98 test << "H\t1.\t1.2\n"; 99 test << "C\t1.2\t1.5\n"; 87 test << ".\tH\tHe\tLi\tBe\tB\tC\n"; 88 test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n"; 89 test << "He\t1.\t1.\t1.\t1.\t1.\t1.\n"; 90 test << "Li\t1.\t1.\t1.\t1.\t1.\t1.\n"; 91 test << "Be\t1.\t1.\t1.\t1.\t1.\t1.\n"; 92 test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n"; 93 test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n"; 100 94 test.close(); 101 95 BG = new BondGraph(true); 96 CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph"); 102 97 }; 103 98 … … 116 111 // are all cleaned when the world is destroyed 117 112 World::purgeInstance(); 118 MemoryUsageObserver::purgeInstance();119 113 logger::purgeInstance(); 114 }; 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()); 120 122 }; 121 123 … … 126 128 CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) ); 127 129 CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) ); 128 CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0, 1) );129 CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength( 1,1) );130 CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) ); 131 CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) ); 130 132 }; 131 133 … … 134 136 void BondGraphTest::ConstructGraphFromTableTest() 135 137 { 136 atom *Walker = TestMolecule->start->next;137 atom *Runner = TestMolecule->end->previous;138 CPPUNIT_ASSERT( TestMolecule->end != Walker );138 molecule::iterator Walker = TestMolecule->begin(); 139 molecule::iterator Runner = TestMolecule->begin(); 140 Runner++; 139 141 CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) ); 140 142 CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) ); 141 CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );143 CPPUNIT_ASSERT_EQUAL( true , (*Walker)->IsBondedTo((*Runner)) ); 142 144 }; 143 145 … … 146 148 void BondGraphTest::ConstructGraphFromCovalentRadiiTest() 147 149 { 148 atom *Walker = TestMolecule->start->next; 149 atom *Runner = TestMolecule->end->previous; 150 CPPUNIT_ASSERT( TestMolecule->end != Walker ); 150 151 //atom *Walker = TestMolecule->start->next; 152 //atom *Runner = TestMolecule->end->previous; 153 //CPPUNIT_ASSERT( TestMolecule->end != Walker ); 151 154 CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) ); 152 155 CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) ); 153 CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) ); 156 157 // this cannot be assured using dynamic IDs 158 //CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) ); 154 159 }; 155 160 -
src/unittests/bondgraphunittest.hpp
r992fd7 r257c77 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(); … … 37 39 38 40 molecule *TestMolecule; 39 element *hydrogen; 40 element *carbon; 41 periodentafel *tafel; 41 const element *hydrogen; 42 const element *carbon; 42 43 43 44 BondGraph *BG; -
src/unittests/listofbondsunittest.cpp
r992fd7 r257c77 38 38 atom *Walker = NULL; 39 39 40 // init private all pointers to zero41 TestMolecule = NULL;42 hydrogen = NULL;43 tafel = NULL;44 45 40 // construct element 46 hydrogen = new element; 47 hydrogen->Z = 1; 48 strcpy(hydrogen->name, "hydrogen"); 49 strcpy(hydrogen->symbol, "H"); 50 51 52 // construct periodentafel 53 tafel = World::getInstance().getPeriode(); 54 tafel->AddElement(hydrogen); 41 hydrogen = World::getInstance().getPeriode()->FindElement(1); 42 CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen"); 55 43 56 44 // construct molecule (tetraeder of hydrogens) 57 45 TestMolecule = World::getInstance().createMolecule(); 58 Walker = World::getInstance().createAtom(); 46 CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule"); 47 Walker = World::getInstance().createAtom(); 48 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 59 49 Walker->type = hydrogen; 60 50 *Walker->node = Vector(1., 0., 1. ); 61 51 TestMolecule->AddAtom(Walker); 62 52 Walker = World::getInstance().createAtom(); 53 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 63 54 Walker->type = hydrogen; 64 55 *Walker->node = Vector(0., 1., 1. ); 65 56 TestMolecule->AddAtom(Walker); 66 57 Walker = World::getInstance().createAtom(); 58 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 67 59 Walker->type = hydrogen; 68 60 *Walker->node = Vector(1., 1., 0. ); 69 61 TestMolecule->AddAtom(Walker); 70 62 Walker = World::getInstance().createAtom(); 63 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 71 64 Walker->type = hydrogen; 72 65 *Walker->node = Vector(0., 0., 0. ); … … 74 67 75 68 // check that TestMolecule was correctly constructed 76 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 77 69 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 78 70 }; 79 71 … … 86 78 // are all cleaned when the world is destroyed 87 79 World::purgeInstance(); 88 MemoryUsageObserver::purgeInstance();89 80 logger::purgeInstance(); 90 81 }; 91 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 92 92 /** Unit Test of molecule::AddBond() 93 93 * … … 96 96 { 97 97 bond *Binder = NULL; 98 atom *atom1 = TestMolecule->start->next; 99 atom *atom2 = atom1->next; 100 CPPUNIT_ASSERT( atom1 != NULL ); 101 CPPUNIT_ASSERT( atom2 != NULL ); 102 103 // add bond 104 Binder = TestMolecule->AddBond(atom1, atom2, 1); 105 CPPUNIT_ASSERT( Binder != NULL ); 106 bond *TestBond = TestMolecule->first->next; 107 CPPUNIT_ASSERT_EQUAL ( TestBond, Binder ); 98 molecule::iterator iter = TestMolecule->begin(); 99 atom *atom1 = *iter; 100 iter++; 101 atom *atom2 = *iter; 102 CPPUNIT_ASSERT( atom1 != NULL ); 103 CPPUNIT_ASSERT( atom2 != NULL ); 104 105 // add bond 106 Binder = TestMolecule->AddBond(atom1, atom2, 1); 107 CPPUNIT_ASSERT( Binder != NULL ); 108 CPPUNIT_ASSERT_EQUAL ( true, TestMolecule->hasBondStructure() ); 108 109 109 110 // check that bond contains the two atoms … … 124 125 { 125 126 bond *Binder = NULL; 126 atom *atom1 = TestMolecule->start->next; 127 atom *atom2 = atom1->next; 127 molecule::iterator iter = TestMolecule->begin(); 128 atom *atom1 = *iter; 129 iter++; 130 atom *atom2 = *iter; 128 131 CPPUNIT_ASSERT( atom1 != NULL ); 129 132 CPPUNIT_ASSERT( atom2 != NULL ); … … 141 144 142 145 // check if removed from molecule 143 CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last);146 CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); 144 147 }; 145 148 … … 150 153 { 151 154 bond *Binder = NULL; 152 atom *atom1 = TestMolecule->start->next; 153 atom *atom2 = atom1->next; 154 atom *atom3 = atom2->next; 155 molecule::iterator iter = TestMolecule->begin(); 156 atom *atom1 = *iter; 157 iter++; 158 atom *atom2 = *iter; 159 iter++; 160 atom *atom3 = *iter; 155 161 CPPUNIT_ASSERT( atom1 != NULL ); 156 162 CPPUNIT_ASSERT( atom2 != NULL ); … … 179 185 180 186 // check if removed from molecule 181 CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, Binder);182 CPPUNIT_ASSERT_EQUAL( Binder->next, TestMolecule->last);187 CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() ); 188 CPPUNIT_ASSERT_EQUAL( (unsigned int)1, TestMolecule->CountBonds() ); 183 189 }; 184 190 … … 189 195 { 190 196 bond *Binder = NULL; 191 atom *atom1 = TestMolecule->start->next; 192 atom *atom2 = atom1->next; 197 molecule::iterator iter = TestMolecule->begin(); 198 atom *atom1 = *iter; 199 iter++; 200 atom *atom2 = *iter; 193 201 CPPUNIT_ASSERT( atom1 != NULL ); 194 202 CPPUNIT_ASSERT( atom2 != NULL ); … … 206 214 207 215 // check if removed from molecule 208 CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last);216 CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); 209 217 }; 210 218 … … 215 223 { 216 224 bond *Binder = NULL; 217 atom *atom1 = TestMolecule->start->next; 218 atom *atom2 = atom1->next; 225 molecule::iterator iter = TestMolecule->begin(); 226 atom *atom1 = *iter; 227 iter++; 228 atom *atom2 = *iter; 219 229 CPPUNIT_ASSERT( atom1 != NULL ); 220 230 CPPUNIT_ASSERT( atom2 != NULL ); … … 231 241 232 242 // check if removed from molecule 233 CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last);243 CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); 234 244 }; 235 245 … … 239 249 void ListOfBondsTest::DeleteAtomTest() 240 250 { 241 bond *Binder = NULL; 242 atom *atom1 = TestMolecule->start->next; 243 atom *atom2 = atom1->next; 244 CPPUNIT_ASSERT( atom1 != NULL ); 245 CPPUNIT_ASSERT( atom2 != NULL ); 246 247 // add bond 248 Binder = TestMolecule->AddBond(atom1, atom2, 1); 249 CPPUNIT_ASSERT( Binder != NULL ); 251 atom *atom1 = NULL; 252 atom *atom2 = NULL; 253 bond *Binder = NULL; 254 { 255 molecule::iterator iter = TestMolecule->begin(); 256 atom1 = *iter; 257 iter++; 258 atom2 = *iter; 259 } 260 CPPUNIT_ASSERT( atom1 != NULL ); 261 CPPUNIT_ASSERT( atom2 != NULL ); 262 263 // add bond 264 Binder = TestMolecule->AddBond(atom1, atom2, 1); 265 CPPUNIT_ASSERT( Binder != NULL ); 266 267 CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom1->ListOfBonds.size() ); 268 CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom2->ListOfBonds.size() ); 269 270 CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() ); 250 271 251 272 // remove atom2 … … 256 277 257 278 // check if removed from molecule 258 CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last);259 }; 279 CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); 280 }; -
src/unittests/listofbondsunittest.hpp
r992fd7 r257c77 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(); … … 41 43 42 44 molecule *TestMolecule; 43 element *hydrogen; 44 periodentafel *tafel; 45 const element *hydrogen; 45 46 }; 46 47 -
src/unittests/manipulateAtomsTest.cpp
r992fd7 r257c77 55 55 public: 56 56 countObserver() : 57 Observer("countObserver"), 57 58 count(0) 58 59 {} -
src/unittests/memoryallocatorunittest.cpp
r992fd7 r257c77 12 12 #include "memoryallocator.hpp" 13 13 #include "memoryallocatorunittest.hpp" 14 #include "memoryusageobserver.hpp" 14 15 #include "helpers.hpp" 15 16 #include "log.hpp" -
src/unittests/stackclassunittest.cpp
r992fd7 r257c77 37 37 Stack->ClearStack(); 38 38 delete(Stack); 39 MemoryUsageObserver::purgeInstance();40 39 logger::purgeInstance(); 41 40 }; -
src/unittests/tesselation_boundarytriangleunittest.cpp
r992fd7 r257c77 70 70 delete tesselpoints[i]; 71 71 } 72 MemoryUsageObserver::purgeInstance();73 72 logger::purgeInstance(); 74 73 errorLogger::purgeInstance(); -
src/unittests/tesselation_insideoutsideunittest.cpp
r992fd7 r257c77 134 134 } 135 135 Corners.clear(); 136 MemoryUsageObserver::purgeInstance();137 136 logger::purgeInstance(); 138 137 errorLogger::purgeInstance(); -
src/unittests/tesselationunittest.cpp
r992fd7 r257c77 106 106 } 107 107 Corners.clear(); 108 MemoryUsageObserver::purgeInstance();109 108 logger::purgeInstance(); 110 109 errorLogger::purgeInstance(); -
src/unittests/vectorunittest.cpp
r992fd7 r257c77 49 49 void VectorTest::tearDown() 50 50 { 51 MemoryUsageObserver::purgeInstance();52 51 logger::purgeInstance(); 53 52 errorLogger::purgeInstance(); -
src/vector.cpp
r992fd7 r257c77 5 5 */ 6 6 7 #include "Helpers/MemDebug.hpp" 7 8 8 9 #include "vector.hpp" … … 517 518 // truncate to [0,1] for each axis 518 519 for (int i=0;i<NDIM;i++) { 519 x[i] += 0.5; // set to center of box520 //x[i] += 0.5; // set to center of box 520 521 while (x[i] >= 1.) 521 522 x[i] -= 1.; -
src/vector_ops.cpp
r992fd7 r257c77 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "vector.hpp" -
src/verbose.cpp
r992fd7 r257c77 1 1 using namespace std; 2 3 #include "Helpers/MemDebug.hpp" 2 4 3 5 #include "info.hpp" -
tests/Makefile.am
r992fd7 r257c77 1 AUTOM4TE = autom4te 2 EXTRA_DIST = testsuite.at $(TESTSUITE) atlocal.in regression 3 TESTSUITE = $(srcdir)/testsuite 1 SUBDIRS = regression Tesselations 4 2 5 SUBDIRS = Tesselations6 7 check-local: atconfig atlocal package.m4 $(TESTSUITE)8 $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)9 10 installcheck-local: atconfig atlocal $(TESTSUITE)11 $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \12 $(TESTSUITEFLAGS)13 14 clean-local:15 test ! -f '$(TESTSUITE)' || \16 $(SHELL) '$(TESTSUITE)' --clean17 18 AUTOTEST = $(AUTOM4TE) --language=autotest19 $(TESTSUITE): $(srcdir)/testsuite.at20 $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at21 mv $@.tmp $@22 23 # The `:;' works around a Bash 3.2 bug when the output is not writeable.24 $(srcdir)/package.m4: $(top_srcdir)/configure.ac25 :;{ \26 echo '# Signature of the current package.' && \27 echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])' && \28 echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])' && \29 echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])' && \30 echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])' && \31 echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \32 } >'$(srcdir)/package.m4' -
tests/Tesselations/defs.in
r992fd7 r257c77 30 30 CLEANUP="$CLEANUP; rm -rf $testdir" 31 31 cp -r @srcdir@/$testdir/* $testdir/ 32 cd $testdir33 32 CLEANUP="rm -f stderr stdout diffstderr diffstdout; cd ..; $CLEANUP" 34 33 CLEANUP="rm -f *.conf*; rm -f NonConvexEnvelope*; rm -f ${testdir}.xyz; rm -f ${testdir}.dbond; $CLEANUP" … … 52 51 FILENAME="NonConvexEnvelope" 53 52 exitcode=0 54 cd $ RADIUS53 cd $testdir/$RADIUS 55 54 #echo "Current dir is `pwd`, calling $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME." 56 55 if [ -e $mol.dbond ]; then 57 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond -N $RADIUS$FILENAME 2>stderr >stdout || exitcode=$?56 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond -N 0 --sphere-radius $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$? 58 57 else 59 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS$FILENAME 2>stderr >stdout || exitcode=$?58 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N 0 --sphere-radius $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$? 60 59 fi 61 60 #echo "Molecuilder done with exitcode $exitcode." 62 61 #cat stderr 63 62 #cat stdout 64 diff ${FILENAME}.dat ../@srcdir@/$mol/$2/${FILENAME}-$mol.dat 2>diffstderr >diffstdout || exitcode=$? 63 grep -E "^[0-9]* [0-9]* [0-9]*$" ../../../../../molecuilder/tests/Tesselations/$mol/$2/${FILENAME}-$mol.dat | sort -n >reference-triangles.dat 64 grep -E "^[0-9]* [0-9]* [0-9]*$" ${FILENAME}.dat | sort -n >new-triangles.dat 65 diff reference-triangles.dat new-triangles.dat 2>diffstderr >diffstdout || exitcode=$? 65 66 #echo "Diff done with exitcode $exitcode." 66 67 #cat diffstderr 67 68 #cat diffstdout 68 cd .. 69 cd ../.. 69 70 test $exitcode = $expected_exitcode || exit 1 70 71 } -
tests/regression/Tesselation/1/post/NonConvexEnvelope.r3d
r992fd7 r257c77 3 3 # All atoms as spheres 4 4 2 5 1. 37419 -0.26503 -4.44089e-160.1 1. 1. 1.5 1.24926 -0.870237 -0.89 0.1 1. 1. 1. 6 6 2 7 0.12489 0.61837 -4.44089e-160.1 1. 1. 1.7 1.24926 -0.870237 0.89 0.1 1. 1. 1. 8 8 2 9 -1.12431 -0.26503 -4.44089e-160.1 1. 1. 1.9 2.13922 0.388414 0 0.1 1. 1. 1. 10 10 2 11 1.37419 -0.89433-0.89 0.1 1. 1. 1.11 -3.63639e-05 1.27176 -0.89 0.1 1. 1. 1. 12 12 2 13 1.37419 -0.894330.89 0.1 1. 1. 1.13 -3.63639e-05 1.27176 0.89 0.1 1. 1. 1. 14 14 2 15 2.26414 0.364321 -4.44089e-160.1 1. 1. 1.15 -2.13919 0.388414 0 0.1 1. 1. 1. 16 16 2 17 0.12489 1.24767 -0.89 0.1 1. 1. 1.17 -1.24924 -0.870237 -0.89 0.1 1. 1. 1. 18 18 2 19 0.12489 1.24767 0.89 0.1 1. 1. 1.19 -1.24924 -0.870237 0.89 0.1 1. 1. 1. 20 20 2 21 -2.01426 0.364321 -4.44089e-160.1 1. 1. 1.21 1.24926 -0.240937 0 0.1 1. 1. 1. 22 22 2 23 - 1.12431 -0.89433 -0.890.1 1. 1. 1.23 -3.63639e-05 0.642463 0 0.1 1. 1. 1. 24 24 2 25 -1. 12431 -0.89433 0.890.1 1. 1. 1.25 -1.24924 -0.240937 0 0.1 1. 1. 1. 26 26 # All tesselation triangles 27 27 8 … … 30 30 BACKFACE 0.3 0.3 1.0 0 0 31 31 1 32 1. 37419 -0.89433 -0.89 2.26414 0.364321 -4.44089e-16 0.12489 1.24767-0.89 1. 0. 0.32 1.24926 -0.870237 -0.89 2.13922 0.388414 0 -3.63639e-05 1.27176 -0.89 1. 0. 0. 33 33 1 34 1. 37419 -0.89433 -0.89 0.12489 1.24767 -0.89 -1.12431 -0.89433-0.89 1. 0. 0.34 1.24926 -0.870237 -0.89 -3.63639e-05 1.27176 -0.89 -1.24924 -0.870237 -0.89 1. 0. 0. 35 35 1 36 0.12489 1.24767 -0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433-0.89 1. 0. 0.36 -3.63639e-05 1.27176 -0.89 -2.13919 0.388414 0 -1.24924 -0.870237 -0.89 1. 0. 0. 37 37 1 38 2. 26414 0.364321 -4.44089e-16 0.12489 1.24767 -0.89 0.12489 1.247670.89 1. 0. 0.38 2.13922 0.388414 0 -3.63639e-05 1.27176 -0.89 -3.63639e-05 1.27176 0.89 1. 0. 0. 39 39 1 40 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-161. 0. 0.40 -3.63639e-05 1.27176 -0.89 -3.63639e-05 1.27176 0.89 -2.13919 0.388414 0 1. 0. 0. 41 41 1 42 1. 37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 0.12489 1.247670.89 1. 0. 0.42 1.24926 -0.870237 0.89 2.13922 0.388414 0 -3.63639e-05 1.27176 0.89 1. 0. 0. 43 43 1 44 1. 37419 -0.89433 0.89 0.12489 1.24767 0.89 -1.12431 -0.894330.89 1. 0. 0.44 1.24926 -0.870237 0.89 -3.63639e-05 1.27176 0.89 -1.24924 -0.870237 0.89 1. 0. 0. 45 45 1 46 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.894330.89 1. 0. 0.46 -3.63639e-05 1.27176 0.89 -2.13919 0.388414 0 -1.24924 -0.870237 0.89 1. 0. 0. 47 47 1 48 -2. 01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 -1.12431 -0.894330.89 1. 0. 0.48 -2.13919 0.388414 0 -1.24924 -0.870237 -0.89 -1.24924 -0.870237 0.89 1. 0. 0. 49 49 1 50 1. 37419 -0.89433 0.89 -1.12431 -0.89433 -0.89 -1.12431 -0.894330.89 1. 0. 0.50 1.24926 -0.870237 0.89 -1.24924 -0.870237 -0.89 -1.24924 -0.870237 0.89 1. 0. 0. 51 51 1 52 1. 37419 -0.89433 -0.89 1.37419 -0.89433 0.89 -1.12431 -0.89433-0.89 1. 0. 0.52 1.24926 -0.870237 -0.89 1.24926 -0.870237 0.89 -1.24924 -0.870237 -0.89 1. 0. 0. 53 53 1 54 1. 37419 -0.89433 -0.89 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-161. 0. 0.54 1.24926 -0.870237 -0.89 1.24926 -0.870237 0.89 2.13922 0.388414 0 1. 0. 0. 55 55 9 56 56 # terminating special property … … 59 59 25.0 0.6 -1.0 -1.0 -1.0 0.2 0 0 0 0 60 60 2 61 1. 67084 -0.47478 -8.88178e-16 5 1 0 061 1.54591 -0.450686 -4.44089e-16 5 1 0 0 62 62 9 63 63 terminating special property -
tests/regression/Tesselation/2/post/ConvexEnvelope.r3d
r992fd7 r257c77 3 3 # All atoms as spheres 4 4 2 5 1. 37419 -0.26503 -4.44089e-160.1 1. 1. 1.5 1.24926 -0.870237 -0.89 0.1 1. 1. 1. 6 6 2 7 0.12489 0.61837 -4.44089e-160.1 1. 1. 1.7 1.24926 -0.870237 0.89 0.1 1. 1. 1. 8 8 2 9 -1.12431 -0.26503 -4.44089e-160.1 1. 1. 1.9 2.13922 0.388414 0 0.1 1. 1. 1. 10 10 2 11 1.37419 -0.89433-0.89 0.1 1. 1. 1.11 -3.63639e-05 1.27176 -0.89 0.1 1. 1. 1. 12 12 2 13 1.37419 -0.894330.89 0.1 1. 1. 1.13 -3.63639e-05 1.27176 0.89 0.1 1. 1. 1. 14 14 2 15 2.26414 0.364321 -4.44089e-160.1 1. 1. 1.15 -2.13919 0.388414 0 0.1 1. 1. 1. 16 16 2 17 0.12489 1.24767 -0.89 0.1 1. 1. 1.17 -1.24924 -0.870237 -0.89 0.1 1. 1. 1. 18 18 2 19 0.12489 1.24767 0.89 0.1 1. 1. 1.19 -1.24924 -0.870237 0.89 0.1 1. 1. 1. 20 20 2 21 -2.01426 0.364321 -4.44089e-160.1 1. 1. 1.21 1.24926 -0.240937 0 0.1 1. 1. 1. 22 22 2 23 - 1.12431 -0.89433 -0.890.1 1. 1. 1.23 -3.63639e-05 0.642463 0 0.1 1. 1. 1. 24 24 2 25 -1. 12431 -0.89433 0.890.1 1. 1. 1.25 -1.24924 -0.240937 0 0.1 1. 1. 1. 26 26 # All tesselation triangles 27 27 8 … … 30 30 BACKFACE 0.3 0.3 1.0 0 0 31 31 1 32 1. 37419 -0.89433 -0.89 2.26414 0.364321 -4.44089e-16 0.12489 1.24767-0.89 1. 0. 0.32 1.24926 -0.870237 -0.89 2.13922 0.388414 0 -3.63639e-05 1.27176 -0.89 1. 0. 0. 33 33 1 34 1. 37419 -0.89433 -0.89 0.12489 1.24767 -0.89 -1.12431 -0.89433-0.89 1. 0. 0.34 1.24926 -0.870237 -0.89 -3.63639e-05 1.27176 -0.89 -1.24924 -0.870237 -0.89 1. 0. 0. 35 35 1 36 0.12489 1.24767 -0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433-0.89 1. 0. 0.36 -3.63639e-05 1.27176 -0.89 -2.13919 0.388414 0 -1.24924 -0.870237 -0.89 1. 0. 0. 37 37 1 38 2. 26414 0.364321 -4.44089e-16 0.12489 1.24767 -0.89 0.12489 1.247670.89 1. 0. 0.38 2.13922 0.388414 0 -3.63639e-05 1.27176 -0.89 -3.63639e-05 1.27176 0.89 1. 0. 0. 39 39 1 40 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-161. 0. 0.40 -3.63639e-05 1.27176 -0.89 -3.63639e-05 1.27176 0.89 -2.13919 0.388414 0 1. 0. 0. 41 41 1 42 1. 37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 0.12489 1.247670.89 1. 0. 0.42 1.24926 -0.870237 0.89 2.13922 0.388414 0 -3.63639e-05 1.27176 0.89 1. 0. 0. 43 43 1 44 1. 37419 -0.89433 0.89 0.12489 1.24767 0.89 -1.12431 -0.894330.89 1. 0. 0.44 1.24926 -0.870237 0.89 -3.63639e-05 1.27176 0.89 -1.24924 -0.870237 0.89 1. 0. 0. 45 45 1 46 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.894330.89 1. 0. 0.46 -3.63639e-05 1.27176 0.89 -2.13919 0.388414 0 -1.24924 -0.870237 0.89 1. 0. 0. 47 47 1 48 -2. 01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 -1.12431 -0.894330.89 1. 0. 0.48 -2.13919 0.388414 0 -1.24924 -0.870237 -0.89 -1.24924 -0.870237 0.89 1. 0. 0. 49 49 1 50 1. 37419 -0.89433 0.89 -1.12431 -0.89433 -0.89 -1.12431 -0.894330.89 1. 0. 0.50 1.24926 -0.870237 0.89 -1.24924 -0.870237 -0.89 -1.24924 -0.870237 0.89 1. 0. 0. 51 51 1 52 1. 37419 -0.89433 -0.89 1.37419 -0.89433 0.89 -1.12431 -0.89433-0.89 1. 0. 0.52 1.24926 -0.870237 -0.89 1.24926 -0.870237 0.89 -1.24924 -0.870237 -0.89 1. 0. 0. 53 53 1 54 1. 37419 -0.89433 -0.89 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-161. 0. 0.54 1.24926 -0.870237 -0.89 1.24926 -0.870237 0.89 2.13922 0.388414 0 1. 0. 0. 55 55 9 56 56 # terminating special property … … 59 59 25.0 0.6 -1.0 -1.0 -1.0 0.2 0 0 0 0 60 60 2 61 1. 67084 -0.47478 -8.88178e-16 5 1 0 061 1.54591 -0.450686 -4.44089e-16 5 1 0 0 62 62 9 63 63 terminating special property -
tests/regression/Tesselation/2/post/NonConvexEnvelope.r3d
r992fd7 r257c77 3 3 # All atoms as spheres 4 4 2 5 1. 37419 -0.26503 -4.44089e-160.1 1. 1. 1.5 1.24926 -0.870237 -0.89 0.1 1. 1. 1. 6 6 2 7 0.12489 0.61837 -4.44089e-160.1 1. 1. 1.7 1.24926 -0.870237 0.89 0.1 1. 1. 1. 8 8 2 9 -1.12431 -0.26503 -4.44089e-160.1 1. 1. 1.9 2.13922 0.388414 0 0.1 1. 1. 1. 10 10 2 11 1.37419 -0.89433-0.89 0.1 1. 1. 1.11 -3.63639e-05 1.27176 -0.89 0.1 1. 1. 1. 12 12 2 13 1.37419 -0.894330.89 0.1 1. 1. 1.13 -3.63639e-05 1.27176 0.89 0.1 1. 1. 1. 14 14 2 15 2.26414 0.364321 -4.44089e-160.1 1. 1. 1.15 -2.13919 0.388414 0 0.1 1. 1. 1. 16 16 2 17 0.12489 1.24767 -0.89 0.1 1. 1. 1.17 -1.24924 -0.870237 -0.89 0.1 1. 1. 1. 18 18 2 19 0.12489 1.24767 0.89 0.1 1. 1. 1.19 -1.24924 -0.870237 0.89 0.1 1. 1. 1. 20 20 2 21 -2.01426 0.364321 -4.44089e-160.1 1. 1. 1.21 1.24926 -0.240937 0 0.1 1. 1. 1. 22 22 2 23 - 1.12431 -0.89433 -0.890.1 1. 1. 1.23 -3.63639e-05 0.642463 0 0.1 1. 1. 1. 24 24 2 25 -1. 12431 -0.89433 0.890.1 1. 1. 1.25 -1.24924 -0.240937 0 0.1 1. 1. 1. 26 26 # All tesselation triangles 27 27 8 … … 30 30 BACKFACE 0.3 0.3 1.0 0 0 31 31 1 32 1. 37419 -0.89433 -0.89 2.26414 0.364321 -4.44089e-16 0.12489 1.24767-0.89 1. 0. 0.32 1.24926 -0.870237 -0.89 2.13922 0.388414 0 -3.63639e-05 1.27176 -0.89 1. 0. 0. 33 33 1 34 1. 37419 -0.89433 -0.89 0.12489 1.24767 -0.89 -1.12431 -0.89433-0.89 1. 0. 0.34 1.24926 -0.870237 -0.89 -3.63639e-05 1.27176 -0.89 -1.24924 -0.870237 -0.89 1. 0. 0. 35 35 1 36 0.12489 1.24767 -0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433-0.89 1. 0. 0.36 -3.63639e-05 1.27176 -0.89 -2.13919 0.388414 0 -1.24924 -0.870237 -0.89 1. 0. 0. 37 37 1 38 2. 26414 0.364321 -4.44089e-16 0.12489 1.24767 -0.89 0.12489 1.247670.89 1. 0. 0.38 2.13922 0.388414 0 -3.63639e-05 1.27176 -0.89 -3.63639e-05 1.27176 0.89 1. 0. 0. 39 39 1 40 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-161. 0. 0.40 -3.63639e-05 1.27176 -0.89 -3.63639e-05 1.27176 0.89 -2.13919 0.388414 0 1. 0. 0. 41 41 1 42 1. 37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 0.12489 1.247670.89 1. 0. 0.42 1.24926 -0.870237 0.89 2.13922 0.388414 0 -3.63639e-05 1.27176 0.89 1. 0. 0. 43 43 1 44 1. 37419 -0.89433 0.89 0.12489 1.24767 0.89 -1.12431 -0.894330.89 1. 0. 0.44 1.24926 -0.870237 0.89 -3.63639e-05 1.27176 0.89 -1.24924 -0.870237 0.89 1. 0. 0. 45 45 1 46 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.894330.89 1. 0. 0.46 -3.63639e-05 1.27176 0.89 -2.13919 0.388414 0 -1.24924 -0.870237 0.89 1. 0. 0. 47 47 1 48 -2. 01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 -1.12431 -0.894330.89 1. 0. 0.48 -2.13919 0.388414 0 -1.24924 -0.870237 -0.89 -1.24924 -0.870237 0.89 1. 0. 0. 49 49 1 50 1. 37419 -0.89433 0.89 -1.12431 -0.89433 -0.89 -1.12431 -0.894330.89 1. 0. 0.50 1.24926 -0.870237 0.89 -1.24924 -0.870237 -0.89 -1.24924 -0.870237 0.89 1. 0. 0. 51 51 1 52 1. 37419 -0.89433 -0.89 1.37419 -0.89433 0.89 -1.12431 -0.89433-0.89 1. 0. 0.52 1.24926 -0.870237 -0.89 1.24926 -0.870237 0.89 -1.24924 -0.870237 -0.89 1. 0. 0. 53 53 1 54 1. 37419 -0.89433 -0.89 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-161. 0. 0.54 1.24926 -0.870237 -0.89 1.24926 -0.870237 0.89 2.13922 0.388414 0 1. 0. 0. 55 55 9 56 56 # terminating special property … … 59 59 25.0 0.6 -1.0 -1.0 -1.0 0.2 0 0 0 0 60 60 2 61 1. 67084 -0.47478 -8.88178e-16 5 1 0 061 1.54591 -0.450686 -4.44089e-16 5 1 0 0 62 62 9 63 63 terminating special property -
tests/regression/Tesselation/3/post/NonConvexEnvelope.dat
r992fd7 r257c77 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="test", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 6.9077 1.1106 0.1214 15 4 0.3612 -3.628 1.323 1 6 5 0.4884 -3.5983 -0.4521 3 … … 46 45 -6.8554 1.8134 -0.9499 1 47 46 7.1391 2.0447 0.0264 0 47 6.9077 1.1106 0.1214 1 48 48 49 1 324450 1 32 35 51 1 34 35 52 2 3 32 3553 1 7 23 3554 8 17 35 55 8 10 17 56 3 8 10 57 3 8 35 58 3 4 35 59 4 29 35 60 2 9 34 3561 2 3 4 62 2 4 29 63 2 15 29 64 1 5 28 2965 2 8 29 3466 2 7 15 67 7 14 15 68 1 4 15 2869 1 4 25 2870 2 5 28 3771 2 8 34 3772 1 34 37 73 1 374474 2 5 26 3775 2 5 26 2776 2 6 27 3377 2 6 33 4478 2 6 37 4479 1 4 25 2780 1 4 27 3081 6 14 30 82 6 24 30 83 2 4 30 3684 30 36 39 85 2 7 30 3986 2 7 30 3987 1 6 27 3088 1 6 18 3089 1 6 18 2790 1 8 27 3391 1 8 23 3392 6 7 24 93 6 7 14 94 7 11 24 95 1 1 20 2496 20 24 41 97 2 4 36 4198 3 6 41 4299 1 1 20 22100 5 11 22 101 5 7 11 102 2 5 7 103 3 6 38 39104 3 6 38 42105 1 8 30 31106 30 31 39 107 3 1 39 40108 9 18 31 109 9 17 18 110 1 7 18 23111 9 19 31 112 9 13 19 113 1 3 19 31114 1 3 21 31115 2 1 31 43116 3 1 40 43117 9 12 13 118 9 10 12 119 9 10 17 120 1 2 13 21121 1 2 21 22122 5 12 22 123 3 5 12 124 2 3 5 125 3 10 12 126 20 21 22 127 20 21 41 128 2 1 41 43129 4 1 42 43130 2 3 32 33131 3 2 33 44132 40 42 43 133 3 8 40 42134 3 8 39 4049 31 43 44 50 31 34 44 51 33 34 44 52 22 31 34 53 16 22 34 54 7 16 34 55 7 9 16 56 2 7 9 57 2 7 34 58 2 3 34 59 3 28 34 60 28 33 34 61 1 2 3 62 1 3 28 63 1 14 28 64 14 27 28 65 27 28 33 66 1 6 14 67 6 13 14 68 13 14 27 69 13 24 27 70 24 27 36 71 27 33 36 72 33 36 44 73 36 43 44 74 24 25 36 75 24 25 26 76 25 26 32 77 25 32 43 78 25 36 43 79 13 24 26 80 13 26 29 81 5 13 29 82 5 23 29 83 23 29 35 84 29 35 38 85 26 29 38 86 26 29 38 87 15 26 29 88 15 17 29 89 15 17 26 90 17 26 32 91 17 22 32 92 5 6 23 93 5 6 13 94 6 10 23 95 10 19 23 96 19 23 40 97 23 35 40 98 35 40 41 99 10 19 21 100 4 10 21 101 4 6 10 102 1 4 6 103 35 37 38 104 35 37 41 105 17 29 30 106 29 30 38 107 30 38 39 108 8 17 30 109 8 16 17 110 16 17 22 111 8 18 30 112 8 12 18 113 12 18 30 114 12 20 30 115 20 30 42 116 30 39 42 117 8 11 12 118 8 9 11 119 8 9 16 120 11 12 20 121 11 20 21 122 4 11 21 123 2 4 11 124 1 2 4 125 2 9 11 126 19 20 21 127 19 20 40 128 20 40 42 129 40 41 42 130 22 31 32 131 31 32 43 132 39 41 42 133 37 39 41 134 37 38 39 -
tests/regression/Tesselation/3/post/NonConvexEnvelope.r3d
r992fd7 r257c77 3 3 # All atoms as spheres 4 4 2 5 0. 952534 -3.05798 0.4201710.1 1. 1. 1.6 2 7 -0.139866 -1.98848 0.3597710.1 1. 1. 1.8 2 9 0.0788342 -1.07508 -0.8752290.1 1. 1. 1.10 2 11 - 1.49147 -2.63828 0.07807120.1 1. 1. 1.12 2 13 - 0.0588658 -1.09478 1.583470.1 1. 1. 1.14 2 15 1.53473 -0.644479 -0.868129 0.1 1. 1. 1.16 2 17 -0.3 33166 -2.00128 -2.024430.1 1. 1. 1.18 2 19 -2.62147 -1.78218 0.6535710.1 1. 1. 1.20 2 21 - 1.60077 -2.70398 -1.465630.1 1. 1. 1.22 2 23 1.37913 -0.560579 1.656070.1 1. 1. 1.24 2 25 1.75933 0.205421 0.3953710.1 1. 1. 1.26 2 27 1.79893 0.246421 -2.088830.1 1. 1. 1.28 2 29 -2. 64037 -0.423279 -0.04912880.1 1. 1. 1.30 2 31 -3.96017 -2.48928 0.4326710.1 1. 1. 1.32 2 33 3.23013 0.593821 0.4844710.1 1. 1. 1.34 2 35 3.14803 0.889821 -1.96833 0.1 1. 1. 1.36 2 37 -3.79507 0.418021 0.498371 0.1 1. 1. 1.38 2 39 3.36023 1.76962 1.454870.1 1. 1. 1.40 2 41 3.78273 1.01752 -0.8494290.1 1. 1. 1.42 2 43 4.07093 -0.563879 1.017670.1 1. 1. 1.44 2 45 - 3.81397 1.77692 -0.2043290.1 1. 1. 1.46 2 47 5.17783 1.62112 -0.8428290.1 1. 1. 1.48 2 49 5.49863 -0.464179 0.4820710.1 1. 1. 1.50 2 51 -4.96867 2.61822 0.343171 0.1 1. 1. 1.52 2 53 5.93083 0.990421 0.3373710.1 1. 1. 1.54 2 55 - 4.98757 3.97722 -0.359529 0.1 1. 1. 1.56 2 57 -6.29237 1.89422 0.08907120.1 1. 1. 1.58 2 59 7.33693 1.04442 0.08867120.1 1. 1. 1.60 2 61 0.790434 -3.69418 1.290270.1 1. 1. 1.62 2 63 0.917634 -3.66448 -0.484829 0.1 1. 1. 1.64 2 65 1.92773 -2.57738 0.4980710.1 1. 1. 1.66 2 67 - 0.574266 -0.203779 -0.8247290.1 1. 1. 1.68 2 69 - 1.52417 -3.64138 0.503471 0.1 1. 1. 1.70 2 71 -0.759066 -0.265179 1.484870.1 1. 1. 1.72 2 73 -0.287266 -1.67078 2.48017 0.1 1. 1. 1.74 2 75 2.19193 -1.51408 -0.867629 0.1 1. 1. 1.76 2 77 -0.573766 -1.42458 -2.917530.1 1. 1. 1.78 2 79 0.450934 -2.72908 -2.233530.1 1. 1. 1.80 2 81 -2.45927 -1.63678 1.721570.1 1. 1. 1.82 2 83 - 1.62867 -3.74268 -1.794930.1 1. 1. 1.84 2 85 - 2.49667 -2.18078 -1.799930.1 1. 1. 1.86 2 87 1.46453 0.112321 2.509270.1 1. 1. 1.88 2 89 2.06173 -1.39848 1.797870.1 1. 1. 1.90 2 91 1.15633 1.11082 0.3266710.1 1. 1. 1.92 2 93 1.76663 -0.360379 -2.993730.1 1. 1. 1.94 2 95 1.03283 1.01972 -2.145330.1 1. 1. 1.96 2 97 -1.69727 0.0925205 0.1319710.1 1. 1. 1.98 2 99 - 2.77417 -0.570279 -1.12083 0.1 1. 1. 1.100 2 101 -4.75167 -1.93408 0.9359710.1 1. 1. 1.102 2 103 - 4.17327 -2.53828 -0.6352290.1 1. 1. 1.104 2 105 - 3.90927 -3.49908 0.8397710.1 1. 1. 1.106 2 107 3.62023 1.25552 -2.868130.1 1. 1. 1.108 2 109 - 4.73807 -0.0977795 0.317371 0.1 1. 1. 1.110 2 111 - 3.66127 0.565021 1.570070.1 1. 1. 1.112 2 113 3.24233 1.41142 2.477570.1 1. 1. 1.114 2 115 4.34293 2.22742 1.341170.1 1. 1. 1.116 2 117 2.58823 2.50762 1.237070.1 1. 1. 1.118 2 119 4.08983 -0.525479 2.106870.1 1. 1. 1.120 2 121 3.62993 -1.50808 0.6983710.1 1. 1. 1.122 2 123 - 2.87097 2.29272 -0.02332880.1 1. 1. 1.124 2 125 -3.94777 1.63002 -1.27603 0.1 1. 1. 1.126 2 127 5.68853 1.38852 -1.777230.1 1. 1. 1.128 2 129 5.11553 2.70122 -0.7102290.1 1. 1. 1.130 2 131 6.17523 -0.969279 1.171270.1 1. 1. 1.132 2 133 5.55043 -0.952879 -0.4909290.1 1. 1. 1.134 2 135 -4.83487 2.76522 1.414870.1 1. 1. 1.136 2 137 5.70193 1.54062 1.25007 0.1 1. 1. 1.138 2 139 -5.81017 4.57652 0.03047120.1 1. 1. 1.140 2 141 -4.04457 4.49292 -0.1785290.1 1. 1. 1.142 2 143 - 5.12137 3.83022 -1.43123 0.1 1. 1. 1.144 2 145 -6.27887 0.926121 0.5896710.1 1. 1. 1.146 2 147 - 7.11497 2.49352 0.4790710.1 1. 1. 1.148 2 149 -6. 42617 1.74722 -0.9826290.1 1. 1. 1.150 2 151 7. 56833 1.97852 -0.006328770.1 1. 1. 1.5 0.777562 -3.65286 1.28459 0.1 1. 1. 1. 6 2 7 0.904762 -3.62316 -0.490507 0.1 1. 1. 1. 8 2 9 1.91486 -2.53606 0.492393 0.1 1. 1. 1. 10 2 11 -0.587138 -0.162455 -0.830407 0.1 1. 1. 1. 12 2 13 -1.53704 -3.60006 0.497793 0.1 1. 1. 1. 14 2 15 -0.771938 -0.223855 1.47919 0.1 1. 1. 1. 16 2 17 -0.300138 -1.62946 2.47449 0.1 1. 1. 1. 18 2 19 2.17906 -1.47276 -0.873307 0.1 1. 1. 1. 20 2 21 -0.586638 -1.38326 -2.92321 0.1 1. 1. 1. 22 2 23 0.438062 -2.68776 -2.23921 0.1 1. 1. 1. 24 2 25 -2.47214 -1.59546 1.71589 0.1 1. 1. 1. 26 2 27 -1.64154 -3.70136 -1.80061 0.1 1. 1. 1. 28 2 29 -2.50954 -2.13946 -1.80561 0.1 1. 1. 1. 30 2 31 1.45166 0.153645 2.50359 0.1 1. 1. 1. 32 2 33 2.04886 -1.35716 1.79219 0.1 1. 1. 1. 34 2 35 1.14346 1.15214 0.320993 0.1 1. 1. 1. 36 2 37 1.75376 -0.319055 -2.99941 0.1 1. 1. 1. 38 2 39 1.01996 1.06104 -2.15101 0.1 1. 1. 1. 40 2 41 -1.71014 0.133845 0.126293 0.1 1. 1. 1. 42 2 43 -2.78704 -0.528955 -1.12651 0.1 1. 1. 1. 44 2 45 -4.76454 -1.89276 0.930293 0.1 1. 1. 1. 46 2 47 -4.18614 -2.49696 -0.640907 0.1 1. 1. 1. 48 2 49 -3.92214 -3.45776 0.834093 0.1 1. 1. 1. 50 2 51 3.60736 1.29684 -2.87381 0.1 1. 1. 1. 52 2 53 -4.75094 -0.0564554 0.311693 0.1 1. 1. 1. 54 2 55 -3.67414 0.606345 1.56439 0.1 1. 1. 1. 56 2 57 3.22946 1.45274 2.47189 0.1 1. 1. 1. 58 2 59 4.33006 2.26874 1.33549 0.1 1. 1. 1. 60 2 61 2.57536 2.54894 1.23139 0.1 1. 1. 1. 62 2 63 4.07696 -0.484155 2.10119 0.1 1. 1. 1. 64 2 65 3.61706 -1.46676 0.692693 0.1 1. 1. 1. 66 2 67 -2.88384 2.33404 -0.0290068 0.1 1. 1. 1. 68 2 69 -3.96064 1.67134 -1.28171 0.1 1. 1. 1. 70 2 71 5.67566 1.42984 -1.78291 0.1 1. 1. 1. 72 2 73 5.10266 2.74254 -0.715907 0.1 1. 1. 1. 74 2 75 6.16236 -0.927955 1.16559 0.1 1. 1. 1. 76 2 77 5.53756 -0.911555 -0.496607 0.1 1. 1. 1. 78 2 79 -4.84774 2.80654 1.40919 0.1 1. 1. 1. 80 2 81 5.68906 1.58194 1.24439 0.1 1. 1. 1. 82 2 83 -5.82304 4.61784 0.0247932 0.1 1. 1. 1. 84 2 85 -4.05744 4.53424 -0.184207 0.1 1. 1. 1. 86 2 87 -5.13424 3.87154 -1.43691 0.1 1. 1. 1. 88 2 89 -6.29174 0.967445 0.583993 0.1 1. 1. 1. 90 2 91 -7.12784 2.53484 0.473393 0.1 1. 1. 1. 92 2 93 -6.43904 1.78854 -0.988307 0.1 1. 1. 1. 94 2 95 7.55546 2.01984 -0.0120068 0.1 1. 1. 1. 96 2 97 0.939662 -3.01666 0.414493 0.1 1. 1. 1. 98 2 99 -0.152738 -1.94716 0.354093 0.1 1. 1. 1. 100 2 101 0.0659622 -1.03376 -0.880907 0.1 1. 1. 1. 102 2 103 -1.50434 -2.59696 0.0723932 0.1 1. 1. 1. 104 2 105 -0.0717378 -1.05346 1.57779 0.1 1. 1. 1. 106 2 107 1.52186 -0.603155 -0.873807 0.1 1. 1. 1. 108 2 109 -0.346038 -1.95996 -2.03011 0.1 1. 1. 1. 110 2 111 -2.63434 -1.74086 0.647893 0.1 1. 1. 1. 112 2 113 -1.61364 -2.66266 -1.47131 0.1 1. 1. 1. 114 2 115 1.36626 -0.519255 1.65039 0.1 1. 1. 1. 116 2 117 1.74646 0.246745 0.389693 0.1 1. 1. 1. 118 2 119 1.78606 0.287745 -2.09451 0.1 1. 1. 1. 120 2 121 -2.65324 -0.381955 -0.0548068 0.1 1. 1. 1. 122 2 123 -3.97304 -2.44796 0.426993 0.1 1. 1. 1. 124 2 125 3.21726 0.635145 0.478793 0.1 1. 1. 1. 126 2 127 3.13516 0.931145 -1.97401 0.1 1. 1. 1. 128 2 129 -3.80794 0.459345 0.492693 0.1 1. 1. 1. 130 2 131 3.34736 1.81094 1.44919 0.1 1. 1. 1. 132 2 133 3.76986 1.05884 -0.855107 0.1 1. 1. 1. 134 2 135 4.05806 -0.522555 1.01199 0.1 1. 1. 1. 136 2 137 -3.82684 1.81824 -0.210007 0.1 1. 1. 1. 138 2 139 5.16496 1.66244 -0.848507 0.1 1. 1. 1. 140 2 141 5.48576 -0.422855 0.476393 0.1 1. 1. 1. 142 2 143 -4.98154 2.65954 0.337493 0.1 1. 1. 1. 144 2 145 5.91796 1.03174 0.331693 0.1 1. 1. 1. 146 2 147 -5.00044 4.01854 -0.365207 0.1 1. 1. 1. 148 2 149 -6.30524 1.93554 0.0833932 0.1 1. 1. 1. 150 2 151 7.32406 1.08574 0.0829932 0.1 1. 1. 1. 152 152 # All tesselation triangles 153 153 8 … … 156 156 BACKFACE 0.3 0.3 1.0 0 0 157 157 1 158 7.33693 1.04442 0.0886712 5.68853 1.38852 -1.77723 7.56833 1.97852 -0.006328771. 0. 0.159 1 160 7.33693 1.04442 0.0886712 5.68853 1.38852 -1.77723 5.55043 -0.952879 -0.4909291. 0. 0.161 1 162 7.33693 1.04442 0.0886712 6.17523 -0.969279 1.17127 5.55043 -0.952879 -0.4909291. 0. 0.163 1 164 3.6 2023 1.25552 -2.86813 5.68853 1.38852 -1.77723 5.55043 -0.952879 -0.4909291. 0. 0.165 1 166 1.7 6663 -0.360379 -2.99373 3.62023 1.25552 -2.86813 5.55043 -0.952879 -0.4909291. 0. 0.167 1 168 2.1 9193 -1.51408 -0.867629 1.76663 -0.360379 -2.99373 5.55043 -0.952879 -0.4909291. 0. 0.169 1 170 2.1 9193 -1.51408 -0.867629 0.450934 -2.72908 -2.23353 1.76663 -0.360379 -2.993731. 0. 0.171 1 172 0.9 17634 -3.66448 -0.484829 2.19193 -1.51408 -0.867629 0.450934 -2.72908 -2.233531. 0. 0.173 1 174 0.9 17634 -3.66448 -0.484829 2.19193 -1.51408 -0.867629 5.55043 -0.952879 -0.4909291. 0. 0.175 1 176 0.9 17634 -3.66448 -0.484829 1.92773 -2.57738 0.498071 5.55043 -0.952879 -0.4909291. 0. 0.177 1 178 1.9 2773 -2.57738 0.498071 3.62993 -1.50808 0.698371 5.55043 -0.952879 -0.4909291. 0. 0.179 1 180 3.6 2993 -1.50808 0.698371 6.17523 -0.969279 1.17127 5.55043 -0.952879 -0.4909291. 0. 0.181 1 182 0.7 90434 -3.69418 1.29027 0.917634 -3.66448 -0.484829 1.92773 -2.57738 0.4980711. 0. 0.183 1 184 0.7 90434 -3.69418 1.29027 1.92773 -2.57738 0.498071 3.62993 -1.50808 0.6983711. 0. 0.185 1 186 0.7 90434 -3.69418 1.29027 2.06173 -1.39848 1.79787 3.62993 -1.50808 0.6983711. 0. 0.187 1 188 2.0 6173 -1.39848 1.79787 4.08983 -0.525479 2.10687 3.62993 -1.50808 0.6983711. 0. 0.189 1 190 4.0 8983 -0.525479 2.10687 3.62993 -1.50808 0.698371 6.17523 -0.969279 1.171271. 0. 0.191 1 192 0.7 90434 -3.69418 1.29027 -0.287266 -1.67078 2.48017 2.06173 -1.39848 1.797871. 0. 0.193 1 194 -0. 287266 -1.67078 2.48017 1.46453 0.112321 2.50927 2.06173 -1.39848 1.797871. 0. 0.195 1 196 1.4 6453 0.112321 2.50927 2.06173 -1.39848 1.79787 4.08983 -0.525479 2.106871. 0. 0.197 1 198 1.4 6453 0.112321 2.50927 3.24233 1.41142 2.47757 4.08983 -0.525479 2.106871. 0. 0.199 1 200 3.2 4233 1.41142 2.47757 4.08983 -0.525479 2.10687 5.70193 1.54062 1.250071. 0. 0.201 1 202 4.0 8983 -0.525479 2.10687 6.17523 -0.969279 1.17127 5.70193 1.54062 1.250071. 0. 0.203 1 204 7.33693 1.04442 0.0886712 6.17523 -0.969279 1.17127 5.70193 1.54062 1.250071. 0. 0.205 1 206 7.33693 1.04442 0.0886712 5.70193 1.54062 1.25007 7.56833 1.97852 -0.006328771. 0. 0.207 1 208 3.2 4233 1.41142 2.47757 4.34293 2.22742 1.34117 5.70193 1.54062 1.250071. 0. 0.209 1 210 3.2 4233 1.41142 2.47757 4.34293 2.22742 1.34117 2.58823 2.50762 1.237071. 0. 0.211 1 212 4.3 4293 2.22742 1.34117 2.58823 2.50762 1.23707 5.11553 2.70122 -0.7102291. 0. 0.213 1 214 4.3 4293 2.22742 1.34117 5.11553 2.70122 -0.710229 7.56833 1.97852 -0.006328771. 0. 0.215 1 216 4.3 4293 2.22742 1.34117 5.70193 1.54062 1.25007 7.56833 1.97852 -0.006328771. 0. 0.217 1 218 1.4 6453 0.112321 2.50927 3.24233 1.41142 2.47757 2.58823 2.50762 1.237071. 0. 0.219 1 220 1.4 6453 0.112321 2.50927 2.58823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 1. 0. 0.221 1 222 -0.7 59066 -0.265179 1.48487 1.46453 0.112321 2.50927 -2.87097 2.29272 -0.0233288 1. 0. 0.223 1 224 -0.7 59066 -0.265179 1.48487 -3.66127 0.565021 1.57007 -2.87097 2.29272 -0.0233288 1. 0. 0.225 1 226 -3.6 6127 0.565021 1.57007 -2.87097 2.29272 -0.0233288 -4.83487 2.76522 1.414871. 0. 0.227 1 228 -2.8 7097 2.29272 -0.0233288 -4.83487 2.76522 1.41487 -4.04457 4.49292 -0.1785291. 0. 0.229 1 230 2.5 8823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 -4.04457 4.49292 -0.1785291. 0. 0.231 1 232 2.5 8823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 -4.04457 4.49292 -0.1785291. 0. 0.233 1 234 1.1 5633 1.11082 0.326671 2.58823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 1. 0. 0.235 1 236 1.1 5633 1.11082 0.326671 1.03283 1.01972 -2.14533 -2.87097 2.29272 -0.0233288 1. 0. 0.237 1 238 1.1 5633 1.11082 0.326671 1.03283 1.01972 -2.14533 2.58823 2.50762 1.237071. 0. 0.239 1 240 1.0 3283 1.01972 -2.14533 2.58823 2.50762 1.23707 5.11553 2.70122 -0.7102291. 0. 0.241 1 242 1.0 3283 1.01972 -2.14533 3.62023 1.25552 -2.86813 5.11553 2.70122 -0.7102291. 0. 0.243 1 244 -0.7 59066 -0.265179 1.48487 -0.287266 -1.67078 2.48017 -3.66127 0.565021 1.570071. 0. 0.245 1 246 -0.7 59066 -0.265179 1.48487 -0.287266 -1.67078 2.48017 1.46453 0.112321 2.509271. 0. 0.247 1 248 -0. 287266 -1.67078 2.48017 -2.45927 -1.63678 1.72157 -3.66127 0.565021 1.570071. 0. 0.249 1 250 -2.4 5927 -1.63678 1.72157 -4.75167 -1.93408 0.935971 -3.66127 0.565021 1.570071. 0. 0.251 1 252 -4.7 5167 -1.93408 0.935971 -3.66127 0.565021 1.57007 -6.27887 0.926121 0.5896711. 0. 0.253 1 254 -3.6 6127 0.565021 1.57007 -4.83487 2.76522 1.41487 -6.27887 0.926121 0.5896711. 0. 0.255 1 256 -4.8 3487 2.76522 1.41487 -6.27887 0.926121 0.589671 -7.11497 2.49352 0.4790711. 0. 0.257 1 258 -2.4 5927 -1.63678 1.72157 -4.75167 -1.93408 0.935971 -3.90927 -3.49908 0.8397711. 0. 0.259 1 260 -1.5 2417 -3.64138 0.503471 -2.45927 -1.63678 1.72157 -3.90927 -3.49908 0.8397711. 0. 0.261 1 262 -1.5 2417 -3.64138 0.503471 -0.287266 -1.67078 2.48017 -2.45927 -1.63678 1.721571. 0. 0.263 1 264 0.7 90434 -3.69418 1.29027 -1.52417 -3.64138 0.503471 -0.287266 -1.67078 2.480171. 0. 0.265 1 266 -4.8 3487 2.76522 1.41487 -5.81017 4.57652 0.0304712 -4.04457 4.49292 -0.1785291. 0. 0.267 1 268 -4.8 3487 2.76522 1.41487 -5.81017 4.57652 0.0304712 -7.11497 2.49352 0.4790711. 0. 0.269 1 270 1.0 3283 1.01972 -2.14533 -2.87097 2.29272 -0.0233288 -3.94777 1.63002 -1.276031. 0. 0.271 1 272 -2.8 7097 2.29272 -0.0233288 -3.94777 1.63002 -1.27603 -4.04457 4.49292 -0.1785291. 0. 0.273 1 274 -3.9 4777 1.63002 -1.27603 -4.04457 4.49292 -0.178529 -5.12137 3.83022 -1.431231. 0. 0.275 1 276 -0.5 73766 -1.42458 -2.91753 1.03283 1.01972 -2.14533 -3.94777 1.63002 -1.276031. 0. 0.277 1 278 -0.5 73766 -1.42458 -2.91753 1.76663 -0.360379 -2.99373 1.03283 1.01972 -2.145331. 0. 0.279 1 280 1.7 6663 -0.360379 -2.99373 1.03283 1.01972 -2.14533 3.62023 1.25552 -2.868131. 0. 0.281 1 282 -0.5 73766 -1.42458 -2.91753 -2.77417 -0.570279 -1.12083 -3.94777 1.63002 -1.276031. 0. 0.283 1 284 -0.5 73766 -1.42458 -2.91753 -2.49667 -2.18078 -1.79993 -2.77417 -0.570279 -1.120831. 0. 0.285 1 286 -2. 49667 -2.18078 -1.79993 -2.77417 -0.570279 -1.12083 -3.94777 1.63002 -1.276031. 0. 0.287 1 288 -2. 49667 -2.18078 -1.79993 -4.17327 -2.53828 -0.635229 -3.94777 1.63002 -1.276031. 0. 0.289 1 290 -4.1 7327 -2.53828 -0.635229 -3.94777 1.63002 -1.27603 -6.42617 1.74722 -0.9826291. 0. 0.291 1 292 -3.9 4777 1.63002 -1.27603 -5.12137 3.83022 -1.43123 -6.42617 1.74722 -0.9826291. 0. 0.293 1 294 -0.5 73766 -1.42458 -2.91753 -1.62867 -3.74268 -1.79493 -2.49667 -2.18078 -1.799931. 0. 0.295 1 296 -0.5 73766 -1.42458 -2.91753 0.450934 -2.72908 -2.23353 -1.62867 -3.74268 -1.794931. 0. 0.297 1 298 -0.5 73766 -1.42458 -2.91753 0.450934 -2.72908 -2.23353 1.76663 -0.360379 -2.993731. 0. 0.299 1 300 -1.6 2867 -3.74268 -1.79493 -2.49667 -2.18078 -1.79993 -4.17327 -2.53828 -0.6352291. 0. 0.301 1 302 -1.6 2867 -3.74268 -1.79493 -4.17327 -2.53828 -0.635229 -3.90927 -3.49908 0.8397711. 0. 0.303 1 304 -1.5 2417 -3.64138 0.503471 -1.62867 -3.74268 -1.79493 -3.90927 -3.49908 0.8397711. 0. 0.305 1 306 0.9 17634 -3.66448 -0.484829 -1.52417 -3.64138 0.503471 -1.62867 -3.74268 -1.794931. 0. 0.307 1 308 0.7 90434 -3.69418 1.29027 0.917634 -3.66448 -0.484829 -1.52417 -3.64138 0.5034711. 0. 0.309 1 310 0.9 17634 -3.66448 -0.484829 0.450934 -2.72908 -2.23353 -1.62867 -3.74268 -1.794931. 0. 0.311 1 312 -4.7 5167 -1.93408 0.935971 -4.17327 -2.53828 -0.635229 -3.90927 -3.49908 0.8397711. 0. 0.313 1 314 -4.7 5167 -1.93408 0.935971 -4.17327 -2.53828 -0.635229 -6.27887 0.926121 0.5896711. 0. 0.315 1 316 -4.1 7327 -2.53828 -0.635229 -6.27887 0.926121 0.589671 -6.42617 1.74722 -0.9826291. 0. 0.317 1 318 -6.2 7887 0.926121 0.589671 -7.11497 2.49352 0.479071 -6.42617 1.74722 -0.9826291. 0. 0.319 1 320 3.6 2023 1.25552 -2.86813 5.68853 1.38852 -1.77723 5.11553 2.70122 -0.7102291. 0. 0.321 1 322 5.6 8853 1.38852 -1.77723 5.11553 2.70122 -0.710229 7.56833 1.97852 -0.006328771. 0. 0.323 1 324 -5.1 2137 3.83022 -1.43123 -7.11497 2.49352 0.479071 -6.42617 1.74722 -0.9826291. 0. 0.325 1 326 -5.8 1017 4.57652 0.0304712 -5.12137 3.83022 -1.43123 -7.11497 2.49352 0.4790711. 0. 0.327 1 328 -5.8 1017 4.57652 0.0304712 -4.04457 4.49292 -0.178529 -5.12137 3.83022 -1.431231. 0. 0.158 5.67566 1.42984 -1.78291 7.55546 2.01984 -0.0120068 7.32406 1.08574 0.0829932 1. 0. 0. 159 1 160 5.67566 1.42984 -1.78291 5.53756 -0.911555 -0.496607 7.32406 1.08574 0.0829932 1. 0. 0. 161 1 162 6.16236 -0.927955 1.16559 5.53756 -0.911555 -0.496607 7.32406 1.08574 0.0829932 1. 0. 0. 163 1 164 3.60736 1.29684 -2.87381 5.67566 1.42984 -1.78291 5.53756 -0.911555 -0.496607 1. 0. 0. 165 1 166 1.75376 -0.319055 -2.99941 3.60736 1.29684 -2.87381 5.53756 -0.911555 -0.496607 1. 0. 0. 167 1 168 2.17906 -1.47276 -0.873307 1.75376 -0.319055 -2.99941 5.53756 -0.911555 -0.496607 1. 0. 0. 169 1 170 2.17906 -1.47276 -0.873307 0.438062 -2.68776 -2.23921 1.75376 -0.319055 -2.99941 1. 0. 0. 171 1 172 0.904762 -3.62316 -0.490507 2.17906 -1.47276 -0.873307 0.438062 -2.68776 -2.23921 1. 0. 0. 173 1 174 0.904762 -3.62316 -0.490507 2.17906 -1.47276 -0.873307 5.53756 -0.911555 -0.496607 1. 0. 0. 175 1 176 0.904762 -3.62316 -0.490507 1.91486 -2.53606 0.492393 5.53756 -0.911555 -0.496607 1. 0. 0. 177 1 178 1.91486 -2.53606 0.492393 3.61706 -1.46676 0.692693 5.53756 -0.911555 -0.496607 1. 0. 0. 179 1 180 3.61706 -1.46676 0.692693 6.16236 -0.927955 1.16559 5.53756 -0.911555 -0.496607 1. 0. 0. 181 1 182 0.777562 -3.65286 1.28459 0.904762 -3.62316 -0.490507 1.91486 -2.53606 0.492393 1. 0. 0. 183 1 184 0.777562 -3.65286 1.28459 1.91486 -2.53606 0.492393 3.61706 -1.46676 0.692693 1. 0. 0. 185 1 186 0.777562 -3.65286 1.28459 2.04886 -1.35716 1.79219 3.61706 -1.46676 0.692693 1. 0. 0. 187 1 188 2.04886 -1.35716 1.79219 4.07696 -0.484155 2.10119 3.61706 -1.46676 0.692693 1. 0. 0. 189 1 190 4.07696 -0.484155 2.10119 3.61706 -1.46676 0.692693 6.16236 -0.927955 1.16559 1. 0. 0. 191 1 192 0.777562 -3.65286 1.28459 -0.300138 -1.62946 2.47449 2.04886 -1.35716 1.79219 1. 0. 0. 193 1 194 -0.300138 -1.62946 2.47449 1.45166 0.153645 2.50359 2.04886 -1.35716 1.79219 1. 0. 0. 195 1 196 1.45166 0.153645 2.50359 2.04886 -1.35716 1.79219 4.07696 -0.484155 2.10119 1. 0. 0. 197 1 198 1.45166 0.153645 2.50359 3.22946 1.45274 2.47189 4.07696 -0.484155 2.10119 1. 0. 0. 199 1 200 3.22946 1.45274 2.47189 4.07696 -0.484155 2.10119 5.68906 1.58194 1.24439 1. 0. 0. 201 1 202 4.07696 -0.484155 2.10119 6.16236 -0.927955 1.16559 5.68906 1.58194 1.24439 1. 0. 0. 203 1 204 6.16236 -0.927955 1.16559 5.68906 1.58194 1.24439 7.32406 1.08574 0.0829932 1. 0. 0. 205 1 206 5.68906 1.58194 1.24439 7.55546 2.01984 -0.0120068 7.32406 1.08574 0.0829932 1. 0. 0. 207 1 208 3.22946 1.45274 2.47189 4.33006 2.26874 1.33549 5.68906 1.58194 1.24439 1. 0. 0. 209 1 210 3.22946 1.45274 2.47189 4.33006 2.26874 1.33549 2.57536 2.54894 1.23139 1. 0. 0. 211 1 212 4.33006 2.26874 1.33549 2.57536 2.54894 1.23139 5.10266 2.74254 -0.715907 1. 0. 0. 213 1 214 4.33006 2.26874 1.33549 5.10266 2.74254 -0.715907 7.55546 2.01984 -0.0120068 1. 0. 0. 215 1 216 4.33006 2.26874 1.33549 5.68906 1.58194 1.24439 7.55546 2.01984 -0.0120068 1. 0. 0. 217 1 218 1.45166 0.153645 2.50359 3.22946 1.45274 2.47189 2.57536 2.54894 1.23139 1. 0. 0. 219 1 220 1.45166 0.153645 2.50359 2.57536 2.54894 1.23139 -2.88384 2.33404 -0.0290068 1. 0. 0. 221 1 222 -0.771938 -0.223855 1.47919 1.45166 0.153645 2.50359 -2.88384 2.33404 -0.0290068 1. 0. 0. 223 1 224 -0.771938 -0.223855 1.47919 -3.67414 0.606345 1.56439 -2.88384 2.33404 -0.0290068 1. 0. 0. 225 1 226 -3.67414 0.606345 1.56439 -2.88384 2.33404 -0.0290068 -4.84774 2.80654 1.40919 1. 0. 0. 227 1 228 -2.88384 2.33404 -0.0290068 -4.84774 2.80654 1.40919 -4.05744 4.53424 -0.184207 1. 0. 0. 229 1 230 2.57536 2.54894 1.23139 -2.88384 2.33404 -0.0290068 -4.05744 4.53424 -0.184207 1. 0. 0. 231 1 232 2.57536 2.54894 1.23139 -2.88384 2.33404 -0.0290068 -4.05744 4.53424 -0.184207 1. 0. 0. 233 1 234 1.14346 1.15214 0.320993 2.57536 2.54894 1.23139 -2.88384 2.33404 -0.0290068 1. 0. 0. 235 1 236 1.14346 1.15214 0.320993 1.01996 1.06104 -2.15101 -2.88384 2.33404 -0.0290068 1. 0. 0. 237 1 238 1.14346 1.15214 0.320993 1.01996 1.06104 -2.15101 2.57536 2.54894 1.23139 1. 0. 0. 239 1 240 1.01996 1.06104 -2.15101 2.57536 2.54894 1.23139 5.10266 2.74254 -0.715907 1. 0. 0. 241 1 242 1.01996 1.06104 -2.15101 3.60736 1.29684 -2.87381 5.10266 2.74254 -0.715907 1. 0. 0. 243 1 244 -0.771938 -0.223855 1.47919 -0.300138 -1.62946 2.47449 -3.67414 0.606345 1.56439 1. 0. 0. 245 1 246 -0.771938 -0.223855 1.47919 -0.300138 -1.62946 2.47449 1.45166 0.153645 2.50359 1. 0. 0. 247 1 248 -0.300138 -1.62946 2.47449 -2.47214 -1.59546 1.71589 -3.67414 0.606345 1.56439 1. 0. 0. 249 1 250 -2.47214 -1.59546 1.71589 -4.76454 -1.89276 0.930293 -3.67414 0.606345 1.56439 1. 0. 0. 251 1 252 -4.76454 -1.89276 0.930293 -3.67414 0.606345 1.56439 -6.29174 0.967445 0.583993 1. 0. 0. 253 1 254 -3.67414 0.606345 1.56439 -4.84774 2.80654 1.40919 -6.29174 0.967445 0.583993 1. 0. 0. 255 1 256 -4.84774 2.80654 1.40919 -6.29174 0.967445 0.583993 -7.12784 2.53484 0.473393 1. 0. 0. 257 1 258 -2.47214 -1.59546 1.71589 -4.76454 -1.89276 0.930293 -3.92214 -3.45776 0.834093 1. 0. 0. 259 1 260 -1.53704 -3.60006 0.497793 -2.47214 -1.59546 1.71589 -3.92214 -3.45776 0.834093 1. 0. 0. 261 1 262 -1.53704 -3.60006 0.497793 -0.300138 -1.62946 2.47449 -2.47214 -1.59546 1.71589 1. 0. 0. 263 1 264 0.777562 -3.65286 1.28459 -1.53704 -3.60006 0.497793 -0.300138 -1.62946 2.47449 1. 0. 0. 265 1 266 -4.84774 2.80654 1.40919 -5.82304 4.61784 0.0247932 -4.05744 4.53424 -0.184207 1. 0. 0. 267 1 268 -4.84774 2.80654 1.40919 -5.82304 4.61784 0.0247932 -7.12784 2.53484 0.473393 1. 0. 0. 269 1 270 1.01996 1.06104 -2.15101 -2.88384 2.33404 -0.0290068 -3.96064 1.67134 -1.28171 1. 0. 0. 271 1 272 -2.88384 2.33404 -0.0290068 -3.96064 1.67134 -1.28171 -4.05744 4.53424 -0.184207 1. 0. 0. 273 1 274 -3.96064 1.67134 -1.28171 -4.05744 4.53424 -0.184207 -5.13424 3.87154 -1.43691 1. 0. 0. 275 1 276 -0.586638 -1.38326 -2.92321 1.01996 1.06104 -2.15101 -3.96064 1.67134 -1.28171 1. 0. 0. 277 1 278 -0.586638 -1.38326 -2.92321 1.75376 -0.319055 -2.99941 1.01996 1.06104 -2.15101 1. 0. 0. 279 1 280 1.75376 -0.319055 -2.99941 1.01996 1.06104 -2.15101 3.60736 1.29684 -2.87381 1. 0. 0. 281 1 282 -0.586638 -1.38326 -2.92321 -2.78704 -0.528955 -1.12651 -3.96064 1.67134 -1.28171 1. 0. 0. 283 1 284 -0.586638 -1.38326 -2.92321 -2.50954 -2.13946 -1.80561 -2.78704 -0.528955 -1.12651 1. 0. 0. 285 1 286 -2.50954 -2.13946 -1.80561 -2.78704 -0.528955 -1.12651 -3.96064 1.67134 -1.28171 1. 0. 0. 287 1 288 -2.50954 -2.13946 -1.80561 -4.18614 -2.49696 -0.640907 -3.96064 1.67134 -1.28171 1. 0. 0. 289 1 290 -4.18614 -2.49696 -0.640907 -3.96064 1.67134 -1.28171 -6.43904 1.78854 -0.988307 1. 0. 0. 291 1 292 -3.96064 1.67134 -1.28171 -5.13424 3.87154 -1.43691 -6.43904 1.78854 -0.988307 1. 0. 0. 293 1 294 -0.586638 -1.38326 -2.92321 -1.64154 -3.70136 -1.80061 -2.50954 -2.13946 -1.80561 1. 0. 0. 295 1 296 -0.586638 -1.38326 -2.92321 0.438062 -2.68776 -2.23921 -1.64154 -3.70136 -1.80061 1. 0. 0. 297 1 298 -0.586638 -1.38326 -2.92321 0.438062 -2.68776 -2.23921 1.75376 -0.319055 -2.99941 1. 0. 0. 299 1 300 -1.64154 -3.70136 -1.80061 -2.50954 -2.13946 -1.80561 -4.18614 -2.49696 -0.640907 1. 0. 0. 301 1 302 -1.64154 -3.70136 -1.80061 -4.18614 -2.49696 -0.640907 -3.92214 -3.45776 0.834093 1. 0. 0. 303 1 304 -1.53704 -3.60006 0.497793 -1.64154 -3.70136 -1.80061 -3.92214 -3.45776 0.834093 1. 0. 0. 305 1 306 0.904762 -3.62316 -0.490507 -1.53704 -3.60006 0.497793 -1.64154 -3.70136 -1.80061 1. 0. 0. 307 1 308 0.777562 -3.65286 1.28459 0.904762 -3.62316 -0.490507 -1.53704 -3.60006 0.497793 1. 0. 0. 309 1 310 0.904762 -3.62316 -0.490507 0.438062 -2.68776 -2.23921 -1.64154 -3.70136 -1.80061 1. 0. 0. 311 1 312 -4.76454 -1.89276 0.930293 -4.18614 -2.49696 -0.640907 -3.92214 -3.45776 0.834093 1. 0. 0. 313 1 314 -4.76454 -1.89276 0.930293 -4.18614 -2.49696 -0.640907 -6.29174 0.967445 0.583993 1. 0. 0. 315 1 316 -4.18614 -2.49696 -0.640907 -6.29174 0.967445 0.583993 -6.43904 1.78854 -0.988307 1. 0. 0. 317 1 318 -6.29174 0.967445 0.583993 -7.12784 2.53484 0.473393 -6.43904 1.78854 -0.988307 1. 0. 0. 319 1 320 3.60736 1.29684 -2.87381 5.67566 1.42984 -1.78291 5.10266 2.74254 -0.715907 1. 0. 0. 321 1 322 5.67566 1.42984 -1.78291 5.10266 2.74254 -0.715907 7.55546 2.01984 -0.0120068 1. 0. 0. 323 1 324 -5.13424 3.87154 -1.43691 -7.12784 2.53484 0.473393 -6.43904 1.78854 -0.988307 1. 0. 0. 325 1 326 -5.82304 4.61784 0.0247932 -5.13424 3.87154 -1.43691 -7.12784 2.53484 0.473393 1. 0. 0. 327 1 328 -5.82304 4.61784 0.0247932 -4.05744 4.53424 -0.184207 -5.13424 3.87154 -1.43691 1. 0. 0. 329 329 9 330 330 # terminating special property … … 333 333 25.0 0.6 -1.0 -1.0 -1.0 0.2 0 0 0 0 334 334 2 335 - 4.99203 4.29989 -0.5264295 1 0 0335 -5.0049 4.34121 -0.532107 5 1 0 0 336 336 9 337 337 terminating special property
Note:
See TracChangeset
for help on using the changeset viewer.