Changeset 33af20


Ignore:
Timestamp:
Jul 12, 2017, 7:10:07 PM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Action_Thermostats, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, Fix_Verbose_Codepatterns, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, Recreated_GuiChecks, StoppableMakroAction, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps
Children:
70f2a1
Parents:
0e894a
git-author:
Frederik Heber <frederik.heber@…> (06/17/17 23:09:44)
git-committer:
Frederik Heber <frederik.heber@…> (07/12/17 19:10:07)
Message:

TremoloParser::save() now supports multiple time steps.

  • TESTS: Removed XFAIL from tests Tremolo with multiple time steps.
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TremoloParser.cpp

    r0e894a r33af20  
    146146  size_t timestep = 0;
    147147  atom *addedatom = NULL;
    148   std::vector<atom *> addedatoms;
    149   std::vector<atom *>::iterator atomiter = addedatoms.begin();
     148  std::list<atom *> addedatoms;
     149  std::list<atom *>::iterator atomiter = addedatoms.begin();
    150150  while (file->good()) {
    151151    std::getline(*file, line, '\n');
     
    226226  distributeContinuousIds(AtomList);
    227227
    228   // store atomdata
    229   save_AtomDataLine(file);
    230 
    231   // store box
    232   save_BoxLine(file);
    233 
    234   // store particles
    235   for (std::vector<const atom*>::const_iterator  atomIt = AtomList.begin();
    236       atomIt != AtomList.end(); ++atomIt)
    237     saveLine(file, *atomIt);
     228  std::pair<size_t, size_t> minmax_trajectories =
     229      getMinMaxTrajectories(AtomList);
     230  LOG(2, "INFO: There are " << minmax_trajectories.second << " steps to save.");
     231
     232  for (size_t step = 0; (step < minmax_trajectories.second) || (step == 0); ++step) {
     233    // store atomdata
     234    save_AtomDataLine(file);
     235
     236    // store box only on first step
     237    if (step == 0)
     238      save_BoxLine(file);
     239
     240    // store particles
     241    for (std::vector<const atom*>::const_iterator  atomIt = AtomList.begin();
     242        atomIt != AtomList.end(); ++atomIt)
     243      saveLine(file, *atomIt, step);
     244  }
    238245}
    239246
     
    495502void FormatParser< tremolo >::saveLine(
    496503    std::ostream* file,
    497     const atom * const currentAtom)
     504    const atom * const currentAtom,
     505    const size_t _timestep)
    498506{
    499507  TremoloKey::atomDataKey currentField;
    500508
    501   LOG(4, "INFO: Saving atom " << *currentAtom << ", its father id is " << currentAtom->GetTrueFather()->getId());
     509  LOG(4, "INFO: Saving atom " << *currentAtom << ", its father id is "
     510      << currentAtom->GetTrueFather()->getId() << " at time step " << _timestep);
    502511
    503512  for (usedFields_t::iterator it = usedFields_save.begin(); it != usedFields_save.end(); it++) {
     
    506515      case TremoloKey::x :
    507516        // for the moment, assume there are always three dimensions
    508         LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << currentAtom->getPosition());
    509         *file << currentAtom->at(0) << "\t";
    510         *file << currentAtom->at(1) << "\t";
    511         *file << currentAtom->at(2) << "\t";
     517        LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << currentAtom->getPositionAtStep(_timestep));
     518        *file << currentAtom->atStep(0, _timestep) << "\t";
     519        *file << currentAtom->atStep(1, _timestep) << "\t";
     520        *file << currentAtom->atStep(2, _timestep) << "\t";
    512521        break;
    513522      case TremoloKey::u :
    514523        // for the moment, assume there are always three dimensions
    515         LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << currentAtom->getAtomicVelocity());
    516         *file << currentAtom->getAtomicVelocity()[0] << "\t";
    517         *file << currentAtom->getAtomicVelocity()[1] << "\t";
    518         *file << currentAtom->getAtomicVelocity()[2] << "\t";
     524        LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << currentAtom->getAtomicVelocityAtStep(_timestep));
     525        *file << currentAtom->getAtomicVelocityAtStep(_timestep)[0] << "\t";
     526        *file << currentAtom->getAtomicVelocityAtStep(_timestep)[1] << "\t";
     527        *file << currentAtom->getAtomicVelocityAtStep(_timestep)[2] << "\t";
    519528        break;
    520529      case TremoloKey::F :
    521530        // for the moment, assume there are always three dimensions
    522         LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << currentAtom->getAtomicForce());
    523         *file << currentAtom->getAtomicForce()[0] << "\t";
    524         *file << currentAtom->getAtomicForce()[1] << "\t";
    525         *file << currentAtom->getAtomicForce()[2] << "\t";
     531        LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << currentAtom->getAtomicForceAtStep(_timestep));
     532        *file << currentAtom->getAtomicForceAtStep(_timestep)[0] << "\t";
     533        *file << currentAtom->getAtomicForceAtStep(_timestep)[1] << "\t";
     534        *file << currentAtom->getAtomicForceAtStep(_timestep)[2] << "\t";
    526535        break;
    527536      case TremoloKey::type :
  • src/Parser/TremoloParser.hpp

    r0e894a r33af20  
    9494  bool isUsedField(const usedFields_t &fields, const std::string &fieldName) const;
    9595  void writeNeighbors(std::ostream* file, const int numberOfNeighbors, const atom* const currentAtom);
    96   void saveLine(std::ostream* file, const atom* const currentAtom);
     96  void saveLine(
     97      std::ostream* file,
     98      const atom* const currentAtom,
     99      const size_t _timestep);
    97100  void save_AtomDataLine(std::ostream* file) const;
    98101  void save_BoxLine(std::ostream* file) const;
  • tests/regression/Parser/Tremolo/testsuite-parser-tremolo-load-multiple-timesteps.at

    r0e894a r33af20  
    2121AT_SETUP([Parser - loading tremolo file with multiple timesteps])
    2222AT_KEYWORDS([parser load tremolo timesteps])
    23 # ::save() does not yet support multiple time steps
    24 AT_XFAIL_IF([/bin/true])
    2523
    2624file=water_multipletimesteps.data
     
    3331AT_SETUP([Parser - loading tremolo file with multiple timesteps with Undo])
    3432AT_KEYWORDS([parser load tremolo timesteps undo])
    35 # with undo we don't notice missing save() implementation
    36 AT_XFAIL_IF([/bin/false])
    3733
    3834file=water_multipletimesteps.data
     
    4541AT_SETUP([Parser - loading tremolo file with multiple timesteps with Redo])
    4642AT_KEYWORDS([parser load tremolo redo])
    47 # ::save() does not yet support multiple time steps
    48 AT_XFAIL_IF([/bin/true])
    4943
    5044file=water_multipletimesteps.data
Note: See TracChangeset for help on using the changeset viewer.