Changeset 8b58ac for src


Ignore:
Timestamp:
Nov 16, 2012, 2:03:40 PM (12 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, 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:
a67a04
Parents:
fb69e9
git-author:
Frederik Heber <heber@…> (11/16/12 14:01:22)
git-committer:
Frederik Heber <heber@…> (11/16/12 14:03:40)
Message:

KeySetsContainer::ParseKeySets() may now parse arbitrary files.

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FragmentationAction/FragmentationAutomationAction.cpp

    rfb69e9 r8b58ac  
    3838
    3939#include "CodePatterns/MemDebug.hpp"
    40 
    41 #include <boost/assign.hpp>
    4240
    4341#include "CodePatterns/Assert.hpp"
     
    6058#include "Fragmentation/Summation/printSum.hpp"
    6159#include "Graph/DepthFirstSearchAnalysis.hpp"
     60#include "Helpers/defs.hpp"
    6261#include "Jobs/MPQCJob.hpp"
    6362#include "Jobs/MPQCData.hpp"
     
    7978
    8079using namespace MoleCuilder;
    81 
    82 using namespace boost::assign;
    8380
    8481// and construct the stuff
     
    282279  // initialise indices
    283280  KeySetsContainer KeySet;
     281  KeySetsContainer ForceKeySet;
    284282  if (!Energy.InitialiseIndices()) return false;
    285283
    286284  if (!Force.ParseIndices(KeySetFilename.c_str())) return false;
    287285
    288   if (!KeySet.ParseKeySets(KeySetFilename.c_str(), Force.RowCounter, Force.MatrixCounter)) return false;
    289 
    290   /// prepare for OrthogonalSummation
     286  {
     287    std::stringstream filename;
     288    filename << FRAGMENTPREFIX << KEYSETFILE;
     289    if (!KeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false;
     290  }
     291
     292  {
     293    std::stringstream filename;
     294    filename << FRAGMENTPREFIX << FORCESFILE;
     295    if (!ForceKeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false;
     296  }
    291297
    292298  // forces need different keysets: they must include hydrogen
  • src/Fragmentation/KeySetsContainer.cpp

    rfb69e9 r8b58ac  
    3737#include <fstream>
    3838#include <sstream>
     39
     40#include <boost/lexical_cast.hpp>
     41#include <boost/tokenizer.hpp>
    3942
    4043#include "CodePatterns/Log.hpp"
     
    7275 * \return parsing succesful
    7376 */
    74 bool KeySetsContainer::ParseKeySets(const std::string name, const IntVector ACounter, const int FCounter) {
     77bool KeySetsContainer::ParseKeySets(const std::string path, const std::string name, const int FCounter) {
    7578  ifstream input;
    76   char *FragmentNumber = NULL;
     79  //char *FragmentNumber = NULL;
    7780  stringstream file;
    7881  char filename[1023];
    7982
    8083  FragmentCounter = FCounter;
    81   LOG(0, "Parsing key sets.");
    8284  KeySets.resize(FragmentCounter);
    83   file << name << FRAGMENTPREFIX << KEYSETFILE;
     85  AtomCounter.resize(FragmentCounter);
     86
     87  // open file
     88  file << path << "/" << name;
    8489  input.open(file.str().c_str(), ios::in);
    8590  if (input.fail()) {
     
    8893  }
    8994
    90   AtomCounter.resize(FragmentCounter);
     95  // parse each line, i.e. get the index set per fragment
     96  LOG(0, "Parsing key sets.");
    9197  for(int i=0;(i<FragmentCounter) && (!input.eof());i++) {
    92     stringstream line;
    93     AtomCounter[i] = ACounter[i];
    94     // parse the values
    95     KeySets[i].resize(AtomCounter[i]);
    96     for(int j=AtomCounter[i];j--;)
    97       KeySets[i][j] = -1;
    98     FragmentNumber = FixedDigitNumber(FragmentCounter, i);
    99     //std::stringstream output;
    100     //output << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:";
    101     delete[](FragmentNumber);
    10298    input.getline(filename, 1023);
    103     line.str(filename);
    104     for(int j=0;(j<AtomCounter[i]) && (!line.eof());j++) {
    105       line >> KeySets[i][j];
    106       //output << " " << KeySets[i][j];
     99    string line(filename);
     100//    LOG(2, "DEBUG: line is " << line << ".");
     101    std::stringstream set_output;
     102    typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
     103    boost::char_separator<char> sep(" \t");
     104    tokenizer tok(line, sep);
     105    for(tokenizer::iterator beg=tok.begin();
     106        beg != tok.end();++beg){
     107      const int tempvalue = boost::lexical_cast<int>(*beg);
     108      KeySets[i].push_back(tempvalue);
     109//      set_output << " " << KeySets[i].back();
    107110    }
    108     //LOG(0, output.str());
     111//    LOG(2, "DEBUG: Scanned keys are '" << set_output.str() << "'.");
     112    AtomCounter[i] = KeySets[i].size();
     113//    {
     114//      std::stringstream output;
     115//      FragmentNumber = FixedDigitNumber(FragmentCounter, i);
     116//      output << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:" << set_output.str();
     117//      delete[](FragmentNumber);
     118//      LOG(0, output.str());
     119//    }
    109120  }
    110121  input.close();
  • src/Fragmentation/KeySetsContainer.hpp

    rfb69e9 r8b58ac  
    3535  ~KeySetsContainer();
    3636
    37   bool ParseKeySets(const std::string name, const std::vector<int> ACounter, const int FCounter);
     37  bool ParseKeySets(const std::string path, const std::string name, const int FCounter);
    3838  bool ParseManyBodyTerms();
    3939  bool Contains(const int GreaterSet, const int SmallerSet);
  • src/Fragmentation/analyzer.cpp

    rfb69e9 r8b58ac  
    182182
    183183  // ---------- Parse the KeySets into an array ---------------
    184   if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
     184  {
     185    std::stringstream filename;
     186    filename << FRAGMENTPREFIX << KEYSETFILE;
     187    if (!KeySet.ParseKeySets(argv[1], filename.str(), Force.MatrixCounter)) return 1;
     188  }
    185189  if (!KeySet.ParseManyBodyTerms()) return 1;
    186190
  • src/Fragmentation/joiner.cpp

    rfb69e9 r8b58ac  
    147147
    148148  // ---------- Parse the KeySets into an array ---------------
    149   if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
     149  {
     150    std::stringstream filename;
     151    filename << FRAGMENTPREFIX << KEYSETFILE;
     152    if (!KeySet.ParseKeySets(argv[1], filename.str(), Force.MatrixCounter)) return 1;
     153  }
    150154
    151155  if (!KeySet.ParseManyBodyTerms()) return 1;
  • src/controller_MPQCCommandJob.cpp

    rfb69e9 r8b58ac  
    217217  if (!Force.ParseIndices(KeySetFilename.c_str())) return false;
    218218
    219   if (!KeySet.ParseKeySets(KeySetFilename.c_str(), Force.RowCounter, Force.MatrixCounter)) return false;
     219  {
     220    std::stringstream filename;
     221    filename << FRAGMENTPREFIX << KEYSETFILE;
     222    if (!KeySet.ParseKeySets(KeySetFilename.c_str(), filename.str(), Force.MatrixCounter)) return 1;
     223  }
    220224
    221225  if (!KeySet.ParseManyBodyTerms()) return false;
Note: See TracChangeset for help on using the changeset viewer.