From 471025aabc3b335c96fd0b3a3212683a7befc154 Mon Sep 17 00:00:00 2001 From: Sebastian Schunert Date: Fri, 29 Nov 2019 20:41:54 -0700 Subject: [PATCH] Add a routine that checks timestamps (#367) --- include/userobjects/LAMMPSFileRunner.h | 3 ++- src/userobjects/LAMMPSFileRunner.C | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/userobjects/LAMMPSFileRunner.h b/include/userobjects/LAMMPSFileRunner.h index 8deda6cf..f67c64a6 100644 --- a/include/userobjects/LAMMPSFileRunner.h +++ b/include/userobjects/LAMMPSFileRunner.h @@ -45,6 +45,8 @@ class LAMMPSFileRunner : public MDRunBase std::pair & filenames, std::pair & timestamps); + bool isTimestamp(std::string ts_candidate) const; + /// whether a sequence of input files or a single input file is read bool _time_sequence; @@ -60,4 +62,3 @@ class LAMMPSFileRunner : public MDRunBase /// Conversion from FEM time to MD time_stamp const Function * _time_conversion; }; - diff --git a/src/userobjects/LAMMPSFileRunner.C b/src/userobjects/LAMMPSFileRunner.C index cd7cff0b..3fb7f663 100644 --- a/src/userobjects/LAMMPSFileRunner.C +++ b/src/userobjects/LAMMPSFileRunner.C @@ -10,6 +10,8 @@ #include "MooseUtils.h" #include "Function.h" #include +#include +#include registerMooseObject("MagpieApp", LAMMPSFileRunner); @@ -136,9 +138,13 @@ LAMMPSFileRunner::findBracketingLAMMPSFiles(Real md_time, " failed. LAMMPS filename must be base..xyz where is the timestamp."); std::stringstream sstr(elements[1]); - if (sstr >> timestamp || sstr.eof()) - if (sstr.fail()) - continue; + if (!isTimestamp(elements[1])) + continue; + sstr >> timestamp; + + // if (sstr >> timestamp || sstr.eof()) + // if (sstr.fail()) + // continue; // increase the counter & check if this file is a candidate for before/after ++lammps_files_found; @@ -259,6 +265,15 @@ LAMMPSFileRunner::readLAMMPSFile(FileName filename) _md_particles.id.shrink_to_fit(); } +bool +LAMMPSFileRunner::isTimestamp(std::string ts_candidate) const +{ + for (auto & s : ts_candidate) + if (!isdigit(s)) + return false; + return true; +} + void LAMMPSFileRunner::readLAMMPSFileHistory(std::pair filenames, std::pair timestamps,