Ignore:
Timestamp:
Jul 3, 2017, 3:07:28 PM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
ForceAnnealing_oldresults, IndependentFragmentGrids_IntegrationTest
Children:
092ede
Parents:
ef8667
git-author:
Frederik Heber <frederik.heber@…> (06/17/17 23:09:44)
git-committer:
Frederik Heber <frederik.heber@…> (07/03/17 15:07:28)
Message:

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

  • TESTS: Removed XFAIL from tests Tremolo with multiple time steps.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TremoloParser.cpp

    ref8667 r67e885  
    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 :
Note: See TracChangeset for help on using the changeset viewer.