Changes in src/moleculelist.cpp [aafd77:c27778]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/moleculelist.cpp
raafd77 rc27778 5 5 */ 6 6 7 #ifdef HAVE_CONFIG_H8 #include <config.h>9 #endif10 11 7 #include "Helpers/MemDebug.hpp" 12 8 13 9 #include <cstring> 14 15 #include <gsl/gsl_inline.h>16 #include <gsl/gsl_heapsort.h>17 10 18 11 #include "World.hpp" … … 26 19 #include "linkedcell.hpp" 27 20 #include "lists.hpp" 28 #include "verbose.hpp"29 21 #include "log.hpp" 30 22 #include "molecule.hpp" 23 #include "memoryallocator.hpp" 31 24 #include "periodentafel.hpp" 32 25 #include "Helpers/Assert.hpp" 33 #include "Matrix.hpp"34 #include "Box.hpp"35 #include "stackclass.hpp"36 26 37 27 #include "Helpers/Assert.hpp" … … 641 631 int FragmentCounter = 0; 642 632 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]; 646 639 // store the fragments as config and as xyz 647 640 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) { … … 681 674 (*ListRunner)->CenterEdge(&BoxDimension); 682 675 (*ListRunner)->SetBoxDimension(&BoxDimension); // update Box of atoms by boundary 676 int j = -1; 683 677 for (int k = 0; k < NDIM; k++) { 678 j += k + 1; 684 679 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 } 688 682 (*ListRunner)->Translate(&BoxDimension); 689 683 … … 731 725 732 726 // 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]; 734 729 735 730 return result; … … 892 887 // center at set box dimensions 893 888 mol->CenterEdge(¢er); 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]; 898 895 insert(mol); 899 896 } … … 1020 1017 * \param *out output stream for debugging 1021 1018 * \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 1024 1020 * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not 1025 1021 * \return true - success, false - faoilure 1026 1022 */ 1027 bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList)1023 bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList) 1028 1024 { 1029 1025 atom *OtherWalker = NULL; … … 1034 1030 DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl); 1035 1031 // fill ListOfLocalAtoms if NULL was given 1036 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter,reference->getAtomCount(), FreeList)) {1032 if (!FillListOfLocalAtoms(ListOfLocalAtoms, reference->getAtomCount(), FreeList)) { 1037 1033 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl); 1038 1034 return false; … … 1051 1047 AtomNo = Father->nr; // global id of the current walker 1052 1048 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 walker1049 OtherWalker = ListOfLocalAtoms[(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker 1054 1050 if (OtherWalker != NULL) { 1055 1051 if (OtherWalker->nr > (*iter)->nr) 1056 1052 Leaf->AddBond((*iter), OtherWalker, (*Runner)->BondDegree); 1057 1053 } 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); 1059 1055 status = false; 1060 1056 } … … 1065 1061 if ((FreeList) && (ListOfLocalAtoms != NULL)) { 1066 1062 // 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); 1070 1064 } 1071 1065 DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl); … … 1113 1107 /** Fills a lookup list of father's Atom::nr -> atom for each subgraph. 1114 1108 * \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 1117 1110 * \param GlobalAtomCount number of atoms in the complete molecule 1118 1111 * \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 */ 1114 bool MoleculeLeafClass::FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount, bool &FreeList) 1122 1115 { 1123 1116 bool status = true; 1124 1117 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); 1140 1120 FreeList = FreeList && true; 1141 } 1121 } else 1122 return false; 1142 1123 1143 1124 return status; … … 1161 1142 DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl); 1162 1143 // fill ListOfLocalAtoms if NULL was given 1163 if (!FillListOfLocalAtoms(ListOfLocalAtoms , FragmentCounter, reference->getAtomCount(), FreeList)) {1144 if (!FillListOfLocalAtoms(ListOfLocalAtoms[FragmentCounter], reference->getAtomCount(), FreeList)) { 1164 1145 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl); 1165 1146 return false; … … 1206 1187 // free the index lookup list 1207 1188 delete[](ListOfLocalAtoms[FragmentCounter]); 1208 if (FragmentCounter == 0) // first fragments frees the initial pointer to list1209 delete[](ListOfLocalAtoms);1210 1189 } 1211 1190 DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl);
Note:
See TracChangeset
for help on using the changeset viewer.