Add TableFileReader
This commit is contained in:
50
src/table_file_reader.cpp
Normal file
50
src/table_file_reader.cpp
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/* -*- c++ -*- ----------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
http://lammps.sandia.gov, Sandia National Laboratories
|
||||||
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
Contributing authors: Richard Berger (Temple U)
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "lammps.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "table_file_reader.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "tokenizer.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
TableFileReader::TableFileReader(LAMMPS *lmp,
|
||||||
|
const std::string &filename) :
|
||||||
|
PotentialFileReader(lmp, filename, "table")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TableFileReader::~TableFileReader() {
|
||||||
|
}
|
||||||
|
|
||||||
|
char * TableFileReader::find_section_start(const std::string & keyword) {
|
||||||
|
char * line = nullptr;
|
||||||
|
while (line = reader->next_line()) {
|
||||||
|
ValueTokenizer values(line);
|
||||||
|
std::string word = values.next_string();
|
||||||
|
|
||||||
|
if (word == keyword) {
|
||||||
|
// matching keyword
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
35
src/table_file_reader.h
Normal file
35
src/table_file_reader.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* -*- c++ -*- ----------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
http://lammps.sandia.gov, Sandia National Laboratories
|
||||||
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
Contributing authors: Richard Berger (Temple U)
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifndef LMP_TABLE_FILE_READER_H
|
||||||
|
#define LMP_TABLE_FILE_READER_H
|
||||||
|
|
||||||
|
#include "potential_file_reader.h"
|
||||||
|
|
||||||
|
namespace LAMMPS_NS
|
||||||
|
{
|
||||||
|
class TableFileReader : public PotentialFileReader {
|
||||||
|
public:
|
||||||
|
TableFileReader(class LAMMPS *lmp, const std::string &filename);
|
||||||
|
virtual ~TableFileReader();
|
||||||
|
|
||||||
|
char * find_section_start(const std::string & keyword);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace LAMMPS_NS
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user