Unverified Commit d478ad2c authored by Richard Berger's avatar Richard Berger
Browse files

Refactor PotentialFileReader

parent 24a0933e
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -34,10 +34,10 @@ PotentialFileReader::PotentialFileReader(LAMMPS *lmp,
  Pointers(lmp),
  reader(nullptr),
  filename(filename),
  potential_name(potential_name)
  filetype(potential_name + " potential")
{
  if (comm->me != 0) {
    error->one(FLERR, "PotentialFileReader should only be called by proc 0!");
    error->one(FLERR, "FileReader should only be called by proc 0!");
  }

  try {
@@ -112,7 +112,7 @@ TextFileReader * PotentialFileReader::open_potential(const std::string& path) {
    utils::logmesg(lmp, fmt::format("Reading potential file {} with DATE: {}", filename, date));
  }

  return new TextFileReader(filepath, potential_name + " potential");
  return new TextFileReader(filepath, filetype);
}

/* ----------------------------------------------------------------------
@@ -121,7 +121,7 @@ TextFileReader * PotentialFileReader::open_potential(const std::string& path) {
------------------------------------------------------------------------- */

std::string PotentialFileReader::get_potential_date(const std::string & path) {
  TextFileReader reader(path, potential_name + " potential");
  TextFileReader reader(path, filetype);
  reader.ignore_comments = false;
  char * line = nullptr;

+4 −3
Original line number Diff line number Diff line
@@ -26,19 +26,20 @@
namespace LAMMPS_NS
{
  class PotentialFileReader : protected Pointers {
  protected:
    TextFileReader * reader;
    std::string filename;
    std::string potential_name;
    std::string filetype;

    TextFileReader * open_potential(const std::string& path);
    std::string get_potential_date(const std::string & path);

  public:
    PotentialFileReader(class LAMMPS *lmp, const std::string &filename, const std::string &potential_name);
    ~PotentialFileReader();
    virtual ~PotentialFileReader();

    void skip_line();
    char * next_line(int nparams);
    char * next_line(int nparams = 0);
    void next_dvector(int n, double * list);
  };