Changeset 920c70 for src/molecule_fragmentation.cpp
- Timestamp:
- May 31, 2010, 1:09:58 PM (15 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 42af9e
- Parents:
- 87b597
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_fragmentation.cpp
r87b597 r920c70 94 94 GraphTestPair testGraphInsert; 95 95 int NumberOfFragments = 0; 96 char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - filename");96 char filename[MAXSTRINGSIZE]; 97 97 98 98 if (FragmentList == NULL) { // check list pointer … … 106 106 if (InputFile != NULL) { 107 107 // each line represents a new fragment 108 char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - *buffer");108 char buffer[MAXSTRINGSIZE]; 109 109 // 1. parse keysets and insert into temp. graph 110 110 while (!InputFile.eof()) { … … 122 122 InputFile.close(); 123 123 InputFile.clear(); 124 Free(&buffer);125 124 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 126 125 } else { … … 129 128 } 130 129 131 Free(&filename);132 130 return status; 133 131 }; … … 148 146 int NumberOfFragments = 0; 149 147 double TEFactor; 150 char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseTEFactorsFile - filename");148 char filename[MAXSTRINGSIZE]; 151 149 152 150 if (FragmentList == NULL) { // check list pointer … … 179 177 } 180 178 181 // free memory182 Free(&filename);183 184 179 return status; 185 180 }; … … 317 312 int No = 0, FragOrder = 0; 318 313 double Value = 0.; 319 char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::CheckOrderAtSite: *buffer");314 char buffer[MAXSTRINGSIZE]; 320 315 sprintf(buffer, "%s/%s%s.dat", path, FRAGMENTPREFIX, ENERGYPERFRAGMENT); 321 316 ifstream InputFile(buffer, ios::in); … … 345 340 InputFile.clear(); 346 341 } 347 Free(&buffer);348 342 349 343 return AdaptiveCriteriaList; … … 474 468 MarkUpdateCandidates(AtomMask, *FinalRootCandidates, Order, this); 475 469 476 Free(&IndexKeySetList);477 Free(&AdaptiveCriteriaList);478 Free(&FinalRootCandidates);470 delete[](IndexKeySetList); 471 delete[](AdaptiveCriteriaList); 472 delete[](FinalRootCandidates); 479 473 } else { // global increase of Bond Order 480 474 while (Walker->next != end) { … … 516 510 return false; 517 511 } 518 SortIndex = Malloc<int>(AtomCount, "molecule::CreateMappingLabelsToConfigSequence: *SortIndex");512 SortIndex = new int[AtomCount]; 519 513 for(int i=AtomCount;i--;) 520 514 SortIndex[i] = -1; … … 522 516 int AtomNo = 0; 523 517 SetIndexedArrayForEachAtomTo( SortIndex, &atom::nr, &IncrementalAbsoluteValue, AtomNo ); 518 delete[](SortIndex); 524 519 525 520 return true; … … 580 575 // === compare it with adjacency file === 581 576 FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(configuration->configpath, ListOfAtoms); 582 Free(&ListOfAtoms);577 delete[](ListOfAtoms); 583 578 584 579 // ===== 2. perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs ===== … … 672 667 delete(Subgraphs); 673 668 } 674 Free(&FragmentList);669 delete[](FragmentList); 675 670 676 671 // ===== 8b. gather keyset lists (graphs) from all subgraphs and transform into MoleculeListClass ===== … … 704 699 StoreKeySetFile(TotalGraph, configuration->configpath); 705 700 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); 701 { 702 // store Adjacency file 703 char filename[MAXSTRINGSIZE]; 704 strcpy(filename, FRAGMENTPREFIX); 705 strcat(filename, ADJACENCYFILE); 706 StoreAdjacencyToFile(configuration->configpath, filename); 707 } 712 708 713 709 // store Hydrogen saturation correction file … … 722 718 // free memory for bond part 723 719 DoLog(1) && (Log() << Verbose(1) << "Freeing bond memory" << endl); 724 Free(&FragmentList); // remove bond molecule from memory725 Free(&SortIndex);720 delete[](FragmentList); // remove bond molecule from memory 721 delete[](SortIndex); 726 722 } else { 727 723 DoLog(1) && (Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl); … … 768 764 bool molecule::ParseOrderAtSiteFromFile(char *path) 769 765 { 770 unsigned char *OrderArray = Calloc<unsigned char>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *OrderArray");771 bool *MaxArray = Calloc<bool>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *MaxArray");766 unsigned char *OrderArray = new unsigned char[AtomCount]; 767 bool *MaxArray = new bool[AtomCount]; 772 768 bool status; 773 769 int AtomNr, value; 774 770 stringstream line; 775 771 ifstream file; 772 773 for(int i=0;i<AtomCount;i++) { 774 OrderArray[i] = 0; 775 MaxArray[i] = false; 776 } 776 777 777 778 DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl); … … 802 803 status = false; 803 804 } 804 Free(&OrderArray);805 Free(&MaxArray);805 delete[](OrderArray); 806 delete[](MaxArray); 806 807 807 808 DoLog(1) && (Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl); … … 929 930 molecule * molecule::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem) 930 931 { 931 atom **SonList = Calloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList");932 atom **SonList = new atom*[AtomCount]; 932 933 molecule *Leaf = World::getInstance().createMolecule(); 934 935 for(int i=0;i<AtomCount;i++) 936 SonList[i] = NULL; 933 937 934 938 // Log() << Verbose(1) << "Begin of StoreFragmentFromKeyset." << endl; … … 939 943 940 944 //Leaflet->Leaf->ScanForPeriodicCorrection(out); 941 Free(&SonList);945 delete[](SonList); 942 946 // Log() << Verbose(1) << "End of StoreFragmentFromKeyset." << endl; 943 947 return Leaf; … … 1084 1088 int bits, TouchedIndex, SubSetDimension, SP, Added; 1085 1089 int SpaceLeft; 1086 int *TouchedList = Malloc<int>(SubOrder + 1, "molecule::SPFragmentGenerator: *TouchedList");1090 int *TouchedList = new int[SubOrder + 1]; 1087 1091 bond **BondsList = NULL; 1088 1092 KeySetTestPair TestKeySetInsert; … … 1124 1128 1125 1129 // then allocate and fill the list 1126 BondsList = Malloc<bond*>(SubSetDimension, "molecule::SPFragmentGenerator: **BondsList");1130 bond *BondsList[SubSetDimension]; 1127 1131 SubSetDimension = FillBondsList(BondsList, FragmentSearch->BondsPerSPList[2*SP], FragmentSearch->BondsPerSPList[2*SP+1], TouchedList, TouchedIndex); 1128 1132 … … 1130 1134 Log() << Verbose(2+verbosity) << "Calling subset generator " << SP << " away from root " << *FragmentSearch->Root << " with sub set dimension " << SubSetDimension << "." << endl; 1131 1135 SPFragmentGenerator(FragmentSearch, SP, BondsList, SubSetDimension, SubOrder-bits); 1132 1133 Free(&BondsList);1134 1136 } 1135 1137 } else { … … 1153 1155 } 1154 1156 } 1155 Free(&TouchedList);1157 delete[](TouchedList); 1156 1158 Log() << Verbose(1+verbosity) << "End of SPFragmentGenerator, " << RootDistance << " away from Root " << *FragmentSearch->Root << " and SubOrder is " << SubOrder << "." << endl; 1157 1159 }; … … 1165 1167 void InitialiseSPList(int Order, struct UniqueFragments &FragmentSearch) 1166 1168 { 1167 FragmentSearch.BondsPerSPList = Malloc<bond*>(Order * 2, "molecule::PowerSetGenerator: ***BondsPerSPList");1168 FragmentSearch.BondsPerSPCount = Malloc<int>(Order, "molecule::PowerSetGenerator: *BondsPerSPCount");1169 FragmentSearch.BondsPerSPList = new bond* [Order * 2]; 1170 FragmentSearch.BondsPerSPCount = new int[Order]; 1169 1171 for (int i=Order;i--;) { 1170 1172 FragmentSearch.BondsPerSPList[2*i] = new bond(); // start node … … 1184 1186 void FreeSPList(int Order, struct UniqueFragments &FragmentSearch) 1185 1187 { 1186 Free(&FragmentSearch.BondsPerSPCount);1188 delete[](FragmentSearch.BondsPerSPCount); 1187 1189 for (int i=Order;i--;) { 1188 1190 delete(FragmentSearch.BondsPerSPList[2*i]); 1189 1191 delete(FragmentSearch.BondsPerSPList[2*i+1]); 1190 1192 } 1191 Free(&FragmentSearch.BondsPerSPList);1193 delete[](FragmentSearch.BondsPerSPList); 1192 1194 }; 1193 1195 … … 1394 1396 1395 1397 // prepare the subset and call the generator 1396 BondsList = Calloc<bond*>(FragmentSearch.BondsPerSPCount[0], "molecule::PowerSetGenerator: **BondsList"); 1398 bond* BondsList[FragmentSearch.BondsPerSPCount[0]]; 1399 for(int i=0;i<FragmentSearch.BondsPerSPCount[0];i++) 1400 BondsList[i] = NULL; 1397 1401 BondsList[0] = FragmentSearch.BondsPerSPList[0]->next; // on SP level 0 there's only the root bond 1398 1402 1399 1403 SPFragmentGenerator(&FragmentSearch, 0, BondsList, FragmentSearch.BondsPerSPCount[0], Order); 1400 1401 Free(&BondsList);1402 1404 } else { 1403 1405 DoLog(0) && (Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl); … … 1507 1509 } 1508 1510 } 1509 Free(&FragmentLowerOrdersList[RootNr]);1511 delete[](FragmentLowerOrdersList[RootNr]); 1510 1512 RootNr++; 1511 1513 } 1512 Free(&FragmentLowerOrdersList);1514 delete[](FragmentLowerOrdersList); 1513 1515 }; 1514 1516 … … 1549 1551 // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5) 1550 1552 // 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"); 1553 NumMoleculesOfOrder = new int[UpgradeCount]; 1554 FragmentLowerOrdersList = new Graph**[UpgradeCount]; 1555 1556 for(int i=0;i<UpgradeCount;i++) { 1557 NumMoleculesOfOrder[i] = 0; 1558 FragmentLowerOrdersList[i] = NULL; 1559 } 1553 1560 1554 1561 // initialise the fragments structure … … 1556 1563 FragmentSearch.FragmentSet = new KeySet; 1557 1564 FragmentSearch.Root = FindAtom(RootKeyNr); 1558 FragmentSearch.ShortestPathList = Malloc<int>(AtomCount, "molecule::PowerSetGenerator: *ShortestPathList");1565 FragmentSearch.ShortestPathList = new int[AtomCount]; 1559 1566 for (int i=AtomCount;i--;) { 1560 1567 FragmentSearch.ShortestPathList[i] = -1; … … 1592 1599 // allocate memory for all lower level orders in this 1D-array of ptrs 1593 1600 NumLevels = 1 << (Order-1); // (int)pow(2,Order); 1594 FragmentLowerOrdersList[RootNr] = Calloc<Graph*>(NumLevels, "molecule::FragmentBOSSANOVA: **FragmentLowerOrdersList[]"); 1601 FragmentLowerOrdersList[RootNr] = new Graph*[NumLevels]; 1602 for (int i=0;i<NumLevels;i++) 1603 FragmentLowerOrdersList[RootNr][i] = NULL; 1595 1604 1596 1605 // create top order where nothing is reduced … … 1628 1637 1629 1638 // cleanup FragmentSearch structure 1630 Free(&FragmentSearch.ShortestPathList);1639 delete[](FragmentSearch.ShortestPathList); 1631 1640 delete(FragmentSearch.FragmentSet); 1632 1641 … … 1641 1650 CombineAllOrderListIntoOne(FragmentList, FragmentLowerOrdersList, RootStack, this); 1642 1651 FreeAllOrdersList(FragmentLowerOrdersList, RootStack, this); 1643 Free(&NumMoleculesOfOrder);1652 delete[](NumMoleculesOfOrder); 1644 1653 1645 1654 DoLog(0) && (Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl); … … 1669 1678 DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl); 1670 1679 1671 ColorList = Calloc<enum Shading>(AtomCount, "molecule::ScanForPeriodicCorrection: *ColorList"); 1680 ColorList = new enum Shading[AtomCount]; 1681 for (int i=0;i<AtomCount;i++) 1682 ColorList[i] = (enum Shading)0; 1672 1683 while (flag) { 1673 1684 // remove bonds that are beyond bonddistance … … 1729 1740 // free allocated space from ReturnFullMatrixforSymmetric() 1730 1741 delete(AtomStack); 1731 Free(&ColorList);1732 Free(&matrix);1742 delete[](ColorList); 1743 delete[](matrix); 1733 1744 DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl); 1734 1745 };
Note:
See TracChangeset
for help on using the changeset viewer.