Changes in / [e58856b:f2a1d3]
- Files:
-
- 80 added
- 4 deleted
- 98 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile.am
re58856b rf2a1d3 1 1 ACLOCAL_AMFLAGS = -I m4 2 SUBDIRS = src src/ Actions src/unittests doc tests2 SUBDIRS = src src/unittests doc tests 3 3 4 4 EXTRA_DIST = autogen.sh -
configure.ac
re58856b rf2a1d3 27 27 28 28 # Boost libraries 29 AX_BOOST_BASE([1. 33.1])29 AX_BOOST_BASE([1.40]) 30 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 … … 93 92 94 93 # test suite 95 AC_CONFIG_TESTDIR(tests )94 AC_CONFIG_TESTDIR(tests/regression) 96 95 AC_CONFIG_FILES([ 97 tests/atlocal 98 tests/Makefile]) 96 tests/Makefile 97 tests/regression/atlocal 98 tests/regression/Makefile]) 99 AC_CONFIG_FILES([tests/regression/molecuilder], [chmod +x tests/regression/molecuilder]) 99 100 AC_CONFIG_FILES([ 100 101 tests/Tesselations/Makefile 101 102 tests/Tesselations/defs]) 102 AC_CONFIG_FILES([tests/molecuilder], [chmod +x tests/molecuilder])103 103 AC_CONFIG_FILES([ 104 104 doc/molecuilder.xml]) -
src/Actions/FragmentationAction/DepthFirstSearchAction.cpp
re58856b rf2a1d3 46 46 molecule * const mol = World::getInstance().getMolecule(MoleculeById(0)); 47 47 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 48 int *MinimumRingSize = new int[mol-> AtomCount];48 int *MinimumRingSize = new int[mol->getAtomCount()]; 49 49 atom ***ListOfLocalAtoms = NULL; 50 50 class StackClass<bond *> *BackEdgeStack = NULL; … … 66 66 delete(Subgraphs); 67 67 for (int i=0;i<FragmentCounter;i++) 68 Free(&ListOfLocalAtoms[i]);69 Free(&ListOfLocalAtoms);68 delete[](ListOfLocalAtoms[i]); 69 delete[](ListOfLocalAtoms); 70 70 } 71 71 delete(BackEdgeStack); -
src/Actions/Makefile.am
re58856b rf2a1d3 30 30 ${TESSELATIONACTIONHEADER} \ 31 31 ${WORLDACTIONHEADER} \ 32 MapOfActions.hpp 32 MapOfActions.hpp \ 33 Values.hpp 33 34 34 35 ANALYSISACTIONSOURCE = \ -
src/Actions/MapOfActions.cpp
re58856b rf2a1d3 12 12 #include "Helpers/Assert.hpp" 13 13 14 #include <boost/lexical_cast.hpp> 15 #include <boost/optional.hpp> 16 #include <boost/program_options.hpp> 17 14 18 #include "CommandLineParser.hpp" 15 19 #include "log.hpp" 16 20 #include "verbose.hpp" 21 22 #include "Actions/Values.hpp" 23 24 void validate(boost::any& v, const std::vector<std::string>& values, VectorValue *, int) 25 { 26 VectorValue VV; 27 if (values.size() != 3) { 28 cerr << "Specified vector does not have three components but " << values.size() << endl; 29 throw boost::program_options::validation_error("Specified vector does not have three components"); 30 } 31 VV.x = boost::lexical_cast<double>(values.at(0)); 32 VV.y = boost::lexical_cast<double>(values.at(1)); 33 VV.z = boost::lexical_cast<double>(values.at(2)); 34 v = boost::any(VectorValue(VV)); 35 } 36 37 void validate(boost::any& v, const std::vector<std::string>& values, BoxValue *, int) 38 { 39 BoxValue BV; 40 if (values.size() != 6) { 41 cerr << "Specified vector does not have three components but " << values.size() << endl; 42 throw boost::program_options::validation_error("Specified symmetric box matrix does not have six components"); 43 } 44 BV.xx = boost::lexical_cast<double>(values.at(0)); 45 BV.xy = boost::lexical_cast<double>(values.at(1)); 46 BV.xz = boost::lexical_cast<double>(values.at(2)); 47 BV.yy = boost::lexical_cast<double>(values.at(3)); 48 BV.yz = boost::lexical_cast<double>(values.at(4)); 49 BV.zz = boost::lexical_cast<double>(values.at(5)); 50 v = boost::any(BoxValue(BV)); 51 } 52 17 53 18 54 /** Constructor of class MapOfActions. … … 62 98 DescriptionMap["save-bonds"] = "name of the bonds file to write to"; 63 99 DescriptionMap["save-temperature"] = "name of the temperature file to write to"; 100 DescriptionMap["scale-box"] = "scale box and atomic positions inside"; 64 101 DescriptionMap["subspace-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs"; 65 102 DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified"; … … 75 112 DescriptionMap["distance"] = "distance in space"; 76 113 DescriptionMap["distances"] = "list of three of distances in space, one for each axis direction"; 114 DescriptionMap["DoRotate"] = "whether to rotate or just report angles"; 77 115 DescriptionMap["element"] = "set of elements"; 78 116 DescriptionMap["end-mol"] = "last or end step"; … … 92 130 ShortFormMap["bond-file"] = "A"; 93 131 ShortFormMap["boundary"] = "c"; 94 ShortFormMap[" bound-in-box"] = "B";132 ShortFormMap["change-box"] = "B"; 95 133 ShortFormMap["center-edge"] = "O"; 96 134 ShortFormMap["center-in-box"] = "b"; … … 123 161 ShortFormMap["suspend-in-water"] = "U"; 124 162 ShortFormMap["translate-mol"] = "t"; 125 ShortFormMap["verbose"] = " V";163 ShortFormMap["verbose"] = "v"; 126 164 ShortFormMap["verlet-integrate"] = "P"; 127 ShortFormMap["version"] = " v";165 ShortFormMap["version"] = "V"; 128 166 129 167 // value types for the actions … … 132 170 TypeMap["bond-table"] = String; 133 171 TypeMap["boundary"] = Vector; 134 TypeMap["change-box"] = Vector; 172 TypeMap["center-in-box"] = Box; 173 TypeMap["change-box"] = Box; 135 174 TypeMap["change-element"] = Element; 136 175 TypeMap["change-molname"] = String; … … 151 190 TypeMap["remove-atom"] = Atom; 152 191 TypeMap["remove-sphere"] = Atom; 153 TypeMap["repeat-box"] = ListOfInts;192 TypeMap["repeat-box"] = Vector; 154 193 TypeMap["rotate-to-pas"] = Molecule; 155 194 TypeMap["save-adjacency"] = String; … … 163 202 TypeMap["verlet-integrate"] = String; 164 203 TypeMap["verbose"] = Integer; 204 165 205 // value types for the values 166 206 TypeMap["bin-output-file"] = String; … … 168 208 TypeMap["bin-start"] = Double; 169 209 TypeMap["distance"] = Double; 170 TypeMap["distances"] = ListOfDoubles; 210 TypeMap["distances"] = Vector; 211 TypeMap["DoRotate"] = Boolean; 171 212 TypeMap["elements"] = Element; 172 213 TypeMap["elements"] = ListOfElements; 173 214 TypeMap["length"] = Double; 174 TypeMap["lengths"] = ListOfDoubles;215 TypeMap["lengths"] = Vector; 175 216 TypeMap["MaxDistance"] = Double; 176 217 TypeMap["molecule-by-id"] = Molecule; … … 179 220 TypeMap["position"] = Vector; 180 221 222 // default values for any action that needs one (always string!) 223 DefaultValue["molecule-by-id"] = "-1"; 224 225 181 226 // list of generic actions 182 227 // generic.insert("add-atom"); 183 228 // generic.insert("bond-file"); 184 229 // generic.insert("bond-table"); 185 //generic.insert("boundary");230 generic.insert("boundary"); 186 231 // generic.insert("bound-in-box"); 187 //generic.insert("center-edge");188 //generic.insert("center-in-box");189 //generic.insert("change-box");232 generic.insert("center-edge"); 233 generic.insert("center-in-box"); 234 generic.insert("change-box"); 190 235 // generic.insert("change-molname"); 191 236 // generic.insert("change-element"); … … 195 240 // generic.insert("element-db"); 196 241 // generic.insert("fastparsing"); 197 //generic.insert("fill-molecule");242 generic.insert("fill-molecule"); 198 243 // generic.insert("fragment-mol"); 199 244 generic.insert("help"); … … 208 253 // generic.insert("remove-atom"); 209 254 // generic.insert("remove-sphere"); 255 generic.insert("repeat-box"); 210 256 // generic.insert("rotate-to-pas"); 211 257 // generic.insert("save-adjacency"); 212 258 // generic.insert("save-bonds"); 213 259 // generic.insert("save-temperature"); 214 //generic.insert("scale-box");260 generic.insert("scale-box"); 215 261 // generic.insert("set-basis"); 216 262 // generic.insert("subspace-dissect"); … … 230 276 generic.insert("input"); 231 277 // generic.insert("length"); 232 // generic.insert("lengths");233 // generic.insert("MaxDistance");234 // generic.insert("molecule-by-id");235 278 // generic.insert("output-file"); 236 279 // generic.insert("periodic"); … … 240 283 // positional arguments 241 284 inputfile.insert("input"); 285 286 // hidden arguments 287 // generic.insert("distance"); 288 generic.insert("DoRotate"); 289 generic.insert("distances"); 290 generic.insert("lengths"); 291 generic.insert("MaxDistance"); 292 generic.insert("molecule-by-id"); 242 293 } 243 294 … … 269 320 case Boolean: 270 321 ListRunner->second->add_options() 271 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< bool >(), getDescription(*OptionRunner).c_str()) 322 (getKeyAndShortForm(*OptionRunner).c_str(), 323 DefaultValue.find(*OptionRunner) != DefaultValue.end() ? 324 po::value< bool >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) : 325 po::value< bool >(), 326 getDescription(*OptionRunner).c_str()) 327 ; 328 break; 329 case Box: 330 ListRunner->second->add_options() 331 (getKeyAndShortForm(*OptionRunner).c_str(), 332 po::value<BoxValue>()->multitoken(), 333 getDescription(*OptionRunner).c_str()) 272 334 ; 273 335 break; 274 336 case Integer: 275 337 ListRunner->second->add_options() 276 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< int >(), getDescription(*OptionRunner).c_str()) 338 (getKeyAndShortForm(*OptionRunner).c_str(), 339 DefaultValue.find(*OptionRunner) != DefaultValue.end() ? 340 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) : 341 po::value< int >(), 342 getDescription(*OptionRunner).c_str()) 277 343 ; 278 344 break; 279 345 case ListOfInts: 280 346 ListRunner->second->add_options() 281 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< vector<int> >(), getDescription(*OptionRunner).c_str()) 347 (getKeyAndShortForm(*OptionRunner).c_str(), 348 po::value< vector<int> >()->multitoken(), 349 getDescription(*OptionRunner).c_str()) 282 350 ; 283 351 break; 284 352 case Double: 285 353 ListRunner->second->add_options() 286 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< double >(), getDescription(*OptionRunner).c_str()) 354 (getKeyAndShortForm(*OptionRunner).c_str(), 355 DefaultValue.find(*OptionRunner) != DefaultValue.end() ? 356 po::value< double >()->default_value(atof(DefaultValue[*OptionRunner].c_str())) : 357 po::value< double >(), 358 getDescription(*OptionRunner).c_str()) 287 359 ; 288 360 break; 289 361 case ListOfDoubles: 290 362 ListRunner->second->add_options() 291 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< vector<double> >(), getDescription(*OptionRunner).c_str()) 363 (getKeyAndShortForm(*OptionRunner).c_str(), 364 po::value< vector<double> >()->multitoken(), 365 getDescription(*OptionRunner).c_str()) 292 366 ; 293 367 break; 294 368 case String: 295 369 ListRunner->second->add_options() 296 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< std::string >(), getDescription(*OptionRunner).c_str()) 370 (getKeyAndShortForm(*OptionRunner).c_str(), 371 DefaultValue.find(*OptionRunner) != DefaultValue.end() ? 372 po::value< std::string >()->default_value(DefaultValue[*OptionRunner]) : 373 po::value< std::string >(), 374 getDescription(*OptionRunner).c_str()) 297 375 ; 298 376 break; 299 377 case Axis: 300 378 ListRunner->second->add_options() 301 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< int >(), getDescription(*OptionRunner).c_str()) 379 (getKeyAndShortForm(*OptionRunner).c_str(), 380 DefaultValue.find(*OptionRunner) != DefaultValue.end() ? 381 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) : 382 po::value< int >(), 383 getDescription(*OptionRunner).c_str()) 302 384 ; 303 385 break; 304 386 case Vector: 305 387 ListRunner->second->add_options() 306 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< vector<double> >(), getDescription(*OptionRunner).c_str()) 307 ; 308 break; 309 case Box: 310 ListRunner->second->add_options() 311 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< vector<double> >(), getDescription(*OptionRunner).c_str()) 388 (getKeyAndShortForm(*OptionRunner).c_str(), 389 po::value<VectorValue>()->multitoken(), 390 getDescription(*OptionRunner).c_str()) 312 391 ; 313 392 break; 314 393 case Molecule: 315 394 ListRunner->second->add_options() 316 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< int >(), getDescription(*OptionRunner).c_str()) 395 (getKeyAndShortForm(*OptionRunner).c_str(), 396 DefaultValue.find(*OptionRunner) != DefaultValue.end() ? 397 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) : 398 po::value< int >(), 399 getDescription(*OptionRunner).c_str()) 317 400 ; 318 401 break; 319 402 case ListOfMolecules: 320 403 ListRunner->second->add_options() 321 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< vector<int> >(), getDescription(*OptionRunner).c_str()) 404 (getKeyAndShortForm(*OptionRunner).c_str(), 405 po::value< vector<int> >()->multitoken(), 406 getDescription(*OptionRunner).c_str()) 322 407 ; 323 408 break; 324 409 case Atom: 325 410 ListRunner->second->add_options() 326 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< int >(), getDescription(*OptionRunner).c_str()) 411 (getKeyAndShortForm(*OptionRunner).c_str(), 412 DefaultValue.find(*OptionRunner) != DefaultValue.end() ? 413 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) : 414 po::value< int >(), 415 getDescription(*OptionRunner).c_str()) 327 416 ; 328 417 break; 329 418 case ListOfAtoms: 330 419 ListRunner->second->add_options() 331 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< vector<int> >(), getDescription(*OptionRunner).c_str()) 420 (getKeyAndShortForm(*OptionRunner).c_str(), 421 po::value< vector<int> >()->multitoken(), 422 getDescription(*OptionRunner).c_str()) 332 423 ; 333 424 break; 334 425 case Element: 335 426 ListRunner->second->add_options() 336 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< int >(), getDescription(*OptionRunner).c_str()) 427 (getKeyAndShortForm(*OptionRunner).c_str(), 428 DefaultValue.find(*OptionRunner) != DefaultValue.end() ? 429 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) : 430 po::value< int >(), 431 getDescription(*OptionRunner).c_str()) 337 432 ; 338 433 break; 339 434 case ListOfElements: 340 435 ListRunner->second->add_options() 341 (getKeyAndShortForm(*OptionRunner).c_str(), po::value< vector<int> >(), getDescription(*OptionRunner).c_str()) 436 (getKeyAndShortForm(*OptionRunner).c_str(), 437 po::value< vector<int> >()->multitoken(), 438 getDescription(*OptionRunner).c_str()) 342 439 ; 343 440 break; -
src/Actions/MapOfActions.hpp
re58856b rf2a1d3 53 53 54 54 // map of the action names and their description 55 map<std::string, std::string> DefaultValue; 55 56 map<std::string, std::string> DescriptionMap; 56 57 map<std::string, std::string> ShortFormMap; -
src/Actions/MoleculeAction/FillWithMoleculeAction.cpp
re58856b rf2a1d3 66 66 67 67 if(dialog->display()) { 68 DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << lengths[0] << "," << lengths[1] << "," << lengths[2] << "), distances (" << distances[0] << "," << distances[1] << "," << distances[2] << "), MaxDistance " << MaxDistance << ", DoRotate " << DoRotate << "." << endl); 68 69 // construct water molecule 69 70 molecule *filler = World::getInstance().createMolecule(); 70 //if (!filler->AddXYZFile(filename)) {71 //DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << filename << "." << endl);72 //}73 // filler->SetNameFromFilename(filename);71 if (!filler->AddXYZFile(filename)) { 72 DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << filename << "." << endl); 73 } 74 filler->SetNameFromFilename(filename.c_str()); 74 75 molecule *Filling = NULL; 75 atom *first = NULL, *second = NULL, *third = NULL;76 first = World::getInstance().createAtom();77 first->type = World::getInstance().getPeriode()->FindElement(1);78 first->x = Vector(0.441, -0.143, 0.);79 filler->AddAtom(first);80 second = World::getInstance().createAtom();81 second->type = World::getInstance().getPeriode()->FindElement(1);82 second->x = Vector(-0.464, 1.137, 0.0);83 filler->AddAtom(second);84 third = World::getInstance().createAtom();85 third->type = World::getInstance().getPeriode()->FindElement(8);86 third->x = Vector(-0.464, 0.177, 0.);87 filler->AddAtom(third);88 filler->AddBond(first, third, 1);89 filler->AddBond(second, third, 1);76 // atom *first = NULL, *second = NULL, *third = NULL; 77 // first = World::getInstance().createAtom(); 78 // first->type = World::getInstance().getPeriode()->FindElement(1); 79 // first->x = Vector(0.441, -0.143, 0.); 80 // filler->AddAtom(first); 81 // second = World::getInstance().createAtom(); 82 // second->type = World::getInstance().getPeriode()->FindElement(1); 83 // second->x = Vector(-0.464, 1.137, 0.0); 84 // filler->AddAtom(second); 85 // third = World::getInstance().createAtom(); 86 // third->type = World::getInstance().getPeriode()->FindElement(8); 87 // third->x = Vector(-0.464, 0.177, 0.); 88 // filler->AddAtom(third); 89 // filler->AddBond(first, third, 1); 90 // filler->AddBond(second, third, 1); 90 91 World::getInstance().getConfig()->BG->ConstructBondGraph(filler); 91 filler->SetNameFromFilename("water");92 // filler->SetNameFromFilename("water"); 92 93 // call routine 93 94 double distance[NDIM]; -
src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp
re58856b rf2a1d3 65 65 DoLog(0) && (Log() << Verbose(0) << "Evaluating non-convex envelope of molecule." << Boundary->getId() << endl); 66 66 DoLog(1) && (Log() << Verbose(1) << "Using rolling ball of radius " << SphereRadius << " and storing tecplot data in " << filename << "." << endl); 67 DoLog(1) && (Log() << Verbose(1) << "Specified molecule has " << Boundary-> AtomCount<< " atoms." << endl);67 DoLog(1) && (Log() << Verbose(1) << "Specified molecule has " << Boundary->getAtomCount() << " atoms." << endl); 68 68 start = clock(); 69 69 LCList = new LinkedCell(Boundary, SphereRadius*2.); -
src/Actions/WorldAction/AddEmptyBoundaryAction.cpp
re58856b rf2a1d3 69 69 AtomRunner = AllAtoms.begin(); 70 70 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) 71 (*AtomRunner)->x -= Min ;71 (*AtomRunner)->x -= Min - boundary; 72 72 delete dialog; 73 73 return Action::success; -
src/Actions/WorldAction/CenterInBoxAction.cpp
re58856b rf2a1d3 33 33 Dialog *dialog = UIFactory::getInstance().makeDialog(); 34 34 35 dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME)); 35 double * cell_size = World::getInstance().getDomain(); 36 dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME)); 36 37 37 38 if(dialog->display()) { -
src/Actions/WorldAction/RepeatBoxAction.cpp
re58856b rf2a1d3 23 23 #include "UIElements/Dialog.hpp" 24 24 #include "Actions/MapOfActions.hpp" 25 #include "Descriptors/MoleculeDescriptor.hpp" 26 #include "Descriptors/MoleculePtrDescriptor.hpp" 25 27 26 28 const char WorldRepeatBoxAction::NAME[] = "repeat-box"; … … 40 42 molecule *mol = NULL; 41 43 int j = 0; 44 atom *Walker = NULL; 45 MoleculeListClass *molecules = World::getInstance().getMolecules(); 42 46 43 47 dialog->queryVector(NAME, &Repeater, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME)); 44 dialog->queryMolecule("molecule-by-id", &mol,MapOfActions::getInstance().getDescription("molecule-by-id")); 48 //dialog->queryMolecule("molecule-by-id", &mol,MapOfActions::getInstance().getDescription("molecule-by-id")); 49 vector<molecule *> AllMolecules; 50 if (mol != NULL) { 51 DoLog(0) && (Log() << Verbose(0) << "Using molecule " << mol->name << "." << endl); 52 AllMolecules = World::getInstance().getAllMolecules(MoleculeByPtr(mol)); 53 } else { 54 DoLog(0) && (Log() << Verbose(0) << "Using all molecules." << endl); 55 AllMolecules = World::getInstance().getAllMolecules(); 56 } 45 57 46 58 if(dialog->display()) { 59 (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl); 47 60 double * const cell_size = World::getInstance().getDomain(); 61 double *M = ReturnFullMatrixforSymmetric(cell_size); 48 62 Vector x,y; 49 for (int axis = 1; axis <= NDIM; axis++) {50 Vector ** vectors;63 int n[NDIM]; 64 for (int axis = 0; axis < NDIM; axis++) { 51 65 Repeater[axis] = floor(Repeater[axis]); 52 66 if (Repeater[axis] < 1) { … … 54 68 Repeater[axis] = 1; 55 69 } 56 mol->CountAtoms(); // recount atoms 57 if (mol->AtomCount != 0) { // if there is more than none 58 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand 59 Elements = new const element *[count]; 60 vectors = new Vector *[count]; 61 j = 0; 62 atom *first = mol->start; 63 while (first->next != mol->end) { // make a list of all atoms with coordinates and element 64 first = first->next; 65 Elements[j] = first->type; 66 vectors[j] = &first->x; 67 j++; 68 } 69 if (count != j) 70 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl); 71 x.Zero(); 72 y.Zero(); 73 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 74 for (int i=1;i<Repeater[axis];i++) { // then add this list with respective translation factor times 75 x += y; // per factor one cell width further 76 for (int k=count;k--;) { // go through every atom of the original cell 77 first = World::getInstance().createAtom(); // create a new body 78 first->x = (*vectors[k]) + x; 79 first->type = Elements[k]; // insert original element 80 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 70 cell_size[(abs(axis+1) == 2) ? 2 : ((abs(axis+2) == 3) ? 5 : 0)] *= Repeater[axis]; 71 } 72 73 molecule *newmol = NULL; 74 Vector ** vectors = NULL; 75 for (n[0] = 0; n[0] < Repeater[0]; n[0]++) { 76 y[0] = n[0]; 77 for (n[1] = 0; n[1] < Repeater[1]; n[1]++) { 78 y[1] = n[1]; 79 for (n[2] = 0; n[2] < Repeater[2]; n[2]++) { 80 y[2] = n[2]; 81 if (n[0] == n[1] == n[2] == 0) 82 continue; 83 for (vector<molecule *>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) { 84 mol = *MolRunner; 85 DoLog(1) && (Log() << Verbose(1) << "Current mol is " << mol->name << "." << endl); 86 count = mol->getAtomCount(); // is changed becausing of adding, thus has to be stored away beforehand 87 if (count != 0) { // if there is more than none 88 Elements = new const element *[count]; 89 vectors = new Vector *[count]; 90 j = 0; 91 for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) { 92 Elements[j] = (*AtomRunner)->type; 93 vectors[j] = &(*AtomRunner)->x; 94 j++; 95 } 96 if (count != j) 97 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl); 98 x = y; 99 x.MatrixMultiplication(M); 100 newmol = World::getInstance().createMolecule(); 101 molecules->insert(newmol); 102 for (int k=count;k--;) { // go through every atom of the original cell 103 Walker = World::getInstance().createAtom(); // create a new body 104 Walker->x = (*vectors[k]) + x; 105 Walker->type = Elements[k]; // insert original element 106 cout << "new atom is " << *Walker << endl; 107 newmol->AddAtom(Walker); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 108 } 109 // free memory 110 delete[](Elements); 111 delete[](vectors); 112 } else { 113 DoLog(1) && (Log() << Verbose(1) << "\t ... is empty." << endl); 114 } 81 115 } 82 116 } 83 // free memory84 delete[](Elements);85 delete[](vectors);86 // correct cell size87 if (axis < 0) { // if sign was negative, we have to translate everything88 x =(-(Repeater[axis]-1)) * y;89 mol->Translate(&x);90 }91 cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= Repeater[axis];92 117 } 93 118 } 119 delete(M); 94 120 delete dialog; 95 121 return Action::success; -
src/Helpers/Assert.cpp
re58856b rf2a1d3 54 54 55 55 56 57 56 bool _my_assert::check(const bool res, 58 57 const char* condition, … … 63 62 { 64 63 if(!res){ 65 cout << "Assertion " << condition <<" failed in file " << filename << " at line " << line << endl;64 cout << "Assertion \"" << condition << "\" failed in file " << filename << " at line " << line << endl; 66 65 cout << "Assertion Message: " << message << std::endl; 67 66 while(true){ -
src/Helpers/MemDebug.cpp
re58856b rf2a1d3 9 9 #include <cstdlib> 10 10 #include <cstring> 11 #include <boost/thread.hpp> 11 12 12 13 using namespace std; 14 15 #ifndef NDBEGUG 16 #ifndef NO_MEMDEBUG 13 17 14 18 namespace Memory { … … 40 44 }; 41 45 46 boost::mutex memorylock; 47 42 48 // start and end of the doubly-linked list 43 49 entry_t *begin=0; … … 128 134 void *operator new(size_t nbytes,const char* file, int line) throw(std::bad_alloc) { 129 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); 138 130 139 // to avoid allocations of 0 bytes if someone screws up 131 140 // allocation with 0 byte size are undefined behavior, so we are … … 153 162 // build the entry in front of the space 154 163 Memory::entry_t *entry = (Memory::entry_t*) res; 164 memset(res,0,entrySpace); 155 165 entry->info.nbytes = nbytes; 156 166 entry->info.isUsed = true; … … 203 213 204 214 void operator delete(void *ptr) throw() { 215 if(!ptr){ 216 cerr << "Warning: Deleting NULL pointer" << endl; 217 return; 218 } 219 220 // we need to lock, so the linked list does not changed while we are in here 221 boost::mutex::scoped_lock guard(Memory::memorylock); 222 205 223 // get the size for the entry, including alignment 206 224 static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t)); … … 211 229 // let's see if the checksum is still matching 212 230 if(Memory::calcChecksum(&entry->info)!=entry->checksum){ 213 c out<< "Possible memory corruption detected!" << endl;214 c out<< "Trying to recover allocation information..." << endl;215 c out<< "Memory was allocated at " << entry->info.file << ":" << entry->info.line << endl;231 cerr << "Possible memory corruption detected!" << endl; 232 cerr << "Trying to recover allocation information..." << endl; 233 cerr << "Memory was allocated at " << entry->info.file << ":" << entry->info.line << endl; 216 234 terminate(); 217 235 } … … 240 258 operator delete(ptr); 241 259 } 260 #endif 261 #endif -
src/Helpers/MemDebug.hpp
re58856b rf2a1d3 21 21 * your sourcefiles. 22 22 */ 23 #ifndef NDEBUG 24 #ifndef NO_MEMDEBUG 25 26 #ifndef MEMDEBUG 27 #define MEMDEBUG 28 #endif 23 29 24 30 namespace Memory { … … 56 62 #define new new(__FILE__,__LINE__) 57 63 64 #endif 65 #endif 66 67 68 #ifndef MEMDEBUG 69 // memory debugging was disabled 70 71 namespace Memory { 72 inline void getState(){} 73 74 template <typename T> 75 inline T *ignore(T* ptr){ 76 return ptr; 77 } 78 } 79 80 #endif 58 81 #endif /* MEMDEBUG_HPP_ */ -
src/Legacy/oldmenu.cpp
re58856b rf2a1d3 424 424 void oldmenu::RemoveAtoms(molecule *mol) 425 425 { 426 atom * first, *second;426 atom *second; 427 427 int axis; 428 428 double tmp1, tmp2; … … 447 447 break; 448 448 case 'b': 449 second = mol->AskAtom("Enter number of atom as reference point: ");450 Log() << Verbose(0) << "Enter radius: ";451 cin >> tmp1;452 first = mol->start;453 second = first->next;454 while(second != mol->end) {455 first = second;456 second = first->next;457 if (first->x.DistanceSquared(second->x) > tmp1*tmp1) // distance to first above radius ...458 mol->RemoveAtom(first);449 { 450 second = mol->AskAtom("Enter number of atom as reference point: "); 451 Log() << Verbose(0) << "Enter radius: "; 452 cin >> tmp1; 453 molecule::iterator runner; 454 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) { 455 runner = iter++; 456 if ((*runner)->x.DistanceSquared((*runner)->x) > tmp1*tmp1) // distance to first above radius ... 457 mol->RemoveAtom((*runner)); 458 } 459 459 } 460 460 break; … … 466 466 Log() << Verbose(0) << "Upper boundary: "; 467 467 cin >> tmp2; 468 first = mol->start; 469 second = first->next; 470 while(second != mol->end) { 471 first = second; 472 second = first->next; 473 if ((first->x[axis] < tmp1) || (first->x[axis] > tmp2)) {// out of boundary ... 474 //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl; 475 mol->RemoveAtom(first); 468 molecule::iterator runner; 469 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) { 470 runner = iter++; 471 if (((*runner)->x[axis] < tmp1) || ((*runner)->x[axis] > tmp2)) {// out of boundary ... 472 //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl; 473 mol->RemoveAtom((*runner)); 476 474 } 477 475 } … … 516 514 min[i] = 0.; 517 515 518 second = mol->start; 519 while ((second->next != mol->end)) { 520 second = second->next; // advance 521 Z = second->type->Z; 516 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 517 Z = (*iter)->type->Z; 522 518 tmp1 = 0.; 523 if (first != second) {524 x = first->x - second->x;519 if (first != (*iter)) { 520 x = first->x - (*iter)->x; 525 521 tmp1 = x.Norm(); 526 522 } 527 523 if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1; 528 //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;524 //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << ((*iter)->nr << ": " << tmp1 << " a.u." << endl; 529 525 } 530 526 for (int i=MAX_ELEMENTS;i--;) … … 609 605 Log() << Verbose(0) << "What's the desired bond order: "; 610 606 cin >> Order1; 611 if (mol-> first->next != mol->last) { // there are bonds607 if (mol->hasBondStructure()) { 612 608 start = clock(); 613 609 mol->FragmentMolecule(Order1, configuration); … … 755 751 Log() << Verbose(0) << "State the factor: "; 756 752 cin >> faktor; 757 758 mol->CountAtoms(); // recount atoms 759 if (mol->AtomCount != 0) { // if there is more than none 760 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand 753 if (mol->getAtomCount() != 0) { // if there is more than none 754 count = mol->getAtomCount(); // is changed becausing of adding, thus has to be stored away beforehand 761 755 Elements = new const element *[count]; 762 756 vectors = new Vector *[count]; 763 757 j = 0; 764 first = mol->start; 765 while (first->next != mol->end) { // make a list of all atoms with coordinates and element 766 first = first->next; 767 Elements[j] = first->type; 768 vectors[j] = &first->x; 758 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 759 Elements[j] = (*iter)->type; 760 vectors[j] = &(*iter)->x; 769 761 j++; 770 762 } … … 783 775 } 784 776 } 785 if (mol-> first->next != mol->last) // if connect matrix is present already, redo it777 if (mol->hasBondStructure()) 786 778 mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 787 779 // free memory … … 1025 1017 return; 1026 1018 } 1027 atom *Walker = mol->start;1028 1019 1029 1020 // generate some KeySets 1030 1021 Log() << Verbose(0) << "Generating KeySets." << endl; 1031 KeySet TestSets[mol-> AtomCount+1];1022 KeySet TestSets[mol->getAtomCount()+1]; 1032 1023 i=1; 1033 while (Walker->next != mol->end) { 1034 Walker = Walker->next; 1024 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1035 1025 for (int j=0;j<i;j++) { 1036 TestSets[j].insert( Walker->nr);1026 TestSets[j].insert((*iter)->nr); 1037 1027 } 1038 1028 i++; … … 1040 1030 Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl; 1041 1031 KeySetTestPair test; 1042 test = TestSets[mol->AtomCount-1].insert(Walker->nr); 1043 if (test.second) { 1044 Log() << Verbose(1) << "Insertion worked?!" << endl; 1032 molecule::const_iterator iter = mol->begin(); 1033 if (iter != mol->end()) { 1034 test = TestSets[mol->getAtomCount()-1].insert((*iter)->nr); 1035 if (test.second) { 1036 Log() << Verbose(1) << "Insertion worked?!" << endl; 1037 } else { 1038 Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl; 1039 } 1045 1040 } else { 1046 Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl; 1047 } 1048 TestSets[mol->AtomCount].insert(mol->end->previous->nr); 1049 TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr); 1041 eLog() << Verbose(1) << "No atoms to test double insertion." << endl; 1042 } 1050 1043 1051 1044 // constructing Graph structure … … 1055 1048 // insert KeySets into Subgraphs 1056 1049 Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl; 1057 for (int j=0;j<mol-> AtomCount;j++) {1050 for (int j=0;j<mol->getAtomCount();j++) { 1058 1051 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.))); 1059 1052 } 1060 1053 Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl; 1061 1054 GraphTestPair test2; 1062 test2 = Subgraphs.insert(GraphPair (TestSets[mol-> AtomCount],pair<int, double>(counter++, 1.)));1055 test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.))); 1063 1056 if (test2.second) { 1064 1057 Log() << Verbose(1) << "Insertion worked?!" << endl; -
src/Makefile.am
re58856b rf2a1d3 113 113 Descriptors/AtomTypeDescriptor.cpp \ 114 114 Descriptors/MoleculeDescriptor.cpp \ 115 Descriptors/MoleculeIdDescriptor.cpp 115 Descriptors/MoleculeIdDescriptor.cpp \ 116 Descriptors/MoleculePtrDescriptor.cpp 116 117 117 118 118 119 DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \ 119 120 Descriptors/AtomIdDescriptor.hpp \ 120 121 Descriptors/AtomTypeDescriptor.hpp \ 121 122 Descriptors/MoleculeDescriptor.hpp \ 122 Descriptors/MoleculeIdDescriptor.hpp 123 Descriptors/MoleculeIdDescriptor.hpp \ 124 Descriptors/MoleculePtrDescriptor.hpp 123 125 124 126 EXCEPTIONSOURCE = Exceptions/CustomException.cpp \ … … 148 150 config.cpp \ 149 151 element.cpp \ 152 elements_db.cpp \ 150 153 ellipsoid.cpp \ 151 154 errorlogger.cpp \ … … 156 159 Line.cpp \ 157 160 linkedcell.cpp \ 158 lists.cpp \159 161 log.cpp \ 160 162 logger.cpp \ 161 memoryusageobserver.cpp \162 163 moleculelist.cpp \ 163 164 molecule.cpp \ … … 170 171 periodentafel.cpp \ 171 172 Plane.cpp \ 173 Space.cpp \ 172 174 tesselation.cpp \ 173 175 tesselationhelpers.cpp \ 174 176 triangleintersectionlist.cpp \ 177 vector.cpp \ 178 vector_ops.cpp \ 175 179 verbose.cpp \ 176 vector_ops.cpp \177 180 World.cpp 178 181 … … 193 196 defs.hpp \ 194 197 element.hpp \ 198 elements_db.hpp \ 195 199 ellipsoid.hpp \ 196 200 errorlogger.hpp \ … … 204 208 log.hpp \ 205 209 logger.hpp \ 206 memoryallocator.hpp \207 memoryusageobserver.hpp \208 210 molecule.hpp \ 209 211 molecule_template.hpp \ … … 218 220 vector_ops.hpp \ 219 221 World.hpp 222 223 # the following files are no longer used: 224 # memoryallocator.hpp \ 225 # memoryallocator.cpp \ 226 # memoryusageobserver.hpp \ 227 # memoryusageobserver.cpp 220 228 221 229 BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB) -
src/Patterns/Cacheable.hpp
re58856b rf2a1d3 28 28 owner(_owner) 29 29 {} 30 virtual T getValue()=0;30 virtual T& getValue()=0; 31 31 virtual void invalidate()=0; 32 32 virtual bool isValid()=0; … … 46 46 {} 47 47 48 virtual T getValue(){48 virtual T& getValue(){ 49 49 // set the state to valid 50 50 State::owner->switchState(State::owner->validState); … … 72 72 {} 73 73 74 virtual T getValue(){74 virtual T& getValue(){ 75 75 return content; 76 76 } … … 100 100 {} 101 101 102 virtual T getValue(){102 virtual T& getValue(){ 103 103 ASSERT(0,"Cannot get a value from a Cacheable after it's Observable has died"); 104 104 // we have to return a grossly invalid reference, because no value can be produced anymore … … 134 134 void subjectKilled(Observable *subject); 135 135 private: 136 137 136 void switchState(state_ptr newState); 138 137 … … 144 143 145 144 Observable *owner; 146 147 145 boost::function<T()> recalcMethod; 148 146 … … 221 219 222 220 const bool isValid() const; 223 const T operator*() const;221 const T& operator*() const; 224 222 225 223 // methods implemented for base-class Observer … … 237 235 238 236 template<typename T> 239 const T Cacheable<T>::operator*() const{237 const T& Cacheable<T>::operator*() const{ 240 238 return recalcMethod(); 241 239 } -
src/Patterns/Observer.cpp
re58856b rf2a1d3 82 82 Observable::_Observable_protector::_Observable_protector(Observable *_protege) : 83 83 protege(_protege) 84 { 85 start_observer_internal(protege); 86 } 87 88 Observable::_Observable_protector::_Observable_protector(const _Observable_protector &dest) : 89 protege(dest.protege) 84 90 { 85 91 start_observer_internal(protege); … … 189 195 ASSERT(callTable.count(this),"SignOff called for an Observable without Observers."); 190 196 callees_t &callees = callTable[this]; 197 191 198 callees_t::iterator iter; 192 199 callees_t::iterator deliter; -
src/Patterns/Observer.hpp
re58856b rf2a1d3 36 36 typedef Notification *const Notification_ptr; 37 37 38 template<class _Set> 39 class ObservedIterator; 40 38 41 /** 39 42 * An Observer is notified by all Observed objects, when anything changes. … … 53 56 friend class Observable; 54 57 friend class Notification; 58 template<class> friend class ObservedIterator; 59 55 60 public: 56 61 Observer(); … … 152 157 static std::set<Observable*> busyObservables; 153 158 154 155 159 //! @cond 156 160 // Structure for RAII-Style notification … … 164 168 public: 165 169 _Observable_protector(Observable *); 170 _Observable_protector(const _Observable_protector&); 166 171 ~_Observable_protector(); 167 172 private: -
src/Plane.cpp
re58856b rf2a1d3 91 91 offset = normalVector->ScalarProduct(_offsetVector); 92 92 } 93 94 /** 95 * copy constructor 96 */ 97 Plane::Plane(const Plane& plane) : 98 normalVector(new Vector(*plane.normalVector)), 99 offset(plane.offset) 100 {} 101 93 102 94 103 Plane::~Plane() -
src/Plane.hpp
re58856b rf2a1d3 26 26 Plane(const Vector &_normalVector, double _offset) throw(ZeroVectorException); 27 27 Plane(const Vector &_normalVector, const Vector &_offsetVector) throw(ZeroVectorException); 28 Plane(const Plane& plane); 28 29 virtual ~Plane(); 29 30 -
src/UIElements/CommandLineUI/CommandLineDialog.cpp
re58856b rf2a1d3 15 15 #include <Descriptors/MoleculeIdDescriptor.hpp> 16 16 #include "CommandLineUI/CommandLineDialog.hpp" 17 18 #include "Actions/Values.hpp" 17 19 18 20 #include "element.hpp" … … 116 118 117 119 bool CommandLineDialog::BooleanCommandLineQuery::handle() { 118 bool badInput = false; 119 char input = ' '; 120 do{ 121 badInput = false; 122 Log() << Verbose(0) << getTitle(); 123 cin >> input; 124 if ((input == 'y' ) || (input == 'Y')) { 125 tmp = true; 126 } else if ((input == 'n' ) || (input == 'N')) { 127 tmp = false; 128 } else { 129 badInput=true; 130 cin.clear(); 131 cin.ignore(std::numeric_limits<streamsize>::max(),'\n'); 132 Log() << Verbose(0) << "Input was not of [yYnN]!" << endl; 133 } 134 } while(badInput); 135 // clear the input buffer of anything still in the line 136 cin.ignore(std::numeric_limits<streamsize>::max(),'\n'); 137 return true; 120 if (CommandLineParser::getInstance().vm.count(getTitle())) { 121 tmp = CommandLineParser::getInstance().vm[getTitle()].as<bool>(); 122 return true; 123 } else 124 return false; 138 125 } 139 126 … … 192 179 if (CommandLineParser::getInstance().vm.count(getTitle())) { 193 180 IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>(); 194 tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol)); 181 cout << "IdxOfMol " << IdxOfMol << endl; 182 if (IdxOfMol >= 0) 183 tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol)); 184 else 185 tmp = NULL; 195 186 return true; 196 187 } else … … 206 197 207 198 bool CommandLineDialog::VectorCommandLineQuery::handle() { 208 vector<double>temp;209 if (CommandLineParser::getInstance().vm.count(getTitle())) { 210 temp = CommandLineParser::getInstance().vm[getTitle()].as< vector<double>>();211 assert((temp.size() == 3) && "Vector from command line does not have three components.");212 for (int i=0;i<NDIM;i++)213 tmp->at(i) = temp[i];199 VectorValue temp; 200 if (CommandLineParser::getInstance().vm.count(getTitle())) { 201 temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >(); 202 tmp->at(0) = temp.x; 203 tmp->at(1) = temp.y; 204 tmp->at(2) = temp.z; 214 205 return true; 215 206 } else … … 226 217 227 218 bool CommandLineDialog::BoxCommandLineQuery::handle() { 228 vector<double> temp; 229 if (CommandLineParser::getInstance().vm.count(getTitle())) { 230 temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >(); 231 assert((temp.size() == 6) && "Symmetric box matrix from command line does not have six components."); 232 for (int i=0;i<6;i++) 233 tmp[i] = temp[i]; 219 BoxValue temp; 220 if (CommandLineParser::getInstance().vm.count(getTitle())) { 221 temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >(); 222 tmp[0] = temp.xx; 223 tmp[1] = temp.xy; 224 tmp[2] = temp.xz; 225 tmp[3] = temp.yy; 226 tmp[4] = temp.yz; 227 tmp[5] = temp.zz; 234 228 return true; 235 229 } else -
src/UIElements/CommandLineUI/CommandLineWindow.cpp
re58856b rf2a1d3 73 73 CommandLineWindow::~CommandLineWindow() 74 74 { 75 // go through all possible actions76 for(std::map<const std::string,Action*>::iterator ActionRunner = ActionRegistry::getInstance().getBeginIter(); ActionRegistry::getInstance().getBeginIter() != ActionRegistry::getInstance().getEndIter(); ActionRunner = ActionRegistry::getInstance().getBeginIter()) {77 ActionRegistry::getInstance().unregisterAction(ActionRunner->second);78 delete(ActionRunner->second);79 }75 // // go through all possible actions 76 // for(std::map<const std::string,Action*>::iterator ActionRunner = ActionRegistry::getInstance().getBeginIter(); ActionRegistry::getInstance().getBeginIter() != ActionRegistry::getInstance().getEndIter(); ActionRunner = ActionRegistry::getInstance().getBeginIter()) { 77 // ActionRegistry::getInstance().unregisterAction(ActionRunner->second); 78 // delete(ActionRunner->second); 79 // } 80 80 81 81 delete statusIndicator; -
src/UIElements/Dialog.cpp
re58856b rf2a1d3 166 166 target(_target) 167 167 { 168 tmp = new Vector();168 tmp = new Vector(); 169 169 } 170 170 … … 193 193 194 194 void Dialog::BoxQuery::setResult() { 195 for (int i=0;i<6;i++) 196 *target[i] = tmp[i]; 195 for (int i=0;i<6;i++) { 196 (*target)[i] = tmp[i]; 197 } 197 198 } 198 199 -
src/World.cpp
re58856b rf2a1d3 87 87 delete[](defaultName); 88 88 const int length = strlen(name); 89 defaultName = new char[length+2];90 if (length < MAXSTRINGSIZE)89 if (length < MAXSTRINGSIZE) { 90 defaultName = new char[length+2]; 91 91 strncpy(defaultName, name, length); 92 else 93 strcpy(defaultName, "none"); 92 } else { 93 defaultName = new char[MAXSTRINGSIZE]; 94 strncpy(defaultName, "none", MAXSTRINGSIZE-1); 95 } 94 96 }; 95 97 -
src/analysis_bonds.cpp
re58856b rf2a1d3 26 26 Mean = 0.; 27 27 28 atom *Walker = mol->start;29 28 int AtomCount = 0; 30 while (Walker->next != mol->end) { 31 Walker = Walker->next; 32 const int count = Walker->ListOfBonds.size(); 29 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 30 const int count = (*iter)->ListOfBonds.size(); 33 31 if (Max < count) 34 32 Max = count; … … 51 49 * \param &Max maximum distance on return, 0 if no bond between the two elements 52 50 */ 53 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, element *type1,element *type2, double &Min, double &Mean, double &Max)51 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max) 54 52 { 55 53 Min = 2e+6; … … 58 56 59 57 int AtomNo = 0; 60 atom *Walker = mol->start; 61 while (Walker->next != mol->end) { 62 Walker = Walker->next; 63 if (Walker->type == type1) 64 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) 65 if ((*BondRunner)->GetOtherAtom(Walker)->type == type2) { 58 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 59 if ((*iter)->type == type1) 60 for (BondList::const_iterator BondRunner = (*iter)->ListOfBonds.begin(); BondRunner != (*iter)->ListOfBonds.end(); BondRunner++) 61 if ((*BondRunner)->GetOtherAtom((*iter))->type == type2) { 66 62 const double distance = (*BondRunner)->GetDistanceSquared(); 67 63 if (Min > distance) … … 124 120 * \param *InterfaceElement or NULL 125 121 */ 126 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, element * InterfaceElement = NULL) 127 { 128 atom *Walker = NULL; 129 atom *Runner = NULL; 122 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL) 123 { 130 124 int count = 0; 131 125 int OtherHydrogens = 0; … … 133 127 bool InterfaceFlag = false; 134 128 bool OtherHydrogenFlag = true; 135 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) { 136 Walker = (*MolWalker)->start; 137 while (Walker->next != (*MolWalker)->end) { 138 Walker = Walker->next; 139 for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); MolRunner++) { 140 Runner = (*MolRunner)->start; 141 while (Runner->next != (*MolRunner)->end) { 142 Runner = Runner->next; 143 if ((Walker->type->Z == 8) && (Runner->type->Z == 8)) { 129 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); ++MolWalker) { 130 molecule::iterator Walker = (*MolWalker)->begin(); 131 for(;Walker!=(*MolWalker)->end();++Walker){ 132 for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); ++MolRunner) { 133 molecule::iterator Runner = (*MolRunner)->begin(); 134 for(;Runner!=(*MolRunner)->end();++Runner){ 135 if (((*Walker)->type->Z == 8) && ((*Runner)->type->Z == 8)) { 144 136 // check distance 145 const double distance = Runner->x.DistanceSquared(Walker->x);137 const double distance = (*Runner)->x.DistanceSquared((*Walker)->x); 146 138 if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means different atoms 147 139 // on other atom(Runner) we check for bond to interface element and … … 151 143 OtherHydrogens = 0; 152 144 InterfaceFlag = (InterfaceElement == NULL); 153 for (BondList::const_iterator BondRunner = Runner->ListOfBonds.begin(); BondRunner != Runner->ListOfBonds.end(); BondRunner++) {154 atom * const OtherAtom = (*BondRunner)->GetOtherAtom( Runner);145 for (BondList::const_iterator BondRunner = (*Runner)->ListOfBonds.begin(); BondRunner != (*Runner)->ListOfBonds.end(); BondRunner++) { 146 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Runner); 155 147 // if hydrogen, check angle to be greater(!) than 30 degrees 156 148 if (OtherAtom->type->Z == 1) { 157 const double angle = CalculateAngle(&OtherAtom->x, & Runner->x, &Walker->x);149 const double angle = CalculateAngle(&OtherAtom->x, &(*Runner)->x, &(*Walker)->x); 158 150 OtherHydrogenFlag = OtherHydrogenFlag && (angle > M_PI*(30./180.) + MYEPSILON); 159 151 Otherangle += angle; … … 176 168 if (InterfaceFlag && OtherHydrogenFlag) { 177 169 // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule 178 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {179 atom * const OtherAtom = (*BondRunner)->GetOtherAtom( Walker);170 for (BondList::const_iterator BondRunner = (*Walker)->ListOfBonds.begin(); BondRunner != (*Walker)->ListOfBonds.end(); BondRunner++) { 171 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Walker); 180 172 if (OtherAtom->type->Z == 1) { 181 173 // check angle 182 if (CheckHydrogenBridgeBondAngle( Walker, OtherAtom,Runner)) {183 DoLog(1) && (Log() << Verbose(1) << Walker->Name << ", " << OtherAtom->Name << " and " << Runner->Name << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle(&OtherAtom->x, &Walker->x, &Runner->x)*(180./M_PI) << "." << endl);174 if (CheckHydrogenBridgeBondAngle(*Walker, OtherAtom, *Runner)) { 175 DoLog(1) && (Log() << Verbose(1) << (*Walker)->getName() << ", " << OtherAtom->getName() << " and " << (*Runner)->getName() << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle(&OtherAtom->x, &(*Walker)->x, &(*Runner)->x)*(180./M_PI) << "." << endl); 184 176 count++; 185 177 break; … … 205 197 int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second) 206 198 { 207 atom *Walker = NULL;208 199 int count = 0; 209 200 210 201 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) { 211 Walker = (*MolWalker)->start;212 while (Walker->next != (*MolWalker)->end){213 Walker = Walker->next;214 if (( Walker->type == first) || (Walker->type == second)) { // first element matches215 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {216 atom * const OtherAtom = (*BondRunner)->GetOtherAtom( Walker);217 if (((OtherAtom->type == first) || (OtherAtom->type == second)) && ( Walker->nr < OtherAtom->nr)) {202 molecule::iterator Walker = (*MolWalker)->begin(); 203 for(;Walker!=(*MolWalker)->end();++Walker){ 204 atom * theAtom = *Walker; 205 if ((theAtom->type == first) || (theAtom->type == second)) { // first element matches 206 for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) { 207 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom); 208 if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (theAtom->nr < OtherAtom->nr)) { 218 209 count++; 219 210 DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl); … … 240 231 bool MatchFlag[2]; 241 232 bool result = false; 242 atom *Walker = NULL;243 233 const element * ElementArray[2]; 244 234 ElementArray[0] = first; … … 246 236 247 237 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) { 248 Walker = (*MolWalker)->start;249 while (Walker->next != (*MolWalker)->end){250 Walker = Walker->next;251 if ( Walker->type == second) { // first element matches238 molecule::iterator Walker = (*MolWalker)->begin(); 239 for(;Walker!=(*MolWalker)->end();++Walker){ 240 atom *theAtom = *Walker; 241 if (theAtom->type == second) { // first element matches 252 242 for (int i=0;i<2;i++) 253 243 MatchFlag[i] = false; 254 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {255 atom * const OtherAtom = (*BondRunner)->GetOtherAtom( Walker);244 for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) { 245 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom); 256 246 for (int i=0;i<2;i++) 257 247 if ((!MatchFlag[i]) && (OtherAtom->type == ElementArray[i])) { -
src/analysis_bonds.hpp
re58856b rf2a1d3 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
re58856b rf2a1d3 39 39 return outmap; 40 40 } 41 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 42 (*MolWalker)->doCountAtoms(); 41 43 outmap = new PairCorrelationMap; 42 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 44 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){ 43 45 if ((*MolWalker)->ActiveFlag) { 44 46 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++) 47 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 48 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 49 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 50 if ((type1 == NULL) || ((*iter)->type == type1)) { 51 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){ 51 52 if ((*MolOtherWalker)->ActiveFlag) { 52 53 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) ) ); 54 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 55 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 56 if ((*iter)->getId() < (*runner)->getId()){ 57 if ((type2 == NULL) || ((*runner)->type == type2)) { 58 distance = (*iter)->node->PeriodicDistance(*(*runner)->node, World::getInstance().getDomain()); 59 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 60 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); 62 61 } 62 } 63 63 } 64 } 64 65 } 65 66 } 66 67 } 67 68 } 68 69 } 69 70 return outmap; 70 71 }; … … 95 96 return outmap; 96 97 } 98 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 99 (*MolWalker)->doCountAtoms(); 97 100 outmap = new PairCorrelationMap; 98 101 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) … … 101 104 double * FullInverseMatrix = InverseMatrix(FullMatrix); 102 105 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); 106 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 107 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 108 if ((type1 == NULL) || ((*iter)->type == type1)) { 109 periodicX = *(*iter)->node; 109 110 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 110 111 // go through every range in xyz and get distance … … 117 118 if ((*MolOtherWalker)->ActiveFlag) { 118 119 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); 120 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 121 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 122 if ((*iter)->nr < (*runner)->nr) 123 if ((type2 == NULL) || ((*runner)->type == type2)) { 124 periodicOtherX = *(*runner)->node; 126 125 periodicOtherX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 127 126 // go through every range in xyz and get distance … … 132 131 checkOtherX.MatrixMultiplication(FullMatrix); 133 132 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) ) );133 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 134 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); 136 135 } 137 136 } … … 141 140 } 142 141 } 143 Free(&FullMatrix);144 Free(&FullInverseMatrix);142 delete[](FullMatrix); 143 delete[](FullInverseMatrix); 145 144 } 146 145 … … 165 164 return outmap; 166 165 } 166 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 167 (*MolWalker)->doCountAtoms(); 167 168 outmap = new CorrelationToPointMap; 168 169 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 169 170 if ((*MolWalker)->ActiveFlag) { 170 171 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()); 172 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 173 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 174 if ((type == NULL) || ((*iter)->type == type)) { 175 distance = (*iter)->node->PeriodicDistance(*point, World::getInstance().getDomain()); 177 176 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) ) );177 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) ); 179 178 } 180 179 } … … 205 204 return outmap; 206 205 } 206 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 207 (*MolWalker)->doCountAtoms(); 207 208 outmap = new CorrelationToPointMap; 208 209 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) … … 211 212 double * FullInverseMatrix = InverseMatrix(FullMatrix); 212 213 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); 214 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 215 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 216 if ((type == NULL) || ((*iter)->type == type)) { 217 periodicX = *(*iter)->node; 219 218 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 220 219 // go through every range in xyz and get distance … … 226 225 distance = checkX.distance(*point); 227 226 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) ) );227 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) ); 229 228 } 230 229 } 231 230 } 232 Free(&FullMatrix);233 Free(&FullInverseMatrix);231 delete[](FullMatrix); 232 delete[](FullInverseMatrix); 234 233 } 235 234 … … 257 256 return outmap; 258 257 } 258 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 259 (*MolWalker)->doCountAtoms(); 259 260 outmap = new CorrelationToSurfaceMap; 260 261 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 261 262 if ((*MolWalker)->ActiveFlag) { 262 263 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);264 if ((*MolWalker)->empty()) 265 DoLog(1) && (1) && (Log() << Verbose(1) << "\t is empty." << endl); 266 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 267 DoLog(1) && (Log() << Verbose(1) << "\tCurrent atom is " << *(*iter) << "." << endl); 268 if ((type == NULL) || ((*iter)->type == type)) { 269 TriangleIntersectionList Intersections((*iter)->node,Surface,LC); 269 270 distance = Intersections.GetSmallestDistance(); 270 271 triangle = Intersections.GetClosestTriangle(); 271 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ( Walker, triangle) ) );272 } 273 } 274 } else 272 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) ); 273 } 274 } 275 } else { 275 276 DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl); 277 } 276 278 277 279 return outmap; … … 306 308 return outmap; 307 309 } 310 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 311 (*MolWalker)->doCountAtoms(); 308 312 outmap = new CorrelationToSurfaceMap; 309 313 double ShortestDistance = 0.; … … 314 318 double * FullInverseMatrix = InverseMatrix(FullMatrix); 315 319 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); 320 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 321 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 322 if ((type == NULL) || ((*iter)->type == type)) { 323 periodicX = *(*iter)->node; 322 324 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 323 325 // go through every range in xyz and get distance … … 337 339 } 338 340 // insert 339 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> ( Walker, ShortestTriangle) ) );341 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) ); 340 342 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; 341 343 } 342 344 } 343 Free(&FullMatrix);344 Free(&FullInverseMatrix);345 delete[](FullMatrix); 346 delete[](FullInverseMatrix); 345 347 } 346 348 -
src/analyzer.cpp
re58856b rf2a1d3 75 75 return 1; 76 76 } else { 77 dir = Malloc<char>(strlen(argv[2]) + 2, "main: *dir");77 dir = new char[strlen(argv[2]) + 2]; 78 78 strcpy(dir, "/"); 79 79 strcat(dir, argv[2]); … … 82 82 if (argc > 4) { 83 83 DoLog(0) && (Log() << Verbose(0) << "Loading periodentafel." << endl); 84 periode = Malloc<periodentafel>(1, "main - periode");84 periode = new periodentafel; 85 85 periode->LoadPeriodentafel(argv[4]); 86 86 } … … 558 558 // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++ 559 559 delete(periode); 560 Free(&dir);560 delete[](dir); 561 561 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 562 562 return 0; -
src/atom.cpp
re58856b rf2a1d3 40 40 41 41 atom *atom::clone(){ 42 atom *res = new atom( );42 atom *res = new atom(this); 43 43 res->previous=0; 44 44 res->next=0; … … 59 59 atom::~atom() 60 60 { 61 unlink(this);62 61 }; 63 62 … … 270 269 { 271 270 if (ComponentNr != NULL) 272 Free(&ComponentNr);273 ComponentNr = Malloc<int>(ListOfBonds.size()+1, "atom::InitComponentNumbers: *ComponentNr");271 delete[](ComponentNr); 272 ComponentNr = new int[ListOfBonds.size()+1]; 274 273 for (int i=ListOfBonds.size()+1;i--;) 275 274 ComponentNr[i] = -1; -
src/atom_bondedparticle.cpp
re58856b rf2a1d3 44 44 void BondedParticle::OutputBondOfAtom() const 45 45 { 46 DoLog(4) && (Log() << Verbose(4) << "Atom " << Name<< "/" << nr << " with " << ListOfBonds.size() << " bonds: " << endl);46 DoLog(4) && (Log() << Verbose(4) << "Atom " << getName() << "/" << nr << " with " << ListOfBonds.size() << " bonds: " << endl); 47 47 int TotalDegree = 0; 48 48 for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); ++Runner) { -
src/atom_graphnode.cpp
re58856b rf2a1d3 27 27 void GraphNode::OutputGraphInfo() const 28 28 { 29 DoLog(2) && (Log() << Verbose(2) << "Atom " << Name<< " is " << ((SeparationVertex) ? "a" : "not a") << " separation vertex, components are ");29 DoLog(2) && (Log() << Verbose(2) << "Atom " << getName() << " is " << ((SeparationVertex) ? "a" : "not a") << " separation vertex, components are "); 30 30 OutputComponentNumber(); 31 31 DoLog(3) && (Log() << Verbose(3) << " with Lowpoint " << LowpointNr << " and Graph Nr. " << GraphNr << "." << endl); -
src/atom_graphnodeinfo.cpp
re58856b rf2a1d3 17 17 GraphNodeInfo::~GraphNodeInfo() 18 18 { 19 Free<int>(&ComponentNr, "atom::~atom: *ComponentNr");19 delete[](ComponentNr); 20 20 }; -
src/atom_particleinfo.cpp
re58856b rf2a1d3 11 11 /** Constructor of ParticleInfo. 12 12 */ 13 ParticleInfo::ParticleInfo() : nr(-1), Name(NULL) {}; 13 ParticleInfo::ParticleInfo() : nr(-1), name("Unknown") { 14 }; 14 15 15 16 ParticleInfo::ParticleInfo(ParticleInfo *pointer) : 16 17 nr(pointer->nr), 17 Name(pointer->Name) 18 { 19 if (Name == NULL) 20 Name = " "; 21 } 18 name(pointer->name) 19 {} 22 20 23 21 … … 25 23 */ 26 24 ParticleInfo::~ParticleInfo() 27 { 28 Free(&Name); 29 }; 25 {}; 26 27 const string& ParticleInfo::getName() const{ 28 return name; 29 } 30 31 void ParticleInfo::setName(const string& _name){ 32 name = _name; 33 } 30 34 31 35 ostream & operator << (ostream &ost, const ParticleInfo &a) 32 36 { 33 if (a.Name == NULL) 34 ost << "[NULL]"; 35 else 36 ost << "[" << a.Name << "|" << &a << "]"; 37 ost << "[" << a.getName() << "|" << &a << "]"; 37 38 return ost; 38 39 }; … … 40 41 ostream & ParticleInfo::operator << (ostream &ost) const 41 42 { 42 if (Name == NULL) 43 ost << "[NULL]"; 44 else 45 ost << "[" << Name << "|" << this << "]"; 43 ost << "[" << name << "|" << this << "]"; 46 44 return ost; 47 45 }; -
src/atom_particleinfo.hpp
re58856b rf2a1d3 28 28 public: 29 29 int nr; // index to easierly identify 30 char *Name; // some name to reference to on output31 30 32 31 ParticleInfo(); … … 34 33 ~ParticleInfo(); 35 34 35 const std::string& getName() const; 36 void setName(const std::string&); 37 36 38 ostream & operator << (ostream &ost) const; 37 39 38 40 private: 41 std::string name; // some name to reference to on output 39 42 }; 40 43 -
src/atom_trajectoryparticle.cpp
re58856b rf2a1d3 10 10 #include "config.hpp" 11 11 #include "element.hpp" 12 #include "info.hpp" 12 13 #include "log.hpp" 13 14 #include "parser.hpp" … … 71 72 void TrajectoryParticle::ResizeTrajectory(int MaxSteps) 72 73 { 74 Info FunctionInfo(__func__); 73 75 if (Trajectory.R.size() <= (unsigned int)(MaxSteps)) { 74 //Log() << Verbose(0) << "Increasing size for trajectory array of " << keyword << " to " << (MaxSteps+1) << "." << endl;76 DoLog(0) && (Log() << Verbose(0) << "Increasing size for trajectory array of " << nr << " from " << Trajectory.R.size() << " to " << (MaxSteps+1) << "." << endl); 75 77 Trajectory.R.resize(MaxSteps+1); 76 78 Trajectory.U.resize(MaxSteps+1); -
src/bond.cpp
re58856b rf2a1d3 53 53 ostream & operator << (ostream &ost, const bond &b) 54 54 { 55 ost << "[" << b.leftatom-> Name << " <" << b.BondDegree << "(H" << b.HydrogenBond << ")>" << b.rightatom->Name<< "]";55 ost << "[" << b.leftatom->getName() << " <" << b.BondDegree << "(H" << b.HydrogenBond << ")>" << b.rightatom->getName() << "]"; 56 56 return ost; 57 57 }; -
src/bondgraph.cpp
re58856b rf2a1d3 88 88 { 89 89 Info FunctionInfo(__func__); 90 bool status = true;90 bool status = true; 91 91 92 if (mol-> start->next == mol->end) // only construct if molecule is not empty92 if (mol->empty()) // only construct if molecule is not empty 93 93 return false; 94 94 … … 124 124 max_distance = 0.; 125 125 126 atom *Runner = mol->start; 127 while (Runner->next != mol->end) { 128 Runner = Runner->next; 129 if (Runner->type->CovalentRadius > max_distance) 130 max_distance = Runner->type->CovalentRadius; 126 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 127 if ((*iter)->type->CovalentRadius > max_distance) 128 max_distance = (*iter)->type->CovalentRadius; 131 129 } 132 130 max_distance *= 2.; -
src/boundary.cpp
re58856b rf2a1d3 139 139 { 140 140 Info FunctionInfo(__func__); 141 atom *Walker = NULL;142 141 PointMap PointsOnBoundary; 143 142 LineMap LinesOnBoundary; … … 165 164 166 165 // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours 167 Walker = mol->start; 168 while (Walker->next != mol->end) { 169 Walker = Walker->next; 170 ProjectedVector = Walker->x - (*MolCenter); 166 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 167 ProjectedVector = (*iter)->x - (*MolCenter); 171 168 ProjectedVector.ProjectOntoPlane(AxisVector); 172 169 … … 182 179 angle = 2. * M_PI - angle; 183 180 } 184 DoLog(1) && (Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);185 BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, Walker)));181 DoLog(1) && (Log() << Verbose(1) << "Inserting " << **iter << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl); 182 BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, (*iter)))); 186 183 if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity 187 184 DoLog(2) && (Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl); 188 185 DoLog(2) && (Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl); 189 DoLog(2) && (Log() << Verbose(2) << "New vector: " << * Walker << endl);186 DoLog(2) && (Log() << Verbose(2) << "New vector: " << **iter << endl); 190 187 const double ProjectedVectorNorm = ProjectedVector.NormSquared(); 191 188 if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) { 192 189 BoundaryTestPair.first->second.first = ProjectedVectorNorm; 193 BoundaryTestPair.first->second.second = Walker;190 BoundaryTestPair.first->second.second = (*iter); 194 191 DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl); 195 192 } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) { 196 helper = Walker->x - (*MolCenter); 193 helper = (*iter)->x; 194 helper -= *MolCenter; 197 195 const double oldhelperNorm = helper.NormSquared(); 198 196 helper = BoundaryTestPair.first->second.second->x - (*MolCenter); 199 197 if (helper.NormSquared() < oldhelperNorm) { 200 BoundaryTestPair.first->second.second = Walker;198 BoundaryTestPair.first->second.second = (*iter); 201 199 DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl); 202 200 } else { … … 226 224 do { // do as long as we still throw one out per round 227 225 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++) { 226 Boundaries::iterator left = BoundaryPoints[axis].begin(); 227 Boundaries::iterator right = BoundaryPoints[axis].begin(); 228 Boundaries::iterator runner = BoundaryPoints[axis].begin(); 229 bool LoopOnceDone = false; 230 while (!LoopOnceDone) { 231 runner = right; 232 right++; 231 233 // set neighbours correctly 232 234 if (runner == BoundaryPoints[axis].begin()) { … … 236 238 } 237 239 left--; 238 right = runner;239 right++;240 240 if (right == BoundaryPoints[axis].end()) { 241 241 right = BoundaryPoints[axis].begin(); 242 LoopOnceDone = true; 242 243 } 243 244 // check distance … … 279 280 DoLog(1) && (Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl); 280 281 BoundaryPoints[axis].erase(runner); 282 runner = right; 281 283 flag = true; 282 284 } … … 359 361 360 362 // 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 } 363 StoreTrianglesinFile(mol, TesselStruct, filename, "_intermed"); 381 364 382 365 // 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 380 TesselStruct->FlipBaseline(line); 398 381 DoLog(1) && (Log() << Verbose(1) << "INFO: Correction of concave baselines worked." << endl); 382 LineRunner = TesselStruct->LinesOnBoundary.begin(); // LineRunner may have been erase if line was deleted from LinesOnBoundary 399 383 } 400 384 } … … 409 393 410 394 // 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 395 StoreTrianglesinFile(mol, TesselStruct, filename, ""); 430 396 431 397 // free reference lists … … 620 586 for (TriangleMap::iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++) 621 587 { // go through every triangle, calculate volume of its pyramid with CoG as peak 622 x = (*runner->second->endpoints[0]->node->node) - (*runner->second->endpoints[1]->node->node);623 y = (*runner->second->endpoints[0]->node->node) - (*runner->second->endpoints[2]->node->node);624 const double a = sqrt(runner->second->endpoints[0]->node->node->DistanceSquared(*runner->second->endpoints[1]->node->node));625 const double b = sqrt(runner->second->endpoints[0]->node->node->DistanceSquared(*runner->second->endpoints[2]->node->node));626 const double c = sqrt(runner->second->endpoints[2]->node->node->DistanceSquared(*runner->second->endpoints[1]->node->node));588 x = runner->second->getEndpoint(0) - runner->second->getEndpoint(1); 589 y = runner->second->getEndpoint(0) - runner->second->getEndpoint(2); 590 const double a = x.Norm(); 591 const double b = y.Norm(); 592 const double c = runner->second->getEndpoint(2).distance(runner->second->getEndpoint(1)); 627 593 const double G = sqrt(((a + b + c) * (a + b + c) - 2 * (a * a + b * b + c * c)) / 16.); // area of tesselated triangle 628 x = Plane(*(runner->second->endpoints[0]->node->node), 629 *(runner->second->endpoints[1]->node->node), 630 *(runner->second->endpoints[2]->node->node)).getNormal(); 631 x.Scale(runner->second->endpoints[1]->node->node->ScalarProduct(x)); 594 x = runner->second->getPlane().getNormal(); 595 x.Scale(runner->second->getEndpoint(1).ScalarProduct(x)); 632 596 const double h = x.Norm(); // distance of CoG to triangle 633 597 const double PyramidVolume = (1. / 3.) * G * h; // this formula holds for _all_ pyramids (independent of n-edge base or (not) centered peak) … … 680 644 /** Creates multiples of the by \a *mol given cluster and suspends them in water with a given final density. 681 645 * We get cluster volume by VolumeOfConvexEnvelope() and its diameters by GetDiametersOfCluster() 646 * TODO: Here, we need a VolumeOfGeneralEnvelope (i.e. non-convex one) 682 647 * \param *out output stream for debugging 683 648 * \param *configuration needed for path to store convex envelope file … … 697 662 int repetition[NDIM] = { 1, 1, 1 }; 698 663 int TotalNoClusters = 1; 699 atom *Walker = NULL;700 664 double totalmass = 0.; 701 665 double clustervolume = 0.; … … 708 672 GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem); 709 673 BoundaryPoints = GetBoundaryPoints(mol, TesselStruct); 710 LinkedCell LCList(mol, 10.); 711 FindConvexBorder(mol, TesselStruct, &LCList, NULL); 674 LinkedCell *LCList = new LinkedCell(mol, 10.); 675 FindConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, NULL); 676 delete (LCList); 677 712 678 713 679 // some preparations beforehand … … 721 687 722 688 // sum up the atomic masses 723 Walker = mol->start; 724 while (Walker->next != mol->end) { 725 Walker = Walker->next; 726 totalmass += Walker->type->mass; 689 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 690 totalmass += (*iter)->type->mass; 727 691 } 728 692 DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl); … … 806 770 Vector Inserter; 807 771 double FillIt = false; 808 atom *Walker = NULL;809 772 bond *Binder = NULL; 810 773 double phi[NDIM]; … … 813 776 814 777 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) 815 if ((*ListRunner)-> AtomCount> 0) {778 if ((*ListRunner)->getAtomCount() > 0) { 816 779 DoLog(1) && (Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl); 817 780 LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list … … 824 787 filler->CenterEdge(&Inserter); 825 788 filler->Center.Zero(); 789 const int FillerCount = filler->getAtomCount(); 826 790 DoLog(2) && (Log() << Verbose(2) << "INFO: Filler molecule has the following bonds:" << endl); 827 Binder = filler->first; 828 while(Binder->next != filler->last) { 829 Binder = Binder->next; 830 DoLog(2) && (Log() << Verbose(2) << " " << *Binder << endl); 831 } 832 833 filler->CountAtoms(); 834 atom * CopyAtoms[filler->AtomCount]; 791 for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner) 792 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 793 if ((*BondRunner)->leftatom == *AtomRunner) 794 DoLog(2) && (Log() << Verbose(2) << " " << *(*BondRunner) << endl); 795 796 atom * CopyAtoms[FillerCount]; 835 797 836 798 // calculate filler grid in [0,1]^3 … … 857 819 858 820 // go through all atoms 859 for (int i=0;i< filler->AtomCount;i++)821 for (int i=0;i<FillerCount;i++) 860 822 CopyAtoms[i] = NULL; 861 Walker = filler->start; 862 while (Walker->next != filler->end) { 863 Walker = Walker->next; 823 for(molecule::const_iterator iter = filler->begin(); iter !=filler->end();++iter){ 864 824 865 825 // create atomic random translation vector ... … … 885 845 886 846 // ... and put at new position 887 Inserter = Walker->x;847 Inserter = (*iter)->x; 888 848 if (DoRandomRotation) 889 849 Inserter.MatrixMultiplication(Rotations); … … 909 869 DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl); 910 870 // copy atom ... 911 CopyAtoms[ Walker->nr] = Walker->clone();912 CopyAtoms[ Walker->nr]->x = Inserter;913 Filling->AddAtom(CopyAtoms[ Walker->nr]);914 DoLog(4) && (Log() << Verbose(4) << "Filling atom " << * Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl);871 CopyAtoms[(*iter)->nr] = (*iter)->clone(); 872 CopyAtoms[(*iter)->nr]->x = Inserter; 873 Filling->AddAtom(CopyAtoms[(*iter)->nr]); 874 DoLog(4) && (Log() << Verbose(4) << "Filling atom " << **iter << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[(*iter)->nr]->x) << "." << endl); 915 875 } else { 916 876 DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl); 917 CopyAtoms[ Walker->nr] = NULL;877 CopyAtoms[(*iter)->nr] = NULL; 918 878 continue; 919 879 } 920 880 } 921 881 // go through all bonds and add as well 922 Binder = filler->first; 923 while(Binder->next != filler->last) { 924 Binder = Binder->next; 925 if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) { 926 Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl; 927 Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree); 928 } 929 } 882 for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner) 883 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 884 if ((*BondRunner)->leftatom == *AtomRunner) { 885 Binder = (*BondRunner); 886 if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) { 887 Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl; 888 Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree); 889 } 890 } 930 891 } 931 Free(&M);932 Free(&MInverse);892 delete[](M); 893 delete[](MInverse); 933 894 934 895 return Filling; … … 954 915 bool TesselationFailFlag = false; 955 916 917 mol->getAtomCount(); 918 956 919 if (TesselStruct == NULL) { 957 920 DoLog(1) && (Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl); … … 1025 988 // // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles 1026 989 // //->InsertStraddlingPoints(mol, LCList); 1027 // mol->GoToFirst();990 // for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1028 991 // class TesselPoint *Runner = NULL; 1029 // while (!mol->IsEnd()) { 1030 // Runner = mol->GetPoint(); 992 // Runner = *iter; 1031 993 // Log() << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl; 1032 994 // if (!->IsInnerPoint(Runner, LCList)) { … … 1036 998 // Log() << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl; 1037 999 // } 1038 // mol->GoToNext();1039 1000 // } 1040 1001 … … 1045 1006 status = CheckListOfBaselines(TesselStruct); 1046 1007 1008 cout << "before correction" << endl; 1009 1047 1010 // store before correction 1048 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");1011 StoreTrianglesinFile(mol, TesselStruct, filename, ""); 1049 1012 1050 1013 // // correct degenerated polygons … … 1056 1019 // write final envelope 1057 1020 CalculateConcavityPerBoundaryPoint(TesselStruct); 1058 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, ""); 1021 cout << "after correction" << endl; 1022 StoreTrianglesinFile(mol, TesselStruct, filename, ""); 1059 1023 1060 1024 if (freeLC) -
src/builder.cpp
re58856b rf2a1d3 53 53 54 54 #include <cstring> 55 #include <cstdlib> 55 56 56 57 #include "analysis_bonds.hpp" … … 864 865 865 866 mol->CountAtoms(); // recount atoms 866 if (mol-> AtomCount!= 0) { // if there is more than none867 count = mol-> AtomCount; // is changed becausing of adding, thus has to be stored away beforehand867 if (mol->getAtomCount() != 0) { // if there is more than none 868 count = mol->getAtomCount(); // is changed becausing of adding, thus has to be stored away beforehand 868 869 Elements = new element *[count]; 869 870 vectors = new Vector *[count]; … … 1295 1296 // generate some KeySets 1296 1297 DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl); 1297 KeySet TestSets[mol-> AtomCount+1];1298 KeySet TestSets[mol->getAtomCount()+1]; 1298 1299 i=1; 1299 1300 while (Walker->next != mol->end) { … … 1306 1307 DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl); 1307 1308 KeySetTestPair test; 1308 test = TestSets[mol-> AtomCount-1].insert(Walker->nr);1309 test = TestSets[mol->getAtomCount()-1].insert(Walker->nr); 1309 1310 if (test.second) { 1310 1311 DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl); … … 1312 1313 DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl); 1313 1314 } 1314 TestSets[mol-> AtomCount].insert(mol->end->previous->nr);1315 TestSets[mol-> AtomCount].insert(mol->end->previous->previous->previous->nr);1315 TestSets[mol->getAtomCount()].insert(mol->end->previous->nr); 1316 TestSets[mol->getAtomCount()].insert(mol->end->previous->previous->previous->nr); 1316 1317 1317 1318 // constructing Graph structure … … 1321 1322 // insert KeySets into Subgraphs 1322 1323 DoLog(0) && (Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl); 1323 for (int j=0;j<mol-> AtomCount;j++) {1324 for (int j=0;j<mol->getAtomCount();j++) { 1324 1325 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.))); 1325 1326 } 1326 1327 DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl); 1327 1328 GraphTestPair test2; 1328 test2 = Subgraphs.insert(GraphPair (TestSets[mol-> AtomCount],pair<int, double>(counter++, 1.)));1329 test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.))); 1329 1330 if (test2.second) { 1330 1331 DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl); … … 1494 1495 */ 1495 1496 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode, 1496 config& configuration, char * &ConfigFileName, set<int> &ArgcList)1497 config& configuration, char **ConfigFileName, set<int> &ArgcList) 1497 1498 { 1498 1499 Vector x,y,z,n; // coordinates for absolute point in cell volume … … 1512 1513 molecule *mol = NULL; 1513 1514 string BondGraphFileName("\n"); 1514 strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1);1515 bool DatabasePathGiven = false; 1515 1516 1516 1517 if (argc > 1) { // config file specified as option … … 1529 1530 break; 1530 1531 case 'v': 1531 ArgcList.insert(argptr-1); 1532 return(1); 1533 break; 1534 case 'V': 1532 setVerbosity(atoi(argv[argptr])); 1535 1533 ArgcList.insert(argptr-1); 1536 1534 ArgcList.insert(argptr); 1537 1535 argptr++; 1538 1536 break; 1537 case 'V': 1538 ArgcList.insert(argptr-1); 1539 return(1); 1540 break; 1539 1541 case 'B': 1542 ArgcList.insert(argptr-1); 1543 ArgcList.insert(argptr); 1544 ArgcList.insert(argptr+1); 1545 ArgcList.insert(argptr+2); 1546 ArgcList.insert(argptr+3); 1547 ArgcList.insert(argptr+4); 1548 ArgcList.insert(argptr+5); 1549 argptr+=6; 1540 1550 if (ExitFlag == 0) ExitFlag = 1; 1541 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])) ) {1542 ExitFlag = 255;1543 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl);1544 performCriticalExit();1545 } else {1546 SaveFlag = true;1547 j = -1;1548 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);1549 double * const cell_size = World::getInstance().getDomain();1550 for (int i=0;i<6;i++) {1551 cell_size[i] = atof(argv[argptr+i]);1552 }1553 argptr+=6;1554 }1555 1551 break; 1556 1552 case 'e': … … 1561 1557 DoLog(0) && (Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl); 1562 1558 strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1); 1559 DatabasePathGiven = true; 1563 1560 argptr+=1; 1564 1561 } … … 1574 1571 } 1575 1572 break; 1573 case 'M': 1574 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1575 ExitFlag = 255; 1576 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -M <basis name>" << endl); 1577 performCriticalExit(); 1578 } else { 1579 configuration.basis = argv[argptr]; 1580 DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl); 1581 argptr+=1; 1582 } 1583 break; 1576 1584 case 'n': 1577 1585 DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl); … … 1581 1589 { 1582 1590 World::getInstance().setDefaultName(argv[argptr]); 1583 DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << *World::getInstance().getDefaultName() << "." << endl);1591 DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << World::getInstance().getDefaultName() << "." << endl); 1584 1592 } 1585 1593 break; … … 1593 1601 1594 1602 // 3a. Parse the element database 1595 if (periode->LoadPeriodentafel(configuration.databasepath)) { 1596 DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl); 1597 //periode->Output(); 1598 } else { 1599 DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl); 1600 return 1; 1601 } 1603 if (DatabasePathGiven) 1604 if (periode->LoadPeriodentafel(configuration.databasepath)) { 1605 DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl); 1606 //periode->Output(); 1607 } else { 1608 DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl); 1609 return 1; 1610 } 1602 1611 // 3b. Find config file name and parse if possible, also BondGraphFileName 1603 1612 if (argv[1][0] != '-') { … … 1613 1622 } else { 1614 1623 DoLog(0) && (Log() << Verbose(0) << "Empty configuration file." << endl); 1615 ConfigFileName = argv[1];1624 strcpy(*ConfigFileName, argv[1]); 1616 1625 configPresent = empty; 1617 1626 output.close(); … … 1619 1628 } else { 1620 1629 test.close(); 1621 ConfigFileName = argv[1];1630 strcpy(*ConfigFileName, argv[1]); 1622 1631 DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... "); 1623 switch (configuration.TestSyntax( ConfigFileName, periode)) {1632 switch (configuration.TestSyntax(*ConfigFileName, periode)) { 1624 1633 case 1: 1625 1634 DoLog(0) && (Log() << Verbose(0) << "new syntax." << endl); 1626 configuration.Load( ConfigFileName, BondGraphFileName, periode, molecules);1635 configuration.Load(*ConfigFileName, BondGraphFileName, periode, molecules); 1627 1636 configPresent = present; 1628 1637 break; 1629 1638 case 0: 1630 1639 DoLog(0) && (Log() << Verbose(0) << "old syntax." << endl); 1631 configuration.LoadOld( ConfigFileName, BondGraphFileName, periode, molecules);1640 configuration.LoadOld(*ConfigFileName, BondGraphFileName, periode, molecules); 1632 1641 configPresent = present; 1633 1642 break; … … 1650 1659 mol = World::getInstance().createMolecule(); 1651 1660 mol->ActiveFlag = true; 1652 if ( ConfigFileName != NULL)1653 mol->SetNameFromFilename( ConfigFileName);1661 if (*ConfigFileName != NULL) 1662 mol->SetNameFromFilename(*ConfigFileName); 1654 1663 molecules->insert(mol); 1655 1664 } … … 1705 1714 if (first->type != NULL) { 1706 1715 mol->AddAtom(first); // add to molecule 1707 if ((configPresent == empty) && (mol-> AtomCount!= 0))1716 if ((configPresent == empty) && (mol->getAtomCount() != 0)) 1708 1717 configPresent = present; 1709 1718 } else … … 1718 1727 if (configPresent == present) { 1719 1728 switch(argv[argptr-1][1]) { 1720 case 'M':1721 if ((argptr >= argc) || (argv[argptr][0] == '-')) {1722 ExitFlag = 255;1723 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl);1724 performCriticalExit();1725 } else {1726 configuration.basis = argv[argptr];1727 DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl);1728 argptr+=1;1729 }1730 break;1731 1729 case 'D': 1732 1730 if (ExitFlag == 0) ExitFlag = 1; … … 1734 1732 DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl); 1735 1733 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 1736 int *MinimumRingSize = new int[mol-> AtomCount];1734 int *MinimumRingSize = new int[mol->getAtomCount()]; 1737 1735 atom ***ListOfLocalAtoms = NULL; 1738 1736 class StackClass<bond *> *BackEdgeStack = NULL; … … 1754 1752 delete(Subgraphs); 1755 1753 for (int i=0;i<FragmentCounter;i++) 1756 Free(&ListOfLocalAtoms[i]);1757 Free(&ListOfLocalAtoms);1754 delete[](ListOfLocalAtoms[i]); 1755 delete[](ListOfLocalAtoms); 1758 1756 } 1759 1757 delete(BackEdgeStack); … … 1795 1793 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] == '-')) { 1796 1794 ExitFlag = 255; 1797 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C E <Z1> <Z2> <output> <bin output> " << endl);1795 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C E <Z1> <Z2> <output> <bin output> <binstart> <binend>" << endl); 1798 1796 performCriticalExit(); 1799 1797 } else { … … 1810 1808 else 1811 1809 correlationmap = PairCorrelation(molecules, elemental, elemental2); 1812 //OutputCorrelationToSurface(&output, correlationmap);1810 OutputPairCorrelation(&output, correlationmap); 1813 1811 BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd ); 1814 1812 OutputCorrelation ( &binoutput, binmap ); … … 1826 1824 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] == '-')) { 1827 1825 ExitFlag = 255; 1828 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);1826 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C P <Z1> <x> <y> <z> <output> <bin output> <binstart> <binend>" << endl); 1829 1827 performCriticalExit(); 1830 1828 } else { … … 1841 1839 else 1842 1840 correlationmap = CorrelationToPoint(molecules, elemental, Point); 1843 //OutputCorrelationToSurface(&output, correlationmap);1841 OutputCorrelationToPoint(&output, correlationmap); 1844 1842 BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd ); 1845 1843 OutputCorrelation ( &binoutput, binmap ); … … 1882 1880 int counter = 0; 1883 1881 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 1884 if ((Boundary == NULL) || (Boundary-> AtomCount < (*BigFinder)->AtomCount)) {1882 if ((Boundary == NULL) || (Boundary->getAtomCount() < (*BigFinder)->getAtomCount())) { 1885 1883 Boundary = *BigFinder; 1886 1884 } 1887 1885 counter++; 1888 1886 } 1889 bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives");1887 bool *Actives = new bool[counter]; 1890 1888 counter = 0; 1891 1889 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { … … 1913 1911 output.close(); 1914 1912 binoutput.close(); 1913 counter = 0; 1915 1914 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) 1916 1915 (*BigFinder)->ActiveFlag = Actives[counter++]; 1917 Free(&Actives);1916 delete[](Actives); 1918 1917 delete(LCList); 1919 1918 delete(TesselStruct); … … 1941 1940 performCriticalExit(); 1942 1941 } else { 1942 mol->getAtomCount(); 1943 1943 SaveFlag = true; 1944 1944 DoLog(1) && (Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl); … … 1950 1950 case 'F': 1951 1951 if (ExitFlag == 0) ExitFlag = 1; 1952 MaxDistance = -1; 1953 if (argv[argptr-1][2] == 'F') { // option is -FF? 1954 // fetch first argument as max distance to surface 1955 MaxDistance = atof(argv[argptr++]); 1956 DoLog(0) && (Log() << Verbose(0) << "Filling with maximum layer distance of " << MaxDistance << "." << endl); 1957 } 1958 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]))) { 1959 ExitFlag = 255; 1960 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); 1961 performCriticalExit(); 1962 } else { 1963 SaveFlag = true; 1964 DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules." << endl); 1965 // construct water molecule 1966 molecule *filler = World::getInstance().createMolecule(); 1967 if (!filler->AddXYZFile(argv[argptr])) { 1968 DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << argv[argptr] << "." << endl); 1969 } 1970 filler->SetNameFromFilename(argv[argptr]); 1971 configuration.BG->ConstructBondGraph(filler); 1972 molecule *Filling = NULL; 1973 atom *second = NULL, *third = NULL; 1974 first = World::getInstance().createAtom(); 1975 first->type = periode->FindElement(1); 1976 first->x = Vector(0.441, -0.143, 0.); 1977 filler->AddAtom(first); 1978 second = World::getInstance().createAtom(); 1979 second->type = periode->FindElement(1); 1980 second->x = Vector(-0.464, 1.137, 0.0); 1981 filler->AddAtom(second); 1982 third = World::getInstance().createAtom(); 1983 third->type = periode->FindElement(8); 1984 third->x = Vector(-0.464, 0.177, 0.); 1985 filler->AddAtom(third); 1986 filler->AddBond(first, third, 1); 1987 filler->AddBond(second, third, 1); 1988 // call routine 1989 double distance[NDIM]; 1990 for (int i=0;i<NDIM;i++) 1991 distance[i] = atof(argv[argptr+i+1]); 1992 Filling = FillBoxWithMolecule(molecules, filler, configuration, MaxDistance, distance, atof(argv[argptr+4]), atof(argv[argptr+5]), atof(argv[argptr+6]), atoi(argv[argptr+7])); 1993 if (Filling != NULL) { 1994 Filling->ActiveFlag = false; 1995 molecules->insert(Filling); 1996 } 1997 World::getInstance().destroyMolecule(filler); 1998 argptr+=6; 1999 } 1952 ArgcList.insert(argptr-1); 1953 ArgcList.insert(argptr); 1954 ArgcList.insert(argptr+1); 1955 ArgcList.insert(argptr+2); 1956 ArgcList.insert(argptr+3); 1957 ArgcList.insert(argptr+4); 1958 ArgcList.insert(argptr+5); 1959 ArgcList.insert(argptr+6); 1960 ArgcList.insert(argptr+7); 1961 ArgcList.insert(argptr+8); 1962 ArgcList.insert(argptr+9); 1963 ArgcList.insert(argptr+10); 1964 ArgcList.insert(argptr+11); 1965 ArgcList.insert(argptr+12); 1966 argptr+=13; 2000 1967 break; 2001 1968 case 'A': … … 2007 1974 } else { 2008 1975 DoLog(0) && (Log() << Verbose(0) << "Parsing bonds from " << argv[argptr] << "." << endl); 2009 ifstream *input = new ifstream(argv[argptr]);2010 mol->CreateAdjacencyListFromDbondFile( input);2011 input ->close();1976 ifstream input(argv[argptr]); 1977 mol->CreateAdjacencyListFromDbondFile(&input); 1978 input.close(); 2012 1979 argptr+=1; 2013 1980 } … … 2059 2026 int counter = 0; 2060 2027 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 2061 (*BigFinder)->CountAtoms(); 2062 if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) { 2028 if ((Boundary == NULL) || (Boundary->getAtomCount() < (*BigFinder)->getAtomCount())) { 2063 2029 Boundary = *BigFinder; 2064 2030 } 2065 2031 counter++; 2066 2032 } 2067 DoLog(1) && (Log() << Verbose(1) << "Biggest molecule has " << Boundary-> AtomCount<< " atoms." << endl);2033 DoLog(1) && (Log() << Verbose(1) << "Biggest molecule has " << Boundary->getAtomCount() << " atoms." << endl); 2068 2034 start = clock(); 2069 2035 LCList = new LinkedCell(Boundary, atof(argv[argptr])*2.); … … 2100 2066 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 2101 2067 ExitFlag = 255; 2102 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -L <step0> <step1> <prefix> <identity mapping?>" << endl);2068 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for linear interpolation: -L <step0> <step1> <prefix> <identity mapping?>" << endl); 2103 2069 performCriticalExit(); 2104 2070 } else { … … 2132 2098 case 'R': 2133 2099 if (ExitFlag == 0) ExitFlag = 1; 2134 if ((argptr+ 1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {2100 if ((argptr+3 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3]))) { 2135 2101 ExitFlag = 255; 2136 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R < id> <distance>" << endl);2102 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <x> <y> <z> <distance>" << endl); 2137 2103 performCriticalExit(); 2138 2104 } else { 2139 2105 SaveFlag = true; 2140 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl); 2141 double tmp1 = atof(argv[argptr+1]); 2142 atom *third = mol->FindAtom(atoi(argv[argptr])); 2143 atom *first = mol->start; 2144 if ((third != NULL) && (first != mol->end)) { 2145 atom *second = first->next; 2146 while(second != mol->end) { 2147 first = second; 2148 second = first->next; 2149 if (first->x.DistanceSquared(third->x) > tmp1*tmp1) // distance to first above radius ... 2150 mol->RemoveAtom(first); 2106 const double radius = atof(argv[argptr+3]); 2107 Vector point(atof(argv[argptr]),atof(argv[argptr+1]),atof(argv[argptr+2])); 2108 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point << " with radius " << radius << "." << endl); 2109 atom *Walker = NULL; 2110 molecule::iterator advancer = mol->begin(); 2111 for(molecule::iterator iter = advancer; advancer != mol->end();) { 2112 iter = advancer++; 2113 if ((*iter)->x.DistanceSquared(point) > radius*radius){ // distance to first above radius ... 2114 Walker = (*iter); 2115 DoLog(1) && (Log() << Verbose(1) << "Removing atom " << *Walker << "." << endl); 2116 mol->RemoveAtom(*(iter)); 2117 World::getInstance().destroyAtom(Walker); 2151 2118 } 2152 } else {2153 DoeLog(1) && (eLog()<< Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl);2154 2119 } 2155 argptr+= 2;2120 argptr+=4; 2156 2121 } 2157 2122 break; … … 2190 2155 case 's': 2191 2156 if (ExitFlag == 0) ExitFlag = 1; 2192 if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {2157 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 2193 2158 ExitFlag = 255; 2194 2159 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl); 2195 2160 performCriticalExit(); 2196 2161 } else { 2197 SaveFlag = true; 2198 j = -1; 2199 DoLog(1) && (Log() << Verbose(1) << "Scaling all ion positions by factor." << endl); 2200 factor = new double[NDIM]; 2201 factor[0] = atof(argv[argptr]); 2202 factor[1] = atof(argv[argptr+1]); 2203 factor[2] = atof(argv[argptr+2]); 2204 mol->Scale((const double ** const)&factor); 2205 double * const cell_size = World::getInstance().getDomain(); 2206 for (int i=0;i<NDIM;i++) { 2207 j += i+1; 2208 x[i] = atof(argv[NDIM+i]); 2209 cell_size[j]*=factor[i]; 2210 } 2211 delete[](factor); 2162 ArgcList.insert(argptr-1); 2163 ArgcList.insert(argptr); 2164 ArgcList.insert(argptr+1); 2165 ArgcList.insert(argptr+2); 2212 2166 argptr+=3; 2213 2167 } … … 2220 2174 performCriticalExit(); 2221 2175 } else { 2222 SaveFlag = true; 2223 j = -1; 2224 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl); 2225 double * const cell_size = World::getInstance().getDomain(); 2226 for (int i=0;i<6;i++) { 2227 cell_size[i] = atof(argv[argptr+i]); 2228 } 2229 // center 2230 mol->CenterInBox(); 2176 ArgcList.insert(argptr-1); 2177 ArgcList.insert(argptr); 2178 ArgcList.insert(argptr+1); 2179 ArgcList.insert(argptr+2); 2180 ArgcList.insert(argptr+3); 2181 ArgcList.insert(argptr+4); 2182 ArgcList.insert(argptr+5); 2231 2183 argptr+=6; 2232 2184 } … … 2239 2191 performCriticalExit(); 2240 2192 } else { 2241 SaveFlag = true; 2242 j = -1; 2243 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl); 2244 double * const cell_size = World::getInstance().getDomain(); 2245 for (int i=0;i<6;i++) { 2246 cell_size[i] = atof(argv[argptr+i]); 2247 } 2248 // center 2249 mol->BoundInBox(); 2193 ArgcList.insert(argptr-1); 2194 ArgcList.insert(argptr); 2195 ArgcList.insert(argptr+1); 2196 ArgcList.insert(argptr+2); 2197 ArgcList.insert(argptr+3); 2198 ArgcList.insert(argptr+4); 2199 ArgcList.insert(argptr+5); 2250 2200 argptr+=6; 2251 2201 } … … 2258 2208 performCriticalExit(); 2259 2209 } else { 2260 SaveFlag = true; 2261 j = -1; 2262 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl); 2263 // make every coordinate positive 2264 mol->CenterEdge(&x); 2265 // update Box of atoms by boundary 2266 mol->SetBoxDimension(&x); 2267 // translate each coordinate by boundary 2268 double * const cell_size = World::getInstance().getDomain(); 2269 j=-1; 2270 for (int i=0;i<NDIM;i++) { 2271 j += i+1; 2272 x[i] = atof(argv[argptr+i]); 2273 cell_size[j] += x[i]*2.; 2274 } 2275 mol->Translate((const Vector *)&x); 2210 ArgcList.insert(argptr-1); 2211 ArgcList.insert(argptr); 2212 ArgcList.insert(argptr+1); 2213 ArgcList.insert(argptr+2); 2276 2214 argptr+=3; 2277 2215 } … … 2279 2217 case 'O': 2280 2218 if (ExitFlag == 0) ExitFlag = 1; 2281 SaveFlag = true; 2282 DoLog(1) && (Log() << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl); 2283 x.Zero(); 2284 mol->CenterEdge(&x); 2285 mol->SetBoxDimension(&x); 2219 ArgcList.insert(argptr-1); 2286 2220 argptr+=0; 2287 2221 break; … … 2293 2227 performCriticalExit(); 2294 2228 } else { 2229 mol->getAtomCount(); 2295 2230 SaveFlag = true; 2296 2231 DoLog(1) && (Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl); … … 2312 2247 mol->CreateAdjacencyList(atof(argv[argptr]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 2313 2248 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl); 2314 if (mol-> first->next != mol->last) {2249 if (mol->hasBondStructure()) { 2315 2250 ExitFlag = mol->FragmentMolecule(atoi(argv[argptr+1]), &configuration); 2316 2251 } … … 2401 2336 performCriticalExit(); 2402 2337 } else { 2403 SaveFlag = true; 2404 double * const cell_size = World::getInstance().getDomain(); 2405 for (int axis = 1; axis <= NDIM; axis++) { 2406 int faktor = atoi(argv[argptr++]); 2407 int count; 2408 const element ** Elements; 2409 Vector ** vectors; 2410 if (faktor < 1) { 2411 DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor mus be greater than 1!" << endl); 2412 faktor = 1; 2413 } 2414 mol->CountAtoms(); // recount atoms 2415 if (mol->AtomCount != 0) { // if there is more than none 2416 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand 2417 Elements = new const element *[count]; 2418 vectors = new Vector *[count]; 2419 j = 0; 2420 first = mol->start; 2421 while (first->next != mol->end) { // make a list of all atoms with coordinates and element 2422 first = first->next; 2423 Elements[j] = first->type; 2424 vectors[j] = &first->x; 2425 j++; 2426 } 2427 if (count != j) 2428 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl); 2429 x.Zero(); 2430 y.Zero(); 2431 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 2432 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times 2433 x += y; // per factor one cell width further 2434 for (int k=count;k--;) { // go through every atom of the original cell 2435 first = World::getInstance().createAtom(); // create a new body 2436 first->x = (*vectors[k]) + x; 2437 first->type = Elements[k]; // insert original element 2438 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 2439 } 2440 } 2441 // free memory 2442 delete[](Elements); 2443 delete[](vectors); 2444 // correct cell size 2445 if (axis < 0) { // if sign was negative, we have to translate everything 2446 x =(-(faktor-1)) * y; 2447 mol->Translate(&x); 2448 } 2449 cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor; 2450 } 2451 } 2338 ArgcList.insert(argptr-1); 2339 ArgcList.insert(argptr); 2340 ArgcList.insert(argptr+1); 2341 ArgcList.insert(argptr+2); 2342 argptr+=3; 2452 2343 } 2453 2344 break; … … 2461 2352 } while (argptr < argc); 2462 2353 if (SaveFlag) 2463 configuration.SaveAll( ConfigFileName, periode, molecules);2354 configuration.SaveAll(*ConfigFileName, periode, molecules); 2464 2355 } else { // no arguments, hence scan the elements db 2465 2356 if (periode->LoadPeriodentafel(configuration.databasepath)) … … 2476 2367 void cleanUp(){ 2477 2368 World::purgeInstance(); 2478 Log() << Verbose(0) << "Maximum of allocated memory: "2479 << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl;2480 Log() << Verbose(0) << "Remaining non-freed memory: "2481 << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;2482 MemoryUsageObserver::purgeInstance();2483 2369 logger::purgeInstance(); 2484 2370 errorLogger::purgeInstance(); … … 2488 2374 ActionRegistry::purgeInstance(); 2489 2375 ActionHistory::purgeInstance(); 2376 Memory::getState(); 2490 2377 } 2491 2378 … … 2493 2380 { 2494 2381 config *configuration = World::getInstance().getConfig(); 2382 // while we are non interactive, we want to abort from asserts 2383 //ASSERT_DO(Assert::Abort); 2384 molecule *mol = NULL; 2495 2385 Vector x, y, z, n; 2496 2386 ifstream test; … … 2499 2389 char **Arguments = NULL; 2500 2390 int ArgcSize = 0; 2391 int ExitFlag = 0; 2501 2392 bool ArgumentsCopied = false; 2502 2393 char *ConfigFileName = new char[MAXSTRINGSIZE]; 2394 2395 // print version check whether arguments are present at all 2503 2396 cout << ESPACKVersion << endl; 2397 if (argc < 2) { 2398 cout << "Obtain help with " << argv[0] << " -h." << endl; 2399 cleanUp(); 2400 Memory::getState(); 2401 return(1); 2402 } 2403 2504 2404 2505 2405 setVerbosity(0); 2506 2406 // need to init the history before any action is created 2507 2407 ActionHistory::init(); 2408 2409 // In the interactive mode, we can leave the user the choice in case of error 2410 ASSERT_DO(Assert::Ask); 2411 2412 // from this moment on, we need to be sure to deeinitialize in the correct order 2413 // this is handled by the cleanup function 2414 atexit(cleanUp); 2508 2415 2509 2416 // Parse command line options and if present create respective UI … … 2512 2419 ArgcList.insert(0); // push back program! 2513 2420 ArgcList.insert(1); // push back config file name 2514 char ConfigFileName[MAXSTRINGSIZE];2515 2421 // handle arguments by ParseCommandLineOptions() 2516 ParseCommandLineOptions(argc,argv,World::getInstance().getMolecules(),World::getInstance().getPeriode(),*World::getInstance().getConfig(), (char *&)ConfigFileName, ArgcList);2422 ExitFlag = ParseCommandLineOptions(argc,argv,World::getInstance().getMolecules(),World::getInstance().getPeriode(),*World::getInstance().getConfig(), &ConfigFileName, ArgcList); 2517 2423 // copy all remaining arguments to a new argv 2518 Arguments = Malloc<char *>(ArgcList.size(), "main - **Arguments");2424 Arguments = new char *[ArgcList.size()]; 2519 2425 cout << "The following arguments are handled by CommandLineParser: "; 2520 2426 for (set<int>::iterator ArgcRunner = ArgcList.begin(); ArgcRunner != ArgcList.end(); ++ArgcRunner) { 2521 Arguments[ArgcSize] = Malloc<char>(strlen(argv[*ArgcRunner])+2, "main - *Arguments[]");2427 Arguments[ArgcSize] = new char[strlen(argv[*ArgcRunner])+2]; 2522 2428 strcpy(Arguments[ArgcSize], argv[*ArgcRunner]); 2523 2429 cout << " " << argv[*ArgcRunner]; … … 2544 2450 } 2545 2451 2546 if(World::getInstance().getPeriode()->StorePeriodentafel(configuration->databasepath)) 2547 Log() << Verbose(0) << "Saving of elements.db successful." << endl; 2548 2549 else 2550 Log() << Verbose(0) << "Saving of elements.db failed." << endl; 2452 Log() << Verbose(0) << "Saving to " << ConfigFileName << "." << endl; 2453 World::getInstance().getConfig()->SaveAll(ConfigFileName, World::getInstance().getPeriode(), World::getInstance().getMolecules()); 2551 2454 2552 2455 // free the new argv 2553 2456 if (ArgumentsCopied) { 2554 2457 for (int i=0; i<ArgcSize;i++) 2555 Free(&Arguments[i]);2556 Free(&Arguments);2458 delete[](Arguments[i]); 2459 delete[](Arguments); 2557 2460 } 2558 2559 cleanUp(); 2560 Memory::getState(); 2561 return (0); 2461 delete[](ConfigFileName); 2462 2463 return (ExitFlag == 1 ? 0 : ExitFlag); 2562 2464 } 2563 2465 -
src/config.cpp
re58856b rf2a1d3 14 14 #include "element.hpp" 15 15 #include "helpers.hpp" 16 #include "info.hpp" 16 17 #include "lists.hpp" 17 18 #include "log.hpp" … … 93 94 return; 94 95 } else 95 buffer = Malloc<char*>(NoLines, "ConfigFileBuffer::ConfigFileBuffer: **buffer");96 buffer = new char *[NoLines]; 96 97 97 98 // scan each line and put into buffer … … 99 100 int i; 100 101 do { 101 buffer[lines] = Malloc<char>(MAXSTRINGSIZE, "ConfigFileBuffer::ConfigFileBuffer: *buffer[]");102 buffer[lines] = new char[MAXSTRINGSIZE]; 102 103 file->getline(buffer[lines], MAXSTRINGSIZE-1); 103 104 i = strlen(buffer[lines]); … … 119 120 { 120 121 for(int i=0;i<NoLines;++i) 121 Free(&buffer[i]);122 Free(&buffer);123 Free(&LineMapping);122 delete[](buffer[i]); 123 delete[](buffer); 124 delete[](LineMapping); 124 125 } 125 126 … … 129 130 void ConfigFileBuffer::InitMapping() 130 131 { 131 LineMapping = Malloc<int>(NoLines, "ConfigFileBuffer::InitMapping: *LineMapping");132 LineMapping = new int[NoLines]; 132 133 for (int i=0;i<NoLines;i++) 133 134 LineMapping[i] = i; … … 179 180 MaxLevel(5), RiemannTensor(0), LevRFactor(0), RiemannLevel(0), Lev0Factor(2), RTActualUse(0), AddPsis(0), RCut(20.), StructOpt(0), IsAngstroem(1), RelativeCoord(0), 180 181 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");182 mainname = new char[MAXSTRINGSIZE]; 183 defaultpath = new char[MAXSTRINGSIZE]; 184 pseudopotpath = new char[MAXSTRINGSIZE]; 185 databasepath = new char[MAXSTRINGSIZE]; 186 configpath = new char[MAXSTRINGSIZE]; 187 configname = new char[MAXSTRINGSIZE]; 187 188 strcpy(mainname,"pcp"); 188 189 strcpy(defaultpath,"not specified"); … … 199 200 config::~config() 200 201 { 201 Free(&mainname);202 Free(&defaultpath);203 Free(&pseudopotpath);204 Free(&databasepath);205 Free(&configpath);206 Free(&configname);207 Free(&ThermostatImplemented);202 delete[](mainname); 203 delete[](defaultpath); 204 delete[](pseudopotpath); 205 delete[](databasepath); 206 delete[](configpath); 207 delete[](configname); 208 delete[](ThermostatImplemented); 208 209 for (int j=0;j<MaxThermostats;j++) 209 Free(&ThermostatNames[j]);210 Free(&ThermostatNames);210 delete[](ThermostatNames[j]); 211 delete[](ThermostatNames); 211 212 212 213 if (BG != NULL) … … 218 219 void config::InitThermostats() 219 220 { 220 ThermostatImplemented = Malloc<int>(MaxThermostats, "config constructor: *ThermostatImplemented");221 ThermostatNames = Malloc<char*>(MaxThermostats, "config constructor: *ThermostatNames");221 ThermostatImplemented = new int[MaxThermostats]; 222 ThermostatNames = new char *[MaxThermostats]; 222 223 for (int j=0;j<MaxThermostats;j++) 223 ThermostatNames[j] = Malloc<char>(12, "config constructor: ThermostatNames[]");224 ThermostatNames[j] = new char[12]; 224 225 225 226 strcpy(ThermostatNames[0],"None"); … … 242 243 void config::ParseThermostats(class ConfigFileBuffer * const fb) 243 244 { 244 char * const thermo = Malloc<char>(12, "IonsInitRead: thermo");245 char * const thermo = new char[12]; 245 246 const int verbose = 0; 246 247 … … 309 310 Thermostat = None; 310 311 } 311 Free(thermo);312 delete[](thermo); 312 313 }; 313 314 … … 1547 1548 int AtomNo = -1; 1548 1549 int MolNo = 0; 1549 atom *Walker = NULL;1550 1550 FILE *f = NULL; 1551 1551 … … 1560 1560 fprintf(f, "# Created by MoleCuilder\n"); 1561 1561 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"); 1562 for (MoleculeList::const_iterator MolRunner = MolList->ListOfMolecules.begin(); MolRunner != MolList->ListOfMolecules.end(); MolRunner++) { 1563 int *elementNo = new int[MAX_ELEMENTS]; 1564 for (int i=0;i<MAX_ELEMENTS;i++) 1565 elementNo[i] = 0; 1565 1566 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 1567 for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) { 1568 sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]); 1569 elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100; // confine to two digits 1570 1570 fprintf(f, 1571 1571 "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 */1572 (*iter)->nr, /* atom serial number */ 1573 1573 name, /* atom name */ 1574 (* Runner)->name, /* residue name */1574 (*MolRunner)->name, /* residue name */ 1575 1575 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1576 1576 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 */1577 (*iter)->node->at(0), /* position X in Angstroem */ 1578 (*iter)->node->at(1), /* position Y in Angstroem */ 1579 (*iter)->node->at(2), /* position Z in Angstroem */ 1580 (double)(*iter)->type->Valence, /* occupancy */ 1581 (double)(*iter)->type->NoValenceOrbitals, /* temperature factor */ 1582 1582 "0", /* segment identifier */ 1583 Walker->type->symbol, /* element symbol */1583 (*iter)->type->symbol, /* element symbol */ 1584 1584 "0"); /* charge */ 1585 1585 AtomNo++; 1586 1586 } 1587 Free(&elementNo);1587 delete[](elementNo); 1588 1588 MolNo++; 1589 1589 } … … 1601 1601 { 1602 1602 int AtomNo = -1; 1603 atom *Walker = NULL;1604 1603 FILE *f = NULL; 1605 1604 1606 int *elementNo = Calloc<int>(MAX_ELEMENTS, "config::SavePDB - elementNo"); 1605 int *elementNo = new int[MAX_ELEMENTS]; 1606 for (int i=0;i<MAX_ELEMENTS;i++) 1607 elementNo[i] = 0; 1607 1608 char name[MAXSTRINGSIZE]; 1608 1609 strncpy(name, filename, MAXSTRINGSIZE-1); … … 1611 1612 if (f == NULL) { 1612 1613 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl); 1613 Free(&elementNo);1614 delete[](elementNo); 1614 1615 return false; 1615 1616 } 1616 1617 fprintf(f, "# Created by MoleCuilder\n"); 1617 1618 1618 Walker = mol->start;1619 1619 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 1620 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1621 sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]); 1622 elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100; // confine to two digits 1624 1623 fprintf(f, 1625 1624 "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 */1625 (*iter)->nr, /* atom serial number */ 1627 1626 name, /* atom name */ 1628 1627 mol->name, /* residue name */ 1629 1628 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1630 1629 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 */1630 (*iter)->node->at(0), /* position X in Angstroem */ 1631 (*iter)->node->at(1), /* position Y in Angstroem */ 1632 (*iter)->node->at(2), /* position Z in Angstroem */ 1633 (double)(*iter)->type->Valence, /* occupancy */ 1634 (double)(*iter)->type->NoValenceOrbitals, /* temperature factor */ 1636 1635 "0", /* segment identifier */ 1637 Walker->type->symbol, /* element symbol */1636 (*iter)->type->symbol, /* element symbol */ 1638 1637 "0"); /* charge */ 1639 1638 AtomNo++; 1640 1639 } 1641 1640 fclose(f); 1642 Free(&elementNo);1641 delete[](elementNo); 1643 1642 1644 1643 return true; … … 1653 1652 bool config::SaveTREMOLO(const char * const filename, const molecule * const mol) const 1654 1653 { 1655 atom *Walker = NULL;1656 1654 ofstream *output = NULL; 1657 1655 stringstream * const fname = new stringstream; … … 1666 1664 1667 1665 // scan maximum number of neighbours 1668 Walker = mol->start;1669 1666 int MaxNeighbours = 0; 1670 while (Walker->next != mol->end) { 1671 Walker = Walker->next; 1672 const int count = Walker->ListOfBonds.size(); 1667 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1668 const int count = (*iter)->ListOfBonds.size(); 1673 1669 if (MaxNeighbours < count) 1674 1670 MaxNeighbours = count; 1675 1671 } 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->Name << "\t"; 1672 *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl; 1673 1674 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1675 *output << (*iter)->nr << "\t"; 1676 *output << (*iter)->getName() << "\t"; 1683 1677 *output << mol->name << "\t"; 1684 1678 *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++)1679 *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t"; 1680 *output << static_cast<double>((*iter)->type->Valence) << "\t"; 1681 *output << (*iter)->type->symbol << "\t"; 1682 for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++) 1683 *output << (*runner)->GetOtherAtom(*iter)->nr << "\t"; 1684 for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++) 1691 1685 *output << "-\t"; 1692 1686 *output << endl; … … 1708 1702 bool config::SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const 1709 1703 { 1710 atom *Walker = NULL;1704 Info FunctionInfo(__func__); 1711 1705 ofstream *output = NULL; 1712 1706 stringstream * const fname = new stringstream; … … 1723 1717 int MaxNeighbours = 0; 1724 1718 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(); 1719 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 1720 const int count = (*iter)->ListOfBonds.size(); 1729 1721 if (MaxNeighbours < count) 1730 1722 MaxNeighbours = count; 1731 1723 } 1732 1724 } 1733 *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl;1725 *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl; 1734 1726 1735 1727 // create global to local id map 1736 int **LocalNotoGlobalNoMap = Calloc<int *>(MolList->ListOfMolecules.size(), "config::SaveTREMOLO - **LocalNotoGlobalNoMap");1728 map<int, int> LocalNotoGlobalNoMap; 1737 1729 { 1738 int MolCounter = 0;1739 int AtomNo = 0;1730 unsigned int MolCounter = 0; 1731 int AtomNo = 1; 1740 1732 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 1733 for(molecule::iterator AtomRunner = (*MolWalker)->begin(); AtomRunner != (*MolWalker)->end(); ++AtomRunner) { 1734 LocalNotoGlobalNoMap.insert( pair<int,int>((*AtomRunner)->getId(), AtomNo++) ); 1735 } 1745 1736 MolCounter++; 1746 1737 } 1738 ASSERT(MolCounter == MolList->ListOfMolecules.size(), "SaveTREMOLO: LocalNotoGlobalNoMap[] has not been correctly initialized for each molecule"); 1747 1739 } 1748 1740 … … 1752 1744 int AtomNo = 0; 1753 1745 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->Name << "\t"; 1746 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 1747 *output << LocalNotoGlobalNoMap[ (*iter)->getId() ] << "\t"; 1748 *output << (*iter)->getName() << "\t"; 1759 1749 *output << (*MolWalker)->name << "\t"; 1760 1750 *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++)1751 *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t"; 1752 *output << (double)(*iter)->type->Valence << "\t"; 1753 *output << (*iter)->type->symbol << "\t"; 1754 for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++) 1755 *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t"; 1756 for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++) 1767 1757 *output << "-\t"; 1768 1758 *output << endl; … … 1778 1768 delete(output); 1779 1769 delete(fname); 1780 for(size_t i=0;i<MolList->ListOfMolecules.size(); i++)1781 Free(&LocalNotoGlobalNoMap[i]);1782 Free(&LocalNotoGlobalNoMap);1783 1770 1784 1771 return true; … … 1808 1795 if (output == NULL) 1809 1796 strcpy(filename,"main_pcp_linux"); 1810 Log() << Verbose(0) << "Saving as pdb input ";1797 Log() << Verbose(0) << "Saving as pdb input ... " << endl; 1811 1798 if (SavePDB(filename, molecules)) 1812 Log() << Verbose(0) << " done." << endl;1799 Log() << Verbose(0) << "\t... done." << endl; 1813 1800 else 1814 Log() << Verbose(0) << " failed." << endl;1801 Log() << Verbose(0) << "\t... failed." << endl; 1815 1802 1816 1803 // then save as tremolo data file … … 1819 1806 if (output == NULL) 1820 1807 strcpy(filename,"main_pcp_linux"); 1821 Log() << Verbose(0) << "Saving as tremolo data input ";1808 Log() << Verbose(0) << "Saving as tremolo data input ... " << endl; 1822 1809 if (SaveTREMOLO(filename, molecules)) 1823 Log() << Verbose(0) << " done." << endl;1810 Log() << Verbose(0) << "\t... done." << endl; 1824 1811 else 1825 Log() << Verbose(0) << " failed." << endl;1812 Log() << Verbose(0) << "\t... failed." << endl; 1826 1813 1827 1814 // translate each to its center and merge all molecules in MoleculeListClass into this molecule … … 1859 1846 output.close(); 1860 1847 output.clear(); 1861 Log() << Verbose(0) << "Saving of config file ";1848 Log() << Verbose(0) << "Saving of config file ... " << endl; 1862 1849 if (Save(filename, periode, mol)) 1863 Log() << Verbose(0) << " successful." << endl;1850 Log() << Verbose(0) << "\t... successful." << endl; 1864 1851 else 1865 Log() << Verbose(0) << " failed." << endl;1852 Log() << Verbose(0) << "\t... failed." << endl; 1866 1853 1867 1854 // and save to xyz file … … 1876 1863 output.open(filename, ios::trunc); 1877 1864 } 1878 Log() << Verbose(0) << "Saving of XYZ file ";1865 Log() << Verbose(0) << "Saving of XYZ file ... " << endl; 1879 1866 if (mol->MDSteps <= 1) { 1880 1867 if (mol->OutputXYZ(&output)) 1881 Log() << Verbose(0) << " successful." << endl;1868 Log() << Verbose(0) << "\t... successful." << endl; 1882 1869 else 1883 Log() << Verbose(0) << " failed." << endl;1870 Log() << Verbose(0) << "\t... failed." << endl; 1884 1871 } else { 1885 1872 if (mol->OutputTrajectoriesXYZ(&output)) 1886 Log() << Verbose(0) << " successful." << endl;1873 Log() << Verbose(0) << "\t... successful." << endl; 1887 1874 else 1888 Log() << Verbose(0) << " failed." << endl;1875 Log() << Verbose(0) << "\t... failed." << endl; 1889 1876 } 1890 1877 output.close(); … … 1896 1883 if (output == NULL) 1897 1884 strcpy(filename,"main_pcp_linux"); 1898 Log() << Verbose(0) << "Saving as mpqc input ";1885 Log() << Verbose(0) << "Saving as mpqc input .. " << endl; 1899 1886 if (SaveMPQC(filename, mol)) 1900 Log() << Verbose(0) << " done." << endl;1887 Log() << Verbose(0) << "\t... done." << endl; 1901 1888 else 1902 Log() << Verbose(0) << " failed." << endl;1889 Log() << Verbose(0) << "\t... failed." << endl; 1903 1890 1904 1891 if (!strcmp(configpath, GetDefaultPath())) { … … 1938 1925 char *dummy1 = NULL; 1939 1926 char *dummy = NULL; 1940 char * const free_dummy = Malloc<char>(256, "config::ParseForParameter: *free_dummy"); // pointers in the line that is read in per step1927 char free_dummy[MAXSTRINGSIZE]; // pointers in the line that is read in per step 1941 1928 dummy1 = free_dummy; 1942 1929 … … 1954 1941 if (file->eof()) { 1955 1942 if ((critical) && (found == 0)) { 1956 Free(free_dummy);1957 1943 //Error(InitReading, name); 1958 1944 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); … … 1962 1948 file->clear(); 1963 1949 file->seekg(file_position, ios::beg); // rewind to start position 1964 Free(free_dummy);1965 1950 return 0; 1966 1951 } … … 1993 1978 dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword) 1994 1979 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name); 1995 //Free((void **)&free_dummy);1996 1980 //Error(FileOpenParams, NULL); 1997 1981 } else { … … 2014 1998 if (file->eof()) { 2015 1999 if ((critical) && (found == 0)) { 2016 Free(free_dummy);2017 2000 //Error(InitReading, name); 2018 2001 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); … … 2022 2005 file->clear(); 2023 2006 file->seekg(file_position, ios::beg); // rewind to start position 2024 Free(free_dummy);2025 2007 return 0; 2026 2008 } … … 2063 2045 if (critical) { 2064 2046 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 2047 //return 0; 2067 2048 exit(255); … … 2071 2052 file->clear(); 2072 2053 file->seekg(file_position, ios::beg); // rewind to start position 2073 Free(free_dummy);2074 2054 return 0; 2075 2055 } … … 2084 2064 file->seekg(file_position, ios::beg); // rewind to start position 2085 2065 } 2086 Free(free_dummy);2087 2066 return 0; 2088 2067 } … … 2140 2119 if ((type >= row_int) && (verbose)) 2141 2120 fprintf(stderr,"\n"); 2142 Free(free_dummy);2143 2121 if (!sequential) { 2144 2122 file->clear(); … … 2221 2199 dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword) 2222 2200 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name); 2223 //Free(&free_dummy);2224 2201 //Error(FileOpenParams, NULL); 2225 2202 } else { -
src/elements.db
-
Property mode
changed from
100755
to100644
re58856b rf2a1d3 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/helpers.cpp
re58856b rf2a1d3 58 58 int CountLinesinFile(ifstream &InputFile) 59 59 { 60 char *buffer = Malloc<char>(MAXSTRINGSIZE, "CountLinesinFile: *buffer");60 char *buffer = new char[MAXSTRINGSIZE]; 61 61 int lines=0; 62 62 … … 70 70 } 71 71 InputFile.seekg(PositionMarker, ios::beg); 72 Free(&buffer);72 delete[](buffer); 73 73 return lines; 74 74 }; … … 90 90 } 91 91 // allocate string 92 returnstring = Malloc<char>(order + 2, "FixedDigitNumber: *returnstring");92 returnstring = new char[order + 2]; 93 93 // terminate and fill string array from end backward 94 94 returnstring[order] = '\0'; … … 122 122 double * ReturnFullMatrixforSymmetric(const double * const symm) 123 123 { 124 double *matrix = Malloc<double>(NDIM * NDIM, "molecule::ReturnFullMatrixforSymmetric: *matrix");124 double *matrix = new double[NDIM * NDIM]; 125 125 matrix[0] = symm[0]; 126 126 matrix[1] = symm[1]; … … 140 140 double * InverseMatrix( const double * const A) 141 141 { 142 double *B = Malloc<double>(NDIM * NDIM, "Vector::InverseMatrix: *B");142 double *B = new double[NDIM * NDIM]; 143 143 double detA = RDET3(A); 144 144 double detAReci; … … 180 180 181 181 182 /** Allocates a memory range using malloc().183 * Prints the provided error message in case of a failure.184 *185 * \param number of memory slices of type X to allocate186 * \param failure message which is printed if the allocation fails187 * \return pointer to the allocated memory range, will be NULL if a failure occurred188 */189 template <> char* Malloc<char>(size_t size, const char* output)190 {191 char* buffer = NULL;192 buffer = (char*) malloc(sizeof(char) * (size + 1));193 for (size_t i = size; i--;)194 buffer[i] = (i % 2 == 0) ? 'p': 'c';195 buffer[size] = '\0';196 197 if (buffer != NULL) {198 MemoryUsageObserver::getInstance()->addMemory(buffer, size);199 } else {200 Log() << Verbose(0) << "Malloc for datatype " << typeid(char).name()201 << " failed - pointer is NULL: " << output << endl;202 }203 204 return buffer;205 };206 207 182 /** 208 * Frees all memory registered by the memory observer and calls exit(225) afterwards.183 * Calls exit(255). 209 184 */ 210 185 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 186 exit(255); 217 187 } -
src/helpers.hpp
re58856b rf2a1d3 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/joiner.cpp
re58856b rf2a1d3 58 58 return 1; 59 59 } else { 60 dir = Malloc<char>(strlen(argv[2]) + 2, "main: *dir");60 dir = new char[strlen(argv[2]) + 2]; 61 61 strcpy(dir, "/"); 62 62 strcat(dir, argv[2]); … … 243 243 // exit 244 244 delete(periode); 245 Free(&dir);245 delete[](dir); 246 246 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 247 247 return 0; -
src/lists.hpp
re58856b rf2a1d3 134 134 }; 135 135 136 /** Returns the first marker in a chain list.137 * \param *me one arbitrary item in chain list138 * \return poiner to first marker139 */140 template <typename X> X *GetFirst(X *me)141 {142 X *Binder = me;143 while(Binder->previous != 0)144 Binder = Binder->previous;145 return Binder;146 };147 148 /** Returns the last marker in a chain list.149 * \param *me one arbitrary item in chain list150 * \return poiner to last marker151 */152 template <typename X> X *GetLast(X *me)153 {154 X *Binder = me;155 while(Binder->next != 0)156 Binder = Binder->next;157 return Binder;158 };159 160 136 #endif /* LISTS_HPP_ */ -
src/molecule.cpp
re58856b rf2a1d3 35 35 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero. 36 36 */ 37 molecule::molecule(const periodentafel * const teil) : elemente(teil), start(World::getInstance().createAtom()), end(World::getInstance().createAtom()),38 first(new bond(start, end, 1, -1)), last(new bond(start, end, 1, -1)), MDSteps(0), AtomCount(0),37 molecule::molecule(const periodentafel * const teil) : elemente(teil), 38 MDSteps(0), 39 39 BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.), 40 40 ActiveFlag(false), IndexNr(-1), 41 41 formula(this,boost::bind(&molecule::calcFormula,this)), 42 last_atom(0), 43 InternalPointer(start) 44 { 45 // init atom chain list 46 start->father = NULL; 47 end->father = NULL; 48 link(start,end); 49 50 // init bond chain list 51 link(first,last); 42 AtomCount(this,boost::bind(&molecule::doCountAtoms,this)), last_atom(0), InternalPointer(begin()) 43 { 52 44 53 45 // other stuff … … 67 59 { 68 60 CleanupMolecule(); 69 delete(first);70 delete(last);71 end->getWorld()->destroyAtom(end);72 start->getWorld()->destroyAtom(start);73 61 }; 74 62 … … 81 69 const std::string molecule::getName(){ 82 70 return std::string(name); 71 } 72 73 int molecule::getAtomCount() const{ 74 return *AtomCount; 83 75 } 84 76 … … 104 96 stringstream sstr; 105 97 periodentafel *periode = World::getInstance().getPeriode(); 106 for (atom *Walker = start; Walker != end; Walker = Walker->next) {107 counts[ Walker->type->getNumber()]++;98 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 99 counts[(*iter)->type->getNumber()]++; 108 100 } 109 101 std::map<atomicNumber_t,unsigned int>::reverse_iterator iter; … … 115 107 } 116 108 109 /************************** Access to the List of Atoms ****************/ 110 111 112 molecule::iterator molecule::begin(){ 113 return molecule::iterator(atoms.begin(),this); 114 } 115 116 molecule::const_iterator molecule::begin() const{ 117 return atoms.begin(); 118 } 119 120 molecule::iterator molecule::end(){ 121 return molecule::iterator(atoms.end(),this); 122 } 123 124 molecule::const_iterator molecule::end() const{ 125 return atoms.end(); 126 } 127 128 bool molecule::empty() const 129 { 130 return (begin() == end()); 131 } 132 133 size_t molecule::size() const 134 { 135 size_t counter = 0; 136 for (molecule::const_iterator iter = begin(); iter != end (); ++iter) 137 counter++; 138 return counter; 139 } 140 141 molecule::const_iterator molecule::erase( const_iterator loc ) 142 { 143 molecule::const_iterator iter = loc; 144 iter--; 145 atoms.erase( loc ); 146 return iter; 147 } 148 149 molecule::const_iterator molecule::erase( atom *& key ) 150 { 151 cout << "trying to erase atom" << endl; 152 molecule::const_iterator iter = find(key); 153 if (iter != end()){ 154 // remove this position and step forward (post-increment) 155 atoms.erase( iter++ ); 156 } 157 return iter; 158 } 159 160 molecule::const_iterator molecule::find ( atom *& key ) const 161 { 162 return atoms.find( key ); 163 } 164 165 pair<molecule::iterator,bool> molecule::insert ( atom * const key ) 166 { 167 pair<atomSet::iterator,bool> res = atoms.insert(key); 168 return pair<iterator,bool>(iterator(res.first,this),res.second); 169 } 117 170 118 171 /** Adds given atom \a *pointer from molecule list. … … 123 176 bool molecule::AddAtom(atom *pointer) 124 177 { 125 bool retval = false;126 178 OBSERVE; 127 179 if (pointer != NULL) { 128 180 pointer->sort = &pointer->nr; 129 pointer->nr = last_atom++; // increase number within molecule130 AtomCount++;131 181 if (pointer->type != NULL) { 132 182 if (ElementsInMolecule[pointer->type->Z] == 0) … … 135 185 if (pointer->type->Z != 1) 136 186 NoNonHydrogen++; 137 if (pointer->Name == NULL){138 Free(&pointer->Name);139 pointer->Name = Malloc<char>(6, "molecule::AddAtom: *pointer->Name");140 sprintf(pointer->Name, "%2s%02d", pointer->type->symbol, pointer->nr+1);141 } 142 } 143 retval = add(pointer, end);144 } 145 return retval;187 if(pointer->getName() == "Unknown"){ 188 stringstream sstr; 189 sstr << pointer->type->symbol << pointer->nr+1; 190 pointer->setName(sstr.str()); 191 } 192 } 193 insert(pointer); 194 } 195 return true; 146 196 }; 147 197 … … 157 207 if (pointer != NULL) { 158 208 atom *walker = pointer->clone(); 159 walker->Name = Malloc<char>(strlen(pointer->Name) + 1, "atom::atom: *Name"); 160 strcpy (walker->Name, pointer->Name); 209 walker->setName(pointer->getName()); 161 210 walker->nr = last_atom++; // increase number within molecule 162 add(walker, end);211 insert(walker); 163 212 if ((pointer->type != NULL) && (pointer->type->Z != 1)) 164 213 NoNonHydrogen++; 165 AtomCount++;166 214 retval=walker; 167 215 } … … 241 289 Orthovector1.MatrixMultiplication(matrix); 242 290 InBondvector -= Orthovector1; // subtract just the additional translation 243 Free(&matrix);291 delete[](matrix); 244 292 bondlength = InBondvector.Norm(); 245 293 // Log() << Verbose(4) << "Corrected InBondvector is now: "; … … 250 298 InBondvector.Normalize(); 251 299 // get typical bond length and store as scale factor for later 300 ASSERT(TopOrigin->type != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given."); 252 301 BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1]; 253 302 if (BondRescale == -1) { 254 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin-> Name << "<->" << TopReplacement->Name<< ") of degree " << TopBond->BondDegree << "!" << endl);303 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl); 255 304 return false; 256 305 BondRescale = bondlength; … … 275 324 InBondvector *= BondRescale; // rescale the distance vector to Hydrogen bond length 276 325 FirstOtherAtom->x = TopOrigin->x; // set coordination to origin ... 277 FirstOtherAtom->x = InBondvector; // ... and add distance vector to replacement atom326 FirstOtherAtom->x += InBondvector; // ... and add distance vector to replacement atom 278 327 AllWentWell = AllWentWell && AddAtom(FirstOtherAtom); 279 328 // Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: "; … … 295 344 SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin); 296 345 } else { 297 DoeLog(2) && (eLog()<< Verbose(2) << "Detected more than four bonds for atom " << TopOrigin-> Name);346 DoeLog(2) && (eLog()<< Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->getName()); 298 347 } 299 348 } … … 339 388 bondangle = TopOrigin->type->HBondAngle[1]; 340 389 if (bondangle == -1) { 341 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin-> Name << "<->" << TopReplacement->Name<< ") of degree " << TopBond->BondDegree << "!" << endl);390 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl); 342 391 return false; 343 392 bondangle = 0; … … 471 520 break; 472 521 } 473 Free(&matrix);522 delete[](matrix); 474 523 475 524 // Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl; … … 554 603 555 604 // copy all bonds 556 bond *Binder = first;605 bond *Binder = NULL; 557 606 bond *NewBond = NULL; 558 while(Binder->next != last) { 559 Binder = Binder->next; 560 561 // get the pendant atoms of current bond in the copy molecule 562 copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->leftatom, (const atom **)&LeftAtom ); 563 copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->rightatom, (const atom **)&RightAtom ); 564 565 NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree); 566 NewBond->Cyclic = Binder->Cyclic; 567 if (Binder->Cyclic) 568 copy->NoCyclicBonds++; 569 NewBond->Type = Binder->Type; 570 } 607 for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 608 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin()) 609 if ((*BondRunner)->leftatom == *AtomRunner) { 610 Binder = (*BondRunner); 611 612 // get the pendant atoms of current bond in the copy molecule 613 copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->leftatom, (const atom **)&LeftAtom ); 614 copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->rightatom, (const atom **)&RightAtom ); 615 616 NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree); 617 NewBond->Cyclic = Binder->Cyclic; 618 if (Binder->Cyclic) 619 copy->NoCyclicBonds++; 620 NewBond->Type = Binder->Type; 621 } 571 622 // correct fathers 572 623 ActOnAllAtoms( &atom::CorrectFather ); 573 624 574 625 // copy values 575 copy->CountAtoms();576 626 copy->CountElements(); 577 if ( first->next != last) { // if adjaceny list is present627 if (hasBondStructure()) { // if adjaceny list is present 578 628 copy->BondDistance = BondDistance; 579 629 } … … 608 658 { 609 659 bond *Binder = NULL; 610 if ((atom1 != NULL) && (FindAtom(atom1->nr) != NULL) && (atom2 != NULL) && (FindAtom(atom2->nr) != NULL)) { 611 Binder = new bond(atom1, atom2, degree, BondCount++); 612 atom1->RegisterBond(Binder); 613 atom2->RegisterBond(Binder); 614 if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1)) 615 NoNonBonds++; 616 add(Binder, last); 617 } else { 618 DoeLog(1) && (eLog()<< Verbose(1) << "Could not add bond between " << atom1->Name << " and " << atom2->Name << " as one or both are not present in the molecule." << endl); 619 } 660 661 // some checks to make sure we are able to create the bond 662 ASSERT(atom1, "First atom in bond-creation was an invalid pointer"); 663 ASSERT(atom2, "Second atom in bond-creation was an invalid pointer"); 664 ASSERT(FindAtom(atom1->nr),"First atom in bond-creation was not part of molecule"); 665 ASSERT(FindAtom(atom2->nr),"Second atom in bond-creation was not parto of molecule"); 666 667 Binder = new bond(atom1, atom2, degree, BondCount++); 668 atom1->RegisterBond(Binder); 669 atom2->RegisterBond(Binder); 670 if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1)) 671 NoNonBonds++; 672 620 673 return Binder; 621 674 }; … … 629 682 { 630 683 //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl); 631 pointer->leftatom->RegisterBond(pointer); 632 pointer->rightatom->RegisterBond(pointer); 633 removewithoutcheck(pointer); 684 delete(pointer); 634 685 return true; 635 686 }; … … 691 742 bool molecule::RemoveAtom(atom *pointer) 692 743 { 744 ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom()."); 745 OBSERVE; 693 746 if (ElementsInMolecule[pointer->type->Z] != 0) { // this would indicate an error 694 747 ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element 695 AtomCount--;696 748 } else 697 DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer-> Name<< " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl);749 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); 698 750 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 699 751 ElementCount--; 700 752 RemoveBonds(pointer); 701 return remove(pointer, start, end); 753 erase(pointer); 754 return true; 702 755 }; 703 756 … … 713 766 ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element 714 767 else 715 DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer-> Name<< " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl);768 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); 716 769 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 717 770 ElementCount--; 718 unlink(pointer);771 erase(pointer); 719 772 return true; 720 773 }; … … 725 778 bool molecule::CleanupMolecule() 726 779 { 727 return (cleanup(first,last) && cleanup(start,end)); 780 for (molecule::iterator iter = begin(); !empty(); iter = begin()) 781 erase(iter); 728 782 }; 729 783 … … 732 786 * \return pointer to atom or NULL 733 787 */ 734 atom * molecule::FindAtom(int Nr) const{ 735 atom * walker = find(&Nr, start,end); 736 if (walker != NULL) { 788 atom * molecule::FindAtom(int Nr) const 789 { 790 molecule::const_iterator iter = begin(); 791 for (; iter != end(); ++iter) 792 if ((*iter)->nr == Nr) 793 break; 794 if (iter != end()) { 737 795 //Log() << Verbose(0) << "Found Atom Nr. " << walker->nr << endl; 738 return walker;796 return (*iter); 739 797 } else { 740 798 DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl); … … 866 924 now = time((time_t *)NULL); // Get the system time and put it into 'now' as 'calender time' 867 925 for (int step=0;step<MDSteps;step++) { 868 *output << AtomCount<< "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now);926 *output << getAtomCount() << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now); 869 927 ActOnAllAtoms( &atom::OutputTrajectoryXYZ, output, step ); 870 928 } … … 883 941 if (output != NULL) { 884 942 now = time((time_t *)NULL); // Get the system time and put it into 'now' as 'calender time' 885 *output << AtomCount<< "\n\tCreated by molecuilder on " << ctime(&now);943 *output << getAtomCount() << "\n\tCreated by molecuilder on " << ctime(&now); 886 944 ActOnAllAtoms( &atom::OutputXYZLine, output ); 887 945 return true; … … 893 951 * \param *out output stream for debugging 894 952 */ 895 void molecule::CountAtoms() 896 { 953 int molecule::doCountAtoms() 954 { 955 int res = size(); 897 956 int i = 0; 898 atom *Walker = start; 899 while (Walker->next != end) { 900 Walker = Walker->next; 957 NoNonHydrogen = 0; 958 for (molecule::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) { 959 (*iter)->nr = i; // update number in molecule (for easier referencing in FragmentMolecule lateron) 960 if ((*iter)->type->Z != 1) // count non-hydrogen atoms whilst at it 961 NoNonHydrogen++; 962 stringstream sstr; 963 sstr << (*iter)->type->symbol << (*iter)->nr+1; 964 (*iter)->setName(sstr.str()); 965 DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl); 901 966 i++; 902 967 } 903 if ((AtomCount == 0) || (i != AtomCount)) { 904 DoLog(3) && (Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl); 905 AtomCount = i; 906 907 // count NonHydrogen atoms and give each atom a unique name 908 if (AtomCount != 0) { 909 i=0; 910 NoNonHydrogen = 0; 911 Walker = start; 912 while (Walker->next != end) { 913 Walker = Walker->next; 914 Walker->nr = i; // update number in molecule (for easier referencing in FragmentMolecule lateron) 915 if (Walker->type->Z != 1) // count non-hydrogen atoms whilst at it 916 NoNonHydrogen++; 917 Free(&Walker->Name); 918 Walker->Name = Malloc<char>(6, "molecule::CountAtoms: *walker->Name"); 919 sprintf(Walker->Name, "%2s%02d", Walker->type->symbol, Walker->nr+1); 920 DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->Name << "." << endl); 921 i++; 922 } 923 } else 924 DoLog(3) && (Log() << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl); 925 } 968 return res; 926 969 }; 927 970 … … 985 1028 /// first count both their atoms and elements and update lists thereby ... 986 1029 //Log() << Verbose(0) << "Counting atoms, updating list" << endl; 987 CountAtoms();988 OtherMolecule->CountAtoms();989 1030 CountElements(); 990 1031 OtherMolecule->CountElements(); … … 993 1034 /// -# AtomCount 994 1035 if (result) { 995 if ( AtomCount != OtherMolecule->AtomCount) {996 DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount<< endl);1036 if (getAtomCount() != OtherMolecule->getAtomCount()) { 1037 DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl); 997 1038 result = false; 998 } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount<< endl;1039 } else Log() << Verbose(4) << "AtomCounts match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl; 999 1040 } 1000 1041 /// -# ElementCount … … 1033 1074 if (result) { 1034 1075 DoLog(5) && (Log() << Verbose(5) << "Calculating distances" << endl); 1035 Distances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances");1036 OtherDistances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances");1076 Distances = new double[getAtomCount()]; 1077 OtherDistances = new double[getAtomCount()]; 1037 1078 SetIndexedArrayForEachAtomTo ( Distances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity); 1038 1079 SetIndexedArrayForEachAtomTo ( OtherDistances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity); 1080 for(int i=0;i<getAtomCount();i++) { 1081 Distances[i] = 0.; 1082 OtherDistances[i] = 0.; 1083 } 1039 1084 1040 1085 /// ... sort each list (using heapsort (o(N log N)) from GSL) 1041 1086 DoLog(5) && (Log() << Verbose(5) << "Sorting distances" << endl); 1042 PermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermMap"); 1043 OtherPermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *OtherPermMap"); 1044 gsl_heapsort_index (PermMap, Distances, AtomCount, sizeof(double), CompareDoubles); 1045 gsl_heapsort_index (OtherPermMap, OtherDistances, AtomCount, sizeof(double), CompareDoubles); 1046 PermutationMap = Calloc<int>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermutationMap"); 1087 PermMap = new size_t[getAtomCount()]; 1088 OtherPermMap = new size_t[getAtomCount()]; 1089 for(int i=0;i<getAtomCount();i++) { 1090 PermMap[i] = 0; 1091 OtherPermMap[i] = 0; 1092 } 1093 gsl_heapsort_index (PermMap, Distances, getAtomCount(), sizeof(double), CompareDoubles); 1094 gsl_heapsort_index (OtherPermMap, OtherDistances, getAtomCount(), sizeof(double), CompareDoubles); 1095 PermutationMap = new int[getAtomCount()]; 1096 for(int i=0;i<getAtomCount();i++) 1097 PermutationMap[i] = 0; 1047 1098 DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl); 1048 for(int i= AtomCount;i--;)1099 for(int i=getAtomCount();i--;) 1049 1100 PermutationMap[PermMap[i]] = (int) OtherPermMap[i]; 1050 1101 … … 1052 1103 DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl); 1053 1104 flag = 0; 1054 for (int i=0;i< AtomCount;i++) {1105 for (int i=0;i<getAtomCount();i++) { 1055 1106 DoLog(5) && (Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " << threshold << endl); 1056 1107 if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold) … … 1059 1110 1060 1111 // free memory 1061 Free(&PermMap);1062 Free(&OtherPermMap);1063 Free(&Distances);1064 Free(&OtherDistances);1112 delete[](PermMap); 1113 delete[](OtherPermMap); 1114 delete[](Distances); 1115 delete[](OtherDistances); 1065 1116 if (flag) { // if not equal 1066 Free(&PermutationMap);1117 delete[](PermutationMap); 1067 1118 result = false; 1068 1119 } … … 1088 1139 int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule) 1089 1140 { 1090 atom *Walker = NULL, *OtherWalker = NULL;1091 1141 DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl); 1092 int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap");1093 for (int i= AtomCount;i--;)1142 int *AtomicMap = new int[getAtomCount()]; 1143 for (int i=getAtomCount();i--;) 1094 1144 AtomicMap[i] = -1; 1095 1145 if (OtherMolecule == this) { // same molecule 1096 for (int i= AtomCount;i--;) // no need as -1 means already that there is trivial correspondence1146 for (int i=getAtomCount();i--;) // no need as -1 means already that there is trivial correspondence 1097 1147 AtomicMap[i] = i; 1098 1148 DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl); 1099 1149 } else { 1100 1150 DoLog(4) && (Log() << Verbose(4) << "Map is "); 1101 Walker = start; 1102 while (Walker->next != end) { 1103 Walker = Walker->next; 1104 if (Walker->father == NULL) { 1105 AtomicMap[Walker->nr] = -2; 1151 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 1152 if ((*iter)->father == NULL) { 1153 AtomicMap[(*iter)->nr] = -2; 1106 1154 } else { 1107 OtherWalker = OtherMolecule->start; 1108 while (OtherWalker->next != OtherMolecule->end) { 1109 OtherWalker = OtherWalker->next; 1155 for (molecule::const_iterator runner = OtherMolecule->begin(); runner != OtherMolecule->end(); ++runner) { 1110 1156 //for (int i=0;i<AtomCount;i++) { // search atom 1111 //for (int j=0;j<OtherMolecule-> AtomCount;j++) {1112 //Log() << Verbose(4) << "Comparing father " << Walker->father << " with the other one " << OtherWalker->father << "." << endl;1113 if ( Walker->father == OtherWalker)1114 AtomicMap[ Walker->nr] = OtherWalker->nr;1157 //for (int j=0;j<OtherMolecule->getAtomCount();j++) { 1158 //Log() << Verbose(4) << "Comparing father " << (*iter)->father << " with the other one " << (*runner)->father << "." << endl; 1159 if ((*iter)->father == (*runner)) 1160 AtomicMap[(*iter)->nr] = (*runner)->nr; 1115 1161 } 1116 1162 } 1117 DoLog(0) && (Log() << Verbose(0) << AtomicMap[ Walker->nr] << "\t");1163 DoLog(0) && (Log() << Verbose(0) << AtomicMap[(*iter)->nr] << "\t"); 1118 1164 } 1119 1165 DoLog(0) && (Log() << Verbose(0) << endl); … … 1149 1195 void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) const 1150 1196 { 1151 atom *Walker = start; 1152 while (Walker->next != end) { 1153 Walker = Walker->next; 1154 array[(Walker->*index)] = Walker; 1197 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 1198 array[((*iter)->*index)] = (*iter); 1155 1199 } 1156 1200 }; -
src/molecule.hpp
re58856b rf2a1d3 34 34 #include "tesselation.hpp" 35 35 #include "Patterns/Observer.hpp" 36 #include "Patterns/ObservedIterator.hpp" 36 37 #include "Patterns/Cacheable.hpp" 37 38 … … 90 91 friend molecule *NewMolecule(); 91 92 friend void DeleteMolecule(molecule *); 93 92 94 public: 95 typedef std::set<atom*> atomSet; 96 typedef ObservedIterator<atomSet> iterator; 97 typedef atomSet::const_iterator const_iterator; 98 93 99 const periodentafel * const elemente; //!< periodic table with each element 94 atom *start; //!< start of atom list 95 atom *end; //!< end of atom list 96 bond *first; //!< start of bond list 97 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 98 105 int MDSteps; //!< The number of MD steps in Trajectories 99 int AtomCount; //!< number of atoms, brought up-to-date by CountAtoms()106 //int AtomCount; //!< number of atoms, brought up-to-date by CountAtoms() 100 107 int BondCount; //!< number of atoms, brought up-to-date by CountBonds() 101 108 int ElementCount; //!< how many unique elements are therein … … 112 119 private: 113 120 Cacheable<string> formula; 121 Cacheable<int> AtomCount; 114 122 moleculeId_t id; 123 atomSet atoms; //<!set of atoms 115 124 protected: 125 //void CountAtoms(); 126 /** 127 * this iterator type should be used for internal variables, \ 128 * since it will not lock 129 */ 130 typedef atomSet::iterator internal_iterator; 131 132 116 133 molecule(const periodentafel * const teil); 117 134 virtual ~molecule(); … … 121 138 //getter and setter 122 139 const std::string getName(); 140 int getAtomCount() const; 141 int doCountAtoms(); 123 142 moleculeId_t getId(); 124 143 void setId(moleculeId_t); … … 127 146 std::string calcFormula(); 128 147 148 iterator begin(); 149 const_iterator begin() const; 150 iterator end(); 151 const_iterator end() const; 152 bool empty() const; 153 size_t size() const; 154 const_iterator erase( const_iterator loc ); 155 const_iterator erase( atom *& key ); 156 const_iterator find ( atom *& key ) const; 157 pair<iterator,bool> insert ( atom * const key ); 158 129 159 130 160 // re-definition of virtual functions from PointCloud … … 132 162 Vector *GetCenter() const ; 133 163 TesselPoint *GetPoint() const ; 134 TesselPoint *GetTerminalPoint() const ;135 164 int GetMaxId() const; 136 165 void GoToNext() const ; 137 void GoToPrevious() const ;138 166 void GoToFirst() const ; 139 void GoToLast() const ;140 167 bool IsEmpty() const ; 141 168 bool IsEnd() const ; … … 226 253 bool RemoveBond(bond *pointer); 227 254 bool RemoveBonds(atom *BondPartner); 255 bool hasBondStructure(); 256 unsigned int CountBonds() const; 228 257 229 258 /// Find atoms. … … 232 261 233 262 /// Count and change present atoms' coordination. 234 void CountAtoms();235 263 void CountElements(); 236 264 void CalculateOrbitals(class config &configuration); … … 249 277 Vector * DetermineCenterOfGravity(); 250 278 Vector * DetermineCenterOfAll() const; 279 Vector * DetermineCenterOfBox() const; 251 280 void SetNameFromFilename(const char *filename); 252 281 void SetBoxDimension(Vector *dim); … … 301 330 bool StoreForcesFile(MoleculeListClass *BondFragments, char *path, int *SortIndex); 302 331 bool CreateMappingLabelsToConfigSequence(int *&SortIndex); 332 bool CreateFatherLookupTable(atom **&LookupTable, int count = 0); 303 333 void BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem); 304 334 /// -# BOSSANOVA … … 329 359 private: 330 360 int last_atom; //!< number given to last atom 331 mutable atom *InternalPointer; //!< internal pointer for PointCloud361 mutable internal_iterator InternalPointer; //!< internal pointer for PointCloud 332 362 }; 333 363 … … 350 380 bool StoreForcesFile(char *path, int *SortIndex); 351 381 void insert(molecule *mol); 382 void erase(molecule *mol); 352 383 molecule * ReturnIndex(int index); 353 384 bool OutputConfigForListOfFragments(config *configuration, int *SortIndex); -
src/molecule_dynamics.cpp
re58856b rf2a1d3 10 10 #include "config.hpp" 11 11 #include "element.hpp" 12 #include "info.hpp" 12 13 #include "log.hpp" 13 14 #include "memoryallocator.hpp" … … 28 29 gsl_matrix *A = gsl_matrix_alloc(NDIM,NDIM); 29 30 gsl_vector *x = gsl_vector_alloc(NDIM); 30 atom * Runner = mol->start;31 31 atom *Sprinter = NULL; 32 32 Vector trajectory1, trajectory2, normal, TestVector; 33 33 double Norm1, Norm2, tmp, result = 0.; 34 34 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++) 35 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 36 if ((*iter) == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++) 38 37 break; 39 38 // determine normalized trajectories direction vector (n1, n2) … … 42 41 trajectory1.Normalize(); 43 42 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);43 Sprinter = Params.PermutationMap[(*iter)->nr]; // find second target point 44 trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep); 46 45 trajectory2.Normalize(); 47 46 Norm2 = trajectory1.Norm(); 48 47 // check whether either is zero() 49 48 if ((Norm1 < MYEPSILON) && (Norm2 < MYEPSILON)) { 50 tmp = Walker->Trajectory.R.at(Params.startstep).distance( Runner->Trajectory.R.at(Params.startstep));49 tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep)); 51 50 } else if (Norm1 < MYEPSILON) { 52 51 Sprinter = Params.PermutationMap[Walker->nr]; // find first target point 53 trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - Runner->Trajectory.R.at(Params.startstep);52 trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep); 54 53 trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything 55 54 trajectory1 -= trajectory2; // project the part in norm direction away 56 55 tmp = trajectory1.Norm(); // remaining norm is distance 57 56 } else if (Norm2 < MYEPSILON) { 58 Sprinter = Params.PermutationMap[ Runner->nr]; // find second target point57 Sprinter = Params.PermutationMap[(*iter)->nr]; // find second target point 59 58 trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep); // copy second offset 60 59 trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything … … 66 65 // Log() << Verbose(0) << " and "; 67 66 // Log() << Verbose(0) << trajectory2; 68 tmp = Walker->Trajectory.R.at(Params.startstep).distance( Runner->Trajectory.R.at(Params.startstep));67 tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep)); 69 68 // Log() << Verbose(0) << " with distance " << tmp << "." << endl; 70 69 } else { // determine distance by finding minimum distance 71 // Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << * Runner<< " are linear independent ";70 // Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *(*iter) << " are linear independent "; 72 71 // Log() << Verbose(0) << endl; 73 72 // Log() << Verbose(0) << "First Trajectory: "; … … 85 84 gsl_matrix_set(A, 1, i, trajectory2[i]); 86 85 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]));86 gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep)[i] - (*iter)->Trajectory.R.at(Params.startstep)[i])); 88 87 } 89 88 // solve the linear system by Householder transformations … … 96 95 trajectory2.Scale(gsl_vector_get(x,1)); 97 96 normal.Scale(gsl_vector_get(x,2)); 98 TestVector = Runner->Trajectory.R.at(Params.startstep) + trajectory2 + normal97 TestVector = (*iter)->Trajectory.R.at(Params.startstep) + trajectory2 + normal 99 98 - (Walker->Trajectory.R.at(Params.startstep) + trajectory1); 100 99 if (TestVector.Norm() < MYEPSILON) { … … 125 124 { 126 125 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)) { 126 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 127 if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[(*iter)->nr]) && (Walker->nr < (*iter)->nr)) { 131 128 // atom *Sprinter = PermutationMap[Walker->nr]; 132 // Log() << Verbose(0) << *Walker << " and " << * Runner<< " are heading to the same target at ";129 // Log() << Verbose(0) << *Walker << " and " << *(*iter) << " are heading to the same target at "; 133 130 // Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep); 134 131 // Log() << Verbose(0) << ", penalting." << endl; … … 161 158 // go through every atom 162 159 atom *Runner = NULL; 163 atom *Walker = start; 164 while (Walker->next != end) { 165 Walker = Walker->next; 160 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 166 161 // 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)));162 Runner = Params.PermutationMap[(*iter)->nr]; // find target point 163 tmp = ((*iter)->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep))); 169 164 tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem; 170 165 result += Params.PenaltyConstants[0] * tmp; … … 172 167 173 168 // second term: sum of distances to other trajectories 174 result += SumDistanceOfTrajectories( Walker, this, Params);169 result += SumDistanceOfTrajectories((*iter), this, Params); 175 170 176 171 // third term: penalty for equal targets 177 result += PenalizeEqualTargets( Walker, this, Params);172 result += PenalizeEqualTargets((*iter), this, Params); 178 173 } 179 174 … … 189 184 { 190 185 stringstream zeile1, zeile2; 191 int *DoubleList = Calloc<int>(AtomCount, "PrintPermutationMap: *DoubleList"); 186 int *DoubleList = new int[AtomCount]; 187 for(int i=0;i<AtomCount;i++) 188 DoubleList[i] = 0; 192 189 int doubles = 0; 193 190 zeile1 << "PermutationMap: "; … … 203 200 if (doubles >0) 204 201 DoLog(2) && (Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl); 205 Free(&DoubleList);202 delete[](DoubleList); 206 203 // Log() << Verbose(2) << zeile1.str() << endl << zeile2.str() << endl; 207 204 }; … … 213 210 void FillDistanceList(molecule *mol, struct EvaluatePotential &Params) 214 211 { 215 for (int i=mol-> AtomCount; i--;) {212 for (int i=mol->getAtomCount(); i--;) { 216 213 Params.DistanceList[i] = new DistanceMap; // is the distance sorted target list per atom 217 214 Params.DistanceList[i]->clear(); 218 215 } 219 216 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) ); 217 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 218 for (molecule::const_iterator runner = mol->begin(); runner != mol->end(); ++runner) { 219 Params.DistanceList[(*iter)->nr]->insert( DistancePair((*iter)->Trajectory.R.at(Params.startstep).distance((*runner)->Trajectory.R.at(Params.endstep)), (*runner)) ); 228 220 } 229 221 } … … 237 229 void CreateInitialLists(molecule *mol, struct EvaluatePotential &Params) 238 230 { 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); 231 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 232 Params.StepList[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin(); // stores the step to the next iterator that could be a possible next target 233 Params.PermutationMap[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin()->second; // always pick target with the smallest distance 234 Params.DoubleList[Params.DistanceList[(*iter)->nr]->begin()->second->nr]++; // increase this target's source count (>1? not injective) 235 Params.DistanceIterators[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin(); // and remember which one we picked 236 DoLog(2) && (Log() << Verbose(2) << **iter << " starts with distance " << Params.DistanceList[(*iter)->nr]->begin()->first << "." << endl); 247 237 } 248 238 }; … … 285 275 void MakeInjectivePermutation(molecule *mol, struct EvaluatePotential &Params) 286 276 { 287 atom *Walker = mol->start;277 molecule::const_iterator iter = mol->begin(); 288 278 DistanceMap::iterator NewBase; 289 279 double Potential = fabs(mol->ConstrainedPotential(Params)); 290 280 281 if (mol->empty()) { 282 eLog() << Verbose(1) << "Molecule is empty." << endl; 283 return; 284 } 291 285 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't286 PrintPermutationMap(mol->getAtomCount(), Params); 287 iter++; 288 if (iter == mol->end()) // round-robin at the end 289 iter = mol->begin(); 290 if (Params.DoubleList[Params.DistanceIterators[(*iter)->nr]->second->nr] <= 1) // no need to make those injective that aren't 297 291 continue; 298 292 // 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 <=1293 Potential = TryNextNearestNeighbourForInjectivePermutation(mol, (*iter), Potential, Params); 294 } 295 for (int i=mol->getAtomCount(); i--;) // now each single entry in the DoubleList should be <=1 302 296 if (Params.DoubleList[i] > 1) { 303 297 DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl); … … 338 332 double Potential, OldPotential, OlderPotential; 339 333 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");334 Params.PermutationMap = new atom *[getAtomCount()]; 335 Params.DistanceList = new DistanceMap *[getAtomCount()]; 336 Params.DistanceIterators = new DistanceMap::iterator[getAtomCount()]; 337 Params.DoubleList = new int[getAtomCount()]; 338 Params.StepList = new DistanceMap::iterator[getAtomCount()]; 345 339 int round; 346 atom * Walker = NULL, *Runner = NULL, *Sprinter = NULL;340 atom *Sprinter = NULL; 347 341 DistanceMap::iterator Rider, Strider; 342 343 // set to zero 344 for (int i=0;i<getAtomCount();i++) { 345 Params.PermutationMap[i] = NULL; 346 Params.DoubleList[i] = 0; 347 } 348 348 349 349 /// Minimise the potential … … 362 362 DoLog(1) && (Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl); 363 363 MakeInjectivePermutation(this, Params); 364 Free(&Params.DoubleList);364 delete[](Params.DoubleList); 365 365 366 366 // argument minimise the constrained potential in this injective PermutationMap … … 371 371 DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl); 372 372 OlderPotential = OldPotential; 373 molecule::const_iterator iter; 373 374 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(); 375 iter = begin(); 376 for (; iter != end(); ++iter) { 377 PrintPermutationMap(getAtomCount(), Params); 378 Sprinter = Params.DistanceIterators[(*iter)->nr]->second; // store initial partner 379 Strider = Params.DistanceIterators[(*iter)->nr]; //remember old iterator 380 Params.DistanceIterators[(*iter)->nr] = Params.StepList[(*iter)->nr]; 381 if (Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->end()) {// stop, before we run through the list and still on 382 Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->begin(); 383 383 break; 384 384 } 385 //Log() << Verbose(2) << "Current Walker: " << * Walker << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[Walker->nr]->second << "." << endl;385 //Log() << Verbose(2) << "Current Walker: " << *(*iter) << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[(*iter)->nr]->second << "." << endl; 386 386 // 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;387 molecule::const_iterator runner = begin(); 388 for (; runner != end(); ++runner) { // find the source whose toes we might be stepping on (Walker's new target should be in use by another already) 389 if (Params.PermutationMap[(*runner)->nr] == Params.DistanceIterators[(*iter)->nr]->second) { 390 //Log() << Verbose(2) << "Found the corresponding owner " << *(*runner) << " to " << *PermutationMap[(*runner)->nr] << "." << endl; 391 391 break; 392 392 } 393 Runner = Runner->next;394 393 } 395 if ( Runner != end) { // we found the other source394 if (runner != end()) { // we found the other source 396 395 // then look in its distance list for Sprinter 397 Rider = Params.DistanceList[ Runner->nr]->begin();398 for (; Rider != Params.DistanceList[ Runner->nr]->end(); Rider++)396 Rider = Params.DistanceList[(*runner)->nr]->begin(); 397 for (; Rider != Params.DistanceList[(*runner)->nr]->end(); Rider++) 399 398 if (Rider->second == Sprinter) 400 399 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;400 if (Rider != Params.DistanceList[(*runner)->nr]->end()) { // if we have found one 401 //Log() << Verbose(2) << "Current Other: " << *(*runner) << " with old/next candidate " << *PermutationMap[(*runner)->nr] << "/" << *Rider->second << "." << endl; 403 402 // 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);403 Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // put next farther distance into PermutationMap 404 Params.PermutationMap[(*runner)->nr] = Sprinter; // and hand the old target to its respective owner 405 PrintPermutationMap(getAtomCount(), Params); 407 406 // calculate the new potential 408 407 //Log() << Verbose(2) << "Checking new potential ..." << endl; … … 410 409 if (Potential > OldPotential) { // we made everything worse! Undo ... 411 410 //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;411 //Log() << Verbose(3) << "Setting " << *(*runner) << "'s source to " << *Params.DistanceIterators[(*runner)->nr]->second << "." << endl; 413 412 // 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;413 Params.PermutationMap[(*runner)->nr] = Params.DistanceIterators[(*runner)->nr]->second; 415 414 // 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;415 Params.DistanceIterators[(*iter)->nr] = Strider; // take next farther distance target 416 //Log() << Verbose(3) << "Setting " << *(*iter) << "'s source to " << *Params.DistanceIterators[(*iter)->nr]->second << "." << endl; 417 Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; 419 418 } else { 420 Params.DistanceIterators[ Runner->nr] = Rider; // if successful also move the pointer in the iterator list419 Params.DistanceIterators[(*runner)->nr] = Rider; // if successful also move the pointer in the iterator list 421 420 DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl); 422 421 OldPotential = Potential; … … 428 427 //Log() << Verbose(0) << endl; 429 428 } else { 430 DoeLog(1) && (eLog()<< Verbose(1) << * Runner << " was not the owner of " << *Sprinter << "!" << endl);429 DoeLog(1) && (eLog()<< Verbose(1) << **runner << " was not the owner of " << *Sprinter << "!" << endl); 431 430 exit(255); 432 431 } 433 432 } else { 434 Params.PermutationMap[ Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // new target has no source!433 Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // new target has no source! 435 434 } 436 Params.StepList[ Walker->nr]++; // take next farther distance target435 Params.StepList[(*iter)->nr]++; // take next farther distance target 437 436 } 438 } while ( Walker->next != end);437 } while (++iter != end()); 439 438 } while ((OlderPotential - OldPotential) > 1e-3); 440 439 DoLog(1) && (Log() << Verbose(1) << "done." << endl); … … 442 441 443 442 /// free memory and return with evaluated potential 444 for (int i= AtomCount; i--;)443 for (int i=getAtomCount(); i--;) 445 444 Params.DistanceList[i]->clear(); 446 Free(&Params.DistanceList);447 Free(&Params.DistanceIterators);445 delete[](Params.DistanceList); 446 delete[](Params.DistanceIterators); 448 447 return ConstrainedPotential(Params); 449 448 }; … … 483 482 // Get the Permutation Map by MinimiseConstrainedPotential 484 483 atom **PermutationMap = NULL; 485 atom * Walker = NULL, *Sprinter = NULL;484 atom *Sprinter = NULL; 486 485 if (!MapByIdentity) 487 486 MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem()); 488 487 else { 489 PermutationMap = Malloc<atom *>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap");488 PermutationMap = new atom *[getAtomCount()]; 490 489 SetIndexedArrayForEachAtomTo( PermutationMap, &atom::nr ); 491 490 } … … 502 501 mol = World::getInstance().createMolecule(); 503 502 MoleculePerStep->insert(mol); 504 Walker = start; 505 while (Walker->next != end) { 506 Walker = Walker->next; 503 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 507 504 // add to molecule list 508 Sprinter = mol->AddCopyAtom( Walker);505 Sprinter = mol->AddCopyAtom((*iter)); 509 506 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);507 Sprinter->x[n] = (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps); 511 508 // add to Trajectories 512 509 //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl; 513 510 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.;511 (*iter)->Trajectory.R.at(step)[n] = (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps); 512 (*iter)->Trajectory.U.at(step)[n] = 0.; 513 (*iter)->Trajectory.F.at(step)[n] = 0.; 517 514 } 518 515 } … … 522 519 523 520 // store the list to single step files 524 int *SortIndex = Malloc<int>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: *SortIndex");525 for (int i= AtomCount; i--; )521 int *SortIndex = new int[getAtomCount()]; 522 for (int i=getAtomCount(); i--; ) 526 523 SortIndex[i] = i; 527 524 status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex); 525 delete[](SortIndex); 528 526 529 527 // free and return 530 Free(&PermutationMap);528 delete[](PermutationMap); 531 529 delete(MoleculePerStep); 532 530 return status; … … 548 546 bool molecule::VerletForceIntegration(char *file, config &configuration) 549 547 { 548 Info FunctionInfo(__func__); 550 549 ifstream input(file); 551 550 string token; … … 567 566 return false; 568 567 } 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);568 if (Force.RowCounter[0] != getAtomCount()) { 569 DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << getAtomCount() << "." << endl); 571 570 performCriticalExit(); 572 571 return false; … … 574 573 // correct Forces 575 574 Velocity.Zero(); 576 for(int i=0;i< AtomCount;i++)575 for(int i=0;i<getAtomCount();i++) 577 576 for(int d=0;d<NDIM;d++) { 578 577 Velocity[d] += Force.Matrix[0][i][d+5]; 579 578 } 580 for(int i=0;i< AtomCount;i++)579 for(int i=0;i<getAtomCount();i++) 581 580 for(int d=0;d<NDIM;d++) { 582 Force.Matrix[0][i][d+5] -= Velocity[d]/ (double)AtomCount;581 Force.Matrix[0][i][d+5] -= Velocity[d]/static_cast<double>(getAtomCount()); 583 582 } 584 583 // solve a constrained potential if we are meant to … … 588 587 ConstrainedPotentialEnergy = MinimiseConstrainedPotential(PermutationMap,configuration.DoConstrainedMD, 0, configuration.GetIsAngstroem()); 589 588 EvaluateConstrainedForces(configuration.DoConstrainedMD, 0, PermutationMap, &Force); 590 Free(&PermutationMap);589 delete[](PermutationMap); 591 590 } 592 591 593 592 // and perform Verlet integration for each atom with position, velocity and force vector 594 593 // check size of vectors 595 ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 );596 597 ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps , &configuration, &Force);594 //ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 ); 595 596 ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps+1, &configuration, &Force); 598 597 } 599 598 // correct velocities (rather momenta) so that center of mass remains motionless 600 599 Velocity.Zero(); 601 600 IonMass = 0.; 602 ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps , &IonMass, &Velocity );601 ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps+1, &IonMass, &Velocity ); 603 602 604 603 // correct velocities (rather momenta) so that center of mass remains motionless 605 604 Velocity.Scale(1./IonMass); 606 605 ActualTemp = 0.; 607 ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps , &Velocity );606 ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps+1, &Velocity ); 608 607 Thermostats(configuration, ActualTemp, Berendsen); 609 608 MDSteps++; … … 683 682 delta_alpha = 0.; 684 683 ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha ); 685 delta_alpha = (delta_alpha - (3.* AtomCount+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass);684 delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass); 686 685 configuration.alpha += delta_alpha*configuration.Deltat; 687 686 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl); -
src/molecule_fragmentation.cpp
re58856b rf2a1d3 39 39 int FragmentCount; 40 40 // get maximum bond degree 41 atom *Walker = start; 42 while (Walker->next != end) { 43 Walker = Walker->next; 44 c = (Walker->ListOfBonds.size() > c) ? Walker->ListOfBonds.size() : c; 41 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 42 c = ((*iter)->ListOfBonds.size() > c) ? (*iter)->ListOfBonds.size() : c; 45 43 } 46 44 FragmentCount = NoNonHydrogen*(1 << (c*order)); … … 94 92 GraphTestPair testGraphInsert; 95 93 int NumberOfFragments = 0; 96 char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - filename");94 char filename[MAXSTRINGSIZE]; 97 95 98 96 if (FragmentList == NULL) { // check list pointer … … 106 104 if (InputFile != NULL) { 107 105 // each line represents a new fragment 108 char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - *buffer");106 char buffer[MAXSTRINGSIZE]; 109 107 // 1. parse keysets and insert into temp. graph 110 108 while (!InputFile.eof()) { … … 122 120 InputFile.close(); 123 121 InputFile.clear(); 124 Free(&buffer); 125 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 122 DoLog(1) && (Log() << Verbose(1) << "\t ... done." << endl); 126 123 } else { 127 DoLog(1) && (Log() << Verbose(1) << " File " << filename << " not found." << endl);124 DoLog(1) && (Log() << Verbose(1) << "\t ... File " << filename << " not found." << endl); 128 125 status = false; 129 126 } 130 127 131 Free(&filename);132 128 return status; 133 129 }; … … 148 144 int NumberOfFragments = 0; 149 145 double TEFactor; 150 char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseTEFactorsFile - filename");146 char filename[MAXSTRINGSIZE]; 151 147 152 148 if (FragmentList == NULL) { // check list pointer … … 179 175 } 180 176 181 // free memory182 Free(&filename);183 184 177 return status; 185 178 }; … … 317 310 int No = 0, FragOrder = 0; 318 311 double Value = 0.; 319 char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::CheckOrderAtSite: *buffer");312 char buffer[MAXSTRINGSIZE]; 320 313 sprintf(buffer, "%s/%s%s.dat", path, FRAGMENTPREFIX, ENERGYPERFRAGMENT); 321 314 ifstream InputFile(buffer, ios::in); … … 345 338 InputFile.clear(); 346 339 } 347 Free(&buffer);348 340 349 341 return AdaptiveCriteriaList; … … 359 351 map<double, pair<int,int> > * ReMapAdaptiveCriteriaListToValue(map<int, pair<double,int> > *AdaptiveCriteriaList, molecule *mol) 360 352 { 361 atom *Walker = mol->start;353 atom *Walker = NULL; 362 354 map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ; 363 355 DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl); … … 391 383 bool MarkUpdateCandidates(bool *AtomMask, map<double, pair<int,int> > &FinalRootCandidates, int Order, molecule *mol) 392 384 { 393 atom *Walker = mol->start;385 atom *Walker = NULL; 394 386 int No = -1; 395 387 bool status = false; … … 435 427 bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path) 436 428 { 437 atom *Walker = start;438 429 bool status = false; 439 430 440 431 // initialize mask list 441 for(int i= AtomCount;i--;)432 for(int i=getAtomCount();i--;) 442 433 AtomMask[i] = false; 443 434 444 435 if (Order < 0) { // adaptive increase of BondOrder per site 445 if (AtomMask[ AtomCount] == true) // break after one step436 if (AtomMask[getAtomCount()] == true) // break after one step 446 437 return false; 447 438 … … 457 448 if (AdaptiveCriteriaList->empty()) { 458 449 DoeLog(2) && (eLog()<< Verbose(2) << "Unable to parse file, incrementing all." << endl); 459 while (Walker->next != end) { 460 Walker = Walker->next; 450 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 461 451 #ifdef ADDHYDROGEN 462 if ( Walker->type->Z != 1) // skip hydrogen452 if ((*iter)->type->Z != 1) // skip hydrogen 463 453 #endif 464 454 { 465 AtomMask[ Walker->nr] = true; // include all (non-hydrogen) atoms455 AtomMask[(*iter)->nr] = true; // include all (non-hydrogen) atoms 466 456 status = true; 467 457 } … … 474 464 MarkUpdateCandidates(AtomMask, *FinalRootCandidates, Order, this); 475 465 476 Free(&IndexKeySetList);477 Free(&AdaptiveCriteriaList);478 Free(&FinalRootCandidates);466 delete[](IndexKeySetList); 467 delete[](AdaptiveCriteriaList); 468 delete[](FinalRootCandidates); 479 469 } else { // global increase of Bond Order 480 while (Walker->next != end) { 481 Walker = Walker->next; 470 for(molecule::const_iterator iter = begin(); iter != end(); ++iter) { 482 471 #ifdef ADDHYDROGEN 483 if ( Walker->type->Z != 1) // skip hydrogen472 if ((*iter)->type->Z != 1) // skip hydrogen 484 473 #endif 485 474 { 486 AtomMask[ Walker->nr] = true; // include all (non-hydrogen) atoms487 if ((Order != 0) && ( Walker->AdaptiveOrder < Order)) // && (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]))475 AtomMask[(*iter)->nr] = true; // include all (non-hydrogen) atoms 476 if ((Order != 0) && ((*iter)->AdaptiveOrder < Order)) // && ((*iter)->AdaptiveOrder < MinimumRingSize[(*iter)->nr])) 488 477 status = true; 489 478 } 490 479 } 491 if (( Order == 0) && (AtomMask[AtomCount] == false)) // single stepping, just check480 if ((!Order) && (!AtomMask[getAtomCount()])) // single stepping, just check 492 481 status = true; 493 482 … … 500 489 } 501 490 502 PrintAtomMask(AtomMask, AtomCount); // for debugging491 PrintAtomMask(AtomMask, getAtomCount()); // for debugging 503 492 504 493 return status; … … 516 505 return false; 517 506 } 518 SortIndex = Malloc<int>(AtomCount, "molecule::CreateMappingLabelsToConfigSequence: *SortIndex");519 for(int i= AtomCount;i--;)507 SortIndex = new int[getAtomCount()]; 508 for(int i=getAtomCount();i--;) 520 509 SortIndex[i] = -1; 521 510 … … 524 513 525 514 return true; 515 }; 516 517 518 519 /** Creates a lookup table for true father's Atom::Nr -> atom ptr. 520 * \param *start begin of list (STL iterator, i.e. first item) 521 * \paran *end end of list (STL iterator, i.e. one past last item) 522 * \param **Lookuptable pointer to return allocated lookup table (should be NULL on start) 523 * \param count optional predetermined size for table (otherwise we set the count to highest true father id) 524 * \return true - success, false - failure 525 */ 526 bool molecule::CreateFatherLookupTable(atom **&LookupTable, int count) 527 { 528 bool status = true; 529 int AtomNo; 530 531 if (LookupTable != NULL) { 532 Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl; 533 return false; 534 } 535 536 // count them 537 if (count == 0) { 538 for (molecule::iterator iter = begin(); iter != end(); ++iter) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron 539 count = (count < (*iter)->GetTrueFather()->nr) ? (*iter)->GetTrueFather()->nr : count; 540 } 541 } 542 if (count <= 0) { 543 Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl; 544 return false; 545 } 546 547 // allocate and fill 548 LookupTable = new atom *[count]; 549 if (LookupTable == NULL) { 550 eLog() << Verbose(0) << "LookupTable memory allocation failed!" << endl; 551 performCriticalExit(); 552 status = false; 553 } else { 554 for (int i=0;i<count;i++) 555 LookupTable[i] = NULL; 556 for (molecule::iterator iter = begin(); iter != end(); ++iter) { 557 AtomNo = (*iter)->GetTrueFather()->nr; 558 if ((AtomNo >= 0) && (AtomNo < count)) { 559 //*out << "Setting LookupTable[" << AtomNo << "] to " << *(*iter) << endl; 560 LookupTable[AtomNo] = (*iter); 561 } else { 562 Log() << Verbose(0) << "Walker " << *(*iter) << " exceeded range of nuclear ids [0, " << count << ")." << endl; 563 status = false; 564 break; 565 } 566 } 567 } 568 569 return status; 526 570 }; 527 571 … … 547 591 { 548 592 MoleculeListClass *BondFragments = NULL; 549 int *SortIndex = NULL; 550 int *MinimumRingSize = new int[AtomCount]; 593 int *MinimumRingSize = new int[getAtomCount()]; 551 594 int FragmentCounter; 552 595 MoleculeLeafClass *MolecularWalker = NULL; … … 576 619 577 620 // create lookup table for Atom::nr 578 FragmentationToDo = FragmentationToDo && CreateFatherLookupTable( start, end, ListOfAtoms, AtomCount);621 FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, getAtomCount()); 579 622 580 623 // === compare it with adjacency file === 581 624 FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(configuration->configpath, ListOfAtoms); 582 Free(&ListOfAtoms);625 delete[](ListOfAtoms); 583 626 584 627 // ===== 2. perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs ===== … … 586 629 587 630 // analysis of the cycles (print rings, get minimum cycle length) for each subgraph 588 for(int i= AtomCount;i--;)589 MinimumRingSize[i] = AtomCount;631 for(int i=getAtomCount();i--;) 632 MinimumRingSize[i] = getAtomCount(); 590 633 MolecularWalker = Subgraphs; 591 634 FragmentCounter = 0; … … 593 636 MolecularWalker = MolecularWalker->next; 594 637 // fill the bond structure of the individually stored subgraphs 595 MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms638 MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms 596 639 DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl); 597 640 LocalBackEdgeStack = new StackClass<bond *> (MolecularWalker->Leaf->BondCount); 598 641 // // check the list of local atoms for debugging 599 642 // Log() << Verbose(0) << "ListOfLocalAtoms for this subgraph is:" << endl; 600 // for (int i=0;i< AtomCount;i++)643 // for (int i=0;i<getAtomCount();i++) 601 644 // if (ListOfLocalAtoms[FragmentCounter][i] == NULL) 602 645 // Log() << Verbose(0) << "\tNULL"; … … 624 667 // ===== 6b. prepare and go into the adaptive (Order<0), single-step (Order==0) or incremental (Order>0) cycle 625 668 KeyStack *RootStack = new KeyStack[Subgraphs->next->Count()]; 626 AtomMask = new bool[ AtomCount+1];627 AtomMask[ AtomCount] = false;669 AtomMask = new bool[getAtomCount()+1]; 670 AtomMask[getAtomCount()] = false; 628 671 FragmentationToDo = false; // if CheckOrderAtSite just ones recommends fragmentation, we will save fragments afterwards 629 672 while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, configuration->configpath))) { 630 673 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()674 AtomMask[getAtomCount()] = true; // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite() 632 675 // ===== 6b. fill RootStack for each subgraph (second adaptivity check) ===== 633 676 Subgraphs->next->FillRootStackForSubgraphs(RootStack, AtomMask, (FragmentCounter = 0)); … … 640 683 DoLog(1) && (Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl); 641 684 //MolecularWalker->Leaf->OutputListOfBonds(out); // output atom::ListOfBonds for debugging 642 if (MolecularWalker->Leaf-> first->next != MolecularWalker->Leaf->last) {685 if (MolecularWalker->Leaf->hasBondStructure()) { 643 686 // call BOSSANOVA method 644 687 DoLog(0) && (Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl); … … 672 715 delete(Subgraphs); 673 716 } 674 Free(&FragmentList);717 delete[](FragmentList); 675 718 676 719 // ===== 8b. gather keyset lists (graphs) from all subgraphs and transform into MoleculeListClass ===== … … 690 733 if (BondFragments->ListOfMolecules.size() != 0) { 691 734 // create the SortIndex from BFS labels to order in the config file 735 int *SortIndex = NULL; 692 736 CreateMappingLabelsToConfigSequence(SortIndex); 693 737 … … 704 748 StoreKeySetFile(TotalGraph, configuration->configpath); 705 749 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); 750 { 751 // store Adjacency file 752 char filename[MAXSTRINGSIZE]; 753 strcpy(filename, FRAGMENTPREFIX); 754 strcat(filename, ADJACENCYFILE); 755 StoreAdjacencyToFile(configuration->configpath, filename); 756 } 712 757 713 758 // store Hydrogen saturation correction file … … 722 767 // free memory for bond part 723 768 DoLog(1) && (Log() << Verbose(1) << "Freeing bond memory" << endl); 724 delete(FragmentList); // remove bond molecule from memory 725 Free(&SortIndex); 769 delete[](SortIndex); 726 770 } else { 727 771 DoLog(1) && (Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl); … … 768 812 bool molecule::ParseOrderAtSiteFromFile(char *path) 769 813 { 770 unsigned char *OrderArray = Calloc<unsigned char>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *OrderArray");771 bool *MaxArray = Calloc<bool>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *MaxArray");814 unsigned char *OrderArray = new unsigned char[getAtomCount()]; 815 bool *MaxArray = new bool[getAtomCount()]; 772 816 bool status; 773 817 int AtomNr, value; 774 818 stringstream line; 775 819 ifstream file; 820 821 for(int i=0;i<getAtomCount();i++) { 822 OrderArray[i] = 0; 823 MaxArray[i] = false; 824 } 776 825 777 826 DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl); … … 796 845 SetAtomValueToIndexedArray( MaxArray, &atom::nr, &atom::MaxOrder ); 797 846 798 DoLog(1) && (Log() << Verbose(1) << " done." << endl);847 DoLog(1) && (Log() << Verbose(1) << "\t ... done." << endl); 799 848 status = true; 800 849 } else { 801 DoLog(1) && (Log() << Verbose(1) << " failed to open file " << line.str() << "." << endl);850 DoLog(1) && (Log() << Verbose(1) << "\t ... failed to open file " << line.str() << "." << endl); 802 851 status = false; 803 852 } 804 Free(&OrderArray);805 Free(&MaxArray);853 delete[](OrderArray); 854 delete[](MaxArray); 806 855 807 856 DoLog(1) && (Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl); … … 872 921 atom *OtherFather = NULL; 873 922 atom *FatherOfRunner = NULL; 874 Leaf->CountAtoms(); 875 876 atom *Runner = Leaf->start; 877 while (Runner->next != Leaf->end) { 878 Runner = Runner->next; 923 924 #ifdef ADDHYDROGEN 925 molecule::const_iterator runner; 926 #endif 927 // we increment the iter just before skipping the hydrogen 928 for (molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end();) { 879 929 LonelyFlag = true; 880 FatherOfRunner = Runner->father; 930 FatherOfRunner = (*iter)->father; 931 ASSERT(FatherOfRunner,"Atom without father found"); 881 932 if (SonList[FatherOfRunner->nr] != NULL) { // check if this, our father, is present in list 882 933 // create all bonds … … 889 940 // Log() << Verbose(3) << "Adding Bond: "; 890 941 // Log() << Verbose(0) << 891 Leaf->AddBond( Runner, SonList[OtherFather->nr], (*BondRunner)->BondDegree);942 Leaf->AddBond((*iter), SonList[OtherFather->nr], (*BondRunner)->BondDegree); 892 943 // Log() << Verbose(0) << "." << endl; 893 //NumBonds[ Runner->nr]++;944 //NumBonds[(*iter)->nr]++; 894 945 } else { 895 946 // Log() << Verbose(3) << "Not adding bond, labels in wrong order." << endl; … … 899 950 // Log() << Verbose(0) << ", who has no son in this fragment molecule." << endl; 900 951 #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))952 //Log() << Verbose(3) << "Adding Hydrogen to " << (*iter)->Name << " and a bond in between." << endl; 953 if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), (*iter), FatherOfRunner, OtherFather, IsAngstroem)) 903 954 exit(1); 904 955 #endif 905 //NumBonds[ Runner->nr] += Binder->BondDegree;956 //NumBonds[(*iter)->nr] += Binder->BondDegree; 906 957 } 907 958 } 908 959 } else { 909 DoeLog(1) && (eLog()<< Verbose(1) << "Son " << Runner->Name << " has father " << FatherOfRunner->Name << " 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 } 960 DoeLog(1) && (eLog()<< Verbose(1) << "Son " << (*iter)->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl); 961 } 962 if ((LonelyFlag) && (Leaf->getAtomCount() > 1)) { 963 DoLog(0) && (Log() << Verbose(0) << **iter << "has got bonds only to hydrogens!" << endl); 964 } 965 ++iter; 914 966 #ifdef ADDHYDROGEN 915 while ((Runner->next != Leaf->end) && (Runner->next->type->Z == 1)) // skip added hydrogen 916 Runner = Runner->next; 967 while ((iter != Leaf->end()) && ((*iter)->type->Z == 1)){ // skip added hydrogen 968 iter++; 969 } 917 970 #endif 918 971 } … … 929 982 molecule * molecule::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem) 930 983 { 931 atom **SonList = Calloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList");984 atom **SonList = new atom*[getAtomCount()]; 932 985 molecule *Leaf = World::getInstance().createMolecule(); 986 987 for(int i=0;i<getAtomCount();i++) 988 SonList[i] = NULL; 933 989 934 990 // Log() << Verbose(1) << "Begin of StoreFragmentFromKeyset." << endl; … … 939 995 940 996 //Leaflet->Leaf->ScanForPeriodicCorrection(out); 941 Free(&SonList);997 delete[](SonList); 942 998 // Log() << Verbose(1) << "End of StoreFragmentFromKeyset." << endl; 943 999 return Leaf; … … 1084 1140 int bits, TouchedIndex, SubSetDimension, SP, Added; 1085 1141 int SpaceLeft; 1086 int *TouchedList = Malloc<int>(SubOrder + 1, "molecule::SPFragmentGenerator: *TouchedList"); 1087 bond **BondsList = NULL; 1142 int *TouchedList = new int[SubOrder + 1]; 1088 1143 KeySetTestPair TestKeySetInsert; 1089 1144 … … 1124 1179 1125 1180 // then allocate and fill the list 1126 BondsList = Malloc<bond*>(SubSetDimension, "molecule::SPFragmentGenerator: **BondsList");1181 bond *BondsList[SubSetDimension]; 1127 1182 SubSetDimension = FillBondsList(BondsList, FragmentSearch->BondsPerSPList[2*SP], FragmentSearch->BondsPerSPList[2*SP+1], TouchedList, TouchedIndex); 1128 1183 … … 1130 1185 Log() << Verbose(2+verbosity) << "Calling subset generator " << SP << " away from root " << *FragmentSearch->Root << " with sub set dimension " << SubSetDimension << "." << endl; 1131 1186 SPFragmentGenerator(FragmentSearch, SP, BondsList, SubSetDimension, SubOrder-bits); 1132 1133 Free(&BondsList);1134 1187 } 1135 1188 } else { … … 1153 1206 } 1154 1207 } 1155 Free(&TouchedList);1208 delete[](TouchedList); 1156 1209 Log() << Verbose(1+verbosity) << "End of SPFragmentGenerator, " << RootDistance << " away from Root " << *FragmentSearch->Root << " and SubOrder is " << SubOrder << "." << endl; 1157 1210 }; … … 1165 1218 void InitialiseSPList(int Order, struct UniqueFragments &FragmentSearch) 1166 1219 { 1167 FragmentSearch.BondsPerSPList = Malloc<bond*>(Order * 2, "molecule::PowerSetGenerator: ***BondsPerSPList");1168 FragmentSearch.BondsPerSPCount = Malloc<int>(Order, "molecule::PowerSetGenerator: *BondsPerSPCount");1220 FragmentSearch.BondsPerSPList = new bond* [Order * 2]; 1221 FragmentSearch.BondsPerSPCount = new int[Order]; 1169 1222 for (int i=Order;i--;) { 1170 1223 FragmentSearch.BondsPerSPList[2*i] = new bond(); // start node … … 1184 1237 void FreeSPList(int Order, struct UniqueFragments &FragmentSearch) 1185 1238 { 1186 Free(&FragmentSearch.BondsPerSPCount);1239 delete[](FragmentSearch.BondsPerSPCount); 1187 1240 for (int i=Order;i--;) { 1188 1241 delete(FragmentSearch.BondsPerSPList[2*i]); 1189 1242 delete(FragmentSearch.BondsPerSPList[2*i+1]); 1190 1243 } 1191 Free(&FragmentSearch.BondsPerSPList);1244 delete[](FragmentSearch.BondsPerSPList); 1192 1245 }; 1193 1246 … … 1370 1423 int molecule::PowerSetGenerator(int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet) 1371 1424 { 1372 bond **BondsList = NULL;1373 1425 int Counter = FragmentSearch.FragmentCounter; // mark current value of counter 1374 1426 … … 1394 1446 1395 1447 // prepare the subset and call the generator 1396 BondsList = Calloc<bond*>(FragmentSearch.BondsPerSPCount[0], "molecule::PowerSetGenerator: **BondsList"); 1448 bond* BondsList[FragmentSearch.BondsPerSPCount[0]]; 1449 for(int i=0;i<FragmentSearch.BondsPerSPCount[0];i++) 1450 BondsList[i] = NULL; 1397 1451 BondsList[0] = FragmentSearch.BondsPerSPList[0]->next; // on SP level 0 there's only the root bond 1398 1452 1399 1453 SPFragmentGenerator(&FragmentSearch, 0, BondsList, FragmentSearch.BondsPerSPCount[0], Order); 1400 1401 Free(&BondsList);1402 1454 } else { 1403 1455 DoLog(0) && (Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl); … … 1507 1559 } 1508 1560 } 1509 Free(&FragmentLowerOrdersList[RootNr]);1561 delete[](FragmentLowerOrdersList[RootNr]); 1510 1562 RootNr++; 1511 1563 } 1512 Free(&FragmentLowerOrdersList);1564 delete[](FragmentLowerOrdersList); 1513 1565 }; 1514 1566 … … 1549 1601 // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5) 1550 1602 // 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"); 1603 NumMoleculesOfOrder = new int[UpgradeCount]; 1604 FragmentLowerOrdersList = new Graph**[UpgradeCount]; 1605 1606 for(int i=0;i<UpgradeCount;i++) { 1607 NumMoleculesOfOrder[i] = 0; 1608 FragmentLowerOrdersList[i] = NULL; 1609 } 1553 1610 1554 1611 // initialise the fragments structure … … 1556 1613 FragmentSearch.FragmentSet = new KeySet; 1557 1614 FragmentSearch.Root = FindAtom(RootKeyNr); 1558 FragmentSearch.ShortestPathList = Malloc<int>(AtomCount, "molecule::PowerSetGenerator: *ShortestPathList");1559 for (int i= AtomCount;i--;) {1615 FragmentSearch.ShortestPathList = new int[getAtomCount()]; 1616 for (int i=getAtomCount();i--;) { 1560 1617 FragmentSearch.ShortestPathList[i] = -1; 1561 1618 } 1562 1619 1563 1620 // Construct the complete KeySet which we need for topmost level only (but for all Roots) 1564 atom *Walker = start;1565 1621 KeySet CompleteMolecule; 1566 while (Walker->next != end) { 1567 Walker = Walker->next; 1568 CompleteMolecule.insert(Walker->GetTrueFather()->nr); 1622 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 1623 CompleteMolecule.insert((*iter)->GetTrueFather()->nr); 1569 1624 } 1570 1625 … … 1577 1632 RootKeyNr = RootStack.front(); 1578 1633 RootStack.pop_front(); 1579 Walker = FindAtom(RootKeyNr);1634 atom *Walker = FindAtom(RootKeyNr); 1580 1635 // check cyclic lengths 1581 1636 //if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) { … … 1592 1647 // allocate memory for all lower level orders in this 1D-array of ptrs 1593 1648 NumLevels = 1 << (Order-1); // (int)pow(2,Order); 1594 FragmentLowerOrdersList[RootNr] = Calloc<Graph*>(NumLevels, "molecule::FragmentBOSSANOVA: **FragmentLowerOrdersList[]"); 1649 FragmentLowerOrdersList[RootNr] = new Graph*[NumLevels]; 1650 for (int i=0;i<NumLevels;i++) 1651 FragmentLowerOrdersList[RootNr][i] = NULL; 1595 1652 1596 1653 // create top order where nothing is reduced … … 1628 1685 1629 1686 // cleanup FragmentSearch structure 1630 Free(&FragmentSearch.ShortestPathList);1687 delete[](FragmentSearch.ShortestPathList); 1631 1688 delete(FragmentSearch.FragmentSet); 1632 1689 … … 1641 1698 CombineAllOrderListIntoOne(FragmentList, FragmentLowerOrdersList, RootStack, this); 1642 1699 FreeAllOrdersList(FragmentLowerOrdersList, RootStack, this); 1643 Free(&NumMoleculesOfOrder);1700 delete[](NumMoleculesOfOrder); 1644 1701 1645 1702 DoLog(0) && (Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl); … … 1664 1721 Vector Translationvector; 1665 1722 //class StackClass<atom *> *CompStack = NULL; 1666 class StackClass<atom *> *AtomStack = new StackClass<atom *>( AtomCount);1723 class StackClass<atom *> *AtomStack = new StackClass<atom *>(getAtomCount()); 1667 1724 bool flag = true; 1668 1725 1669 1726 DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl); 1670 1727 1671 ColorList = Calloc<enum Shading>(AtomCount, "molecule::ScanForPeriodicCorrection: *ColorList"); 1728 ColorList = new enum Shading[getAtomCount()]; 1729 for (int i=0;i<getAtomCount();i++) 1730 ColorList[i] = (enum Shading)0; 1672 1731 while (flag) { 1673 1732 // remove bonds that are beyond bonddistance 1674 for(int i=NDIM;i--;) 1675 Translationvector[i] = 0.; 1733 Translationvector.Zero(); 1676 1734 // scan all bonds 1677 Binder = first;1678 1735 flag = false; 1679 while ((!flag) && (Binder->next != last)) { 1680 Binder = Binder->next; 1681 for (int i=NDIM;i--;) { 1682 tmp = fabs(Binder->leftatom->x[i] - Binder->rightatom->x[i]); 1683 //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl; 1684 if (tmp > BondDistance) { 1685 OtherBinder = Binder->next; // note down binding partner for later re-insertion 1686 unlink(Binder); // unlink bond 1687 DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl); 1688 flag = true; 1689 break; 1736 for(molecule::iterator AtomRunner = begin(); (!flag) && (AtomRunner != end()); ++AtomRunner) 1737 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); (!flag) && (BondRunner != (*AtomRunner)->ListOfBonds.end()); ++BondRunner) { 1738 Binder = (*BondRunner); 1739 for (int i=NDIM;i--;) { 1740 tmp = fabs(Binder->leftatom->x[i] - Binder->rightatom->x[i]); 1741 //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl; 1742 if (tmp > BondDistance) { 1743 OtherBinder = Binder->next; // note down binding partner for later re-insertion 1744 unlink(Binder); // unlink bond 1745 DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl); 1746 flag = true; 1747 break; 1748 } 1690 1749 } 1691 1750 } 1692 }1693 1751 if (flag) { 1694 1752 // create translation vector from their periodically modified distance … … 1702 1760 Log() << Verbose(0) << Translationvector << endl; 1703 1761 // apply to all atoms of first component via BFS 1704 for (int i= AtomCount;i--;)1762 for (int i=getAtomCount();i--;) 1705 1763 ColorList[i] = white; 1706 1764 AtomStack->Push(Binder->leftatom); … … 1726 1784 //delete(CompStack); 1727 1785 } 1728 1729 1786 // free allocated space from ReturnFullMatrixforSymmetric() 1730 1787 delete(AtomStack); 1731 Free(&ColorList);1732 Free(&matrix);1788 delete[](ColorList); 1789 delete[](matrix); 1733 1790 DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl); 1734 1791 }; -
src/molecule_geometry.cpp
re58856b rf2a1d3 27 27 bool status = true; 28 28 const Vector *Center = DetermineCenterOfAll(); 29 const Vector *CenterBox = DetermineCenterOfBox(); 29 30 double * const cell_size = World::getInstance().getDomain(); 30 31 double *M = ReturnFullMatrixforSymmetric(cell_size); … … 33 34 // go through all atoms 34 35 ActOnAllVectors( &Vector::SubtractVector, *Center); 36 ActOnAllVectors( &Vector::SubtractVector, *CenterBox); 35 37 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 36 38 37 Free(&M);38 Free(&Minv);39 delete[](M); 40 delete[](Minv); 39 41 delete(Center); 40 42 return status; … … 55 57 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 56 58 57 Free(&M);58 Free(&Minv);59 delete[](M); 60 delete[](Minv); 59 61 return status; 60 62 }; … … 69 71 70 72 // Log() << Verbose(3) << "Begin of CenterEdge." << endl; 71 atom *ptr = start->next; // start at first in list72 if ( ptr != end) {//list not empty?73 molecule::const_iterator iter = begin(); // start at first in list 74 if (iter != end()) { //list not empty? 73 75 for (int i=NDIM;i--;) { 74 max->at(i) = ptr->x[i]; 75 min->at(i) = ptr->x[i]; 76 } 77 while (ptr->next != end) { // continue with second if present 78 ptr = ptr->next; 79 //ptr->Output(1,1,out); 76 max->at(i) = (*iter)->x[i]; 77 min->at(i) = (*iter)->x[i]; 78 } 79 for (; iter != end(); ++iter) {// continue with second if present 80 //(*iter)->Output(1,1,out); 80 81 for (int i=NDIM;i--;) { 81 max->at(i) = (max->at(i) < ptr->x[i]) ? ptr->x[i] : max->at(i);82 min->at(i) = (min->at(i) > ptr->x[i]) ? ptr->x[i] : min->at(i);82 max->at(i) = (max->at(i) < (*iter)->x[i]) ? (*iter)->x[i] : max->at(i); 83 min->at(i) = (min->at(i) > (*iter)->x[i]) ? (*iter)->x[i] : min->at(i); 83 84 } 84 85 } … … 104 105 { 105 106 int Num = 0; 106 atom *ptr = start; // start at first in list107 molecule::const_iterator iter = begin(); // start at first in list 107 108 108 109 Center.Zero(); 109 110 110 if (ptr->next != end) { //list not empty? 111 while (ptr->next != end) { // continue with second if present 112 ptr = ptr->next; 111 if (iter != end()) { //list not empty? 112 for (; iter != end(); ++iter) { // continue with second if present 113 113 Num++; 114 Center += ptr->x;114 Center += (*iter)->x; 115 115 } 116 116 Center.Scale(-1./Num); // divide through total number (and sign for direction) … … 125 125 Vector * molecule::DetermineCenterOfAll() const 126 126 { 127 atom *ptr = start->next; // start at first in list 127 molecule::const_iterator iter = begin(); // start at first in list 128 Vector *a = new Vector(); 129 double Num = 0; 130 131 a->Zero(); 132 133 if (iter != end()) { //list not empty? 134 for (; iter != end(); ++iter) { // continue with second if present 135 Num++; 136 (*a) += (*iter)->x; 137 } 138 a->Scale(1./Num); // divide through total mass (and sign for direction) 139 } 140 return a; 141 }; 142 143 /** Returns vector pointing to center of the domain. 144 * \return pointer to center of the domain 145 */ 146 Vector * molecule::DetermineCenterOfBox() const 147 { 148 Vector *a = new Vector(0.5,0.5,0.5); 149 150 const double *cell_size = World::getInstance().getDomain(); 151 double *M = ReturnFullMatrixforSymmetric(cell_size); 152 a->MatrixMultiplication(M); 153 delete[](M); 154 155 return a; 156 }; 157 158 /** Returns vector pointing to center of gravity. 159 * \param *out output stream for debugging 160 * \return pointer to center of gravity vector 161 */ 162 Vector * molecule::DetermineCenterOfGravity() 163 { 164 molecule::const_iterator iter = begin(); // start at first in list 128 165 Vector *a = new Vector(); 129 166 Vector tmp; … … 132 169 a->Zero(); 133 170 134 if (ptr != end) { //list not empty? 135 while (ptr->next != end) { // continue with second if present 136 ptr = ptr->next; 137 Num += 1.; 138 tmp = ptr->x; 171 if (iter != end()) { //list not empty? 172 for (; iter != end(); ++iter) { // continue with second if present 173 Num += (*iter)->type->mass; 174 tmp = (*iter)->type->mass * (*iter)->x; 139 175 (*a) += tmp; 140 176 } 141 177 a->Scale(1./Num); // divide through total mass (and sign for direction) 142 }143 return a;144 };145 146 /** Returns vector pointing to center of gravity.147 * \param *out output stream for debugging148 * \return pointer to center of gravity vector149 */150 Vector * molecule::DetermineCenterOfGravity()151 {152 atom *ptr = start->next; // start at first in list153 Vector *a = new Vector();154 Vector tmp;155 double Num = 0;156 157 a->Zero();158 159 if (ptr != end) { //list not empty?160 while (ptr->next != end) { // continue with second if present161 ptr = ptr->next;162 Num += ptr->type->mass;163 tmp = ptr->type->mass * ptr->x;164 (*a) += tmp;165 }166 a->Scale(-1./Num); // divide through total mass (and sign for direction)167 178 } 168 179 // Log() << Verbose(1) << "Resulting center of gravity: "; … … 202 213 void molecule::Scale(const double ** const factor) 203 214 { 204 atom *ptr = start; 205 206 while (ptr->next != end) { 207 ptr = ptr->next; 215 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 208 216 for (int j=0;j<MDSteps;j++) 209 ptr->Trajectory.R.at(j).ScaleAll(*factor);210 ptr->x.ScaleAll(*factor);217 (*iter)->Trajectory.R.at(j).ScaleAll(*factor); 218 (*iter)->x.ScaleAll(*factor); 211 219 } 212 220 }; … … 217 225 void molecule::Translate(const Vector *trans) 218 226 { 219 atom *ptr = start; 220 221 while (ptr->next != end) { 222 ptr = ptr->next; 227 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 223 228 for (int j=0;j<MDSteps;j++) 224 ptr->Trajectory.R.at(j) += (*trans);225 ptr->x += (*trans);229 (*iter)->Trajectory.R.at(j) += (*trans); 230 (*iter)->x += (*trans); 226 231 } 227 232 }; … … 238 243 239 244 // go through all atoms 240 ActOnAllVectors( &Vector:: SubtractVector, *trans);245 ActOnAllVectors( &Vector::AddVector, *trans); 241 246 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 242 247 243 Free(&M);244 Free(&Minv);248 delete[](M); 249 delete[](Minv); 245 250 }; 246 251 … … 259 264 void molecule::DeterminePeriodicCenter(Vector ¢er) 260 265 { 261 atom *Walker = start;262 266 double * const cell_size = World::getInstance().getDomain(); 263 267 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 264 double *inversematrix = InverseMatrix( cell_size);268 double *inversematrix = InverseMatrix(matrix); 265 269 double tmp; 266 270 bool flag; … … 270 274 Center.Zero(); 271 275 flag = true; 272 while (Walker->next != end) { 273 Walker = Walker->next; 276 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 274 277 #ifdef ADDHYDROGEN 275 if ( Walker->type->Z != 1) {278 if ((*iter)->type->Z != 1) { 276 279 #endif 277 Testvector = Walker->x;280 Testvector = (*iter)->x; 278 281 Testvector.MatrixMultiplication(inversematrix); 279 282 Translationvector.Zero(); 280 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {281 if ( Walker->nr < (*Runner)->GetOtherAtom(Walker)->nr) // otherwise we shift one to, the other fro and gain nothing283 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 284 if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing 282 285 for (int j=0;j<NDIM;j++) { 283 tmp = Walker->x[j] - (*Runner)->GetOtherAtom(Walker)->x[j];286 tmp = (*iter)->x[j] - (*Runner)->GetOtherAtom(*iter)->x[j]; 284 287 if ((fabs(tmp)) > BondDistance) { 285 288 flag = false; 286 DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << Walker->Name<< " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl);289 DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << (*iter)->getName() << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl); 287 290 if (tmp > 0) 288 291 Translationvector[j] -= 1.; … … 298 301 #ifdef ADDHYDROGEN 299 302 // now also change all hydrogens 300 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {301 if ((*Runner)->GetOtherAtom( Walker)->type->Z == 1) {302 Testvector = (*Runner)->GetOtherAtom( Walker)->x;303 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 304 if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) { 305 Testvector = (*Runner)->GetOtherAtom((*iter))->x; 303 306 Testvector.MatrixMultiplication(inversematrix); 304 307 Testvector += Translationvector; … … 312 315 } 313 316 } while (!flag); 314 Free(&matrix);315 Free(&inversematrix);316 317 Center.Scale(1./ (double)AtomCount);317 delete[](matrix); 318 delete[](inversematrix); 319 320 Center.Scale(1./static_cast<double>(getAtomCount())); 318 321 }; 319 322 … … 325 328 void molecule::PrincipalAxisSystem(bool DoRotate) 326 329 { 327 atom *ptr = start; // start at first in list328 330 double InertiaTensor[NDIM*NDIM]; 329 331 Vector *CenterOfGravity = DetermineCenterOfGravity(); … … 336 338 337 339 // sum up inertia tensor 338 while (ptr->next != end) { 339 ptr = ptr->next; 340 Vector x = ptr->x; 340 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 341 Vector x = (*iter)->x; 341 342 //x.SubtractVector(CenterOfGravity); 342 InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]);343 InertiaTensor[1] += ptr->type->mass*(-x[0]*x[1]);344 InertiaTensor[2] += ptr->type->mass*(-x[0]*x[2]);345 InertiaTensor[3] += ptr->type->mass*(-x[1]*x[0]);346 InertiaTensor[4] += ptr->type->mass*(x[0]*x[0] + x[2]*x[2]);347 InertiaTensor[5] += ptr->type->mass*(-x[1]*x[2]);348 InertiaTensor[6] += ptr->type->mass*(-x[2]*x[0]);349 InertiaTensor[7] += ptr->type->mass*(-x[2]*x[1]);350 InertiaTensor[8] += ptr->type->mass*(x[0]*x[0] + x[1]*x[1]);343 InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]); 344 InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]); 345 InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]); 346 InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]); 347 InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]); 348 InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]); 349 InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]); 350 InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]); 351 InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]); 351 352 } 352 353 // print InertiaTensor for debugging … … 386 387 387 388 // sum up inertia tensor 388 ptr = start; 389 while (ptr->next != end) { 390 ptr = ptr->next; 391 Vector x = ptr->x; 392 //x.SubtractVector(CenterOfGravity); 393 InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]); 394 InertiaTensor[1] += ptr->type->mass*(-x[0]*x[1]); 395 InertiaTensor[2] += ptr->type->mass*(-x[0]*x[2]); 396 InertiaTensor[3] += ptr->type->mass*(-x[1]*x[0]); 397 InertiaTensor[4] += ptr->type->mass*(x[0]*x[0] + x[2]*x[2]); 398 InertiaTensor[5] += ptr->type->mass*(-x[1]*x[2]); 399 InertiaTensor[6] += ptr->type->mass*(-x[2]*x[0]); 400 InertiaTensor[7] += ptr->type->mass*(-x[2]*x[1]); 401 InertiaTensor[8] += ptr->type->mass*(x[0]*x[0] + x[1]*x[1]); 389 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 390 Vector x = (*iter)->x; 391 InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]); 392 InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]); 393 InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]); 394 InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]); 395 InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]); 396 InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]); 397 InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]); 398 InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]); 399 InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]); 402 400 } 403 401 // print InertiaTensor for debugging … … 423 421 void molecule::Align(Vector *n) 424 422 { 425 atom *ptr = start;426 423 double alpha, tmp; 427 424 Vector z_axis; … … 434 431 alpha = atan(-n->at(0)/n->at(2)); 435 432 DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... "); 436 while (ptr->next != end) { 437 ptr = ptr->next; 438 tmp = ptr->x[0]; 439 ptr->x[0] = cos(alpha) * tmp + sin(alpha) * ptr->x[2]; 440 ptr->x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x[2]; 433 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 434 tmp = (*iter)->x[0]; 435 (*iter)->x[0] = cos(alpha) * tmp + sin(alpha) * (*iter)->x[2]; 436 (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2]; 441 437 for (int j=0;j<MDSteps;j++) { 442 tmp = ptr->Trajectory.R.at(j)[0];443 ptr->Trajectory.R.at(j)[0] = cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j)[2];444 ptr->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j)[2];438 tmp = (*iter)->Trajectory.R.at(j)[0]; 439 (*iter)->Trajectory.R.at(j)[0] = cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2]; 440 (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2]; 445 441 } 446 442 } … … 452 448 453 449 // rotate on z-y plane 454 ptr = start;455 450 alpha = atan(-n->at(1)/n->at(2)); 456 451 DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... "); 457 while (ptr->next != end) { 458 ptr = ptr->next; 459 tmp = ptr->x[1]; 460 ptr->x[1] = cos(alpha) * tmp + sin(alpha) * ptr->x[2]; 461 ptr->x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x[2]; 452 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 453 tmp = (*iter)->x[1]; 454 (*iter)->x[1] = cos(alpha) * tmp + sin(alpha) * (*iter)->x[2]; 455 (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2]; 462 456 for (int j=0;j<MDSteps;j++) { 463 tmp = ptr->Trajectory.R.at(j)[1];464 ptr->Trajectory.R.at(j)[1] = cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j)[2];465 ptr->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j)[2];457 tmp = (*iter)->Trajectory.R.at(j)[1]; 458 (*iter)->Trajectory.R.at(j)[1] = cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2]; 459 (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2]; 466 460 } 467 461 } … … 487 481 Vector a,b,c,d; 488 482 struct lsq_params *par = (struct lsq_params *)params; 489 atom *ptr = par->mol->start;490 483 491 484 // initialize vectors … … 497 490 b[2] = gsl_vector_get(x,5); 498 491 // go through all atoms 499 while (ptr != par->mol->end) { 500 ptr = ptr->next; 501 if (ptr->type == ((struct lsq_params *)params)->type) { // for specific type 502 c = ptr->x - a; 492 for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) { 493 if ((*iter)->type == ((struct lsq_params *)params)->type) { // for specific type 494 c = (*iter)->x - a; 503 495 t = c.ScalarProduct(b); // get direction parameter 504 496 d = t*b; // and create vector -
src/molecule_graph.cpp
re58856b rf2a1d3 12 12 #include "element.hpp" 13 13 #include "helpers.hpp" 14 #include "info.hpp" 14 15 #include "linkedcell.hpp" 15 16 #include "lists.hpp" … … 19 20 #include "World.hpp" 20 21 #include "Helpers/fast_functions.hpp" 22 #include "Helpers/Assert.hpp" 23 21 24 22 25 struct BFSAccounting … … 54 57 void molecule::CreateAdjacencyListFromDbondFile(ifstream *input) 55 58 { 56 59 Info FunctionInfo(__func__); 57 60 // 1 We will parse bonds out of the dbond file created by tremolo. 58 61 int atom1, atom2; 59 62 atom *Walker, *OtherWalker; 60 61 if (!input) { 62 DoLog(1) && (Log() << Verbose(1) << "Opening silica failed \n"); 63 char line[MAXSTRINGSIZE]; 64 65 if (input->fail()) { 66 DoeLog(0) && (eLog() << Verbose(0) << "Opening of bond file failed \n"); 67 performCriticalExit(); 63 68 }; 64 65 *input >> ws >> atom1; 66 *input >> ws >> atom2; 67 DoLog(1) && (Log() << Verbose(1) << "Scanning file\n"); 69 doCountAtoms(); 70 71 // skip header 72 input->getline(line,MAXSTRINGSIZE); 73 DoLog(1) && (Log() << Verbose(1) << "Scanning file ... \n"); 68 74 while (!input->eof()) // Check whether we read everything already 69 75 { 70 *input >> ws >> atom1; 71 *input >> ws >> atom2; 72 76 input->getline(line,MAXSTRINGSIZE); 77 stringstream zeile(line); 78 zeile >> atom1; 79 zeile >> atom2; 80 81 DoLog(2) && (Log() << Verbose(2) << "Looking for atoms " << atom1 << " and " << atom2 << "." << endl); 73 82 if (atom2 < atom1) //Sort indices of atoms in order 74 83 flip(atom1, atom2); 75 84 Walker = FindAtom(atom1); 85 ASSERT(Walker,"Could not find an atom with the ID given in dbond file"); 76 86 OtherWalker = FindAtom(atom2); 87 ASSERT(OtherWalker,"Could not find an atom with the ID given in dbond file"); 77 88 AddBond(Walker, OtherWalker); //Add the bond between the two atoms with respective indices. 78 89 } … … 103 114 atom *Walker = NULL; 104 115 atom *OtherWalker = NULL; 105 atom **AtomMap = NULL;106 116 int n[NDIM]; 107 117 double MinDistance, MaxDistance; … … 118 128 DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl); 119 129 // 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 } 130 for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 131 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin()) 132 if ((*BondRunner)->leftatom == *AtomRunner) 133 delete((*BondRunner)); 127 134 BondCount = 0; 128 135 129 136 // 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.)) { 137 DoLog(1) && (Log() << Verbose(1) << "AtomCount " << getAtomCount() << " and bonddistance is " << bonddistance << "." << endl); 138 139 if ((getAtomCount() > 1) && (bonddistance > 1.)) { 134 140 DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl); 135 141 LC = new LinkedCell(this, bonddistance); … … 137 143 // create a list to map Tesselpoint::nr to atom * 138 144 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;145 146 // set numbers for atoms that can later be used 147 int i=0; 148 for(internal_iterator iter = atoms.begin();iter!= atoms.end(); ++iter){ 149 (*iter)->nr = i++; 144 150 } 145 151 … … 153 159 if (List != NULL) { 154 160 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; 161 Walker = dynamic_cast<atom*>(*Runner); 162 ASSERT(Walker,"Tesselpoint that was not an atom retrieved from LinkedNode"); 163 //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl; 157 164 // 3c. check for possible bond between each atom in this and every one in the 27 cells 158 165 for (n[0] = -1; n[0] <= 1; n[0]++) … … 164 171 for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) { 165 172 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; 173 OtherWalker = dynamic_cast<atom*>(*OtherRunner); 174 ASSERT(OtherWalker,"TesselPoint that was not an atom retrieved from LinkedNode"); 175 //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 170 176 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 177 const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size); 171 178 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 172 179 // Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl; … … 188 195 } 189 196 } 190 Free(&AtomMap);191 197 delete (LC); 192 198 DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl); … … 199 205 ActOnAllAtoms( &atom::OutputBondOfAtom ); 200 206 } else 201 DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << AtomCount<< ", thus no bonds, no connections!." << endl);207 DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << getAtomCount() << ", thus no bonds, no connections!." << endl); 202 208 DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl); 203 209 if (free_BG) … … 206 212 ; 207 213 214 /** Checks for presence of bonds within atom list. 215 * TODO: more sophisticated check for bond structure (e.g. connected subgraph, ...) 216 * \return true - bonds present, false - no bonds 217 */ 218 bool molecule::hasBondStructure() 219 { 220 for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 221 if (!(*AtomRunner)->ListOfBonds.empty()) 222 return true; 223 return false; 224 } 225 226 /** Counts the number of present bonds. 227 * \return number of bonds 228 */ 229 unsigned int molecule::CountBonds() const 230 { 231 unsigned int counter = 0; 232 for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 233 for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 234 if ((*BondRunner)->leftatom == *AtomRunner) 235 counter++; 236 return counter; 237 } 238 208 239 /** Prints a list of all bonds to \a *out. 209 240 * \param output stream … … 212 243 { 213 244 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 }245 for(molecule::const_iterator AtomRunner = molecule::begin(); AtomRunner != molecule::end(); ++AtomRunner) 246 for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 247 if ((*BondRunner)->leftatom == *AtomRunner) { 248 DoLog(0) && (Log() << Verbose(0) << *(*BondRunner) << "\t" << endl); 249 } 219 250 DoLog(0) && (Log() << Verbose(0) << endl); 220 251 } … … 241 272 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 242 273 } else { 243 DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount<< " atoms." << endl);274 DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << getAtomCount() << " atoms." << endl); 244 275 } 245 276 DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl); … … 260 291 MoleculeLeafClass *Subgraphs = NULL; 261 292 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 } 293 for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 294 if ((!(*AtomRunner)->ListOfBonds.empty()) && ((*(*AtomRunner)->ListOfBonds.begin())->Type == Undetermined)) { 295 DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl); 296 Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack); 297 while (Subgraphs->next != NULL) { 298 Subgraphs = Subgraphs->next; 299 delete (Subgraphs->previous); 300 } 301 delete (Subgraphs); 302 delete[] (MinimumRingSize); 303 break; 304 } 305 for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 306 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 307 if ((*BondRunner)->leftatom == *AtomRunner) 308 if ((*BondRunner)->Cyclic) 309 NoCyclicBonds++; 278 310 delete (BackEdgeStack); 279 311 return NoCyclicBonds; … … 317 349 Walker->GraphNr = DFS.CurrentGraphNr; 318 350 Walker->LowpointNr = DFS.CurrentGraphNr; 319 DoLog(1) && (Log() << Verbose(1) << "Setting Walker[" << Walker-> Name<< "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl);351 DoLog(1) && (Log() << Verbose(1) << "Setting Walker[" << Walker->getName() << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl); 320 352 DFS.AtomStack->Push(Walker); 321 353 DFS.CurrentGraphNr++; … … 348 380 Binder->MarkUsed(black); 349 381 OtherAtom = Binder->GetOtherAtom(Walker); 350 DoLog(2) && (Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom-> Name<< "." << endl);382 DoLog(2) && (Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->getName() << "." << endl); 351 383 if (OtherAtom->GraphNr != -1) { 352 384 // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3) … … 354 386 DFS.BackEdgeStack->Push(Binder); 355 387 Walker->LowpointNr = (Walker->LowpointNr < OtherAtom->GraphNr) ? Walker->LowpointNr : OtherAtom->GraphNr; 356 DoLog(3) && (Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker-> Name<< "] to " << Walker->LowpointNr << "." << endl);388 DoLog(3) && (Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->getName() << "] to " << Walker->LowpointNr << "." << endl); 357 389 } else { 358 390 // (4b) ... otherwise set OtherAtom as Ancestor of Walker and Walker as OtherAtom, go to (2) … … 360 392 OtherAtom->Ancestor = Walker; 361 393 Walker = OtherAtom; 362 DoLog(3) && (Log() << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom-> Name << "]'s Ancestor is now " << OtherAtom->Ancestor->Name << ", Walker is OtherAtom " << OtherAtom->Name<< "." << endl);394 DoLog(3) && (Log() << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->getName() << "]'s Ancestor is now " << OtherAtom->Ancestor->getName() << ", Walker is OtherAtom " << OtherAtom->getName() << "." << endl); 363 395 break; 364 396 } … … 382 414 383 415 // (5) if Ancestor of Walker is ... 384 DoLog(1) && (Log() << Verbose(1) << "(5) Number of Walker[" << Walker-> Name << "]'s Ancestor[" << Walker->Ancestor->Name<< "] is " << Walker->Ancestor->GraphNr << "." << endl);416 DoLog(1) && (Log() << Verbose(1) << "(5) Number of Walker[" << Walker->getName() << "]'s Ancestor[" << Walker->Ancestor->getName() << "] is " << Walker->Ancestor->GraphNr << "." << endl); 385 417 386 418 if (Walker->Ancestor->GraphNr != DFS.Root->GraphNr) { … … 389 421 // (6a) set Ancestor's Lowpoint number to minimum of of its Ancestor and itself, go to Step(8) 390 422 Walker->Ancestor->LowpointNr = (Walker->Ancestor->LowpointNr < Walker->LowpointNr) ? Walker->Ancestor->LowpointNr : Walker->LowpointNr; 391 DoLog(2) && (Log() << Verbose(2) << "(6) Setting Walker[" << Walker-> Name << "]'s Ancestor[" << Walker->Ancestor->Name<< "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl);423 DoLog(2) && (Log() << Verbose(2) << "(6) Setting Walker[" << Walker->getName() << "]'s Ancestor[" << Walker->Ancestor->getName() << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl); 392 424 } else { 393 425 // (7) (Ancestor of Walker is a separating vertex, remove all from stack till Walker (including), these and Ancestor form a component 394 426 Walker->Ancestor->SeparationVertex = true; 395 DoLog(2) && (Log() << Verbose(2) << "(7) Walker[" << Walker-> Name << "]'s Ancestor[" << Walker->Ancestor->Name<< "]'s is a separating vertex, creating component." << endl);427 DoLog(2) && (Log() << Verbose(2) << "(7) Walker[" << Walker->getName() << "]'s Ancestor[" << Walker->Ancestor->getName() << "]'s is a separating vertex, creating component." << endl); 396 428 mol->SetNextComponentNumber(Walker->Ancestor, DFS.ComponentNumber); 397 DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker-> Name<< "]'s Ancestor's Compont is " << DFS.ComponentNumber << "." << endl);429 DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->getName() << "]'s Ancestor's Compont is " << DFS.ComponentNumber << "." << endl); 398 430 mol->SetNextComponentNumber(Walker, DFS.ComponentNumber); 399 DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker-> Name<< "]'s Compont is " << DFS.ComponentNumber << "." << endl);431 DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->getName() << "]'s Compont is " << DFS.ComponentNumber << "." << endl); 400 432 do { 401 433 OtherAtom = DFS.AtomStack->PopLast(); 402 434 LeafWalker->Leaf->AddCopyAtom(OtherAtom); 403 435 mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber); 404 DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom-> Name<< "]'s Compont is " << DFS.ComponentNumber << "." << endl);436 DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->getName() << "]'s Compont is " << DFS.ComponentNumber << "." << endl); 405 437 } while (OtherAtom != Walker); 406 438 DFS.ComponentNumber++; 407 439 } 408 440 // (8) Walker becomes its Ancestor, go to (3) 409 DoLog(2) && (Log() << Verbose(2) << "(8) Walker[" << Walker-> Name << "] is now its Ancestor " << Walker->Ancestor->Name<< ", backstepping. " << endl);441 DoLog(2) && (Log() << Verbose(2) << "(8) Walker[" << Walker->getName() << "] is now its Ancestor " << Walker->Ancestor->getName() << ", backstepping. " << endl); 410 442 Walker = Walker->Ancestor; 411 443 DFS.BackStepping = true; … … 431 463 //DFS.AtomStack->Output(out); 432 464 mol->SetNextComponentNumber(DFS.Root, DFS.ComponentNumber); 433 DoLog(3) && (Log() << Verbose(3) << "(9) Root[" << DFS.Root-> Name<< "]'s Component is " << DFS.ComponentNumber << "." << endl);465 DoLog(3) && (Log() << Verbose(3) << "(9) Root[" << DFS.Root->getName() << "]'s Component is " << DFS.ComponentNumber << "." << endl); 434 466 mol->SetNextComponentNumber(Walker, DFS.ComponentNumber); 435 DoLog(3) && (Log() << Verbose(3) << "(9) Walker[" << Walker-> Name<< "]'s Component is " << DFS.ComponentNumber << "." << endl);467 DoLog(3) && (Log() << Verbose(3) << "(9) Walker[" << Walker->getName() << "]'s Component is " << DFS.ComponentNumber << "." << endl); 436 468 do { 437 469 OtherAtom = DFS.AtomStack->PopLast(); 438 470 LeafWalker->Leaf->AddCopyAtom(OtherAtom); 439 471 mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber); 440 DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom-> Name<< "]'s Compont is " << DFS.ComponentNumber << "." << endl);472 DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->getName() << "]'s Compont is " << DFS.ComponentNumber << "." << endl); 441 473 } while (OtherAtom != Walker); 442 474 DFS.ComponentNumber++; … … 445 477 Walker = DFS.Root; 446 478 Binder = mol->FindNextUnused(Walker); 447 DoLog(1) && (Log() << Verbose(1) << "(10) Walker is Root[" << DFS.Root-> Name<< "], next Unused Bond is " << Binder << "." << endl);479 DoLog(1) && (Log() << Verbose(1) << "(10) Walker is Root[" << DFS.Root->getName() << "], next Unused Bond is " << Binder << "." << endl); 448 480 if (Binder != NULL) { // Root is separation vertex 449 481 DoLog(1) && (Log() << Verbose(1) << "(11) Root is a separation vertex." << endl); … … 461 493 void DepthFirstSearchAnalysis_Init(struct DFSAccounting &DFS, const molecule * const mol) 462 494 { 463 DFS.AtomStack = new StackClass<atom *> (mol-> AtomCount);495 DFS.AtomStack = new StackClass<atom *> (mol->getAtomCount()); 464 496 DFS.CurrentGraphNr = 0; 465 497 DFS.ComponentNumber = 0; … … 502 534 bond *Binder = NULL; 503 535 504 if ( AtomCount== 0)536 if (getAtomCount() == 0) 505 537 return SubGraphs; 506 538 DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl); 507 539 DepthFirstSearchAnalysis_Init(DFS, this); 508 540 509 DFS.Root = start->next;510 while (DFS.Root != end) { // if there any atoms at all541 for (molecule::const_iterator iter = begin(); iter != end();) { 542 DFS.Root = *iter; 511 543 // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all 512 544 DFS.AtomStack->ClearStack(); … … 548 580 549 581 // 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;582 while ((iter != end()) && ((*iter)->GraphNr != -1)) { 583 //Log() << Verbose(1) << "Current next subgraph root candidate is " << (*iter)->Name << "." << endl; 584 if ((*iter)->GraphNr != -1) // if already discovered, step on 585 iter++; 554 586 } 555 587 } … … 573 605 { 574 606 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 } 607 for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 608 for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 609 if ((*BondRunner)->leftatom == *AtomRunner) 610 if ((*BondRunner)->rightatom->LowpointNr == (*BondRunner)->leftatom->LowpointNr) { // cyclic ?? 611 (*BondRunner)->Cyclic = true; 612 NoCyclicBonds++; 613 } 583 614 } 584 615 ; … … 599 630 void molecule::OutputGraphInfoPerBond() const 600 631 { 632 bond *Binder = NULL; 601 633 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 } 634 for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 635 for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 636 if ((*BondRunner)->leftatom == *AtomRunner) { 637 Binder = *BondRunner; 638 DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <"); 639 DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp."); 640 Binder->leftatom->OutputComponentNumber(); 641 DoLog(0) && (Log() << Verbose(0) << " === "); 642 DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp."); 643 Binder->rightatom->OutputComponentNumber(); 644 DoLog(0) && (Log() << Verbose(0) << ">." << endl); 645 if (Binder->Cyclic) // cyclic ?? 646 DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl); 647 } 615 648 } 616 649 ; … … 624 657 { 625 658 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");659 BFS.PredecessorList = new atom*[AtomCount]; 660 BFS.ShortestPathList = new int[AtomCount]; 661 BFS.ColorList = new enum Shading[AtomCount]; 629 662 BFS.BFSStack = new StackClass<atom *> (AtomCount); 630 663 631 for (int i = AtomCount; i--;) 664 for (int i = AtomCount; i--;) { 632 665 BFS.ShortestPathList[i] = -1; 666 BFS.PredecessorList[i] = 0; 667 } 633 668 }; 634 669 … … 639 674 void FinalizeBFSAccounting(struct BFSAccounting &BFS) 640 675 { 641 Free(&BFS.PredecessorList);642 Free(&BFS.ShortestPathList);643 Free(&BFS.ColorList);676 delete[](BFS.PredecessorList); 677 delete[](BFS.ShortestPathList); 678 delete[](BFS.ColorList); 644 679 delete (BFS.BFSStack); 645 680 BFS.AtomCount = 0; … … 692 727 if (OtherAtom->type->Z != 1) { 693 728 #endif 694 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom-> Name<< " for bond " << *(*Runner) << "." << endl);729 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl); 695 730 if (BFS.ColorList[OtherAtom->nr] == white) { 696 731 BFS.TouchedStack->Push(OtherAtom); … … 698 733 BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor 699 734 BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1; 700 DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom-> Name << " lightgray, its predecessor is " << Walker->Name<< " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl);735 DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->getName() << " lightgray, its predecessor is " << Walker->getName() << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl); 701 736 //if (BFS.ShortestPathList[OtherAtom->nr] < MinimumRingSize[Walker->GetTrueFather()->nr]) { // Check for maximum distance 702 737 DoLog(3) && (Log() << Verbose(3) << "Putting OtherAtom into queue." << endl); … … 719 754 } 720 755 BFS.ColorList[Walker->nr] = black; 721 DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker-> Name<< " black." << endl);756 DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->getName() << " black." << endl); 722 757 if (OtherAtom == BFS.Root) { // if we have found the root, check whether this cycle wasn't already found beforehand 723 758 // step through predecessor list … … 770 805 Walker = BFS.Root; 771 806 while (Walker != BackEdge->rightatom) { 772 DoLog(0) && (Log() << Verbose(0) << Walker-> Name<< " <-> ");807 DoLog(0) && (Log() << Verbose(0) << Walker->getName() << " <-> "); 773 808 Walker = BFS.PredecessorList[Walker->nr]; 774 809 Walker->GetTrueFather()->IsCyclic = true; 775 810 RingSize++; 776 811 } 777 DoLog(0) && (Log() << Verbose(0) << Walker-> Name<< " with a length of " << RingSize << "." << endl << endl);812 DoLog(0) && (Log() << Verbose(0) << Walker->getName() << " with a length of " << RingSize << "." << endl << endl); 778 813 // walk through all and set MinimumRingSize 779 814 Walker = BFS.Root; … … 854 889 if (MinRingSize != -1) { // if rings are present 855 890 // 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 891 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 892 Root = *iter; 893 894 if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->getAtomCount()) { // check whether MinimumRingSize is set, if not BFS to next where it is 861 895 Walker = Root; 862 896 863 897 //Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl; 864 CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol-> AtomCount);898 CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->getAtomCount()); 865 899 866 900 } … … 892 926 int MinRingSize = -1; 893 927 894 InitializeBFSAccounting(BFS, AtomCount);928 InitializeBFSAccounting(BFS, getAtomCount()); 895 929 896 930 //Log() << Verbose(1) << "Back edge list - "; … … 966 1000 void molecule::ResetAllBondsToUnused() const 967 1001 { 968 bond *Binder = first; 969 while (Binder->next != last) { 970 Binder = Binder->next; 971 Binder->ResetUsed(); 972 } 1002 for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) 1003 for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 1004 if ((*BondRunner)->leftatom == *AtomRunner) 1005 (*BondRunner)->ResetUsed(); 973 1006 } 974 1007 ; … … 1004 1037 line << filename; 1005 1038 AdjacencyFile.open(line.str().c_str(), ios::out); 1006 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " );1039 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl); 1007 1040 if (AdjacencyFile != NULL) { 1008 1041 AdjacencyFile << "m\tn" << endl; 1009 1042 ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile); 1010 1043 AdjacencyFile.close(); 1011 DoLog(1) && (Log() << Verbose(1) << " done." << endl);1044 DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl); 1012 1045 } else { 1013 DoLog(1) && (Log() << Verbose(1) << " failed to open file " << line.str() << "." << endl);1046 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line.str() << "." << endl); 1014 1047 status = false; 1015 1048 } … … 1036 1069 line << filename; 1037 1070 BondFile.open(line.str().c_str(), ios::out); 1038 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " );1071 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl); 1039 1072 if (BondFile != NULL) { 1040 1073 BondFile << "m\tn" << endl; 1041 1074 ActOnAllAtoms(&atom::OutputBonds, &BondFile); 1042 1075 BondFile.close(); 1043 DoLog(1) && (Log() << Verbose(1) << " done." << endl);1076 DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl); 1044 1077 } else { 1045 DoLog(1) && (Log() << Verbose(1) << " failed to open file " << line.str() << "." << endl);1078 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line.str() << "." << endl); 1046 1079 status = false; 1047 1080 } … … 1056 1089 filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE; 1057 1090 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 ... " );1091 DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " << endl); 1059 1092 if (File == NULL) 1060 1093 return false; 1061 1094 1062 1095 // allocate storage structure 1063 CurrentBonds = Calloc<int> (8, "molecule::CheckAdjacencyFileAgainstMolecule - CurrentBonds"); // contains parsed bonds of current atom 1096 CurrentBonds = new int[8]; // contains parsed bonds of current atom 1097 for(int i=0;i<8;i++) 1098 CurrentBonds[i] = 0; 1064 1099 return true; 1065 1100 } … … 1070 1105 File.close(); 1071 1106 File.clear(); 1072 Free(&CurrentBonds);1107 delete[](CurrentBonds); 1073 1108 } 1074 1109 ; … … 1090 1125 NonMatchNumber++; 1091 1126 status = false; 1127 DoeLog(2) && (eLog() << Verbose(2) << id << " can not be found in list." << endl); 1128 } else { 1092 1129 //Log() << Verbose(0) << "[" << id << "]\t"; 1093 } else {1094 //Log() << Verbose(0) << id << "\t";1095 1130 } 1096 1131 } … … 1114 1149 bool status = true; 1115 1150 atom *Walker = NULL; 1116 char *buffer = NULL;1117 1151 int *CurrentBonds = NULL; 1118 1152 int NonMatchNumber = 0; // will number of atoms with differing bond structure 1119 1153 size_t CurrentBondsOfAtom = -1; 1154 const int AtomCount = getAtomCount(); 1120 1155 1121 1156 if (!CheckAdjacencyFileAgainstMolecule_Init(path, File, CurrentBonds)) { … … 1124 1159 } 1125 1160 1126 buffer = Malloc<char> (MAXSTRINGSIZE, "molecule::CheckAdjacencyFileAgainstMolecule: *buffer");1161 char buffer[MAXSTRINGSIZE]; 1127 1162 // Parse the file line by line and count the bonds 1128 1163 while (!File.eof()) { … … 1140 1175 // compare against present bonds 1141 1176 CheckAdjacencyFileAgainstMolecule_CompareBonds(status, NonMatchNumber, Walker, CurrentBondsOfAtom, AtomNr, CurrentBonds, ListOfAtoms); 1142 } 1143 } 1144 Free(&buffer); 1177 } else { 1178 if (AtomNr != -1) 1179 DoeLog(2) && (eLog() << Verbose(2) << AtomNr << " is not valid in the range of ids [" << 0 << "," << AtomCount << ")." << endl); 1180 } 1181 } 1145 1182 CheckAdjacencyFileAgainstMolecule_Finalize(File, CurrentBonds); 1146 1183 … … 1196 1233 BFS.AtomCount = AtomCount; 1197 1234 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");1235 BFS.PredecessorList = new atom*[AtomCount]; 1236 BFS.ShortestPathList = new int[AtomCount]; 1237 BFS.ColorList = new enum Shading[AtomCount]; 1201 1238 BFS.BFSStack = new StackClass<atom *> (AtomCount); 1202 1239 … … 1207 1244 // initialise each vertex as white with no predecessor, empty queue, color Root lightgray 1208 1245 for (int i = AtomCount; i--;) { 1246 BFS.PredecessorList[i] = NULL; 1209 1247 BFS.ShortestPathList[i] = -1; 1210 1248 if ((AddedAtomList != NULL) && (AddedAtomList[i] != NULL)) // mark already present atoms (i.e. Root and maybe others) as visited … … 1213 1251 BFS.ColorList[i] = white; 1214 1252 } 1215 //BFS.ShortestPathList[Root->nr] = 0; // is set due to Calloc()1253 //BFS.ShortestPathList[Root->nr] = 0; // done by Calloc 1216 1254 } 1217 1255 ; … … 1219 1257 void BreadthFirstSearchAdd_Free(struct BFSAccounting &BFS) 1220 1258 { 1221 Free(&BFS.PredecessorList);1222 Free(&BFS.ShortestPathList);1223 Free(&BFS.ColorList);1259 delete[](BFS.PredecessorList); 1260 delete[](BFS.ShortestPathList); 1261 delete[](BFS.ColorList); 1224 1262 delete (BFS.BFSStack); 1225 1263 BFS.AtomCount = 0; … … 1233 1271 BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor 1234 1272 BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1; 1235 DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom-> Name << " " << ((BFS.ColorList[OtherAtom->nr] == white) ? "white" : "lightgray") << ", its predecessor is " << Walker->Name<< " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl);1273 DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->getName() << " " << ((BFS.ColorList[OtherAtom->nr] == white) ? "white" : "lightgray") << ", its predecessor is " << Walker->getName() << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl); 1236 1274 if ((((BFS.ShortestPathList[OtherAtom->nr] < BFS.BondOrder) && (Binder != Bond)))) { // Check for maximum distance 1237 1275 DoLog(3) && (Log() << Verbose(3)); 1238 1276 if (AddedAtomList[OtherAtom->nr] == NULL) { // add if it's not been so far 1239 1277 AddedAtomList[OtherAtom->nr] = Mol->AddCopyAtom(OtherAtom); 1240 DoLog(0) && (Log() << Verbose(0) << "Added OtherAtom " << OtherAtom-> Name);1278 DoLog(0) && (Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->getName()); 1241 1279 AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder); 1242 1280 DoLog(0) && (Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", "); 1243 1281 } else { // this code should actually never come into play (all white atoms are not yet present in BondMolecule, that's why they are white in the first place) 1244 DoLog(0) && (Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom-> Name);1282 DoLog(0) && (Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->getName()); 1245 1283 if (AddedBondList[Binder->nr] == NULL) { 1246 1284 AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder); … … 1313 1351 AddedAtomList[Root->nr] = Mol->AddCopyAtom(Root); 1314 1352 1315 BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, AtomCount, AddedAtomList);1353 BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, getAtomCount(), AddedAtomList); 1316 1354 1317 1355 // and go on ... Queue always contains all lightgray vertices … … 1322 1360 // followed by n+1 till top of stack. 1323 1361 Walker = BFS.BFSStack->PopFirst(); // pop oldest added 1324 DoLog(1) && (Log() << Verbose(1) << "Current Walker is: " << Walker-> Name<< ", and has " << Walker->ListOfBonds.size() << " bonds." << endl);1362 DoLog(1) && (Log() << Verbose(1) << "Current Walker is: " << Walker->getName() << ", and has " << Walker->ListOfBonds.size() << " bonds." << endl); 1325 1363 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { 1326 1364 if ((*Runner) != NULL) { // don't look at bond equal NULL 1327 1365 Binder = (*Runner); 1328 1366 OtherAtom = (*Runner)->GetOtherAtom(Walker); 1329 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom-> Name<< " for bond " << *(*Runner) << "." << endl);1367 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl); 1330 1368 if (BFS.ColorList[OtherAtom->nr] == white) { 1331 1369 BreadthFirstSearchAdd_UnvisitedNode(Mol, BFS, Walker, OtherAtom, Binder, Bond, AddedAtomList, AddedBondList, IsAngstroem); … … 1336 1374 } 1337 1375 BFS.ColorList[Walker->nr] = black; 1338 DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker-> Name<< " black." << endl);1376 DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->getName() << " black." << endl); 1339 1377 } 1340 1378 BreadthFirstSearchAdd_Free(BFS); … … 1360 1398 { 1361 1399 // reset parent list 1362 ParentList = Calloc<atom*> (AtomCount, "molecule::BuildInducedSubgraph_Init: **ParentList"); 1400 ParentList = new atom*[AtomCount]; 1401 for (int i=0;i<AtomCount;i++) 1402 ParentList[i] = NULL; 1363 1403 DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl); 1364 1404 } … … 1369 1409 // fill parent list with sons 1370 1410 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; 1411 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1412 ParentList[(*iter)->father->nr] = (*iter); 1375 1413 // 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 ; 1414 DoLog(4) && (Log() << Verbose(4) << "Son[" << (*iter)->father->nr << "] of " << (*iter)->father << " is " << ParentList[(*iter)->father->nr] << "." << endl); 1415 } 1416 }; 1381 1417 1382 1418 void BuildInducedSubgraph_Finalize(atom **&ParentList) 1383 1419 { 1384 Free(&ParentList);1420 delete[](ParentList); 1385 1421 } 1386 1422 ; … … 1389 1425 { 1390 1426 bool status = true; 1391 atom *Walker = NULL;1392 1427 atom *OtherAtom = NULL; 1393 1428 // check each entry of parent list and if ok (one-to-and-onto matching) create bonds 1394 1429 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) { 1430 for (molecule::const_iterator iter = Father->begin(); iter != Father->end(); ++iter) { 1431 if (ParentList[(*iter)->nr] != NULL) { 1432 if (ParentList[(*iter)->nr]->father != (*iter)) { 1400 1433 status = false; 1401 1434 } else { 1402 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {1403 OtherAtom = (*Runner)->GetOtherAtom( Walker);1435 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 1436 OtherAtom = (*Runner)->GetOtherAtom((*iter)); 1404 1437 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]->Name << " and " << ParentList[OtherAtom->nr]->Name<< "." << endl);1406 mol->AddBond(ParentList[ Walker->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);1438 DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[(*iter)->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl); 1439 mol->AddBond(ParentList[(*iter)->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree); 1407 1440 } 1408 1441 } … … 1427 1460 bool status = true; 1428 1461 atom **ParentList = NULL; 1429 1430 1462 DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl); 1431 BuildInducedSubgraph_Init(ParentList, Father-> AtomCount);1463 BuildInducedSubgraph_Init(ParentList, Father->getAtomCount()); 1432 1464 BuildInducedSubgraph_FillParentList(this, Father, ParentList); 1433 1465 status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList); -
src/molecule_pointcloud.cpp
re58856b rf2a1d3 8 8 #include "atom.hpp" 9 9 #include "config.hpp" 10 #include "info.hpp" 10 11 #include "memoryallocator.hpp" 11 12 #include "molecule.hpp" … … 31 32 }; 32 33 33 /** Return current atom in the list. 34 * \return pointer to atom or NULL if none present 34 35 /** PointCloud implementation of GoPoint 36 * Uses atoms and STL stuff. 35 37 */ 36 TesselPoint *molecule::GetPoint() const38 TesselPoint* molecule::GetPoint() const 37 39 { 38 if ((InternalPointer != start) && (InternalPointer != end)) 39 return InternalPointer; 40 else 41 return NULL; 40 return (*InternalPointer); 42 41 }; 43 42 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. 43 /** PointCloud implementation of GoToNext. 44 * Uses atoms and STL stuff. 62 45 */ 63 46 void molecule::GoToNext() const 64 47 { 65 if (InternalPointer != end)66 InternalPointer = InternalPointer->next;48 if (InternalPointer != atoms.end()) 49 InternalPointer++; 67 50 }; 68 51 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. 52 /** PointCloud implementation of GoToFirst. 53 * Uses atoms and STL stuff. 79 54 */ 80 55 void molecule::GoToFirst() const 81 56 { 82 InternalPointer = start->next;57 InternalPointer = atoms.begin(); 83 58 }; 84 59 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 60 /** PointCloud implementation of IsEmpty. 61 * Uses atoms and STL stuff. 94 62 */ 95 63 bool molecule::IsEmpty() const 96 64 { 97 return ( start->next == end);65 return (empty()); 98 66 }; 99 67 100 /** Checks whether we are at the last atom101 * \return true - current atom is last one, false - is not last one68 /** PointCloud implementation of IsLast. 69 * Uses atoms and STL stuff. 102 70 */ 103 71 bool molecule::IsEnd() const 104 72 { 105 return (InternalPointer == end);73 return (InternalPointer == atoms.end()); 106 74 }; 75 76 int molecule::GetMaxId() const { 77 return getAtomCount(); 78 } -
src/molecule_template.hpp
re58856b rf2a1d3 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
re58856b rf2a1d3 20 20 #include "memoryallocator.hpp" 21 21 #include "periodentafel.hpp" 22 #include "World.hpp" 22 #include "Helpers/Assert.hpp" 23 24 #include "Helpers/Assert.hpp" 23 25 24 26 /*********************************** Functions for class MoleculeListClass *************************/ … … 38 40 MoleculeListClass::~MoleculeListClass() 39 41 { 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); 42 DoLog(4) && (Log() << Verbose(4) << "Clearing ListOfMolecules." << endl); 43 for(MoleculeList::iterator MolRunner = ListOfMolecules.begin(); MolRunner != ListOfMolecules.end(); ++MolRunner) 44 (*MolRunner)->signOff(this); 46 45 ListOfMolecules.clear(); // empty list 47 46 }; … … 49 48 /** Insert a new molecule into the list and set its number. 50 49 * \param *mol molecule to add to list. 51 * \return true - add successful52 50 */ 53 51 void MoleculeListClass::insert(molecule *mol) … … 59 57 }; 60 58 59 /** Erases a molecule from the list. 60 * \param *mol molecule to add to list. 61 */ 62 void MoleculeListClass::erase(molecule *mol) 63 { 64 OBSERVE; 65 mol->signOff(this); 66 ListOfMolecules.remove(mol); 67 }; 68 61 69 /** Compare whether two molecules are equal. 62 70 * \param *a molecule one … … 69 77 int Count, Counter, aCounter, bCounter; 70 78 int flag; 71 atom *aWalker = NULL;72 atom *bWalker = NULL;73 79 74 80 // sort each atom list and put the numbers into a list, then go through 75 81 //Log() << Verbose(0) << "Comparing fragment no. " << *(molecule **)a << " to " << *(molecule **)b << "." << endl; 76 if ((**(molecule **) a).AtomCount < (**(molecule **) b).AtomCount) { 82 // Yes those types are awkward... but check it for yourself it checks out this way 83 molecule *const *mol1_ptr= static_cast<molecule *const *>(a); 84 molecule *mol1 = *mol1_ptr; 85 molecule *const *mol2_ptr= static_cast<molecule *const *>(b); 86 molecule *mol2 = *mol2_ptr; 87 if (mol1->getAtomCount() < mol2->getAtomCount()) { 77 88 return -1; 78 89 } else { 79 if ( (**(molecule **) a).AtomCount > (**(molecule **) b).AtomCount)90 if (mol1->getAtomCount() > mol2->getAtomCount()) 80 91 return +1; 81 92 else { 82 Count = (**(molecule **) a).AtomCount;93 Count = mol1->getAtomCount(); 83 94 aList = new int[Count]; 84 95 bList = new int[Count]; 85 96 86 97 // fill the lists 87 aWalker = (**(molecule **) a).start;88 bWalker = (**(molecule **) b).start;89 98 Counter = 0; 90 99 aCounter = 0; 91 100 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) 101 molecule::const_iterator aiter = mol1->begin(); 102 molecule::const_iterator biter = mol2->begin(); 103 for (;(aiter != mol1->end()) && (biter != mol2->end()); 104 ++aiter, ++biter) { 105 if ((*aiter)->GetTrueFather() == NULL) 96 106 aList[Counter] = Count + (aCounter++); 97 107 else 98 aList[Counter] = aWalker->GetTrueFather()->nr;99 if ( bWalker->GetTrueFather() == NULL)108 aList[Counter] = (*aiter)->GetTrueFather()->nr; 109 if ((*biter)->GetTrueFather() == NULL) 100 110 bList[Counter] = Count + (bCounter++); 101 111 else 102 bList[Counter] = bWalker->GetTrueFather()->nr;112 bList[Counter] = (*biter)->GetTrueFather()->nr; 103 113 Counter++; 104 114 } 105 115 // check if AtomCount was for real 106 116 flag = 0; 107 if ((a Walker->next == (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {117 if ((aiter == mol1->end()) && (biter != mol2->end())) { 108 118 flag = -1; 109 119 } else { 110 if ((a Walker->next != (**(molecule **) a).end) && (bWalker->next == (**(molecule **) b).end))120 if ((aiter != mol1->end()) && (biter == mol2->end())) 111 121 flag = 1; 112 122 } … … 142 152 void MoleculeListClass::Enumerate(ostream *out) 143 153 { 144 atom *Walker = NULL;145 154 periodentafel *periode = World::getInstance().getPeriode(); 146 155 std::map<atomicNumber_t,unsigned int> counts; … … 158 167 // count atoms per element and determine size of bounding sphere 159 168 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); 169 for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) { 170 counts[(*iter)->type->getNumber()]++; 171 if ((*iter)->x.DistanceSquared(Origin) > size) 172 size = (*iter)->x.DistanceSquared(Origin); 166 173 } 167 174 // output Index, Name, number of atoms, chemical formula 168 (*out) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)-> AtomCount<< "\t";175 (*out) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->getAtomCount() << "\t"; 169 176 170 177 std::map<atomicNumber_t,unsigned int>::reverse_iterator iter; … … 202 209 203 210 // 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); 211 molecule::iterator runner; 212 for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) { 213 runner = iter++; 214 srcmol->UnlinkAtom((*runner)); 215 mol->AddAtom((*runner)); 211 216 } 212 217 … … 228 233 229 234 // 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); 235 atom *Walker = NULL; 236 for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) { 237 Walker = mol->AddCopyAtom((*iter)); 236 238 Walker->father = Walker; 237 239 } … … 330 332 331 333 // prepare index list for bonds 332 srcmol->CountAtoms(); 333 atom ** CopyAtoms = new atom*[srcmol->AtomCount]; 334 for(int i=0;i<srcmol->AtomCount;i++) 334 atom ** CopyAtoms = new atom*[srcmol->getAtomCount()]; 335 for(int i=0;i<srcmol->getAtomCount();i++) 335 336 CopyAtoms[i] = NULL; 336 337 337 338 // for each of the source atoms check whether we are in- or outside and add copy atom 338 atom *Walker = srcmol->start;339 339 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]); 340 for (molecule::const_iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) { 341 DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << **iter << "." << endl); 342 if (!TesselStruct->IsInnerPoint((*iter)->x, LCList)) { 343 CopyAtoms[(*iter)->nr] = (*iter)->clone(); 344 mol->AddAtom(CopyAtoms[(*iter)->nr]); 346 345 nr++; 347 346 } else { … … 349 348 } 350 349 } 351 DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol-> AtomCount<< " atoms have been merged.");350 DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol->getAtomCount() << " atoms have been merged."); 352 351 353 352 // 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 }353 for(molecule::iterator AtomRunner = srcmol->begin(); AtomRunner != srcmol->end(); ++AtomRunner) 354 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner) 355 if ((*BondRunner)->leftatom == *AtomRunner) { 356 DoLog(3) && (Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[(*BondRunner)->leftatom->nr] << " and " << *CopyAtoms[(*BondRunner)->rightatom->nr]<< "." << endl); 357 mol->AddBond(CopyAtoms[(*BondRunner)->leftatom->nr], CopyAtoms[(*BondRunner)->rightatom->nr], (*BondRunner)->BondDegree); 358 } 360 359 delete(LCList); 361 360 return true; … … 382 381 bool MoleculeListClass::AddHydrogenCorrection(char *path) 383 382 { 384 atom *Walker = NULL;385 atom *Runner = NULL;386 383 bond *Binder = NULL; 387 384 double ***FitConstant = NULL, **correction = NULL; … … 427 424 428 425 // 0b. allocate memory for constants 429 FitConstant = Calloc<double**>(3, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant");426 FitConstant = new double**[3]; 430 427 for (int k = 0; k < 3; k++) { 431 FitConstant[k] = Calloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]");428 FitConstant[k] = new double*[a]; 432 429 for (int i = a; i--;) { 433 FitConstant[k][i] = Calloc<double>(b, "MoleculeListClass::AddHydrogenCorrection: *FitConstant[][]"); 430 FitConstant[k][i] = new double[b]; 431 for (int j = b; j--;) { 432 FitConstant[k][i][j] = 0.; 433 } 434 434 } 435 435 } … … 477 477 478 478 // 0d. allocate final correction matrix 479 correction = Calloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **correction");479 correction = new double*[a]; 480 480 for (int i = a; i--;) 481 correction[i] = Calloc<double>(b, "MoleculeListClass::AddHydrogenCorrection: *correction[]");481 correction[i] = new double[b]; 482 482 483 483 // 1a. go through every molecule in the list … … 488 488 correction[k][j] = 0.; 489 489 // 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; 490 for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) { 491 //Log() << Verbose(1) << "(*iter): " << *(*iter) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl; 492 if (((*iter)->type->Z == 1) && (((*iter)->father == NULL) 493 || ((*iter)->father->type->Z != 1))) { // if it's a hydrogen 494 for (molecule::const_iterator runner = (*ListRunner)->begin(); runner != (*ListRunner)->end(); ++runner) { 495 //Log() << Verbose(2) << "Runner: " << *(*runner) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl; 500 496 // 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!)497 Binder = *((*runner)->ListOfBonds.begin()); 498 if (((*runner)->type->Z == 1) && ((*runner)->nr > (*iter)->nr) && (Binder->GetOtherAtom((*runner)) != Binder->GetOtherAtom((*iter)))) { // (hydrogens have only one bonding partner!) 503 499 // 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;500 distance = (*runner)->x.distance((*iter)->x); 501 //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *(*runner) << "<= " << distance << "=>" << *(*iter) << ":" << endl; 506 502 for (int k = 0; k < a; k++) { 507 503 for (int j = 0; j < b; j++) { … … 531 527 FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), (*ListRunner)->IndexNr); 532 528 line += FragmentNumber; 533 delete (FragmentNumber);529 delete[] (FragmentNumber); 534 530 line += HCORRECTIONSUFFIX; 535 531 output.open(line.c_str()); … … 542 538 output.close(); 543 539 } 540 for (int i = a; i--;) 541 delete[](correction[i]); 542 delete[](correction); 543 544 544 line = path; 545 545 line.append("/"); … … 556 556 for (int k = 0; k < 3; k++) { 557 557 for (int i = a; i--;) { 558 Free(&FitConstant[k][i]);559 } 560 Free(&FitConstant[k]);561 } 562 Free(&FitConstant);558 delete[](FitConstant[k][i]); 559 } 560 delete[](FitConstant[k]); 561 } 562 delete[](FitConstant); 563 563 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 564 564 return true; … … 577 577 ofstream ForcesFile; 578 578 stringstream line; 579 atom *Walker = NULL;580 579 periodentafel *periode=World::getInstance().getPeriode(); 581 580 … … 590 589 periodentafel::const_iterator elemIter; 591 590 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 591 if ((*ListRunner)->ElementsInMolecule[(*elemIter).first]) { // if this element got atoms 592 for(molecule::iterator atomIter = (*ListRunner)->begin(); atomIter !=(*ListRunner)->end();++atomIter){ 593 if ((*atomIter)->type->getNumber() == (*elemIter).first) { 594 if (((*atomIter)->GetTrueFather() != NULL) && ((*atomIter)->GetTrueFather() != (*atomIter))) {// if there is a rea 598 595 //Log() << Verbose(0) << "Walker is " << *Walker << " with true father " << *( Walker->GetTrueFather()) << ", it 599 ForcesFile << SortIndex[ Walker->GetTrueFather()->nr] << "\t";596 ForcesFile << SortIndex[(*atomIter)->GetTrueFather()->nr] << "\t"; 600 597 } else 601 598 // otherwise a -1 to indicate an added saturation hydrogen … … 622 619 * \param *configuration standard configuration to attach atoms in fragment molecule to. 623 620 * \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 621 * \return true - success (each file was written), false - something went wrong. 627 622 */ … … 633 628 bool result = true; 634 629 bool intermediateResult = true; 635 atom *Walker = NULL;636 630 Vector BoxDimension; 637 631 char *FragmentNumber = NULL; … … 674 668 // list atoms in fragment for debugging 675 669 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->Name << " "); 670 for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) { 671 DoLog(0) && (Log() << Verbose(0) << (*iter)->getName() << " "); 680 672 } 681 673 DoLog(0) && (Log() << Verbose(0) << endl); … … 724 716 //outputFragment.close(); 725 717 //outputFragment.clear(); 726 Free(&FragmentNumber);718 delete[](FragmentNumber); 727 719 } 728 720 DoLog(0) && (Log() << Verbose(0) << " done." << endl); … … 756 748 void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration) 757 749 { 750 // 0a. remove all present molecules 751 vector<molecule *> allmolecules = World::getInstance().getAllMolecules(); 752 for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) { 753 erase(*MolRunner); 754 World::getInstance().destroyMolecule(*MolRunner); 755 } 756 // 0b. remove all bonds and construct a molecule with all atoms 758 757 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); 758 vector <atom *> allatoms = World::getInstance().getAllAtoms(); 759 for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) { 760 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin()) 761 delete(*BondRunner); 762 mol->AddAtom(*AtomRunner); 785 763 } 786 764 … … 810 788 const int MolCount = Subgraphs->next->Count(); 811 789 char number[MAXSTRINGSIZE]; 812 molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules"); 790 molecule **molecules = new molecule *[MolCount]; 791 MoleculeLeafClass *MolecularWalker = Subgraphs; 813 792 for (int i=0;i<MolCount;i++) { 793 MolecularWalker = MolecularWalker->next; 814 794 molecules[i] = World::getInstance().createMolecule(); 815 795 molecules[i]->ActiveFlag = true; … … 820 800 } 821 801 DoLog(1) && (Log() << Verbose(1) << "MolName is " << molecules[i]->name << endl); 802 for (molecule::iterator iter = MolecularWalker->Leaf->begin(); iter != MolecularWalker->Leaf->end(); ++iter) { 803 DoLog(1) && (Log() << Verbose(1) << **iter << endl); 804 } 822 805 insert(molecules[i]); 823 806 } … … 825 808 // 4b. create and fill map of which atom is associated to which connected molecule (note, counting starts at 1) 826 809 int FragmentCounter = 0; 827 int *MolMap = Calloc<int>(mol->AtomCount, "config::Load() - *MolMap"); 828 MoleculeLeafClass *MolecularWalker = Subgraphs; 829 Walker = NULL; 810 map<int, atom *> AtomToFragmentMap; 811 MolecularWalker = Subgraphs; 830 812 while (MolecularWalker->next != NULL) { 831 813 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; 814 for (molecule::iterator iter = MolecularWalker->Leaf->begin(); !MolecularWalker->Leaf->empty(); iter = MolecularWalker->Leaf->begin()) { 815 atom * Walker = *iter; 816 DoLog(1) && (Log() << Verbose(1) << "Re-linking " << Walker << "..." << endl); 817 MolecularWalker->Leaf->erase(iter); 818 molecules[FragmentCounter]->AddAtom(Walker); // counting starts at 1 836 819 } 837 820 FragmentCounter++; 838 821 } 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 } 822 World::getInstance().destroyMolecule(mol); 823 858 824 // 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 } 825 // TODO: check whether this is really not needed anymore 866 826 // 4e. free Leafs 867 827 MolecularWalker = Subgraphs; … … 871 831 } 872 832 delete(MolecularWalker); 873 Free(&MolMap); 874 Free(&molecules); 833 delete[](molecules); 875 834 DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl); 876 835 }; … … 882 841 int MoleculeListClass::CountAllAtoms() const 883 842 { 884 atom *Walker = NULL;885 843 int AtomNo = 0; 886 844 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 } 845 AtomNo += (*MolWalker)->size(); 892 846 } 893 847 return AtomNo; … … 1064 1018 bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList) 1065 1019 { 1066 atom *Walker = NULL;1067 1020 atom *OtherWalker = NULL; 1068 1021 atom *Father = NULL; … … 1072 1025 DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl); 1073 1026 // fill ListOfLocalAtoms if NULL was given 1074 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference-> AtomCount, FreeList)) {1027 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) { 1075 1028 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl); 1076 1029 return false; … … 1080 1033 DoLog(1) && (Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl); 1081 1034 // 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(); 1035 for(molecule::iterator AtomRunner = Leaf->begin(); AtomRunner != Leaf->end(); ++AtomRunner) 1036 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin()) 1037 if ((*BondRunner)->leftatom == *AtomRunner) 1038 delete((*BondRunner)); 1039 1040 for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) { 1041 Father = (*iter)->GetTrueFather(); 1094 1042 AtomNo = Father->nr; // global id of the current walker 1095 1043 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 walker1044 OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker 1097 1045 if (OtherWalker != NULL) { 1098 if (OtherWalker->nr > Walker->nr)1099 Leaf->AddBond( Walker, OtherWalker, (*Runner)->BondDegree);1046 if (OtherWalker->nr > (*iter)->nr) 1047 Leaf->AddBond((*iter), OtherWalker, (*Runner)->BondDegree); 1100 1048 } else { 1101 DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom( Walker->GetTrueFather())->nr << "] is NULL!" << endl);1049 DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl); 1102 1050 status = false; 1103 1051 } … … 1108 1056 if ((FreeList) && (ListOfLocalAtoms != NULL)) { 1109 1057 // free the index lookup list 1110 Free(&ListOfLocalAtoms[FragmentCounter]);1058 delete[](ListOfLocalAtoms[FragmentCounter]); 1111 1059 if (FragmentCounter == 0) // first fragments frees the initial pointer to list 1112 Free(&ListOfLocalAtoms);1060 delete[](ListOfLocalAtoms); 1113 1061 } 1114 1062 DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl); … … 1126 1074 bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter) 1127 1075 { 1128 atom * Walker = NULL, *Father = NULL;1076 atom *Father = NULL; 1129 1077 1130 1078 if (RootStack != NULL) { … … 1132 1080 if (&(RootStack[FragmentCounter]) != NULL) { 1133 1081 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(); 1082 for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) { 1083 Father = (*iter)->GetTrueFather(); 1138 1084 if (AtomMask[Father->nr]) // apply mask 1139 1085 #ifdef ADDHYDROGEN 1140 if ( Walker->type->Z != 1) // skip hydrogen1086 if ((*iter)->type->Z != 1) // skip hydrogen 1141 1087 #endif 1142 RootStack[FragmentCounter].push_front( Walker->nr);1088 RootStack[FragmentCounter].push_front((*iter)->nr); 1143 1089 } 1144 1090 if (next != NULL) … … 1171 1117 // allocate and set each field to NULL 1172 1118 const int Counter = Count(); 1173 ListOfLocalAtoms = Calloc<atom**>(Counter, "MoleculeLeafClass::FillListOfLocalAtoms - ***ListOfLocalAtoms"); 1119 ASSERT(FragmentCounter < Counter, "FillListOfLocalAtoms: FragmenCounter greater than present fragments."); 1120 ListOfLocalAtoms = new atom**[Counter]; 1174 1121 if (ListOfLocalAtoms == NULL) { 1175 1122 FreeList = FreeList && false; 1176 1123 status = false; 1177 1124 } 1125 for (int i=0;i<Counter;i++) 1126 ListOfLocalAtoms[i] = NULL; 1178 1127 } 1179 1128 1180 1129 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);1130 status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms[FragmentCounter], GlobalAtomCount); 1182 1131 FreeList = FreeList && true; 1183 1132 } … … 1203 1152 DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl); 1204 1153 // fill ListOfLocalAtoms if NULL was given 1205 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference-> AtomCount, FreeList)) {1154 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) { 1206 1155 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl); 1207 1156 return false; … … 1211 1160 if (FragmentList == NULL) { 1212 1161 KeySetCounter = Count(); 1213 FragmentList = Calloc<Graph*>(KeySetCounter, "MoleculeLeafClass::AssignKeySetsToFragment - **FragmentList"); 1162 FragmentList = new Graph*[KeySetCounter]; 1163 for (int i=0;i<KeySetCounter;i++) 1164 FragmentList[i] = NULL; 1214 1165 KeySetCounter = 0; 1215 1166 } … … 1245 1196 if ((FreeList) && (ListOfLocalAtoms != NULL)) { 1246 1197 // free the index lookup list 1247 Free(&ListOfLocalAtoms[FragmentCounter]);1198 delete[](ListOfLocalAtoms[FragmentCounter]); 1248 1199 if (FragmentCounter == 0) // first fragments frees the initial pointer to list 1249 Free(&ListOfLocalAtoms);1200 delete[](ListOfLocalAtoms); 1250 1201 } 1251 1202 DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl); -
src/parser.cpp
re58856b rf2a1d3 32 32 if (input == NULL) { 33 33 if (!test) 34 DoLog(0) && (Log() << Verbose(0) << endl << " Unable to open " << filename << ", is the directory correct?" << endl);34 DoLog(0) && (Log() << Verbose(0) << endl << "FilePresent: Unable to open " << filename << ", is the directory correct?" << endl); 35 35 return false; 36 36 } … … 59 59 MatrixContainer::MatrixContainer() { 60 60 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");61 Header = new char*[1]; 62 Matrix = new double**[1]; // one more each for the total molecule 63 RowCounter = new int[1]; 64 ColumnCounter = new int[1]; 65 65 Header[0] = NULL; 66 66 Matrix[0] = NULL; … … 77 77 if ((ColumnCounter != NULL) && (RowCounter != NULL)) { 78 78 for(int j=RowCounter[i]+1;j--;) 79 Free(&Matrix[i][j]);80 Free(&Matrix[i]);79 delete[](Matrix[i][j]); 80 delete[](Matrix[i]); 81 81 } 82 82 } 83 83 if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL)) 84 84 for(int j=RowCounter[MatrixCounter]+1;j--;) 85 Free(&Matrix[MatrixCounter][j]);85 delete[](Matrix[MatrixCounter][j]); 86 86 if (MatrixCounter != 0) 87 Free(&Matrix[MatrixCounter]);88 Free(&Matrix);87 delete[](Matrix[MatrixCounter]); 88 delete[](Matrix); 89 89 } 90 90 if (Indices != NULL) 91 91 for(int i=MatrixCounter+1;i--;) { 92 Free(&Indices[i]);93 } 94 Free(&Indices);92 delete[](Indices[i]); 93 } 94 delete[](Indices); 95 95 96 96 if (Header != NULL) 97 97 for(int i=MatrixCounter+1;i--;) 98 Free(&Header[i]);99 Free(&Header);100 Free(&RowCounter);101 Free(&ColumnCounter);98 delete[](Header[i]); 99 delete[](Header); 100 delete[](RowCounter); 101 delete[](ColumnCounter); 102 102 }; 103 103 … … 112 112 if (Matrix == NULL) { 113 113 DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl); 114 Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");114 Indices = new int*[MatrixCounter + 1]; 115 115 for(int i=MatrixCounter+1;i--;) { 116 Indices[i] = Malloc<int>(RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");116 Indices[i] = new int[RowCounter[i]]; 117 117 for(int j=RowCounter[i];j--;) 118 118 Indices[i][j] = j; … … 122 122 if (MatrixCounter != Matrix->MatrixCounter) 123 123 return false; 124 Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");124 Indices = new int*[MatrixCounter + 1]; 125 125 for(int i=MatrixCounter+1;i--;) { 126 126 if (RowCounter[i] != Matrix->RowCounter[i]) 127 127 return false; 128 Indices[i] = Malloc<int>(Matrix->RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");128 Indices[i] = new int[Matrix->RowCounter[i]]; 129 129 for(int j=Matrix->RowCounter[i];j--;) { 130 130 Indices[i][j] = Matrix->Indices[i][j]; … … 160 160 //Log() << Verbose(1) << "Opening " << name << " ... " << input << endl; 161 161 if (input == NULL) { 162 DoeLog(1) && (eLog()<< Verbose(1) << endl << " Unable to open " << name << ", is the directory correct?" << endl);162 DoeLog(1) && (eLog()<< Verbose(1) << endl << "MatrixContainer::ParseMatrix: Unable to open " << name << ", is the directory correct?" << endl); 163 163 //performCriticalExit(); 164 164 return false; … … 166 166 167 167 // parse header 168 Header[MatrixNr] = Malloc<char>(1024, "MatrixContainer::ParseMatrix: *Header[]");168 Header[MatrixNr] = new char[1024]; 169 169 for (int m=skiplines+1;m--;) 170 170 input.getline(Header[MatrixNr], 1023); … … 205 205 // allocate matrix if it's not zero dimension in one direction 206 206 if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) { 207 Matrix[MatrixNr] = Malloc<double*>(RowCounter[MatrixNr] + 1, "MatrixContainer::ParseMatrix: **Matrix[]");207 Matrix[MatrixNr] = new double*[RowCounter[MatrixNr] + 1]; 208 208 209 209 // parse in each entry for this matrix … … 217 217 strncpy(Header[MatrixNr], line.str().c_str(), 1023); 218 218 for(int j=0;j<RowCounter[MatrixNr];j++) { 219 Matrix[MatrixNr][j] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[][]");219 Matrix[MatrixNr][j] = new double[ColumnCounter[MatrixNr]]; 220 220 input.getline(filename, 1023); 221 221 stringstream lines(filename); … … 227 227 //Log() << Verbose(1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl; 228 228 } 229 Matrix[MatrixNr][ RowCounter[MatrixNr] ] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]");229 Matrix[MatrixNr][ RowCounter[MatrixNr] ] = new double[ColumnCounter[MatrixNr]]; 230 230 for(int j=ColumnCounter[MatrixNr];j--;) 231 231 Matrix[MatrixNr][ RowCounter[MatrixNr] ][j] = 0.; … … 269 269 input.open(file.str().c_str(), ios::in); 270 270 if (input == NULL) { 271 DoLog(0) && (Log() << Verbose(0) << endl << " Unable to open " << file.str() << ", is the directory correct?" << endl);271 DoLog(0) && (Log() << Verbose(0) << endl << "MatrixContainer::ParseFragmentMatrix: Unable to open " << file.str() << ", is the directory correct?" << endl); 272 272 return false; 273 273 } … … 281 281 282 282 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"); 283 delete[](Header); 284 delete[](Matrix); 285 delete[](RowCounter); 286 delete[](ColumnCounter); 287 Header = new char*[MatrixCounter + 1]; // one more each for the total molecule 288 Matrix = new double**[MatrixCounter + 1]; // one more each for the total molecule 289 RowCounter = new int[MatrixCounter + 1]; 290 ColumnCounter = new int[MatrixCounter + 1]; 287 291 for(int i=MatrixCounter+1;i--;) { 288 292 Matrix[i] = NULL; … … 298 302 if (!ParseMatrix(file.str().c_str(), skiplines, skipcolumns, i)) 299 303 return false; 300 Free(&FragmentNumber);304 delete[](FragmentNumber); 301 305 } 302 306 return true; … … 313 317 { 314 318 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");319 Header = new char*[MatrixCounter + 1]; 320 Matrix = new double**[MatrixCounter + 1]; // one more each for the total molecule 321 RowCounter = new int[MatrixCounter + 1]; 322 ColumnCounter = new int[MatrixCounter + 1]; 319 323 for(int i=MatrixCounter+1;i--;) { 320 Header[i] = Malloc<char>(1024, "MatrixContainer::AllocateMatrix: *Header[i]");324 Header[i] = new char[1024]; 321 325 strncpy(Header[i], GivenHeader[i], 1023); 322 326 RowCounter[i] = RCounter[i]; 323 327 ColumnCounter[i] = CCounter[i]; 324 Matrix[i] = Malloc<double*>(RowCounter[i] + 1, "MatrixContainer::AllocateMatrix: **Matrix[]");328 Matrix[i] = new double*[RowCounter[i] + 1]; 325 329 for(int j=RowCounter[i]+1;j--;) { 326 Matrix[i][j] = Malloc<double>(ColumnCounter[i], "MatrixContainer::AllocateMatrix: *Matrix[][]");330 Matrix[i][j] = new double[ColumnCounter[i]]; 327 331 for(int k=ColumnCounter[i];k--;) 328 332 Matrix[i][j][k] = 0.; … … 474 478 FragmentNumber = FixedDigitNumber(MatrixCounter, i); 475 479 line << name << FRAGMENTPREFIX << FragmentNumber << "/" << prefix; 476 Free(&FragmentNumber);480 delete[](FragmentNumber); 477 481 output.open(line.str().c_str(), ios::out); 478 482 if (output == NULL) { 479 DoeLog(0) && (eLog()<< Verbose(0) << " Unable to open output energy file " << line.str() << "!" << endl);483 DoeLog(0) && (eLog()<< Verbose(0) << "MatrixContainer::WriteTotalFragments: Unable to open output energy file " << line.str() << "!" << endl); 480 484 performCriticalExit(); 481 485 return false; … … 507 511 output.open(line.str().c_str(), ios::out); 508 512 if (output == NULL) { 509 DoeLog(0) && (eLog()<< Verbose(0) << " Unable to open output matrix file " << line.str() << "!" << endl);513 DoeLog(0) && (eLog()<< Verbose(0) << "MatrixContainer::WriteLastMatrix: Unable to open output matrix file " << line.str() << "!" << endl); 510 514 performCriticalExit(); 511 515 return false; … … 530 534 { 531 535 DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl); 532 Indices = Malloc<int*>(MatrixCounter + 1, "EnergyMatrix::ParseIndices: **Indices");536 Indices = new int*[MatrixCounter + 1]; 533 537 for(int i=MatrixCounter+1;i--;) { 534 Indices[i] = Malloc<int>(RowCounter[i], "EnergyMatrix::ParseIndices: *Indices[]");538 Indices[i] = new int[RowCounter[i]]; 535 539 for(int j=RowCounter[i];j--;) 536 540 Indices[i][j] = j; … … 589 593 // allocate last plus one matrix 590 594 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[]");595 Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1]; 592 596 for(int j=0;j<=RowCounter[MatrixCounter];j++) 593 Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");597 Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]]; 594 598 595 599 // try independently to parse global energysuffix file if present … … 616 620 617 621 DoLog(0) && (Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl); 618 Indices = Malloc<int*>(MatrixCounter + 1, "ForceMatrix::ParseIndices: **Indices");622 Indices = new int*[MatrixCounter + 1]; 619 623 line << name << FRAGMENTPREFIX << FORCESFILE; 620 624 input.open(line.str().c_str(), ios::in); 621 625 //Log() << Verbose(0) << "Opening " << line.str() << " ... " << input << endl; 622 626 if (input == NULL) { 623 DoLog(0) && (Log() << Verbose(0) << endl << " Unable to open " << line.str() << ", is the directory correct?" << endl);627 DoLog(0) && (Log() << Verbose(0) << endl << "ForceMatrix::ParseIndices: Unable to open " << line.str() << ", is the directory correct?" << endl); 624 628 return false; 625 629 } … … 629 633 line.str(filename); 630 634 // parse the values 631 Indices[i] = Malloc<int>(RowCounter[i], "ForceMatrix::ParseIndices: *Indices[]");635 Indices[i] = new int[RowCounter[i]]; 632 636 FragmentNumber = FixedDigitNumber(MatrixCounter, i); 633 637 //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:"; 634 Free(&FragmentNumber);638 delete[](FragmentNumber); 635 639 for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) { 636 640 line >> Indices[i][j]; … … 639 643 //Log() << Verbose(0) << endl; 640 644 } 641 Indices[MatrixCounter] = Malloc<int>(RowCounter[MatrixCounter], "ForceMatrix::ParseIndices: *Indices[]");645 Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]]; 642 646 for(int j=RowCounter[MatrixCounter];j--;) { 643 647 Indices[MatrixCounter][j] = j; … … 700 704 input.open(file.str().c_str(), ios::in); 701 705 if (input == NULL) { 702 DoLog(0) && (Log() << Verbose(0) << endl << " Unable to open " << file.str() << ", is the directory correct?" << endl);706 DoLog(0) && (Log() << Verbose(0) << endl << "ForceMatrix::ParseFragmentMatrix: Unable to open " << file.str() << ", is the directory correct?" << endl); 703 707 return false; 704 708 } … … 725 729 // allocate last plus one matrix 726 730 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[]");731 Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1]; 728 732 for(int j=0;j<=RowCounter[MatrixCounter];j++) 729 Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");733 Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]]; 730 734 731 735 // try independently to parse global forcesuffix file if present … … 754 758 755 759 DoLog(0) && (Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl); 756 Indices = Malloc<int*>(MatrixCounter + 1, "HessianMatrix::ParseIndices: **Indices");760 Indices = new int*[MatrixCounter + 1]; 757 761 line << name << FRAGMENTPREFIX << FORCESFILE; 758 762 input.open(line.str().c_str(), ios::in); 759 763 //Log() << Verbose(0) << "Opening " << line.str() << " ... " << input << endl; 760 764 if (input == NULL) { 761 DoLog(0) && (Log() << Verbose(0) << endl << " Unable to open " << line.str() << ", is the directory correct?" << endl);765 DoLog(0) && (Log() << Verbose(0) << endl << "HessianMatrix::ParseIndices: Unable to open " << line.str() << ", is the directory correct?" << endl); 762 766 return false; 763 767 } … … 767 771 line.str(filename); 768 772 // parse the values 769 Indices[i] = Malloc<int>(RowCounter[i], "HessianMatrix::ParseIndices: *Indices[]");773 Indices[i] = new int[RowCounter[i]]; 770 774 FragmentNumber = FixedDigitNumber(MatrixCounter, i); 771 775 //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:"; 772 Free(&FragmentNumber);776 delete[](FragmentNumber); 773 777 for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) { 774 778 line >> Indices[i][j]; … … 777 781 //Log() << Verbose(0) << endl; 778 782 } 779 Indices[MatrixCounter] = Malloc<int>(RowCounter[MatrixCounter], "HessianMatrix::ParseIndices: *Indices[]");783 Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]]; 780 784 for(int j=RowCounter[MatrixCounter];j--;) { 781 785 Indices[MatrixCounter][j] = j; … … 930 934 input.open(file.str().c_str(), ios::in); 931 935 if (input == NULL) { 932 DoLog(0) && (Log() << Verbose(0) << endl << " Unable to open " << file.str() << ", is the directory correct?" << endl);936 DoLog(0) && (Log() << Verbose(0) << endl << "HessianMatrix::ParseFragmentMatrix: Unable to open " << file.str() << ", is the directory correct?" << endl); 933 937 return false; 934 938 } … … 953 957 // allocate last plus one matrix 954 958 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[]");959 Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1]; 956 960 for(int j=0;j<=RowCounter[MatrixCounter];j++) 957 Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");961 Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]]; 958 962 959 963 // try independently to parse global forcesuffix file if present … … 985 989 KeySetsContainer::~KeySetsContainer() { 986 990 for(int i=FragmentCounter;i--;) 987 Free(&KeySets[i]);991 delete[](KeySets[i]); 988 992 for(int i=Order;i--;) 989 Free(&OrderSet[i]);990 Free(&KeySets);991 Free(&OrderSet);992 Free(&AtomCounter);993 Free(&FragmentsPerOrder);993 delete[](OrderSet[i]); 994 delete[](KeySets); 995 delete[](OrderSet); 996 delete[](AtomCounter); 997 delete[](FragmentsPerOrder); 994 998 }; 995 999 … … 1008 1012 FragmentCounter = FCounter; 1009 1013 DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl); 1010 KeySets = Malloc<int*>(FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets");1014 KeySets = new int*[FragmentCounter]; 1011 1015 for(int i=FragmentCounter;i--;) 1012 1016 KeySets[i] = NULL; … … 1014 1018 input.open(file.str().c_str(), ios::in); 1015 1019 if (input == NULL) { 1016 DoLog(0) && (Log() << Verbose(0) << endl << " Unable to open " << file.str() << ", is the directory correct?" << endl);1020 DoLog(0) && (Log() << Verbose(0) << endl << "KeySetsContainer::ParseKeySets: Unable to open " << file.str() << ", is the directory correct?" << endl); 1017 1021 return false; 1018 1022 } 1019 1023 1020 AtomCounter = Malloc<int>(FragmentCounter, "KeySetsContainer::ParseKeySets: *RowCounter");1024 AtomCounter = new int[FragmentCounter]; 1021 1025 for(int i=0;(i<FragmentCounter) && (!input.eof());i++) { 1022 1026 stringstream line; 1023 1027 AtomCounter[i] = ACounter[i]; 1024 1028 // parse the values 1025 KeySets[i] = Malloc<int>(AtomCounter[i], "KeySetsContainer::ParseKeySets: *KeySets[]");1029 KeySets[i] = new int[AtomCounter[i]]; 1026 1030 for(int j=AtomCounter[i];j--;) 1027 1031 KeySets[i][j] = -1; 1028 1032 FragmentNumber = FixedDigitNumber(FragmentCounter, i); 1029 1033 //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:"; 1030 Free(&FragmentNumber);1034 delete[](FragmentNumber); 1031 1035 input.getline(filename, 1023); 1032 1036 line.str(filename); … … 1062 1066 1063 1067 // scan through all to determine fragments per order 1064 FragmentsPerOrder = Malloc<int>(Order, "KeySetsContainer::ParseManyBodyTerms: *FragmentsPerOrder");1068 FragmentsPerOrder = new int[Order]; 1065 1069 for(int i=Order;i--;) 1066 1070 FragmentsPerOrder[i] = 0; … … 1076 1080 1077 1081 // scan through all to gather indices to each order set 1078 OrderSet = Malloc<int*>(Order, "KeySetsContainer::ParseManyBodyTerms: **OrderSet");1082 OrderSet = new int*[Order]; 1079 1083 for(int i=Order;i--;) 1080 OrderSet[i] = Malloc<int>(FragmentsPerOrder[i], "KeySetsContainer::ParseManyBodyTermsKeySetsContainer::ParseManyBodyTerms: *OrderSet[]");1084 OrderSet[i] = new int[FragmentsPerOrder[i]]; 1081 1085 for(int i=Order;i--;) 1082 1086 FragmentsPerOrder[i] = 0; -
src/periodentafel.cpp
re58856b rf2a1d3 8 8 9 9 #include <iomanip> 10 #include <iostream> 10 11 #include <fstream> 11 12 #include <cstring> 12 #include <cassert> 13 13 14 #include "Helpers/Assert.hpp" 14 15 #include "element.hpp" 16 #include "elements_db.hpp" 15 17 #include "helpers.hpp" 16 18 #include "lists.hpp" … … 27 29 */ 28 30 periodentafel::periodentafel() 29 {}; 31 { 32 bool status = true; 33 status = LoadElementsDatabase(new stringstream(elementsDB,ios_base::in)); 34 ASSERT(status, "General element initialization failed"); 35 status = LoadValenceDatabase(new stringstream(valenceDB,ios_base::in)); 36 ASSERT(status, "Valence entry of element initialization failed"); 37 status = LoadOrbitalsDatabase(new stringstream(orbitalsDB,ios_base::in)); 38 ASSERT(status, "Orbitals entry of element initialization failed"); 39 status = LoadHBondAngleDatabase(new stringstream(HbondangleDB,ios_base::in)); 40 ASSERT(status, "HBond angle entry of element initialization failed"); 41 status = LoadHBondLengthsDatabase(new stringstream(HbonddistanceDB,ios_base::in)); 42 ASSERT(status, "HBond distance entry of element initialization failed"); 43 }; 30 44 31 45 /** destructor for class periodentafel 32 46 * Removes every element and afterwards deletes start and end of list. 47 * TODO: Handle when elements have changed and store databases then 33 48 */ 34 49 periodentafel::~periodentafel() … … 39 54 /** Adds element to period table list 40 55 * \param *pointer element to be added 41 * \return true - succeeded, false - does not occur56 * \return iterator to added element 42 57 */ 43 58 periodentafel::iterator periodentafel::AddElement(element * const pointer) 44 59 { 45 60 atomicNumber_t Z = pointer->getNumber(); 46 assert(!elements.count(Z));61 ASSERT(!elements.count(Z), "Element is already present."); 47 62 pointer->sort = &pointer->Z; 48 63 if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS) … … 54 69 /** Removes element from list. 55 70 * \param *pointer element to be removed 56 * \return true - succeeded, false - element not found57 71 */ 58 72 void periodentafel::RemoveElement(element * const pointer) 59 73 { 60 atomicNumber_t Z = pointer->getNumber(); 74 RemoveElement(pointer->getNumber()); 75 }; 76 77 /** Removes element from list. 78 * \param Z element to be removed 79 */ 80 void periodentafel::RemoveElement(atomicNumber_t Z) 81 { 61 82 elements.erase(Z); 62 83 }; 63 84 64 85 /** Removes every element from the period table. 65 * \return true - succeeded, false - does not occur66 86 */ 67 87 void periodentafel::CleanupPeriodtable() … … 78 98 * \return pointer to element or NULL if not found 79 99 */ 80 const element *periodentafel::FindElement(atomicNumber_t Z) const100 element * const periodentafel::FindElement(atomicNumber_t Z) const 81 101 { 82 102 const_iterator res = elements.find(Z); … … 89 109 * \return pointer to element 90 110 */ 91 const element *periodentafel::FindElement(const char * const shorthand) const111 element * const periodentafel::FindElement(const char * const shorthand) const 92 112 { 93 113 element *res = 0; … … 102 122 103 123 /** Asks for element number and returns pointer to element 104 */ 105 const element * periodentafel::AskElement() const 106 { 107 const element *walker = NULL; 124 * \return desired element or NULL 125 */ 126 element * const periodentafel::AskElement() const 127 { 128 element * walker = NULL; 108 129 int Z; 109 130 do { … … 118 139 * \return pointer to either present or newly created element 119 140 */ 120 const element * periodentafel::EnterElement() 121 { 122 const element *res = NULL; 141 element * const periodentafel::EnterElement() 142 { 123 143 atomicNumber_t Z = 0; 124 144 DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl); 125 145 cin >> Z; 126 res = FindElement(Z);146 element * const res = FindElement(Z); 127 147 if (!res) { 128 148 // TODO: make this using the constructor 129 element *tmp;130 149 DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl); 131 tmp = new element;150 element *tmp = new element; 132 151 tmp->Z = Z; 133 152 DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl); … … 138 157 cin >> tmp->symbol; 139 158 AddElement(tmp); 140 re s =tmp;159 return tmp; 141 160 } 142 161 return res; … … 204 223 bool periodentafel::LoadPeriodentafel(const char *path) 205 224 { 206 ifstream infile; 207 element *ptr; 208 map<atomicNumber_t,element*> parsedElems; 225 ifstream input; 209 226 bool status = true; 210 227 bool otherstatus = true; … … 215 232 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 216 233 strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename)); 217 infile.open(filename); 218 if (infile != NULL) { 219 infile.getline(header1, MAXSTRINGSIZE); 220 infile.getline(header2, MAXSTRINGSIZE); // skip first two header lines 234 input.open(filename); 235 status = status && LoadElementsDatabase(&input); 236 237 // fill valence DB per element 238 strncpy(filename, path, MAXSTRINGSIZE); 239 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 240 strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename)); 241 input.open(filename); 242 otherstatus = otherstatus && LoadValenceDatabase(&input); 243 244 // fill orbitals DB per element 245 strncpy(filename, path, MAXSTRINGSIZE); 246 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 247 strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename)); 248 input.open(filename); 249 otherstatus = otherstatus && LoadOrbitalsDatabase(&input); 250 251 // fill H-BondAngle DB per element 252 strncpy(filename, path, MAXSTRINGSIZE); 253 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 254 strncat(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename)); 255 input.open(filename); 256 otherstatus = otherstatus && LoadHBondAngleDatabase(&input); 257 258 // fill H-BondDistance DB per element 259 strncpy(filename, path, MAXSTRINGSIZE); 260 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 261 strncat(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename)); 262 input.open(filename); 263 otherstatus = otherstatus && LoadHBondLengthsDatabase(&input); 264 265 if (!otherstatus){ 266 DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl); 267 } 268 269 return status; 270 }; 271 272 /** load the element info. 273 * \param *input stream to parse from 274 * \return true - parsing successful, false - something went wrong 275 */ 276 bool periodentafel::LoadElementsDatabase(istream *input) 277 { 278 bool status = true; 279 int counter = 0; 280 if (!(*input).fail()) { 281 (*input).getline(header1, MAXSTRINGSIZE); 282 (*input).getline(header2, MAXSTRINGSIZE); // skip first two header lines 221 283 DoLog(0) && (Log() << Verbose(0) << "Parsed elements:"); 222 while (! infile.eof()) {284 while (!(*input).eof()) { 223 285 element *neues = new element; 224 infile >> neues->name; 225 //infile >> ws; 226 infile >> neues->symbol; 227 //infile >> ws; 228 infile >> neues->period; 229 //infile >> ws; 230 infile >> neues->group; 231 //infile >> ws; 232 infile >> neues->block; 233 //infile >> ws; 234 infile >> neues->Z; 235 //infile >> ws; 236 infile >> neues->mass; 237 //infile >> ws; 238 infile >> neues->CovalentRadius; 239 //infile >> ws; 240 infile >> neues->VanDerWaalsRadius; 241 //infile >> ws; 242 infile >> ws; 243 DoLog(0) && (Log() << Verbose(0) << " " << neues->symbol); 286 (*input) >> neues->name; 287 //(*input) >> ws; 288 (*input) >> neues->symbol; 289 //(*input) >> ws; 290 (*input) >> neues->period; 291 //(*input) >> ws; 292 (*input) >> neues->group; 293 //(*input) >> ws; 294 (*input) >> neues->block; 295 //(*input) >> ws; 296 (*input) >> neues->Z; 297 //(*input) >> ws; 298 (*input) >> neues->mass; 299 //(*input) >> ws; 300 (*input) >> neues->CovalentRadius; 301 //(*input) >> ws; 302 (*input) >> neues->VanDerWaalsRadius; 303 //(*input) >> ws; 304 (*input) >> ws; 305 if (elements.count(neues->Z)) {// if element already present, remove and delete it 306 element * const Elemental = FindElement(neues->Z); 307 ASSERT(Elemental != NULL, "element should be present but is not??"); 308 RemoveElement(Elemental); 309 delete(Elemental); 310 } 244 311 //neues->Output((ofstream *)&cout); 245 if ((neues->Z > 0) && (neues->Z < MAX_ELEMENTS)) 246 parsedElems[neues->getNumber()] = neues; 247 else { 248 DoLog(0) && (Log() << Verbose(0) << "Could not parse element: "); 249 neues->Output((ofstream *)&cout); 312 if ((neues->Z > 0) && (neues->Z < MAX_ELEMENTS)) { 313 DoLog(0) && (Log() << Verbose(0) << " " << neues->symbol); 314 elements[neues->getNumber()] = neues; 315 counter++; 316 } else { 317 DoeLog(2) && (eLog() << Verbose(2) << "Detected empty line or invalid element in elements db, discarding." << endl); 318 DoLog(0) && (Log() << Verbose(0) << " <?>"); 250 319 delete(neues); 251 320 } 252 321 } 253 322 DoLog(0) && (Log() << Verbose(0) << endl); 254 infile.close();255 infile.clear();256 323 } else 257 324 status = false; 258 325 259 // fill valence DB per element 260 strncpy(filename, path, MAXSTRINGSIZE); 261 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 262 strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename)); 263 infile.open(filename); 264 if (infile != NULL) { 265 while (!infile.eof()) { 326 if (counter == 0) 327 status = false; 328 329 return status; 330 } 331 332 /** load the valence info. 333 * \param *input stream to parse from 334 * \return true - parsing successful, false - something went wrong 335 */ 336 bool periodentafel::LoadValenceDatabase(istream *input) 337 { 338 char dummy[MAXSTRINGSIZE]; 339 if (!(*input).fail()) { 340 (*input).getline(dummy, MAXSTRINGSIZE); 341 while (!(*input).eof()) { 266 342 atomicNumber_t Z; 267 infile >> Z; 268 infile >> ws; 269 infile >> parsedElems[Z]->Valence; 270 infile >> ws; 343 (*input) >> Z; 344 ASSERT(elements.count(Z), "Element not present"); 345 (*input) >> ws; 346 (*input) >> elements[Z]->Valence; 347 (*input) >> ws; 271 348 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl; 272 349 } 273 infile.close(); 274 infile.clear(); 275 } else 276 otherstatus = false; 277 278 // fill valence DB per element 279 strncpy(filename, path, MAXSTRINGSIZE); 280 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 281 strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename)); 282 infile.open(filename); 283 if (infile != NULL) { 284 while (!infile.eof()) { 350 return true; 351 } else 352 return false; 353 } 354 355 /** load the orbitals info. 356 * \param *input stream to parse from 357 * \return true - parsing successful, false - something went wrong 358 */ 359 bool periodentafel::LoadOrbitalsDatabase(istream *input) 360 { 361 char dummy[MAXSTRINGSIZE]; 362 if (!(*input).fail()) { 363 (*input).getline(dummy, MAXSTRINGSIZE); 364 while (!(*input).eof()) { 285 365 atomicNumber_t Z; 286 infile >> Z; 287 infile >> ws; 288 infile >> parsedElems[Z]->NoValenceOrbitals; 289 infile >> ws; 366 (*input) >> Z; 367 ASSERT(elements.count(Z), "Element not present"); 368 (*input) >> ws; 369 (*input) >> elements[Z]->NoValenceOrbitals; 370 (*input) >> ws; 290 371 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl; 291 372 } 292 infile.close(); 293 infile.clear(); 294 } else 295 otherstatus = false; 296 297 // fill H-BondDistance DB per element 298 strncpy(filename, path, MAXSTRINGSIZE); 299 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 300 strncat(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename)); 301 infile.open(filename); 302 if (infile != NULL) { 303 while (!infile.eof()) { 373 return true; 374 } else 375 return false; 376 } 377 378 /** load the hbond angles info. 379 * \param *input stream to parse from 380 * \return true - parsing successful, false - something went wrong 381 */ 382 bool periodentafel::LoadHBondAngleDatabase(istream *input) 383 { 384 char dummy[MAXSTRINGSIZE]; 385 if (!(*input).fail()) { 386 (*input).getline(dummy, MAXSTRINGSIZE); 387 while (!(*input).eof()) { 304 388 atomicNumber_t Z; 305 infile >> Z; 306 ptr = parsedElems[Z]; 307 infile >> ws; 308 infile >> ptr->HBondDistance[0]; 309 infile >> ptr->HBondDistance[1]; 310 infile >> ptr->HBondDistance[2]; 311 infile >> ws; 389 (*input) >> Z; 390 ASSERT(elements.count(Z), "Element not present"); 391 (*input) >> ws; 392 (*input) >> elements[Z]->HBondAngle[0]; 393 (*input) >> elements[Z]->HBondAngle[1]; 394 (*input) >> elements[Z]->HBondAngle[2]; 395 (*input) >> ws; 396 //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; 397 } 398 return true; 399 } else 400 return false; 401 } 402 403 /** load the hbond lengths info. 404 * \param *input stream to parse from 405 * \return true - parsing successful, false - something went wrong 406 */ 407 bool periodentafel::LoadHBondLengthsDatabase(istream *input) 408 { 409 char dummy[MAXSTRINGSIZE]; 410 if (!(*input).fail()) { 411 (*input).getline(dummy, MAXSTRINGSIZE); 412 while (!(*input).eof()) { 413 atomicNumber_t Z; 414 (*input) >> Z; 415 ASSERT(elements.count(Z), "Element not present"); 416 (*input) >> ws; 417 (*input) >> elements[Z]->HBondDistance[0]; 418 (*input) >> elements[Z]->HBondDistance[1]; 419 (*input) >> elements[Z]->HBondDistance[2]; 420 (*input) >> ws; 312 421 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl; 313 422 } 314 infile.close(); 315 infile.clear(); 316 } else 317 otherstatus = false; 318 319 // fill H-BondAngle DB per element 320 strncpy(filename, path, MAXSTRINGSIZE); 321 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 322 strncat(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename)); 323 infile.open(filename); 324 if (infile != NULL) { 325 while (!infile.eof()) { 326 atomicNumber_t Z; 327 infile >> Z; 328 ptr = parsedElems[Z]; 329 infile >> ws; 330 infile >> ptr->HBondAngle[0]; 331 infile >> ptr->HBondAngle[1]; 332 infile >> ptr->HBondAngle[2]; 333 infile >> ws; 334 //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; 335 } 336 infile.close(); 337 } else 338 otherstatus = false; 339 340 if (otherstatus){ 341 map<atomicNumber_t,element*>::iterator iter; 342 for(iter=parsedElems.begin();iter!=parsedElems.end();++iter){ 343 AddElement((*iter).second); 344 } 345 } 346 else{ 347 DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl); 348 map<atomicNumber_t,element*>::iterator iter; 349 for(iter=parsedElems.begin();iter!=parsedElems.end();++iter){ 350 AddElement((*iter).second); 351 } 352 } 353 354 return status; 355 }; 423 return true; 424 } else 425 return false; 426 } 356 427 357 428 /** Stores element list to file. … … 374 445 } 375 446 f.close(); 376 } else377 result = false;378 return result;379 }; 447 return true; 448 } else 449 return result; 450 }; -
src/periodentafel.hpp
re58856b rf2a1d3 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; … … 43 45 iterator AddElement(element * const pointer); 44 46 void RemoveElement(element * const pointer); 47 void 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
re58856b rf2a1d3 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
re58856b rf2a1d3 21 21 #include "Plane.hpp" 22 22 #include "Exceptions/LinearDependenceException.hpp" 23 #include "Helpers/Assert.hpp" 24 25 #include "Helpers/Assert.hpp" 23 26 24 27 class molecule; … … 83 86 ostream & operator <<(ostream &ost, const BoundaryPointSet &a) 84 87 { 85 ost << "[" << a.Nr << "|" << a.node-> Name<< " at " << *a.node->node << "]";88 ost << "[" << a.Nr << "|" << a.node->getName() << " at " << *a.node->node << "]"; 86 89 return ost; 87 90 } … … 321 324 ostream & operator <<(ostream &ost, const BoundaryLineSet &a) 322 325 { 323 ost << "[" << a.Nr << "|" << a.endpoints[0]->node-> Name << " at " << *a.endpoints[0]->node->node << "," << a.endpoints[1]->node->Name<< " at " << *a.endpoints[1]->node->node << "]";326 ost << "[" << a.Nr << "|" << a.endpoints[0]->node->getName() << " at " << *a.endpoints[0]->node->node << "," << a.endpoints[1]->node->getName() << " at " << *a.endpoints[1]->node->node << "]"; 324 327 return ost; 325 328 } … … 357 360 // get ascending order of endpoints 358 361 PointMap OrderMap; 359 for (int i = 0; i < 3; i++) 362 for (int i = 0; i < 3; i++) { 360 363 // for all three lines 361 364 for (int j = 0; j < 2; j++) { // for both endpoints … … 363 366 // and we don't care whether insertion fails 364 367 } 368 } 365 369 // set endpoints 366 370 int Counter = 0; … … 371 375 Counter++; 372 376 } 373 if (Counter < 3) { 374 DoeLog(0) && (eLog() << Verbose(0) << "We have a triangle with only two distinct endpoints!" << endl); 375 performCriticalExit(); 376 } 377 } 378 ; 377 ASSERT(Counter >= 3,"We have a triangle with only two distinct endpoints!"); 378 }; 379 379 380 380 381 /** Destructor of BoundaryTriangleSet. … … 682 683 } 683 684 685 /** 686 * gets the Plane defined by the three triangle Basepoints 687 */ 688 Plane BoundaryTriangleSet::getPlane() const{ 689 ASSERT(endpoints[0] && endpoints[1] && endpoints[2], "Triangle not fully defined"); 690 691 return Plane(*endpoints[0]->node->node, 692 *endpoints[1]->node->node, 693 *endpoints[2]->node->node); 694 } 695 696 Vector BoundaryTriangleSet::getEndpoint(int i) const{ 697 ASSERT(i>=0 && i<3,"Index of Endpoint out of Range"); 698 699 return *endpoints[i]->node->node; 700 } 701 702 string BoundaryTriangleSet::getEndpointName(int i) const{ 703 ASSERT(i>=0 && i<3,"Index of Endpoint out of Range"); 704 705 return endpoints[i]->node->getName(); 706 } 707 684 708 /** output operator for BoundaryTriangleSet. 685 709 * \param &ost output stream … … 688 712 ostream &operator <<(ostream &ost, const BoundaryTriangleSet &a) 689 713 { 690 ost << "[" << a.Nr << "|" << a. endpoints[0]->node->Name << "," << a.endpoints[1]->node->Name << "," << a.endpoints[2]->node->Name<< "]";714 ost << "[" << a.Nr << "|" << a.getEndpointName(0) << "," << a.getEndpointName(1) << "," << a.getEndpointName(2) << "]"; 691 715 // ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << "," 692 716 // << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]"; … … 948 972 ost << "[" << a.Nr << "|"; 949 973 for (PointSet::const_iterator Runner = a.endpoints.begin(); Runner != a.endpoints.end();) { 950 ost << (*Runner)->node-> Name;974 ost << (*Runner)->node->getName(); 951 975 Runner++; 952 976 if (Runner != a.endpoints.end()) … … 967 991 node = NULL; 968 992 nr = -1; 969 Name = NULL;970 993 } 971 994 ; … … 983 1006 ostream & operator <<(ostream &ost, const TesselPoint &a) 984 1007 { 985 ost << "[" << (a.Name) << "|" << a.Name << " at" << *a.node << "]";1008 ost << "[" << a.getName() << "|" << *a.node << "]"; 986 1009 return ost; 987 1010 } … … 1135 1158 ostream & operator <<(ostream &ost, const CandidateForTesselation &a) 1136 1159 { 1137 ost << "[" << a.BaseLine->Nr << "|" << a.BaseLine->endpoints[0]->node-> Name << "," << a.BaseLine->endpoints[1]->node->Name<< "] with ";1160 ost << "[" << a.BaseLine->Nr << "|" << a.BaseLine->endpoints[0]->node->getName() << "," << a.BaseLine->endpoints[1]->node->getName() << "] with "; 1138 1161 if (a.pointlist.empty()) 1139 1162 ost << "no candidate."; … … 1209 1232 ; 1210 1233 1211 /** PointCloud implementation of GetTerminalPoint.1212 * Uses PointsOnBoundary and STL stuff.1213 */1214 TesselPoint * Tesselation::GetTerminalPoint() const1215 {1216 Info FunctionInfo(__func__);1217 PointMap::const_iterator Runner = PointsOnBoundary.end();1218 Runner--;1219 return (Runner->second->node);1220 }1221 ;1222 1223 1234 /** PointCloud implementation of GoToNext. 1224 1235 * Uses PointsOnBoundary and STL stuff. … … 1232 1243 ; 1233 1244 1234 /** PointCloud implementation of GoToPrevious.1235 * Uses PointsOnBoundary and STL stuff.1236 */1237 void Tesselation::GoToPrevious() const1238 {1239 Info FunctionInfo(__func__);1240 if (InternalPointer != PointsOnBoundary.begin())1241 InternalPointer--;1242 }1243 ;1244 1245 1245 /** PointCloud implementation of GoToFirst. 1246 1246 * Uses PointsOnBoundary and STL stuff. … … 1250 1250 Info FunctionInfo(__func__); 1251 1251 InternalPointer = PointsOnBoundary.begin(); 1252 }1253 ;1254 1255 /** PointCloud implementation of GoToLast.1256 * Uses PointsOnBoundary and STL stuff.1257 */1258 void Tesselation::GoToLast() const1259 {1260 Info FunctionInfo(__func__);1261 InternalPointer = PointsOnBoundary.end();1262 InternalPointer--;1263 1252 } 1264 1253 ; … … 1348 1337 if (fabs(distance) < 1e-4) // we need to have a small epsilon around 0 which is still ok 1349 1338 continue; 1350 DoLog(2) && (Log() << Verbose(2) << "Projection of " << checker->second->node-> Name<< " yields distance of " << distance << "." << endl);1339 DoLog(2) && (Log() << Verbose(2) << "Projection of " << checker->second->node->getName() << " yields distance of " << distance << "." << endl); 1351 1340 tmp = distance / fabs(distance); 1352 1341 // 4b. Any have different sign to than before? (i.e. would lie outside convex hull with this starting triangle) 1353 1342 if ((sign != 0) && (tmp != sign)) { 1354 1343 // 4c. If so, break 4. loop and continue with next candidate in 1. loop 1355 DoLog(2) && (Log() << Verbose(2) << "Current candidates: " << A->second->node-> Name << "," << baseline->second.first->second->node->Name << "," << baseline->second.second->second->node->Name << " leaves " << checker->second->node->Name<< " outside the convex hull." << endl);1344 DoLog(2) && (Log() << Verbose(2) << "Current candidates: " << A->second->node->getName() << "," << baseline->second.first->second->node->getName() << "," << baseline->second.second->second->node->getName() << " leaves " << checker->second->node->getName() << " outside the convex hull." << endl); 1356 1345 break; 1357 1346 } else { // note the sign for later 1358 DoLog(2) && (Log() << Verbose(2) << "Current candidates: " << A->second->node-> Name << "," << baseline->second.first->second->node->Name << "," << baseline->second.second->second->node->Name << " leave " << checker->second->node->Name<< " inside the convex hull." << endl);1347 DoLog(2) && (Log() << Verbose(2) << "Current candidates: " << A->second->node->getName() << "," << baseline->second.first->second->node->getName() << "," << baseline->second.second->second->node->getName() << " leave " << checker->second->node->getName() << " inside the convex hull." << endl); 1359 1348 sign = tmp; 1360 1349 } … … 1456 1445 CenterVector.Zero(); 1457 1446 for (int i = 0; i < 3; i++) 1458 CenterVector += (*BTS->endpoints[i]->node->node);1447 CenterVector += BTS->getEndpoint(i); 1459 1448 CenterVector.Scale(1. / 3.); 1460 1449 DoLog(2) && (Log() << Verbose(2) << "CenterVector of base triangle is " << CenterVector << endl); … … 1933 1922 RemoveTesselationLine(triangle->lines[i]); 1934 1923 } else { 1935 DoLog(0) && (Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: " );1924 DoLog(0) && (Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: " << endl); 1936 1925 OpenLines.insert(pair<BoundaryLineSet *, CandidateForTesselation *> (triangle->lines[i], NULL)); 1937 1926 for (TriangleMap::iterator TriangleRunner = triangle->lines[i]->triangles.begin(); TriangleRunner != triangle->lines[i]->triangles.end(); TriangleRunner++) 1938 DoLog(0) && (Log() << Verbose(0) << " [" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t");1927 DoLog(0) && (Log() << Verbose(0) << "\t[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t"); 1939 1928 DoLog(0) && (Log() << Verbose(0) << endl); 1940 1929 // for (int j=0;j<2;j++) { … … 2570 2559 // fill the set of neighbours 2571 2560 TesselPointSet SetOfNeighbours; 2561 2572 2562 SetOfNeighbours.insert(CandidateLine.BaseLine->endpoints[1]->node); 2573 2563 for (TesselPointList::iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); Runner++) … … 2989 2979 OldBaseLineNr = Base->Nr; 2990 2980 m = 0; 2991 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) { 2992 DoLog(0) && (Log() << Verbose(0) << "INFO: Deleting triangle " << *(runner->second) << "." << endl); 2993 OldTriangleNrs[m++] = runner->second->Nr; 2994 RemoveTesselationTriangle(runner->second); 2981 // first obtain all triangle to delete ... (otherwise we pull the carpet (Base) from under the for-loop's feet) 2982 list <BoundaryTriangleSet *> TrianglesOfBase; 2983 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); ++runner) 2984 TrianglesOfBase.push_back(runner->second); 2985 // .. then delete each triangle (which deletes the line as well) 2986 for (list <BoundaryTriangleSet *>::iterator runner = TrianglesOfBase.begin(); !TrianglesOfBase.empty(); runner = TrianglesOfBase.begin()) { 2987 DoLog(0) && (Log() << Verbose(0) << "INFO: Deleting triangle " << *(*runner) << "." << endl); 2988 OldTriangleNrs[m++] = (*runner)->Nr; 2989 RemoveTesselationTriangle((*runner)); 2990 TrianglesOfBase.erase(runner); 2995 2991 } 2996 2992 … … 4292 4288 DoLog(2) && (Log() << Verbose(2) << "INFO: MiddleNode is " << **MiddleNode << "." << endl); 4293 4289 DoLog(2) && (Log() << Verbose(2) << "INFO: EndNode is " << **EndNode << "." << endl); 4294 DoLog(1) && (Log() << Verbose(1) << "INFO: Attempting to create triangle " << (*StartNode)-> Name << ", " << (*MiddleNode)->Name << " and " << (*EndNode)->Name<< "." << endl);4290 DoLog(1) && (Log() << Verbose(1) << "INFO: Attempting to create triangle " << (*StartNode)->getName() << ", " << (*MiddleNode)->getName() << " and " << (*EndNode)->getName() << "." << endl); 4295 4291 TriangleCandidates[0] = *StartNode; 4296 4292 TriangleCandidates[1] = *MiddleNode; … … 4714 4710 return; 4715 4711 } 4716 DoLog(0) && (Log() << Verbose(0) << "Nearest point on boundary is " << NearestPoint-> Name<< "." << endl);4712 DoLog(0) && (Log() << Verbose(0) << "Nearest point on boundary is " << NearestPoint->getName() << "." << endl); 4717 4713 4718 4714 // go through its lines and find the best one to split … … 4799 4795 ofstream *tempstream = NULL; 4800 4796 string NameofTempFile; 4801 char NumberName[255];4797 string NumberName; 4802 4798 4803 4799 if (LastTriangle != NULL) { 4804 sprintf(NumberName, "-%04d-%s_%s_%s", (int) TrianglesOnBoundary.size(), LastTriangle->endpoints[0]->node->Name, LastTriangle->endpoints[1]->node->Name, LastTriangle->endpoints[2]->node->Name); 4800 stringstream sstr; 4801 sstr << "-"<< TrianglesOnBoundary.size() << "-" << LastTriangle->getEndpointName(0) << "_" << LastTriangle->getEndpointName(1) << "_" << LastTriangle->getEndpointName(2); 4802 NumberName = sstr.str(); 4805 4803 if (DoTecplotOutput) { 4806 4804 string NameofTempFile(filename); -
src/tesselation.hpp
re58856b rf2a1d3 38 38 class PointCloud; 39 39 class Tesselation; 40 class Plane; 40 41 41 42 /********************************************** definitions *********************************/ … … 166 167 bool IsPresentTupel(const BoundaryTriangleSet * const T) const; 167 168 169 Plane getPlane() const; 170 Vector getEndpoint(int) const; 171 std::string getEndpointName(int) const; 172 168 173 class BoundaryPointSet *endpoints[3]; 169 174 class BoundaryLineSet *lines[3]; … … 171 176 Vector SphereCenter; 172 177 int Nr; 178 179 private: 180 173 181 }; 174 182 … … 236 244 virtual Vector *GetCenter() const { return NULL; }; 237 245 virtual TesselPoint *GetPoint() const { return NULL; }; 238 virtual TesselPoint *GetTerminalPoint() const { return NULL; };239 246 virtual int GetMaxId() const { return 0; }; 240 247 virtual void GoToNext() const {}; 241 virtual void GoToPrevious() const {};242 248 virtual void GoToFirst() const {}; 243 virtual void GoToLast() const {};244 249 virtual bool IsEmpty() const { return true; }; 245 250 virtual bool IsEnd() const { return true; }; … … 355 360 virtual Vector *GetCenter(ofstream *out) const; 356 361 virtual TesselPoint *GetPoint() const; 357 virtual TesselPoint *GetTerminalPoint() const;358 362 virtual void GoToNext() const; 359 virtual void GoToPrevious() const;360 363 virtual void GoToFirst() const; 361 virtual void GoToLast() const;362 364 virtual bool IsEmpty() const; 363 365 virtual bool IsEnd() const; -
src/tesselationhelpers.cpp
re58856b rf2a1d3 16 16 #include "vector_ops.hpp" 17 17 #include "verbose.hpp" 18 #include "Plane.hpp" 18 19 19 20 double DetGet(gsl_matrix * const A, const int inPlace) … … 687 688 return -1; 688 689 } 689 distance = x->DistanceTo Plane(triangle->NormalVector, *triangle->endpoints[0]->node->node);690 distance = x->DistanceToSpace(triangle->getPlane()); 690 691 return distance; 691 692 }; … … 784 785 Walker = cloud->GetPoint(); 785 786 *rasterfile << "2" << endl << " "; // 2 is sphere type 786 for (i=0;i<NDIM;i++) 787 *rasterfile << Walker->node->at(i)-center->at(i) << " "; 787 for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates 788 const double tmp = Walker->node->at(j)-center->at(j); 789 *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " "; 790 } 788 791 *rasterfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour 789 792 cloud->GoToNext(); … … 795 798 *rasterfile << "1" << endl << " "; // 1 is triangle type 796 799 for (i=0;i<3;i++) { // print each node 797 for (int j=0;j<NDIM;j++) // and for each node all NDIM coordinates 798 *rasterfile << TriangleRunner->second->endpoints[i]->node->node->at(j)-center->at(j) << " "; 800 for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates 801 const double tmp = TriangleRunner->second->endpoints[i]->node->node->at(j)-center->at(j); 802 *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " "; 803 } 799 804 *rasterfile << "\t"; 800 805 } … … 829 834 if (TesselStruct->LastTriangle != NULL) { 830 835 for (int i=0;i<3;i++) 831 *tecplot << (i==0 ? "" : "_") << TesselStruct->LastTriangle->endpoints[i]->node-> Name;836 *tecplot << (i==0 ? "" : "_") << TesselStruct->LastTriangle->endpoints[i]->node->getName(); 832 837 } else { 833 838 *tecplot << "none"; … … 835 840 } 836 841 *tecplot << "\", N=" << TesselStruct->PointsOnBoundary.size() << ", E=" << TesselStruct->TrianglesOnBoundary.size() << ", DATAPACKING=POINT, ZONETYPE=FETRIANGLE" << endl; 837 int i=cloud->GetMaxId();838 int *LookupList = new int[ i];839 for ( cloud->GoToFirst(), i=0; !cloud->IsEnd(); cloud->GoToNext(), i++)842 const int MaxId=cloud->GetMaxId(); 843 int *LookupList = new int[MaxId]; 844 for (int i=0; i< MaxId ; i++){ 840 845 LookupList[i] = -1; 846 } 841 847 842 848 // print atom coordinates 843 849 int Counter = 1; 844 850 TesselPoint *Walker = NULL; 845 for (PointMap::const_iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); target++) {851 for (PointMap::const_iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); ++target) { 846 852 Walker = target->second->node; 847 853 LookupList[Walker->nr] = Counter++; 848 *tecplot << Walker->node->at(0) << " " << Walker->node->at(1) << " " << Walker->node->at(2) << " " << target->second->value << endl; 854 for (int i=0;i<NDIM;i++) { 855 const double tmp = Walker->node->at(i); 856 *tecplot << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " "; 857 } 858 *tecplot << target->second->value << endl; 849 859 } 850 860 *tecplot << endl; … … 852 862 DoLog(1) && (Log() << Verbose(1) << "The following triangles were created:" << endl); 853 863 for (TriangleMap::const_iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++) { 854 DoLog(1) && (Log() << Verbose(1) << " " << runner->second->endpoints[0]->node-> Name << "<->" << runner->second->endpoints[1]->node->Name << "<->" << runner->second->endpoints[2]->node->Name<< endl);864 DoLog(1) && (Log() << Verbose(1) << " " << runner->second->endpoints[0]->node->getName() << "<->" << runner->second->endpoints[1]->node->getName() << "<->" << runner->second->endpoints[2]->node->getName() << endl); 855 865 *tecplot << LookupList[runner->second->endpoints[0]->node->nr] << " " << LookupList[runner->second->endpoints[1]->node->nr] << " " << LookupList[runner->second->endpoints[2]->node->nr] << endl; 856 866 } -
src/unittests/ActOnAllUnitTest.cpp
re58856b rf2a1d3 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
re58856b rf2a1d3 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 element52 hydrogen = new element;53 hydrogen->Z = 1;54 strcpy(hydrogen->name, "hydrogen");55 strcpy(hydrogen->symbol, "H");56 57 58 // construct periodentafel59 tafel = World::getInstance().getPeriode();60 tafel->AddElement(hydrogen);61 62 46 // construct molecule (tetraeder of hydrogens) 47 hydrogen = World::getInstance().getPeriode()->FindElement(1); 48 CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found"); 63 49 TestMolecule = World::getInstance().createMolecule(); 64 50 Walker = World::getInstance().createAtom(); … … 80 66 81 67 // check that TestMolecule was correctly constructed 82 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 4 );68 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 83 69 84 70 TestList = World::getInstance().getMolecules(); … … 105 91 delete(point); 106 92 World::purgeInstance(); 107 MemoryUsageObserver::purgeInstance();108 93 logger::purgeInstance(); 109 94 }; -
src/unittests/AnalysisCorrelationToPointUnitTest.hpp
re58856b rf2a1d3 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 … … 40 37 MoleculeListClass *TestList; 41 38 molecule *TestMolecule; 42 element *hydrogen; 43 periodentafel *tafel; 39 const element *hydrogen; 44 40 45 41 CorrelationToPointMap *pointmap; -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
re58856b rf2a1d3 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 element57 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 periodentafel67 tafel = World::getInstance().getPeriode();68 tafel->AddElement(hydrogen);69 tafel->AddElement(carbon);70 71 54 // construct molecule (tetraeder of hydrogens) base 55 hydrogen = World::getInstance().getPeriode()->FindElement(1); 72 56 TestSurfaceMolecule = World::getInstance().createMolecule(); 57 73 58 Walker = World::getInstance().createAtom(); 74 59 Walker->type = hydrogen; 75 60 *Walker->node = Vector(1., 0., 1. ); 76 77 TestSurfaceMolecule->AddAtom(Walker); 61 TestSurfaceMolecule->AddAtom(Walker); 62 78 63 Walker = World::getInstance().createAtom(); 79 64 Walker->type = hydrogen; 80 65 *Walker->node = Vector(0., 1., 1. ); 81 66 TestSurfaceMolecule->AddAtom(Walker); 67 82 68 Walker = World::getInstance().createAtom(); 83 69 Walker->type = hydrogen; 84 70 *Walker->node = Vector(1., 1., 0. ); 85 71 TestSurfaceMolecule->AddAtom(Walker); 72 86 73 Walker = World::getInstance().createAtom(); 87 74 Walker->type = hydrogen; … … 90 77 91 78 // check that TestMolecule was correctly constructed 92 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule-> AtomCount, 4 );79 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 ); 93 80 94 81 TestList = World::getInstance().getMolecules(); … … 102 89 103 90 // add outer atoms 91 carbon = World::getInstance().getPeriode()->FindElement(6); 104 92 TestSurfaceMolecule = World::getInstance().createMolecule(); 105 93 Walker = World::getInstance().createAtom(); … … 107 95 *Walker->node = Vector(4., 0., 4. ); 108 96 TestSurfaceMolecule->AddAtom(Walker); 97 109 98 Walker = World::getInstance().createAtom(); 110 99 Walker->type = carbon; 111 100 *Walker->node = Vector(0., 4., 4. ); 112 101 TestSurfaceMolecule->AddAtom(Walker); 102 113 103 Walker = World::getInstance().createAtom(); 114 104 Walker->type = carbon; 115 105 *Walker->node = Vector(4., 4., 0. ); 116 106 TestSurfaceMolecule->AddAtom(Walker); 107 117 108 // add inner atoms 118 109 Walker = World::getInstance().createAtom(); … … 120 111 *Walker->node = Vector(0.5, 0.5, 0.5 ); 121 112 TestSurfaceMolecule->AddAtom(Walker); 113 122 114 TestSurfaceMolecule->ActiveFlag = true; 123 115 TestList->insert(TestSurfaceMolecule); … … 141 133 delete(LC); 142 134 World::purgeInstance(); 143 MemoryUsageObserver::purgeInstance();144 135 logger::purgeInstance(); 145 136 }; … … 150 141 void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest() 151 142 { 152 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule-> AtomCount);143 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() ); 153 144 CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() ); 154 145 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() ); -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
re58856b rf2a1d3 45 45 MoleculeListClass *TestList; 46 46 molecule *TestSurfaceMolecule; 47 element *hydrogen; 48 element *carbon; 49 periodentafel *tafel; 47 const element *hydrogen; 48 const element *carbon; 50 49 51 50 CorrelationToSurfaceMap *surfacemap; -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
re58856b rf2a1d3 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 element52 hydrogen = new element;53 hydrogen->Z = 1;54 strcpy(hydrogen->name, "hydrogen");55 strcpy(hydrogen->symbol, "H");56 57 // construct periodentafel58 tafel = World::getInstance().getPeriode();59 tafel->AddElement(hydrogen);60 61 49 // construct molecule (tetraeder of hydrogens) 50 hydrogen = World::getInstance().getPeriode()->FindElement(1); 62 51 TestMolecule = World::getInstance().createMolecule(); 63 52 Walker = World::getInstance().createAtom(); … … 79 68 80 69 // check that TestMolecule was correctly constructed 81 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 4 );70 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 82 71 83 72 TestList = World::getInstance().getMolecules(); … … 101 90 // note that all the atoms are cleaned by TestMolecule 102 91 World::purgeInstance(); 103 MemoryUsageObserver::purgeInstance();104 92 logger::purgeInstance(); 105 93 errorLogger::purgeInstance(); -
src/unittests/AnalysisPairCorrelationUnitTest.hpp
re58856b rf2a1d3 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 … … 40 37 MoleculeListClass *TestList; 41 38 molecule *TestMolecule; 42 element *hydrogen; 43 periodentafel *tafel; 39 const element *hydrogen; 44 40 45 41 PairCorrelationMap *correlationmap; -
src/unittests/CountBondsUnitTest.cpp
re58856b rf2a1d3 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
re58856b rf2a1d3 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
re58856b rf2a1d3 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->Name = Malloc<char>(6, "LinkedCellTest::SetIndexToNodeTest - Walker"); 208 strcpy(Walker->Name, "test"); 209 Walker->x= Vector(1,1,1); 210 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(Walker) ); 211 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); 212 197 213 198 // check out of bounds vectors 214 Walker = World::getInstance().createAtom(); 215 Walker->Name = Malloc<char>(6, "LinkedCellTest::SetIndexToNodeTest - Walker"); 216 strcpy(Walker->Name, "test"); 217 Walker->x = Vector(0,-1,0); 218 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(Walker) ); 219 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); 220 204 }; 221 205 … … 289 273 size = ListOfPoints->size(); 290 274 CPPUNIT_ASSERT_EQUAL( (size_t)27, size ); 291 Walker = TestMolecule->start; 292 Walker = TestMolecule->start; 293 while (Walker->next != TestMolecule->end) { 294 Walker = Walker->next; 295 ListOfPoints->remove(Walker); 275 276 for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){ 277 ListOfPoints->remove((*iter)); 296 278 size--; 297 279 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); … … 308 290 size=ListOfPoints->size(); 309 291 CPPUNIT_ASSERT_EQUAL( (size_t)8, size ); 310 Walker = TestMolecule->start; 311 while (Walker->next != TestMolecule->end) { 312 Walker = Walker->next; 313 if ((Walker->x[0] <2) && (Walker->x[1] <2) && (Walker->x[2] <2)) { 314 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); 315 295 size--; 316 296 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); … … 328 308 size=ListOfPoints->size(); 329 309 CPPUNIT_ASSERT_EQUAL( (size_t)27, size ); 330 Walker = TestMolecule->start; 331 while (Walker->next != TestMolecule->end) { 332 Walker = Walker->next; 333 ListOfPoints->remove(Walker); 310 for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){ 311 ListOfPoints->remove(*iter); 334 312 size--; 335 313 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); … … 357 335 size = ListOfPoints->size(); 358 336 CPPUNIT_ASSERT_EQUAL( (size_t)7, size ); 359 Walker = TestMolecule->start; 360 while (Walker->next != TestMolecule->end) { 361 Walker = Walker->next; 362 if ((Walker->x.DistanceSquared(tester) - 1.) < MYEPSILON ) { 363 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); 364 340 size--; 365 341 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); -
src/unittests/LinkedCellUnitTest.hpp
re58856b rf2a1d3 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
re58856b rf2a1d3 33 33 MemoryAllocatorUnitTest \ 34 34 MoleculeDescriptorTest \ 35 PlaneUnittest \36 35 ObserverTest \ 37 36 ParserUnitTest \ 37 periodentafelTest \ 38 PlaneUnittest \ 38 39 SingletonTest \ 39 40 StackClassUnitTest \ … … 48 49 noinst_PROGRAMS = $(TESTS) TestRunner 49 50 50 GSLLIBS = ../libgslwrapper.a 51 ALLLIBS = ../libmolecuilder.a ${GSLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB}51 GSLLIBS = ../libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} 52 ALLLIBS = ../libmolecuilder.a ${GSLLIBS} 52 53 53 54 TESTSOURCES = \ … … 75 76 memoryusageobserverunittest.cpp \ 76 77 MoleculeDescriptorTest.cpp \ 77 PlaneUnittest.cpp \78 78 ObserverTest.cpp \ 79 79 ParserUnitTest.cpp \ 80 periodentafelTest.cpp \ 81 PlaneUnittest.cpp \ 80 82 SingletonTest.cpp \ 81 83 stackclassunittest.cpp \ … … 109 111 memoryusageobserverunittest.hpp \ 110 112 MoleculeDescriptorTest.hpp \ 113 periodentafelTest.hpp \ 111 114 PlaneUnittest.hpp \ 112 115 ObserverTest.hpp \ … … 179 182 manipulateAtomsTest_LDADD = ${ALLLIBS} 180 183 181 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp184 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp 182 185 MemoryAllocatorUnitTest_LDADD = ${ALLLIBS} 183 186 184 MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp187 MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp 185 188 MemoryUsageObserverUnitTest_LDADD = ${ALLLIBS} 186 189 … … 194 197 ParserUnitTest_LDADD = ${ALLLIBS} 195 198 199 periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp 200 periodentafelTest_LDADD = ${ALLLIBS} 201 196 202 PlaneUnittest_SOURCES = UnitTestMain.cpp PlaneUnittest.cpp PlaneUnittest.hpp 197 203 PlaneUnittest_LDADD = ${ALLLIBS} … … 212 218 Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS} 213 219 214 TestRunner_SOURCES = TestRunnerMain.cpp $(TESTSOURCES) $(TESTHEADERS)220 TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp $(TESTSOURCES) $(TESTHEADERS) 215 221 TestRunner_LDADD = ${ALLLIBS} 216 222 -
src/unittests/ObserverTest.cpp
re58856b rf2a1d3 11 11 #include <cppunit/extensions/TestFactoryRegistry.h> 12 12 #include <cppunit/ui/text/TestRunner.h> 13 #include <set> 13 14 14 15 #include "Patterns/Observer.hpp" 16 #include "Patterns/ObservedIterator.hpp" 15 17 #include "Helpers/Assert.hpp" 16 18 … … 162 164 bool wasNotified; 163 165 }; 166 167 class ObservableCollection : public Observable { 168 public: 169 typedef std::set<SimpleObservable*> set; 170 typedef ObservedIterator<set> iterator; 171 typedef set::const_iterator const_iterator; 172 173 ObservableCollection(int _num) : 174 num(_num) 175 { 176 for(int i=0; i<num; ++i){ 177 SimpleObservable *content = new SimpleObservable(); 178 content->signOn(this); 179 theSet.insert(content); 180 } 181 } 182 183 ~ObservableCollection(){ 184 set::iterator iter; 185 for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){ 186 delete (*iter); 187 } 188 } 189 190 iterator begin(){ 191 return iterator(theSet.begin(),this); 192 } 193 194 iterator end(){ 195 return iterator(theSet.end(),this); 196 } 197 198 const int num; 199 200 private: 201 set theSet; 202 }; 203 164 204 165 205 /******************* actuall tests ***************/ … … 173 213 blockObservable = new BlockObservable(); 174 214 notificationObservable = new NotificationObservable(); 215 collection = new ObservableCollection(5); 175 216 176 217 observer1 = new UpdateCountObserver(); … … 181 222 notificationObserver1 = new NotificationObserver(notificationObservable->notification1); 182 223 notificationObserver2 = new NotificationObserver(notificationObservable->notification2); 183 184 224 } 185 225 … … 191 231 delete blockObservable; 192 232 delete notificationObservable; 233 delete collection; 193 234 194 235 delete observer1; … … 277 318 blockObservable->changeMethod2(); 278 319 blockObservable->noChangeMethod(); 320 } 321 322 void ObserverTest::iteratorTest(){ 323 int i = 0; 324 // test the general iterator methods 325 for(ObservableCollection::iterator iter=collection->begin(); iter!=collection->end();++iter){ 326 CPPUNIT_ASSERT(i< collection->num); 327 i++; 328 } 329 330 i=0; 331 for(ObservableCollection::const_iterator iter=collection->begin(); iter!=collection->end();++iter){ 332 CPPUNIT_ASSERT(i<collection->num); 333 i++; 334 } 335 336 collection->signOn(observer1); 337 { 338 // we construct this out of the loop, so the iterator dies at the end of 339 // the scope and not the end of the loop (allows more testing) 340 ObservableCollection::iterator iter; 341 for(iter=collection->begin(); iter!=collection->end(); ++iter){ 342 (*iter)->changeMethod(); 343 } 344 // At this point no change should have been propagated 345 CPPUNIT_ASSERT_EQUAL( 0, observer1->updates); 346 } 347 // After the Iterator has died the propagation should take place 348 CPPUNIT_ASSERT_EQUAL( 1, observer1->updates); 349 350 // when using a const_iterator no changes should be propagated 351 for(ObservableCollection::const_iterator iter = collection->begin(); iter!=collection->end();++iter); 352 CPPUNIT_ASSERT_EQUAL( 1, observer1->updates); 353 collection->signOff(observer1); 279 354 } 280 355 -
src/unittests/ObserverTest.hpp
re58856b rf2a1d3 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/ParserUnitTest.cpp
re58856b rf2a1d3 31 31 32 32 void ParserUnitTest::setUp() { 33 element* oxygen = new element(); 34 oxygen->symbol[0] = 'O'; 35 oxygen->Z = 8; 36 World::getInstance().getPeriode()->AddElement(oxygen); 37 38 element* hydrogen = new element(); 39 hydrogen->symbol[0] = 'H'; 40 hydrogen->Z = 1; 41 World::getInstance().getPeriode()->AddElement(hydrogen); 33 World::getInstance(); 42 34 } 43 35 -
src/unittests/analysisbondsunittest.cpp
re58856b rf2a1d3 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
re58856b rf2a1d3 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
re58856b rf2a1d3 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
re58856b rf2a1d3 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
re58856b rf2a1d3 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 … … 240 250 { 241 251 bond *Binder = NULL; 242 atom *atom1 = TestMolecule->start->next; 243 atom *atom2 = atom1->next; 252 molecule::iterator iter = TestMolecule->begin(); 253 atom *atom1 = *iter; 254 iter++; 255 atom *atom2 = *iter; 244 256 CPPUNIT_ASSERT( atom1 != NULL ); 245 257 CPPUNIT_ASSERT( atom2 != NULL ); … … 256 268 257 269 // check if removed from molecule 258 CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last);259 }; 270 CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() ); 271 }; -
src/unittests/listofbondsunittest.hpp
re58856b rf2a1d3 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/memoryallocatorunittest.cpp
re58856b rf2a1d3 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
re58856b rf2a1d3 37 37 Stack->ClearStack(); 38 38 delete(Stack); 39 MemoryUsageObserver::purgeInstance();40 39 logger::purgeInstance(); 41 40 }; -
src/unittests/tesselation_boundarytriangleunittest.cpp
re58856b rf2a1d3 37 37 tesselpoints[0] = new TesselPoint; 38 38 tesselpoints[0]->node = new Vector(0., 0., 0.); 39 tesselpoints[0]->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name"); 40 strcpy(tesselpoints[0]->Name, "1"); 39 tesselpoints[0]->setName("1"); 41 40 tesselpoints[0]->nr = 1; 42 41 points[0] = new BoundaryPointSet(tesselpoints[0]); 43 42 tesselpoints[1] = new TesselPoint; 44 43 tesselpoints[1]->node = new Vector(0., 1., 0.); 45 tesselpoints[1]->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name"); 46 strcpy(tesselpoints[1]->Name, "2"); 44 tesselpoints[1]->setName("2"); 47 45 tesselpoints[1]->nr = 2; 48 46 points[1] = new BoundaryPointSet(tesselpoints[1]); 49 47 tesselpoints[2] = new TesselPoint; 50 tesselpoints[2] ->node = new Vector(1., 0., 0.); 51 tesselpoints[2] ->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name"); 52 strcpy(tesselpoints[2] ->Name, "3"); 53 tesselpoints[2] ->nr = 3; 48 tesselpoints[2]->node = new Vector(1., 0., 0.); 49 tesselpoints[2]->setName("3"); 50 tesselpoints[2]->nr = 3; 54 51 points[2] = new BoundaryPointSet(tesselpoints[2] ); 55 52 … … 73 70 delete tesselpoints[i]; 74 71 } 75 MemoryUsageObserver::purgeInstance();76 72 logger::purgeInstance(); 77 73 errorLogger::purgeInstance(); -
src/unittests/tesselation_insideoutsideunittest.cpp
re58856b rf2a1d3 38 38 Walker = new TesselPoint; 39 39 Walker->node = new Vector(0., 0., 0.); 40 Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name"); 41 strcpy(Walker->Name, "1"); 40 Walker->setName("1"); 42 41 Walker->nr = 1; 43 42 Corners.push_back(Walker); 44 43 Walker = new TesselPoint; 45 44 Walker->node = new Vector(0., 1., 0.); 46 Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name"); 47 strcpy(Walker->Name, "2"); 45 Walker->setName("2"); 48 46 Walker->nr = 2; 49 47 Corners.push_back(Walker); 50 48 Walker = new TesselPoint; 51 49 Walker->node = new Vector(1., 0., 0.); 52 Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name"); 53 strcpy(Walker->Name, "3"); 50 Walker->setName("3"); 54 51 Walker->nr = 3; 55 52 Corners.push_back(Walker); 56 53 Walker = new TesselPoint; 57 54 Walker->node = new Vector(1., 1., 0.); 58 Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name"); 59 strcpy(Walker->Name, "4"); 55 Walker->setName("4"); 60 56 Walker->nr = 4; 61 57 Corners.push_back(Walker); 62 58 Walker = new TesselPoint; 63 59 Walker->node = new Vector(0., 0., 1.); 64 Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name"); 65 strcpy(Walker->Name, "5"); 60 Walker->setName("5"); 66 61 Walker->nr = 5; 67 62 Corners.push_back(Walker); 68 63 Walker = new TesselPoint; 69 64 Walker->node = new Vector(0., 1., 1.); 70 Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name"); 71 strcpy(Walker->Name, "6"); 65 Walker->setName("6"); 72 66 Walker->nr = 6; 73 67 Corners.push_back(Walker); 74 68 Walker = new TesselPoint; 75 69 Walker->node = new Vector(1., 0., 1.); 76 Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name"); 77 strcpy(Walker->Name, "7"); 70 Walker->setName("7"); 78 71 Walker->nr = 7; 79 72 Corners.push_back(Walker); 80 73 Walker = new TesselPoint; 81 74 Walker->node = new Vector(1., 1., 1.); 82 Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name"); 83 strcpy(Walker->Name, "8"); 75 Walker->setName("8"); 84 76 Walker->nr = 8; 85 77 Corners.push_back(Walker); … … 142 134 } 143 135 Corners.clear(); 144 MemoryUsageObserver::purgeInstance();145 136 logger::purgeInstance(); 146 137 errorLogger::purgeInstance(); -
src/unittests/tesselationunittest.cpp
re58856b rf2a1d3 37 37 Walker = new TesselPoint; 38 38 Walker->node = new Vector(1., 0., -1.); 39 Walker->Name = Malloc<char>(3, "TesselationTest::setUp"); 40 strcpy(Walker->Name, "1"); 39 Walker->setName("1"); 41 40 Walker->nr = 1; 42 41 Corners.push_back(Walker); 43 42 Walker = new TesselPoint; 44 43 Walker->node = new Vector(-1., 1., -1.); 45 Walker->Name = Malloc<char>(3, "TesselationTest::setUp"); 46 strcpy(Walker->Name, "2"); 44 Walker->setName("2"); 47 45 Walker->nr = 2; 48 46 Corners.push_back(Walker); 49 47 Walker = new TesselPoint; 50 48 Walker->node = new Vector(-1., -1., -1.); 51 Walker->Name = Malloc<char>(3, "TesselationTest::setUp"); 52 strcpy(Walker->Name, "3"); 49 Walker->setName("3"); 53 50 Walker->nr = 3; 54 51 Corners.push_back(Walker); 55 52 Walker = new TesselPoint; 56 53 Walker->node = new Vector(-1., 0., 1.); 57 Walker->Name = Malloc<char>(3, "TesselationTest::setUp"); 58 strcpy(Walker->Name, "4"); 54 Walker->setName("4"); 59 55 Walker->nr = 4; 60 56 Corners.push_back(Walker); … … 110 106 } 111 107 Corners.clear(); 112 MemoryUsageObserver::purgeInstance();113 108 logger::purgeInstance(); 114 109 errorLogger::purgeInstance(); -
src/unittests/vectorunittest.cpp
re58856b rf2a1d3 49 49 void VectorTest::tearDown() 50 50 { 51 MemoryUsageObserver::purgeInstance();52 51 logger::purgeInstance(); 53 52 errorLogger::purgeInstance(); -
src/vector.cpp
re58856b rf2a1d3 266 266 * \return distance to plane 267 267 */ 268 double Vector::DistanceTo Plane(const Vector &PlaneNormal, const Vector &PlaneOffset) const269 { 270 return GetDistanceVectorToPlane(PlaneNormal,PlaneOffset).Norm();268 double Vector::DistanceToSpace(const Space &space) const 269 { 270 return space.distance(*this); 271 271 }; 272 272 … … 543 543 // truncate to [0,1] for each axis 544 544 for (int i=0;i<NDIM;i++) { 545 x[i] += 0.5; // set to center of box545 //x[i] += 0.5; // set to center of box 546 546 while (x[i] >= 1.) 547 547 x[i] -= 1.; -
src/vector.hpp
re58856b rf2a1d3 40 40 double DistanceSquared(const Vector &y) const; 41 41 Vector GetDistanceVectorToPlane(const Vector &PlaneNormal, const Vector &PlaneOffset) const; 42 double DistanceTo Plane(const Vector &PlaneNormal, const Vector &PlaneOffset) const;42 double DistanceToSpace(const Space& space) const; 43 43 double PeriodicDistance(const Vector &y, const double * const cell_size) const; 44 44 double PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const; -
tests/Makefile.am
re58856b rf2a1d3 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
re58856b rf2a1d3 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 … … 68 67 #cat diffstderr 69 68 #cat diffstdout 70 cd .. 69 cd ../.. 71 70 test $exitcode = $expected_exitcode || exit 1 72 71 } -
tests/regression/Tesselation/1/post/NonConvexEnvelope.r3d
re58856b rf2a1d3 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
re58856b rf2a1d3 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
re58856b rf2a1d3 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
re58856b rf2a1d3 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
re58856b rf2a1d3 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.