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:
33af20
Parents:
220d2c
git-author:
Frederik Heber <frederik.heber@…> (06/17/17 23:09:19)
git-committer:
Frederik Heber <frederik.heber@…> (07/12/17 19:10:07)
Message:

Extracted getMinMaxTrajectories() into FormatParser_common.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/FormatParser_common.cpp

    r220d2c r0e894a  
    3636
    3737#include <iostream>
    38 
     38#include <limits>
     39
     40#include "CodePatterns/Assert.hpp"
    3941#include "CodePatterns/Observer/Notification.hpp"
    4042#include "World.hpp"
     
    179181  return iter->second;
    180182}
     183
     184std::pair<size_t, size_t> FormatParser_common::getMinMaxTrajectories(
     185    const std::vector<const atom *> &_atoms) const
     186{
     187  // get max and min trajectories
     188  size_t min_trajectories = std::numeric_limits<size_t>::max();
     189  size_t max_trajectories = std::numeric_limits<size_t>::min();
     190  for (std::vector<const atom *>::const_iterator iter = _atoms.begin();
     191      iter != _atoms.end();
     192      ++iter) {
     193    if (max_trajectories < (*iter)->getTrajectorySize())
     194      max_trajectories = (*iter)->getTrajectorySize();
     195    if (min_trajectories > (*iter)->getTrajectorySize())
     196      min_trajectories = (*iter)->getTrajectorySize();
     197  }
     198  // no atoms? Then, they all have same amount
     199  if (_atoms.size() == 0)
     200    min_trajectories = max_trajectories = 1;
     201  ASSERT(min_trajectories == max_trajectories,
     202      "FormatParser_common::getMinMaxTrajectories() - not all atoms have same number of trajectories: "
     203      +toString(min_trajectories)+" != "+toString(max_trajectories)+".");
     204
     205  return std::make_pair(min_trajectories, max_trajectories);
     206}
Note: See TracChangeset for help on using the changeset viewer.