Changes in / [e58856b:f2a1d3]


Ignore:
Files:
80 added
4 deleted
98 edited

Legend:

Unmodified
Added
Removed
  • Makefile.am

    re58856b rf2a1d3  
    11ACLOCAL_AMFLAGS = -I m4
    2 SUBDIRS = src src/Actions src/unittests doc tests
     2SUBDIRS = src src/unittests doc tests
    33
    44EXTRA_DIST = autogen.sh
  • configure.ac

    re58856b rf2a1d3  
    2727
    2828# Boost libraries
    29 AX_BOOST_BASE([1.33.1])
     29AX_BOOST_BASE([1.40])
    3030AX_BOOST_PROGRAM_OPTIONS
    3131#AX_BOOST_FOREACH
    3232#AX_BOOST_FILESYSTEM
    3333AX_BOOST_THREAD
    34 #AX_BOOST_PROGRAM_OPTIONS
    3534#AX_BOOST_SERIALIZATION
    3635
     
    9392
    9493# test suite
    95 AC_CONFIG_TESTDIR(tests)
     94AC_CONFIG_TESTDIR(tests/regression)
    9695AC_CONFIG_FILES([
    97         tests/atlocal
    98         tests/Makefile])
     96        tests/Makefile
     97        tests/regression/atlocal
     98        tests/regression/Makefile])
     99AC_CONFIG_FILES([tests/regression/molecuilder], [chmod +x tests/regression/molecuilder])
    99100AC_CONFIG_FILES([
    100101        tests/Tesselations/Makefile
    101102        tests/Tesselations/defs])
    102 AC_CONFIG_FILES([tests/molecuilder], [chmod +x tests/molecuilder])
    103103AC_CONFIG_FILES([
    104104        doc/molecuilder.xml])
  • src/Actions/FragmentationAction/DepthFirstSearchAction.cpp

    re58856b rf2a1d3  
    4646    molecule * const mol = World::getInstance().getMolecule(MoleculeById(0));
    4747    MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    48     int *MinimumRingSize = new int[mol->AtomCount];
     48    int *MinimumRingSize = new int[mol->getAtomCount()];
    4949    atom ***ListOfLocalAtoms = NULL;
    5050    class StackClass<bond *> *BackEdgeStack = NULL;
     
    6666      delete(Subgraphs);
    6767      for (int i=0;i<FragmentCounter;i++)
    68         Free(&ListOfLocalAtoms[i]);
    69       Free(&ListOfLocalAtoms);
     68        delete[](ListOfLocalAtoms[i]);
     69      delete[](ListOfLocalAtoms);
    7070    }
    7171    delete(BackEdgeStack);
  • src/Actions/Makefile.am

    re58856b rf2a1d3  
    3030  ${TESSELATIONACTIONHEADER} \
    3131  ${WORLDACTIONHEADER} \
    32   MapOfActions.hpp
     32  MapOfActions.hpp \
     33  Values.hpp
    3334 
    3435ANALYSISACTIONSOURCE = \
  • src/Actions/MapOfActions.cpp

    re58856b rf2a1d3  
    1212#include "Helpers/Assert.hpp"
    1313
     14#include <boost/lexical_cast.hpp>
     15#include <boost/optional.hpp>
     16#include <boost/program_options.hpp>
     17
    1418#include "CommandLineParser.hpp"
    1519#include "log.hpp"
    1620#include "verbose.hpp"
     21
     22#include "Actions/Values.hpp"
     23
     24void 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
     37void 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
    1753
    1854/** Constructor of class MapOfActions.
     
    6298  DescriptionMap["save-bonds"] = "name of the bonds file to write to";
    6399  DescriptionMap["save-temperature"] = "name of the temperature file to write to";
     100  DescriptionMap["scale-box"] = "scale box and atomic positions inside";
    64101  DescriptionMap["subspace-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs";
    65102  DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified";
     
    75112  DescriptionMap["distance"] = "distance in space";
    76113  DescriptionMap["distances"] = "list of three of distances in space, one for each axis direction";
     114  DescriptionMap["DoRotate"] = "whether to rotate or just report angles";
    77115  DescriptionMap["element"] = "set of elements";
    78116  DescriptionMap["end-mol"] = "last or end step";
     
    92130  ShortFormMap["bond-file"] = "A";
    93131  ShortFormMap["boundary"] = "c";
    94   ShortFormMap["bound-in-box"] = "B";
     132  ShortFormMap["change-box"] = "B";
    95133  ShortFormMap["center-edge"] = "O";
    96134  ShortFormMap["center-in-box"] = "b";
     
    123161  ShortFormMap["suspend-in-water"] = "U";
    124162  ShortFormMap["translate-mol"] = "t";
    125   ShortFormMap["verbose"] = "V";
     163  ShortFormMap["verbose"] = "v";
    126164  ShortFormMap["verlet-integrate"] = "P";
    127   ShortFormMap["version"] = "v";
     165  ShortFormMap["version"] = "V";
    128166
    129167  // value types for the actions
     
    132170  TypeMap["bond-table"] = String;
    133171  TypeMap["boundary"] = Vector;
    134   TypeMap["change-box"] = Vector;
     172  TypeMap["center-in-box"] = Box;
     173  TypeMap["change-box"] = Box;
    135174  TypeMap["change-element"] = Element;
    136175  TypeMap["change-molname"] = String;
     
    151190  TypeMap["remove-atom"] = Atom;
    152191  TypeMap["remove-sphere"] = Atom;
    153   TypeMap["repeat-box"] = ListOfInts;
     192  TypeMap["repeat-box"] = Vector;
    154193  TypeMap["rotate-to-pas"] = Molecule;
    155194  TypeMap["save-adjacency"] = String;
     
    163202  TypeMap["verlet-integrate"] = String;
    164203  TypeMap["verbose"] = Integer;
     204
    165205  // value types for the values
    166206  TypeMap["bin-output-file"] = String;
     
    168208  TypeMap["bin-start"] = Double;
    169209  TypeMap["distance"] = Double;
    170   TypeMap["distances"] = ListOfDoubles;
     210  TypeMap["distances"] = Vector;
     211  TypeMap["DoRotate"] = Boolean;
    171212  TypeMap["elements"] = Element;
    172213  TypeMap["elements"] = ListOfElements;
    173214  TypeMap["length"] = Double;
    174   TypeMap["lengths"] = ListOfDoubles;
     215  TypeMap["lengths"] = Vector;
    175216  TypeMap["MaxDistance"] = Double;
    176217  TypeMap["molecule-by-id"] = Molecule;
     
    179220  TypeMap["position"] = Vector;
    180221
     222  // default values for any action that needs one (always string!)
     223  DefaultValue["molecule-by-id"] = "-1";
     224
     225
    181226  // list of generic actions
    182227//      generic.insert("add-atom");
    183228//  generic.insert("bond-file");
    184229//      generic.insert("bond-table");
    185 //  generic.insert("boundary");
     230  generic.insert("boundary");
    186231//  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");
    190235//  generic.insert("change-molname");
    191236//      generic.insert("change-element");
     
    195240//      generic.insert("element-db");
    196241//      generic.insert("fastparsing");
    197 //  generic.insert("fill-molecule");
     242  generic.insert("fill-molecule");
    198243//  generic.insert("fragment-mol");
    199244  generic.insert("help");
     
    208253//  generic.insert("remove-atom");
    209254//  generic.insert("remove-sphere");
     255  generic.insert("repeat-box");
    210256//  generic.insert("rotate-to-pas");
    211257//      generic.insert("save-adjacency");
    212258//  generic.insert("save-bonds");
    213259//  generic.insert("save-temperature");
    214 //  generic.insert("scale-box");
     260  generic.insert("scale-box");
    215261//  generic.insert("set-basis");
    216262//      generic.insert("subspace-dissect");
     
    230276    generic.insert("input");
    231277//  generic.insert("length");
    232 //  generic.insert("lengths");
    233 //  generic.insert("MaxDistance");
    234 //  generic.insert("molecule-by-id");
    235278//  generic.insert("output-file");
    236279//  generic.insert("periodic");
     
    240283    // positional arguments
    241284    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");
    242293}
    243294
     
    269320          case Boolean:
    270321            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())
    272334              ;
    273335            break;
    274336          case Integer:
    275337            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())
    277343              ;
    278344            break;
    279345          case ListOfInts:
    280346            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())
    282350              ;
    283351            break;
    284352          case Double:
    285353            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())
    287359              ;
    288360            break;
    289361          case ListOfDoubles:
    290362            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())
    292366              ;
    293367            break;
    294368          case String:
    295369            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())
    297375              ;
    298376            break;
    299377          case Axis:
    300378            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())
    302384              ;
    303385            break;
    304386          case Vector:
    305387            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())
    312391              ;
    313392            break;
    314393          case Molecule:
    315394            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())
    317400              ;
    318401            break;
    319402          case ListOfMolecules:
    320403            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())
    322407              ;
    323408            break;
    324409          case Atom:
    325410            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())
    327416              ;
    328417            break;
    329418          case ListOfAtoms:
    330419            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())
    332423              ;
    333424            break;
    334425          case Element:
    335426            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())
    337432              ;
    338433            break;
    339434          case ListOfElements:
    340435            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())
    342439              ;
    343440            break;
  • src/Actions/MapOfActions.hpp

    re58856b rf2a1d3  
    5353
    5454  // map of the action names and their description
     55  map<std::string, std::string> DefaultValue;
    5556  map<std::string, std::string> DescriptionMap;
    5657  map<std::string, std::string> ShortFormMap;
  • src/Actions/MoleculeAction/FillWithMoleculeAction.cpp

    re58856b rf2a1d3  
    6666
    6767  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);
    6869    // construct water molecule
    6970    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());
    7475    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);
    9091    World::getInstance().getConfig()->BG->ConstructBondGraph(filler);
    91     filler->SetNameFromFilename("water");
     92//    filler->SetNameFromFilename("water");
    9293    // call routine
    9394    double distance[NDIM];
  • src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp

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

    re58856b rf2a1d3  
    6969    AtomRunner = AllAtoms.begin();
    7070    for (; AtomRunner != AllAtoms.end(); ++AtomRunner)
    71       (*AtomRunner)->x -= Min;
     71      (*AtomRunner)->x -= Min - boundary;
    7272    delete dialog;
    7373    return Action::success;
  • src/Actions/WorldAction/CenterInBoxAction.cpp

    re58856b rf2a1d3  
    3333  Dialog *dialog = UIFactory::getInstance().makeDialog();
    3434
    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));
    3637
    3738  if(dialog->display()) {
  • src/Actions/WorldAction/RepeatBoxAction.cpp

    re58856b rf2a1d3  
    2323#include "UIElements/Dialog.hpp"
    2424#include "Actions/MapOfActions.hpp"
     25#include "Descriptors/MoleculeDescriptor.hpp"
     26#include "Descriptors/MoleculePtrDescriptor.hpp"
    2527
    2628const char WorldRepeatBoxAction::NAME[] = "repeat-box";
     
    4042  molecule *mol = NULL;
    4143  int j = 0;
     44  atom *Walker = NULL;
     45  MoleculeListClass *molecules = World::getInstance().getMolecules();
    4246
    4347  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  }
    4557
    4658  if(dialog->display()) {
     59    (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl);
    4760    double * const cell_size = World::getInstance().getDomain();
     61    double *M = ReturnFullMatrixforSymmetric(cell_size);
    4862    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++) {
    5165      Repeater[axis] = floor(Repeater[axis]);
    5266      if (Repeater[axis] < 1) {
     
    5468        Repeater[axis] = 1;
    5569      }
    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            }
    81115          }
    82116        }
    83         // free memory
    84         delete[](Elements);
    85         delete[](vectors);
    86         // correct cell size
    87         if (axis < 0) { // if sign was negative, we have to translate everything
    88           x =(-(Repeater[axis]-1)) * y;
    89           mol->Translate(&x);
    90         }
    91         cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= Repeater[axis];
    92117      }
    93118    }
     119    delete(M);
    94120    delete dialog;
    95121    return Action::success;
  • src/Helpers/Assert.cpp

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

    re58856b rf2a1d3  
    99#include <cstdlib>
    1010#include <cstring>
     11#include <boost/thread.hpp>
    1112
    1213using namespace std;
     14
     15#ifndef NDBEGUG
     16#ifndef NO_MEMDEBUG
    1317
    1418namespace Memory {
     
    4044  };
    4145
     46  boost::mutex memorylock;
     47
    4248  // start and end of the doubly-linked list
    4349  entry_t *begin=0;
     
    128134void *operator new(size_t nbytes,const char* file, int line) throw(std::bad_alloc) {
    129135
     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
    130139  // to avoid allocations of 0 bytes if someone screws up
    131140  // allocation with 0 byte size are undefined behavior, so we are
     
    153162  // build the entry in front of the space
    154163  Memory::entry_t *entry = (Memory::entry_t*) res;
     164  memset(res,0,entrySpace);
    155165  entry->info.nbytes = nbytes;
    156166  entry->info.isUsed = true;
     
    203213
    204214void 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
    205223  // get the size for the entry, including alignment
    206224  static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t));
     
    211229  // let's see if the checksum is still matching
    212230  if(Memory::calcChecksum(&entry->info)!=entry->checksum){
    213     cout << "Possible memory corruption detected!" << endl;
    214     cout << "Trying to recover allocation information..." << endl;
    215     cout << "Memory was allocated at " << entry->info.file << ":" << entry->info.line << endl;
     231    cerr << "Possible memory corruption detected!" << endl;
     232    cerr << "Trying to recover allocation information..." << endl;
     233    cerr << "Memory was allocated at " << entry->info.file << ":" << entry->info.line << endl;
    216234    terminate();
    217235  }
     
    240258  operator delete(ptr);
    241259}
     260#endif
     261#endif
  • src/Helpers/MemDebug.hpp

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

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

    re58856b rf2a1d3  
    113113  Descriptors/AtomTypeDescriptor.cpp \
    114114  Descriptors/MoleculeDescriptor.cpp \
    115   Descriptors/MoleculeIdDescriptor.cpp
     115  Descriptors/MoleculeIdDescriptor.cpp \
     116  Descriptors/MoleculePtrDescriptor.cpp
    116117                                   
    117                                    
     118
    118119DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \
    119120  Descriptors/AtomIdDescriptor.hpp \
    120121  Descriptors/AtomTypeDescriptor.hpp \
    121122  Descriptors/MoleculeDescriptor.hpp \
    122   Descriptors/MoleculeIdDescriptor.hpp
     123  Descriptors/MoleculeIdDescriptor.hpp \
     124  Descriptors/MoleculePtrDescriptor.hpp
    123125                                   
    124126EXCEPTIONSOURCE = Exceptions/CustomException.cpp \
     
    148150  config.cpp \
    149151  element.cpp \
     152  elements_db.cpp \
    150153  ellipsoid.cpp \
    151154  errorlogger.cpp \
     
    156159  Line.cpp \
    157160  linkedcell.cpp \
    158   lists.cpp \
    159161  log.cpp \
    160162  logger.cpp \
    161   memoryusageobserver.cpp \
    162163  moleculelist.cpp \
    163164  molecule.cpp \
     
    170171  periodentafel.cpp \
    171172  Plane.cpp \
     173  Space.cpp \
    172174  tesselation.cpp \
    173175  tesselationhelpers.cpp \
    174176  triangleintersectionlist.cpp \
     177  vector.cpp \
     178  vector_ops.cpp \
    175179  verbose.cpp \
    176   vector_ops.cpp \
    177180  World.cpp
    178181
     
    193196  defs.hpp \
    194197  element.hpp \
     198  elements_db.hpp \
    195199  ellipsoid.hpp \
    196200  errorlogger.hpp \
     
    204208  log.hpp \
    205209  logger.hpp \
    206   memoryallocator.hpp \
    207   memoryusageobserver.hpp \
    208210  molecule.hpp \
    209211  molecule_template.hpp \
     
    218220  vector_ops.hpp \
    219221  World.hpp
     222
     223# the following files are no longer used:
     224#  memoryallocator.hpp \
     225#  memoryallocator.cpp \
     226#  memoryusageobserver.hpp \
     227#  memoryusageobserver.cpp
    220228
    221229BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB)
  • src/Patterns/Cacheable.hpp

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

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

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

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

    re58856b rf2a1d3  
    2626  Plane(const Vector &_normalVector, double _offset)  throw(ZeroVectorException);
    2727  Plane(const Vector &_normalVector, const Vector &_offsetVector) throw(ZeroVectorException);
     28  Plane(const Plane& plane);
    2829  virtual ~Plane();
    2930
  • src/UIElements/CommandLineUI/CommandLineDialog.cpp

    re58856b rf2a1d3  
    1515#include <Descriptors/MoleculeIdDescriptor.hpp>
    1616#include "CommandLineUI/CommandLineDialog.hpp"
     17
     18#include "Actions/Values.hpp"
    1719
    1820#include "element.hpp"
     
    116118
    117119bool 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;
    138125}
    139126
     
    192179  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    193180    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;
    195186    return true;
    196187  } else
     
    206197
    207198bool 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;
    214205    return true;
    215206  } else
     
    226217
    227218bool 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;
    234228    return true;
    235229  } else
  • src/UIElements/CommandLineUI/CommandLineWindow.cpp

    re58856b rf2a1d3  
    7373CommandLineWindow::~CommandLineWindow()
    7474{
    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   }
     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//  }
    8080
    8181  delete statusIndicator;
  • src/UIElements/Dialog.cpp

    re58856b rf2a1d3  
    166166  target(_target)
    167167{
    168 tmp = new Vector();
     168  tmp = new Vector();
    169169}
    170170
     
    193193
    194194void 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  }
    197198}
    198199
  • src/World.cpp

    re58856b rf2a1d3  
    8787  delete[](defaultName);
    8888  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];
    9191    strncpy(defaultName, name, length);
    92   else
    93     strcpy(defaultName, "none");
     92  } else {
     93    defaultName = new char[MAXSTRINGSIZE];
     94    strncpy(defaultName, "none", MAXSTRINGSIZE-1);
     95  }
    9496};
    9597
  • src/analysis_bonds.cpp

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

    re58856b rf2a1d3  
    3131
    3232void 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);
     33void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max);
    3434
    35 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, element * InterfaceElement);
     35int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, const element * InterfaceElement);
    3636int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second);
    3737int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third);
  • src/analysis_correlation.cpp

    re58856b rf2a1d3  
    3939    return outmap;
    4040  }
     41  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     42    (*MolWalker)->doCountAtoms();
    4143  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++){
    4345    if ((*MolWalker)->ActiveFlag) {
    4446      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++){
    5152            if ((*MolOtherWalker)->ActiveFlag) {
    5253              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)) ) );
    6261                  }
     62                }
    6363              }
     64            }
    6465          }
    6566        }
    6667      }
    6768    }
    68 
     69  }
    6970  return outmap;
    7071};
     
    9596    return outmap;
    9697  }
     98  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     99    (*MolWalker)->doCountAtoms();
    97100  outmap = new PairCorrelationMap;
    98101  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     
    101104      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    102105      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;
    109110          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    110111          // go through every range in xyz and get distance
     
    117118                  if ((*MolOtherWalker)->ActiveFlag) {
    118119                    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;
    126125                          periodicOtherX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    127126                          // go through every range in xyz and get distance
     
    132131                                checkOtherX.MatrixMultiplication(FullMatrix);
    133132                                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)) ) );
    136135                              }
    137136                        }
     
    141140        }
    142141      }
    143       Free(&FullMatrix);
    144       Free(&FullInverseMatrix);
     142      delete[](FullMatrix);
     143      delete[](FullInverseMatrix);
    145144    }
    146145
     
    165164    return outmap;
    166165  }
     166  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     167    (*MolWalker)->doCountAtoms();
    167168  outmap = new CorrelationToPointMap;
    168169  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    169170    if ((*MolWalker)->ActiveFlag) {
    170171      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());
    177176          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) ) );
    179178        }
    180179      }
     
    205204    return outmap;
    206205  }
     206  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     207    (*MolWalker)->doCountAtoms();
    207208  outmap = new CorrelationToPointMap;
    208209  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     
    211212      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    212213      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;
    219218          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    220219          // go through every range in xyz and get distance
     
    226225                distance = checkX.distance(*point);
    227226                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) ) );
    229228              }
    230229        }
    231230      }
    232       Free(&FullMatrix);
    233       Free(&FullInverseMatrix);
     231      delete[](FullMatrix);
     232      delete[](FullInverseMatrix);
    234233    }
    235234
     
    257256    return outmap;
    258257  }
     258  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     259    (*MolWalker)->doCountAtoms();
    259260  outmap = new CorrelationToSurfaceMap;
    260261  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    261262    if ((*MolWalker)->ActiveFlag) {
    262263      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);
    269270          distance = Intersections.GetSmallestDistance();
    270271          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 {
    275276      DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl);
     277    }
    276278
    277279  return outmap;
     
    306308    return outmap;
    307309  }
     310  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     311    (*MolWalker)->doCountAtoms();
    308312  outmap = new CorrelationToSurfaceMap;
    309313  double ShortestDistance = 0.;
     
    314318      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    315319      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;
    322324          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    323325          // go through every range in xyz and get distance
     
    337339              }
    338340          // 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) ) );
    340342          //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
    341343        }
    342344      }
    343       Free(&FullMatrix);
    344       Free(&FullInverseMatrix);
     345      delete[](FullMatrix);
     346      delete[](FullInverseMatrix);
    345347    }
    346348
  • src/analyzer.cpp

    re58856b rf2a1d3  
    7575    return 1;
    7676  } else {
    77     dir = Malloc<char>(strlen(argv[2]) + 2, "main: *dir");
     77    dir = new char[strlen(argv[2]) + 2];
    7878    strcpy(dir, "/");
    7979    strcat(dir, argv[2]);
     
    8282  if (argc > 4) {
    8383    DoLog(0) && (Log() << Verbose(0) << "Loading periodentafel." << endl);
    84     periode = Malloc<periodentafel>(1, "main - periode");
     84    periode = new periodentafel;
    8585    periode->LoadPeriodentafel(argv[4]);
    8686  }
     
    558558  // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++
    559559  delete(periode);
    560   Free(&dir);
     560  delete[](dir);
    561561  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    562562  return 0;
  • src/atom.cpp

    re58856b rf2a1d3  
    4040
    4141atom *atom::clone(){
    42   atom *res = new atom();
     42  atom *res = new atom(this);
    4343  res->previous=0;
    4444  res->next=0;
     
    5959atom::~atom()
    6060{
    61   unlink(this);
    6261};
    6362
     
    270269{
    271270  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];
    274273  for (int i=ListOfBonds.size()+1;i--;)
    275274    ComponentNr[i] = -1;
  • src/atom_bondedparticle.cpp

    re58856b rf2a1d3  
    4444void BondedParticle::OutputBondOfAtom() const
    4545{
    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);
    4747  int TotalDegree = 0;
    4848  for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); ++Runner) {
  • src/atom_graphnode.cpp

    re58856b rf2a1d3  
    2727void GraphNode::OutputGraphInfo() const
    2828{
    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 ");
    3030  OutputComponentNumber();
    3131  DoLog(3) && (Log() << Verbose(3) << " with Lowpoint " << LowpointNr << " and Graph Nr. " << GraphNr << "." << endl);
  • src/atom_graphnodeinfo.cpp

    re58856b rf2a1d3  
    1717GraphNodeInfo::~GraphNodeInfo()
    1818{
    19   Free<int>(&ComponentNr, "atom::~atom: *ComponentNr");
     19  delete[](ComponentNr);
    2020};
  • src/atom_particleinfo.cpp

    re58856b rf2a1d3  
    1111/** Constructor of ParticleInfo.
    1212 */
    13 ParticleInfo::ParticleInfo() : nr(-1), Name(NULL) {};
     13ParticleInfo::ParticleInfo() : nr(-1), name("Unknown") {
     14};
    1415
    1516ParticleInfo::ParticleInfo(ParticleInfo *pointer) :
    1617    nr(pointer->nr),
    17     Name(pointer->Name)
    18     {
    19       if (Name == NULL)
    20         Name = " ";
    21     }
     18    name(pointer->name)
     19    {}
    2220
    2321
     
    2523 */
    2624ParticleInfo::~ParticleInfo()
    27 {
    28   Free(&Name);
    29 };
     25{};
     26
     27const string& ParticleInfo::getName() const{
     28  return name;
     29}
     30
     31void ParticleInfo::setName(const string& _name){
     32  name = _name;
     33}
    3034
    3135ostream & operator << (ostream &ost, const ParticleInfo &a)
    3236{
    33   if (a.Name == NULL)
    34     ost << "[NULL]";
    35   else
    36     ost << "[" << a.Name << "|" << &a << "]";
     37  ost << "[" << a.getName() << "|" << &a << "]";
    3738  return ost;
    3839};
     
    4041ostream & ParticleInfo::operator << (ostream &ost) const
    4142{
    42   if (Name == NULL)
    43     ost << "[NULL]";
    44   else
    45     ost << "[" << Name << "|" << this << "]";
     43  ost << "[" << name << "|" << this << "]";
    4644  return ost;
    4745};
  • src/atom_particleinfo.hpp

    re58856b rf2a1d3  
    2828public:
    2929  int nr;       // index to easierly identify
    30   char *Name;   // some name to reference to on output
    3130
    3231  ParticleInfo();
     
    3433  ~ParticleInfo();
    3534
     35  const std::string& getName() const;
     36  void setName(const std::string&);
     37
    3638  ostream & operator << (ostream &ost) const;
    3739
    3840private:
     41  std::string name;   // some name to reference to on output
    3942};
    4043
  • src/atom_trajectoryparticle.cpp

    re58856b rf2a1d3  
    1010#include "config.hpp"
    1111#include "element.hpp"
     12#include "info.hpp"
    1213#include "log.hpp"
    1314#include "parser.hpp"
     
    7172void TrajectoryParticle::ResizeTrajectory(int MaxSteps)
    7273{
     74  Info FunctionInfo(__func__);
    7375  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);
    7577    Trajectory.R.resize(MaxSteps+1);
    7678    Trajectory.U.resize(MaxSteps+1);
  • src/bond.cpp

    re58856b rf2a1d3  
    5353ostream & operator << (ostream &ost, const bond &b)
    5454{
    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() << "]";
    5656  return ost;
    5757};
  • src/bondgraph.cpp

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

    re58856b rf2a1d3  
    139139{
    140140        Info FunctionInfo(__func__);
    141   atom *Walker = NULL;
    142141  PointMap PointsOnBoundary;
    143142  LineMap LinesOnBoundary;
     
    165164
    166165    // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours
    167     Walker = mol->start;
    168     while (Walker->next != mol->end) {
    169       Walker = Walker->next;
    170       ProjectedVector = Walker->x - (*MolCenter);
     166    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     167      ProjectedVector = (*iter)->x - (*MolCenter);
    171168      ProjectedVector.ProjectOntoPlane(AxisVector);
    172169
     
    182179        angle = 2. * M_PI - angle;
    183180      }
    184       DoLog(1) && (Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);
    185       BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, Walker)));
     181    DoLog(1) && (Log() << Verbose(1) << "Inserting " << **iter << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);
     182      BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, (*iter))));
    186183      if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity
    187184        DoLog(2) && (Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl);
    188185        DoLog(2) && (Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl);
    189         DoLog(2) && (Log() << Verbose(2) << "New vector: " << *Walker << endl);
     186        DoLog(2) && (Log() << Verbose(2) << "New vector: " << **iter << endl);
    190187        const double ProjectedVectorNorm = ProjectedVector.NormSquared();
    191188        if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) {
    192189          BoundaryTestPair.first->second.first = ProjectedVectorNorm;
    193           BoundaryTestPair.first->second.second = Walker;
     190          BoundaryTestPair.first->second.second = (*iter);
    194191          DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl);
    195192        } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) {
    196           helper = Walker->x - (*MolCenter);
     193          helper = (*iter)->x;
     194          helper -= *MolCenter;
    197195          const double oldhelperNorm = helper.NormSquared();
    198196          helper = BoundaryTestPair.first->second.second->x - (*MolCenter);
    199197          if (helper.NormSquared() < oldhelperNorm) {
    200             BoundaryTestPair.first->second.second = Walker;
     198            BoundaryTestPair.first->second.second = (*iter);
    201199            DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl);
    202200          } else {
     
    226224    do { // do as long as we still throw one out per round
    227225      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++;
    231233        // set neighbours correctly
    232234        if (runner == BoundaryPoints[axis].begin()) {
     
    236238        }
    237239        left--;
    238         right = runner;
    239         right++;
    240240        if (right == BoundaryPoints[axis].end()) {
    241241          right = BoundaryPoints[axis].begin();
     242          LoopOnceDone = true;
    242243        }
    243244        // check distance
     
    279280            DoLog(1) && (Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl);
    280281            BoundaryPoints[axis].erase(runner);
     282            runner = right;
    281283            flag = true;
    282284          }
     
    359361
    360362  // 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");
    381364
    382365  // 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
     
    397380          TesselStruct->FlipBaseline(line);
    398381          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
    399383        }
    400384      }
     
    409393
    410394  // 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, "");
    430396
    431397  // free reference lists
     
    620586  for (TriangleMap::iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++)
    621587    { // 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));
    627593      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));
    632596      const double h = x.Norm(); // distance of CoG to triangle
    633597      const double PyramidVolume = (1. / 3.) * G * h; // this formula holds for _all_ pyramids (independent of n-edge base or (not) centered peak)
     
    680644/** Creates multiples of the by \a *mol given cluster and suspends them in water with a given final density.
    681645 * We get cluster volume by VolumeOfConvexEnvelope() and its diameters by GetDiametersOfCluster()
     646 * TODO: Here, we need a VolumeOfGeneralEnvelope (i.e. non-convex one)
    682647 * \param *out output stream for debugging
    683648 * \param *configuration needed for path to store convex envelope file
     
    697662  int repetition[NDIM] = { 1, 1, 1 };
    698663  int TotalNoClusters = 1;
    699   atom *Walker = NULL;
    700664  double totalmass = 0.;
    701665  double clustervolume = 0.;
     
    708672  GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem);
    709673  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
    712678
    713679  // some preparations beforehand
     
    721687
    722688  // 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;
    727691  }
    728692  DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl);
     
    806770  Vector Inserter;
    807771  double FillIt = false;
    808   atom *Walker = NULL;
    809772  bond *Binder = NULL;
    810773  double phi[NDIM];
     
    813776
    814777  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++)
    815     if ((*ListRunner)->AtomCount > 0) {
     778    if ((*ListRunner)->getAtomCount() > 0) {
    816779      DoLog(1) && (Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl);
    817780      LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list
     
    824787  filler->CenterEdge(&Inserter);
    825788  filler->Center.Zero();
     789  const int FillerCount = filler->getAtomCount();
    826790  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];
    835797
    836798  // calculate filler grid in [0,1]^3
     
    857819
    858820        // go through all atoms
    859         for (int i=0;i<filler->AtomCount;i++)
     821        for (int i=0;i<FillerCount;i++)
    860822          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){
    864824
    865825          // create atomic random translation vector ...
     
    885845
    886846          // ... and put at new position
    887           Inserter = Walker->x;
     847          Inserter = (*iter)->x;
    888848          if (DoRandomRotation)
    889849            Inserter.MatrixMultiplication(Rotations);
     
    909869            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl);
    910870            // 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);
    915875          } else {
    916876            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;
    918878            continue;
    919879          }
    920880        }
    921881        // 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            }
    930891      }
    931   Free(&M);
    932   Free(&MInverse);
     892  delete[](M);
     893  delete[](MInverse);
    933894
    934895  return Filling;
     
    954915  bool TesselationFailFlag = false;
    955916
     917  mol->getAtomCount();
     918
    956919  if (TesselStruct == NULL) {
    957920    DoLog(1) && (Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl);
     
    1025988//  // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles
    1026989//  //->InsertStraddlingPoints(mol, LCList);
    1027 //  mol->GoToFirst();
     990//  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    1028991//  class TesselPoint *Runner = NULL;
    1029 //  while (!mol->IsEnd()) {
    1030 //    Runner = mol->GetPoint();
     992//    Runner = *iter;
    1031993//    Log() << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl;
    1032994//    if (!->IsInnerPoint(Runner, LCList)) {
     
    1036998//      Log() << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl;
    1037999//    }
    1038 //    mol->GoToNext();
    10391000//  }
    10401001
     
    10451006  status = CheckListOfBaselines(TesselStruct);
    10461007
     1008  cout << "before correction" << endl;
     1009
    10471010  // store before correction
    1048   StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");
     1011  StoreTrianglesinFile(mol, TesselStruct, filename, "");
    10491012
    10501013//  // correct degenerated polygons
     
    10561019  // write final envelope
    10571020  CalculateConcavityPerBoundaryPoint(TesselStruct);
    1058   StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");
     1021  cout << "after correction" << endl;
     1022  StoreTrianglesinFile(mol, TesselStruct, filename, "");
    10591023
    10601024  if (freeLC)
  • src/builder.cpp

    re58856b rf2a1d3  
    5353
    5454#include <cstring>
     55#include <cstdlib>
    5556
    5657#include "analysis_bonds.hpp"
     
    864865
    865866        mol->CountAtoms(); // recount atoms
    866         if (mol->AtomCount != 0) {  // if there is more than none
    867           count = mol->AtomCount;  // is changed becausing of adding, thus has to be stored away beforehand
     867        if (mol->getAtomCount() != 0) {  // if there is more than none
     868          count = mol->getAtomCount();  // is changed becausing of adding, thus has to be stored away beforehand
    868869          Elements = new element *[count];
    869870          vectors = new Vector *[count];
     
    12951296  // generate some KeySets
    12961297  DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl);
    1297   KeySet TestSets[mol->AtomCount+1];
     1298  KeySet TestSets[mol->getAtomCount()+1];
    12981299  i=1;
    12991300  while (Walker->next != mol->end) {
     
    13061307  DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl);
    13071308  KeySetTestPair test;
    1308   test = TestSets[mol->AtomCount-1].insert(Walker->nr);
     1309  test = TestSets[mol->getAtomCount()-1].insert(Walker->nr);
    13091310  if (test.second) {
    13101311    DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
     
    13121313    DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl);
    13131314  }
    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);
    13161317
    13171318  // constructing Graph structure
     
    13211322  // insert KeySets into Subgraphs
    13221323  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++) {
    13241325    Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
    13251326  }
    13261327  DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl);
    13271328  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.)));
    13291330  if (test2.second) {
    13301331    DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
     
    14941495 */
    14951496static 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)
    14971498{
    14981499  Vector x,y,z,n;  // coordinates for absolute point in cell volume
     
    15121513  molecule *mol = NULL;
    15131514  string BondGraphFileName("\n");
    1514   strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1);
     1515  bool DatabasePathGiven = false;
    15151516
    15161517  if (argc > 1) { // config file specified as option
     
    15291530            break;
    15301531          case 'v':
    1531             ArgcList.insert(argptr-1);
    1532             return(1);
    1533             break;
    1534           case 'V':
     1532            setVerbosity(atoi(argv[argptr]));
    15351533            ArgcList.insert(argptr-1);
    15361534            ArgcList.insert(argptr);
    15371535            argptr++;
    15381536            break;
     1537          case 'V':
     1538            ArgcList.insert(argptr-1);
     1539            return(1);
     1540            break;
    15391541          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;
    15401550            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             }
    15551551            break;
    15561552          case 'e':
     
    15611557              DoLog(0) && (Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl);
    15621558              strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1);
     1559              DatabasePathGiven = true;
    15631560              argptr+=1;
    15641561            }
     
    15741571            }
    15751572            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;
    15761584          case 'n':
    15771585            DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
     
    15811589            {
    15821590              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);
    15841592            }
    15851593            break;
     
    15931601
    15941602    // 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      }
    16021611    // 3b. Find config file name and parse if possible, also BondGraphFileName
    16031612    if (argv[1][0] != '-') {
     
    16131622        } else {
    16141623          DoLog(0) && (Log() << Verbose(0) << "Empty configuration file." << endl);
    1615           ConfigFileName = argv[1];
     1624          strcpy(*ConfigFileName, argv[1]);
    16161625          configPresent = empty;
    16171626          output.close();
     
    16191628      } else {
    16201629        test.close();
    1621         ConfigFileName = argv[1];
     1630        strcpy(*ConfigFileName, argv[1]);
    16221631        DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
    1623         switch (configuration.TestSyntax(ConfigFileName, periode)) {
     1632        switch (configuration.TestSyntax(*ConfigFileName, periode)) {
    16241633          case 1:
    16251634            DoLog(0) && (Log() << Verbose(0) << "new syntax." << endl);
    1626             configuration.Load(ConfigFileName, BondGraphFileName, periode, molecules);
     1635            configuration.Load(*ConfigFileName, BondGraphFileName, periode, molecules);
    16271636            configPresent = present;
    16281637            break;
    16291638          case 0:
    16301639            DoLog(0) && (Log() << Verbose(0) << "old syntax." << endl);
    1631             configuration.LoadOld(ConfigFileName, BondGraphFileName, periode, molecules);
     1640            configuration.LoadOld(*ConfigFileName, BondGraphFileName, periode, molecules);
    16321641            configPresent = present;
    16331642            break;
     
    16501659       mol = World::getInstance().createMolecule();
    16511660       mol->ActiveFlag = true;
    1652        if (ConfigFileName != NULL)
    1653          mol->SetNameFromFilename(ConfigFileName);
     1661       if (*ConfigFileName != NULL)
     1662         mol->SetNameFromFilename(*ConfigFileName);
    16541663       molecules->insert(mol);
    16551664     }
     
    17051714                if (first->type != NULL) {
    17061715                  mol->AddAtom(first);  // add to molecule
    1707                   if ((configPresent == empty) && (mol->AtomCount != 0))
     1716                  if ((configPresent == empty) && (mol->getAtomCount() != 0))
    17081717                    configPresent = present;
    17091718                } else
     
    17181727        if (configPresent == present) {
    17191728          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;
    17311729            case 'D':
    17321730              if (ExitFlag == 0) ExitFlag = 1;
     
    17341732                DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
    17351733                MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    1736                 int *MinimumRingSize = new int[mol->AtomCount];
     1734                int *MinimumRingSize = new int[mol->getAtomCount()];
    17371735                atom ***ListOfLocalAtoms = NULL;
    17381736                class StackClass<bond *> *BackEdgeStack = NULL;
     
    17541752                  delete(Subgraphs);
    17551753                  for (int i=0;i<FragmentCounter;i++)
    1756                     Free(&ListOfLocalAtoms[i]);
    1757                   Free(&ListOfLocalAtoms);
     1754                    delete[](ListOfLocalAtoms[i]);
     1755                  delete[](ListOfLocalAtoms);
    17581756                }
    17591757                delete(BackEdgeStack);
     
    17951793                        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] == '-')) {
    17961794                          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);
    17981796                          performCriticalExit();
    17991797                        } else {
     
    18101808                          else
    18111809                            correlationmap = PairCorrelation(molecules, elemental, elemental2);
    1812                           //OutputCorrelationToSurface(&output, correlationmap);
     1810                          OutputPairCorrelation(&output, correlationmap);
    18131811                          BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
    18141812                          OutputCorrelation ( &binoutput, binmap );
     
    18261824                        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] == '-')) {
    18271825                          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);
    18291827                          performCriticalExit();
    18301828                        } else {
     
    18411839                          else
    18421840                            correlationmap = CorrelationToPoint(molecules, elemental, Point);
    1843                           //OutputCorrelationToSurface(&output, correlationmap);
     1841                          OutputCorrelationToPoint(&output, correlationmap);
    18441842                          BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
    18451843                          OutputCorrelation ( &binoutput, binmap );
     
    18821880                          int counter  = 0;
    18831881                          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())) {
    18851883                              Boundary = *BigFinder;
    18861884                            }
    18871885                            counter++;
    18881886                          }
    1889                           bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives");
     1887                          bool *Actives = new bool[counter];
    18901888                          counter = 0;
    18911889                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
     
    19131911                          output.close();
    19141912                          binoutput.close();
     1913                          counter = 0;
    19151914                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++)
    19161915                            (*BigFinder)->ActiveFlag = Actives[counter++];
    1917                           Free(&Actives);
     1916                          delete[](Actives);
    19181917                          delete(LCList);
    19191918                          delete(TesselStruct);
     
    19411940                performCriticalExit();
    19421941              } else {
     1942                mol->getAtomCount();
    19431943                SaveFlag = true;
    19441944                DoLog(1) && (Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl);
     
    19501950            case 'F':
    19511951              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;
    20001967              break;
    20011968            case 'A':
     
    20071974              } else {
    20081975                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();
    20121979                argptr+=1;
    20131980              }
     
    20592026                int counter  = 0;
    20602027                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())) {
    20632029                    Boundary = *BigFinder;
    20642030                  }
    20652031                  counter++;
    20662032                }
    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);
    20682034                start = clock();
    20692035                LCList = new LinkedCell(Boundary, atof(argv[argptr])*2.);
     
    21002066              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    21012067                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);
    21032069                performCriticalExit();
    21042070              } else {
     
    21322098            case 'R':
    21332099              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])))  {
    21352101                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);
    21372103                performCriticalExit();
    21382104              } else {
    21392105                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);
    21512118                  }
    2152                 } else {
    2153                   DoeLog(1) && (eLog()<< Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl);
    21542119                }
    2155                 argptr+=2;
     2120                argptr+=4;
    21562121              }
    21572122              break;
     
    21902155            case 's':
    21912156              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])) ) {
    21932158                ExitFlag = 255;
    21942159                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl);
    21952160                performCriticalExit();
    21962161              } 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);
    22122166                argptr+=3;
    22132167              }
     
    22202174                performCriticalExit();
    22212175              } 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);
    22312183                argptr+=6;
    22322184              }
     
    22392191                performCriticalExit();
    22402192              } 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);
    22502200                argptr+=6;
    22512201              }
     
    22582208                performCriticalExit();
    22592209              } 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);
    22762214                argptr+=3;
    22772215              }
     
    22792217            case 'O':
    22802218              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);
    22862220              argptr+=0;
    22872221              break;
     
    22932227                performCriticalExit();
    22942228              } else {
     2229                mol->getAtomCount();
    22952230                SaveFlag = true;
    22962231                DoLog(1) && (Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl);
     
    23122247                mol->CreateAdjacencyList(atof(argv[argptr]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    23132248                DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
    2314                 if (mol->first->next != mol->last) {
     2249                if (mol->hasBondStructure()) {
    23152250                  ExitFlag = mol->FragmentMolecule(atoi(argv[argptr+1]), &configuration);
    23162251                }
     
    24012336                performCriticalExit();
    24022337              } 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;
    24522343              }
    24532344              break;
     
    24612352    } while (argptr < argc);
    24622353    if (SaveFlag)
    2463       configuration.SaveAll(ConfigFileName, periode, molecules);
     2354      configuration.SaveAll(*ConfigFileName, periode, molecules);
    24642355  } else {  // no arguments, hence scan the elements db
    24652356    if (periode->LoadPeriodentafel(configuration.databasepath))
     
    24762367void cleanUp(){
    24772368  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();
    24832369  logger::purgeInstance();
    24842370  errorLogger::purgeInstance();
     
    24882374  ActionRegistry::purgeInstance();
    24892375  ActionHistory::purgeInstance();
     2376  Memory::getState();
    24902377}
    24912378
     
    24932380{
    24942381    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;
    24952385    Vector x, y, z, n;
    24962386    ifstream test;
     
    24992389    char **Arguments = NULL;
    25002390    int ArgcSize = 0;
     2391    int ExitFlag = 0;
    25012392    bool ArgumentsCopied = false;
    2502 
     2393    char *ConfigFileName = new char[MAXSTRINGSIZE];
     2394
     2395    // print version check whether arguments are present at all
    25032396    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
    25042404
    25052405    setVerbosity(0);
    25062406    // need to init the history before any action is created
    25072407    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);
    25082415
    25092416    // Parse command line options and if present create respective UI
     
    25122419      ArgcList.insert(0); // push back program!
    25132420      ArgcList.insert(1); // push back config file name
    2514       char ConfigFileName[MAXSTRINGSIZE];
    25152421      // 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);
    25172423      // copy all remaining arguments to a new argv
    2518       Arguments = Malloc<char *>(ArgcList.size(), "main - **Arguments");
     2424      Arguments = new char *[ArgcList.size()];
    25192425      cout << "The following arguments are handled by CommandLineParser: ";
    25202426      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];
    25222428        strcpy(Arguments[ArgcSize], argv[*ArgcRunner]);
    25232429        cout << " " << argv[*ArgcRunner];
     
    25442450    }
    25452451
    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());
    25512454
    25522455  // free the new argv
    25532456  if (ArgumentsCopied) {
    25542457    for (int i=0; i<ArgcSize;i++)
    2555       Free(&Arguments[i]);
    2556     Free(&Arguments);
     2458      delete[](Arguments[i]);
     2459    delete[](Arguments);
    25572460  }
    2558 
    2559   cleanUp();
    2560   Memory::getState();
    2561   return (0);
     2461  delete[](ConfigFileName);
     2462
     2463  return (ExitFlag == 1 ? 0 : ExitFlag);
    25622464}
    25632465
  • src/config.cpp

    re58856b rf2a1d3  
    1414#include "element.hpp"
    1515#include "helpers.hpp"
     16#include "info.hpp"
    1617#include "lists.hpp"
    1718#include "log.hpp"
     
    9394    return;
    9495  } else
    95     buffer = Malloc<char*>(NoLines, "ConfigFileBuffer::ConfigFileBuffer: **buffer");
     96    buffer = new char *[NoLines];
    9697
    9798  // scan each line and put into buffer
     
    99100  int i;
    100101  do {
    101     buffer[lines] = Malloc<char>(MAXSTRINGSIZE, "ConfigFileBuffer::ConfigFileBuffer: *buffer[]");
     102    buffer[lines] = new char[MAXSTRINGSIZE];
    102103    file->getline(buffer[lines], MAXSTRINGSIZE-1);
    103104    i = strlen(buffer[lines]);
     
    119120{
    120121  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);
    124125}
    125126
     
    129130void ConfigFileBuffer::InitMapping()
    130131{
    131   LineMapping = Malloc<int>(NoLines, "ConfigFileBuffer::InitMapping: *LineMapping");
     132  LineMapping = new int[NoLines];
    132133  for (int i=0;i<NoLines;i++)
    133134    LineMapping[i] = i;
     
    179180    MaxLevel(5), RiemannTensor(0), LevRFactor(0), RiemannLevel(0), Lev0Factor(2), RTActualUse(0), AddPsis(0), RCut(20.), StructOpt(0), IsAngstroem(1), RelativeCoord(0),
    180181    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];
    187188  strcpy(mainname,"pcp");
    188189  strcpy(defaultpath,"not specified");
     
    199200config::~config()
    200201{
    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);
    208209  for (int j=0;j<MaxThermostats;j++)
    209     Free(&ThermostatNames[j]);
    210   Free(&ThermostatNames);
     210    delete[](ThermostatNames[j]);
     211  delete[](ThermostatNames);
    211212
    212213  if (BG != NULL)
     
    218219void config::InitThermostats()
    219220{
    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];
    222223  for (int j=0;j<MaxThermostats;j++)
    223     ThermostatNames[j] = Malloc<char>(12, "config constructor: ThermostatNames[]");
     224    ThermostatNames[j] = new char[12];
    224225
    225226  strcpy(ThermostatNames[0],"None");
     
    242243void config::ParseThermostats(class ConfigFileBuffer * const fb)
    243244{
    244   char * const thermo = Malloc<char>(12, "IonsInitRead: thermo");
     245  char * const thermo = new char[12];
    245246  const int verbose = 0;
    246247
     
    309310    Thermostat = None;
    310311  }
    311   Free(thermo);
     312  delete[](thermo);
    312313};
    313314
     
    15471548  int AtomNo = -1;
    15481549  int MolNo = 0;
    1549   atom *Walker = NULL;
    15501550  FILE *f = NULL;
    15511551
     
    15601560  fprintf(f, "# Created by MoleCuilder\n");
    15611561
    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;
    15651566    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
    15701570      fprintf(f,
    15711571             "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 */
    15731573             name,         /* atom name */
    1574              (*Runner)->name,      /* residue name */
     1574             (*MolRunner)->name,      /* residue name */
    15751575             'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
    15761576             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 */
    15821582             "0",            /* segment identifier */
    1583              Walker->type->symbol,    /* element symbol */
     1583             (*iter)->type->symbol,    /* element symbol */
    15841584             "0");           /* charge */
    15851585      AtomNo++;
    15861586    }
    1587     Free(&elementNo);
     1587    delete[](elementNo);
    15881588    MolNo++;
    15891589  }
     
    16011601{
    16021602  int AtomNo = -1;
    1603   atom *Walker = NULL;
    16041603  FILE *f = NULL;
    16051604
    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;
    16071608  char name[MAXSTRINGSIZE];
    16081609  strncpy(name, filename, MAXSTRINGSIZE-1);
     
    16111612  if (f == NULL) {
    16121613    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl);
    1613     Free(&elementNo);
     1614    delete[](elementNo);
    16141615    return false;
    16151616  }
    16161617  fprintf(f, "# Created by MoleCuilder\n");
    16171618
    1618   Walker = mol->start;
    16191619  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
    16241623    fprintf(f,
    16251624           "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 */
    16271626           name,         /* atom name */
    16281627           mol->name,      /* residue name */
    16291628           'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
    16301629           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 */
    16361635           "0",            /* segment identifier */
    1637            Walker->type->symbol,    /* element symbol */
     1636           (*iter)->type->symbol,    /* element symbol */
    16381637           "0");           /* charge */
    16391638    AtomNo++;
    16401639  }
    16411640  fclose(f);
    1642   Free(&elementNo);
     1641  delete[](elementNo);
    16431642
    16441643  return true;
     
    16531652bool config::SaveTREMOLO(const char * const filename, const molecule * const mol) const
    16541653{
    1655   atom *Walker = NULL;
    16561654  ofstream *output = NULL;
    16571655  stringstream * const fname = new stringstream;
     
    16661664
    16671665  // scan maximum number of neighbours
    1668   Walker = mol->start;
    16691666  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();
    16731669    if (MaxNeighbours < count)
    16741670      MaxNeighbours = count;
    16751671  }
    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";
    16831677    *output << mol->name << "\t";
    16841678    *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++)
    16911685      *output << "-\t";
    16921686    *output << endl;
     
    17081702bool config::SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const
    17091703{
    1710   atom *Walker = NULL;
     1704  Info FunctionInfo(__func__);
    17111705  ofstream *output = NULL;
    17121706  stringstream * const fname = new stringstream;
     
    17231717  int MaxNeighbours = 0;
    17241718  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();
    17291721      if (MaxNeighbours < count)
    17301722        MaxNeighbours = count;
    17311723    }
    17321724  }
    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;
    17341726
    17351727  // create global to local id map
    1736   int **LocalNotoGlobalNoMap = Calloc<int *>(MolList->ListOfMolecules.size(), "config::SaveTREMOLO - **LocalNotoGlobalNoMap");
     1728  map<int, int> LocalNotoGlobalNoMap;
    17371729  {
    1738     int MolCounter = 0;
    1739     int AtomNo = 0;
     1730    unsigned int MolCounter = 0;
     1731    int AtomNo = 1;
    17401732    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      }
    17451736      MolCounter++;
    17461737    }
     1738    ASSERT(MolCounter == MolList->ListOfMolecules.size(), "SaveTREMOLO: LocalNotoGlobalNoMap[] has not been correctly initialized for each molecule");
    17471739  }
    17481740
     
    17521744    int AtomNo = 0;
    17531745    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";
    17591749        *output << (*MolWalker)->name << "\t";
    17601750        *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++)
    17671757          *output << "-\t";
    17681758        *output << endl;
     
    17781768  delete(output);
    17791769  delete(fname);
    1780   for(size_t i=0;i<MolList->ListOfMolecules.size(); i++)
    1781     Free(&LocalNotoGlobalNoMap[i]);
    1782   Free(&LocalNotoGlobalNoMap);
    17831770
    17841771  return true;
     
    18081795  if (output == NULL)
    18091796    strcpy(filename,"main_pcp_linux");
    1810   Log() << Verbose(0) << "Saving as pdb input ";
     1797  Log() << Verbose(0) << "Saving as pdb input ... " << endl;
    18111798  if (SavePDB(filename, molecules))
    1812     Log() << Verbose(0) << "done." << endl;
     1799    Log() << Verbose(0) << "\t... done." << endl;
    18131800  else
    1814     Log() << Verbose(0) << "failed." << endl;
     1801    Log() << Verbose(0) << "\t... failed." << endl;
    18151802
    18161803  // then save as tremolo data file
     
    18191806  if (output == NULL)
    18201807    strcpy(filename,"main_pcp_linux");
    1821   Log() << Verbose(0) << "Saving as tremolo data input ";
     1808  Log() << Verbose(0) << "Saving as tremolo data input ... " << endl;
    18221809  if (SaveTREMOLO(filename, molecules))
    1823     Log() << Verbose(0) << "done." << endl;
     1810    Log() << Verbose(0) << "\t... done." << endl;
    18241811  else
    1825     Log() << Verbose(0) << "failed." << endl;
     1812    Log() << Verbose(0) << "\t... failed." << endl;
    18261813
    18271814  // translate each to its center and merge all molecules in MoleculeListClass into this molecule
     
    18591846  output.close();
    18601847  output.clear();
    1861   Log() << Verbose(0) << "Saving of config file ";
     1848  Log() << Verbose(0) << "Saving of config file ... " << endl;
    18621849  if (Save(filename, periode, mol))
    1863     Log() << Verbose(0) << "successful." << endl;
     1850    Log() << Verbose(0) << "\t... successful." << endl;
    18641851  else
    1865     Log() << Verbose(0) << "failed." << endl;
     1852    Log() << Verbose(0) << "\t... failed." << endl;
    18661853
    18671854  // and save to xyz file
     
    18761863    output.open(filename, ios::trunc);
    18771864  }
    1878   Log() << Verbose(0) << "Saving of XYZ file ";
     1865  Log() << Verbose(0) << "Saving of XYZ file ... " << endl;
    18791866  if (mol->MDSteps <= 1) {
    18801867    if (mol->OutputXYZ(&output))
    1881       Log() << Verbose(0) << "successful." << endl;
     1868      Log() << Verbose(0) << "\t... successful." << endl;
    18821869    else
    1883       Log() << Verbose(0) << "failed." << endl;
     1870      Log() << Verbose(0) << "\t... failed." << endl;
    18841871  } else {
    18851872    if (mol->OutputTrajectoriesXYZ(&output))
    1886       Log() << Verbose(0) << "successful." << endl;
     1873      Log() << Verbose(0) << "\t... successful." << endl;
    18871874    else
    1888       Log() << Verbose(0) << "failed." << endl;
     1875      Log() << Verbose(0) << "\t... failed." << endl;
    18891876  }
    18901877  output.close();
     
    18961883  if (output == NULL)
    18971884    strcpy(filename,"main_pcp_linux");
    1898   Log() << Verbose(0) << "Saving as mpqc input ";
     1885  Log() << Verbose(0) << "Saving as mpqc input .. " << endl;
    18991886  if (SaveMPQC(filename, mol))
    1900     Log() << Verbose(0) << "done." << endl;
     1887    Log() << Verbose(0) << "\t... done." << endl;
    19011888  else
    1902     Log() << Verbose(0) << "failed." << endl;
     1889    Log() << Verbose(0) << "\t... failed." << endl;
    19031890
    19041891  if (!strcmp(configpath, GetDefaultPath())) {
     
    19381925  char *dummy1 = NULL;
    19391926  char *dummy = NULL;
    1940   char * const free_dummy = Malloc<char>(256, "config::ParseForParameter: *free_dummy");    // pointers in the line that is read in per step
     1927  char free_dummy[MAXSTRINGSIZE];    // pointers in the line that is read in per step
    19411928  dummy1 = free_dummy;
    19421929
     
    19541941      if (file->eof()) {
    19551942        if ((critical) && (found == 0)) {
    1956           Free(free_dummy);
    19571943          //Error(InitReading, name);
    19581944          fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
     
    19621948          file->clear();
    19631949          file->seekg(file_position, ios::beg);  // rewind to start position
    1964           Free(free_dummy);
    19651950          return 0;
    19661951        }
     
    19931978        dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword)
    19941979        //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name);
    1995         //Free((void **)&free_dummy);
    19961980        //Error(FileOpenParams, NULL);
    19971981      } else {
     
    20141998              if (file->eof()) {
    20151999                if ((critical) && (found == 0)) {
    2016                   Free(free_dummy);
    20172000                  //Error(InitReading, name);
    20182001                  fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
     
    20222005                  file->clear();
    20232006                  file->seekg(file_position, ios::beg);  // rewind to start position
    2024                   Free(free_dummy);
    20252007                  return 0;
    20262008                }
     
    20632045                  if (critical) {
    20642046                    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);
    20662047                    //return 0;
    20672048                    exit(255);
     
    20712052                    file->clear();
    20722053                    file->seekg(file_position, ios::beg);  // rewind to start position
    2073                     Free(free_dummy);
    20742054                    return 0;
    20752055                  }
     
    20842064                  file->seekg(file_position, ios::beg);  // rewind to start position
    20852065                }
    2086                 Free(free_dummy);
    20872066                return 0;
    20882067              }
     
    21402119  if ((type >= row_int) && (verbose))
    21412120    fprintf(stderr,"\n");
    2142   Free(free_dummy);
    21432121  if (!sequential) {
    21442122    file->clear();
     
    22212199        dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword)
    22222200        //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name);
    2223         //Free(&free_dummy);
    22242201        //Error(FileOpenParams, NULL);
    22252202      } else {
  • src/elements.db

    • Property mode changed from 100755 to 100644
    re58856b rf2a1d3  
    22#Element        Name    Symbol  Period  Group   Block   Atomic  Number  AtomicWeight    Covalent        Radius  vdW     Radius
    33Hydrogen        H       1       1       s       1       1.008   0.23    1.09
    4 Helium  He      1       18      p       2       4.003   1.50    1.40
     4Helium  He      1       18      p       2       4.003   1.5     1.4
    55Lithium Li      2       1       s       3       6.941   0.68    1.82
    6 Beryllium       Be      2       2       s       4       9.012   0.35    2.00
    7 Boron   B       2       13      p       5       10.811  0.83    2.00
    8 Carbon  C       2       14      p       6       12.011  0.68    1.70
     6Beryllium       Be      2       2       s       4       9.012   0.35    2
     7Boron   B       2       13      p       5       10.811  0.83    2
     8Carbon  C       2       14      p       6       12.011  0.68    1.7
    99Nitrogen        N       2       15      p       7       14.007  0.68    1.55
    1010Oxygen  O       2       16      p       8       15.999  0.68    1.52
    1111Fluorine        F       2       17      p       9       18.998  0.64    1.47
    12 Neon    Ne      2       18      p       10      20.180  1.50    1.54
     12Neon    Ne      2       18      p       10      20.18   1.5     1.54
    1313Sodium  Na      3       1       s       11      22.991  0.97    2.27
    14 Magnesium       Mg      3       2       s       12      24.305  1.10    1.73
    15 Aluminium       Al      3       13      p       13      26.982  1.35    2.00
    16 Silicon Si      3       14      p       14      28.086  1.20    2.10
    17 Phosphorus      P       3       15      p       15      30.974  1.05    1.80
    18 Sulphur S       3       16      p       16      32.066  1.02    1.80
     14Magnesium       Mg      3       2       s       12      24.305  1.1     1.73
     15Aluminium       Al      3       13      p       13      26.982  1.35    2
     16Silicon Si      3       14      p       14      28.086  1.2     2.1
     17Phosphorus      P       3       15      p       15      30.974  1.05    1.8
     18Sulphur S       3       16      p       16      32.066  1.02    1.8
    1919Chlorine        Cl      3       17      p       17      35.453  0.99    1.75
    2020Argon   Ar      3       18      p       18      39.948  1.51    1.88
    2121Potassium       K       4       1       s       19      39.098  1.33    2.75
    22 Calcium Ca      4       2       s       20      40.078  0.99    2.00
    23 Scandium        Sc      4       3       d       21      44.956  1.44    2.00
    24 Titanium        Ti      4       4       d       22      47.867  1.47    2.00
    25 Vanadium        V       4       5       d       23      50.942  1.33    2.00
    26 Chromium        Cr      4       6       d       24      51.996  1.35    2.00
    27 Manganese       Mn      4       7       d       25      54.938  1.35    2.00
    28 Iron    Fe      4       8       d       26      55.845  1.34    2.00
    29 Cobalt  Co      4       9       d       27      58.933  1.33    2.00
    30 Nickel  Ni      4       10      d       28      58.693  1.50    1.63
    31 Copper  Cu      4       11      d       29      63.546  1.52    1.40
    32 Zinc    Zn      4       12      d       30      65.390  1.45    1.39
     22Calcium Ca      4       2       s       20      40.078  0.99    2
     23Scandium        Sc      4       3       d       21      44.956  1.44    2
     24Titanium        Ti      4       4       d       22      47.867  1.47    2
     25Vanadium        V       4       5       d       23      50.942  1.33    2
     26Chromium        Cr      4       6       d       24      51.996  1.35    2
     27Manganese       Mn      4       7       d       25      54.938  1.35    2
     28Iron    Fe      4       8       d       26      55.845  1.34    2
     29Cobalt  Co      4       9       d       27      58.933  1.33    2
     30Nickel  Ni      4       10      d       28      58.693  1.5     1.63
     31Copper  Cu      4       11      d       29      63.546  1.52    1.4
     32Zinc    Zn      4       12      d       30      65.39   1.45    1.39
    3333Gallium Ga      4       13      p       31      69.723  1.22    1.87
    34 Germanium       Ge      4       14      p       32      72.610  1.17    2.00
     34Germanium       Ge      4       14      p       32      72.61   1.17    2
    3535Arsenic As      4       15      p       33      74.922  1.21    1.85
    36 Selenium        Se      4       16      p       34      78.960  1.22    1.90
     36Selenium        Se      4       16      p       34      78.96   1.22    1.9
    3737Bromine Br      4       17      p       35      79.904  1.21    1.85
    38 Krypton Kr      4       18      p       36      83.800  1.50    2.02
    39 Rubidium        Rb      5       1       s       37      85.468  1.47    2.00
    40 Strontium       Sr      5       2       s       38      87.620  1.12    2.00
    41 Yttrium Y       5       3       d       39      88.906  1.78    2.00
    42 Zirconium       Zr      5       4       d       40      91.224  1.56    2.00
    43 Niobium Nb      5       5       d       41      92.906  1.48    2.00
    44 Molybdenum      Mo      5       6       d       42      95.940  1.47    2.00
    45 Technetium      Tc      5       7       d       43      98      1.35    2.00
    46 Ruthenium       Ru      5       8       d       44      101.070 1.40    2.00
    47 Rhodium Rh      5       9       d       45      102.906 1.45    2.00
    48 Palladium       Pd      5       10      d       46      106.420 1.50    1.63
     38Krypton Kr      4       18      p       36      83.8    1.5     2.02
     39Rubidium        Rb      5       1       s       37      85.468  1.47    2
     40Strontium       Sr      5       2       s       38      87.62   1.12    2
     41Yttrium Y       5       3       d       39      88.906  1.78    2
     42Zirconium       Zr      5       4       d       40      91.224  1.56    2
     43Niobium Nb      5       5       d       41      92.906  1.48    2
     44Molybdenum      Mo      5       6       d       42      95.94   1.47    2
     45Technetium      Tc      5       7       d       43      98      1.35    2
     46Ruthenium       Ru      5       8       d       44      101.07  1.4     2
     47Rhodium Rh      5       9       d       45      102.906 1.45    2
     48Palladium       Pd      5       10      d       46      106.42  1.5     1.63
    4949Silver  Ag      5       11      d       47      107.868 1.59    1.72
    5050Cadmium Cd      5       12      d       48      112.411 1.69    1.58
    5151Indium  In      5       13      p       49      114.818 1.63    1.93
    5252Tin     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
     53Antimony        Sb      5       15      p       51      121.76  1.46    2
     54Tellurium       Te      5       16      p       52      127.6   1.47    2.06
     55Iodine  I       5       17      p       53      126.904 1.4     1.98
     56Xenon   Xe      5       18      p       54      131.29  1.5     2.16
     57Caesium Cs      6       1       s       55      132.905 1.67    2
     58Barium  Ba      6       2       s       56      137.327 1.34    2
     59Lanthanum       La      6Lan    19      f       57      138.906 1.87    2
     60Cerium  Ce      6Lan    19      f       58      140.116 1.83    2
     61Praseodymium    Pr      6Lan    19      f       59      140.908 1.82    2
     62Neodymium       Nd      6Lan    19      f       60      144.24  1.81    2
     63Promethium      Pm      6Lan    19      f       61      145     1.8     2
     64Samarium        Sm      6Lan    19      f       62      150.36  1.8     2
     65Europium        Eu      6Lan    19      f       63      151.964 1.99    2
     66Gadolinium      Gd      6Lan    19      f       64      157.25  1.79    2
     67Terbium Tb      6Lan    19      f       65      158.925 1.76    2
     68Dysprosium      Dy      6Lan    19      f       66      162.5   1.75    2
     69Holmium Ho      6Lan    19      f       67      164.93  1.74    2
     70Erbium  Er      6Lan    19      f       68      167.26  1.73    2
     71Thulium Tm      6Lan    19      f       69      168.934 1.72    2
     72Ytterbium       Yb      6Lan    19      f       70      173.04  1.94    2
     73Lutetium        Lu      6       3       d       71      174.967 1.72    2
     74Hafnium Hf      6       4       d       72      178.49  1.57    2
     75Tantalum        Ta      6       5       d       73      180.948 1.43    2
     76Tungsten        W       6       6       d       74      183.84  1.37    2
     77Rhenium Re      6       7       d       75      186.207 1.35    2
     78Osmium  Os      6       8       d       76      190.23  1.37    2
     79Iridium Ir      6       9       d       77      192.217 1.32    2
     80Platinum        Pt      6       10      d       78      195.078 1.5     1.72
     81Gold    Au      6       11      d       79      196.967 1.5     1.66
     82Mercury Hg      6       12      d       80      200.59  1.7     1.55
    6983Thallium        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
     84Lead    Pb      6       14      p       82      207.2   1.54    2.02
     85Bismuth Bi      6       15      p       83      208.98  1.54    2
     86Polonium        Po      6       16      p       84      210     1.68    2
     87Astatine        At      6       17      p       85      210     1.21    2
     88Radon   Rn      6       18      p       86      222     1.5     2
     89Francium        Fr      7       1       s       87      223     1.5     2
     90Radium  Ra      7       2       s       88      226     1.9     2
     91Actinium        Ac      7Act    20      f       89      227     1.88    2
     92Thorium Th      7Act    20      f       90      232.038 1.79    2
     93Protactinium    Pa      7Act    20      f       91      231.036 1.61    2
    11294Uranium U       7Act    20      f       92      238.029 1.58    1.86
     95Neptunium       Np      7Act    20      f       93      237     1.55    2
     96Plutonium       Pu      7Act    20      f       94      244     1.53    2
     97Americium       Am      7Act    20      f       95      243     1.51    2
     98Curium  Cm      7Act    20      f       96      247     0.99    2
     99Berkelium       Bk      7Act    20      f       97      247     1.54    2
     100Californium     Cf      7Act    20      f       98      251     1.83    2
     101Einsteinium     Es      7Act    20      f       99      252     1.5     2
     102Fermium Fm      7Act    20      f       100     257     1.5     2
     103Mendelevium     Md      7Act    20      f       101     258     1.5     2
     104Nobelium        No      7Act    20      f       102     259     1.5     2
     105Lawrencium      Lr      7       3       d       103     262     1.5     2
     106Rutherfordium   Rf      7       4       d       104     261     1.5     2
     107Dubnium Db      7       5       d       105     262     1.5     2
     108Seaborgium      Sg      7       6       d       106     266     1.5     2
     109Bohrium Bh      7       7       d       107     264     1.5     2
     110Hassium Hs      7       8       d       108     269     1.5     2
     111Meitnerium      Mt      7       9       d       109     268     1.5     2
     112Darmstadtium    Ds      7       10      d       110     271     1.5     2
  • src/helpers.cpp

    re58856b rf2a1d3  
    5858int CountLinesinFile(ifstream &InputFile)
    5959{
    60   char *buffer = Malloc<char>(MAXSTRINGSIZE, "CountLinesinFile: *buffer");
     60  char *buffer = new char[MAXSTRINGSIZE];
    6161  int lines=0;
    6262
     
    7070  }
    7171  InputFile.seekg(PositionMarker, ios::beg);
    72   Free(&buffer);
     72  delete[](buffer);
    7373  return lines;
    7474};
     
    9090  }
    9191  // allocate string
    92   returnstring = Malloc<char>(order + 2, "FixedDigitNumber: *returnstring");
     92  returnstring = new char[order + 2];
    9393  // terminate  and fill string array from end backward
    9494  returnstring[order] = '\0';
     
    122122double * ReturnFullMatrixforSymmetric(const double * const symm)
    123123{
    124   double *matrix = Malloc<double>(NDIM * NDIM, "molecule::ReturnFullMatrixforSymmetric: *matrix");
     124  double *matrix = new double[NDIM * NDIM];
    125125  matrix[0] = symm[0];
    126126  matrix[1] = symm[1];
     
    140140double * InverseMatrix( const double * const A)
    141141{
    142   double *B = Malloc<double>(NDIM * NDIM, "Vector::InverseMatrix: *B");
     142  double *B = new double[NDIM * NDIM];
    143143  double detA = RDET3(A);
    144144  double detAReci;
     
    180180
    181181
    182 /** Allocates a memory range using malloc().
    183  * Prints the provided error message in case of a failure.
    184  *
    185  * \param number of memory slices of type X to allocate
    186  * \param failure message which is printed if the allocation fails
    187  * \return pointer to the allocated memory range, will be NULL if a failure occurred
    188  */
    189 template <> char* Malloc<char>(size_t size, const char* output)
    190 {
    191   char* buffer = NULL;
    192   buffer = (char*) malloc(sizeof(char) * (size + 1));
    193   for (size_t i = size; i--;)
    194     buffer[i] = (i % 2 == 0) ? 'p': 'c';
    195   buffer[size] = '\0';
    196 
    197   if (buffer != NULL) {
    198     MemoryUsageObserver::getInstance()->addMemory(buffer, size);
    199   } else {
    200     Log() << Verbose(0) << "Malloc for datatype " << typeid(char).name()
    201       << " failed - pointer is NULL: " << output << endl;
    202   }
    203 
    204   return buffer;
    205 };
    206 
    207182/**
    208  * Frees all memory registered by the memory observer and calls exit(225) afterwards.
     183 * Calls exit(255).
    209184 */
    210185void 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 
    216186  exit(255);
    217187}
  • src/helpers.hpp

    re58856b rf2a1d3  
    9797
    9898  if (LookupTable != NULL) {
    99     DoLog(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);
    100100    return false;
    101101  }
     
    110110  }
    111111  if (count <= 0) {
    112     DoLog(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);
    113113    return false;
    114114  }
    115115
    116116  // allocate and fill
    117   LookupTable = Calloc<T*>(count, "CreateFatherLookupTable - **LookupTable");
     117  LookupTable = new T*[count];
    118118  if (LookupTable == NULL) {
    119119    DoeLog(0) && (eLog()<< Verbose(0) << "LookupTable memory allocation failed!" << endl);
     
    129129        LookupTable[AtomNo] = Walker;
    130130      } else {
    131         DoLog(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);
    132132        status = false;
    133133        break;
     
    138138  return status;
    139139};
     140
    140141
    141142/** Frees a two-dimensional array.
  • src/joiner.cpp

    re58856b rf2a1d3  
    5858    return 1;
    5959  } else {
    60     dir = Malloc<char>(strlen(argv[2]) + 2, "main: *dir");
     60    dir = new char[strlen(argv[2]) + 2];
    6161    strcpy(dir, "/");
    6262    strcat(dir, argv[2]);
     
    243243  // exit
    244244  delete(periode);
    245   Free(&dir);
     245  delete[](dir);
    246246  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    247247  return 0;
  • src/lists.hpp

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

    re58856b rf2a1d3  
    3535 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero.
    3636 */
    37 molecule::molecule(const periodentafel * const teil) : elemente(teil), start(World::getInstance().createAtom()), end(World::getInstance().createAtom()),
    38   first(new bond(start, end, 1, -1)), last(new bond(start, end, 1, -1)), MDSteps(0), AtomCount(0),
     37molecule::molecule(const periodentafel * const teil) : elemente(teil),
     38  MDSteps(0),
    3939  BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.),
    4040  ActiveFlag(false), IndexNr(-1),
    4141  formula(this,boost::bind(&molecule::calcFormula,this)),
    42   last_atom(0),
    43   InternalPointer(start)
    44 {
    45   // init atom chain list
    46   start->father = NULL;
    47   end->father = NULL;
    48   link(start,end);
    49 
    50   // init bond chain list
    51   link(first,last);
     42  AtomCount(this,boost::bind(&molecule::doCountAtoms,this)), last_atom(0),  InternalPointer(begin())
     43{
    5244
    5345  // other stuff
     
    6759{
    6860  CleanupMolecule();
    69   delete(first);
    70   delete(last);
    71   end->getWorld()->destroyAtom(end);
    72   start->getWorld()->destroyAtom(start);
    7361};
    7462
     
    8169const std::string molecule::getName(){
    8270  return std::string(name);
     71}
     72
     73int molecule::getAtomCount() const{
     74  return *AtomCount;
    8375}
    8476
     
    10496  stringstream sstr;
    10597  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()]++;
    108100  }
    109101  std::map<atomicNumber_t,unsigned int>::reverse_iterator iter;
     
    115107}
    116108
     109/************************** Access to the List of Atoms ****************/
     110
     111
     112molecule::iterator molecule::begin(){
     113  return molecule::iterator(atoms.begin(),this);
     114}
     115
     116molecule::const_iterator molecule::begin() const{
     117  return atoms.begin();
     118}
     119
     120molecule::iterator molecule::end(){
     121  return molecule::iterator(atoms.end(),this);
     122}
     123
     124molecule::const_iterator molecule::end() const{
     125  return atoms.end();
     126}
     127
     128bool molecule::empty() const
     129{
     130  return (begin() == end());
     131}
     132
     133size_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
     141molecule::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
     149molecule::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
     160molecule::const_iterator molecule::find ( atom *& key ) const
     161{
     162  return atoms.find( key );
     163}
     164
     165pair<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}
    117170
    118171/** Adds given atom \a *pointer from molecule list.
     
    123176bool molecule::AddAtom(atom *pointer)
    124177{
    125   bool retval = false;
    126178  OBSERVE;
    127179  if (pointer != NULL) {
    128180    pointer->sort = &pointer->nr;
    129     pointer->nr = last_atom++;  // increase number within molecule
    130     AtomCount++;
    131181    if (pointer->type != NULL) {
    132182      if (ElementsInMolecule[pointer->type->Z] == 0)
     
    135185      if (pointer->type->Z != 1)
    136186        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;
    146196};
    147197
     
    157207  if (pointer != NULL) {
    158208    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());
    161210    walker->nr = last_atom++;  // increase number within molecule
    162     add(walker, end);
     211    insert(walker);
    163212    if ((pointer->type != NULL) && (pointer->type->Z != 1))
    164213      NoNonHydrogen++;
    165     AtomCount++;
    166214    retval=walker;
    167215  }
     
    241289    Orthovector1.MatrixMultiplication(matrix);
    242290    InBondvector -= Orthovector1; // subtract just the additional translation
    243     Free(&matrix);
     291    delete[](matrix);
    244292    bondlength = InBondvector.Norm();
    245293//    Log() << Verbose(4) << "Corrected InBondvector is now: ";
     
    250298  InBondvector.Normalize();
    251299  // get typical bond length and store as scale factor for later
     300  ASSERT(TopOrigin->type != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");
    252301  BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1];
    253302  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);
    255304    return false;
    256305    BondRescale = bondlength;
     
    275324      InBondvector *= BondRescale;   // rescale the distance vector to Hydrogen bond length
    276325      FirstOtherAtom->x = TopOrigin->x; // set coordination to origin ...
    277       FirstOtherAtom->x = InBondvector;  // ... and add distance vector to replacement atom
     326      FirstOtherAtom->x += InBondvector;  // ... and add distance vector to replacement atom
    278327      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
    279328//      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
     
    295344            SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin);
    296345          } 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());
    298347          }
    299348        }
     
    339388      bondangle = TopOrigin->type->HBondAngle[1];
    340389      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);
    342391        return false;
    343392        bondangle = 0;
     
    471520      break;
    472521  }
    473   Free(&matrix);
     522  delete[](matrix);
    474523
    475524//  Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
     
    554603
    555604  // copy all bonds
    556   bond *Binder = first;
     605  bond *Binder = NULL;
    557606  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      }
    571622  // correct fathers
    572623  ActOnAllAtoms( &atom::CorrectFather );
    573624
    574625  // copy values
    575   copy->CountAtoms();
    576626  copy->CountElements();
    577   if (first->next != last) {  // if adjaceny list is present
     627  if (hasBondStructure()) {  // if adjaceny list is present
    578628    copy->BondDistance = BondDistance;
    579629  }
     
    608658{
    609659  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
    620673  return Binder;
    621674};
     
    629682{
    630683  //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);
    634685  return true;
    635686};
     
    691742bool molecule::RemoveAtom(atom *pointer)
    692743{
     744  ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom().");
     745  OBSERVE;
    693746  if (ElementsInMolecule[pointer->type->Z] != 0)  { // this would indicate an error
    694747    ElementsInMolecule[pointer->type->Z]--;  // decrease number of atom of this element
    695     AtomCount--;
    696748  } 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);
    698750  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    699751    ElementCount--;
    700752  RemoveBonds(pointer);
    701   return remove(pointer, start, end);
     753  erase(pointer);
     754  return true;
    702755};
    703756
     
    713766    ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element
    714767  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);
    716769  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    717770    ElementCount--;
    718   unlink(pointer);
     771  erase(pointer);
    719772  return true;
    720773};
     
    725778bool molecule::CleanupMolecule()
    726779{
    727   return (cleanup(first,last) && cleanup(start,end));
     780  for (molecule::iterator iter = begin(); !empty(); iter = begin())
     781      erase(iter);
    728782};
    729783
     
    732786 * \return pointer to atom or NULL
    733787 */
    734 atom * molecule::FindAtom(int Nr)  const{
    735   atom * walker = find(&Nr, start,end);
    736   if (walker != NULL) {
     788atom * 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()) {
    737795    //Log() << Verbose(0) << "Found Atom Nr. " << walker->nr << endl;
    738     return walker;
     796    return (*iter);
    739797  } else {
    740798    DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl);
     
    866924    now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
    867925    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);
    869927      ActOnAllAtoms( &atom::OutputTrajectoryXYZ, output, step );
    870928    }
     
    883941  if (output != NULL) {
    884942    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);
    886944    ActOnAllAtoms( &atom::OutputXYZLine, output );
    887945    return true;
     
    893951 * \param *out output stream for debugging
    894952 */
    895 void molecule::CountAtoms()
    896 {
     953int molecule::doCountAtoms()
     954{
     955  int res = size();
    897956  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);
    901966    i++;
    902967  }
    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;
    926969};
    927970
     
    9851028  /// first count both their atoms and elements and update lists thereby ...
    9861029  //Log() << Verbose(0) << "Counting atoms, updating list" << endl;
    987   CountAtoms();
    988   OtherMolecule->CountAtoms();
    9891030  CountElements();
    9901031  OtherMolecule->CountElements();
     
    9931034  /// -# AtomCount
    9941035  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);
    9971038      result = false;
    998     } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
     1039    } else Log() << Verbose(4) << "AtomCounts match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl;
    9991040  }
    10001041  /// -# ElementCount
     
    10331074  if (result) {
    10341075    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()];
    10371078    SetIndexedArrayForEachAtomTo ( Distances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity);
    10381079    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    }
    10391084
    10401085    /// ... sort each list (using heapsort (o(N log N)) from GSL)
    10411086    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;
    10471098    DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl);
    1048     for(int i=AtomCount;i--;)
     1099    for(int i=getAtomCount();i--;)
    10491100      PermutationMap[PermMap[i]] = (int) OtherPermMap[i];
    10501101
     
    10521103    DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl);
    10531104    flag = 0;
    1054     for (int i=0;i<AtomCount;i++) {
     1105    for (int i=0;i<getAtomCount();i++) {
    10551106      DoLog(5) && (Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " <<  threshold << endl);
    10561107      if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold)
     
    10591110
    10601111    // 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);
    10651116    if (flag) { // if not equal
    1066       Free(&PermutationMap);
     1117      delete[](PermutationMap);
    10671118      result = false;
    10681119    }
     
    10881139int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule)
    10891140{
    1090   atom *Walker = NULL, *OtherWalker = NULL;
    10911141  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--;)
    10941144    AtomicMap[i] = -1;
    10951145  if (OtherMolecule == this) {  // same molecule
    1096     for (int i=AtomCount;i--;) // no need as -1 means already that there is trivial correspondence
     1146    for (int i=getAtomCount();i--;) // no need as -1 means already that there is trivial correspondence
    10971147      AtomicMap[i] = i;
    10981148    DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl);
    10991149  } else {
    11001150    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;
    11061154      } 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) {
    11101156      //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;
    11151161        }
    11161162      }
    1117       DoLog(0) && (Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t");
     1163      DoLog(0) && (Log() << Verbose(0) << AtomicMap[(*iter)->nr] << "\t");
    11181164    }
    11191165    DoLog(0) && (Log() << Verbose(0) << endl);
     
    11491195void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) const
    11501196{
    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);
    11551199  }
    11561200};
  • src/molecule.hpp

    re58856b rf2a1d3  
    3434#include "tesselation.hpp"
    3535#include "Patterns/Observer.hpp"
     36#include "Patterns/ObservedIterator.hpp"
    3637#include "Patterns/Cacheable.hpp"
    3738
     
    9091  friend molecule *NewMolecule();
    9192  friend void DeleteMolecule(molecule *);
     93
    9294  public:
     95    typedef std::set<atom*> atomSet;
     96    typedef ObservedIterator<atomSet> iterator;
     97    typedef atomSet::const_iterator const_iterator;
     98
    9399    const periodentafel * const elemente; //!< periodic table with each element
    94     atom *start;        //!< start of atom list
    95     atom *end;          //!< end of atom list
    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
    98105    int MDSteps;        //!< The number of MD steps in Trajectories
    99     int AtomCount;          //!< number of atoms, brought up-to-date by CountAtoms()
     106    //int AtomCount;          //!< number of atoms, brought up-to-date by CountAtoms()
    100107    int BondCount;          //!< number of atoms, brought up-to-date by CountBonds()
    101108    int ElementCount;       //!< how many unique elements are therein
     
    112119  private:
    113120    Cacheable<string> formula;
     121    Cacheable<int>    AtomCount;
    114122    moleculeId_t id;
     123    atomSet atoms; //<!set of atoms
    115124  protected:
     125    //void CountAtoms();
     126    /**
     127     * this iterator type should be used for internal variables, \
     128     * since it will not lock
     129     */
     130    typedef atomSet::iterator internal_iterator;
     131
     132
    116133    molecule(const periodentafel * const teil);
    117134    virtual ~molecule();
     
    121138  //getter and setter
    122139  const std::string getName();
     140  int getAtomCount() const;
     141  int doCountAtoms();
    123142  moleculeId_t getId();
    124143  void setId(moleculeId_t);
     
    127146  std::string calcFormula();
    128147
     148  iterator begin();
     149  const_iterator begin() const;
     150  iterator end();
     151  const_iterator end() const;
     152  bool empty() const;
     153  size_t size() const;
     154  const_iterator erase( const_iterator loc );
     155  const_iterator erase( atom *& key );
     156  const_iterator find (  atom *& key ) const;
     157  pair<iterator,bool> insert ( atom * const key );
     158
    129159
    130160  // re-definition of virtual functions from PointCloud
     
    132162  Vector *GetCenter() const ;
    133163  TesselPoint *GetPoint() const ;
    134   TesselPoint *GetTerminalPoint() const ;
    135164  int GetMaxId() const;
    136165  void GoToNext() const ;
    137   void GoToPrevious() const ;
    138166  void GoToFirst() const ;
    139   void GoToLast() const ;
    140167  bool IsEmpty() const ;
    141168  bool IsEnd() const ;
     
    226253  bool RemoveBond(bond *pointer);
    227254  bool RemoveBonds(atom *BondPartner);
     255  bool hasBondStructure();
     256  unsigned int CountBonds() const;
    228257
    229258  /// Find atoms.
     
    232261
    233262  /// Count and change present atoms' coordination.
    234   void CountAtoms();
    235263  void CountElements();
    236264  void CalculateOrbitals(class config &configuration);
     
    249277  Vector * DetermineCenterOfGravity();
    250278  Vector * DetermineCenterOfAll() const;
     279  Vector * DetermineCenterOfBox() const;
    251280  void SetNameFromFilename(const char *filename);
    252281  void SetBoxDimension(Vector *dim);
     
    301330  bool StoreForcesFile(MoleculeListClass *BondFragments, char *path, int *SortIndex);
    302331  bool CreateMappingLabelsToConfigSequence(int *&SortIndex);
     332  bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
    303333  void BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem);
    304334  /// -# BOSSANOVA
     
    329359  private:
    330360  int last_atom;      //!< number given to last atom
    331   mutable atom *InternalPointer;  //!< internal pointer for PointCloud
     361  mutable internal_iterator InternalPointer;  //!< internal pointer for PointCloud
    332362};
    333363
     
    350380  bool StoreForcesFile(char *path, int *SortIndex);
    351381  void insert(molecule *mol);
     382  void erase(molecule *mol);
    352383  molecule * ReturnIndex(int index);
    353384  bool OutputConfigForListOfFragments(config *configuration, int *SortIndex);
  • src/molecule_dynamics.cpp

    re58856b rf2a1d3  
    1010#include "config.hpp"
    1111#include "element.hpp"
     12#include "info.hpp"
    1213#include "log.hpp"
    1314#include "memoryallocator.hpp"
     
    2829  gsl_matrix *A = gsl_matrix_alloc(NDIM,NDIM);
    2930  gsl_vector *x = gsl_vector_alloc(NDIM);
    30   atom * Runner = mol->start;
    3131  atom *Sprinter = NULL;
    3232  Vector trajectory1, trajectory2, normal, TestVector;
    3333  double Norm1, Norm2, tmp, result = 0.;
    3434
    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++)
    3837      break;
    3938    // determine normalized trajectories direction vector (n1, n2)
     
    4241    trajectory1.Normalize();
    4342    Norm1 = trajectory1.Norm();
    44     Sprinter = Params.PermutationMap[Runner->nr];   // find second target point
    45     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);
    4645    trajectory2.Normalize();
    4746    Norm2 = trajectory1.Norm();
    4847    // check whether either is zero()
    4948    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));
    5150    } else if (Norm1 < MYEPSILON) {
    5251      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);
    5453      trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything
    5554      trajectory1 -= trajectory2;   // project the part in norm direction away
    5655      tmp = trajectory1.Norm();  // remaining norm is distance
    5756    } else if (Norm2 < MYEPSILON) {
    58       Sprinter = Params.PermutationMap[Runner->nr];   // find second target point
     57      Sprinter = Params.PermutationMap[(*iter)->nr];   // find second target point
    5958      trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep);  // copy second offset
    6059      trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything
     
    6665  //        Log() << Verbose(0) << " and ";
    6766  //        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));
    6968  //        Log() << Verbose(0) << " with distance " << tmp << "." << endl;
    7069    } 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 ";
    7271  //        Log() << Verbose(0) << endl;
    7372  //        Log() << Verbose(0) << "First Trajectory: ";
     
    8584        gsl_matrix_set(A, 1, i, trajectory2[i]);
    8685        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]));
    8887      }
    8988      // solve the linear system by Householder transformations
     
    9695      trajectory2.Scale(gsl_vector_get(x,1));
    9796      normal.Scale(gsl_vector_get(x,2));
    98       TestVector = Runner->Trajectory.R.at(Params.startstep) + trajectory2 + normal
     97      TestVector = (*iter)->Trajectory.R.at(Params.startstep) + trajectory2 + normal
    9998                   - (Walker->Trajectory.R.at(Params.startstep) + trajectory1);
    10099      if (TestVector.Norm() < MYEPSILON) {
     
    125124{
    126125  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)) {
    131128  //    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 ";
    133130  //        Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep);
    134131  //        Log() << Verbose(0) << ", penalting." << endl;
     
    161158  // go through every atom
    162159  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) {
    166161    // first term: distance to target
    167     Runner = Params.PermutationMap[Walker->nr];   // find target point
    168     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)));
    169164    tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem;
    170165    result += Params.PenaltyConstants[0] * tmp;
     
    172167
    173168    // second term: sum of distances to other trajectories
    174     result += SumDistanceOfTrajectories(Walker, this, Params);
     169    result += SumDistanceOfTrajectories((*iter), this, Params);
    175170
    176171    // third term: penalty for equal targets
    177     result += PenalizeEqualTargets(Walker, this, Params);
     172    result += PenalizeEqualTargets((*iter), this, Params);
    178173  }
    179174
     
    189184{
    190185  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;
    192189  int doubles = 0;
    193190  zeile1 << "PermutationMap: ";
     
    203200  if (doubles >0)
    204201    DoLog(2) && (Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl);
    205   Free(&DoubleList);
     202  delete[](DoubleList);
    206203//  Log() << Verbose(2) << zeile1.str() << endl << zeile2.str() << endl;
    207204};
     
    213210void FillDistanceList(molecule *mol, struct EvaluatePotential &Params)
    214211{
    215   for (int i=mol->AtomCount; i--;) {
     212  for (int i=mol->getAtomCount(); i--;) {
    216213    Params.DistanceList[i] = new DistanceMap;    // is the distance sorted target list per atom
    217214    Params.DistanceList[i]->clear();
    218215  }
    219216
    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)) );
    228220    }
    229221  }
     
    237229void CreateInitialLists(molecule *mol, struct EvaluatePotential &Params)
    238230{
    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);
    247237  }
    248238};
     
    285275void MakeInjectivePermutation(molecule *mol, struct EvaluatePotential &Params)
    286276{
    287   atom *Walker = mol->start;
     277  molecule::const_iterator iter = mol->begin();
    288278  DistanceMap::iterator NewBase;
    289279  double Potential = fabs(mol->ConstrainedPotential(Params));
    290280
     281  if (mol->empty()) {
     282    eLog() << Verbose(1) << "Molecule is empty." << endl;
     283    return;
     284  }
    291285  while ((Potential) > Params.PenaltyConstants[2]) {
    292     PrintPermutationMap(mol->AtomCount, Params);
    293     Walker = Walker->next;
    294     if (Walker == mol->end) // round-robin at the end
    295       Walker = mol->start->next;
    296     if (Params.DoubleList[Params.DistanceIterators[Walker->nr]->second->nr] <= 1)  // no need to make those injective that aren't
     286    PrintPermutationMap(mol->getAtomCount(), Params);
     287    iter++;
     288    if (iter == mol->end()) // round-robin at the end
     289      iter = mol->begin();
     290    if (Params.DoubleList[Params.DistanceIterators[(*iter)->nr]->second->nr] <= 1)  // no need to make those injective that aren't
    297291      continue;
    298292    // 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 <=1
     293    Potential = TryNextNearestNeighbourForInjectivePermutation(mol, (*iter), Potential, Params);
     294  }
     295  for (int i=mol->getAtomCount(); i--;) // now each single entry in the DoubleList should be <=1
    302296    if (Params.DoubleList[i] > 1) {
    303297      DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl);
     
    338332  double Potential, OldPotential, OlderPotential;
    339333  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()];
    345339  int round;
    346   atom *Walker = NULL, *Runner = NULL, *Sprinter = NULL;
     340  atom *Sprinter = NULL;
    347341  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  }
    348348
    349349  /// Minimise the potential
     
    362362  DoLog(1) && (Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl);
    363363  MakeInjectivePermutation(this, Params);
    364   Free(&Params.DoubleList);
     364  delete[](Params.DoubleList);
    365365
    366366  // argument minimise the constrained potential in this injective PermutationMap
     
    371371    DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl);
    372372    OlderPotential = OldPotential;
     373    molecule::const_iterator iter;
    373374    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();
    383383          break;
    384384        }
    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;
    386386        // 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;
    391391            break;
    392392          }
    393           Runner = Runner->next;
    394393        }
    395         if (Runner != end) { // we found the other source
     394        if (runner != end()) { // we found the other source
    396395          // 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++)
    399398            if (Rider->second == Sprinter)
    400399              break;
    401           if (Rider != Params.DistanceList[Runner->nr]->end()) { // if we have found one
    402             //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;
    403402            // exchange both
    404             Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // put next farther distance into PermutationMap
    405             Params.PermutationMap[Runner->nr] = Sprinter;  // and hand the old target to its respective owner
    406             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);
    407406            // calculate the new potential
    408407            //Log() << Verbose(2) << "Checking new potential ..." << endl;
     
    410409            if (Potential > OldPotential) { // we made everything worse! Undo ...
    411410              //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;
    413412              // 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;
    415414              // Undo for Walker
    416               Params.DistanceIterators[Walker->nr] = Strider;  // take next farther distance target
    417               //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;
    419418            } else {
    420               Params.DistanceIterators[Runner->nr] = Rider;  // if successful also move the pointer in the iterator list
     419              Params.DistanceIterators[(*runner)->nr] = Rider;  // if successful also move the pointer in the iterator list
    421420              DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl);
    422421              OldPotential = Potential;
     
    428427            //Log() << Verbose(0) << endl;
    429428          } 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);
    431430            exit(255);
    432431          }
    433432        } 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!
    435434        }
    436         Params.StepList[Walker->nr]++; // take next farther distance target
     435        Params.StepList[(*iter)->nr]++; // take next farther distance target
    437436      }
    438     } while (Walker->next != end);
     437    } while (++iter != end());
    439438  } while ((OlderPotential - OldPotential) > 1e-3);
    440439  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     
    442441
    443442  /// free memory and return with evaluated potential
    444   for (int i=AtomCount; i--;)
     443  for (int i=getAtomCount(); i--;)
    445444    Params.DistanceList[i]->clear();
    446   Free(&Params.DistanceList);
    447   Free(&Params.DistanceIterators);
     445  delete[](Params.DistanceList);
     446  delete[](Params.DistanceIterators);
    448447  return ConstrainedPotential(Params);
    449448};
     
    483482  // Get the Permutation Map by MinimiseConstrainedPotential
    484483  atom **PermutationMap = NULL;
    485   atom *Walker = NULL, *Sprinter = NULL;
     484  atom *Sprinter = NULL;
    486485  if (!MapByIdentity)
    487486    MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem());
    488487  else {
    489     PermutationMap = Malloc<atom *>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap");
     488    PermutationMap = new atom *[getAtomCount()];
    490489    SetIndexedArrayForEachAtomTo( PermutationMap, &atom::nr );
    491490  }
     
    502501    mol = World::getInstance().createMolecule();
    503502    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) {
    507504      // add to molecule list
    508       Sprinter = mol->AddCopyAtom(Walker);
     505      Sprinter = mol->AddCopyAtom((*iter));
    509506      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);
    511508        // add to Trajectories
    512509        //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
    513510        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.;
    517514        }
    518515      }
     
    522519
    523520  // 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--; )
    526523    SortIndex[i] = i;
    527524  status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex);
     525  delete[](SortIndex);
    528526
    529527  // free and return
    530   Free(&PermutationMap);
     528  delete[](PermutationMap);
    531529  delete(MoleculePerStep);
    532530  return status;
     
    548546bool molecule::VerletForceIntegration(char *file, config &configuration)
    549547{
     548  Info FunctionInfo(__func__);
    550549  ifstream input(file);
    551550  string token;
     
    567566      return false;
    568567    }
    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);
    571570      performCriticalExit();
    572571      return false;
     
    574573    // correct Forces
    575574    Velocity.Zero();
    576     for(int i=0;i<AtomCount;i++)
     575    for(int i=0;i<getAtomCount();i++)
    577576      for(int d=0;d<NDIM;d++) {
    578577        Velocity[d] += Force.Matrix[0][i][d+5];
    579578      }
    580     for(int i=0;i<AtomCount;i++)
     579    for(int i=0;i<getAtomCount();i++)
    581580      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());
    583582      }
    584583    // solve a constrained potential if we are meant to
     
    588587      ConstrainedPotentialEnergy = MinimiseConstrainedPotential(PermutationMap,configuration.DoConstrainedMD, 0, configuration.GetIsAngstroem());
    589588      EvaluateConstrainedForces(configuration.DoConstrainedMD, 0, PermutationMap, &Force);
    590       Free(&PermutationMap);
     589      delete[](PermutationMap);
    591590    }
    592591
    593592    // and perform Verlet integration for each atom with position, velocity and force vector
    594593    // 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);
    598597  }
    599598  // correct velocities (rather momenta) so that center of mass remains motionless
    600599  Velocity.Zero();
    601600  IonMass = 0.;
    602   ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps, &IonMass, &Velocity );
     601  ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps+1, &IonMass, &Velocity );
    603602
    604603  // correct velocities (rather momenta) so that center of mass remains motionless
    605604  Velocity.Scale(1./IonMass);
    606605  ActualTemp = 0.;
    607   ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps, &Velocity );
     606  ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps+1, &Velocity );
    608607  Thermostats(configuration, ActualTemp, Berendsen);
    609608  MDSteps++;
     
    683682      delta_alpha = 0.;
    684683      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);
    686685      configuration.alpha += delta_alpha*configuration.Deltat;
    687686      DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl);
  • src/molecule_fragmentation.cpp

    re58856b rf2a1d3  
    3939  int FragmentCount;
    4040  // get maximum bond degree
    41   atom *Walker = start;
    42   while (Walker->next != end) {
    43     Walker = Walker->next;
    44     c = (Walker->ListOfBonds.size() > c) ? Walker->ListOfBonds.size() : c;
     41  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     42    c = ((*iter)->ListOfBonds.size() > c) ? (*iter)->ListOfBonds.size() : c;
    4543  }
    4644  FragmentCount = NoNonHydrogen*(1 << (c*order));
     
    9492  GraphTestPair testGraphInsert;
    9593  int NumberOfFragments = 0;
    96   char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - filename");
     94  char filename[MAXSTRINGSIZE];
    9795
    9896  if (FragmentList == NULL) { // check list pointer
     
    106104  if (InputFile != NULL) {
    107105    // each line represents a new fragment
    108     char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - *buffer");
     106    char buffer[MAXSTRINGSIZE];
    109107    // 1. parse keysets and insert into temp. graph
    110108    while (!InputFile.eof()) {
     
    122120    InputFile.close();
    123121    InputFile.clear();
    124     Free(&buffer);
    125     DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     122    DoLog(1) && (Log() << Verbose(1) << "\t ... done." << endl);
    126123  } else {
    127     DoLog(1) && (Log() << Verbose(1) << "File " << filename << " not found." << endl);
     124    DoLog(1) && (Log() << Verbose(1) << "\t ... File " << filename << " not found." << endl);
    128125    status = false;
    129126  }
    130127
    131   Free(&filename);
    132128  return status;
    133129};
     
    148144  int NumberOfFragments = 0;
    149145  double TEFactor;
    150   char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseTEFactorsFile - filename");
     146  char filename[MAXSTRINGSIZE];
    151147
    152148  if (FragmentList == NULL) { // check list pointer
     
    179175  }
    180176
    181   // free memory
    182   Free(&filename);
    183 
    184177  return status;
    185178};
     
    317310  int No = 0, FragOrder = 0;
    318311  double Value = 0.;
    319   char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::CheckOrderAtSite: *buffer");
     312  char buffer[MAXSTRINGSIZE];
    320313  sprintf(buffer, "%s/%s%s.dat", path, FRAGMENTPREFIX, ENERGYPERFRAGMENT);
    321314  ifstream InputFile(buffer, ios::in);
     
    345338    InputFile.clear();
    346339  }
    347   Free(&buffer);
    348340
    349341  return AdaptiveCriteriaList;
     
    359351map<double, pair<int,int> >  * ReMapAdaptiveCriteriaListToValue(map<int, pair<double,int> > *AdaptiveCriteriaList, molecule *mol)
    360352{
    361   atom *Walker = mol->start;
     353  atom *Walker = NULL;
    362354  map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ;
    363355  DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl);
     
    391383bool MarkUpdateCandidates(bool *AtomMask, map<double, pair<int,int> > &FinalRootCandidates, int Order, molecule *mol)
    392384{
    393   atom *Walker = mol->start;
     385  atom *Walker = NULL;
    394386  int No = -1;
    395387  bool status = false;
     
    435427bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path)
    436428{
    437   atom *Walker = start;
    438429  bool status = false;
    439430
    440431  // initialize mask list
    441   for(int i=AtomCount;i--;)
     432  for(int i=getAtomCount();i--;)
    442433    AtomMask[i] = false;
    443434
    444435  if (Order < 0) { // adaptive increase of BondOrder per site
    445     if (AtomMask[AtomCount] == true)  // break after one step
     436    if (AtomMask[getAtomCount()] == true)  // break after one step
    446437      return false;
    447438
     
    457448    if (AdaptiveCriteriaList->empty()) {
    458449      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) {
    461451    #ifdef ADDHYDROGEN
    462         if (Walker->type->Z != 1) // skip hydrogen
     452        if ((*iter)->type->Z != 1) // skip hydrogen
    463453    #endif
    464454        {
    465           AtomMask[Walker->nr] = true;  // include all (non-hydrogen) atoms
     455          AtomMask[(*iter)->nr] = true;  // include all (non-hydrogen) atoms
    466456          status = true;
    467457        }
     
    474464    MarkUpdateCandidates(AtomMask, *FinalRootCandidates, Order, this);
    475465
    476     Free(&IndexKeySetList);
    477     Free(&AdaptiveCriteriaList);
    478     Free(&FinalRootCandidates);
     466    delete[](IndexKeySetList);
     467    delete[](AdaptiveCriteriaList);
     468    delete[](FinalRootCandidates);
    479469  } 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) {
    482471  #ifdef ADDHYDROGEN
    483       if (Walker->type->Z != 1) // skip hydrogen
     472      if ((*iter)->type->Z != 1) // skip hydrogen
    484473  #endif
    485474      {
    486         AtomMask[Walker->nr] = true;  // include all (non-hydrogen) atoms
    487         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]))
    488477          status = true;
    489478      }
    490479    }
    491     if ((Order == 0) && (AtomMask[AtomCount] == false))  // single stepping, just check
     480    if ((!Order) && (!AtomMask[getAtomCount()]))  // single stepping, just check
    492481      status = true;
    493482
     
    500489  }
    501490
    502   PrintAtomMask(AtomMask, AtomCount); // for debugging
     491  PrintAtomMask(AtomMask, getAtomCount()); // for debugging
    503492
    504493  return status;
     
    516505    return false;
    517506  }
    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--;)
    520509    SortIndex[i] = -1;
    521510
     
    524513
    525514  return true;
     515};
     516
     517
     518
     519/** Creates a lookup table for true father's Atom::Nr -> atom ptr.
     520 * \param *start begin of list (STL iterator, i.e. first item)
     521 * \paran *end end of list (STL iterator, i.e. one past last item)
     522 * \param **Lookuptable pointer to return allocated lookup table (should be NULL on start)
     523 * \param count optional predetermined size for table (otherwise we set the count to highest true father id)
     524 * \return true - success, false - failure
     525 */
     526bool molecule::CreateFatherLookupTable(atom **&LookupTable, int count)
     527{
     528  bool status = true;
     529  int AtomNo;
     530
     531  if (LookupTable != NULL) {
     532    Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl;
     533    return false;
     534  }
     535
     536  // count them
     537  if (count == 0) {
     538    for (molecule::iterator iter = begin(); iter != end(); ++iter) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
     539      count = (count < (*iter)->GetTrueFather()->nr) ? (*iter)->GetTrueFather()->nr : count;
     540    }
     541  }
     542  if (count <= 0) {
     543    Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl;
     544    return false;
     545  }
     546
     547  // allocate and fill
     548  LookupTable = new atom *[count];
     549  if (LookupTable == NULL) {
     550    eLog() << Verbose(0) << "LookupTable memory allocation failed!" << endl;
     551    performCriticalExit();
     552    status = false;
     553  } else {
     554    for (int i=0;i<count;i++)
     555      LookupTable[i] = NULL;
     556    for (molecule::iterator iter = begin(); iter != end(); ++iter) {
     557      AtomNo = (*iter)->GetTrueFather()->nr;
     558      if ((AtomNo >= 0) && (AtomNo < count)) {
     559        //*out << "Setting LookupTable[" << AtomNo << "] to " << *(*iter) << endl;
     560        LookupTable[AtomNo] = (*iter);
     561      } else {
     562        Log() << Verbose(0) << "Walker " << *(*iter) << " exceeded range of nuclear ids [0, " << count << ")." << endl;
     563        status = false;
     564        break;
     565      }
     566    }
     567  }
     568
     569  return status;
    526570};
    527571
     
    547591{
    548592  MoleculeListClass *BondFragments = NULL;
    549   int *SortIndex = NULL;
    550   int *MinimumRingSize = new int[AtomCount];
     593  int *MinimumRingSize = new int[getAtomCount()];
    551594  int FragmentCounter;
    552595  MoleculeLeafClass *MolecularWalker = NULL;
     
    576619
    577620  // create lookup table for Atom::nr
    578   FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(start, end, ListOfAtoms, AtomCount);
     621  FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, getAtomCount());
    579622
    580623  // === compare it with adjacency file ===
    581624  FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(configuration->configpath, ListOfAtoms);
    582   Free(&ListOfAtoms);
     625  delete[](ListOfAtoms);
    583626
    584627  // ===== 2. perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs =====
     
    586629
    587630  // 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();
    590633  MolecularWalker = Subgraphs;
    591634  FragmentCounter = 0;
     
    593636    MolecularWalker = MolecularWalker->next;
    594637    // fill the bond structure of the individually stored subgraphs
    595   MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false);  // we want to keep the created ListOfLocalAtoms
     638    MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false);  // we want to keep the created ListOfLocalAtoms
    596639    DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    597640    LocalBackEdgeStack = new StackClass<bond *> (MolecularWalker->Leaf->BondCount);
    598641//    // check the list of local atoms for debugging
    599642//    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++)
    601644//      if (ListOfLocalAtoms[FragmentCounter][i] == NULL)
    602645//        Log() << Verbose(0) << "\tNULL";
     
    624667  // ===== 6b. prepare and go into the adaptive (Order<0), single-step (Order==0) or incremental (Order>0) cycle
    625668  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;
    628671  FragmentationToDo = false;  // if CheckOrderAtSite just ones recommends fragmentation, we will save fragments afterwards
    629672  while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, configuration->configpath))) {
    630673    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()
    632675    // ===== 6b. fill RootStack for each subgraph (second adaptivity check) =====
    633676    Subgraphs->next->FillRootStackForSubgraphs(RootStack, AtomMask, (FragmentCounter = 0));
     
    640683      DoLog(1) && (Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl);
    641684      //MolecularWalker->Leaf->OutputListOfBonds(out);  // output atom::ListOfBonds for debugging
    642       if (MolecularWalker->Leaf->first->next != MolecularWalker->Leaf->last) {
     685      if (MolecularWalker->Leaf->hasBondStructure()) {
    643686        // call BOSSANOVA method
    644687        DoLog(0) && (Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl);
     
    672715    delete(Subgraphs);
    673716  }
    674   Free(&FragmentList);
     717  delete[](FragmentList);
    675718
    676719  // ===== 8b. gather keyset lists (graphs) from all subgraphs and transform into MoleculeListClass =====
     
    690733  if (BondFragments->ListOfMolecules.size() != 0) {
    691734    // create the SortIndex from BFS labels to order in the config file
     735    int *SortIndex = NULL;
    692736    CreateMappingLabelsToConfigSequence(SortIndex);
    693737
     
    704748    StoreKeySetFile(TotalGraph, configuration->configpath);
    705749
    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    }
    712757
    713758    // store Hydrogen saturation correction file
     
    722767    // free memory for bond part
    723768    DoLog(1) && (Log() << Verbose(1) << "Freeing bond memory" << endl);
    724     delete(FragmentList); // remove bond molecule from memory
    725     Free(&SortIndex);
     769    delete[](SortIndex);
    726770  } else {
    727771    DoLog(1) && (Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl);
     
    768812bool molecule::ParseOrderAtSiteFromFile(char *path)
    769813{
    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()];
    772816  bool status;
    773817  int AtomNr, value;
    774818  stringstream line;
    775819  ifstream file;
     820
     821  for(int i=0;i<getAtomCount();i++) {
     822    OrderArray[i] = 0;
     823    MaxArray[i] = false;
     824  }
    776825
    777826  DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl);
     
    796845    SetAtomValueToIndexedArray( MaxArray, &atom::nr, &atom::MaxOrder );
    797846
    798     DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     847    DoLog(1) && (Log() << Verbose(1) << "\t ... done." << endl);
    799848    status = true;
    800849  } 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);
    802851    status = false;
    803852  }
    804   Free(&OrderArray);
    805   Free(&MaxArray);
     853  delete[](OrderArray);
     854  delete[](MaxArray);
    806855
    807856  DoLog(1) && (Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl);
     
    872921  atom *OtherFather = NULL;
    873922  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();) {
    879929    LonelyFlag = true;
    880     FatherOfRunner = Runner->father;
     930    FatherOfRunner = (*iter)->father;
     931    ASSERT(FatherOfRunner,"Atom without father found");
    881932    if (SonList[FatherOfRunner->nr] != NULL)  {  // check if this, our father, is present in list
    882933      // create all bonds
     
    889940//            Log() << Verbose(3) << "Adding Bond: ";
    890941//            Log() << Verbose(0) <<
    891             Leaf->AddBond(Runner, SonList[OtherFather->nr], (*BondRunner)->BondDegree);
     942            Leaf->AddBond((*iter), SonList[OtherFather->nr], (*BondRunner)->BondDegree);
    892943//            Log() << Verbose(0) << "." << endl;
    893             //NumBonds[Runner->nr]++;
     944            //NumBonds[(*iter)->nr]++;
    894945          } else {
    895946//            Log() << Verbose(3) << "Not adding bond, labels in wrong order." << endl;
     
    899950//          Log() << Verbose(0) << ", who has no son in this fragment molecule." << endl;
    900951#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))
    903954            exit(1);
    904955#endif
    905           //NumBonds[Runner->nr] += Binder->BondDegree;
     956          //NumBonds[(*iter)->nr] += Binder->BondDegree;
    906957        }
    907958      }
    908959    } 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;
    914966#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    }
    917970#endif
    918971  }
     
    929982molecule * molecule::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem)
    930983{
    931   atom **SonList = Calloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList");
     984  atom **SonList = new atom*[getAtomCount()];
    932985  molecule *Leaf = World::getInstance().createMolecule();
     986
     987  for(int i=0;i<getAtomCount();i++)
     988    SonList[i] = NULL;
    933989
    934990//  Log() << Verbose(1) << "Begin of StoreFragmentFromKeyset." << endl;
     
    939995
    940996  //Leaflet->Leaf->ScanForPeriodicCorrection(out);
    941   Free(&SonList);
     997  delete[](SonList);
    942998//  Log() << Verbose(1) << "End of StoreFragmentFromKeyset." << endl;
    943999  return Leaf;
     
    10841140  int bits, TouchedIndex, SubSetDimension, SP, Added;
    10851141  int SpaceLeft;
    1086   int *TouchedList = Malloc<int>(SubOrder + 1, "molecule::SPFragmentGenerator: *TouchedList");
    1087   bond **BondsList = NULL;
     1142  int *TouchedList = new int[SubOrder + 1];
    10881143  KeySetTestPair TestKeySetInsert;
    10891144
     
    11241179
    11251180          // then allocate and fill the list
    1126           BondsList = Malloc<bond*>(SubSetDimension, "molecule::SPFragmentGenerator: **BondsList");
     1181          bond *BondsList[SubSetDimension];
    11271182          SubSetDimension = FillBondsList(BondsList, FragmentSearch->BondsPerSPList[2*SP], FragmentSearch->BondsPerSPList[2*SP+1], TouchedList, TouchedIndex);
    11281183
     
    11301185          Log() << Verbose(2+verbosity) << "Calling subset generator " << SP << " away from root " << *FragmentSearch->Root << " with sub set dimension " << SubSetDimension << "." << endl;
    11311186          SPFragmentGenerator(FragmentSearch, SP, BondsList, SubSetDimension, SubOrder-bits);
    1132 
    1133           Free(&BondsList);
    11341187        }
    11351188      } else {
     
    11531206    }
    11541207  }
    1155   Free(&TouchedList);
     1208  delete[](TouchedList);
    11561209  Log() << Verbose(1+verbosity) << "End of SPFragmentGenerator, " << RootDistance << " away from Root " << *FragmentSearch->Root << " and SubOrder is " << SubOrder << "." << endl;
    11571210};
     
    11651218void InitialiseSPList(int Order, struct UniqueFragments &FragmentSearch)
    11661219{
    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];
    11691222  for (int i=Order;i--;) {
    11701223    FragmentSearch.BondsPerSPList[2*i] = new bond();    // start node
     
    11841237void FreeSPList(int Order, struct UniqueFragments &FragmentSearch)
    11851238{
    1186   Free(&FragmentSearch.BondsPerSPCount);
     1239  delete[](FragmentSearch.BondsPerSPCount);
    11871240  for (int i=Order;i--;) {
    11881241    delete(FragmentSearch.BondsPerSPList[2*i]);
    11891242    delete(FragmentSearch.BondsPerSPList[2*i+1]);
    11901243  }
    1191   Free(&FragmentSearch.BondsPerSPList);
     1244  delete[](FragmentSearch.BondsPerSPList);
    11921245};
    11931246
     
    13701423int molecule::PowerSetGenerator(int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet)
    13711424{
    1372   bond **BondsList = NULL;
    13731425  int Counter = FragmentSearch.FragmentCounter; // mark current value of counter
    13741426
     
    13941446
    13951447    // 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;
    13971451    BondsList[0] = FragmentSearch.BondsPerSPList[0]->next;  // on SP level 0 there's only the root bond
    13981452
    13991453    SPFragmentGenerator(&FragmentSearch, 0, BondsList, FragmentSearch.BondsPerSPCount[0], Order);
    1400 
    1401     Free(&BondsList);
    14021454  } else {
    14031455    DoLog(0) && (Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl);
     
    15071559      }
    15081560    }
    1509     Free(&FragmentLowerOrdersList[RootNr]);
     1561    delete[](FragmentLowerOrdersList[RootNr]);
    15101562    RootNr++;
    15111563  }
    1512   Free(&FragmentLowerOrdersList);
     1564  delete[](FragmentLowerOrdersList);
    15131565};
    15141566
     
    15491601  // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5)
    15501602  // 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  }
    15531610
    15541611  // initialise the fragments structure
     
    15561613  FragmentSearch.FragmentSet = new KeySet;
    15571614  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--;) {
    15601617    FragmentSearch.ShortestPathList[i] = -1;
    15611618  }
    15621619
    15631620  // Construct the complete KeySet which we need for topmost level only (but for all Roots)
    1564   atom *Walker = start;
    15651621  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);
    15691624  }
    15701625
     
    15771632    RootKeyNr = RootStack.front();
    15781633    RootStack.pop_front();
    1579     Walker = FindAtom(RootKeyNr);
     1634    atom *Walker = FindAtom(RootKeyNr);
    15801635    // check cyclic lengths
    15811636    //if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) {
     
    15921647      // allocate memory for all lower level orders in this 1D-array of ptrs
    15931648      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;
    15951652
    15961653      // create top order where nothing is reduced
     
    16281685
    16291686  // cleanup FragmentSearch structure
    1630   Free(&FragmentSearch.ShortestPathList);
     1687  delete[](FragmentSearch.ShortestPathList);
    16311688  delete(FragmentSearch.FragmentSet);
    16321689
     
    16411698  CombineAllOrderListIntoOne(FragmentList, FragmentLowerOrdersList, RootStack, this);
    16421699  FreeAllOrdersList(FragmentLowerOrdersList, RootStack, this);
    1643   Free(&NumMoleculesOfOrder);
     1700  delete[](NumMoleculesOfOrder);
    16441701
    16451702  DoLog(0) && (Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl);
     
    16641721  Vector Translationvector;
    16651722  //class StackClass<atom *> *CompStack = NULL;
    1666   class StackClass<atom *> *AtomStack = new StackClass<atom *>(AtomCount);
     1723  class StackClass<atom *> *AtomStack = new StackClass<atom *>(getAtomCount());
    16671724  bool flag = true;
    16681725
    16691726  DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl);
    16701727
    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;
    16721731  while (flag) {
    16731732    // remove bonds that are beyond bonddistance
    1674     for(int i=NDIM;i--;)
    1675       Translationvector[i] = 0.;
     1733    Translationvector.Zero();
    16761734    // scan all bonds
    1677     Binder = first;
    16781735    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          }
    16901749        }
    16911750      }
    1692     }
    16931751    if (flag) {
    16941752      // create translation vector from their periodically modified distance
     
    17021760      Log() << Verbose(0) << Translationvector <<  endl;
    17031761      // apply to all atoms of first component via BFS
    1704       for (int i=AtomCount;i--;)
     1762      for (int i=getAtomCount();i--;)
    17051763        ColorList[i] = white;
    17061764      AtomStack->Push(Binder->leftatom);
     
    17261784    //delete(CompStack);
    17271785  }
    1728 
    17291786  // free allocated space from ReturnFullMatrixforSymmetric()
    17301787  delete(AtomStack);
    1731   Free(&ColorList);
    1732   Free(&matrix);
     1788  delete[](ColorList);
     1789  delete[](matrix);
    17331790  DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl);
    17341791};
  • src/molecule_geometry.cpp

    re58856b rf2a1d3  
    2727  bool status = true;
    2828  const Vector *Center = DetermineCenterOfAll();
     29  const Vector *CenterBox = DetermineCenterOfBox();
    2930  double * const cell_size = World::getInstance().getDomain();
    3031  double *M = ReturnFullMatrixforSymmetric(cell_size);
     
    3334  // go through all atoms
    3435  ActOnAllVectors( &Vector::SubtractVector, *Center);
     36  ActOnAllVectors( &Vector::SubtractVector, *CenterBox);
    3537  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    3638
    37   Free(&M);
    38   Free(&Minv);
     39  delete[](M);
     40  delete[](Minv);
    3941  delete(Center);
    4042  return status;
     
    5557  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    5658
    57   Free(&M);
    58   Free(&Minv);
     59  delete[](M);
     60  delete[](Minv);
    5961  return status;
    6062};
     
    6971
    7072//  Log() << Verbose(3) << "Begin of CenterEdge." << endl;
    71   atom *ptr = start->next;  // start at first in list
    72   if (ptr != end) {  //list not empty?
     73  molecule::const_iterator iter = begin();  // start at first in list
     74  if (iter != end()) { //list not empty?
    7375    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);
    8081      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);
    8384      }
    8485    }
     
    104105{
    105106  int Num = 0;
    106   atom *ptr = start;  // start at first in list
     107  molecule::const_iterator iter = begin();  // start at first in list
    107108
    108109  Center.Zero();
    109110
    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
    113113      Num++;
    114       Center += ptr->x;
     114      Center += (*iter)->x;
    115115    }
    116116    Center.Scale(-1./Num); // divide through total number (and sign for direction)
     
    125125Vector * molecule::DetermineCenterOfAll() const
    126126{
    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 */
     146Vector * 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 */
     162Vector * molecule::DetermineCenterOfGravity()
     163{
     164  molecule::const_iterator iter = begin();  // start at first in list
    128165  Vector *a = new Vector();
    129166  Vector tmp;
     
    132169  a->Zero();
    133170
    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;
    139175      (*a) += tmp;
    140176    }
    141177    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 debugging
    148  * \return pointer to center of gravity vector
    149  */
    150 Vector * molecule::DetermineCenterOfGravity()
    151 {
    152   atom *ptr = start->next;  // start at first in list
    153   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 present
    161       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)
    167178  }
    168179//  Log() << Verbose(1) << "Resulting center of gravity: ";
     
    202213void molecule::Scale(const double ** const factor)
    203214{
    204   atom *ptr = start;
    205 
    206   while (ptr->next != end) {
    207     ptr = ptr->next;
     215  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    208216    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);
    211219  }
    212220};
     
    217225void molecule::Translate(const Vector *trans)
    218226{
    219   atom *ptr = start;
    220 
    221   while (ptr->next != end) {
    222     ptr = ptr->next;
     227  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    223228    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);
    226231  }
    227232};
     
    238243
    239244  // go through all atoms
    240   ActOnAllVectors( &Vector::SubtractVector, *trans);
     245  ActOnAllVectors( &Vector::AddVector, *trans);
    241246  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    242247
    243   Free(&M);
    244   Free(&Minv);
     248  delete[](M);
     249  delete[](Minv);
    245250};
    246251
     
    259264void molecule::DeterminePeriodicCenter(Vector &center)
    260265{
    261   atom *Walker = start;
    262266  double * const cell_size = World::getInstance().getDomain();
    263267  double *matrix = ReturnFullMatrixforSymmetric(cell_size);
    264   double *inversematrix = InverseMatrix(cell_size);
     268  double *inversematrix = InverseMatrix(matrix);
    265269  double tmp;
    266270  bool flag;
     
    270274    Center.Zero();
    271275    flag = true;
    272     while (Walker->next != end) {
    273       Walker = Walker->next;
     276    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    274277#ifdef ADDHYDROGEN
    275       if (Walker->type->Z != 1) {
     278      if ((*iter)->type->Z != 1) {
    276279#endif
    277         Testvector = Walker->x;
     280        Testvector = (*iter)->x;
    278281        Testvector.MatrixMultiplication(inversematrix);
    279282        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 nothing
     283        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     284         if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing
    282285            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];
    284287              if ((fabs(tmp)) > BondDistance) {
    285288                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);
    287290                if (tmp > 0)
    288291                  Translationvector[j] -= 1.;
     
    298301#ifdef ADDHYDROGEN
    299302        // 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;
    303306            Testvector.MatrixMultiplication(inversematrix);
    304307            Testvector += Translationvector;
     
    312315    }
    313316  } 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()));
    318321};
    319322
     
    325328void molecule::PrincipalAxisSystem(bool DoRotate)
    326329{
    327   atom *ptr = start;  // start at first in list
    328330  double InertiaTensor[NDIM*NDIM];
    329331  Vector *CenterOfGravity = DetermineCenterOfGravity();
     
    336338
    337339  // 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;
    341342    //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]);
    351352  }
    352353  // print InertiaTensor for debugging
     
    386387
    387388    // 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]);
    402400    }
    403401    // print InertiaTensor for debugging
     
    423421void molecule::Align(Vector *n)
    424422{
    425   atom *ptr = start;
    426423  double alpha, tmp;
    427424  Vector z_axis;
     
    434431  alpha = atan(-n->at(0)/n->at(2));
    435432  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];
    441437    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];
    445441    }
    446442  }
     
    452448
    453449  // rotate on z-y plane
    454   ptr = start;
    455450  alpha = atan(-n->at(1)/n->at(2));
    456451  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];
    462456    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];
    466460    }
    467461  }
     
    487481  Vector a,b,c,d;
    488482  struct lsq_params *par = (struct lsq_params *)params;
    489   atom *ptr = par->mol->start;
    490483
    491484  // initialize vectors
     
    497490  b[2] = gsl_vector_get(x,5);
    498491  // 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;
    503495      t = c.ScalarProduct(b);           // get direction parameter
    504496      d = t*b;       // and create vector
  • src/molecule_graph.cpp

    re58856b rf2a1d3  
    1212#include "element.hpp"
    1313#include "helpers.hpp"
     14#include "info.hpp"
    1415#include "linkedcell.hpp"
    1516#include "lists.hpp"
     
    1920#include "World.hpp"
    2021#include "Helpers/fast_functions.hpp"
     22#include "Helpers/Assert.hpp"
     23
    2124
    2225struct BFSAccounting
     
    5457void molecule::CreateAdjacencyListFromDbondFile(ifstream *input)
    5558{
    56 
     59  Info FunctionInfo(__func__);
    5760  // 1 We will parse bonds out of the dbond file created by tremolo.
    5861  int atom1, atom2;
    5962  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();
    6368  };
    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");
    6874  while (!input->eof()) // Check whether we read everything already
    6975  {
    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);
    7382    if (atom2 < atom1) //Sort indices of atoms in order
    7483      flip(atom1, atom2);
    7584    Walker = FindAtom(atom1);
     85    ASSERT(Walker,"Could not find an atom with the ID given in dbond file");
    7686    OtherWalker = FindAtom(atom2);
     87    ASSERT(OtherWalker,"Could not find an atom with the ID given in dbond file");
    7788    AddBond(Walker, OtherWalker); //Add the bond between the two atoms with respective indices.
    7889  }
     
    103114  atom *Walker = NULL;
    104115  atom *OtherWalker = NULL;
    105   atom **AtomMap = NULL;
    106116  int n[NDIM];
    107117  double MinDistance, MaxDistance;
     
    118128  DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl);
    119129  // 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));
    127134  BondCount = 0;
    128135
    129136  // 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.)) {
    134140    DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl);
    135141    LC = new LinkedCell(this, bonddistance);
     
    137143    // create a list to map Tesselpoint::nr to atom *
    138144    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++;
    144150    }
    145151
     
    153159          if (List != NULL) {
    154160            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;
    157164              // 3c. check for possible bond between each atom in this and every one in the 27 cells
    158165              for (n[0] = -1; n[0] <= 1; n[0]++)
     
    164171                      for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
    165172                        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;
    170176                          (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
     177                          const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size);
    171178                          const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
    172179//                          Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl;
     
    188195          }
    189196        }
    190     Free(&AtomMap);
    191197    delete (LC);
    192198    DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl);
     
    199205    ActOnAllAtoms( &atom::OutputBondOfAtom );
    200206  } 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);
    202208  DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl);
    203209  if (free_BG)
     
    206212;
    207213
     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 */
     218bool 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 */
     229unsigned 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
    208239/** Prints a list of all bonds to \a *out.
    209240 * \param output stream
     
    212243{
    213244  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      }
    219250  DoLog(0) && (Log() << Verbose(0) << endl);
    220251}
     
    241272    DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    242273  } 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);
    244275  }
    245276  DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl);
     
    260291  MoleculeLeafClass *Subgraphs = NULL;
    261292  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++;
    278310  delete (BackEdgeStack);
    279311  return NoCyclicBonds;
     
    317349    Walker->GraphNr = DFS.CurrentGraphNr;
    318350    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);
    320352    DFS.AtomStack->Push(Walker);
    321353    DFS.CurrentGraphNr++;
     
    348380    Binder->MarkUsed(black);
    349381    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);
    351383    if (OtherAtom->GraphNr != -1) {
    352384      // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3)
     
    354386      DFS.BackEdgeStack->Push(Binder);
    355387      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);
    357389    } else {
    358390      // (4b) ... otherwise set OtherAtom as Ancestor of Walker and Walker as OtherAtom, go to (2)
     
    360392      OtherAtom->Ancestor = Walker;
    361393      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);
    363395      break;
    364396    }
     
    382414
    383415  // (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);
    385417
    386418  if (Walker->Ancestor->GraphNr != DFS.Root->GraphNr) {
     
    389421      // (6a) set Ancestor's Lowpoint number to minimum of of its Ancestor and itself, go to Step(8)
    390422      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);
    392424    } else {
    393425      // (7) (Ancestor of Walker is a separating vertex, remove all from stack till Walker (including), these and Ancestor form a component
    394426      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);
    396428      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);
    398430      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);
    400432      do {
    401433        OtherAtom = DFS.AtomStack->PopLast();
    402434        LeafWalker->Leaf->AddCopyAtom(OtherAtom);
    403435        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);
    405437      } while (OtherAtom != Walker);
    406438      DFS.ComponentNumber++;
    407439    }
    408440    // (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);
    410442    Walker = Walker->Ancestor;
    411443    DFS.BackStepping = true;
     
    431463    //DFS.AtomStack->Output(out);
    432464    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);
    434466    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);
    436468    do {
    437469      OtherAtom = DFS.AtomStack->PopLast();
    438470      LeafWalker->Leaf->AddCopyAtom(OtherAtom);
    439471      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);
    441473    } while (OtherAtom != Walker);
    442474    DFS.ComponentNumber++;
     
    445477    Walker = DFS.Root;
    446478    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);
    448480    if (Binder != NULL) { // Root is separation vertex
    449481      DoLog(1) && (Log() << Verbose(1) << "(11) Root is a separation vertex." << endl);
     
    461493void DepthFirstSearchAnalysis_Init(struct DFSAccounting &DFS, const molecule * const mol)
    462494{
    463   DFS.AtomStack = new StackClass<atom *> (mol->AtomCount);
     495  DFS.AtomStack = new StackClass<atom *> (mol->getAtomCount());
    464496  DFS.CurrentGraphNr = 0;
    465497  DFS.ComponentNumber = 0;
     
    502534  bond *Binder = NULL;
    503535
    504   if (AtomCount == 0)
     536  if (getAtomCount() == 0)
    505537    return SubGraphs;
    506538  DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl);
    507539  DepthFirstSearchAnalysis_Init(DFS, this);
    508540
    509   DFS.Root = start->next;
    510   while (DFS.Root != end) { // if there any atoms at all
     541  for (molecule::const_iterator iter = begin(); iter != end();) {
     542    DFS.Root = *iter;
    511543    // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all
    512544    DFS.AtomStack->ClearStack();
     
    548580
    549581    // 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 on
    553         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++;
    554586    }
    555587  }
     
    573605{
    574606  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        }
    583614}
    584615;
     
    599630void molecule::OutputGraphInfoPerBond() const
    600631{
     632  bond *Binder = NULL;
    601633  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      }
    615648}
    616649;
     
    624657{
    625658  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];
    629662  BFS.BFSStack = new StackClass<atom *> (AtomCount);
    630663
    631   for (int i = AtomCount; i--;)
     664  for (int i = AtomCount; i--;) {
    632665    BFS.ShortestPathList[i] = -1;
     666    BFS.PredecessorList[i] = 0;
     667  }
    633668};
    634669
     
    639674void FinalizeBFSAccounting(struct BFSAccounting &BFS)
    640675{
    641   Free(&BFS.PredecessorList);
    642   Free(&BFS.ShortestPathList);
    643   Free(&BFS.ColorList);
     676  delete[](BFS.PredecessorList);
     677  delete[](BFS.ShortestPathList);
     678  delete[](BFS.ColorList);
    644679  delete (BFS.BFSStack);
    645680  BFS.AtomCount = 0;
     
    692727        if (OtherAtom->type->Z != 1) {
    693728#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);
    695730        if (BFS.ColorList[OtherAtom->nr] == white) {
    696731          BFS.TouchedStack->Push(OtherAtom);
     
    698733          BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor
    699734          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);
    701736          //if (BFS.ShortestPathList[OtherAtom->nr] < MinimumRingSize[Walker->GetTrueFather()->nr]) { // Check for maximum distance
    702737          DoLog(3) && (Log() << Verbose(3) << "Putting OtherAtom into queue." << endl);
     
    719754    }
    720755    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);
    722757    if (OtherAtom == BFS.Root) { // if we have found the root, check whether this cycle wasn't already found beforehand
    723758      // step through predecessor list
     
    770805    Walker = BFS.Root;
    771806    while (Walker != BackEdge->rightatom) {
    772       DoLog(0) && (Log() << Verbose(0) << Walker->Name << " <-> ");
     807      DoLog(0) && (Log() << Verbose(0) << Walker->getName() << " <-> ");
    773808      Walker = BFS.PredecessorList[Walker->nr];
    774809      Walker->GetTrueFather()->IsCyclic = true;
    775810      RingSize++;
    776811    }
    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);
    778813    // walk through all and set MinimumRingSize
    779814    Walker = BFS.Root;
     
    854889  if (MinRingSize != -1) { // if rings are present
    855890    // 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
    861895        Walker = Root;
    862896
    863897        //Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl;
    864         CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->AtomCount);
     898        CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->getAtomCount());
    865899
    866900      }
     
    892926  int MinRingSize = -1;
    893927
    894   InitializeBFSAccounting(BFS, AtomCount);
     928  InitializeBFSAccounting(BFS, getAtomCount());
    895929
    896930  //Log() << Verbose(1) << "Back edge list - ";
     
    9661000void molecule::ResetAllBondsToUnused() const
    9671001{
    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();
    9731006}
    9741007;
     
    10041037    line << filename;
    10051038  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);
    10071040  if (AdjacencyFile != NULL) {
    10081041    AdjacencyFile << "m\tn" << endl;
    10091042    ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile);
    10101043    AdjacencyFile.close();
    1011     DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     1044    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
    10121045  } 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);
    10141047    status = false;
    10151048  }
     
    10361069    line << filename;
    10371070  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);
    10391072  if (BondFile != NULL) {
    10401073    BondFile << "m\tn" << endl;
    10411074    ActOnAllAtoms(&atom::OutputBonds, &BondFile);
    10421075    BondFile.close();
    1043     DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     1076    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
    10441077  } 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);
    10461079    status = false;
    10471080  }
     
    10561089  filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
    10571090  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);
    10591092  if (File == NULL)
    10601093    return false;
    10611094
    10621095  // 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;
    10641099  return true;
    10651100}
     
    10701105  File.close();
    10711106  File.clear();
    1072   Free(&CurrentBonds);
     1107  delete[](CurrentBonds);
    10731108}
    10741109;
     
    10901125        NonMatchNumber++;
    10911126        status = false;
     1127        DoeLog(2) && (eLog() << Verbose(2) << id << " can not be found in list." << endl);
     1128      } else {
    10921129        //Log() << Verbose(0) << "[" << id << "]\t";
    1093       } else {
    1094         //Log() << Verbose(0) << id << "\t";
    10951130      }
    10961131    }
     
    11141149  bool status = true;
    11151150  atom *Walker = NULL;
    1116   char *buffer = NULL;
    11171151  int *CurrentBonds = NULL;
    11181152  int NonMatchNumber = 0; // will number of atoms with differing bond structure
    11191153  size_t CurrentBondsOfAtom = -1;
     1154  const int AtomCount = getAtomCount();
    11201155
    11211156  if (!CheckAdjacencyFileAgainstMolecule_Init(path, File, CurrentBonds)) {
     
    11241159  }
    11251160
    1126   buffer = Malloc<char> (MAXSTRINGSIZE, "molecule::CheckAdjacencyFileAgainstMolecule: *buffer");
     1161  char buffer[MAXSTRINGSIZE];
    11271162  // Parse the file line by line and count the bonds
    11281163  while (!File.eof()) {
     
    11401175      // compare against present bonds
    11411176      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  }
    11451182  CheckAdjacencyFileAgainstMolecule_Finalize(File, CurrentBonds);
    11461183
     
    11961233  BFS.AtomCount = AtomCount;
    11971234  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];
    12011238  BFS.BFSStack = new StackClass<atom *> (AtomCount);
    12021239
     
    12071244  // initialise each vertex as white with no predecessor, empty queue, color Root lightgray
    12081245  for (int i = AtomCount; i--;) {
     1246    BFS.PredecessorList[i] = NULL;
    12091247    BFS.ShortestPathList[i] = -1;
    12101248    if ((AddedAtomList != NULL) && (AddedAtomList[i] != NULL)) // mark already present atoms (i.e. Root and maybe others) as visited
     
    12131251      BFS.ColorList[i] = white;
    12141252  }
    1215   //BFS.ShortestPathList[Root->nr] = 0; //is set due to Calloc()
     1253  //BFS.ShortestPathList[Root->nr] = 0; // done by Calloc
    12161254}
    12171255;
     
    12191257void BreadthFirstSearchAdd_Free(struct BFSAccounting &BFS)
    12201258{
    1221   Free(&BFS.PredecessorList);
    1222   Free(&BFS.ShortestPathList);
    1223   Free(&BFS.ColorList);
     1259  delete[](BFS.PredecessorList);
     1260  delete[](BFS.ShortestPathList);
     1261  delete[](BFS.ColorList);
    12241262  delete (BFS.BFSStack);
    12251263  BFS.AtomCount = 0;
     
    12331271  BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor
    12341272  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);
    12361274  if ((((BFS.ShortestPathList[OtherAtom->nr] < BFS.BondOrder) && (Binder != Bond)))) { // Check for maximum distance
    12371275    DoLog(3) && (Log() << Verbose(3));
    12381276    if (AddedAtomList[OtherAtom->nr] == NULL) { // add if it's not been so far
    12391277      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());
    12411279      AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder);
    12421280      DoLog(0) && (Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", ");
    12431281    } 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());
    12451283      if (AddedBondList[Binder->nr] == NULL) {
    12461284        AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder);
     
    13131351    AddedAtomList[Root->nr] = Mol->AddCopyAtom(Root);
    13141352
    1315   BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, AtomCount, AddedAtomList);
     1353  BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, getAtomCount(), AddedAtomList);
    13161354
    13171355  // and go on ... Queue always contains all lightgray vertices
     
    13221360    // followed by n+1 till top of stack.
    13231361    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);
    13251363    for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    13261364      if ((*Runner) != NULL) { // don't look at bond equal NULL
    13271365        Binder = (*Runner);
    13281366        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);
    13301368        if (BFS.ColorList[OtherAtom->nr] == white) {
    13311369          BreadthFirstSearchAdd_UnvisitedNode(Mol, BFS, Walker, OtherAtom, Binder, Bond, AddedAtomList, AddedBondList, IsAngstroem);
     
    13361374    }
    13371375    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);
    13391377  }
    13401378  BreadthFirstSearchAdd_Free(BFS);
     
    13601398{
    13611399  // 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;
    13631403  DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl);
    13641404}
     
    13691409  // fill parent list with sons
    13701410  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);
    13751413    // 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};
    13811417
    13821418void BuildInducedSubgraph_Finalize(atom **&ParentList)
    13831419{
    1384   Free(&ParentList);
     1420  delete[](ParentList);
    13851421}
    13861422;
     
    13891425{
    13901426  bool status = true;
    1391   atom *Walker = NULL;
    13921427  atom *OtherAtom = NULL;
    13931428  // check each entry of parent list and if ok (one-to-and-onto matching) create bonds
    13941429  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)) {
    14001433        status = false;
    14011434      } 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));
    14041437          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);
    14071440          }
    14081441        }
     
    14271460  bool status = true;
    14281461  atom **ParentList = NULL;
    1429 
    14301462  DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl);
    1431   BuildInducedSubgraph_Init(ParentList, Father->AtomCount);
     1463  BuildInducedSubgraph_Init(ParentList, Father->getAtomCount());
    14321464  BuildInducedSubgraph_FillParentList(this, Father, ParentList);
    14331465  status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList);
  • src/molecule_pointcloud.cpp

    re58856b rf2a1d3  
    88#include "atom.hpp"
    99#include "config.hpp"
     10#include "info.hpp"
    1011#include "memoryallocator.hpp"
    1112#include "molecule.hpp"
     
    3132};
    3233
    33 /** Return current atom in the list.
    34  * \return pointer to atom or NULL if none present
     34
     35/** PointCloud implementation of GoPoint
     36 * Uses atoms and STL stuff.
    3537 */
    36 TesselPoint *molecule::GetPoint() const
     38TesselPoint* molecule::GetPoint() const
    3739{
    38   if ((InternalPointer != start) && (InternalPointer != end))
    39     return InternalPointer;
    40   else
    41     return NULL;
     40  return (*InternalPointer);
    4241};
    4342
    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.
    6245 */
    6346void molecule::GoToNext() const
    6447{
    65   if (InternalPointer != end)
    66     InternalPointer = InternalPointer->next;
     48  if (InternalPointer != atoms.end())
     49    InternalPointer++;
    6750};
    6851
    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.
    7954 */
    8055void molecule::GoToFirst() const
    8156{
    82   InternalPointer = start->next;
     57  InternalPointer = atoms.begin();
    8358};
    8459
    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.
    9462 */
    9563bool molecule::IsEmpty() const
    9664{
    97   return (start->next == end);
     65  return (empty());
    9866};
    9967
    100 /** Checks whether we are at the last atom
    101  * \return true - current atom is last one, false - is not last one
     68/** PointCloud implementation of IsLast.
     69 * Uses atoms and STL stuff.
    10270 */
    10371bool molecule::IsEnd() const
    10472{
    105   return (InternalPointer == end);
     73  return (InternalPointer == atoms.end());
    10674};
     75
     76int molecule::GetMaxId() const {
     77  return getAtomCount();
     78}
  • src/molecule_template.hpp

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

    re58856b rf2a1d3  
    2020#include "memoryallocator.hpp"
    2121#include "periodentafel.hpp"
    22 #include "World.hpp"
     22#include "Helpers/Assert.hpp"
     23
     24#include "Helpers/Assert.hpp"
    2325
    2426/*********************************** Functions for class MoleculeListClass *************************/
     
    3840MoleculeListClass::~MoleculeListClass()
    3941{
    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);
    4645  ListOfMolecules.clear(); // empty list
    4746};
     
    4948/** Insert a new molecule into the list and set its number.
    5049 * \param *mol molecule to add to list.
    51  * \return true - add successful
    5250 */
    5351void MoleculeListClass::insert(molecule *mol)
     
    5957};
    6058
     59/** Erases a molecule from the list.
     60 * \param *mol molecule to add to list.
     61 */
     62void MoleculeListClass::erase(molecule *mol)
     63{
     64  OBSERVE;
     65  mol->signOff(this);
     66  ListOfMolecules.remove(mol);
     67};
     68
    6169/** Compare whether two molecules are equal.
    6270 * \param *a molecule one
     
    6977  int Count, Counter, aCounter, bCounter;
    7078  int flag;
    71   atom *aWalker = NULL;
    72   atom *bWalker = NULL;
    7379
    7480  // sort each atom list and put the numbers into a list, then go through
    7581  //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()) {
    7788    return -1;
    7889  } else {
    79     if ((**(molecule **) a).AtomCount > (**(molecule **) b).AtomCount)
     90    if (mol1->getAtomCount() > mol2->getAtomCount())
    8091      return +1;
    8192    else {
    82       Count = (**(molecule **) a).AtomCount;
     93      Count = mol1->getAtomCount();
    8394      aList = new int[Count];
    8495      bList = new int[Count];
    8596
    8697      // fill the lists
    87       aWalker = (**(molecule **) a).start;
    88       bWalker = (**(molecule **) b).start;
    8998      Counter = 0;
    9099      aCounter = 0;
    91100      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)
    96106          aList[Counter] = Count + (aCounter++);
    97107        else
    98           aList[Counter] = aWalker->GetTrueFather()->nr;
    99         if (bWalker->GetTrueFather() == NULL)
     108          aList[Counter] = (*aiter)->GetTrueFather()->nr;
     109        if ((*biter)->GetTrueFather() == NULL)
    100110          bList[Counter] = Count + (bCounter++);
    101111        else
    102           bList[Counter] = bWalker->GetTrueFather()->nr;
     112          bList[Counter] = (*biter)->GetTrueFather()->nr;
    103113        Counter++;
    104114      }
    105115      // check if AtomCount was for real
    106116      flag = 0;
    107       if ((aWalker->next == (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {
     117      if ((aiter == mol1->end()) && (biter != mol2->end())) {
    108118        flag = -1;
    109119      } else {
    110         if ((aWalker->next != (**(molecule **) a).end) && (bWalker->next == (**(molecule **) b).end))
     120        if ((aiter != mol1->end()) && (biter == mol2->end()))
    111121          flag = 1;
    112122      }
     
    142152void MoleculeListClass::Enumerate(ostream *out)
    143153{
    144   atom *Walker = NULL;
    145154  periodentafel *periode = World::getInstance().getPeriode();
    146155  std::map<atomicNumber_t,unsigned int> counts;
     
    158167      // count atoms per element and determine size of bounding sphere
    159168      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);
    166173      }
    167174      // 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";
    169176
    170177      std::map<atomicNumber_t,unsigned int>::reverse_iterator iter;
     
    202209
    203210  // 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));
    211216  }
    212217
     
    228233
    229234  // 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));
    236238    Walker->father = Walker;
    237239  }
     
    330332
    331333  // 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++)
    335336    CopyAtoms[i] = NULL;
    336337
    337338  // for each of the source atoms check whether we are in- or outside and add copy atom
    338   atom *Walker = srcmol->start;
    339339  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]);
    346345      nr++;
    347346    } else {
     
    349348    }
    350349  }
    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.");
    352351
    353352  // 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      }
    360359  delete(LCList);
    361360  return true;
     
    382381bool MoleculeListClass::AddHydrogenCorrection(char *path)
    383382{
    384   atom *Walker = NULL;
    385   atom *Runner = NULL;
    386383  bond *Binder = NULL;
    387384  double ***FitConstant = NULL, **correction = NULL;
     
    427424
    428425  // 0b. allocate memory for constants
    429   FitConstant = Calloc<double**>(3, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant");
     426  FitConstant = new double**[3];
    430427  for (int k = 0; k < 3; k++) {
    431     FitConstant[k] = Calloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]");
     428    FitConstant[k] = new double*[a];
    432429    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      }
    434434    }
    435435  }
     
    477477
    478478  // 0d. allocate final correction matrix
    479   correction = Calloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **correction");
     479  correction = new double*[a];
    480480  for (int i = a; i--;)
    481     correction[i] = Calloc<double>(b, "MoleculeListClass::AddHydrogenCorrection: *correction[]");
     481    correction[i] = new double[b];
    482482
    483483  // 1a. go through every molecule in the list
     
    488488        correction[k][j] = 0.;
    489489    // 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;
    500496          // 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!)
    503499            // 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;
    506502            for (int k = 0; k < a; k++) {
    507503              for (int j = 0; j < b; j++) {
     
    531527    FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), (*ListRunner)->IndexNr);
    532528    line += FragmentNumber;
    533     delete (FragmentNumber);
     529    delete[] (FragmentNumber);
    534530    line += HCORRECTIONSUFFIX;
    535531    output.open(line.c_str());
     
    542538    output.close();
    543539  }
     540  for (int i = a; i--;)
     541    delete[](correction[i]);
     542  delete[](correction);
     543
    544544  line = path;
    545545  line.append("/");
     
    556556  for (int k = 0; k < 3; k++) {
    557557    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);
    563563  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    564564  return true;
     
    577577  ofstream ForcesFile;
    578578  stringstream line;
    579   atom *Walker = NULL;
    580579  periodentafel *periode=World::getInstance().getPeriode();
    581580
     
    590589      periodentafel::const_iterator elemIter;
    591590      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
    598595                //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";
    600597              } else
    601598                // otherwise a -1 to indicate an added saturation hydrogen
     
    622619 * \param *configuration standard configuration to attach atoms in fragment molecule to.
    623620 * \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't
    625  * \param DoCentering true - call molecule::CenterEdge(), false - don't
    626621 * \return true - success (each file was written), false - something went wrong.
    627622 */
     
    633628  bool result = true;
    634629  bool intermediateResult = true;
    635   atom *Walker = NULL;
    636630  Vector BoxDimension;
    637631  char *FragmentNumber = NULL;
     
    674668    // list atoms in fragment for debugging
    675669    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() << " ");
    680672    }
    681673    DoLog(0) && (Log() << Verbose(0) << endl);
     
    724716    //outputFragment.close();
    725717    //outputFragment.clear();
    726     Free(&FragmentNumber);
     718    delete[](FragmentNumber);
    727719  }
    728720  DoLog(0) && (Log() << Verbose(0) << " done." << endl);
     
    756748void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration)
    757749{
     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
    758757  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);
    785763  }
    786764
     
    810788  const int MolCount = Subgraphs->next->Count();
    811789  char number[MAXSTRINGSIZE];
    812   molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules");
     790  molecule **molecules = new molecule *[MolCount];
     791  MoleculeLeafClass *MolecularWalker = Subgraphs;
    813792  for (int i=0;i<MolCount;i++) {
     793    MolecularWalker = MolecularWalker->next;
    814794    molecules[i] = World::getInstance().createMolecule();
    815795    molecules[i]->ActiveFlag = true;
     
    820800    }
    821801    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    }
    822805    insert(molecules[i]);
    823806  }
     
    825808  // 4b. create and fill map of which atom is associated to which connected molecule (note, counting starts at 1)
    826809  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;
    830812  while (MolecularWalker->next != NULL) {
    831813    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
    836819    }
    837820    FragmentCounter++;
    838821  }
    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
    858824  // 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
    866826  // 4e. free Leafs
    867827  MolecularWalker = Subgraphs;
     
    871831  }
    872832  delete(MolecularWalker);
    873   Free(&MolMap);
    874   Free(&molecules);
     833  delete[](molecules);
    875834  DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl);
    876835};
     
    882841int MoleculeListClass::CountAllAtoms() const
    883842{
    884   atom *Walker = NULL;
    885843  int AtomNo = 0;
    886844  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();
    892846  }
    893847  return AtomNo;
     
    10641018bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList)
    10651019{
    1066   atom *Walker = NULL;
    10671020  atom *OtherWalker = NULL;
    10681021  atom *Father = NULL;
     
    10721025  DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl);
    10731026  // fill ListOfLocalAtoms if NULL was given
    1074   if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
     1027  if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) {
    10751028    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    10761029    return false;
     
    10801033    DoLog(1) && (Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl);
    10811034    // 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();
    10941042      AtomNo = Father->nr; // global id of the current walker
    10951043      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 walker
     1044        OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker
    10971045        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);
    11001048        } 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);
    11021050          status = false;
    11031051        }
     
    11081056  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
    11091057    // free the index lookup list
    1110     Free(&ListOfLocalAtoms[FragmentCounter]);
     1058    delete[](ListOfLocalAtoms[FragmentCounter]);
    11111059    if (FragmentCounter == 0) // first fragments frees the initial pointer to list
    1112       Free(&ListOfLocalAtoms);
     1060      delete[](ListOfLocalAtoms);
    11131061  }
    11141062  DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl);
     
    11261074bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter)
    11271075{
    1128   atom *Walker = NULL, *Father = NULL;
     1076  atom *Father = NULL;
    11291077
    11301078  if (RootStack != NULL) {
     
    11321080    if (&(RootStack[FragmentCounter]) != NULL) {
    11331081      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();
    11381084        if (AtomMask[Father->nr]) // apply mask
    11391085#ifdef ADDHYDROGEN
    1140           if (Walker->type->Z != 1) // skip hydrogen
     1086          if ((*iter)->type->Z != 1) // skip hydrogen
    11411087#endif
    1142           RootStack[FragmentCounter].push_front(Walker->nr);
     1088          RootStack[FragmentCounter].push_front((*iter)->nr);
    11431089      }
    11441090      if (next != NULL)
     
    11711117    // allocate and set each field to NULL
    11721118    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];
    11741121    if (ListOfLocalAtoms == NULL) {
    11751122      FreeList = FreeList && false;
    11761123      status = false;
    11771124    }
     1125    for (int i=0;i<Counter;i++)
     1126      ListOfLocalAtoms[i] = NULL;
    11781127  }
    11791128
    11801129  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);
    11821131    FreeList = FreeList && true;
    11831132  }
     
    12031152  DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl);
    12041153  // fill ListOfLocalAtoms if NULL was given
    1205   if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
     1154  if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) {
    12061155    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    12071156    return false;
     
    12111160  if (FragmentList == NULL) {
    12121161    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;
    12141165    KeySetCounter = 0;
    12151166  }
     
    12451196  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
    12461197    // free the index lookup list
    1247     Free(&ListOfLocalAtoms[FragmentCounter]);
     1198    delete[](ListOfLocalAtoms[FragmentCounter]);
    12481199    if (FragmentCounter == 0) // first fragments frees the initial pointer to list
    1249       Free(&ListOfLocalAtoms);
     1200      delete[](ListOfLocalAtoms);
    12501201  }
    12511202  DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl);
  • src/parser.cpp

    re58856b rf2a1d3  
    3232  if (input == NULL) {
    3333    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);
    3535    return false;
    3636  }
     
    5959MatrixContainer::MatrixContainer() {
    6060  Indices = NULL;
    61   Header = Malloc<char*>(1, "MatrixContainer::MatrixContainer: **Header");
    62   Matrix = Malloc<double**>(1, "MatrixContainer::MatrixContainer: ***Matrix"); // one more each for the total molecule
    63   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];
    6565  Header[0] = NULL;
    6666  Matrix[0] = NULL;
     
    7777      if ((ColumnCounter != NULL) && (RowCounter != NULL)) {
    7878          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]);
    8181      }
    8282    }
    8383    if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))
    8484      for(int j=RowCounter[MatrixCounter]+1;j--;)
    85         Free(&Matrix[MatrixCounter][j]);
     85        delete[](Matrix[MatrixCounter][j]);
    8686    if (MatrixCounter != 0)
    87       Free(&Matrix[MatrixCounter]);
    88     Free(&Matrix);
     87      delete[](Matrix[MatrixCounter]);
     88    delete[](Matrix);
    8989  }
    9090  if (Indices != NULL)
    9191    for(int i=MatrixCounter+1;i--;) {
    92       Free(&Indices[i]);
    93     }
    94   Free(&Indices);
     92      delete[](Indices[i]);
     93    }
     94  delete[](Indices);
    9595 
    9696  if (Header != NULL)
    9797    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);
    102102};
    103103
     
    112112  if (Matrix == NULL) {
    113113    DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl);
    114     Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");
     114    Indices = new int*[MatrixCounter + 1];
    115115    for(int i=MatrixCounter+1;i--;) {
    116       Indices[i] = Malloc<int>(RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");
     116      Indices[i] = new int[RowCounter[i]];
    117117      for(int j=RowCounter[i];j--;)
    118118        Indices[i][j] = j;
     
    122122    if (MatrixCounter != Matrix->MatrixCounter)
    123123      return false;
    124     Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");
     124    Indices = new int*[MatrixCounter + 1];
    125125    for(int i=MatrixCounter+1;i--;) {
    126126      if (RowCounter[i] != Matrix->RowCounter[i])
    127127        return false;
    128       Indices[i] = Malloc<int>(Matrix->RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");
     128      Indices[i] = new int[Matrix->RowCounter[i]];
    129129      for(int j=Matrix->RowCounter[i];j--;) {
    130130        Indices[i][j] = Matrix->Indices[i][j];
     
    160160  //Log() << Verbose(1) << "Opening " << name << " ... "  << input << endl;
    161161  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);
    163163    //performCriticalExit();
    164164    return false;
     
    166166
    167167  // parse header
    168   Header[MatrixNr] = Malloc<char>(1024, "MatrixContainer::ParseMatrix: *Header[]");
     168  Header[MatrixNr] = new char[1024];
    169169  for (int m=skiplines+1;m--;)
    170170    input.getline(Header[MatrixNr], 1023);
     
    205205  // allocate matrix if it's not zero dimension in one direction
    206206  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];
    208208 
    209209    // parse in each entry for this matrix
     
    217217    strncpy(Header[MatrixNr], line.str().c_str(), 1023); 
    218218    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]];
    220220      input.getline(filename, 1023);
    221221      stringstream lines(filename);
     
    227227        //Log() << Verbose(1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl;
    228228      }
    229       Matrix[MatrixNr][ RowCounter[MatrixNr] ] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]");
     229      Matrix[MatrixNr][ RowCounter[MatrixNr] ] = new double[ColumnCounter[MatrixNr]];
    230230      for(int j=ColumnCounter[MatrixNr];j--;)
    231231        Matrix[MatrixNr][ RowCounter[MatrixNr] ][j] = 0.;
     
    269269  input.open(file.str().c_str(), ios::in);
    270270  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);
    272272    return false;
    273273  }
     
    281281
    282282  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];
    287291  for(int i=MatrixCounter+1;i--;) {
    288292    Matrix[i] = NULL;
     
    298302    if (!ParseMatrix(file.str().c_str(), skiplines, skipcolumns, i))
    299303      return false;
    300     Free(&FragmentNumber);
     304    delete[](FragmentNumber);
    301305  }
    302306  return true;
     
    313317{
    314318  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 molecule
    317   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];
    319323  for(int i=MatrixCounter+1;i--;) {
    320     Header[i] = Malloc<char>(1024, "MatrixContainer::AllocateMatrix: *Header[i]");
     324    Header[i] = new char[1024];
    321325    strncpy(Header[i], GivenHeader[i], 1023);
    322326    RowCounter[i] = RCounter[i];
    323327    ColumnCounter[i] = CCounter[i];
    324     Matrix[i] = Malloc<double*>(RowCounter[i] + 1, "MatrixContainer::AllocateMatrix: **Matrix[]");
     328    Matrix[i] = new double*[RowCounter[i] + 1];
    325329    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]];
    327331      for(int k=ColumnCounter[i];k--;)
    328332        Matrix[i][j][k] = 0.;
     
    474478    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
    475479    line << name << FRAGMENTPREFIX << FragmentNumber << "/" << prefix;
    476     Free(&FragmentNumber);
     480    delete[](FragmentNumber);
    477481    output.open(line.str().c_str(), ios::out);
    478482    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);
    480484      performCriticalExit();
    481485      return false;
     
    507511  output.open(line.str().c_str(), ios::out);
    508512  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);
    510514    performCriticalExit();
    511515    return false;
     
    530534{
    531535  DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl);
    532   Indices = Malloc<int*>(MatrixCounter + 1, "EnergyMatrix::ParseIndices: **Indices");
     536  Indices = new int*[MatrixCounter + 1];
    533537  for(int i=MatrixCounter+1;i--;) {
    534     Indices[i] = Malloc<int>(RowCounter[i], "EnergyMatrix::ParseIndices: *Indices[]");
     538    Indices[i] = new int[RowCounter[i]];
    535539    for(int j=RowCounter[i];j--;)
    536540      Indices[i][j] = j;
     
    589593    // allocate last plus one matrix
    590594    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];
    592596    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]];
    594598   
    595599    // try independently to parse global energysuffix file if present
     
    616620
    617621  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];
    619623  line << name << FRAGMENTPREFIX << FORCESFILE;
    620624  input.open(line.str().c_str(), ios::in);
    621625  //Log() << Verbose(0) << "Opening " << line.str() << " ... "  << input << endl;
    622626  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);
    624628    return false;
    625629  }
     
    629633    line.str(filename);
    630634    // parse the values
    631     Indices[i] = Malloc<int>(RowCounter[i], "ForceMatrix::ParseIndices: *Indices[]");
     635    Indices[i] = new int[RowCounter[i]];
    632636    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
    633637    //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:";
    634     Free(&FragmentNumber);
     638    delete[](FragmentNumber);
    635639    for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) {
    636640      line >> Indices[i][j];
     
    639643    //Log() << Verbose(0) << endl;
    640644  }
    641   Indices[MatrixCounter] = Malloc<int>(RowCounter[MatrixCounter], "ForceMatrix::ParseIndices: *Indices[]");
     645  Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]];
    642646  for(int j=RowCounter[MatrixCounter];j--;) {
    643647    Indices[MatrixCounter][j] = j;
     
    700704    input.open(file.str().c_str(), ios::in);
    701705    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);
    703707      return false;
    704708    }
     
    725729    // allocate last plus one matrix
    726730    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];
    728732    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]];
    730734
    731735    // try independently to parse global forcesuffix file if present
     
    754758 
    755759  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];
    757761  line << name << FRAGMENTPREFIX << FORCESFILE;
    758762  input.open(line.str().c_str(), ios::in);
    759763  //Log() << Verbose(0) << "Opening " << line.str() << " ... "  << input << endl;
    760764  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);
    762766    return false;
    763767  }
     
    767771    line.str(filename);
    768772    // parse the values
    769     Indices[i] = Malloc<int>(RowCounter[i], "HessianMatrix::ParseIndices: *Indices[]");
     773    Indices[i] = new int[RowCounter[i]];
    770774    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
    771775    //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:";
    772     Free(&FragmentNumber);
     776    delete[](FragmentNumber);
    773777    for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) {
    774778      line >> Indices[i][j];
     
    777781    //Log() << Verbose(0) << endl;
    778782  }
    779   Indices[MatrixCounter] = Malloc<int>(RowCounter[MatrixCounter], "HessianMatrix::ParseIndices: *Indices[]");
     783  Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]];
    780784  for(int j=RowCounter[MatrixCounter];j--;) {
    781785    Indices[MatrixCounter][j] = j;
     
    930934    input.open(file.str().c_str(), ios::in);
    931935    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);
    933937      return false;
    934938    }
     
    953957    // allocate last plus one matrix
    954958    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];
    956960    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]];
    958962
    959963    // try independently to parse global forcesuffix file if present
     
    985989KeySetsContainer::~KeySetsContainer() {
    986990  for(int i=FragmentCounter;i--;)
    987     Free(&KeySets[i]);
     991    delete[](KeySets[i]);
    988992  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);
    994998};
    995999
     
    10081012  FragmentCounter = FCounter;
    10091013  DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl);
    1010   KeySets = Malloc<int*>(FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets");
     1014  KeySets = new int*[FragmentCounter];
    10111015  for(int i=FragmentCounter;i--;)
    10121016    KeySets[i] = NULL;
     
    10141018  input.open(file.str().c_str(), ios::in);
    10151019  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);
    10171021    return false;
    10181022  }
    10191023
    1020   AtomCounter = Malloc<int>(FragmentCounter, "KeySetsContainer::ParseKeySets: *RowCounter");
     1024  AtomCounter = new int[FragmentCounter];
    10211025  for(int i=0;(i<FragmentCounter) && (!input.eof());i++) {
    10221026    stringstream line;
    10231027    AtomCounter[i] = ACounter[i];
    10241028    // parse the values
    1025     KeySets[i] = Malloc<int>(AtomCounter[i], "KeySetsContainer::ParseKeySets: *KeySets[]");
     1029    KeySets[i] = new int[AtomCounter[i]];
    10261030    for(int j=AtomCounter[i];j--;)
    10271031      KeySets[i][j] = -1;
    10281032    FragmentNumber = FixedDigitNumber(FragmentCounter, i);
    10291033    //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:";
    1030     Free(&FragmentNumber);
     1034    delete[](FragmentNumber);
    10311035    input.getline(filename, 1023);
    10321036    line.str(filename);
     
    10621066
    10631067  // scan through all to determine fragments per order
    1064   FragmentsPerOrder = Malloc<int>(Order, "KeySetsContainer::ParseManyBodyTerms: *FragmentsPerOrder");
     1068  FragmentsPerOrder = new int[Order];
    10651069  for(int i=Order;i--;)
    10661070    FragmentsPerOrder[i] = 0;
     
    10761080
    10771081  // scan through all to gather indices to each order set
    1078   OrderSet = Malloc<int*>(Order, "KeySetsContainer::ParseManyBodyTerms: **OrderSet");
     1082  OrderSet = new int*[Order];
    10791083  for(int i=Order;i--;)
    1080     OrderSet[i] = Malloc<int>(FragmentsPerOrder[i], "KeySetsContainer::ParseManyBodyTermsKeySetsContainer::ParseManyBodyTerms: *OrderSet[]");
     1084    OrderSet[i] = new int[FragmentsPerOrder[i]];
    10811085  for(int i=Order;i--;)
    10821086    FragmentsPerOrder[i] = 0;
  • src/periodentafel.cpp

    re58856b rf2a1d3  
    88
    99#include <iomanip>
     10#include <iostream>
    1011#include <fstream>
    1112#include <cstring>
    12 #include <cassert>
    13 
     13
     14#include "Helpers/Assert.hpp"
    1415#include "element.hpp"
     16#include "elements_db.hpp"
    1517#include "helpers.hpp"
    1618#include "lists.hpp"
     
    2729 */
    2830periodentafel::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};
    3044
    3145/** destructor for class periodentafel
    3246 * Removes every element and afterwards deletes start and end of list.
     47 * TODO: Handle when elements have changed and store databases then
    3348 */
    3449periodentafel::~periodentafel()
     
    3954/** Adds element to period table list
    4055 * \param *pointer element to be added
    41  * \return true - succeeded, false - does not occur
     56 * \return iterator to added element
    4257 */
    4358periodentafel::iterator periodentafel::AddElement(element * const pointer)
    4459{
    4560  atomicNumber_t Z = pointer->getNumber();
    46   assert(!elements.count(Z));
     61  ASSERT(!elements.count(Z), "Element is already present.");
    4762  pointer->sort = &pointer->Z;
    4863  if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS)
     
    5469/** Removes element from list.
    5570 * \param *pointer element to be removed
    56  * \return true - succeeded, false - element not found
    5771 */
    5872void periodentafel::RemoveElement(element * const pointer)
    5973{
    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 */
     80void periodentafel::RemoveElement(atomicNumber_t Z)
     81{
    6182  elements.erase(Z);
    6283};
    6384
    6485/** Removes every element from the period table.
    65  * \return true - succeeded, false - does not occur
    6686 */
    6787void periodentafel::CleanupPeriodtable()
     
    7898 * \return pointer to element or NULL if not found
    7999 */
    80 const element * periodentafel::FindElement(atomicNumber_t Z) const
     100element * const periodentafel::FindElement(atomicNumber_t Z) const
    81101{
    82102  const_iterator res = elements.find(Z);
     
    89109 * \return pointer to element
    90110 */
    91 const element * periodentafel::FindElement(const char * const shorthand) const
     111element * const periodentafel::FindElement(const char * const shorthand) const
    92112{
    93113  element *res = 0;
     
    102122
    103123/** 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 */
     126element * const periodentafel::AskElement() const
     127{
     128  element * walker = NULL;
    108129  int Z;
    109130  do {
     
    118139 * \return pointer to either present or newly created element
    119140 */
    120 const element * periodentafel::EnterElement()
    121 {
    122   const element *res = NULL;
     141element * const periodentafel::EnterElement()
     142{
    123143  atomicNumber_t Z = 0;
    124144  DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl);
    125145  cin >> Z;
    126   res = FindElement(Z);
     146  element * const res = FindElement(Z);
    127147  if (!res) {
    128148    // TODO: make this using the constructor
    129     element *tmp;
    130149    DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl);
    131     tmp = new element;
     150    element *tmp = new element;
    132151    tmp->Z = Z;
    133152    DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl);
     
    138157    cin >> tmp->symbol;
    139158    AddElement(tmp);
    140     res = tmp;
     159    return tmp;
    141160  }
    142161  return res;
     
    204223bool periodentafel::LoadPeriodentafel(const char *path)
    205224{
    206   ifstream infile;
    207   element *ptr;
    208   map<atomicNumber_t,element*> parsedElems;
     225  ifstream input;
    209226  bool status = true;
    210227  bool otherstatus = true;
     
    215232  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
    216233  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 */
     276bool 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
    221283    DoLog(0) && (Log() << Verbose(0) <<  "Parsed elements:");
    222     while (!infile.eof()) {
     284    while (!(*input).eof()) {
    223285      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      }
    244311      //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) << " <?>");
    250319        delete(neues);
    251320      }
    252321    }
    253322    DoLog(0) && (Log() << Verbose(0) << endl);
    254     infile.close();
    255     infile.clear();
    256323  } else
    257324    status = false;
    258325
    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 */
     336bool periodentafel::LoadValenceDatabase(istream *input)
     337{
     338  char dummy[MAXSTRINGSIZE];
     339  if (!(*input).fail()) {
     340    (*input).getline(dummy, MAXSTRINGSIZE);
     341    while (!(*input).eof()) {
    266342      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;
    271348      //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl;
    272349    }
    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 */
     359bool periodentafel::LoadOrbitalsDatabase(istream *input)
     360{
     361  char dummy[MAXSTRINGSIZE];
     362  if (!(*input).fail()) {
     363    (*input).getline(dummy, MAXSTRINGSIZE);
     364    while (!(*input).eof()) {
    285365      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;
    290371      //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
    291372    }
    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 */
     382bool periodentafel::LoadHBondAngleDatabase(istream *input)
     383{
     384  char dummy[MAXSTRINGSIZE];
     385  if (!(*input).fail()) {
     386    (*input).getline(dummy, MAXSTRINGSIZE);
     387    while (!(*input).eof()) {
    304388      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 */
     407bool 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;
    312421      //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
    313422    }
    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}
    356427
    357428/** Stores element list to file.
     
    374445    }
    375446    f.close();
    376   } else
    377     result = false;
    378   return result;
    379 };
     447    return true;
     448  } else
     449    return result;
     450};
  • src/periodentafel.hpp

    re58856b rf2a1d3  
    1313#include <iterator>
    1414
     15#include "unittests/periodentafelTest.hpp"
    1516#include "defs.hpp"
    1617#include "types.hpp"
     
    2728class periodentafel {
    2829  /******* Types *********/
     30  friend class periodentafelTest;
    2931  private:
    3032    typedef std::map<atomicNumber_t,element*> elementSet;
     
    4345  iterator AddElement(element * const pointer);
    4446  void RemoveElement(element * const pointer);
     47  void RemoveElement(atomicNumber_t);
    4548  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();
    5053
    5154  const_iterator begin();
     
    5962
    6063  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
    6171    elementSet elements;
    6272};
  • src/stackclass.hpp

    re58856b rf2a1d3  
    5050template <typename T> StackClass<T>::StackClass(int dimension) : StackList(NULL), EntryCount(dimension), CurrentLastEntry(0), CurrentFirstEntry(0), NextFreeField(0)
    5151{
    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;
    5355};
    5456
     
    5759template <typename T> StackClass<T>::~StackClass()
    5860{
    59   Free(&StackList);
     61  delete[](StackList);
    6062};
    6163
  • src/tesselation.cpp

    re58856b rf2a1d3  
    2121#include "Plane.hpp"
    2222#include "Exceptions/LinearDependenceException.hpp"
     23#include "Helpers/Assert.hpp"
     24
     25#include "Helpers/Assert.hpp"
    2326
    2427class molecule;
     
    8386ostream & operator <<(ostream &ost, const BoundaryPointSet &a)
    8487{
    85   ost << "[" << a.Nr << "|" << a.node->Name << " at " << *a.node->node << "]";
     88  ost << "[" << a.Nr << "|" << a.node->getName() << " at " << *a.node->node << "]";
    8689  return ost;
    8790}
     
    321324ostream & operator <<(ostream &ost, const BoundaryLineSet &a)
    322325{
    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 << "]";
    324327  return ost;
    325328}
     
    357360  // get ascending order of endpoints
    358361  PointMap OrderMap;
    359   for (int i = 0; i < 3; i++)
     362  for (int i = 0; i < 3; i++) {
    360363    // for all three lines
    361364    for (int j = 0; j < 2; j++) { // for both endpoints
     
    363366      // and we don't care whether insertion fails
    364367    }
     368  }
    365369  // set endpoints
    366370  int Counter = 0;
     
    371375    Counter++;
    372376  }
    373   if (Counter < 3) {
    374     DoeLog(0) && (eLog() << Verbose(0) << "We have a triangle with only two distinct endpoints!" << endl);
    375     performCriticalExit();
    376   }
    377 }
    378 ;
     377  ASSERT(Counter >= 3,"We have a triangle with only two distinct endpoints!");
     378};
     379
    379380
    380381/** Destructor of BoundaryTriangleSet.
     
    682683}
    683684
     685/**
     686 * gets the Plane defined by the three triangle Basepoints
     687 */
     688Plane BoundaryTriangleSet::getPlane() const{
     689  ASSERT(endpoints[0] && endpoints[1] && endpoints[2], "Triangle not fully defined");
     690
     691  return Plane(*endpoints[0]->node->node,
     692               *endpoints[1]->node->node,
     693               *endpoints[2]->node->node);
     694}
     695
     696Vector BoundaryTriangleSet::getEndpoint(int i) const{
     697  ASSERT(i>=0 && i<3,"Index of Endpoint out of Range");
     698
     699  return *endpoints[i]->node->node;
     700}
     701
     702string BoundaryTriangleSet::getEndpointName(int i) const{
     703  ASSERT(i>=0 && i<3,"Index of Endpoint out of Range");
     704
     705  return endpoints[i]->node->getName();
     706}
     707
    684708/** output operator for BoundaryTriangleSet.
    685709 * \param &ost output stream
     
    688712ostream &operator <<(ostream &ost, const BoundaryTriangleSet &a)
    689713{
    690   ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << "," << a.endpoints[1]->node->Name << "," << a.endpoints[2]->node->Name << "]";
     714  ost << "[" << a.Nr << "|" << a.getEndpointName(0) << "," << a.getEndpointName(1) << "," << a.getEndpointName(2) << "]";
    691715  //  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << ","
    692716  //      << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]";
     
    948972  ost << "[" << a.Nr << "|";
    949973  for (PointSet::const_iterator Runner = a.endpoints.begin(); Runner != a.endpoints.end();) {
    950     ost << (*Runner)->node->Name;
     974    ost << (*Runner)->node->getName();
    951975    Runner++;
    952976    if (Runner != a.endpoints.end())
     
    967991  node = NULL;
    968992  nr = -1;
    969   Name = NULL;
    970993}
    971994;
     
    9831006ostream & operator <<(ostream &ost, const TesselPoint &a)
    9841007{
    985   ost << "[" << (a.Name) << "|" << a.Name << " at " << *a.node << "]";
     1008  ost << "[" << a.getName() << "|" << *a.node << "]";
    9861009  return ost;
    9871010}
     
    11351158ostream & operator <<(ostream &ost, const CandidateForTesselation &a)
    11361159{
    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 ";
    11381161  if (a.pointlist.empty())
    11391162    ost << "no candidate.";
     
    12091232;
    12101233
    1211 /** PointCloud implementation of GetTerminalPoint.
    1212  * Uses PointsOnBoundary and STL stuff.
    1213  */
    1214 TesselPoint * Tesselation::GetTerminalPoint() const
    1215 {
    1216   Info FunctionInfo(__func__);
    1217   PointMap::const_iterator Runner = PointsOnBoundary.end();
    1218   Runner--;
    1219   return (Runner->second->node);
    1220 }
    1221 ;
    1222 
    12231234/** PointCloud implementation of GoToNext.
    12241235 * Uses PointsOnBoundary and STL stuff.
     
    12321243;
    12331244
    1234 /** PointCloud implementation of GoToPrevious.
    1235  * Uses PointsOnBoundary and STL stuff.
    1236  */
    1237 void Tesselation::GoToPrevious() const
    1238 {
    1239   Info FunctionInfo(__func__);
    1240   if (InternalPointer != PointsOnBoundary.begin())
    1241     InternalPointer--;
    1242 }
    1243 ;
    1244 
    12451245/** PointCloud implementation of GoToFirst.
    12461246 * Uses PointsOnBoundary and STL stuff.
     
    12501250  Info FunctionInfo(__func__);
    12511251  InternalPointer = PointsOnBoundary.begin();
    1252 }
    1253 ;
    1254 
    1255 /** PointCloud implementation of GoToLast.
    1256  * Uses PointsOnBoundary and STL stuff.
    1257  */
    1258 void Tesselation::GoToLast() const
    1259 {
    1260   Info FunctionInfo(__func__);
    1261   InternalPointer = PointsOnBoundary.end();
    1262   InternalPointer--;
    12631252}
    12641253;
     
    13481337      if (fabs(distance) < 1e-4) // we need to have a small epsilon around 0 which is still ok
    13491338        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);
    13511340      tmp = distance / fabs(distance);
    13521341      // 4b. Any have different sign to than before? (i.e. would lie outside convex hull with this starting triangle)
    13531342      if ((sign != 0) && (tmp != sign)) {
    13541343        // 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);
    13561345        break;
    13571346      } 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);
    13591348        sign = tmp;
    13601349      }
     
    14561445        CenterVector.Zero();
    14571446        for (int i = 0; i < 3; i++)
    1458           CenterVector += (*BTS->endpoints[i]->node->node);
     1447          CenterVector += BTS->getEndpoint(i);
    14591448        CenterVector.Scale(1. / 3.);
    14601449        DoLog(2) && (Log() << Verbose(2) << "CenterVector of base triangle is " << CenterVector << endl);
     
    19331922        RemoveTesselationLine(triangle->lines[i]);
    19341923      } 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);
    19361925        OpenLines.insert(pair<BoundaryLineSet *, CandidateForTesselation *> (triangle->lines[i], NULL));
    19371926        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");
    19391928        DoLog(0) && (Log() << Verbose(0) << endl);
    19401929        //        for (int j=0;j<2;j++) {
     
    25702559  // fill the set of neighbours
    25712560  TesselPointSet SetOfNeighbours;
     2561
    25722562  SetOfNeighbours.insert(CandidateLine.BaseLine->endpoints[1]->node);
    25732563  for (TesselPointList::iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); Runner++)
     
    29892979  OldBaseLineNr = Base->Nr;
    29902980  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);
    29952991  }
    29962992
     
    42924288        DoLog(2) && (Log() << Verbose(2) << "INFO: MiddleNode is " << **MiddleNode << "." << endl);
    42934289        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);
    42954291        TriangleCandidates[0] = *StartNode;
    42964292        TriangleCandidates[1] = *MiddleNode;
     
    47144710    return;
    47154711  }
    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);
    47174713
    47184714  // go through its lines and find the best one to split
     
    47994795  ofstream *tempstream = NULL;
    48004796  string NameofTempFile;
    4801   char NumberName[255];
     4797  string NumberName;
    48024798
    48034799  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();
    48054803    if (DoTecplotOutput) {
    48064804      string NameofTempFile(filename);
  • src/tesselation.hpp

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

    re58856b rf2a1d3  
    1616#include "vector_ops.hpp"
    1717#include "verbose.hpp"
     18#include "Plane.hpp"
    1819
    1920double DetGet(gsl_matrix * const A, const int inPlace)
     
    687688    return -1;
    688689  }
    689   distance = x->DistanceToPlane(triangle->NormalVector, *triangle->endpoints[0]->node->node);
     690  distance = x->DistanceToSpace(triangle->getPlane());
    690691  return distance;
    691692};
     
    784785      Walker = cloud->GetPoint();
    785786      *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      }
    788791      *rasterfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
    789792      cloud->GoToNext();
     
    795798      *rasterfile << "1" << endl << "  ";  // 1 is triangle type
    796799      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        }
    799804        *rasterfile << "\t";
    800805      }
     
    829834      if (TesselStruct->LastTriangle != NULL) {
    830835        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();
    832837      } else {
    833838        *tecplot << "none";
     
    835840    }
    836841    *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++){
    840845      LookupList[i] = -1;
     846    }
    841847
    842848    // print atom coordinates
    843849    int Counter = 1;
    844850    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) {
    846852      Walker = target->second->node;
    847853      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;
    849859    }
    850860    *tecplot << endl;
     
    852862    DoLog(1) && (Log() << Verbose(1) << "The following triangles were created:" << endl);
    853863    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);
    855865      *tecplot << LookupList[runner->second->endpoints[0]->node->nr] << " " << LookupList[runner->second->endpoints[1]->node->nr] << " " << LookupList[runner->second->endpoints[2]->node->nr] << endl;
    856866    }
  • src/unittests/ActOnAllUnitTest.cpp

    re58856b rf2a1d3  
    4646  // Ref was copy constructed, hence has to be cleaned, too!
    4747  Ref.EmptyList();
    48   MemoryUsageObserver::purgeInstance();
    4948};
    5049
     
    7776
    7877  // 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];
    8180  for (int i=0;i<NDIM;++i) {
    8281    factors[i] = 2.;
     
    8887  VL.ActOnAll<Vector,void,const double*>(&Vector::ScaleAll, inverses );
    8988  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
    90   Free(factors);
    91   Free(inverses);
     89  delete[](factors);
     90  delete[](inverses);
    9291};
    9392
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    re58856b rf2a1d3  
    1717#include "AnalysisCorrelationToPointUnitTest.hpp"
    1818
    19 #include "World.hpp"
    2019#include "atom.hpp"
    21 #include "boundary.hpp"
    2220#include "element.hpp"
    2321#include "molecule.hpp"
    2422#include "linkedcell.hpp"
    2523#include "periodentafel.hpp"
    26 #include "tesselation.hpp"
    2724#include "World.hpp"
    2825
     
    4340  TestList = NULL;
    4441  TestMolecule = NULL;
    45   hydrogen = NULL;
    46   tafel = NULL;
    4742  pointmap = NULL;
    4843  binmap = NULL;
    4944  point = NULL;
    5045
    51   // construct element
    52   hydrogen = new element;
    53   hydrogen->Z = 1;
    54   strcpy(hydrogen->name, "hydrogen");
    55   strcpy(hydrogen->symbol, "H");
    56 
    57 
    58   // construct periodentafel
    59   tafel = World::getInstance().getPeriode();
    60   tafel->AddElement(hydrogen);
    61 
    6246  // construct molecule (tetraeder of hydrogens)
     47  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     48  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
    6349  TestMolecule = World::getInstance().createMolecule();
    6450  Walker = World::getInstance().createAtom();
     
    8066
    8167  // check that TestMolecule was correctly constructed
    82   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
     68  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    8369
    8470  TestList = World::getInstance().getMolecules();
     
    10591  delete(point);
    10692  World::purgeInstance();
    107   MemoryUsageObserver::purgeInstance();
    10893  logger::purgeInstance();
    10994};
  • src/unittests/AnalysisCorrelationToPointUnitTest.hpp

    re58856b rf2a1d3  
    1212
    1313class element;
    14 class LinkedCell;
    1514class molecule;
    1615class MoleculeListClass;
    17 class periodentafel;
    18 class Tesselation;
    1916class Vector;
    2017
     
    4037      MoleculeListClass *TestList;
    4138      molecule *TestMolecule;
    42       element *hydrogen;
    43       periodentafel *tafel;
     39      const element *hydrogen;
    4440
    4541      CorrelationToPointMap *pointmap;
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    re58856b rf2a1d3  
    1717#include "AnalysisCorrelationToSurfaceUnitTest.hpp"
    1818
    19 #include "World.hpp"
    2019#include "atom.hpp"
    2120#include "boundary.hpp"
     
    2625#include "tesselation.hpp"
    2726#include "World.hpp"
     27#include "Helpers/Assert.hpp"
    2828
    2929#include "Helpers/Assert.hpp"
     
    4040void AnalysisCorrelationToSurfaceUnitTest::setUp()
    4141{
    42   //ASSERT_DO(Assert::Throw);
     42  ASSERT_DO(Assert::Throw);
    4343
    4444  atom *Walker = NULL;
     
    4747  TestList = NULL;
    4848  TestSurfaceMolecule = NULL;
    49   hydrogen = NULL;
    50   tafel = NULL;
    5149  surfacemap = NULL;
    5250  binmap = NULL;
     
    5452  LC = NULL;
    5553
    56   // construct element
    57   hydrogen = new element;
    58   hydrogen->Z = 1;
    59   strcpy(hydrogen->name, "hydrogen");
    60   strcpy(hydrogen->symbol, "H");
    61   carbon = new element;
    62   carbon->Z = 6;
    63   strcpy(carbon->name, "carbon");
    64   strcpy(carbon->symbol, "C");
    65 
    66   // construct periodentafel
    67   tafel = World::getInstance().getPeriode();
    68   tafel->AddElement(hydrogen);
    69   tafel->AddElement(carbon);
    70 
    7154  // construct molecule (tetraeder of hydrogens) base
     55  hydrogen = World::getInstance().getPeriode()->FindElement(1);
    7256  TestSurfaceMolecule = World::getInstance().createMolecule();
     57
    7358  Walker = World::getInstance().createAtom();
    7459  Walker->type = hydrogen;
    7560  *Walker->node = Vector(1., 0., 1. );
    76 
    77   TestSurfaceMolecule->AddAtom(Walker);
     61  TestSurfaceMolecule->AddAtom(Walker);
     62
    7863  Walker = World::getInstance().createAtom();
    7964  Walker->type = hydrogen;
    8065  *Walker->node = Vector(0., 1., 1. );
    8166  TestSurfaceMolecule->AddAtom(Walker);
     67
    8268  Walker = World::getInstance().createAtom();
    8369  Walker->type = hydrogen;
    8470  *Walker->node = Vector(1., 1., 0. );
    8571  TestSurfaceMolecule->AddAtom(Walker);
     72
    8673  Walker = World::getInstance().createAtom();
    8774  Walker->type = hydrogen;
     
    9077
    9178  // check that TestMolecule was correctly constructed
    92   CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->AtomCount, 4 );
     79  CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 );
    9380
    9481  TestList = World::getInstance().getMolecules();
     
    10289
    10390  // add outer atoms
     91  carbon = World::getInstance().getPeriode()->FindElement(6);
    10492  TestSurfaceMolecule = World::getInstance().createMolecule();
    10593  Walker = World::getInstance().createAtom();
     
    10795  *Walker->node = Vector(4., 0., 4. );
    10896  TestSurfaceMolecule->AddAtom(Walker);
     97
    10998  Walker = World::getInstance().createAtom();
    11099  Walker->type = carbon;
    111100  *Walker->node = Vector(0., 4., 4. );
    112101  TestSurfaceMolecule->AddAtom(Walker);
     102
    113103  Walker = World::getInstance().createAtom();
    114104  Walker->type = carbon;
    115105  *Walker->node = Vector(4., 4., 0. );
    116106  TestSurfaceMolecule->AddAtom(Walker);
     107
    117108  // add inner atoms
    118109  Walker = World::getInstance().createAtom();
     
    120111  *Walker->node = Vector(0.5, 0.5, 0.5 );
    121112  TestSurfaceMolecule->AddAtom(Walker);
     113
    122114  TestSurfaceMolecule->ActiveFlag = true;
    123115  TestList->insert(TestSurfaceMolecule);
     
    141133  delete(LC);
    142134  World::purgeInstance();
    143   MemoryUsageObserver::purgeInstance();
    144135  logger::purgeInstance();
    145136};
     
    150141void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest()
    151142{
    152   CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->AtomCount );
     143  CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() );
    153144  CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );
    154145  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp

    re58856b rf2a1d3  
    4545      MoleculeListClass *TestList;
    4646      molecule *TestSurfaceMolecule;
    47       element *hydrogen;
    48       element *carbon;
    49       periodentafel *tafel;
     47      const element *hydrogen;
     48      const element *carbon;
    5049
    5150      CorrelationToSurfaceMap *surfacemap;
  • src/unittests/AnalysisPairCorrelationUnitTest.cpp

    re58856b rf2a1d3  
    4444  TestList = NULL;
    4545  TestMolecule = NULL;
    46   hydrogen = NULL;
    47   tafel = NULL;
    4846  correlationmap = NULL;
    4947  binmap = NULL;
    5048
    51   // construct element
    52   hydrogen = new element;
    53   hydrogen->Z = 1;
    54   strcpy(hydrogen->name, "hydrogen");
    55   strcpy(hydrogen->symbol, "H");
    56 
    57   // construct periodentafel
    58   tafel = World::getInstance().getPeriode();
    59   tafel->AddElement(hydrogen);
    60 
    6149  // construct molecule (tetraeder of hydrogens)
     50  hydrogen = World::getInstance().getPeriode()->FindElement(1);
    6251  TestMolecule = World::getInstance().createMolecule();
    6352  Walker = World::getInstance().createAtom();
     
    7968
    8069  // check that TestMolecule was correctly constructed
    81   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
     70  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    8271
    8372  TestList = World::getInstance().getMolecules();
     
    10190  // note that all the atoms are cleaned by TestMolecule
    10291  World::purgeInstance();
    103   MemoryUsageObserver::purgeInstance();
    10492  logger::purgeInstance();
    10593  errorLogger::purgeInstance();
  • src/unittests/AnalysisPairCorrelationUnitTest.hpp

    re58856b rf2a1d3  
    1212
    1313class element;
    14 class LinkedCell;
    1514class molecule;
    1615class MoleculeListClass;
    17 class periodentafel;
    18 class Tesselation;
    1916class Vector;
    2017
     
    4037      MoleculeListClass *TestList;
    4138      molecule *TestMolecule;
    42       element *hydrogen;
    43       periodentafel *tafel;
     39      const element *hydrogen;
    4440
    4541      PairCorrelationMap *correlationmap;
  • src/unittests/CountBondsUnitTest.cpp

    re58856b rf2a1d3  
    1616#include <stdio.h>
    1717#include <cstring>
     18
     19#include "Helpers/Assert.hpp"
    1820
    1921#include "analysis_bonds.hpp"
     
    4042{
    4143  atom *Walker = NULL;
    42   BG = NULL;
    43   filename = NULL;
    44 
    45   // init private all pointers to zero
    46   molecules = NULL;
    47   TestMolecule1 = NULL;
    48   TestMolecule2 = NULL;
    49   hydrogen = NULL;
    50   oxygen = NULL;
    51   tafel = NULL;
    5244
    5345  // 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");
    6950
    7051  // construct molecule (water molecule)
    7152  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");
    7356  Walker->type = hydrogen;
    7457  *Walker->node = Vector(-0.2418, 0.9350, 0. );
    7558  TestMolecule1->AddAtom(Walker);
    7659  Walker = World::getInstance().createAtom();
     60  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7761  Walker->type = hydrogen;
    7862  *Walker->node = Vector(0.9658, 0., 0. );
    7963  TestMolecule1->AddAtom(Walker);
    8064  Walker = World::getInstance().createAtom();
     65  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8166  Walker->type = oxygen;
    8267  *Walker->node = Vector(0., 0., 0. );
     
    8469
    8570  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");
    8774  Walker->type = hydrogen;
    8875  *Walker->node = Vector(-0.2418, 0.9350, 0. );
    8976  TestMolecule2->AddAtom(Walker);
    9077  Walker = World::getInstance().createAtom();
     78  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    9179  Walker->type = hydrogen;
    9280  *Walker->node = Vector(0.9658, 0., 0. );
    9381  TestMolecule2->AddAtom(Walker);
    9482  Walker = World::getInstance().createAtom();
     83  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    9584  Walker->type = oxygen;
    9685  *Walker->node = Vector(0., 0., 0. );
     
    9887
    9988  molecules = World::getInstance().getMolecules();
     89  CPPUNIT_ASSERT(molecules != NULL && "could not obtain list of molecules");
    10090  molecules->insert(TestMolecule1);
    10191  molecules->insert(TestMolecule2);
    10292
    10393  // 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 );
    11096
    11197  // create a small file with table
    11298  BG = new BondGraph(true);
     99  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    113100
    114101  // construct bond graphs
     
    126113
    127114  World::purgeInstance();
    128   MemoryUsageObserver::purgeInstance();
    129115};
    130116
     
    158144{
    159145  double *mirror = new double[3];
     146  CPPUNIT_ASSERT(mirror != NULL && "could not create array of doubles");
    160147  for (int i=0;i<3;i++)
    161148    mirror[i] = -1.;
  • src/unittests/CountBondsUnitTest.hpp

    re58856b rf2a1d3  
    3939      molecule *TestMolecule1;
    4040      molecule *TestMolecule2;
    41       element *hydrogen;
    42       element *oxygen;
    43       periodentafel *tafel;
     41      const element *hydrogen;
     42      const element *oxygen;
    4443
    4544      BondGraph *BG;
  • src/unittests/LinkedCellUnitTest.cpp

    re58856b rf2a1d3  
    3838  atom *Walker = NULL;
    3939
    40   // init private all pointers to zero
    41   TestMolecule = NULL;
    42   hydrogen = NULL;
    43   tafel = NULL;
    44 
    4540  // 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");
    5543
    5644  // construct molecule (water molecule)
    5745  TestMolecule = World::getInstance().createMolecule();
     46  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
    5847  for (double x=0.5;x<3;x+=1.)
    5948    for (double y=0.5;y<3;y+=1.)
    6049      for (double z=0.5;z<3;z+=1.) {
    6150        Walker = World::getInstance().createAtom();
     51        CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    6252        Walker->type = hydrogen;
    6353        *Walker->node = Vector(x, y, z );
     
    6757  // construct linked cell
    6858  LC = new LinkedCell (TestMolecule, 1.);
     59  CPPUNIT_ASSERT(LC != NULL && "could not create LinkedCell");
    6960
    7061  // 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 );
    7463};
    7564
     
    7968  delete(LC);
    8069  World::purgeInstance();
    81   MemoryUsageObserver::purgeInstance();
    8270};
    8371
     
    197185{
    198186  // 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) );
    203189  }
    204190
    205191  // 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);
    212197
    213198  // 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);
    220204};
    221205
     
    289273  size = ListOfPoints->size();
    290274  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));
    296278    size--;
    297279    CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
     
    308290  size=ListOfPoints->size();
    309291  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);
    315295      size--;
    316296      CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
     
    328308  size=ListOfPoints->size();
    329309  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);
    334312    size--;
    335313    CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
     
    357335  size = ListOfPoints->size();
    358336  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);
    364340      size--;
    365341      CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
  • src/unittests/LinkedCellUnitTest.hpp

    re58856b rf2a1d3  
    4848
    4949      molecule *TestMolecule;
    50       element *hydrogen;
    51       periodentafel *tafel;
     50      const element *hydrogen;
    5251      LinkedCell *LC;
    5352};
  • src/unittests/Makefile.am

    re58856b rf2a1d3  
    3333  MemoryAllocatorUnitTest \
    3434  MoleculeDescriptorTest \
    35   PlaneUnittest \
    3635  ObserverTest \
    3736  ParserUnitTest \
     37  periodentafelTest \
     38  PlaneUnittest \
    3839  SingletonTest \
    3940  StackClassUnitTest \
     
    4849noinst_PROGRAMS = $(TESTS) TestRunner
    4950
    50 GSLLIBS = ../libgslwrapper.a
    51 ALLLIBS = ../libmolecuilder.a ${GSLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB}
     51GSLLIBS = ../libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
     52ALLLIBS = ../libmolecuilder.a ${GSLLIBS}
    5253
    5354TESTSOURCES = \
     
    7576  memoryusageobserverunittest.cpp \
    7677  MoleculeDescriptorTest.cpp \
    77   PlaneUnittest.cpp \
    7878  ObserverTest.cpp \
    7979  ParserUnitTest.cpp \
     80  periodentafelTest.cpp \
     81  PlaneUnittest.cpp \
    8082  SingletonTest.cpp \
    8183  stackclassunittest.cpp \
     
    109111  memoryusageobserverunittest.hpp \
    110112  MoleculeDescriptorTest.hpp \
     113  periodentafelTest.hpp \
    111114  PlaneUnittest.hpp \
    112115  ObserverTest.hpp \
     
    179182manipulateAtomsTest_LDADD = ${ALLLIBS}
    180183
    181 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp
     184MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp
    182185MemoryAllocatorUnitTest_LDADD = ${ALLLIBS}
    183186
    184 MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp
     187MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp
    185188MemoryUsageObserverUnitTest_LDADD = ${ALLLIBS}
    186189
     
    194197ParserUnitTest_LDADD = ${ALLLIBS}
    195198
     199periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp
     200periodentafelTest_LDADD = ${ALLLIBS}
     201
    196202PlaneUnittest_SOURCES = UnitTestMain.cpp PlaneUnittest.cpp PlaneUnittest.hpp
    197203PlaneUnittest_LDADD = ${ALLLIBS}
     
    212218Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS}
    213219
    214 TestRunner_SOURCES = TestRunnerMain.cpp $(TESTSOURCES) $(TESTHEADERS)
     220TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp $(TESTSOURCES) $(TESTHEADERS)
    215221TestRunner_LDADD = ${ALLLIBS}
    216222
  • src/unittests/ObserverTest.cpp

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

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

    re58856b rf2a1d3  
    3131
    3232void 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();
    4234}
    4335
  • src/unittests/analysisbondsunittest.cpp

    re58856b rf2a1d3  
    2525#include "molecule.hpp"
    2626#include "periodentafel.hpp"
     27#include "World.hpp"
    2728
    2829#ifdef HAVE_TESTRUNNER
     
    4041  atom *Walker = NULL;
    4142
    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");
    6648
    6749  // construct molecule (tetraeder of hydrogens)
    6850  TestMolecule = World::getInstance().createMolecule();
     51  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
    6952  Walker = World::getInstance().createAtom();
     53  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7054  Walker->type = hydrogen;
    7155  *Walker->node = Vector(1.5, 0., 1.5 );
    7256  TestMolecule->AddAtom(Walker);
    7357  Walker = World::getInstance().createAtom();
     58  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7459  Walker->type = hydrogen;
    7560  *Walker->node = Vector(0., 1.5, 1.5 );
    7661  TestMolecule->AddAtom(Walker);
    7762  Walker = World::getInstance().createAtom();
     63  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7864  Walker->type = hydrogen;
    7965  *Walker->node = Vector(1.5, 1.5, 0. );
    8066  TestMolecule->AddAtom(Walker);
    8167  Walker = World::getInstance().createAtom();
     68  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8269  Walker->type = hydrogen;
    8370  *Walker->node = Vector(0., 0., 0. );
    8471  TestMolecule->AddAtom(Walker);
    8572  Walker = World::getInstance().createAtom();
     73  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8674  Walker->type = carbon;
    8775  *Walker->node = Vector(0.5, 0.5, 0.5 );
     
    8977
    9078  // check that TestMolecule was correctly constructed
    91   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 5 );
     79  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 5 );
    9280
    9381  // create a small file with table
    9482  filename = new string("test.dat");
     83  CPPUNIT_ASSERT(filename != NULL && "could not create string");
    9584  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";
    9992  test.close();
    10093  BG = new BondGraph(true);
     94  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    10195
    10296  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    10397  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) );
    106100
    107101  BG->ConstructBondGraph(TestMolecule);
  • src/unittests/analysisbondsunittest.hpp

    re58856b rf2a1d3  
    3434
    3535      molecule *TestMolecule;
    36       element *hydrogen;
    37       element *carbon;
    38       periodentafel *tafel;
     36      const element *hydrogen;
     37      const element *carbon;
    3938
    4039      BondGraph *BG;
  • src/unittests/bondgraphunittest.cpp

    re58856b rf2a1d3  
    1515#include <stdio.h>
    1616#include <cstring>
     17
     18#include "Helpers/Assert.hpp"
    1719
    1820#include "World.hpp"
     
    4143  atom *Walker = NULL;
    4244
    43   // init private all pointers to zero
    44   TestMolecule = NULL;
    45   hydrogen = NULL;
    46   tafel = NULL;
    47 
    4845  // 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");
    6750
    6851  // construct molecule (tetraeder of hydrogens)
    6952  TestMolecule = World::getInstance().createMolecule();
     53  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
    7054  Walker = World::getInstance().createAtom();
     55  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7156  Walker->type = carbon;
    7257  *Walker->node = Vector(1., 0., 1. );
     
    7459
    7560  Walker = World::getInstance().createAtom();
     61  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7662  Walker->type = carbon;
    7763  *Walker->node = Vector(0., 1., 1. );
     
    7965
    8066  Walker = World::getInstance().createAtom();
     67  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8168  Walker->type = carbon;
    8269  *Walker->node = Vector(1., 1., 0. );
     
    8471
    8572  Walker = World::getInstance().createAtom();
     73  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8674  Walker->type = carbon;
    8775  *Walker->node = Vector(0., 0., 0. );
     
    8977
    9078  // check that TestMolecule was correctly constructed
    91   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
     79  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    9280
    9381  // create a small file with table
    9482  dummyname = new string("dummy.dat");
     83  CPPUNIT_ASSERT(dummyname != NULL && "could not create string");
    9584  filename = new string("test.dat");
     85  CPPUNIT_ASSERT(filename != NULL && "could not create string");
    9686  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";
    10094  test.close();
    10195  BG = new BondGraph(true);
     96  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    10297};
    10398
     
    116111  // are all cleaned when the world is destroyed
    117112  World::purgeInstance();
    118   MemoryUsageObserver::purgeInstance();
    119113  logger::purgeInstance();
     114};
     115
     116/** Tests whether setup worked.
     117 */
     118void BondGraphTest::SetupTest()
     119{
     120  CPPUNIT_ASSERT_EQUAL (false, TestMolecule->empty());
     121  CPPUNIT_ASSERT_EQUAL ((size_t)4, TestMolecule->size());
    120122};
    121123
     
    126128  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    127129  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) );
    130132};
    131133
     
    134136void BondGraphTest::ConstructGraphFromTableTest()
    135137{
    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++;
    139141  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    140142  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    141   CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
     143  CPPUNIT_ASSERT_EQUAL( true , (*Walker)->IsBondedTo((*Runner)) );
    142144};
    143145
     
    146148void BondGraphTest::ConstructGraphFromCovalentRadiiTest()
    147149{
    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 );
    151154  CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) );
    152155  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) );
    154159};
    155160
  • src/unittests/bondgraphunittest.hpp

    re58856b rf2a1d3  
    2222{
    2323    CPPUNIT_TEST_SUITE( BondGraphTest) ;
     24    CPPUNIT_TEST ( SetupTest );
    2425    CPPUNIT_TEST ( LoadTableTest );
    2526    CPPUNIT_TEST ( ConstructGraphFromTableTest );
     
    3031      void setUp();
    3132      void tearDown();
     33      void SetupTest();
    3234      void LoadTableTest();
    3335      void ConstructGraphFromTableTest();
     
    3739
    3840      molecule *TestMolecule;
    39       element *hydrogen;
    40       element *carbon;
    41       periodentafel *tafel;
     41      const element *hydrogen;
     42      const element *carbon;
    4243
    4344      BondGraph *BG;
  • src/unittests/listofbondsunittest.cpp

    re58856b rf2a1d3  
    3838  atom *Walker = NULL;
    3939
    40   // init private all pointers to zero
    41   TestMolecule = NULL;
    42   hydrogen = NULL;
    43   tafel = NULL;
    44 
    4540  // 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");
    5543
    5644  // construct molecule (tetraeder of hydrogens)
    5745  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");
    5949  Walker->type = hydrogen;
    6050  *Walker->node = Vector(1., 0., 1. );
    6151  TestMolecule->AddAtom(Walker);
    6252  Walker = World::getInstance().createAtom();
     53  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    6354  Walker->type = hydrogen;
    6455  *Walker->node = Vector(0., 1., 1. );
    6556  TestMolecule->AddAtom(Walker);
    6657  Walker = World::getInstance().createAtom();
     58  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    6759  Walker->type = hydrogen;
    6860  *Walker->node = Vector(1., 1., 0. );
    6961  TestMolecule->AddAtom(Walker);
    7062  Walker = World::getInstance().createAtom();
     63  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7164  Walker->type = hydrogen;
    7265  *Walker->node = Vector(0., 0., 0. );
     
    7467
    7568  // check that TestMolecule was correctly constructed
    76   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    77 
     69  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    7870};
    7971
     
    8678  // are all cleaned when the world is destroyed
    8779  World::purgeInstance();
    88   MemoryUsageObserver::purgeInstance();
    8980  logger::purgeInstance();
    9081};
    9182
     83/** Tests whether setup worked correctly.
     84 *
     85 */
     86void ListOfBondsTest::SetupTest()
     87{
     88  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->empty() );
     89  CPPUNIT_ASSERT_EQUAL( (size_t)4, TestMolecule->size() );
     90};
     91
    9292/** Unit Test of molecule::AddBond()
    9393 *
     
    9696{
    9797  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() );
    108109
    109110  // check that bond contains the two atoms
     
    124125{
    125126  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;
    128131  CPPUNIT_ASSERT( atom1 != NULL );
    129132  CPPUNIT_ASSERT( atom2 != NULL );
     
    141144
    142145  // check if removed from molecule
    143   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
     146  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
    144147};
    145148
     
    150153{
    151154  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;
    155161  CPPUNIT_ASSERT( atom1 != NULL );
    156162  CPPUNIT_ASSERT( atom2 != NULL );
     
    179185
    180186  // 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() );
    183189};
    184190
     
    189195{
    190196  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;
    193201  CPPUNIT_ASSERT( atom1 != NULL );
    194202  CPPUNIT_ASSERT( atom2 != NULL );
     
    206214
    207215  // check if removed from molecule
    208   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
     216  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
    209217};
    210218
     
    215223{
    216224  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;
    219229  CPPUNIT_ASSERT( atom1 != NULL );
    220230  CPPUNIT_ASSERT( atom2 != NULL );
     
    231241
    232242  // check if removed from molecule
    233   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
     243  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
    234244};
    235245
     
    240250{
    241251  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;
    244256  CPPUNIT_ASSERT( atom1 != NULL );
    245257  CPPUNIT_ASSERT( atom2 != NULL );
     
    256268
    257269  // 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  
    2020{
    2121    CPPUNIT_TEST_SUITE( ListOfBondsTest) ;
     22    CPPUNIT_TEST ( SetupTest );
    2223    CPPUNIT_TEST ( AddingBondTest );
    2324    CPPUNIT_TEST ( RemovingBondTest );
     
    3132      void setUp();
    3233      void tearDown();
     34      void SetupTest();
    3335      void AddingBondTest();
    3436      void RemovingBondTest();
     
    4143
    4244      molecule *TestMolecule;
    43       element *hydrogen;
    44       periodentafel *tafel;
     45      const element *hydrogen;
    4546};
    4647
  • src/unittests/memoryallocatorunittest.cpp

    re58856b rf2a1d3  
    1212#include "memoryallocator.hpp"
    1313#include "memoryallocatorunittest.hpp"
     14#include "memoryusageobserver.hpp"
    1415#include "helpers.hpp"
    1516#include "log.hpp"
  • src/unittests/stackclassunittest.cpp

    re58856b rf2a1d3  
    3737  Stack->ClearStack();
    3838  delete(Stack);
    39   MemoryUsageObserver::purgeInstance();
    4039  logger::purgeInstance();
    4140};
  • src/unittests/tesselation_boundarytriangleunittest.cpp

    re58856b rf2a1d3  
    3737  tesselpoints[0] = new TesselPoint;
    3838  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");
    4140  tesselpoints[0]->nr = 1;
    4241  points[0] = new BoundaryPointSet(tesselpoints[0]);
    4342  tesselpoints[1] = new TesselPoint;
    4443  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");
    4745  tesselpoints[1]->nr = 2;
    4846  points[1] = new BoundaryPointSet(tesselpoints[1]);
    4947  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;
    5451  points[2] = new BoundaryPointSet(tesselpoints[2] );
    5552
     
    7370    delete tesselpoints[i];
    7471  }
    75   MemoryUsageObserver::purgeInstance();
    7672  logger::purgeInstance();
    7773  errorLogger::purgeInstance();
  • src/unittests/tesselation_insideoutsideunittest.cpp

    re58856b rf2a1d3  
    3838  Walker = new TesselPoint;
    3939  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");
    4241  Walker->nr = 1;
    4342  Corners.push_back(Walker);
    4443  Walker = new TesselPoint;
    4544  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");
    4846  Walker->nr = 2;
    4947  Corners.push_back(Walker);
    5048  Walker = new TesselPoint;
    5149  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");
    5451  Walker->nr = 3;
    5552  Corners.push_back(Walker);
    5653  Walker = new TesselPoint;
    5754  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");
    6056  Walker->nr = 4;
    6157  Corners.push_back(Walker);
    6258  Walker = new TesselPoint;
    6359  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");
    6661  Walker->nr = 5;
    6762  Corners.push_back(Walker);
    6863  Walker = new TesselPoint;
    6964  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");
    7266  Walker->nr = 6;
    7367  Corners.push_back(Walker);
    7468  Walker = new TesselPoint;
    7569  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");
    7871  Walker->nr = 7;
    7972  Corners.push_back(Walker);
    8073  Walker = new TesselPoint;
    8174  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");
    8476  Walker->nr = 8;
    8577  Corners.push_back(Walker);
     
    142134  }
    143135  Corners.clear();
    144   MemoryUsageObserver::purgeInstance();
    145136  logger::purgeInstance();
    146137  errorLogger::purgeInstance();
  • src/unittests/tesselationunittest.cpp

    re58856b rf2a1d3  
    3737  Walker = new TesselPoint;
    3838  Walker->node = new Vector(1., 0., -1.);
    39   Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
    40   strcpy(Walker->Name, "1");
     39  Walker->setName("1");
    4140  Walker->nr = 1;
    4241  Corners.push_back(Walker);
    4342  Walker = new TesselPoint;
    4443  Walker->node = new Vector(-1., 1., -1.);
    45   Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
    46   strcpy(Walker->Name, "2");
     44  Walker->setName("2");
    4745  Walker->nr = 2;
    4846  Corners.push_back(Walker);
    4947  Walker = new TesselPoint;
    5048  Walker->node = new Vector(-1., -1., -1.);
    51   Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
    52   strcpy(Walker->Name, "3");
     49  Walker->setName("3");
    5350  Walker->nr = 3;
    5451  Corners.push_back(Walker);
    5552  Walker = new TesselPoint;
    5653  Walker->node = new Vector(-1., 0., 1.);
    57   Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
    58   strcpy(Walker->Name, "4");
     54  Walker->setName("4");
    5955  Walker->nr = 4;
    6056  Corners.push_back(Walker);
     
    110106  }
    111107  Corners.clear();
    112   MemoryUsageObserver::purgeInstance();
    113108  logger::purgeInstance();
    114109  errorLogger::purgeInstance();
  • src/unittests/vectorunittest.cpp

    re58856b rf2a1d3  
    4949void VectorTest::tearDown()
    5050{
    51   MemoryUsageObserver::purgeInstance();
    5251  logger::purgeInstance();
    5352  errorLogger::purgeInstance();
  • src/vector.cpp

    re58856b rf2a1d3  
    266266 * \return distance to plane
    267267 */
    268 double Vector::DistanceToPlane(const Vector &PlaneNormal, const Vector &PlaneOffset) const
    269 {
    270   return GetDistanceVectorToPlane(PlaneNormal,PlaneOffset).Norm();
     268double Vector::DistanceToSpace(const Space &space) const
     269{
     270  return space.distance(*this);
    271271};
    272272
     
    543543  // truncate to [0,1] for each axis
    544544  for (int i=0;i<NDIM;i++) {
    545     x[i] += 0.5;  // set to center of box
     545    //x[i] += 0.5;  // set to center of box
    546546    while (x[i] >= 1.)
    547547      x[i] -= 1.;
  • src/vector.hpp

    re58856b rf2a1d3  
    4040  double DistanceSquared(const Vector &y) const;
    4141  Vector GetDistanceVectorToPlane(const Vector &PlaneNormal, const Vector &PlaneOffset) const;
    42   double DistanceToPlane(const Vector &PlaneNormal, const Vector &PlaneOffset) const;
     42  double DistanceToSpace(const Space& space) const;
    4343  double PeriodicDistance(const Vector &y, const double * const cell_size) const;
    4444  double PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const;
  • tests/Makefile.am

    re58856b rf2a1d3  
    1 AUTOM4TE = autom4te
    2 EXTRA_DIST = testsuite.at $(TESTSUITE) atlocal.in regression
    3 TESTSUITE = $(srcdir)/testsuite
     1SUBDIRS = regression Tesselations
    42
    5 SUBDIRS = Tesselations
    6 
    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)' --clean
    17 
    18 AUTOTEST = $(AUTOM4TE) --language=autotest
    19 $(TESTSUITE): $(srcdir)/testsuite.at
    20                 $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
    21                 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.ac
    25                         :;{ \
    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  
    3030        CLEANUP="$CLEANUP; rm -rf $testdir"
    3131        cp -r @srcdir@/$testdir/* $testdir/
    32         cd $testdir
    3332        CLEANUP="rm -f stderr stdout diffstderr diffstdout; cd ..; $CLEANUP"
    3433        CLEANUP="rm -f *.conf*; rm -f NonConvexEnvelope*; rm -f ${testdir}.xyz; rm -f ${testdir}.dbond; $CLEANUP"
     
    5251        FILENAME="NonConvexEnvelope"
    5352        exitcode=0
    54         cd $RADIUS
     53        cd $testdir/$RADIUS
    5554        #echo "Current dir is `pwd`, calling $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME."
    5655        if [ -e $mol.dbond ]; then
     
    6867        #cat diffstderr
    6968        #cat diffstdout
    70         cd ..
     69        cd ../..
    7170        test $exitcode = $expected_exitcode || exit 1
    7271}
  • tests/regression/Tesselation/1/post/NonConvexEnvelope.r3d

    re58856b rf2a1d3  
    33# All atoms as spheres
    442
    5   1.37419 -0.26503 -4.44089e-16         0.1     1. 1. 1.
     5  1.24926 -0.870237 -0.89       0.1     1. 1. 1.
    662
    7   0.12489 0.61837 -4.44089e-16  0.1     1. 1. 1.
     7  1.24926 -0.870237 0.89        0.1     1. 1. 1.
    882
    9   -1.12431 -0.26503 -4.44089e-16        0.1     1. 1. 1.
     9  2.13922 0.388414 0    0.1     1. 1. 1.
    10102
    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.
    12122
    13   1.37419 -0.89433 0.89         0.1     1. 1. 1.
     13  -3.63639e-05 1.27176 0.89     0.1     1. 1. 1.
    14142
    15   2.26414 0.364321 -4.44089e-16         0.1     1. 1. 1.
     15  -2.13919 0.388414 0   0.1     1. 1. 1.
    16162
    17   0.12489 1.24767 -0.89         0.1     1. 1. 1.
     17  -1.24924 -0.870237 -0.89      0.1     1. 1. 1.
    18182
    19   0.12489 1.24767 0.89  0.1     1. 1. 1.
     19  -1.24924 -0.870237 0.89       0.1     1. 1. 1.
    20202
    21   -2.01426 0.364321 -4.44089e-16        0.1     1. 1. 1.
     21  1.24926 -0.240937 0   0.1     1. 1. 1.
    22222
    23   -1.12431 -0.89433 -0.89       0.1     1. 1. 1.
     23  -3.63639e-05 0.642463 0       0.1     1. 1. 1.
    24242
    25   -1.12431 -0.89433 0.89        0.1     1. 1. 1.
     25  -1.24924 -0.240937 0  0.1     1. 1. 1.
    2626# All tesselation triangles
    27278
     
    3030  BACKFACE  0.3 0.3 1.0   0 0
    31311
    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.
    33331
    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.
    35351
    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.
    37371
    38   2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.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.
    39391
    40   0.12489 1.24767 -0.89         0.12489 1.24767 0.89    -2.01426 0.364321 -4.44089e-16  1. 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.
    41411
    42   1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.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.
    43431
    44   1.37419 -0.89433 0.89         0.12489 1.24767 0.89    -1.12431 -0.89433 0.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.
    45451
    46   0.12489 1.24767 0.89  -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 0.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.
    47471
    48   -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.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.
    49491
    50   1.37419 -0.89433 0.89         -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.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.
    51511
    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.
    53531
    54   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
     54  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  2.13922 0.388414 0      1. 0. 0.
    55559
    5656#  terminating special property
     
    5959  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    60602
    61   1.67084 -0.47478 -8.88178e-16 5       1 0 0
     61  1.54591 -0.450686 -4.44089e-16        5       1 0 0
    62629
    6363  terminating special property
  • tests/regression/Tesselation/2/post/ConvexEnvelope.r3d

    re58856b rf2a1d3  
    33# All atoms as spheres
    442
    5   1.37419 -0.26503 -4.44089e-16         0.1     1. 1. 1.
     5  1.24926 -0.870237 -0.89       0.1     1. 1. 1.
    662
    7   0.12489 0.61837 -4.44089e-16  0.1     1. 1. 1.
     7  1.24926 -0.870237 0.89        0.1     1. 1. 1.
    882
    9   -1.12431 -0.26503 -4.44089e-16        0.1     1. 1. 1.
     9  2.13922 0.388414 0    0.1     1. 1. 1.
    10102
    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.
    12122
    13   1.37419 -0.89433 0.89         0.1     1. 1. 1.
     13  -3.63639e-05 1.27176 0.89     0.1     1. 1. 1.
    14142
    15   2.26414 0.364321 -4.44089e-16         0.1     1. 1. 1.
     15  -2.13919 0.388414 0   0.1     1. 1. 1.
    16162
    17   0.12489 1.24767 -0.89         0.1     1. 1. 1.
     17  -1.24924 -0.870237 -0.89      0.1     1. 1. 1.
    18182
    19   0.12489 1.24767 0.89  0.1     1. 1. 1.
     19  -1.24924 -0.870237 0.89       0.1     1. 1. 1.
    20202
    21   -2.01426 0.364321 -4.44089e-16        0.1     1. 1. 1.
     21  1.24926 -0.240937 0   0.1     1. 1. 1.
    22222
    23   -1.12431 -0.89433 -0.89       0.1     1. 1. 1.
     23  -3.63639e-05 0.642463 0       0.1     1. 1. 1.
    24242
    25   -1.12431 -0.89433 0.89        0.1     1. 1. 1.
     25  -1.24924 -0.240937 0  0.1     1. 1. 1.
    2626# All tesselation triangles
    27278
     
    3030  BACKFACE  0.3 0.3 1.0   0 0
    31311
    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.
    33331
    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.
    35351
    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.
    37371
    38   2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.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.
    39391
    40   0.12489 1.24767 -0.89         0.12489 1.24767 0.89    -2.01426 0.364321 -4.44089e-16  1. 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.
    41411
    42   1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.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.
    43431
    44   1.37419 -0.89433 0.89         0.12489 1.24767 0.89    -1.12431 -0.89433 0.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.
    45451
    46   0.12489 1.24767 0.89  -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 0.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.
    47471
    48   -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.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.
    49491
    50   1.37419 -0.89433 0.89         -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.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.
    51511
    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.
    53531
    54   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
     54  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  2.13922 0.388414 0      1. 0. 0.
    55559
    5656#  terminating special property
     
    5959  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    60602
    61   1.67084 -0.47478 -8.88178e-16 5       1 0 0
     61  1.54591 -0.450686 -4.44089e-16        5       1 0 0
    62629
    6363  terminating special property
  • tests/regression/Tesselation/2/post/NonConvexEnvelope.r3d

    re58856b rf2a1d3  
    33# All atoms as spheres
    442
    5   1.37419 -0.26503 -4.44089e-16         0.1     1. 1. 1.
     5  1.24926 -0.870237 -0.89       0.1     1. 1. 1.
    662
    7   0.12489 0.61837 -4.44089e-16  0.1     1. 1. 1.
     7  1.24926 -0.870237 0.89        0.1     1. 1. 1.
    882
    9   -1.12431 -0.26503 -4.44089e-16        0.1     1. 1. 1.
     9  2.13922 0.388414 0    0.1     1. 1. 1.
    10102
    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.
    12122
    13   1.37419 -0.89433 0.89         0.1     1. 1. 1.
     13  -3.63639e-05 1.27176 0.89     0.1     1. 1. 1.
    14142
    15   2.26414 0.364321 -4.44089e-16         0.1     1. 1. 1.
     15  -2.13919 0.388414 0   0.1     1. 1. 1.
    16162
    17   0.12489 1.24767 -0.89         0.1     1. 1. 1.
     17  -1.24924 -0.870237 -0.89      0.1     1. 1. 1.
    18182
    19   0.12489 1.24767 0.89  0.1     1. 1. 1.
     19  -1.24924 -0.870237 0.89       0.1     1. 1. 1.
    20202
    21   -2.01426 0.364321 -4.44089e-16        0.1     1. 1. 1.
     21  1.24926 -0.240937 0   0.1     1. 1. 1.
    22222
    23   -1.12431 -0.89433 -0.89       0.1     1. 1. 1.
     23  -3.63639e-05 0.642463 0       0.1     1. 1. 1.
    24242
    25   -1.12431 -0.89433 0.89        0.1     1. 1. 1.
     25  -1.24924 -0.240937 0  0.1     1. 1. 1.
    2626# All tesselation triangles
    27278
     
    3030  BACKFACE  0.3 0.3 1.0   0 0
    31311
    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.
    33331
    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.
    35351
    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.
    37371
    38   2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.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.
    39391
    40   0.12489 1.24767 -0.89         0.12489 1.24767 0.89    -2.01426 0.364321 -4.44089e-16  1. 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.
    41411
    42   1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.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.
    43431
    44   1.37419 -0.89433 0.89         0.12489 1.24767 0.89    -1.12431 -0.89433 0.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.
    45451
    46   0.12489 1.24767 0.89  -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 0.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.
    47471
    48   -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.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.
    49491
    50   1.37419 -0.89433 0.89         -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.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.
    51511
    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.
    53531
    54   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
     54  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  2.13922 0.388414 0      1. 0. 0.
    55559
    5656#  terminating special property
     
    5959  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    60602
    61   1.67084 -0.47478 -8.88178e-16 5       1 0 0
     61  1.54591 -0.450686 -4.44089e-16        5       1 0 0
    62629
    6363  terminating special property
  • tests/regression/Tesselation/3/post/NonConvexEnvelope.dat

    re58856b rf2a1d3  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="test", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 6.9077 1.1106 0.1214 1
    540.3612 -3.628 1.323 1
    650.4884 -3.5983 -0.4521 3
     
    4645-6.8554 1.8134 -0.9499 1
    47467.1391 2.0447 0.0264 0
     476.9077 1.1106 0.1214 1
    4848
    49 1 32 44
    50 1 32 35
    51 1 34 35
    52 23 32 35
    53 17 23 35
    54 8 17 35
    55 8 10 17
    56 3 8 10
    57 3 8 35
    58 3 4 35
    59 4 29 35
    60 29 34 35
    61 2 3 4
    62 2 4 29
    63 2 15 29
    64 15 28 29
    65 28 29 34
    66 2 7 15
    67 7 14 15
    68 14 15 28
    69 14 25 28
    70 25 28 37
    71 28 34 37
    72 1 34 37
    73 1 37 44
    74 25 26 37
    75 25 26 27
    76 26 27 33
    77 26 33 44
    78 26 37 44
    79 14 25 27
    80 14 27 30
    81 6 14 30
    82 6 24 30
    83 24 30 36
    84 30 36 39
    85 27 30 39
    86 27 30 39
    87 16 27 30
    88 16 18 30
    89 16 18 27
    90 18 27 33
    91 18 23 33
    92 6 7 24
    93 6 7 14
    94 7 11 24
    95 11 20 24
    96 20 24 41
    97 24 36 41
    98 36 41 42
    99 11 20 22
    100 5 11 22
    101 5 7 11
    102 2 5 7
    103 36 38 39
    104 36 38 42
    105 18 30 31
    106 30 31 39
    107 31 39 40
    108 9 18 31
    109 9 17 18
    110 17 18 23
    111 9 19 31
    112 9 13 19
    113 13 19 31
    114 13 21 31
    115 21 31 43
    116 31 40 43
    117 9 12 13
    118 9 10 12
    119 9 10 17
    120 12 13 21
    121 12 21 22
    122 5 12 22
    123 3 5 12
    124 2 3 5
    125 3 10 12
    126 20 21 22
    127 20 21 41
    128 21 41 43
    129 41 42 43
    130 23 32 33
    131 32 33 44
    132 40 42 43
    133 38 40 42
    134 38 39 40
     4931 43 44
     5031 34 44
     5133 34 44
     5222 31 34
     5316 22 34
     547 16 34
     557 9 16
     562 7 9
     572 7 34
     582 3 34
     593 28 34
     6028 33 34
     611 2 3
     621 3 28
     631 14 28
     6414 27 28
     6527 28 33
     661 6 14
     676 13 14
     6813 14 27
     6913 24 27
     7024 27 36
     7127 33 36
     7233 36 44
     7336 43 44
     7424 25 36
     7524 25 26
     7625 26 32
     7725 32 43
     7825 36 43
     7913 24 26
     8013 26 29
     815 13 29
     825 23 29
     8323 29 35
     8429 35 38
     8526 29 38
     8626 29 38
     8715 26 29
     8815 17 29
     8915 17 26
     9017 26 32
     9117 22 32
     925 6 23
     935 6 13
     946 10 23
     9510 19 23
     9619 23 40
     9723 35 40
     9835 40 41
     9910 19 21
     1004 10 21
     1014 6 10
     1021 4 6
     10335 37 38
     10435 37 41
     10517 29 30
     10629 30 38
     10730 38 39
     1088 17 30
     1098 16 17
     11016 17 22
     1118 18 30
     1128 12 18
     11312 18 30
     11412 20 30
     11520 30 42
     11630 39 42
     1178 11 12
     1188 9 11
     1198 9 16
     12011 12 20
     12111 20 21
     1224 11 21
     1232 4 11
     1241 2 4
     1252 9 11
     12619 20 21
     12719 20 40
     12820 40 42
     12940 41 42
     13022 31 32
     13131 32 43
     13239 41 42
     13337 39 41
     13437 38 39
  • tests/regression/Tesselation/3/post/NonConvexEnvelope.r3d

    re58856b rf2a1d3  
    33# All atoms as spheres
    442
    5   0.952534 -3.05798 0.420171    0.1     1. 1. 1.
    6 2
    7   -0.139866 -1.98848 0.359771   0.1     1. 1. 1.
    8 2
    9   0.0788342 -1.07508 -0.875229  0.1     1. 1. 1.
    10 2
    11   -1.49147 -2.63828 0.0780712   0.1     1. 1. 1.
    12 2
    13   -0.0588658 -1.09478 1.58347   0.1     1. 1. 1.
    14 2
    15   1.53473 -0.644479 -0.868129   0.1     1. 1. 1.
    16 2
    17   -0.333166 -2.00128 -2.02443   0.1     1. 1. 1.
    18 2
    19   -2.62147 -1.78218 0.653571    0.1     1. 1. 1.
    20 2
    21   -1.60077 -2.70398 -1.46563    0.1     1. 1. 1.
    22 2
    23   1.37913 -0.560579 1.65607     0.1     1. 1. 1.
    24 2
    25   1.75933 0.205421 0.395371     0.1     1. 1. 1.
    26 2
    27   1.79893 0.246421 -2.08883     0.1     1. 1. 1.
    28 2
    29   -2.64037 -0.423279 -0.0491288         0.1     1. 1. 1.
    30 2
    31   -3.96017 -2.48928 0.432671    0.1     1. 1. 1.
    32 2
    33   3.23013 0.593821 0.484471     0.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.45487       0.1     1. 1. 1.
    40 2
    41   3.78273 1.01752 -0.849429     0.1     1. 1. 1.
    42 2
    43   4.07093 -0.563879 1.01767     0.1     1. 1. 1.
    44 2
    45   -3.81397 1.77692 -0.204329    0.1     1. 1. 1.
    46 2
    47   5.17783 1.62112 -0.842829     0.1     1. 1. 1.
    48 2
    49   5.49863 -0.464179 0.482071    0.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.337371     0.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.0890712    0.1     1. 1. 1.
    58 2
    59   7.33693 1.04442 0.0886712     0.1     1. 1. 1.
    60 2
    61   0.790434 -3.69418 1.29027     0.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.498071     0.1     1. 1. 1.
    66 2
    67   -0.574266 -0.203779 -0.824729         0.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.48487   0.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.91753   0.1     1. 1. 1.
    78 2
    79   0.450934 -2.72908 -2.23353    0.1     1. 1. 1.
    80 2
    81   -2.45927 -1.63678 1.72157     0.1     1. 1. 1.
    82 2
    83   -1.62867 -3.74268 -1.79493    0.1     1. 1. 1.
    84 2
    85   -2.49667 -2.18078 -1.79993    0.1     1. 1. 1.
    86 2
    87   1.46453 0.112321 2.50927      0.1     1. 1. 1.
    88 2
    89   2.06173 -1.39848 1.79787      0.1     1. 1. 1.
    90 2
    91   1.15633 1.11082 0.326671      0.1     1. 1. 1.
    92 2
    93   1.76663 -0.360379 -2.99373    0.1     1. 1. 1.
    94 2
    95   1.03283 1.01972 -2.14533      0.1     1. 1. 1.
    96 2
    97   -1.69727 0.0925205 0.131971   0.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.935971    0.1     1. 1. 1.
    102 2
    103   -4.17327 -2.53828 -0.635229   0.1     1. 1. 1.
    104 2
    105   -3.90927 -3.49908 0.839771    0.1     1. 1. 1.
    106 2
    107   3.62023 1.25552 -2.86813      0.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.57007     0.1     1. 1. 1.
    112 2
    113   3.24233 1.41142 2.47757       0.1     1. 1. 1.
    114 2
    115   4.34293 2.22742 1.34117       0.1     1. 1. 1.
    116 2
    117   2.58823 2.50762 1.23707       0.1     1. 1. 1.
    118 2
    119   4.08983 -0.525479 2.10687     0.1     1. 1. 1.
    120 2
    121   3.62993 -1.50808 0.698371     0.1     1. 1. 1.
    122 2
    123   -2.87097 2.29272 -0.0233288   0.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.77723      0.1     1. 1. 1.
    128 2
    129   5.11553 2.70122 -0.710229     0.1     1. 1. 1.
    130 2
    131   6.17523 -0.969279 1.17127     0.1     1. 1. 1.
    132 2
    133   5.55043 -0.952879 -0.490929   0.1     1. 1. 1.
    134 2
    135   -4.83487 2.76522 1.41487      0.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.0304712    0.1     1. 1. 1.
    140 2
    141   -4.04457 4.49292 -0.178529    0.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.589671    0.1     1. 1. 1.
    146 2
    147   -7.11497 2.49352 0.479071     0.1     1. 1. 1.
    148 2
    149   -6.42617 1.74722 -0.982629    0.1     1. 1. 1.
    150 2
    151   7.56833 1.97852 -0.00632877   0.1     1. 1. 1.
     5  0.777562 -3.65286 1.28459     0.1     1. 1. 1.
     62
     7  0.904762 -3.62316 -0.490507   0.1     1. 1. 1.
     82
     9  1.91486 -2.53606 0.492393     0.1     1. 1. 1.
     102
     11  -0.587138 -0.162455 -0.830407         0.1     1. 1. 1.
     122
     13  -1.53704 -3.60006 0.497793    0.1     1. 1. 1.
     142
     15  -0.771938 -0.223855 1.47919   0.1     1. 1. 1.
     162
     17  -0.300138 -1.62946 2.47449    0.1     1. 1. 1.
     182
     19  2.17906 -1.47276 -0.873307    0.1     1. 1. 1.
     202
     21  -0.586638 -1.38326 -2.92321   0.1     1. 1. 1.
     222
     23  0.438062 -2.68776 -2.23921    0.1     1. 1. 1.
     242
     25  -2.47214 -1.59546 1.71589     0.1     1. 1. 1.
     262
     27  -1.64154 -3.70136 -1.80061    0.1     1. 1. 1.
     282
     29  -2.50954 -2.13946 -1.80561    0.1     1. 1. 1.
     302
     31  1.45166 0.153645 2.50359      0.1     1. 1. 1.
     322
     33  2.04886 -1.35716 1.79219      0.1     1. 1. 1.
     342
     35  1.14346 1.15214 0.320993      0.1     1. 1. 1.
     362
     37  1.75376 -0.319055 -2.99941    0.1     1. 1. 1.
     382
     39  1.01996 1.06104 -2.15101      0.1     1. 1. 1.
     402
     41  -1.71014 0.133845 0.126293    0.1     1. 1. 1.
     422
     43  -2.78704 -0.528955 -1.12651   0.1     1. 1. 1.
     442
     45  -4.76454 -1.89276 0.930293    0.1     1. 1. 1.
     462
     47  -4.18614 -2.49696 -0.640907   0.1     1. 1. 1.
     482
     49  -3.92214 -3.45776 0.834093    0.1     1. 1. 1.
     502
     51  3.60736 1.29684 -2.87381      0.1     1. 1. 1.
     522
     53  -4.75094 -0.0564554 0.311693  0.1     1. 1. 1.
     542
     55  -3.67414 0.606345 1.56439     0.1     1. 1. 1.
     562
     57  3.22946 1.45274 2.47189       0.1     1. 1. 1.
     582
     59  4.33006 2.26874 1.33549       0.1     1. 1. 1.
     602
     61  2.57536 2.54894 1.23139       0.1     1. 1. 1.
     622
     63  4.07696 -0.484155 2.10119     0.1     1. 1. 1.
     642
     65  3.61706 -1.46676 0.692693     0.1     1. 1. 1.
     662
     67  -2.88384 2.33404 -0.0290068   0.1     1. 1. 1.
     682
     69  -3.96064 1.67134 -1.28171     0.1     1. 1. 1.
     702
     71  5.67566 1.42984 -1.78291      0.1     1. 1. 1.
     722
     73  5.10266 2.74254 -0.715907     0.1     1. 1. 1.
     742
     75  6.16236 -0.927955 1.16559     0.1     1. 1. 1.
     762
     77  5.53756 -0.911555 -0.496607   0.1     1. 1. 1.
     782
     79  -4.84774 2.80654 1.40919      0.1     1. 1. 1.
     802
     81  5.68906 1.58194 1.24439       0.1     1. 1. 1.
     822
     83  -5.82304 4.61784 0.0247932    0.1     1. 1. 1.
     842
     85  -4.05744 4.53424 -0.184207    0.1     1. 1. 1.
     862
     87  -5.13424 3.87154 -1.43691     0.1     1. 1. 1.
     882
     89  -6.29174 0.967445 0.583993    0.1     1. 1. 1.
     902
     91  -7.12784 2.53484 0.473393     0.1     1. 1. 1.
     922
     93  -6.43904 1.78854 -0.988307    0.1     1. 1. 1.
     942
     95  7.55546 2.01984 -0.0120068    0.1     1. 1. 1.
     962
     97  0.939662 -3.01666 0.414493    0.1     1. 1. 1.
     982
     99  -0.152738 -1.94716 0.354093   0.1     1. 1. 1.
     1002
     101  0.0659622 -1.03376 -0.880907  0.1     1. 1. 1.
     1022
     103  -1.50434 -2.59696 0.0723932   0.1     1. 1. 1.
     1042
     105  -0.0717378 -1.05346 1.57779   0.1     1. 1. 1.
     1062
     107  1.52186 -0.603155 -0.873807   0.1     1. 1. 1.
     1082
     109  -0.346038 -1.95996 -2.03011   0.1     1. 1. 1.
     1102
     111  -2.63434 -1.74086 0.647893    0.1     1. 1. 1.
     1122
     113  -1.61364 -2.66266 -1.47131    0.1     1. 1. 1.
     1142
     115  1.36626 -0.519255 1.65039     0.1     1. 1. 1.
     1162
     117  1.74646 0.246745 0.389693     0.1     1. 1. 1.
     1182
     119  1.78606 0.287745 -2.09451     0.1     1. 1. 1.
     1202
     121  -2.65324 -0.381955 -0.0548068         0.1     1. 1. 1.
     1222
     123  -3.97304 -2.44796 0.426993    0.1     1. 1. 1.
     1242
     125  3.21726 0.635145 0.478793     0.1     1. 1. 1.
     1262
     127  3.13516 0.931145 -1.97401     0.1     1. 1. 1.
     1282
     129  -3.80794 0.459345 0.492693    0.1     1. 1. 1.
     1302
     131  3.34736 1.81094 1.44919       0.1     1. 1. 1.
     1322
     133  3.76986 1.05884 -0.855107     0.1     1. 1. 1.
     1342
     135  4.05806 -0.522555 1.01199     0.1     1. 1. 1.
     1362
     137  -3.82684 1.81824 -0.210007    0.1     1. 1. 1.
     1382
     139  5.16496 1.66244 -0.848507     0.1     1. 1. 1.
     1402
     141  5.48576 -0.422855 0.476393    0.1     1. 1. 1.
     1422
     143  -4.98154 2.65954 0.337493     0.1     1. 1. 1.
     1442
     145  5.91796 1.03174 0.331693      0.1     1. 1. 1.
     1462
     147  -5.00044 4.01854 -0.365207    0.1     1. 1. 1.
     1482
     149  -6.30524 1.93554 0.0833932    0.1     1. 1. 1.
     1502
     151  7.32406 1.08574 0.0829932     0.1     1. 1. 1.
    152152# All tesselation triangles
    1531538
     
    156156  BACKFACE  0.3 0.3 1.0   0 0
    1571571
    158   7.33693 1.04442 0.0886712     5.68853 1.38852 -1.77723        7.56833 1.97852 -0.00632877     1. 0. 0.
    159 1
    160   7.33693 1.04442 0.0886712     5.68853 1.38852 -1.77723        5.55043 -0.952879 -0.490929     1. 0. 0.
    161 1
    162   7.33693 1.04442 0.0886712     6.17523 -0.969279 1.17127       5.55043 -0.952879 -0.490929     1. 0. 0.
    163 1
    164   3.62023 1.25552 -2.86813      5.68853 1.38852 -1.77723        5.55043 -0.952879 -0.490929     1. 0. 0.
    165 1
    166   1.76663 -0.360379 -2.99373    3.62023 1.25552 -2.86813        5.55043 -0.952879 -0.490929     1. 0. 0.
    167 1
    168   2.19193 -1.51408 -0.867629    1.76663 -0.360379 -2.99373      5.55043 -0.952879 -0.490929     1. 0. 0.
    169 1
    170   2.19193 -1.51408 -0.867629    0.450934 -2.72908 -2.23353      1.76663 -0.360379 -2.99373      1. 0. 0.
    171 1
    172   0.917634 -3.66448 -0.484829   2.19193 -1.51408 -0.867629      0.450934 -2.72908 -2.23353      1. 0. 0.
    173 1
    174   0.917634 -3.66448 -0.484829   2.19193 -1.51408 -0.867629      5.55043 -0.952879 -0.490929     1. 0. 0.
    175 1
    176   0.917634 -3.66448 -0.484829   1.92773 -2.57738 0.498071       5.55043 -0.952879 -0.490929     1. 0. 0.
    177 1
    178   1.92773 -2.57738 0.498071     3.62993 -1.50808 0.698371       5.55043 -0.952879 -0.490929     1. 0. 0.
    179 1
    180   3.62993 -1.50808 0.698371     6.17523 -0.969279 1.17127       5.55043 -0.952879 -0.490929     1. 0. 0.
    181 1
    182   0.790434 -3.69418 1.29027     0.917634 -3.66448 -0.484829     1.92773 -2.57738 0.498071       1. 0. 0.
    183 1
    184   0.790434 -3.69418 1.29027     1.92773 -2.57738 0.498071       3.62993 -1.50808 0.698371       1. 0. 0.
    185 1
    186   0.790434 -3.69418 1.29027     2.06173 -1.39848 1.79787        3.62993 -1.50808 0.698371       1. 0. 0.
    187 1
    188   2.06173 -1.39848 1.79787      4.08983 -0.525479 2.10687       3.62993 -1.50808 0.698371       1. 0. 0.
    189 1
    190   4.08983 -0.525479 2.10687     3.62993 -1.50808 0.698371       6.17523 -0.969279 1.17127       1. 0. 0.
    191 1
    192   0.790434 -3.69418 1.29027     -0.287266 -1.67078 2.48017      2.06173 -1.39848 1.79787        1. 0. 0.
    193 1
    194   -0.287266 -1.67078 2.48017    1.46453 0.112321 2.50927        2.06173 -1.39848 1.79787        1. 0. 0.
    195 1
    196   1.46453 0.112321 2.50927      2.06173 -1.39848 1.79787        4.08983 -0.525479 2.10687       1. 0. 0.
    197 1
    198   1.46453 0.112321 2.50927      3.24233 1.41142 2.47757         4.08983 -0.525479 2.10687       1. 0. 0.
    199 1
    200   3.24233 1.41142 2.47757       4.08983 -0.525479 2.10687       5.70193 1.54062 1.25007         1. 0. 0.
    201 1
    202   4.08983 -0.525479 2.10687     6.17523 -0.969279 1.17127       5.70193 1.54062 1.25007         1. 0. 0.
    203 1
    204   7.33693 1.04442 0.0886712     6.17523 -0.969279 1.17127       5.70193 1.54062 1.25007         1. 0. 0.
    205 1
    206   7.33693 1.04442 0.0886712     5.70193 1.54062 1.25007         7.56833 1.97852 -0.00632877     1. 0. 0.
    207 1
    208   3.24233 1.41142 2.47757       4.34293 2.22742 1.34117         5.70193 1.54062 1.25007         1. 0. 0.
    209 1
    210   3.24233 1.41142 2.47757       4.34293 2.22742 1.34117         2.58823 2.50762 1.23707         1. 0. 0.
    211 1
    212   4.34293 2.22742 1.34117       2.58823 2.50762 1.23707         5.11553 2.70122 -0.710229       1. 0. 0.
    213 1
    214   4.34293 2.22742 1.34117       5.11553 2.70122 -0.710229       7.56833 1.97852 -0.00632877     1. 0. 0.
    215 1
    216   4.34293 2.22742 1.34117       5.70193 1.54062 1.25007         7.56833 1.97852 -0.00632877     1. 0. 0.
    217 1
    218   1.46453 0.112321 2.50927      3.24233 1.41142 2.47757         2.58823 2.50762 1.23707         1. 0. 0.
    219 1
    220   1.46453 0.112321 2.50927      2.58823 2.50762 1.23707         -2.87097 2.29272 -0.0233288     1. 0. 0.
    221 1
    222   -0.759066 -0.265179 1.48487   1.46453 0.112321 2.50927        -2.87097 2.29272 -0.0233288     1. 0. 0.
    223 1
    224   -0.759066 -0.265179 1.48487   -3.66127 0.565021 1.57007       -2.87097 2.29272 -0.0233288     1. 0. 0.
    225 1
    226   -3.66127 0.565021 1.57007     -2.87097 2.29272 -0.0233288     -4.83487 2.76522 1.41487        1. 0. 0.
    227 1
    228   -2.87097 2.29272 -0.0233288   -4.83487 2.76522 1.41487        -4.04457 4.49292 -0.178529      1. 0. 0.
    229 1
    230   2.58823 2.50762 1.23707       -2.87097 2.29272 -0.0233288     -4.04457 4.49292 -0.178529      1. 0. 0.
    231 1
    232   2.58823 2.50762 1.23707       -2.87097 2.29272 -0.0233288     -4.04457 4.49292 -0.178529      1. 0. 0.
    233 1
    234   1.15633 1.11082 0.326671      2.58823 2.50762 1.23707         -2.87097 2.29272 -0.0233288     1. 0. 0.
    235 1
    236   1.15633 1.11082 0.326671      1.03283 1.01972 -2.14533        -2.87097 2.29272 -0.0233288     1. 0. 0.
    237 1
    238   1.15633 1.11082 0.326671      1.03283 1.01972 -2.14533        2.58823 2.50762 1.23707         1. 0. 0.
    239 1
    240   1.03283 1.01972 -2.14533      2.58823 2.50762 1.23707         5.11553 2.70122 -0.710229       1. 0. 0.
    241 1
    242   1.03283 1.01972 -2.14533      3.62023 1.25552 -2.86813        5.11553 2.70122 -0.710229       1. 0. 0.
    243 1
    244   -0.759066 -0.265179 1.48487   -0.287266 -1.67078 2.48017      -3.66127 0.565021 1.57007       1. 0. 0.
    245 1
    246   -0.759066 -0.265179 1.48487   -0.287266 -1.67078 2.48017      1.46453 0.112321 2.50927        1. 0. 0.
    247 1
    248   -0.287266 -1.67078 2.48017    -2.45927 -1.63678 1.72157       -3.66127 0.565021 1.57007       1. 0. 0.
    249 1
    250   -2.45927 -1.63678 1.72157     -4.75167 -1.93408 0.935971      -3.66127 0.565021 1.57007       1. 0. 0.
    251 1
    252   -4.75167 -1.93408 0.935971    -3.66127 0.565021 1.57007       -6.27887 0.926121 0.589671      1. 0. 0.
    253 1
    254   -3.66127 0.565021 1.57007     -4.83487 2.76522 1.41487        -6.27887 0.926121 0.589671      1. 0. 0.
    255 1
    256   -4.83487 2.76522 1.41487      -6.27887 0.926121 0.589671      -7.11497 2.49352 0.479071       1. 0. 0.
    257 1
    258   -2.45927 -1.63678 1.72157     -4.75167 -1.93408 0.935971      -3.90927 -3.49908 0.839771      1. 0. 0.
    259 1
    260   -1.52417 -3.64138 0.503471    -2.45927 -1.63678 1.72157       -3.90927 -3.49908 0.839771      1. 0. 0.
    261 1
    262   -1.52417 -3.64138 0.503471    -0.287266 -1.67078 2.48017      -2.45927 -1.63678 1.72157       1. 0. 0.
    263 1
    264   0.790434 -3.69418 1.29027     -1.52417 -3.64138 0.503471      -0.287266 -1.67078 2.48017      1. 0. 0.
    265 1
    266   -4.83487 2.76522 1.41487      -5.81017 4.57652 0.0304712      -4.04457 4.49292 -0.178529      1. 0. 0.
    267 1
    268   -4.83487 2.76522 1.41487      -5.81017 4.57652 0.0304712      -7.11497 2.49352 0.479071       1. 0. 0.
    269 1
    270   1.03283 1.01972 -2.14533      -2.87097 2.29272 -0.0233288     -3.94777 1.63002 -1.27603       1. 0. 0.
    271 1
    272   -2.87097 2.29272 -0.0233288   -3.94777 1.63002 -1.27603       -4.04457 4.49292 -0.178529      1. 0. 0.
    273 1
    274   -3.94777 1.63002 -1.27603     -4.04457 4.49292 -0.178529      -5.12137 3.83022 -1.43123       1. 0. 0.
    275 1
    276   -0.573766 -1.42458 -2.91753   1.03283 1.01972 -2.14533        -3.94777 1.63002 -1.27603       1. 0. 0.
    277 1
    278   -0.573766 -1.42458 -2.91753   1.76663 -0.360379 -2.99373      1.03283 1.01972 -2.14533        1. 0. 0.
    279 1
    280   1.76663 -0.360379 -2.99373    1.03283 1.01972 -2.14533        3.62023 1.25552 -2.86813        1. 0. 0.
    281 1
    282   -0.573766 -1.42458 -2.91753   -2.77417 -0.570279 -1.12083     -3.94777 1.63002 -1.27603       1. 0. 0.
    283 1
    284   -0.573766 -1.42458 -2.91753   -2.49667 -2.18078 -1.79993      -2.77417 -0.570279 -1.12083     1. 0. 0.
    285 1
    286   -2.49667 -2.18078 -1.79993    -2.77417 -0.570279 -1.12083     -3.94777 1.63002 -1.27603       1. 0. 0.
    287 1
    288   -2.49667 -2.18078 -1.79993    -4.17327 -2.53828 -0.635229     -3.94777 1.63002 -1.27603       1. 0. 0.
    289 1
    290   -4.17327 -2.53828 -0.635229   -3.94777 1.63002 -1.27603       -6.42617 1.74722 -0.982629      1. 0. 0.
    291 1
    292   -3.94777 1.63002 -1.27603     -5.12137 3.83022 -1.43123       -6.42617 1.74722 -0.982629      1. 0. 0.
    293 1
    294   -0.573766 -1.42458 -2.91753   -1.62867 -3.74268 -1.79493      -2.49667 -2.18078 -1.79993      1. 0. 0.
    295 1
    296   -0.573766 -1.42458 -2.91753   0.450934 -2.72908 -2.23353      -1.62867 -3.74268 -1.79493      1. 0. 0.
    297 1
    298   -0.573766 -1.42458 -2.91753   0.450934 -2.72908 -2.23353      1.76663 -0.360379 -2.99373      1. 0. 0.
    299 1
    300   -1.62867 -3.74268 -1.79493    -2.49667 -2.18078 -1.79993      -4.17327 -2.53828 -0.635229     1. 0. 0.
    301 1
    302   -1.62867 -3.74268 -1.79493    -4.17327 -2.53828 -0.635229     -3.90927 -3.49908 0.839771      1. 0. 0.
    303 1
    304   -1.52417 -3.64138 0.503471    -1.62867 -3.74268 -1.79493      -3.90927 -3.49908 0.839771      1. 0. 0.
    305 1
    306   0.917634 -3.66448 -0.484829   -1.52417 -3.64138 0.503471      -1.62867 -3.74268 -1.79493      1. 0. 0.
    307 1
    308   0.790434 -3.69418 1.29027     0.917634 -3.66448 -0.484829     -1.52417 -3.64138 0.503471      1. 0. 0.
    309 1
    310   0.917634 -3.66448 -0.484829   0.450934 -2.72908 -2.23353      -1.62867 -3.74268 -1.79493      1. 0. 0.
    311 1
    312   -4.75167 -1.93408 0.935971    -4.17327 -2.53828 -0.635229     -3.90927 -3.49908 0.839771      1. 0. 0.
    313 1
    314   -4.75167 -1.93408 0.935971    -4.17327 -2.53828 -0.635229     -6.27887 0.926121 0.589671      1. 0. 0.
    315 1
    316   -4.17327 -2.53828 -0.635229   -6.27887 0.926121 0.589671      -6.42617 1.74722 -0.982629      1. 0. 0.
    317 1
    318   -6.27887 0.926121 0.589671    -7.11497 2.49352 0.479071       -6.42617 1.74722 -0.982629      1. 0. 0.
    319 1
    320   3.62023 1.25552 -2.86813      5.68853 1.38852 -1.77723        5.11553 2.70122 -0.710229       1. 0. 0.
    321 1
    322   5.68853 1.38852 -1.77723      5.11553 2.70122 -0.710229       7.56833 1.97852 -0.00632877     1. 0. 0.
    323 1
    324   -5.12137 3.83022 -1.43123     -7.11497 2.49352 0.479071       -6.42617 1.74722 -0.982629      1. 0. 0.
    325 1
    326   -5.81017 4.57652 0.0304712    -5.12137 3.83022 -1.43123       -7.11497 2.49352 0.479071       1. 0. 0.
    327 1
    328   -5.81017 4.57652 0.0304712    -4.04457 4.49292 -0.178529      -5.12137 3.83022 -1.43123       1. 0. 0.
     158  5.67566 1.42984 -1.78291      7.55546 2.01984 -0.0120068      7.32406 1.08574 0.0829932       1. 0. 0.
     1591
     160  5.67566 1.42984 -1.78291      5.53756 -0.911555 -0.496607     7.32406 1.08574 0.0829932       1. 0. 0.
     1611
     162  6.16236 -0.927955 1.16559     5.53756 -0.911555 -0.496607     7.32406 1.08574 0.0829932       1. 0. 0.
     1631
     164  3.60736 1.29684 -2.87381      5.67566 1.42984 -1.78291        5.53756 -0.911555 -0.496607     1. 0. 0.
     1651
     166  1.75376 -0.319055 -2.99941    3.60736 1.29684 -2.87381        5.53756 -0.911555 -0.496607     1. 0. 0.
     1671
     168  2.17906 -1.47276 -0.873307    1.75376 -0.319055 -2.99941      5.53756 -0.911555 -0.496607     1. 0. 0.
     1691
     170  2.17906 -1.47276 -0.873307    0.438062 -2.68776 -2.23921      1.75376 -0.319055 -2.99941      1. 0. 0.
     1711
     172  0.904762 -3.62316 -0.490507   2.17906 -1.47276 -0.873307      0.438062 -2.68776 -2.23921      1. 0. 0.
     1731
     174  0.904762 -3.62316 -0.490507   2.17906 -1.47276 -0.873307      5.53756 -0.911555 -0.496607     1. 0. 0.
     1751
     176  0.904762 -3.62316 -0.490507   1.91486 -2.53606 0.492393       5.53756 -0.911555 -0.496607     1. 0. 0.
     1771
     178  1.91486 -2.53606 0.492393     3.61706 -1.46676 0.692693       5.53756 -0.911555 -0.496607     1. 0. 0.
     1791
     180  3.61706 -1.46676 0.692693     6.16236 -0.927955 1.16559       5.53756 -0.911555 -0.496607     1. 0. 0.
     1811
     182  0.777562 -3.65286 1.28459     0.904762 -3.62316 -0.490507     1.91486 -2.53606 0.492393       1. 0. 0.
     1831
     184  0.777562 -3.65286 1.28459     1.91486 -2.53606 0.492393       3.61706 -1.46676 0.692693       1. 0. 0.
     1851
     186  0.777562 -3.65286 1.28459     2.04886 -1.35716 1.79219        3.61706 -1.46676 0.692693       1. 0. 0.
     1871
     188  2.04886 -1.35716 1.79219      4.07696 -0.484155 2.10119       3.61706 -1.46676 0.692693       1. 0. 0.
     1891
     190  4.07696 -0.484155 2.10119     3.61706 -1.46676 0.692693       6.16236 -0.927955 1.16559       1. 0. 0.
     1911
     192  0.777562 -3.65286 1.28459     -0.300138 -1.62946 2.47449      2.04886 -1.35716 1.79219        1. 0. 0.
     1931
     194  -0.300138 -1.62946 2.47449    1.45166 0.153645 2.50359        2.04886 -1.35716 1.79219        1. 0. 0.
     1951
     196  1.45166 0.153645 2.50359      2.04886 -1.35716 1.79219        4.07696 -0.484155 2.10119       1. 0. 0.
     1971
     198  1.45166 0.153645 2.50359      3.22946 1.45274 2.47189         4.07696 -0.484155 2.10119       1. 0. 0.
     1991
     200  3.22946 1.45274 2.47189       4.07696 -0.484155 2.10119       5.68906 1.58194 1.24439         1. 0. 0.
     2011
     202  4.07696 -0.484155 2.10119     6.16236 -0.927955 1.16559       5.68906 1.58194 1.24439         1. 0. 0.
     2031
     204  6.16236 -0.927955 1.16559     5.68906 1.58194 1.24439         7.32406 1.08574 0.0829932       1. 0. 0.
     2051
     206  5.68906 1.58194 1.24439       7.55546 2.01984 -0.0120068      7.32406 1.08574 0.0829932       1. 0. 0.
     2071
     208  3.22946 1.45274 2.47189       4.33006 2.26874 1.33549         5.68906 1.58194 1.24439         1. 0. 0.
     2091
     210  3.22946 1.45274 2.47189       4.33006 2.26874 1.33549         2.57536 2.54894 1.23139         1. 0. 0.
     2111
     212  4.33006 2.26874 1.33549       2.57536 2.54894 1.23139         5.10266 2.74254 -0.715907       1. 0. 0.
     2131
     214  4.33006 2.26874 1.33549       5.10266 2.74254 -0.715907       7.55546 2.01984 -0.0120068      1. 0. 0.
     2151
     216  4.33006 2.26874 1.33549       5.68906 1.58194 1.24439         7.55546 2.01984 -0.0120068      1. 0. 0.
     2171
     218  1.45166 0.153645 2.50359      3.22946 1.45274 2.47189         2.57536 2.54894 1.23139         1. 0. 0.
     2191
     220  1.45166 0.153645 2.50359      2.57536 2.54894 1.23139         -2.88384 2.33404 -0.0290068     1. 0. 0.
     2211
     222  -0.771938 -0.223855 1.47919   1.45166 0.153645 2.50359        -2.88384 2.33404 -0.0290068     1. 0. 0.
     2231
     224  -0.771938 -0.223855 1.47919   -3.67414 0.606345 1.56439       -2.88384 2.33404 -0.0290068     1. 0. 0.
     2251
     226  -3.67414 0.606345 1.56439     -2.88384 2.33404 -0.0290068     -4.84774 2.80654 1.40919        1. 0. 0.
     2271
     228  -2.88384 2.33404 -0.0290068   -4.84774 2.80654 1.40919        -4.05744 4.53424 -0.184207      1. 0. 0.
     2291
     230  2.57536 2.54894 1.23139       -2.88384 2.33404 -0.0290068     -4.05744 4.53424 -0.184207      1. 0. 0.
     2311
     232  2.57536 2.54894 1.23139       -2.88384 2.33404 -0.0290068     -4.05744 4.53424 -0.184207      1. 0. 0.
     2331
     234  1.14346 1.15214 0.320993      2.57536 2.54894 1.23139         -2.88384 2.33404 -0.0290068     1. 0. 0.
     2351
     236  1.14346 1.15214 0.320993      1.01996 1.06104 -2.15101        -2.88384 2.33404 -0.0290068     1. 0. 0.
     2371
     238  1.14346 1.15214 0.320993      1.01996 1.06104 -2.15101        2.57536 2.54894 1.23139         1. 0. 0.
     2391
     240  1.01996 1.06104 -2.15101      2.57536 2.54894 1.23139         5.10266 2.74254 -0.715907       1. 0. 0.
     2411
     242  1.01996 1.06104 -2.15101      3.60736 1.29684 -2.87381        5.10266 2.74254 -0.715907       1. 0. 0.
     2431
     244  -0.771938 -0.223855 1.47919   -0.300138 -1.62946 2.47449      -3.67414 0.606345 1.56439       1. 0. 0.
     2451
     246  -0.771938 -0.223855 1.47919   -0.300138 -1.62946 2.47449      1.45166 0.153645 2.50359        1. 0. 0.
     2471
     248  -0.300138 -1.62946 2.47449    -2.47214 -1.59546 1.71589       -3.67414 0.606345 1.56439       1. 0. 0.
     2491
     250  -2.47214 -1.59546 1.71589     -4.76454 -1.89276 0.930293      -3.67414 0.606345 1.56439       1. 0. 0.
     2511
     252  -4.76454 -1.89276 0.930293    -3.67414 0.606345 1.56439       -6.29174 0.967445 0.583993      1. 0. 0.
     2531
     254  -3.67414 0.606345 1.56439     -4.84774 2.80654 1.40919        -6.29174 0.967445 0.583993      1. 0. 0.
     2551
     256  -4.84774 2.80654 1.40919      -6.29174 0.967445 0.583993      -7.12784 2.53484 0.473393       1. 0. 0.
     2571
     258  -2.47214 -1.59546 1.71589     -4.76454 -1.89276 0.930293      -3.92214 -3.45776 0.834093      1. 0. 0.
     2591
     260  -1.53704 -3.60006 0.497793    -2.47214 -1.59546 1.71589       -3.92214 -3.45776 0.834093      1. 0. 0.
     2611
     262  -1.53704 -3.60006 0.497793    -0.300138 -1.62946 2.47449      -2.47214 -1.59546 1.71589       1. 0. 0.
     2631
     264  0.777562 -3.65286 1.28459     -1.53704 -3.60006 0.497793      -0.300138 -1.62946 2.47449      1. 0. 0.
     2651
     266  -4.84774 2.80654 1.40919      -5.82304 4.61784 0.0247932      -4.05744 4.53424 -0.184207      1. 0. 0.
     2671
     268  -4.84774 2.80654 1.40919      -5.82304 4.61784 0.0247932      -7.12784 2.53484 0.473393       1. 0. 0.
     2691
     270  1.01996 1.06104 -2.15101      -2.88384 2.33404 -0.0290068     -3.96064 1.67134 -1.28171       1. 0. 0.
     2711
     272  -2.88384 2.33404 -0.0290068   -3.96064 1.67134 -1.28171       -4.05744 4.53424 -0.184207      1. 0. 0.
     2731
     274  -3.96064 1.67134 -1.28171     -4.05744 4.53424 -0.184207      -5.13424 3.87154 -1.43691       1. 0. 0.
     2751
     276  -0.586638 -1.38326 -2.92321   1.01996 1.06104 -2.15101        -3.96064 1.67134 -1.28171       1. 0. 0.
     2771
     278  -0.586638 -1.38326 -2.92321   1.75376 -0.319055 -2.99941      1.01996 1.06104 -2.15101        1. 0. 0.
     2791
     280  1.75376 -0.319055 -2.99941    1.01996 1.06104 -2.15101        3.60736 1.29684 -2.87381        1. 0. 0.
     2811
     282  -0.586638 -1.38326 -2.92321   -2.78704 -0.528955 -1.12651     -3.96064 1.67134 -1.28171       1. 0. 0.
     2831
     284  -0.586638 -1.38326 -2.92321   -2.50954 -2.13946 -1.80561      -2.78704 -0.528955 -1.12651     1. 0. 0.
     2851
     286  -2.50954 -2.13946 -1.80561    -2.78704 -0.528955 -1.12651     -3.96064 1.67134 -1.28171       1. 0. 0.
     2871
     288  -2.50954 -2.13946 -1.80561    -4.18614 -2.49696 -0.640907     -3.96064 1.67134 -1.28171       1. 0. 0.
     2891
     290  -4.18614 -2.49696 -0.640907   -3.96064 1.67134 -1.28171       -6.43904 1.78854 -0.988307      1. 0. 0.
     2911
     292  -3.96064 1.67134 -1.28171     -5.13424 3.87154 -1.43691       -6.43904 1.78854 -0.988307      1. 0. 0.
     2931
     294  -0.586638 -1.38326 -2.92321   -1.64154 -3.70136 -1.80061      -2.50954 -2.13946 -1.80561      1. 0. 0.
     2951
     296  -0.586638 -1.38326 -2.92321   0.438062 -2.68776 -2.23921      -1.64154 -3.70136 -1.80061      1. 0. 0.
     2971
     298  -0.586638 -1.38326 -2.92321   0.438062 -2.68776 -2.23921      1.75376 -0.319055 -2.99941      1. 0. 0.
     2991
     300  -1.64154 -3.70136 -1.80061    -2.50954 -2.13946 -1.80561      -4.18614 -2.49696 -0.640907     1. 0. 0.
     3011
     302  -1.64154 -3.70136 -1.80061    -4.18614 -2.49696 -0.640907     -3.92214 -3.45776 0.834093      1. 0. 0.
     3031
     304  -1.53704 -3.60006 0.497793    -1.64154 -3.70136 -1.80061      -3.92214 -3.45776 0.834093      1. 0. 0.
     3051
     306  0.904762 -3.62316 -0.490507   -1.53704 -3.60006 0.497793      -1.64154 -3.70136 -1.80061      1. 0. 0.
     3071
     308  0.777562 -3.65286 1.28459     0.904762 -3.62316 -0.490507     -1.53704 -3.60006 0.497793      1. 0. 0.
     3091
     310  0.904762 -3.62316 -0.490507   0.438062 -2.68776 -2.23921      -1.64154 -3.70136 -1.80061      1. 0. 0.
     3111
     312  -4.76454 -1.89276 0.930293    -4.18614 -2.49696 -0.640907     -3.92214 -3.45776 0.834093      1. 0. 0.
     3131
     314  -4.76454 -1.89276 0.930293    -4.18614 -2.49696 -0.640907     -6.29174 0.967445 0.583993      1. 0. 0.
     3151
     316  -4.18614 -2.49696 -0.640907   -6.29174 0.967445 0.583993      -6.43904 1.78854 -0.988307      1. 0. 0.
     3171
     318  -6.29174 0.967445 0.583993    -7.12784 2.53484 0.473393       -6.43904 1.78854 -0.988307      1. 0. 0.
     3191
     320  3.60736 1.29684 -2.87381      5.67566 1.42984 -1.78291        5.10266 2.74254 -0.715907       1. 0. 0.
     3211
     322  5.67566 1.42984 -1.78291      5.10266 2.74254 -0.715907       7.55546 2.01984 -0.0120068      1. 0. 0.
     3231
     324  -5.13424 3.87154 -1.43691     -7.12784 2.53484 0.473393       -6.43904 1.78854 -0.988307      1. 0. 0.
     3251
     326  -5.82304 4.61784 0.0247932    -5.13424 3.87154 -1.43691       -7.12784 2.53484 0.473393       1. 0. 0.
     3271
     328  -5.82304 4.61784 0.0247932    -4.05744 4.53424 -0.184207      -5.13424 3.87154 -1.43691       1. 0. 0.
    3293299
    330330#  terminating special property
     
    333333  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    3343342
    335   -4.99203 4.29989 -0.526429    5       1 0 0
     335  -5.0049 4.34121 -0.532107     5       1 0 0
    3363369
    337337  terminating special property
Note: See TracChangeset for help on using the changeset viewer.