Changeset d067d45 for src/parser.cpp


Ignore:
Timestamp:
Jul 23, 2009, 1:45:24 PM (16 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

Merge branch 'MultipleMolecules'

Conflicts:

molecuilder/src/analyzer.cpp
molecuilder/src/atom.cpp
molecuilder/src/boundary.cpp
molecuilder/src/boundary.hpp
molecuilder/src/builder.cpp
molecuilder/src/config.cpp
molecuilder/src/datacreator.hpp
molecuilder/src/helpers.cpp
molecuilder/src/joiner.cpp
molecuilder/src/moleculelist.cpp
molecuilder/src/molecules.cpp
molecuilder/src/molecules.hpp
molecuilder/src/parser.cpp
molecuilder/src/parser.hpp
molecuilder/src/vector.cpp
molecuilder/src/verbose.cpp

merges:

compilation fixes:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/parser.cpp

    rce5ac3 rd067d45  
    22 *
    33 * Declarations of various class functions for the parsing of value files.
    4  *   
     4 *
    55 */
    66
    77// ======================================= INCLUDES ==========================================
    88
    9 #include "helpers.hpp" 
     9#include "helpers.hpp"
    1010#include "parser.hpp"
    1111
     
    2525{
    2626  ifstream input;
    27  
     27
    2828  input.open(filename, ios::in);
    2929  if (input == NULL) {
     
    145145 * \param skiplines number of inital columns to skip
    146146 * \param MatrixNr index number in Matrix array to parse into
    147  * \return parsing successful 
     147 * \return parsing successful
    148148 */
    149149bool MatrixContainer::ParseMatrix(const char *name, int skiplines, int skipcolumns, int MatrixNr)
     
    183183  // scan rest for number of rows/lines
    184184  RowCounter[MatrixNr]=-1;    // counts one line too much
    185   while (!input.eof()) { 
     185  while (!input.eof()) {
    186186    input.getline(filename, 1023);
    187187    //cout << "Comparing: " << strncmp(filename,"MeanForce",9) << endl;
     
    194194  if (RowCounter[MatrixNr] == 0)
    195195    cerr << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl;
    196  
     196
    197197  // allocate matrix if it's not zero dimension in one direction
    198198  if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) {
     
    233233/** Parsing a number of matrices.
    234234 * -# First, count the number of matrices by counting lines in KEYSETFILE
    235  * -# Then, 
     235 * -# Then,
    236236 *    -# construct the fragment number
    237237 *    -# open the matrix file
     
    241241 *    -# allocate matrix
    242242 *    -# 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
    244244 * \param *name directory with files
    245245 * \param *prefix prefix of each matrix file
     
    247247 * \param skiplines number of inital lines to skip
    248248 * \param skiplines number of inital columns to skip
    249  * \return parsing successful 
     249 * \return parsing successful
    250250 */
    251251bool MatrixContainer::ParseFragmentMatrix(char *name, char *prefix, string suffix, int skiplines, int skipcolumns)
     
    256256  stringstream file;
    257257  string token;
    258  
     258
    259259  // count the number of matrices
    260260  MatrixCounter = -1; // we count one too much
     
    270270    MatrixCounter++;
    271271  }
    272   input.close(); 
     272  input.close();
    273273  cout << "Determined " << MatrixCounter << " fragments." << endl;
    274  
     274
    275275  cout << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl;
    276276  Header = (char **) ReAlloc(Header, sizeof(char *)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: **Header"); // one more each for the total molecule
     
    421421                if (m == MatrixValues.Indices[ KeySet.OrderSet[Order][CurrentFragment] ][l]) {
    422422                  m = l;
    423                   break; 
     423                  break;
    424424                }
    425425              }
     
    447447   //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;
    448448  }
    449  
     449
    450450  return true;
    451451};
     
    512512
    513513// ======================================= 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 */
     519bool 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};
    514530
    515531/** Sums the energy with each factor and put into last element of \a EnergyMatrix::Matrix.
     
    545561 * \param skiplines number of inital columns to skip
    546562 * \return parsing successful
    547  */ 
     563 */
    548564bool EnergyMatrix::ParseFragmentMatrix(char *name, char *prefix, string suffix, int skiplines, int skipcolumns)
    549565{
     
    580596/** Parsing force Indices of each fragment
    581597 * \param *name directory with \a ForcesFile
    582  * \return parsing successful 
    583  */
    584 bool ForceMatrix::ParseIndices(char *name) 
     598 * \return parsing successful
     599 */
     600bool ForceMatrix::ParseIndices(char *name)
    585601{
    586602  ifstream input;
     
    588604  char filename[1023];
    589605  stringstream line;
    590  
     606
    591607  cout << "Parsing force indices for " << MatrixCounter << " matrices." << endl;
    592608  Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "ForceMatrix::ParseIndices: **Indices");
     
    659675 * \param skiplines number of inital columns to skip
    660676 * \return parsing successful
    661  */ 
     677 */
    662678bool ForceMatrix::ParseFragmentMatrix(char *name, char *prefix, string suffix, int skiplines, int skipcolumns)
    663679{
     
    932948    ParseMatrix(filename, skiplines, skipcolumns, MatrixCounter);
    933949  }
    934  
     950
    935951
    936952  return status;
     
    974990  stringstream file;
    975991  char filename[1023];
    976  
     992
    977993  FragmentCounter = FCounter;
    978994  cout << "Parsing key sets." << endl;
     
    9861002    return false;
    9871003  }
    988  
     1004
    9891005  AtomCounter = (int *) Malloc(sizeof(int)*FragmentCounter, "KeySetsContainer::ParseKeySets: *RowCounter");
    9901006  for(int i=0;(i<FragmentCounter) && (!input.eof());i++) {
     
    10161032{
    10171033  int Counter;
    1018  
     1034
    10191035  cout << "Creating Fragment terms." << endl;
    10201036  // scan through all to determine maximum order
     
    10291045  }
    10301046  cout << "Found Order is " << Order << "." << endl;
    1031  
     1047
    10321048  // scan through all to determine fragments per order
    10331049  FragmentsPerOrder = (int *) Malloc(sizeof(int)*Order, "KeySetsContainer::ParseManyBodyTerms: *FragmentsPerOrder");
     
    10431059  for(int i=0;i<Order;i++)
    10441060    cout << "Found No. of Fragments of Order " << i+1 << " is " << FragmentsPerOrder[i] << "." << endl;
    1045    
     1061
    10461062  // scan through all to gather indices to each order set
    10471063  OrderSet = (int **) Malloc(sizeof(int *)*Order, "KeySetsContainer::ParseManyBodyTerms: **OrderSet");
     
    10661082  }
    10671083  cout << endl;
    1068  
    1069    
     1084
     1085
    10701086  return true;
    10711087};
Note: See TracChangeset for help on using the changeset viewer.