apply code changes suggested by clang-tidy

This commit is contained in:
Axel Kohlmeyer
2022-12-11 18:44:50 -05:00
parent 9beb64236e
commit e0792d3a62
7 changed files with 20 additions and 20 deletions

View File

@ -867,7 +867,7 @@ void FixElectrodeConp::update_charges()
accel_interface->intel_pack_buffers(); accel_interface->intel_pack_buffers();
} }
std::vector<double> FixElectrodeConp::ele_ele_interaction(std::vector<double> q_local) std::vector<double> FixElectrodeConp::ele_ele_interaction(const std::vector<double>& q_local)
{ {
assert(q_local.size() == nlocalele); assert(q_local.size() == nlocalele);
assert(algo == Algo::CG || algo == Algo::MATRIX_CG); assert(algo == Algo::CG || algo == Algo::MATRIX_CG);

View File

@ -75,7 +75,7 @@ class FixElectrodeConp : public Fix {
virtual std::vector<double> constraint_projection(std::vector<double>); virtual std::vector<double> constraint_projection(std::vector<double>);
virtual std::vector<double> constraint_correction(std::vector<double>); virtual std::vector<double> constraint_correction(std::vector<double>);
virtual void compute_macro_matrices(); virtual void compute_macro_matrices();
std::vector<double> ele_ele_interaction(std::vector<double>); std::vector<double> ele_ele_interaction(const std::vector<double>&);
std::vector<double> group_psi; std::vector<double> group_psi;
std::vector<int> group_bits; std::vector<int> group_bits;
std::vector<int> groups; std::vector<int> groups;

View File

@ -37,6 +37,7 @@
#include <cmath> #include <cmath>
#include <random> #include <random>
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -253,7 +254,7 @@ void FitPOD::get_exyz_files(std::vector<std::string>& files, const std::string &
int FitPOD::get_number_atom_exyz(std::vector<int>& num_atom, int& num_atom_sum, std::string file) int FitPOD::get_number_atom_exyz(std::vector<int>& num_atom, int& num_atom_sum, std::string file)
{ {
std::string filename = file; std::string filename = std::move(file);
FILE *fp; FILE *fp;
if (comm->me == 0) { if (comm->me == 0) {
fp = utils::open_potential(filename,lmp,nullptr); fp = utils::open_potential(filename,lmp,nullptr);
@ -325,7 +326,7 @@ void FitPOD::read_exyz_file(double *lattice, double *stress, double *energy, dou
int *atomtype, std::string file, std::vector<std::string> species) int *atomtype, std::string file, std::vector<std::string> species)
{ {
std::string filename = file; std::string filename = std::move(file);
FILE *fp; FILE *fp;
if (comm->me == 0) { if (comm->me == 0) {
fp = utils::open_potential(filename,lmp,nullptr); fp = utils::open_potential(filename,lmp,nullptr);
@ -459,7 +460,7 @@ void FitPOD::read_exyz_file(double *lattice, double *stress, double *energy, dou
} }
} }
void FitPOD::get_data(datastruct &data, std::vector<std::string> species) void FitPOD::get_data(datastruct &data, const std::vector<std::string>& species)
{ {
get_exyz_files(data.data_files, data.data_path, data.file_extension); get_exyz_files(data.data_files, data.data_path, data.file_extension);
data.num_atom_sum = get_number_atoms(data.num_atom, data.num_atom_each_file, data.num_config, data.data_files); data.num_atom_sum = get_number_atoms(data.num_atom, data.num_atom_each_file, data.num_config, data.data_files);
@ -707,7 +708,7 @@ void FitPOD::select_data(datastruct &newdata, const datastruct &data)
"", maxname+90, "data_file", maxname, "", maxname+90); "", maxname+90, "data_file", maxname, "", maxname+90);
for (int i=0; i< (int) newdata.data_files.size(); i++) { for (int i=0; i< (int) newdata.data_files.size(); i++) {
std::string filename = newdata.data_files[i].substr(newdata.data_path.size()+1,newdata.data_files[i].size()); std::string filename = newdata.data_files[i].substr(newdata.data_path.size()+1,newdata.data_files[i].size());
newdata.filenames.push_back(filename.c_str()); newdata.filenames.emplace_back(filename.c_str());
if (comm->me == 0) if (comm->me == 0)
utils::logmesg(lmp, " {:<{}} | {:>8} | {:>8} | {:>8} | {:>8}\n", utils::logmesg(lmp, " {:<{}} | {:>8} | {:>8} | {:>8} | {:>8}\n",
newdata.filenames[i], maxname, newdata.num_config[i], newdata.num_atom_each_file[i], newdata.filenames[i], maxname, newdata.num_config[i], newdata.num_atom_each_file[i],
@ -720,7 +721,7 @@ void FitPOD::select_data(datastruct &newdata, const datastruct &data)
} }
} }
void FitPOD::read_data_files(std::string data_file, std::vector<std::string> species) void FitPOD::read_data_files(const std::string& data_file, const std::vector<std::string>& species)
{ {
datastruct data; datastruct data;

View File

@ -155,12 +155,12 @@ class FitPOD : public Command {
std::vector<int> &num_config, std::vector<std::string> training_files); std::vector<int> &num_config, std::vector<std::string> training_files);
void read_exyz_file(double *lattice, double *stress, double *energy, double *pos, double *forces, void read_exyz_file(double *lattice, double *stress, double *energy, double *pos, double *forces,
int *atomtype, std::string file, std::vector<std::string> species); int *atomtype, std::string file, std::vector<std::string> species);
void get_data(datastruct &data, std::vector<std::string> species); void get_data(datastruct &data, const std::vector<std::string>& species);
std::vector<int> linspace(int start_in, int end_in, int num_in); std::vector<int> linspace(int start_in, int end_in, int num_in);
std::vector<int> shuffle(int start_in, int end_in, int num_in); std::vector<int> shuffle(int start_in, int end_in, int num_in);
std::vector<int> select(int n, double fraction, int randomize); std::vector<int> select(int n, double fraction, int randomize);
void select_data(datastruct &newdata, const datastruct &data); void select_data(datastruct &newdata, const datastruct &data);
void read_data_files(std::string data_file, std::vector<std::string> species); void read_data_files(const std::string& data_file, const std::vector<std::string>& species);
int latticecoords(double *y, int *alist, double *x, double *a1, double *a2, double *a3, int latticecoords(double *y, int *alist, double *x, double *a1, double *a2, double *a3,
double rcut, int *pbc, int nx); double rcut, int *pbc, int nx);
int podneighborlist(int *neighlist, int *numneigh, double *r, double rcutsq, int nx, int N, int podneighborlist(int *neighlist, int *numneigh, double *r, double rcutsq, int nx, int N,

View File

@ -2308,7 +2308,7 @@ double FixBondReact::custom_constraint(const std::string& varstr)
evlstr.push_back(varstr.substr(prev3+1)); evlstr.push_back(varstr.substr(prev3+1));
for (auto & evl : evlstr) evlcat += evl; for (auto & evl : evlstr) evlcat += evl;
return input->variable->compute_equal(evlcat.c_str()); return input->variable->compute_equal(evlcat);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -17,10 +17,10 @@
#include "../version.h" #include "../version.h"
#include <stdint.h> #include <cstdint>
#include <stdio.h> #include <cstdio>
#include <stdlib.h> #include <cstdlib>
#include <string.h> #include <cstring>
#if defined(_WIN32) #if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
@ -183,7 +183,7 @@ double MPI_Wtime()
double time; double time;
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, nullptr);
time = 1.0 * tv.tv_sec + 1.0e-6 * tv.tv_usec; time = 1.0 * tv.tv_sec + 1.0e-6 * tv.tv_usec;
return time; return time;
#endif #endif
@ -223,7 +223,7 @@ static int stubtypesize(MPI_Datatype datatype)
int MPI_Type_size(MPI_Datatype datatype, int *size) int MPI_Type_size(MPI_Datatype datatype, int *size)
{ {
if (size == NULL) return MPI_ERR_ARG; if (size == nullptr) return MPI_ERR_ARG;
*size = stubtypesize(datatype); *size = stubtypesize(datatype);
return 0; return 0;

View File

@ -1185,11 +1185,10 @@ bool Info::has_accelerator_feature(const std::string &package,
} }
if (category == "api") { if (category == "api") {
#if defined(_OPENMP) #if defined(_OPENMP)
if (setting == "openmp") return true; return setting == "openmp";
#else #else
if (setting == "serial") return true; return setting == "serial";
#endif #endif
return false;
} }
} }
#endif #endif