Refactor PotentialFileReader
This commit is contained in:
@ -34,10 +34,10 @@ PotentialFileReader::PotentialFileReader(LAMMPS *lmp,
|
|||||||
Pointers(lmp),
|
Pointers(lmp),
|
||||||
reader(nullptr),
|
reader(nullptr),
|
||||||
filename(filename),
|
filename(filename),
|
||||||
potential_name(potential_name)
|
filetype(potential_name + " potential")
|
||||||
{
|
{
|
||||||
if (comm->me != 0) {
|
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 {
|
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));
|
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) {
|
std::string PotentialFileReader::get_potential_date(const std::string & path) {
|
||||||
TextFileReader reader(path, potential_name + " potential");
|
TextFileReader reader(path, filetype);
|
||||||
reader.ignore_comments = false;
|
reader.ignore_comments = false;
|
||||||
char * line = nullptr;
|
char * line = nullptr;
|
||||||
|
|
||||||
|
|||||||
@ -26,19 +26,20 @@
|
|||||||
namespace LAMMPS_NS
|
namespace LAMMPS_NS
|
||||||
{
|
{
|
||||||
class PotentialFileReader : protected Pointers {
|
class PotentialFileReader : protected Pointers {
|
||||||
|
protected:
|
||||||
TextFileReader * reader;
|
TextFileReader * reader;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
std::string potential_name;
|
std::string filetype;
|
||||||
|
|
||||||
TextFileReader * open_potential(const std::string& path);
|
TextFileReader * open_potential(const std::string& path);
|
||||||
std::string get_potential_date(const std::string & path);
|
std::string get_potential_date(const std::string & path);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PotentialFileReader(class LAMMPS *lmp, const std::string &filename, const std::string &potential_name);
|
PotentialFileReader(class LAMMPS *lmp, const std::string &filename, const std::string &potential_name);
|
||||||
~PotentialFileReader();
|
virtual ~PotentialFileReader();
|
||||||
|
|
||||||
void skip_line();
|
void skip_line();
|
||||||
char * next_line(int nparams);
|
char * next_line(int nparams = 0);
|
||||||
void next_dvector(int n, double * list);
|
void next_dvector(int n, double * list);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user