reformat with clang-format

This commit is contained in:
Axel Kohlmeyer
2021-07-20 18:31:52 -04:00
parent b9cc8c8d24
commit c19d37990d
2 changed files with 71 additions and 67 deletions

View File

@ -1,4 +1,3 @@
// clang-format off
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -45,26 +44,20 @@ using namespace LAMMPS_NS;
* \param auto_convert Bitmask of supported unit conversions
*/
PotentialFileReader::PotentialFileReader(LAMMPS *lmp,
const std::string &filename,
PotentialFileReader::PotentialFileReader(LAMMPS *lmp, const std::string &filename,
const std::string &potential_name,
const std::string &name_suffix,
const int auto_convert) :
Pointers(lmp),
reader(nullptr),
filename(filename),
filetype(potential_name + name_suffix),
unit_convert(auto_convert)
const std::string &name_suffix, const int auto_convert) :
Pointers(lmp),
reader(nullptr), filename(filename), filetype(potential_name + name_suffix),
unit_convert(auto_convert)
{
if (comm->me != 0) {
error->one(FLERR, "FileReader should only be called by proc 0!");
}
if (comm->me != 0) { error->one(FLERR, "FileReader should only be called by proc 0!"); }
try {
reader = open_potential(filename);
if (!reader) {
error->one(FLERR, "cannot open {} potential file {}: {}",
potential_name, filename, utils::getsyserror());
error->one(FLERR, "cannot open {} potential file {}: {}", potential_name, filename,
utils::getsyserror());
}
} catch (FileReaderException &e) {
error->one(FLERR, e.what());
@ -77,30 +70,32 @@ PotentialFileReader::PotentialFileReader(LAMMPS *lmp,
* \param potential_name Name of potential style for error messages
* \param auto_convert Bitmask of supported unit conversions
*/
PotentialFileReader::PotentialFileReader(LAMMPS *lmp,
const std::string &filename,
PotentialFileReader::PotentialFileReader(LAMMPS *lmp, const std::string &filename,
const std::string &potential_name,
const int auto_convert) :
PotentialFileReader(lmp, filename, potential_name, " potential", auto_convert)
PotentialFileReader(lmp, filename, potential_name, " potential", auto_convert)
{
}
/** Closes the file */
PotentialFileReader::~PotentialFileReader() {
PotentialFileReader::~PotentialFileReader()
{
delete reader;
}
/** Set comment (= text after '#') handling preference for the file to be read
*
* \param value Comment text is ignored if true, or not if false */
void PotentialFileReader::ignore_comments(bool value) {
void PotentialFileReader::ignore_comments(bool value)
{
reader->ignore_comments = value;
}
/** Read a line but ignore its content */
void PotentialFileReader::skip_line() {
void PotentialFileReader::skip_line()
{
try {
reader->skip_line();
} catch (FileReaderException &e) {
@ -119,7 +114,8 @@ void PotentialFileReader::skip_line() {
* \param nparams Number of words that must be read. Default: 0
* \return String with the concatenated text */
char *PotentialFileReader::next_line(int nparams) {
char *PotentialFileReader::next_line(int nparams)
{
try {
return reader->next_line(nparams);
} catch (FileReaderException &e) {
@ -137,7 +133,8 @@ char *PotentialFileReader::next_line(int nparams) {
* \param list Pointer to array with suitable storage for *n* doubles
* \param n Number of doubles to be read */
void PotentialFileReader::next_dvector(double * list, int n) {
void PotentialFileReader::next_dvector(double *list, int n)
{
try {
return reader->next_dvector(list, n);
} catch (FileReaderException &e) {
@ -155,7 +152,8 @@ void PotentialFileReader::next_dvector(double * list, int n) {
* \param separators String with list of separators.
* \return ValueTokenizer object for read in text */
ValueTokenizer PotentialFileReader::next_values(int nparams, const std::string &separators) {
ValueTokenizer PotentialFileReader::next_values(int nparams, const std::string &separators)
{
try {
return reader->next_values(nparams, separators);
} catch (FileReaderException &e) {
@ -168,9 +166,10 @@ ValueTokenizer PotentialFileReader::next_values(int nparams, const std::string &
*
* \return Value of first word in line as double */
double PotentialFileReader::next_double() {
double PotentialFileReader::next_double()
{
try {
char * line = reader->next_line(1);
char *line = reader->next_line(1);
return ValueTokenizer(line).next_double();
} catch (FileReaderException &e) {
error->one(FLERR, e.what());
@ -182,9 +181,10 @@ double PotentialFileReader::next_double() {
*
* \return Value of first word in line as int */
int PotentialFileReader::next_int() {
int PotentialFileReader::next_int()
{
try {
char * line = reader->next_line(1);
char *line = reader->next_line(1);
return ValueTokenizer(line).next_int();
} catch (FileReaderException &e) {
error->one(FLERR, e.what());
@ -196,9 +196,10 @@ int PotentialFileReader::next_int() {
*
* \return Value of first word in line as tagint */
tagint PotentialFileReader::next_tagint() {
tagint PotentialFileReader::next_tagint()
{
try {
char * line = reader->next_line(1);
char *line = reader->next_line(1);
return ValueTokenizer(line).next_tagint();
} catch (FileReaderException &e) {
error->one(FLERR, e.what());
@ -210,9 +211,10 @@ tagint PotentialFileReader::next_tagint() {
*
* \return Value of first word in line as bigint */
bigint PotentialFileReader::next_bigint() {
bigint PotentialFileReader::next_bigint()
{
try {
char * line = reader->next_line(1);
char *line = reader->next_line(1);
return ValueTokenizer(line).next_bigint();
} catch (FileReaderException &e) {
error->one(FLERR, e.what());
@ -224,9 +226,10 @@ bigint PotentialFileReader::next_bigint() {
*
* \return First word of read in line */
std::string PotentialFileReader::next_string() {
std::string PotentialFileReader::next_string()
{
try {
char * line = reader->next_line(1);
char *line = reader->next_line(1);
return ValueTokenizer(line).next_string();
} catch (FileReaderException &e) {
error->one(FLERR, e.what());
@ -246,17 +249,17 @@ std::string PotentialFileReader::next_string() {
* \param path Path of the potential file to open
* \return Pointer to TextFileReader object created */
TextFileReader *PotentialFileReader::open_potential(const std::string &path) {
TextFileReader *PotentialFileReader::open_potential(const std::string &path)
{
std::string filepath = utils::get_potential_file_path(path);
if (!filepath.empty()) {
std::string unit_style = lmp->update->unit_style;
std::string date = utils::get_potential_date(filepath, filetype);
std::string units = utils::get_potential_units(filepath, filetype);
std::string date = utils::get_potential_date(filepath, filetype);
std::string units = utils::get_potential_units(filepath, filetype);
if (!date.empty())
utils::logmesg(lmp,"Reading {} file {} with DATE: {}\n",
filetype, filename, date);
utils::logmesg(lmp, "Reading {} file {} with DATE: {}\n", filetype, filename, date);
if (units.empty()) {
unit_convert = utils::NOCONVERT;
@ -266,18 +269,18 @@ TextFileReader *PotentialFileReader::open_potential(const std::string &path) {
} else {
if ((units == "metal") && (unit_style == "real") && (unit_convert & utils::METAL2REAL)) {
unit_convert = utils::METAL2REAL;
} else if ((units == "real") && (unit_style == "metal") && (unit_convert & utils::REAL2METAL)) {
} else if ((units == "real") && (unit_style == "metal") &&
(unit_convert & utils::REAL2METAL)) {
unit_convert = utils::REAL2METAL;
} else {
lmp->error->one(FLERR, "{} file {} requires {} units "
"but {} units are in use", filetype,
filename, units, unit_style);
lmp->error->one(FLERR, "{} file {} requires {} units but {} units are in use", filetype,
filename, units, unit_style);
}
}
}
if (unit_convert != utils::NOCONVERT)
lmp->error->warning(FLERR, "Converting {} in {} units to {} units",
filetype, units, unit_style);
lmp->error->warning(FLERR, "Converting {} in {} units to {} units", filetype, units,
unit_style);
return new TextFileReader(filepath, filetype);
}
return nullptr;