Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/moleculelist.cpp

    raafd77 rc27778  
    55 */
    66
    7 #ifdef HAVE_CONFIG_H
    8 #include <config.h>
    9 #endif
    10 
    117#include "Helpers/MemDebug.hpp"
    128
    139#include <cstring>
    14 
    15 #include <gsl/gsl_inline.h>
    16 #include <gsl/gsl_heapsort.h>
    1710
    1811#include "World.hpp"
     
    2619#include "linkedcell.hpp"
    2720#include "lists.hpp"
    28 #include "verbose.hpp"
    2921#include "log.hpp"
    3022#include "molecule.hpp"
     23#include "memoryallocator.hpp"
    3124#include "periodentafel.hpp"
    3225#include "Helpers/Assert.hpp"
    33 #include "Matrix.hpp"
    34 #include "Box.hpp"
    35 #include "stackclass.hpp"
    3626
    3727#include "Helpers/Assert.hpp"
     
    641631  int FragmentCounter = 0;
    642632  ofstream output;
    643   Matrix cell_size = World::getInstance().getDomain().getM();
    644   Matrix cell_size_backup = cell_size;
    645 
     633  double cell_size_backup[6];
     634  double * const cell_size = World::getInstance().getDomain();
     635
     636  // backup cell_size
     637  for (int i=0;i<6;i++)
     638    cell_size_backup[i] = cell_size[i];
    646639  // store the fragments as config and as xyz
    647640  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
     
    681674    (*ListRunner)->CenterEdge(&BoxDimension);
    682675    (*ListRunner)->SetBoxDimension(&BoxDimension); // update Box of atoms by boundary
     676    int j = -1;
    683677    for (int k = 0; k < NDIM; k++) {
     678      j += k + 1;
    684679      BoxDimension[k] = 2.5 * (World::getInstance().getConfig()->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
    685       cell_size.at(k,k) = BoxDimension[k] * 2.;
    686     }
    687     World::getInstance().setDomain(cell_size);
     680      cell_size[j] = BoxDimension[k] * 2.;
     681    }
    688682    (*ListRunner)->Translate(&BoxDimension);
    689683
     
    731725
    732726  // restore cell_size
    733   World::getInstance().setDomain(cell_size_backup);
     727  for (int i=0;i<6;i++)
     728    cell_size[i] = cell_size_backup[i];
    734729
    735730  return result;
     
    892887  // center at set box dimensions
    893888  mol->CenterEdge(&center);
    894   Matrix domain;
    895   for(int i =0;i<NDIM;++i)
    896     domain.at(i,i) = center[i];
    897   World::getInstance().setDomain(domain);
     889  World::getInstance().getDomain()[0] = center[0];
     890  World::getInstance().getDomain()[1] = 0;
     891  World::getInstance().getDomain()[2] = center[1];
     892  World::getInstance().getDomain()[3] = 0;
     893  World::getInstance().getDomain()[4] = 0;
     894  World::getInstance().getDomain()[5] = center[2];
    898895  insert(mol);
    899896}
     
    10201017 * \param *out output stream for debugging
    10211018 * \param *reference reference molecule with the bond structure to be copied
    1022  * \param &FragmentCounter Counter needed to address \a **ListOfLocalAtoms
    1023  * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in \a *reference, may be NULL on start, then it is filled
     1019 * \param **&ListOfLocalAtoms Lookup table for this subgraph and index of each atom in \a *reference, may be NULL on start, then it is filled
    10241020 * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
    10251021 * \return true - success, false - faoilure
    10261022 */
    1027 bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList)
     1023bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList)
    10281024{
    10291025  atom *OtherWalker = NULL;
     
    10341030  DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl);
    10351031  // fill ListOfLocalAtoms if NULL was given
    1036   if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) {
     1032  if (!FillListOfLocalAtoms(ListOfLocalAtoms, reference->getAtomCount(), FreeList)) {
    10371033    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    10381034    return false;
     
    10511047      AtomNo = Father->nr; // global id of the current walker
    10521048      for (BondList::const_iterator Runner = Father->ListOfBonds.begin(); Runner != Father->ListOfBonds.end(); (++Runner)) {
    1053         OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker
     1049        OtherWalker = ListOfLocalAtoms[(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker
    10541050        if (OtherWalker != NULL) {
    10551051          if (OtherWalker->nr > (*iter)->nr)
    10561052            Leaf->AddBond((*iter), OtherWalker, (*Runner)->BondDegree);
    10571053        } else {
    1058           DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl);
     1054          DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << (*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl);
    10591055          status = false;
    10601056        }
     
    10651061  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
    10661062    // free the index lookup list
    1067     delete[](ListOfLocalAtoms[FragmentCounter]);
    1068     if (FragmentCounter == 0) // first fragments frees the initial pointer to list
    1069       delete[](ListOfLocalAtoms);
     1063    delete[](ListOfLocalAtoms);
    10701064  }
    10711065  DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl);
     
    11131107/** Fills a lookup list of father's Atom::nr -> atom for each subgraph.
    11141108 * \param *out output stream from debugging
    1115  * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
    1116  * \param FragmentCounter counts the fragments as we move along the list
     1109 * \param **&ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
    11171110 * \param GlobalAtomCount number of atoms in the complete molecule
    11181111 * \param &FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
    1119  * \return true - success, false - failure
    1120  */
    1121 bool MoleculeLeafClass::FillListOfLocalAtoms(atom ***&ListOfLocalAtoms, const int FragmentCounter, const int GlobalAtomCount, bool &FreeList)
     1112 * \return true - success, false - failure (ListOfLocalAtoms != NULL)
     1113 */
     1114bool MoleculeLeafClass::FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount, bool &FreeList)
    11221115{
    11231116  bool status = true;
    11241117
    1125   if (ListOfLocalAtoms == NULL) { // allocated initial pointer
    1126     // allocate and set each field to NULL
    1127     const int Counter = Count();
    1128     ASSERT(FragmentCounter < Counter, "FillListOfLocalAtoms: FragmenCounter greater than present fragments.");
    1129     ListOfLocalAtoms = new atom**[Counter];
    1130     if (ListOfLocalAtoms == NULL) {
    1131       FreeList = FreeList && false;
    1132       status = false;
    1133     }
    1134     for (int i=0;i<Counter;i++)
    1135       ListOfLocalAtoms[i] = NULL;
    1136   }
    1137 
    1138   if ((ListOfLocalAtoms != NULL) && (ListOfLocalAtoms[FragmentCounter] == NULL)) { // allocate and fill list of this fragment/subgraph
    1139     status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms[FragmentCounter], GlobalAtomCount);
     1118  if (ListOfLocalAtoms == NULL) { // allocate and fill list of this fragment/subgraph
     1119    status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms, GlobalAtomCount);
    11401120    FreeList = FreeList && true;
    1141   }
     1121  } else
     1122    return false;
    11421123
    11431124  return status;
     
    11611142  DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl);
    11621143  // fill ListOfLocalAtoms if NULL was given
    1163   if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) {
     1144  if (!FillListOfLocalAtoms(ListOfLocalAtoms[FragmentCounter], reference->getAtomCount(), FreeList)) {
    11641145    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    11651146    return false;
     
    12061187    // free the index lookup list
    12071188    delete[](ListOfLocalAtoms[FragmentCounter]);
    1208     if (FragmentCounter == 0) // first fragments frees the initial pointer to list
    1209       delete[](ListOfLocalAtoms);
    12101189  }
    12111190  DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl);
Note: See TracChangeset for help on using the changeset viewer.