Changeset d067d45 for src/parser.cpp
- Timestamp:
- Jul 23, 2009, 1:45:24 PM (16 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, Candidate_v1.7.0, 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:
- 51c910
- Parents:
- ce5ac3 (diff), 437922 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - git-author:
- Frederik Heber <heber@…> (07/23/09 12:34:47)
- git-committer:
- Frederik Heber <heber@…> (07/23/09 13:45:24)
- File:
-
- 1 edited
-
src/parser.cpp (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/parser.cpp
rce5ac3 rd067d45 2 2 * 3 3 * Declarations of various class functions for the parsing of value files. 4 * 4 * 5 5 */ 6 6 7 7 // ======================================= INCLUDES ========================================== 8 8 9 #include "helpers.hpp" 9 #include "helpers.hpp" 10 10 #include "parser.hpp" 11 11 … … 25 25 { 26 26 ifstream input; 27 27 28 28 input.open(filename, ios::in); 29 29 if (input == NULL) { … … 145 145 * \param skiplines number of inital columns to skip 146 146 * \param MatrixNr index number in Matrix array to parse into 147 * \return parsing successful 147 * \return parsing successful 148 148 */ 149 149 bool MatrixContainer::ParseMatrix(const char *name, int skiplines, int skipcolumns, int MatrixNr) … … 183 183 // scan rest for number of rows/lines 184 184 RowCounter[MatrixNr]=-1; // counts one line too much 185 while (!input.eof()) { 185 while (!input.eof()) { 186 186 input.getline(filename, 1023); 187 187 //cout << "Comparing: " << strncmp(filename,"MeanForce",9) << endl; … … 194 194 if (RowCounter[MatrixNr] == 0) 195 195 cerr << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl; 196 196 197 197 // allocate matrix if it's not zero dimension in one direction 198 198 if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) { … … 233 233 /** Parsing a number of matrices. 234 234 * -# First, count the number of matrices by counting lines in KEYSETFILE 235 * -# Then, 235 * -# Then, 236 236 * -# construct the fragment number 237 237 * -# open the matrix file … … 241 241 * -# allocate matrix 242 242 * -# loop over found column and row counts and parse in each entry 243 * -# Finally, allocate one additional matrix (\a MatrixCounter) containing combined or temporary values 243 * -# Finally, allocate one additional matrix (\a MatrixCounter) containing combined or temporary values 244 244 * \param *name directory with files 245 245 * \param *prefix prefix of each matrix file … … 247 247 * \param skiplines number of inital lines to skip 248 248 * \param skiplines number of inital columns to skip 249 * \return parsing successful 249 * \return parsing successful 250 250 */ 251 251 bool MatrixContainer::ParseFragmentMatrix(char *name, char *prefix, string suffix, int skiplines, int skipcolumns) … … 256 256 stringstream file; 257 257 string token; 258 258 259 259 // count the number of matrices 260 260 MatrixCounter = -1; // we count one too much … … 270 270 MatrixCounter++; 271 271 } 272 input.close(); 272 input.close(); 273 273 cout << "Determined " << MatrixCounter << " fragments." << endl; 274 274 275 275 cout << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl; 276 276 Header = (char **) ReAlloc(Header, sizeof(char *)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: **Header"); // one more each for the total molecule … … 421 421 if (m == MatrixValues.Indices[ KeySet.OrderSet[Order][CurrentFragment] ][l]) { 422 422 m = l; 423 break; 423 break; 424 424 } 425 425 } … … 447 447 //cout << "Final Fragments[ KeySet.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << KeySet.AtomCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][KeySet.AtomCounter[0]-1][1] << endl; 448 448 } 449 449 450 450 return true; 451 451 }; … … 512 512 513 513 // ======================================= CLASS EnergyMatrix ============================= 514 515 /** Create a trivial energy index mapping. 516 * This just maps 1 to 1, 2 to 2 and so on for all fragments. 517 * \return creation sucessful 518 */ 519 bool EnergyMatrix::ParseIndices() 520 { 521 cout << "Parsing energy indices." << endl; 522 Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "EnergyMatrix::ParseIndices: **Indices"); 523 for(int i=MatrixCounter+1;i--;) { 524 Indices[i] = (int *) Malloc(sizeof(int)*RowCounter[i], "EnergyMatrix::ParseIndices: *Indices[]"); 525 for(int j=RowCounter[i];j--;) 526 Indices[i][j] = j; 527 } 528 return true; 529 }; 514 530 515 531 /** Sums the energy with each factor and put into last element of \a EnergyMatrix::Matrix. … … 545 561 * \param skiplines number of inital columns to skip 546 562 * \return parsing successful 547 */ 563 */ 548 564 bool EnergyMatrix::ParseFragmentMatrix(char *name, char *prefix, string suffix, int skiplines, int skipcolumns) 549 565 { … … 580 596 /** Parsing force Indices of each fragment 581 597 * \param *name directory with \a ForcesFile 582 * \return parsing successful 583 */ 584 bool ForceMatrix::ParseIndices(char *name) 598 * \return parsing successful 599 */ 600 bool ForceMatrix::ParseIndices(char *name) 585 601 { 586 602 ifstream input; … … 588 604 char filename[1023]; 589 605 stringstream line; 590 606 591 607 cout << "Parsing force indices for " << MatrixCounter << " matrices." << endl; 592 608 Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "ForceMatrix::ParseIndices: **Indices"); … … 659 675 * \param skiplines number of inital columns to skip 660 676 * \return parsing successful 661 */ 677 */ 662 678 bool ForceMatrix::ParseFragmentMatrix(char *name, char *prefix, string suffix, int skiplines, int skipcolumns) 663 679 { … … 932 948 ParseMatrix(filename, skiplines, skipcolumns, MatrixCounter); 933 949 } 934 950 935 951 936 952 return status; … … 974 990 stringstream file; 975 991 char filename[1023]; 976 992 977 993 FragmentCounter = FCounter; 978 994 cout << "Parsing key sets." << endl; … … 986 1002 return false; 987 1003 } 988 1004 989 1005 AtomCounter = (int *) Malloc(sizeof(int)*FragmentCounter, "KeySetsContainer::ParseKeySets: *RowCounter"); 990 1006 for(int i=0;(i<FragmentCounter) && (!input.eof());i++) { … … 1016 1032 { 1017 1033 int Counter; 1018 1034 1019 1035 cout << "Creating Fragment terms." << endl; 1020 1036 // scan through all to determine maximum order … … 1029 1045 } 1030 1046 cout << "Found Order is " << Order << "." << endl; 1031 1047 1032 1048 // scan through all to determine fragments per order 1033 1049 FragmentsPerOrder = (int *) Malloc(sizeof(int)*Order, "KeySetsContainer::ParseManyBodyTerms: *FragmentsPerOrder"); … … 1043 1059 for(int i=0;i<Order;i++) 1044 1060 cout << "Found No. of Fragments of Order " << i+1 << " is " << FragmentsPerOrder[i] << "." << endl; 1045 1061 1046 1062 // scan through all to gather indices to each order set 1047 1063 OrderSet = (int **) Malloc(sizeof(int *)*Order, "KeySetsContainer::ParseManyBodyTerms: **OrderSet"); … … 1066 1082 } 1067 1083 cout << endl; 1068 1069 1084 1085 1070 1086 return true; 1071 1087 };
Note:
See TracChangeset
for help on using the changeset viewer.
