diff --git a/lib/awpmd/ivutils/include/vector_3.h b/lib/awpmd/ivutils/include/vector_3.h index 5711d3bf35..6beef2bcd6 100644 --- a/lib/awpmd/ivutils/include/vector_3.h +++ b/lib/awpmd/ivutils/include/vector_3.h @@ -487,7 +487,7 @@ vec_type dist_av(Vector_3 *va1,Vector_3 *va2,int n); /*e optionally gives the indexes for maximal and minimal difference va2 can be nullptr, then the norm of va1 is used */ -vec_type diff_av(Vector_3 *va1,Vector_3 *va2,int n, int *minind=0, int *maxind=0); +vec_type diff_av(Vector_3 *va1,Vector_3 *va2,int n, int *minind=nullptr, int *maxind=nullptr); //e finds suitable perpendicular to a vector Vector_3 FindPerp(const Vector_3 &vAB); @@ -507,7 +507,7 @@ Vector_3 GetIScopei(const Vector_3 *varr,int *indarr,int n,Vector_3* box_min,Vec // neue Funktionen //e clears vector array with optional integer index -void clear_vecarri(int n,Vector_3 *vec, int *ind=0); +void clear_vecarri(int n,Vector_3 *vec, int *ind=nullptr); //e reflects the vector ini+dir*t+0.5*force*t^2 to be inside a box limited by 0 and box sizes //e changes dir according to the final state diff --git a/lib/poems/SystemProcessor.h b/lib/poems/SystemProcessor.h index f009794f66..faa8c01d62 100644 --- a/lib/poems/SystemProcessor.h +++ b/lib/poems/SystemProcessor.h @@ -49,9 +49,9 @@ private: POEMSChain * AddNewChain(POEMSNode * currentNode); bool setLinkVisited(POEMSNode * firstNode, POEMSNode * secondNode); public: - SystemProcessor(void); + SystemProcessor(); - ~SystemProcessor(void) { + ~SystemProcessor() { headsOfSystems.DeleteValues(); for(int i = 0; i < ringsInSystem.GetNumElements(); i++) { @@ -66,7 +66,7 @@ public: int getNumberOfHeadChains(); }; -SystemProcessor::SystemProcessor(void){ +SystemProcessor::SystemProcessor(){ // register callback for deleting auxiliary data from tree nodes. nodes.SetDeleteAuxData(&POEMSNodeDelete_cb); } @@ -271,14 +271,14 @@ bool SystemProcessor::setLinkVisited(POEMSNode * firstNode, POEMSNode * secondNo return true; //return true to indicate that this is the first time the link has been visited } -List * SystemProcessor::getSystemData(void) //Gets the list of POEMSChains that comprise the system. Might eventually only +List * SystemProcessor::getSystemData() //Gets the list of POEMSChains that comprise the system. Might eventually only //return chains linked to the reference plane, but currently returns every chain //in the system. { return &headsOfSystems; } -int SystemProcessor::getNumberOfHeadChains(void) //This function isnt implemented yet, and might be taken out entirely; this was a holdover +int SystemProcessor::getNumberOfHeadChains() //This function isnt implemented yet, and might be taken out entirely; this was a holdover //from when I intended to return an array of chain pointers, rather than a list of chains //It will probably be deleted once I finish figuring out exactly what needs to be returned { diff --git a/lib/poems/body.cpp b/lib/poems/body.cpp index 1fc31243c8..510154ac75 100644 --- a/lib/poems/body.cpp +++ b/lib/poems/body.cpp @@ -132,6 +132,6 @@ Body* NewBody(int type){ case PARTICLE : // A Particle return new Particle; default : // error - return 0; + return nullptr; } } diff --git a/lib/poems/colmatmap.cpp b/lib/poems/colmatmap.cpp index 69ec4ec1b0..e075f1d297 100644 --- a/lib/poems/colmatmap.cpp +++ b/lib/poems/colmatmap.cpp @@ -24,7 +24,7 @@ using namespace std; ColMatMap::ColMatMap(){ numrows = 0; - elements = 0; + elements = nullptr; } ColMatMap::~ColMatMap(){ @@ -33,7 +33,7 @@ ColMatMap::~ColMatMap(){ ColMatMap::ColMatMap(const ColMatMap& A){ // copy constructor numrows = 0; - elements = 0; + elements = nullptr; Dim(A.numrows); for(int i=0;iDim(m,n); } diff --git a/lib/poems/matrixfun.cpp b/lib/poems/matrixfun.cpp index 9c20d7cac9..b57710aa7a 100644 --- a/lib/poems/matrixfun.cpp +++ b/lib/poems/matrixfun.cpp @@ -36,7 +36,7 @@ VirtualMatrix* NewMatrix(int type){ case MAT4X4 : return new Mat4x4; case VECT3 : return new Vect3; case VECT4 : return new Vect4; - default : return 0; // error! + default : return nullptr; // error! } } diff --git a/lib/poems/onbody.cpp b/lib/poems/onbody.cpp index a9f260a329..84dd0b9ea3 100644 --- a/lib/poems/onbody.cpp +++ b/lib/poems/onbody.cpp @@ -30,9 +30,9 @@ using namespace std; OnBody::OnBody(){ - system_body = 0; - system_joint = 0; - parent = 0; + system_body = nullptr; + system_joint = nullptr; + parent = nullptr; // these terms have zeros which are NEVER overwritten sI.Zeros(); diff --git a/lib/poems/onsolver.cpp b/lib/poems/onsolver.cpp index 8149ad694b..24758a7aa8 100644 --- a/lib/poems/onsolver.cpp +++ b/lib/poems/onsolver.cpp @@ -28,8 +28,8 @@ using namespace std; OnSolver::OnSolver(){ numbodies = 0; - bodyarray = 0; - q=0;u=0; qdot=0; udot=0; qdotdot=0; + bodyarray = nullptr; + q=nullptr;u=nullptr; qdot=nullptr; udot=nullptr; qdotdot=nullptr; type = ONSOLVER; } diff --git a/lib/poems/poemslist.h b/lib/poems/poemslist.h index 39a3af2b51..a56c953349 100644 --- a/lib/poems/poemslist.h +++ b/lib/poems/poemslist.h @@ -65,7 +65,7 @@ template ListElement::ListElement(){ } template ListElement::ListElement(T* v){ - next = prev = 0; + next = prev = nullptr; value = v; } @@ -77,7 +77,7 @@ template ListElement::~ListElement(){ // template List::List(){ - head = tail = 0; + head = tail = nullptr; numelements = 0; } @@ -181,7 +181,7 @@ template S** List::CreateArray(){ S** array = new S* [numelements]; ListElement* ele = head; - for(int i=0;ele != 0;i++){ + for(int i=0;ele != nullptr;i++){ array[i] = ele->value; ele = ele->next; } diff --git a/lib/poems/poemsobject.cpp b/lib/poems/poemsobject.cpp index 5f221f1242..0732179415 100644 --- a/lib/poems/poemsobject.cpp +++ b/lib/poems/poemsobject.cpp @@ -20,7 +20,7 @@ #include POEMSObject::POEMSObject(){ - name = 0; + name = nullptr; ChangeName((const char*)"unnamed"); ID = -1; } diff --git a/lib/poems/poemstree.h b/lib/poems/poemstree.h index cb9499cfd4..6ff7c5ccde 100644 --- a/lib/poems/poemstree.h +++ b/lib/poems/poemstree.h @@ -64,8 +64,8 @@ protected: public: // constructor, destructor - Tree(void); - ~Tree(void) + Tree(); + ~Tree() { ClearTree(root); }; @@ -85,19 +85,19 @@ public: void Insert(const int& item, const int& data, void * AuxData = nullptr); void Delete(const int& item); void AVLInsert(TreeNode* &tree, TreeNode* newNode, int &reviseBalanceFactor); - void ClearList(void); + void ClearList(); // tree specific methods void Update(const int& item); - TreeNode *GetRoot(void) const; + TreeNode *GetRoot() const; }; // constructor -Tree::Tree(void) +Tree::Tree() { - root = 0; - current = 0; + root = nullptr; + current = nullptr; size = 0; DeleteAuxData = nullptr; } @@ -105,7 +105,7 @@ Tree::Tree(void) // return root pointer -TreeNode *Tree::GetRoot(void) const +TreeNode *Tree::GetRoot() const { return root; } @@ -603,7 +603,7 @@ void Tree::ClearTree(TreeNode * &t) } // delete all nodes in list -void Tree::ClearList(void) +void Tree::ClearList() { delete root; delete current; diff --git a/lib/poems/poemstreenode.cpp b/lib/poems/poemstreenode.cpp index d1fd965752..48bd80f283 100644 --- a/lib/poems/poemstreenode.cpp +++ b/lib/poems/poemstreenode.cpp @@ -27,23 +27,23 @@ TreeNode::TreeNode (const int & item, TreeNode *lptr,TreeNode *rptr, // return left -TreeNode* TreeNode::Left(void) +TreeNode* TreeNode::Left() { return left; } // return right -TreeNode* TreeNode::Right(void) +TreeNode* TreeNode::Right() { return right; } -int TreeNode::GetBalanceFactor(void) +int TreeNode::GetBalanceFactor() { return balanceFactor; } -int TreeNode::GetData(void) +int TreeNode::GetData() { return data; } diff --git a/lib/poems/point.cpp b/lib/poems/point.cpp index 66bf8d0373..680c30598e 100644 --- a/lib/poems/point.cpp +++ b/lib/poems/point.cpp @@ -39,6 +39,6 @@ Point* NewPoint(int type){ case FIXEDPOINT : // A Fixed Point return new FixedPoint(); default : // error - return 0; + return nullptr; } } diff --git a/lib/poems/rowmatrix.cpp b/lib/poems/rowmatrix.cpp index 41e24911aa..dcd00ce7cb 100644 --- a/lib/poems/rowmatrix.cpp +++ b/lib/poems/rowmatrix.cpp @@ -24,7 +24,7 @@ using namespace std; RowMatrix::RowMatrix(){ numcols = 0; - elements = 0; + elements = nullptr; } RowMatrix::~RowMatrix(){ @@ -33,7 +33,7 @@ RowMatrix::~RowMatrix(){ RowMatrix::RowMatrix(const RowMatrix& A){ // copy constructor numcols = 0; - elements = 0; + elements = nullptr; Dim(A.numcols); for(int i=0;i* b_ele = bodies.GetHeadElement(); - while(b_ele !=0){ + while(b_ele !=nullptr){ out << i << ' '; body = b_ele->value; @@ -200,7 +200,7 @@ void System::WriteOut(ostream& out){ i = 0; Joint* joint; ListElement* j_ele = joints.GetHeadElement(); - while(j_ele !=0){ + while(j_ele !=nullptr){ out << i << ' '; joint = j_ele->value; diff --git a/src/DPD-REACT/fix_rx.h b/src/DPD-REACT/fix_rx.h index 1d65c4c09e..bd3122e81d 100644 --- a/src/DPD-REACT/fix_rx.h +++ b/src/DPD-REACT/fix_rx.h @@ -97,7 +97,7 @@ class FixRX : public Fix { // Sparse stoichiometric matrix storage format and methods. bool useSparseKinetics; //SparseKinetics sparseKinetics; - void initSparse(void); + void initSparse(); int rhs_sparse(double, const double *, double *, void *) const; int sparseKinetics_maxReactants; //x_ops = (struct xdr_ops *) &xdrstdio_ops; xdrs->x_private = (char *) file; xdrs->x_handy = 0; - xdrs->x_base = 0; + xdrs->x_base = nullptr; } /* diff --git a/src/EXTRA-FIX/fix_ttm.cpp b/src/EXTRA-FIX/fix_ttm.cpp index abcbd2ba1e..13fbd4aff4 100644 --- a/src/EXTRA-FIX/fix_ttm.cpp +++ b/src/EXTRA-FIX/fix_ttm.cpp @@ -77,7 +77,7 @@ FixTTM::FixTTM(LAMMPS *lmp, int narg, char **arg) : nzgrid = utils::inumeric(FLERR,arg[12],false,lmp); tinit = 0.0; - infile = outfile = NULL; + infile = outfile = nullptr; int iarg = 13; while (iarg < narg) { diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index be52d98183..49aea4eeb6 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -148,7 +148,7 @@ PairKIM::PairKIM(LAMMPS *lmp) : PairKIM::~PairKIM() { // clean up kim_modelname - if (kim_modelname != 0) delete [] kim_modelname; + if (kim_modelname != nullptr) delete [] kim_modelname; // clean up lammps atom species number to unique particle names mapping if (lmps_unique_elements) @@ -169,7 +169,7 @@ PairKIM::~PairKIM() // clean up lmps_stripped_neigh_ptr if (lmps_stripped_neigh_ptr) { delete [] lmps_stripped_neigh_ptr; - lmps_stripped_neigh_ptr = 0; + lmps_stripped_neigh_ptr = nullptr; } // clean up allocated memory for standard Pair class usage @@ -184,7 +184,7 @@ PairKIM::~PairKIM() // clean up neighborlist pointers if (neighborLists) { delete [] neighborLists; - neighborLists = 0; + neighborLists = nullptr; } // clean up KIM interface (if necessary) @@ -330,9 +330,9 @@ void PairKIM::settings(int narg, char **arg) set_lmps_flags(); // set KIM Model name - if (kim_modelname != 0) { + if (kim_modelname != nullptr) { delete [] kim_modelname; - kim_modelname = 0; + kim_modelname = nullptr; } kim_modelname = utils::strdup(arg[0]); @@ -385,7 +385,7 @@ void PairKIM::coeff(int narg, char **arg) delete [] lmps_unique_elements; } lmps_unique_elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) lmps_unique_elements[i] = 0; + for (i = 0; i < atom->ntypes; i++) lmps_unique_elements[i] = nullptr; // Assume all species arguments are valid // errors will be detected by below diff --git a/src/LATBOLTZ/fix_lb_fluid.cpp b/src/LATBOLTZ/fix_lb_fluid.cpp index 0295c04f47..2dfe603ca1 100644 --- a/src/LATBOLTZ/fix_lb_fluid.cpp +++ b/src/LATBOLTZ/fix_lb_fluid.cpp @@ -570,7 +570,7 @@ int FixLbFluid::setmask() return mask; } -void FixLbFluid::init(void) +void FixLbFluid::init() { int i,j; @@ -787,7 +787,7 @@ int FixLbFluid::unpack_exchange(int nlocal, double *buf) //========================================================================== // calculate the force from the local atoms acting on the fluid. //========================================================================== -void FixLbFluid::calc_fluidforce(void) +void FixLbFluid::calc_fluidforce() { int *mask = atom->mask; int nlocal = atom->nlocal; @@ -1255,7 +1255,7 @@ require more frequent neighborlist rebuilds"); // read in a fluid restart file. This is only used to restart the // fluid portion of a LAMMPS simulation. //========================================================================== -void FixLbFluid::read_restartfile(void) +void FixLbFluid::read_restartfile() { MPI_Status status; MPI_Datatype realtype; @@ -1295,7 +1295,7 @@ void FixLbFluid::read_restartfile(void) //========================================================================== // write a fluid restart file. //========================================================================== -void FixLbFluid::write_restartfile(void) +void FixLbFluid::write_restartfile() { MPI_File fh; @@ -1343,7 +1343,7 @@ void FixLbFluid::write_restartfile(void) // This assumes that all the simulation parameters have been given in // terms of distance, time and mass units. //========================================================================== -void FixLbFluid::rescale(void) +void FixLbFluid::rescale() { vwtp = vwtp*dt_lb/dx_lb; vwbt = vwbt*dt_lb/dx_lb; @@ -1419,7 +1419,7 @@ satisfy the Courant condition.\n"); // Set the lattice-Boltzmann velocity vectors and weights for the D3Q15 // model. Initialize the fluid velocity and density. //========================================================================== -void FixLbFluid::initializeLB15(void) +void FixLbFluid::initializeLB15() { int i,j,k,m; @@ -1586,7 +1586,7 @@ void FixLbFluid::initializeLB15(void) // Set the lattice-Boltzmann velocity vectors and weights for the D3Q19 // model. Initialize the fluid velocity and density. //========================================================================== -void FixLbFluid::initializeLB19(void) +void FixLbFluid::initializeLB19() { int i,j,k,m; @@ -1823,7 +1823,7 @@ void FixLbFluid::initializeLB19(void) // Initialize the equilibrium distribution functions // (this just uses the initial fluid parameters, and assumes no forces). //========================================================================== -void FixLbFluid::initialize_feq(void) +void FixLbFluid::initialize_feq() { int i,j,k,p; MPI_Request requests[8]; @@ -2311,7 +2311,7 @@ void FixLbFluid::equilibriumdist19(int xstart, int xend, int ystart, int yend, i // Calculate the fluid density and velocity over the entire simulation // domain. //========================================================================== -void FixLbFluid::parametercalc_full(void) +void FixLbFluid::parametercalc_full() { MPI_Request requests[4]; MPI_Request requests2[12]; @@ -2529,7 +2529,7 @@ void FixLbFluid::update_periodic(int xstart, int xend, int ystart, int yend, int //========================================================================== // Print the fluid properties to the screen. //========================================================================== -void FixLbFluid::streamout(void) +void FixLbFluid::streamout() { int i,j,k; int istart,jstart,kstart; @@ -2651,7 +2651,7 @@ void FixLbFluid::streamout(void) // Update the distribution functions over the entire simulation domain for // the D3Q15 model. //========================================================================== -void FixLbFluid::update_full15(void) +void FixLbFluid::update_full15() { MPI_Request req_send15,req_recv15; @@ -3008,7 +3008,7 @@ void FixLbFluid::update_full15(void) // Update the distribution functions over the entire simulation domain for // the D3Q19 model. //========================================================================== -void FixLbFluid::update_full19(void) +void FixLbFluid::update_full19() { MPI_Request req_send15,req_recv15; diff --git a/src/LATBOLTZ/fix_lb_fluid.h b/src/LATBOLTZ/fix_lb_fluid.h index 0842acbe64..98d3e2c792 100644 --- a/src/LATBOLTZ/fix_lb_fluid.h +++ b/src/LATBOLTZ/fix_lb_fluid.h @@ -139,26 +139,26 @@ class FixLbFluid : public Fix { int printfluid; int fixviscouslb; - void rescale(void); - void (FixLbFluid::*initializeLB)(void); - void initializeLB15(void); - void initializeLB19(void); - void initialize_feq(void); + void rescale(); + void (FixLbFluid::*initializeLB)(); + void initializeLB15(); + void initializeLB19(); + void initialize_feq(); void (FixLbFluid::*equilibriumdist)(int, int, int, int, int, int); void equilibriumdist15(int, int, int, int, int, int); void equilibriumdist19(int, int, int, int, int, int); void parametercalc_part(int, int, int, int, int, int); - void parametercalc_full(void); + void parametercalc_full(); void update_periodic(int, int, int, int, int, int); - void (FixLbFluid::*update_full)(void); - void update_full15(void); - void update_full19(void); - void streamout(void); - void read_restartfile(void); - void write_restartfile(void); + void (FixLbFluid::*update_full)(); + void update_full15(); + void update_full19(); + void streamout(); + void read_restartfile(); + void write_restartfile(); void peskin_interpolation(int); void trilinear_interpolation(int); - void calc_fluidforce(void); + void calc_fluidforce(); }; } // namespace LAMMPS_NS #endif diff --git a/src/LATBOLTZ/fix_lb_pc.cpp b/src/LATBOLTZ/fix_lb_pc.cpp index bae0987b21..352803b670 100644 --- a/src/LATBOLTZ/fix_lb_pc.cpp +++ b/src/LATBOLTZ/fix_lb_pc.cpp @@ -338,7 +338,7 @@ int FixLbPC::unpack_exchange(int nlocal, double *buf) } /* ---------------------------------------------------------------------- */ - void FixLbPC::compute_up(void) + void FixLbPC::compute_up() { int *mask = atom->mask; int nlocal = atom->nlocal; diff --git a/src/LATBOLTZ/fix_lb_pc.h b/src/LATBOLTZ/fix_lb_pc.h index e2e47d915f..d218f22ebd 100644 --- a/src/LATBOLTZ/fix_lb_pc.h +++ b/src/LATBOLTZ/fix_lb_pc.h @@ -50,7 +50,7 @@ class FixLbPC : public Fix { double **up; double **up_old; - void compute_up(void); + void compute_up(); class FixLbFluid *fix_lb_fluid; }; diff --git a/src/LATBOLTZ/fix_lb_rigid_pc_sphere.cpp b/src/LATBOLTZ/fix_lb_rigid_pc_sphere.cpp index 304d5bbf0f..d9dfc7b264 100644 --- a/src/LATBOLTZ/fix_lb_rigid_pc_sphere.cpp +++ b/src/LATBOLTZ/fix_lb_rigid_pc_sphere.cpp @@ -1536,7 +1536,7 @@ double FixLbRigidPCSphere::compute_array(int i, int j) } /* ---------------------------------------------------------------------- */ - void FixLbRigidPCSphere::compute_up(void) + void FixLbRigidPCSphere::compute_up() { int *mask = atom->mask; int nlocal = atom->nlocal; diff --git a/src/MACHDYN/pair_smd_tlsph.h b/src/MACHDYN/pair_smd_tlsph.h index 86e2bbe52b..0950430ca0 100644 --- a/src/MACHDYN/pair_smd_tlsph.h +++ b/src/MACHDYN/pair_smd_tlsph.h @@ -49,8 +49,8 @@ class PairTlsph : public Pair { void write_restart_settings(FILE *) {} void read_restart_settings(FILE *) {} virtual double memory_usage(); - void compute_shape_matrix(void); - void material_model(void); + void compute_shape_matrix(); + void material_model(); void *extract(const char *, int &); int pack_forward_comm(int, int *, double *, int, int *); void unpack_forward_comm(int, int, double *); diff --git a/src/MANYBODY/pair_edip.cpp b/src/MANYBODY/pair_edip.cpp index 0efa509cb3..51b38037ab 100644 --- a/src/MANYBODY/pair_edip.cpp +++ b/src/MANYBODY/pair_edip.cpp @@ -463,7 +463,7 @@ void PairEDIP::compute(int eflag, int vflag) /* ---------------------------------------------------------------------- */ -void PairEDIP::allocateGrids(void) +void PairEDIP::allocateGrids() { int numGridPointsOneCutoffFunction; int numGridPointsNotOneCutoffFunction; diff --git a/src/MANYBODY/pair_edip.h b/src/MANYBODY/pair_edip.h index 8ee3a74dd8..5812768d55 100644 --- a/src/MANYBODY/pair_edip.h +++ b/src/MANYBODY/pair_edip.h @@ -90,11 +90,11 @@ class PairEDIP : public Pair { Param *params; // parameter set for an I-J-K interaction void allocate(); - void allocatePreLoops(void); - void deallocatePreLoops(void); - void allocateGrids(void); - void deallocateGrids(void); - void initGrids(void); + void allocatePreLoops(); + void deallocatePreLoops(); + void allocateGrids(); + void deallocateGrids(); + void initGrids(); void read_file(char *); void setup_params(); diff --git a/src/MANYBODY/pair_edip_multi.cpp b/src/MANYBODY/pair_edip_multi.cpp index 47cc5a90fa..3cabec4505 100644 --- a/src/MANYBODY/pair_edip_multi.cpp +++ b/src/MANYBODY/pair_edip_multi.cpp @@ -486,7 +486,7 @@ void PairEDIPMulti::edip_fcut3(double r, Param *param, double &f, double &fdr) pre-calculated structures ------------------------------------------------------------------------- */ -void PairEDIPMulti::allocatePreLoops(void) +void PairEDIPMulti::allocatePreLoops() { int nthreads = comm->nthreads; @@ -497,7 +497,7 @@ void PairEDIPMulti::allocatePreLoops(void) deallocate preLoops ------------------------------------------------------------------------- */ -void PairEDIPMulti::deallocatePreLoops(void) +void PairEDIPMulti::deallocatePreLoops() { memory->destroy(preForceCoord); } diff --git a/src/MANYBODY/pair_edip_multi.h b/src/MANYBODY/pair_edip_multi.h index 44921ebdba..3ee7347a56 100644 --- a/src/MANYBODY/pair_edip_multi.h +++ b/src/MANYBODY/pair_edip_multi.h @@ -57,8 +57,8 @@ class PairEDIPMulti : public Pair { Param *params; // parameter set for an I-J-K interaction void allocate(); - void allocatePreLoops(void); - void deallocatePreLoops(void); + void allocatePreLoops(); + void deallocatePreLoops(); void read_file(char *); void setup(); diff --git a/src/MANYBODY/pair_tersoff_table.h b/src/MANYBODY/pair_tersoff_table.h index 662fd532b7..ab345d8af2 100644 --- a/src/MANYBODY/pair_tersoff_table.h +++ b/src/MANYBODY/pair_tersoff_table.h @@ -69,8 +69,8 @@ class PairTersoffTable : public Pair { double **preGtetaFunction, **preGtetaFunctionDerived; double *preCutoffFunction, *preCutoffFunctionDerived; - virtual void allocatePreLoops(void); - virtual void deallocatePreLoops(void); + virtual void allocatePreLoops(); + virtual void deallocatePreLoops(); // grids @@ -79,8 +79,8 @@ class PairTersoffTable : public Pair { double **gtetaFunction, **gtetaFunctionDerived; double **betaZetaPower, **betaZetaPowerDerived; - void allocateGrids(void); - void deallocateGrids(void); + void allocateGrids(); + void deallocateGrids(); }; } // namespace LAMMPS_NS diff --git a/src/MGPT/mgpt_readpot.cpp b/src/MGPT/mgpt_readpot.cpp index 75ea1202aa..df62bf735d 100644 --- a/src/MGPT/mgpt_readpot.cpp +++ b/src/MGPT/mgpt_readpot.cpp @@ -166,7 +166,7 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl int ipotx,modex; double pnx; double vol0; - double *vatab,*vbtab,*vctab,*vdtab,*vetab,*p1tab,*altab,*vpairtab = 0; + double *vatab,*vbtab,*vctab,*vdtab,*vetab,*p1tab,*altab,*vpairtab = nullptr; double *r0rwstab,*evol0tab; double (*C)[4]; double *y,*dy; diff --git a/src/MGPT/mgpt_readpot.h b/src/MGPT/mgpt_readpot.h index d860146959..89b59aa243 100644 --- a/src/MGPT/mgpt_readpot.h +++ b/src/MGPT/mgpt_readpot.h @@ -320,7 +320,7 @@ struct potdata2 { tdeppot.devol0 = maketempspline(ntemp,potlist,&(potlist[0].devol0)); - tdeppot.ddl[0] = 0; + tdeppot.ddl[0] = nullptr; for(int k = 1; k<=4; k++) tdeppot.ddl[k] = maketempspline(ntemp,potlist,&(potlist[0].ddl[k])); diff --git a/src/MGPT/pair_mgpt.cpp b/src/MGPT/pair_mgpt.cpp index fb956cabaf..2bea1273c6 100644 --- a/src/MGPT/pair_mgpt.cpp +++ b/src/MGPT/pair_mgpt.cpp @@ -222,8 +222,8 @@ PairMGPT::triplet_data *PairMGPT::get_triplet(const double xx[][3],int i,int j,i double t0,t1; - bond_data *bij = 0,*bik = 0; - triplet_data *tptr = 0; + bond_data *bij = nullptr,*bik = nullptr; + triplet_data *tptr = nullptr; t0 = gettime(); if (recompute == 0) { @@ -231,7 +231,7 @@ PairMGPT::triplet_data *PairMGPT::get_triplet(const double xx[][3],int i,int j,i bik = bhash->Lookup(Doublet(i,k)); } - if (bij == 0) { + if (bij == nullptr) { if (recompute == 0) bij = bhash->Insert(Doublet(i,j)); else @@ -242,7 +242,7 @@ PairMGPT::triplet_data *PairMGPT::get_triplet(const double xx[][3],int i,int j,i make_bond(xx,j,i,bij); } - if (bik == 0) { + if (bik == nullptr) { if (recompute == 0) bik = bhash->Insert(Doublet(i,k)); else @@ -256,7 +256,7 @@ PairMGPT::triplet_data *PairMGPT::get_triplet(const double xx[][3],int i,int j,i t_make_b += t1-t0; t0 = gettime(); - if (bij != 0 && bij != 0) { + if (bij != nullptr && bij != nullptr) { tptr = twork; make_triplet(bij,bik,tptr); *dvir_ij_p = bij->fl_deriv_sum; @@ -933,7 +933,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, const int ski = (k < i) ? 1 : -1; - T12 = T23 = T31 = 0; + T12 = T23 = T31 = nullptr; mj = first[j]; /* @@ -1042,7 +1042,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, accumulate_forces_3(w3); } - if (T12 != 0) { + if (T12 != nullptr) { //printf("T12 i,j,k = %d,%d,%d\n",i,j,k); mcount++; if (three_body_energies && evflag) { @@ -1098,7 +1098,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, accumulate_forces_3(w3); } - if (T23 != 0) { + if (T23 != nullptr) { //printf("T23 i,j,k = %d,%d,%d\n",i,j,k); mcount++; if (three_body_energies && evflag) { @@ -1154,7 +1154,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } - if (T31 != 0) { + if (T31 != nullptr) { //printf("T31 i,j,k = %d,%d,%d\n",i,j,k); mcount++; if (three_body_energies && evflag) { @@ -1327,15 +1327,15 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, tr1 = tr2 = tr3 = 0.0; dvir_im = dvir_jm = dvir_km = 0.0; - T45 = T56 = T64 = 0; - if (T12 != 0 && c_km && c_im) + T45 = T56 = T64 = nullptr; + if (T12 != nullptr && c_km && c_im) T45 = get_triplet(xx,m,i,k,&bond_hash,&T45work,&dvir_im,&dvir_km); - if (T23 != 0 && c_im && c_jm) + if (T23 != nullptr && c_im && c_jm) T56 = get_triplet(xx,m,i,j,&bond_hash,&T56work,&dvir_im,&dvir_jm); - if (T31 != 0 && c_jm && c_km) + if (T31 != nullptr && c_jm && c_km) T64 = get_triplet(xx,m,j,k,&bond_hash,&T64work,&dvir_jm,&dvir_km); - if (T12 != 0 && T45 != 0) { + if (T12 != nullptr && T45 != nullptr) { if (four_body_energies && evflag) { tr1 = transtrace(T12->H1H2,T45->H1H2); double dvir = ( (dvir_ij + dvir_jk + dvir_im + dvir_km)*splinepot.ve + @@ -1364,7 +1364,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, accumulate_forces_4(w4); } - if (T23 != 0 && T56 != 0) { + if (T23 != nullptr && T56 != nullptr) { if (four_body_energies && evflag) { tr2 = transtrace(T23->H1H2,T56->H1H2); double dvir = ( (dvir_ki + dvir_jk + dvir_im + dvir_jm)*splinepot.ve + @@ -1394,7 +1394,7 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } - if (T31 != 0 && T64 != 0) { + if (T31 != nullptr && T64 != nullptr) { if (four_body_energies && evflag) { tr3 = transtrace(T31->H1H2,T64->H1H2); double dvir = ( (dvir_ki + dvir_ij + dvir_jm + dvir_km)*splinepot.ve + diff --git a/src/MGPT/pair_mgpt.h b/src/MGPT/pair_mgpt.h index 106c2cc8f0..ed73ed1f35 100644 --- a/src/MGPT/pair_mgpt.h +++ b/src/MGPT/pair_mgpt.h @@ -146,7 +146,7 @@ public: table = new Link *[size]; for(int i = 0; inext; delete p; p = q; @@ -188,9 +188,9 @@ public: return &table[idx]->data; } else { /* This is for threading... and incomplete */ typedef Link *LinkPtr; - LinkPtr ptr = table[idx],last = 0,dataptr = new Link(key,0); + LinkPtr ptr = table[idx],last = nullptr,dataptr = new Link(key,nullptr); - while(ptr != 0) { + while(ptr != nullptr) { last = ptr; ptr = ptr->next; } @@ -241,7 +241,7 @@ public: p = table[idx]; - while(p != 0 && !(p->key == key)) { + while(p != nullptr && !(p->key == key)) { p = p->next; count = count + 1; } @@ -251,9 +251,9 @@ public: nsearch = nsearch + 1; nstep = nstep + count; - if(p != 0) p->hits++; + if(p != nullptr) p->hits++; - return (p == 0) ? 0 : &p->data; + return (p == nullptr) ? nullptr : &p->data; } }; @@ -469,8 +469,8 @@ public: return 0; } double get_weight(const int triclinic, - const double a[3] = 0,const double b[3] = 0, - const double c[3] = 0,const double d[3] = 0) { + const double a[3] = nullptr,const double b[3] = nullptr, + const double c[3] = nullptr,const double d[3] = nullptr) { const double *s0 = triclinic ? domain->sublo_lamda : domain->sublo, *s1 = triclinic ? domain->subhi_lamda : domain->subhi; @@ -479,10 +479,10 @@ public: for(int p = 0; p<3; p++) { double cog = 0.0,q,w,n = 0.0; - if(a != 0) { cog = cog + a[p]; n = n + 1; } - if(b != 0) { cog = cog + b[p]; n = n + 1; } - if(c != 0) { cog = cog + c[p]; n = n + 1; } - if(d != 0) { cog = cog + d[p]; n = n + 1; } + if(a != nullptr) { cog = cog + a[p]; n = n + 1; } + if(b != nullptr) { cog = cog + b[p]; n = n + 1; } + if(c != nullptr) { cog = cog + c[p]; n = n + 1; } + if(d != nullptr) { cog = cog + d[p]; n = n + 1; } cog = cog * (1.0/n); if(cog < 0.5*(s0[p]+s1[p])) q = cog - s0[p]; diff --git a/src/ML-IAP/mliap_model_python.cpp b/src/ML-IAP/mliap_model_python.cpp index b89d17f289..878d234c69 100644 --- a/src/ML-IAP/mliap_model_python.cpp +++ b/src/ML-IAP/mliap_model_python.cpp @@ -62,7 +62,7 @@ MLIAPModelPython::MLIAPModelPython(LAMMPS *lmp, char *coefffilename) : // if LAMMPS_POTENTIALS environment variable is set, add it to PYTHONPATH as well const char *potentials_path = getenv("LAMMPS_POTENTIALS"); - if (potentials_path != NULL) { PyList_Append(py_path, PY_STRING_FROM_STRING(potentials_path)); } + if (potentials_path != nullptr) { PyList_Append(py_path, PY_STRING_FROM_STRING(potentials_path)); } PyGILState_Release(gstate); if (coefffilename) read_coeffs(coefffilename); diff --git a/src/ML-IAP/mliap_model_python.h b/src/ML-IAP/mliap_model_python.h index 8410b4dc4a..4243c67332 100644 --- a/src/ML-IAP/mliap_model_python.h +++ b/src/ML-IAP/mliap_model_python.h @@ -20,7 +20,7 @@ namespace LAMMPS_NS { class MLIAPModelPython : public MLIAPModel { public: - MLIAPModelPython(LAMMPS *, char * = NULL); + MLIAPModelPython(LAMMPS *, char * = nullptr); ~MLIAPModelPython(); virtual int get_nparams(); virtual int get_gamma_nnz(class MLIAPData *); diff --git a/src/ML-RANN/rann_fingerprint_bond.cpp b/src/ML-RANN/rann_fingerprint_bond.cpp index dd2a309415..48c73757e7 100644 --- a/src/ML-RANN/rann_fingerprint_bond.cpp +++ b/src/ML-RANN/rann_fingerprint_bond.cpp @@ -77,26 +77,26 @@ bool Fingerprint_bond::parse_values(std::string constant,std::vectorerrorf(FLERR,"Undefined value for bond power"); if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && mlength!=0 && kmax!=0)return true; diff --git a/src/ML-RANN/rann_fingerprint_bondscreened.cpp b/src/ML-RANN/rann_fingerprint_bondscreened.cpp index 0e9d562f6e..6f65ca6454 100644 --- a/src/ML-RANN/rann_fingerprint_bondscreened.cpp +++ b/src/ML-RANN/rann_fingerprint_bondscreened.cpp @@ -78,26 +78,26 @@ bool Fingerprint_bondscreened::parse_values(std::string constant,std::vectorerrorf(FLERR,"Undefined value for bond power"); if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && mlength!=0 && kmax!=0)return true; diff --git a/src/ML-RANN/rann_fingerprint_bondscreenedspin.cpp b/src/ML-RANN/rann_fingerprint_bondscreenedspin.cpp index 5fb81dc5b1..1dcf8872d2 100644 --- a/src/ML-RANN/rann_fingerprint_bondscreenedspin.cpp +++ b/src/ML-RANN/rann_fingerprint_bondscreenedspin.cpp @@ -79,26 +79,26 @@ bool Fingerprint_bondscreenedspin::parse_values(std::string constant,std::vector int nwords,l; nwords=line1.size(); if (constant.compare("re")==0) { - re = strtod(line1[0].c_str(),NULL); + re = strtod(line1[0].c_str(),nullptr); } else if (constant.compare("rc")==0) { - rc = strtod(line1[0].c_str(),NULL); + rc = strtod(line1[0].c_str(),nullptr); } else if (constant.compare("alphak")==0) { delete[] alpha_k; alpha_k = new double[nwords]; for (l=0;lerrorf(FLERR,"Undefined value for bond power"); if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && mlength!=0 && kmax!=0)return true; diff --git a/src/ML-RANN/rann_fingerprint_bondspin.cpp b/src/ML-RANN/rann_fingerprint_bondspin.cpp index 77749fa3c7..76c4c016ac 100644 --- a/src/ML-RANN/rann_fingerprint_bondspin.cpp +++ b/src/ML-RANN/rann_fingerprint_bondspin.cpp @@ -78,26 +78,26 @@ bool Fingerprint_bondspin::parse_values(std::string constant,std::vectorerrorf(FLERR,"Undefined value for bond power"); if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && mlength!=0 && kmax!=0)return true; diff --git a/src/ML-RANN/rann_fingerprint_radial.cpp b/src/ML-RANN/rann_fingerprint_radial.cpp index 29eeb07a65..f5b381f1f1 100644 --- a/src/ML-RANN/rann_fingerprint_radial.cpp +++ b/src/ML-RANN/rann_fingerprint_radial.cpp @@ -67,30 +67,30 @@ bool Fingerprint_radial::parse_values(std::string constant,std::vectorerrorf(FLERR,"Undefined value for radial power"); //code will run with default o=0 if o is never specified. All other values must be defined in potential file. - if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && nmax!=0)return true; + if (re!=0 && rc!=0 && alpha!=nullptr && dr!=0 && nmax!=0)return true; return false; } diff --git a/src/ML-RANN/rann_fingerprint_radialscreened.cpp b/src/ML-RANN/rann_fingerprint_radialscreened.cpp index 9ac98d183c..b8af308389 100644 --- a/src/ML-RANN/rann_fingerprint_radialscreened.cpp +++ b/src/ML-RANN/rann_fingerprint_radialscreened.cpp @@ -68,30 +68,30 @@ bool Fingerprint_radialscreened::parse_values(std::string constant,std::vectorerrorf(FLERR,"Undefined value for radial power"); //code will run with default o=0 if o is never specified. All other values must be defined in potential file. - if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && nmax!=0)return true; + if (re!=0 && rc!=0 && alpha!=nullptr && dr!=0 && nmax!=0)return true; return false; } diff --git a/src/ML-RANN/rann_fingerprint_radialscreenedspin.cpp b/src/ML-RANN/rann_fingerprint_radialscreenedspin.cpp index 3caeaa84da..de28610c8b 100644 --- a/src/ML-RANN/rann_fingerprint_radialscreenedspin.cpp +++ b/src/ML-RANN/rann_fingerprint_radialscreenedspin.cpp @@ -69,30 +69,30 @@ bool Fingerprint_radialscreenedspin::parse_values(std::string constant,std::vect int l; int nwords=line1.size(); if (constant.compare("re")==0) { - re = strtod(line1[0].c_str(),NULL); + re = strtod(line1[0].c_str(),nullptr); } else if (constant.compare("rc")==0) { - rc = strtod(line1[0].c_str(),NULL); + rc = strtod(line1[0].c_str(),nullptr); } else if (constant.compare("alpha")==0) { delete[] alpha; alpha = new double[nwords]; for (l=0;lerrorf(FLERR,"Undefined value for radial power"); //code will run with default o=0 if o is never specified. All other values must be defined in potential file. - if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && nmax!=0)return true; + if (re!=0 && rc!=0 && alpha!=nullptr && dr!=0 && nmax!=0)return true; return false; } diff --git a/src/ML-RANN/rann_fingerprint_radialspin.cpp b/src/ML-RANN/rann_fingerprint_radialspin.cpp index b48fad80d0..e7a4ef449e 100644 --- a/src/ML-RANN/rann_fingerprint_radialspin.cpp +++ b/src/ML-RANN/rann_fingerprint_radialspin.cpp @@ -68,30 +68,30 @@ bool Fingerprint_radialspin::parse_values(std::string constant,std::vectorerrorf(FLERR,"Undefined value for radial power"); //code will run with default o=0 if o is never specified. All other values must be defined in potential file. - if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && nmax!=0)return true; + if (re!=0 && rc!=0 && alpha!=nullptr && dr!=0 && nmax!=0)return true; return false; } diff --git a/src/MOLECULE/dihedral_table.cpp b/src/MOLECULE/dihedral_table.cpp index c701c4564f..a91324dd98 100644 --- a/src/MOLECULE/dihedral_table.cpp +++ b/src/MOLECULE/dihedral_table.cpp @@ -86,7 +86,7 @@ static int solve_cyc_tridiag( const double diag[], size_t d_stride, double * c = (double *) malloc (N * sizeof (double)); double * z = (double *) malloc (N * sizeof (double)); - if (delta == 0 || gamma == 0 || alpha == 0 || c == 0 || z == 0) { + if (delta == nullptr || gamma == nullptr || alpha == nullptr || c == nullptr || z == nullptr) { if (warn) fprintf(stderr,"Internal Cyclic Spline Error: failed to allocate working space\n"); diff --git a/src/MOLFILE/molfile_interface.cpp b/src/MOLFILE/molfile_interface.cpp index 808bc16ab4..9ce3822082 100644 --- a/src/MOLFILE/molfile_interface.cpp +++ b/src/MOLFILE/molfile_interface.cpp @@ -35,9 +35,9 @@ #define DEBUG 0 extern "C" { - typedef int (*initfunc)(void); + typedef int (*initfunc)(); typedef int (*regfunc)(void *, vmdplugin_register_cb); - typedef int (*finifunc)(void); + typedef int (*finifunc)(); typedef struct { void *p; diff --git a/src/MOLFILE/molfile_interface.h b/src/MOLFILE/molfile_interface.h index 4be74d5cbe..151618286b 100644 --- a/src/MOLFILE/molfile_interface.h +++ b/src/MOLFILE/molfile_interface.h @@ -113,7 +113,7 @@ class MolfileInterface { // inquire on interface status // true if file stream is active. - bool is_open() const { return (_ptr != 0); }; + bool is_open() const { return (_ptr != nullptr); }; // true if file format requires or provides atom properties bool has_props() const { return (_mode & (M_RSTRUCT | M_WSTRUCT)) != 0; }; // true if file format can read or write velocities diff --git a/src/OPENMP/pair_buck_long_coul_long_omp.cpp b/src/OPENMP/pair_buck_long_coul_long_omp.cpp index 4fd746b9a4..372c993a8d 100644 --- a/src/OPENMP/pair_buck_long_coul_long_omp.cpp +++ b/src/OPENMP/pair_buck_long_coul_long_omp.cpp @@ -332,7 +332,7 @@ void PairBuckLongCoulLongOMP::compute_inner() loop_setup_thr(ifrom, ito, tid, inum, nthreads); ThrData *thr = fix->get_thr(tid); thr->timer(Timer::START); - ev_setup_thr(0, 0, nall, 0, 0, nullptr, thr); + ev_setup_thr(0, 0, nall, nullptr, nullptr, nullptr, thr); eval_inner(ifrom, ito, thr); thr->timer(Timer::PAIR); @@ -357,7 +357,7 @@ void PairBuckLongCoulLongOMP::compute_middle() loop_setup_thr(ifrom, ito, tid, inum, nthreads); ThrData *thr = fix->get_thr(tid); thr->timer(Timer::START); - ev_setup_thr(0, 0, nall, 0, 0, nullptr, thr); + ev_setup_thr(0, 0, nall, nullptr, nullptr, nullptr, thr); eval_middle(ifrom, ito, thr); thr->timer(Timer::PAIR); @@ -810,7 +810,7 @@ void PairBuckLongCoulLongOMP::eval_inner(int iifrom, int iito, ThrData * const t const double qqrd2e = force->qqrd2e; const double *x0 = x[0]; - double *f0 = f[0], *fi = 0; + double *f0 = f[0], *fi = nullptr; int *ilist = list->ilist_inner; @@ -903,7 +903,7 @@ void PairBuckLongCoulLongOMP::eval_middle(int iifrom, int iito, ThrData * const const double qqrd2e = force->qqrd2e; const double *x0 = x[0]; - double *f0 = f[0], *fi = 0; + double *f0 = f[0], *fi = nullptr; int *ilist = list->ilist_middle; diff --git a/src/OPENMP/pair_lj_long_coul_long_omp.cpp b/src/OPENMP/pair_lj_long_coul_long_omp.cpp index a2758c545c..e0707a87e0 100644 --- a/src/OPENMP/pair_lj_long_coul_long_omp.cpp +++ b/src/OPENMP/pair_lj_long_coul_long_omp.cpp @@ -331,7 +331,7 @@ void PairLJLongCoulLongOMP::compute_inner() loop_setup_thr(ifrom, ito, tid, inum, nthreads); ThrData *thr = fix->get_thr(tid); thr->timer(Timer::START); - ev_setup_thr(0, 0, nall, 0, 0, nullptr, thr); + ev_setup_thr(0, 0, nall, nullptr, nullptr, nullptr, thr); eval_inner(ifrom, ito, thr); thr->timer(Timer::PAIR); @@ -356,7 +356,7 @@ void PairLJLongCoulLongOMP::compute_middle() loop_setup_thr(ifrom, ito, tid, inum, nthreads); ThrData *thr = fix->get_thr(tid); thr->timer(Timer::START); - ev_setup_thr(0, 0, nall, 0, 0, nullptr, thr); + ev_setup_thr(0, 0, nall, nullptr, nullptr, nullptr, thr); eval_middle(ifrom, ito, thr); thr->timer(Timer::PAIR); @@ -805,7 +805,7 @@ void PairLJLongCoulLongOMP::eval_inner(int iifrom, int iito, ThrData * const thr const double qqrd2e = force->qqrd2e; const double *x0 = x[0]; - double *f0 = f[0], *fi = 0; + double *f0 = f[0], *fi = nullptr; int *ilist = list->ilist_inner; @@ -896,7 +896,7 @@ void PairLJLongCoulLongOMP::eval_middle(int iifrom, int iito, ThrData * const th const double qqrd2e = force->qqrd2e; const double *x0 = x[0]; - double *f0 = f[0], *fi = 0; + double *f0 = f[0], *fi = nullptr; int *ilist = list->ilist_middle; diff --git a/src/OPENMP/pair_tersoff_table_omp.cpp b/src/OPENMP/pair_tersoff_table_omp.cpp index 5367a3d043..94f9e72c3d 100644 --- a/src/OPENMP/pair_tersoff_table_omp.cpp +++ b/src/OPENMP/pair_tersoff_table_omp.cpp @@ -502,7 +502,7 @@ void PairTersoffTableOMP::eval(int iifrom, int iito, ThrData * const thr) } // loop on I } -void PairTersoffTableOMP::deallocatePreLoops(void) +void PairTersoffTableOMP::deallocatePreLoops() { memory->destroy(thrGtetaFunction); memory->destroy(thrGtetaFunctionDerived); @@ -510,7 +510,7 @@ void PairTersoffTableOMP::deallocatePreLoops(void) memory->destroy(thrCutoffFunctionDerived); } -void PairTersoffTableOMP::allocatePreLoops(void) +void PairTersoffTableOMP::allocatePreLoops() { const int nthreads = comm->nthreads; memory->create(thrGtetaFunction,nthreads,leadingDimensionInteractionList,leadingDimensionInteractionList,"tersofftable:thrGtetaFunction"); diff --git a/src/OPENMP/pair_tersoff_table_omp.h b/src/OPENMP/pair_tersoff_table_omp.h index ce5260f77f..c686087f11 100644 --- a/src/OPENMP/pair_tersoff_table_omp.h +++ b/src/OPENMP/pair_tersoff_table_omp.h @@ -37,8 +37,8 @@ class PairTersoffTableOMP : public PairTersoffTable, public ThrOMP { double ***thrGtetaFunction, ***thrGtetaFunctionDerived; double **thrCutoffFunction, **thrCutoffFunctionDerived; - void allocatePreLoops(void); - void deallocatePreLoops(void); + void allocatePreLoops(); + void deallocatePreLoops(); private: template void eval(int ifrom, int ito, ThrData *const thr); diff --git a/src/OPENMP/thr_data.cpp b/src/OPENMP/thr_data.cpp index 5ff0263eea..f85b2b685f 100644 --- a/src/OPENMP/thr_data.cpp +++ b/src/OPENMP/thr_data.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ------------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -17,8 +16,8 @@ per-thread data management for LAMMPS ------------------------------------------------------------------------- */ -#include #include +#include #include "thr_data.h" @@ -29,21 +28,20 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -ThrData::ThrData(int tid, Timer *t) - : _f(0),_torque(0),_erforce(0),_de(0),_drho(0),_mu(0),_lambda(0),_rhoB(0), - _D_values(0),_rho(0),_fp(0),_rho1d(0),_drho1d(0),_rho1d_6(0),_drho1d_6(0), - _tid(tid), _timer(t) +ThrData::ThrData(int tid, Timer *t) : + _f(nullptr), _torque(nullptr), _erforce(nullptr), _de(nullptr), _drho(nullptr), _mu(nullptr), + _lambda(nullptr), _rhoB(nullptr), _D_values(nullptr), _rho(nullptr), _fp(nullptr), + _rho1d(nullptr), _drho1d(nullptr), _rho1d_6(nullptr), _drho1d_6(nullptr), _tid(tid), _timer(t) { _timer_active = 0; } - /* ---------------------------------------------------------------------- */ void ThrData::check_tid(int tid) { if (tid != _tid) - fprintf(stderr,"WARNING: external and internal tid mismatch %d != %d\n",tid,_tid); + fprintf(stderr, "WARNING: external and internal tid mismatch %d != %d\n", tid, _tid); } /* ---------------------------------------------------------------------- */ @@ -53,9 +51,7 @@ void ThrData::_stamp(enum Timer::ttype flag) // do nothing until it gets set to 0 in ::setup() if (_timer_active < 0) return; - if (flag == Timer::START) { - _timer_active = 1; - } + if (flag == Timer::START) { _timer_active = 1; } if (_timer_active) _timer->stamp(flag); } @@ -72,44 +68,49 @@ double ThrData::get_time(enum Timer::ttype flag) /* ---------------------------------------------------------------------- */ -void ThrData::init_force(int nall, double **f, double **torque, - double *erforce, double *de, double *drho) +void ThrData::init_force(int nall, double **f, double **torque, double *erforce, double *de, + double *drho) { - eng_vdwl=eng_coul=eng_bond=eng_angle=eng_dihed=eng_imprp=eng_kspce=0.0; - memset(virial_pair,0,6*sizeof(double)); - memset(virial_bond,0,6*sizeof(double)); - memset(virial_angle,0,6*sizeof(double)); - memset(virial_dihed,0,6*sizeof(double)); - memset(virial_imprp,0,6*sizeof(double)); - memset(virial_kspce,0,6*sizeof(double)); + eng_vdwl = eng_coul = eng_bond = eng_angle = eng_dihed = eng_imprp = eng_kspce = 0.0; + memset(virial_pair, 0, 6 * sizeof(double)); + memset(virial_bond, 0, 6 * sizeof(double)); + memset(virial_angle, 0, 6 * sizeof(double)); + memset(virial_dihed, 0, 6 * sizeof(double)); + memset(virial_imprp, 0, 6 * sizeof(double)); + memset(virial_kspce, 0, 6 * sizeof(double)); - eatom_pair=eatom_bond=eatom_angle=eatom_dihed=eatom_imprp=eatom_kspce=nullptr; - vatom_pair=vatom_bond=vatom_angle=vatom_dihed=vatom_imprp=vatom_kspce=nullptr; + eatom_pair = eatom_bond = eatom_angle = eatom_dihed = eatom_imprp = eatom_kspce = nullptr; + vatom_pair = vatom_bond = vatom_angle = vatom_dihed = vatom_imprp = vatom_kspce = nullptr; if (nall >= 0 && f) { - _f = f + _tid*nall; - memset(&(_f[0][0]),0,nall*3*sizeof(double)); - } else _f = nullptr; + _f = f + _tid * nall; + memset(&(_f[0][0]), 0, nall * 3 * sizeof(double)); + } else + _f = nullptr; if (nall >= 0 && torque) { - _torque = torque + _tid*nall; - memset(&(_torque[0][0]),0,nall*3*sizeof(double)); - } else _torque = nullptr; + _torque = torque + _tid * nall; + memset(&(_torque[0][0]), 0, nall * 3 * sizeof(double)); + } else + _torque = nullptr; if (nall >= 0 && erforce) { - _erforce = erforce + _tid*nall; - memset(&(_erforce[0]),0,nall*sizeof(double)); - } else _erforce = nullptr; + _erforce = erforce + _tid * nall; + memset(&(_erforce[0]), 0, nall * sizeof(double)); + } else + _erforce = nullptr; if (nall >= 0 && de) { - _de = de + _tid*nall; - memset(&(_de[0]),0,nall*sizeof(double)); - } else _de = nullptr; + _de = de + _tid * nall; + memset(&(_de[0]), 0, nall * sizeof(double)); + } else + _de = nullptr; if (nall >= 0 && drho) { - _drho = drho + _tid*nall; - memset(&(_drho[0]),0,nall*sizeof(double)); - } else _drho = nullptr; + _drho = drho + _tid * nall; + memset(&(_drho[0]), 0, nall * sizeof(double)); + } else + _drho = nullptr; } /* ---------------------------------------------------------------------- @@ -119,8 +120,8 @@ void ThrData::init_force(int nall, double **f, double **torque, void ThrData::init_eam(int nall, double *rho) { if (nall >= 0 && rho) { - _rho = rho + _tid*nall; - memset(_rho, 0, nall*sizeof(double)); + _rho = rho + _tid * nall; + memset(_rho, 0, nall * sizeof(double)); } } @@ -131,10 +132,10 @@ void ThrData::init_adp(int nall, double *rho, double **mu, double **lambda) init_eam(nall, rho); if (nall >= 0 && mu && lambda) { - _mu = mu + _tid*nall; - _lambda = lambda + _tid*nall; - memset(&(_mu[0][0]), 0, nall*3*sizeof(double)); - memset(&(_lambda[0][0]), 0, nall*6*sizeof(double)); + _mu = mu + _tid * nall; + _lambda = lambda + _tid * nall; + memset(&(_mu[0][0]), 0, nall * 3 * sizeof(double)); + memset(&(_lambda[0][0]), 0, nall * 6 * sizeof(double)); } } @@ -145,8 +146,8 @@ void ThrData::init_eim(int nall, double *rho, double *fp) init_eam(nall, rho); if (nall >= 0 && fp) { - _fp = fp + _tid*nall; - memset(_fp,0,nall*sizeof(double)); + _fp = fp + _tid * nall; + memset(_fp, 0, nall * sizeof(double)); } } @@ -166,18 +167,18 @@ void ThrData::init_pppm(int order, Memory *memory) if (order > 0) { rho1d = static_cast(_rho1d); drho1d = static_cast(_drho1d); - if (rho1d) memory->destroy2d_offset(rho1d,-order/2); - if (drho1d) memory->destroy2d_offset(drho1d,-order/2); - memory->create2d_offset(rho1d,3,-order/2,order/2,"thr_data:rho1d"); - memory->create2d_offset(drho1d,3,-order/2,order/2,"thr_data:drho1d"); + if (rho1d) memory->destroy2d_offset(rho1d, -order / 2); + if (drho1d) memory->destroy2d_offset(drho1d, -order / 2); + memory->create2d_offset(rho1d, 3, -order / 2, order / 2, "thr_data:rho1d"); + memory->create2d_offset(drho1d, 3, -order / 2, order / 2, "thr_data:drho1d"); _rho1d = static_cast(rho1d); _drho1d = static_cast(drho1d); } else { order = -order; rho1d = static_cast(_rho1d); drho1d = static_cast(_drho1d); - if (rho1d) memory->destroy2d_offset(rho1d,-order/2); - if (drho1d) memory->destroy2d_offset(drho1d,-order/2); + if (rho1d) memory->destroy2d_offset(rho1d, -order / 2); + if (drho1d) memory->destroy2d_offset(drho1d, -order / 2); _rho1d = nullptr; _drho1d = nullptr; } @@ -199,18 +200,18 @@ void ThrData::init_pppm_disp(int order_6, Memory *memory) if (order_6 > 0) { rho1d_6 = static_cast(_rho1d_6); drho1d_6 = static_cast(_drho1d_6); - if (rho1d_6) memory->destroy2d_offset(rho1d_6,-order_6/2); - if (drho1d_6) memory->destroy2d_offset(drho1d_6,-order_6/2); - memory->create2d_offset(rho1d_6,3,-order_6/2,order_6/2,"thr_data:rho1d_6"); - memory->create2d_offset(drho1d_6,3,-order_6/2,order_6/2,"thr_data:drho1d_6"); + if (rho1d_6) memory->destroy2d_offset(rho1d_6, -order_6 / 2); + if (drho1d_6) memory->destroy2d_offset(drho1d_6, -order_6 / 2); + memory->create2d_offset(rho1d_6, 3, -order_6 / 2, order_6 / 2, "thr_data:rho1d_6"); + memory->create2d_offset(drho1d_6, 3, -order_6 / 2, order_6 / 2, "thr_data:drho1d_6"); _rho1d_6 = static_cast(rho1d_6); _drho1d_6 = static_cast(drho1d_6); } else { order_6 = -order_6; rho1d_6 = static_cast(_rho1d_6); drho1d_6 = static_cast(_drho1d_6); - if (rho1d_6) memory->destroy2d_offset(rho1d_6,-order_6/2); - if (drho1d_6) memory->destroy2d_offset(drho1d_6,-order_6/2); + if (rho1d_6) memory->destroy2d_offset(rho1d_6, -order_6 / 2); + if (drho1d_6) memory->destroy2d_offset(drho1d_6, -order_6 / 2); } } @@ -227,35 +228,35 @@ void ThrData::virial_fdotr_compute(double **x, int nlocal, int nghost, int nfirs if (nfirst < 0) { int nall = nlocal + nghost; for (int i = 0; i < nall; i++) { - virial_pair[0] += _f[i][0]*x[i][0]; - virial_pair[1] += _f[i][1]*x[i][1]; - virial_pair[2] += _f[i][2]*x[i][2]; - virial_pair[3] += _f[i][1]*x[i][0]; - virial_pair[4] += _f[i][2]*x[i][0]; - virial_pair[5] += _f[i][2]*x[i][1]; + virial_pair[0] += _f[i][0] * x[i][0]; + virial_pair[1] += _f[i][1] * x[i][1]; + virial_pair[2] += _f[i][2] * x[i][2]; + virial_pair[3] += _f[i][1] * x[i][0]; + virial_pair[4] += _f[i][2] * x[i][0]; + virial_pair[5] += _f[i][2] * x[i][1]; } - // neighbor includegroup flag is set - // sum over force on initial nfirst particles and ghosts + // neighbor includegroup flag is set + // sum over force on initial nfirst particles and ghosts } else { int nall = nfirst; for (int i = 0; i < nall; i++) { - virial_pair[0] += _f[i][0]*x[i][0]; - virial_pair[1] += _f[i][1]*x[i][1]; - virial_pair[2] += _f[i][2]*x[i][2]; - virial_pair[3] += _f[i][1]*x[i][0]; - virial_pair[4] += _f[i][2]*x[i][0]; - virial_pair[5] += _f[i][2]*x[i][1]; + virial_pair[0] += _f[i][0] * x[i][0]; + virial_pair[1] += _f[i][1] * x[i][1]; + virial_pair[2] += _f[i][2] * x[i][2]; + virial_pair[3] += _f[i][1] * x[i][0]; + virial_pair[4] += _f[i][2] * x[i][0]; + virial_pair[5] += _f[i][2] * x[i][1]; } nall = nlocal + nghost; for (int i = nlocal; i < nall; i++) { - virial_pair[0] += _f[i][0]*x[i][0]; - virial_pair[1] += _f[i][1]*x[i][1]; - virial_pair[2] += _f[i][2]*x[i][2]; - virial_pair[3] += _f[i][1]*x[i][0]; - virial_pair[4] += _f[i][2]*x[i][0]; - virial_pair[5] += _f[i][2]*x[i][1]; + virial_pair[0] += _f[i][0] * x[i][0]; + virial_pair[1] += _f[i][1] * x[i][1]; + virial_pair[2] += _f[i][2] * x[i][2]; + virial_pair[3] += _f[i][1] * x[i][0]; + virial_pair[4] += _f[i][2] * x[i][0]; + virial_pair[5] += _f[i][2] * x[i][1]; } } } @@ -264,9 +265,9 @@ void ThrData::virial_fdotr_compute(double **x, int nlocal, int nghost, int nfirs double ThrData::memory_usage() { - double bytes = (7 + 6*6) * sizeof(double); - bytes += (double)2 * sizeof(double*); - bytes += (double)4 * sizeof(int); + double bytes = (7 + 6 * 6) * sizeof(double); + bytes += (double) 2 * sizeof(double *); + bytes += (double) 4 * sizeof(int); return bytes; } @@ -287,10 +288,10 @@ void LAMMPS_NS::data_reduce_thr(double *dall, int nall, int nthreads, int ndim, if (nthreads == 1) return; #pragma omp barrier { - const int nvals = ndim*nall; - const int idelta = nvals/nthreads + 1; - const int ifrom = tid*idelta; - const int ito = ((ifrom + idelta) > nvals) ? nvals : (ifrom + idelta); + const int nvals = ndim * nall; + const int idelta = nvals / nthreads + 1; + const int ifrom = tid * idelta; + const int ito = ((ifrom + idelta) > nvals) ? nvals : (ifrom + idelta); #if defined(USER_OMP_NO_UNROLL) if (ifrom < nvals) { @@ -298,8 +299,8 @@ void LAMMPS_NS::data_reduce_thr(double *dall, int nall, int nthreads, int ndim, for (m = ifrom; m < ito; ++m) { for (int n = 1; n < nthreads; ++n) { - dall[m] += dall[n*nvals + m]; - dall[n*nvals + m] = 0.0; + dall[m] += dall[n * nvals + m]; + dall[n * nvals + m] = 0.0; } } } @@ -313,47 +314,47 @@ void LAMMPS_NS::data_reduce_thr(double *dall, int nall, int nthreads, int ndim, // contiguous values in the array at a time // -- modify this code based on the size of the cache line double t0, t1, t2, t3, t4, t5, t6, t7; - for (m = ifrom; m < (ito-7); m+=8) { - t0 = dall[m ]; - t1 = dall[m+1]; - t2 = dall[m+2]; - t3 = dall[m+3]; - t4 = dall[m+4]; - t5 = dall[m+5]; - t6 = dall[m+6]; - t7 = dall[m+7]; + for (m = ifrom; m < (ito - 7); m += 8) { + t0 = dall[m]; + t1 = dall[m + 1]; + t2 = dall[m + 2]; + t3 = dall[m + 3]; + t4 = dall[m + 4]; + t5 = dall[m + 5]; + t6 = dall[m + 6]; + t7 = dall[m + 7]; for (int n = 1; n < nthreads; ++n) { - t0 += dall[n*nvals + m ]; - t1 += dall[n*nvals + m+1]; - t2 += dall[n*nvals + m+2]; - t3 += dall[n*nvals + m+3]; - t4 += dall[n*nvals + m+4]; - t5 += dall[n*nvals + m+5]; - t6 += dall[n*nvals + m+6]; - t7 += dall[n*nvals + m+7]; - dall[n*nvals + m ] = 0.0; - dall[n*nvals + m+1] = 0.0; - dall[n*nvals + m+2] = 0.0; - dall[n*nvals + m+3] = 0.0; - dall[n*nvals + m+4] = 0.0; - dall[n*nvals + m+5] = 0.0; - dall[n*nvals + m+6] = 0.0; - dall[n*nvals + m+7] = 0.0; + t0 += dall[n * nvals + m]; + t1 += dall[n * nvals + m + 1]; + t2 += dall[n * nvals + m + 2]; + t3 += dall[n * nvals + m + 3]; + t4 += dall[n * nvals + m + 4]; + t5 += dall[n * nvals + m + 5]; + t6 += dall[n * nvals + m + 6]; + t7 += dall[n * nvals + m + 7]; + dall[n * nvals + m] = 0.0; + dall[n * nvals + m + 1] = 0.0; + dall[n * nvals + m + 2] = 0.0; + dall[n * nvals + m + 3] = 0.0; + dall[n * nvals + m + 4] = 0.0; + dall[n * nvals + m + 5] = 0.0; + dall[n * nvals + m + 6] = 0.0; + dall[n * nvals + m + 7] = 0.0; } - dall[m ] = t0; - dall[m+1] = t1; - dall[m+2] = t2; - dall[m+3] = t3; - dall[m+4] = t4; - dall[m+5] = t5; - dall[m+6] = t6; - dall[m+7] = t7; + dall[m] = t0; + dall[m + 1] = t1; + dall[m + 2] = t2; + dall[m + 3] = t3; + dall[m + 4] = t4; + dall[m + 5] = t5; + dall[m + 6] = t6; + dall[m + 7] = t7; } // do the last < 8 values for (; m < ito; m++) { for (int n = 1; n < nthreads; ++n) { - dall[m] += dall[n*nvals + m]; - dall[n*nvals + m] = 0.0; + dall[m] += dall[n * nvals + m]; + dall[n * nvals + m] = 0.0; } } } diff --git a/src/OPT/pair_eam_opt.cpp b/src/OPT/pair_eam_opt.cpp index 08af3e7d18..998b14a5e7 100644 --- a/src/OPT/pair_eam_opt.cpp +++ b/src/OPT/pair_eam_opt.cpp @@ -349,8 +349,8 @@ void PairEAMOpt::eval() ff[i].z += tmpfz; } - free(fast_alpha); fast_alpha = 0; - free(fast_gamma); fast_gamma = 0; + free(fast_alpha); fast_alpha = nullptr; + free(fast_gamma); fast_gamma = nullptr; if (vflag_fdotr) virial_fdotr_compute(); } diff --git a/src/OPT/pair_lj_charmm_coul_long_opt.cpp b/src/OPT/pair_lj_charmm_coul_long_opt.cpp index 7b6bec5b94..186172035c 100644 --- a/src/OPT/pair_lj_charmm_coul_long_opt.cpp +++ b/src/OPT/pair_lj_charmm_coul_long_opt.cpp @@ -333,7 +333,7 @@ void PairLJCharmmCoulLongOpt::eval() ff[i].z += tmpfz; } - free(fast_alpha); fast_alpha = 0; + free(fast_alpha); fast_alpha = nullptr; if (vflag_fdotr) virial_fdotr_compute(); } diff --git a/src/OPT/pair_lj_cut_opt.cpp b/src/OPT/pair_lj_cut_opt.cpp index e0ab42b779..f272e6fc78 100644 --- a/src/OPT/pair_lj_cut_opt.cpp +++ b/src/OPT/pair_lj_cut_opt.cpp @@ -195,7 +195,7 @@ void PairLJCutOpt::eval() ff[i].z += tmpfz; } - free(fast_alpha); fast_alpha = 0; + free(fast_alpha); fast_alpha = nullptr; if (vflag_fdotr) virial_fdotr_compute(); } diff --git a/src/OPT/pair_morse_opt.cpp b/src/OPT/pair_morse_opt.cpp index 80414b40c8..04aace0d43 100644 --- a/src/OPT/pair_morse_opt.cpp +++ b/src/OPT/pair_morse_opt.cpp @@ -192,7 +192,7 @@ void PairMorseOpt::eval() ff[i].z += tmpfz; } - free(fast_alpha); fast_alpha = 0; + free(fast_alpha); fast_alpha = nullptr; if (vflag_fdotr) virial_fdotr_compute(); } diff --git a/src/OPT/pair_ufm_opt.cpp b/src/OPT/pair_ufm_opt.cpp index 3008d0af22..3502dfda6c 100644 --- a/src/OPT/pair_ufm_opt.cpp +++ b/src/OPT/pair_ufm_opt.cpp @@ -191,7 +191,7 @@ void PairUFMOpt::eval() ff[i].z += tmpfz; } - free(fast_alpha); fast_alpha = 0; + free(fast_alpha); fast_alpha = nullptr; if (vflag_fdotr) virial_fdotr_compute(); } diff --git a/src/PTM/ptm_index.cpp b/src/PTM/ptm_index.cpp index a0798b9e88..aff81af2e3 100644 --- a/src/PTM/ptm_index.cpp +++ b/src/PTM/ptm_index.cpp @@ -23,7 +23,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include #include -#include +#include static double calculate_interatomic_distance(int type, double scale) { assert(type >= 1 && type <= 8); diff --git a/src/REACTION/fix_bond_react.cpp b/src/REACTION/fix_bond_react.cpp index 69c9c87ddf..bddeb330e4 100644 --- a/src/REACTION/fix_bond_react.cpp +++ b/src/REACTION/fix_bond_react.cpp @@ -49,6 +49,7 @@ Contributing Author: Jacob Gissinger (jacob.r.gissinger@gmail.com) #include #include +#include using namespace LAMMPS_NS; using namespace FixConst; @@ -1380,6 +1381,10 @@ void FixBondReact::superimpose_algorithm() if (!rxnflag) return; + // C++11 and later compatible version of Park pRNG + std::random_device rnd; + std::minstd_rand park_rng(rnd()); + // check if we overstepped our reaction limit for (int i = 0; i < nreacts; i++) { if (reaction_count_total[i] > max_rxn[i]) { @@ -1400,7 +1405,7 @@ void FixBondReact::superimpose_algorithm() for (int j = 0; j < nprocs; j++) for (int k = 0; k < local_rxncounts[j]; k++) rxn_by_proc[itemp++] = j; - std::random_shuffle(&rxn_by_proc[0],&rxn_by_proc[delta_rxn]); + std::shuffle(&rxn_by_proc[0],&rxn_by_proc[delta_rxn], park_rng); for (int j = 0; j < nprocs; j++) all_localskips[j] = 0; nghostlyskips[i] = 0; diff --git a/src/exceptions.h b/src/exceptions.h index 1df6c5d1a3..1c9d8c8daf 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -26,9 +26,9 @@ class LAMMPSException : public std::exception { LAMMPSException(const std::string &msg) : message(msg) {} - ~LAMMPSException() throw() {} + ~LAMMPSException() noexcept {} - virtual const char *what() const throw() { return message.c_str(); } + virtual const char *what() const noexcept { return message.c_str(); } }; class LAMMPSAbortException : public LAMMPSException { diff --git a/src/file_writer.h b/src/file_writer.h index 473975d7fe..42e636d16f 100644 --- a/src/file_writer.h +++ b/src/file_writer.h @@ -39,9 +39,9 @@ class FileWriterException : public std::exception { public: FileWriterException(const std::string &msg) : message(msg) {} - ~FileWriterException() throw() {} + ~FileWriterException() noexcept {} - virtual const char *what() const throw() { return message.c_str(); } + virtual const char *what() const noexcept { return message.c_str(); } }; } // namespace LAMMPS_NS diff --git a/src/min_hftn.cpp b/src/min_hftn.cpp index e743f1e1da..6786379cd7 100644 --- a/src/min_hftn.cpp +++ b/src/min_hftn.cpp @@ -95,7 +95,7 @@ MinHFTN::MinHFTN(LAMMPS *lmp) : Min(lmp) Destructor ------------------------------------------------------------------------- */ -MinHFTN::~MinHFTN (void) +MinHFTN::~MinHFTN() { for (int i = 1; i < NUM_HFTN_ATOM_BASED_VECTORS; i++) if (_daExtraGlobal[i] != nullptr) diff --git a/src/min_hftn.h b/src/min_hftn.h index 3512d24220..4b909c3112 100644 --- a/src/min_hftn.h +++ b/src/min_hftn.h @@ -27,7 +27,7 @@ namespace LAMMPS_NS { class MinHFTN : public Min { public: MinHFTN(LAMMPS *); - ~MinHFTN(void); + ~MinHFTN(); void init(); void setup_style(); void reset_vectors(); @@ -64,7 +64,7 @@ class MinHFTN : public Min { const double dEnergyAtXin, const double dForce2AtXin, double &dEnergyAtXout, double &dForce2AtXout, int &nStepType, double &dStepLength2, double &dStepLengthInf); - double calc_xinf_using_mpi_(void) const; + double calc_xinf_using_mpi_() const; double calc_dot_prod_using_mpi_(const int nIx1, const int nIx2) const; double calc_grad_dot_v_using_mpi_(const int nIx) const; void calc_dhd_dd_using_mpi_(double &dDHD, double &dDD) const; @@ -72,19 +72,19 @@ class MinHFTN : public Min { void calc_plengths_using_mpi_(double &dStepLength2, double &dStepLengthInf) const; bool step_exceeds_TR_(const double dTrustRadius, const double dPP, const double dPD, const double dDD, double &dTau) const; - bool step_exceeds_DMAX_(void) const; + bool step_exceeds_DMAX_() const; void adjust_step_to_tau_(const double tau); double compute_to_tr_(const double dPP, const double dPD, const double dDD, const double dTrustRadius, const bool bConsiderBothRoots, const double dDHD, const double dPdotHD, const double dGradDotD) const; void evaluate_dir_der_(const bool bUseForwardDiffs, const int nIxDir, const int nIxResult, const bool bEvaluateAtX, double &dNewEnergy); - void open_hftn_print_file_(void); + void open_hftn_print_file_(); void hftn_print_line_(const bool bIsStepAccepted, const int nIteration, const int nTotalEvals, const double dEnergy, const double dForce2, const int nStepType, const double dTrustRadius, const double dStepLength2, const double dActualRed, const double dPredictedRed) const; - void close_hftn_print_file_(void); + void close_hftn_print_file_(); }; } // namespace LAMMPS_NS diff --git a/src/pointers.h b/src/pointers.h index 55033aae3e..44820d06eb 100644 --- a/src/pointers.h +++ b/src/pointers.h @@ -23,14 +23,16 @@ #define LMP_POINTERS_H #include "lmptype.h" // IWYU pragma: export + #include // IWYU pragma: export #include // IWYU pragme: export #include // IWYU pragma: export #include // IWYU pragma: export -#include "lammps.h" // IWYU pragma: export -#include "utils.h" // IWYU pragma: export + #include "fmt/format.h" // IWYU pragma: export +#include "lammps.h" // IWYU pragma: export #include "platform.h" // IWYU pragma: export +#include "utils.h" // IWYU pragma: export namespace LAMMPS_NS { @@ -91,6 +93,14 @@ class Pointers { python(ptr->python) {} virtual ~Pointers() {} + // remove default members execept for the copy constructor + + Pointers() = delete; + Pointers(const Pointers &) = default; + Pointers(Pointers &&) = delete; + Pointers & operator=(const Pointers&) = delete; + Pointers & operator=(Pointers&&) = delete; + protected: LAMMPS *lmp; Memory *&memory; diff --git a/src/text_file_reader.h b/src/text_file_reader.h index 98657a937e..826f470299 100644 --- a/src/text_file_reader.h +++ b/src/text_file_reader.h @@ -52,9 +52,9 @@ class FileReaderException : public std::exception { public: FileReaderException(const std::string &msg) : message(msg) {} - ~FileReaderException() throw() {} + ~FileReaderException() noexcept {} - virtual const char *what() const throw() { return message.c_str(); } + virtual const char *what() const noexcept { return message.c_str(); } }; class EOFException : public FileReaderException { diff --git a/src/tokenizer.h b/src/tokenizer.h index 7f45a512dd..ad4f0d3536 100644 --- a/src/tokenizer.h +++ b/src/tokenizer.h @@ -62,11 +62,11 @@ class TokenizerException : public std::exception { * \param token String of the token/word that caused the error */ TokenizerException(const std::string &msg, const std::string &token); - ~TokenizerException() throw() {} + ~TokenizerException() noexcept {} /** Retrieve message describing the thrown exception * \return string with error message */ - virtual const char *what() const throw() { return message.c_str(); } + virtual const char *what() const noexcept { return message.c_str(); } }; class InvalidIntegerException : public TokenizerException { diff --git a/src/utils.cpp b/src/utils.cpp index 035b68d660..dab56da8d3 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1481,7 +1481,7 @@ static int ismetachar(char c); int re_matchp(const char *text, re_t pattern, int *matchlen) { *matchlen = 0; - if (pattern != 0) { + if (pattern != nullptr) { if (pattern[0].type == RX_BEGIN) { return ((matchpattern(&pattern[1], text, matchlen)) ? 0 : -1); } else { @@ -1595,7 +1595,7 @@ re_t re_compile(re_ctx_t context, const char *pattern) i += 1; /* Increment i to avoid including '^' in the char-buffer */ if (pattern[i + 1] == 0) /* incomplete pattern, missing non-zero char after '^' */ { - return 0; + return nullptr; } } else { re_compiled[j].type = RX_CHAR_CLASS; @@ -1605,20 +1605,20 @@ re_t re_compile(re_ctx_t context, const char *pattern) while ((pattern[++i] != ']') && (pattern[i] != '\0')) { /* Missing ] */ if (pattern[i] == '\\') { - if (ccl_bufidx >= MAX_CHAR_CLASS_LEN - 1) { return 0; } + if (ccl_bufidx >= MAX_CHAR_CLASS_LEN - 1) { return nullptr; } if (pattern[i + 1] == 0) /* incomplete pattern, missing non-zero char after '\\' */ { - return 0; + return nullptr; } ccl_buf[ccl_bufidx++] = pattern[i++]; } else if (ccl_bufidx >= MAX_CHAR_CLASS_LEN) { - return 0; + return nullptr; } ccl_buf[ccl_bufidx++] = pattern[i]; } if (ccl_bufidx >= MAX_CHAR_CLASS_LEN) { /* Catches cases such as [00000000000000000000000000000000000000][ */ - return 0; + return nullptr; } /* Null-terminate string end */ ccl_buf[ccl_bufidx++] = 0; @@ -1633,7 +1633,7 @@ re_t re_compile(re_ctx_t context, const char *pattern) } /* no buffer-out-of-bounds access on invalid patterns - * see https://github.com/kokke/tiny-regex-c/commit/1a279e04014b70b0695fba559a7c05d55e6ee90b */ - if (pattern[i] == 0) { return 0; } + if (pattern[i] == 0) { return nullptr; } i += 1; j += 1; diff --git a/unittest/cplusplus/test_lammps_class.cpp b/unittest/cplusplus/test_lammps_class.cpp index fa7f6b30a9..663c7358d9 100644 --- a/unittest/cplusplus/test_lammps_class.cpp +++ b/unittest/cplusplus/test_lammps_class.cpp @@ -108,21 +108,22 @@ TEST_F(LAMMPS_plain, TestStyles) const char *found; const char *atom_styles[] = {"atomic", "body", "charge", "ellipsoid", "hybrid", - "line", "sphere", "tri", NULL}; - for (int i = 0; atom_styles[i] != NULL; ++i) { + "line", "sphere", "tri", nullptr}; + for (int i = 0; atom_styles[i] != nullptr; ++i) { found = lmp->match_style("atom", atom_styles[i]); - EXPECT_STREQ(found, NULL); + EXPECT_STREQ(found, nullptr); } - const char *molecule_atom_styles[] = {"angle", "bond", "full", "molecular", "template", NULL}; - for (int i = 0; molecule_atom_styles[i] != NULL; ++i) { + const char *molecule_atom_styles[] = {"angle", "bond", "full", + "molecular", "template", nullptr}; + for (int i = 0; molecule_atom_styles[i] != nullptr; ++i) { found = lmp->match_style("atom", molecule_atom_styles[i]); EXPECT_STREQ(found, "MOLECULE"); } const char *kokkos_atom_styles[] = {"angle/kk", "bond/kk", "full/kk", - "molecular/kk", "hybrid/kk", NULL}; - for (int i = 0; kokkos_atom_styles[i] != NULL; ++i) { + "molecular/kk", "hybrid/kk", nullptr}; + for (int i = 0; kokkos_atom_styles[i] != nullptr; ++i) { found = lmp->match_style("atom", kokkos_atom_styles[i]); EXPECT_STREQ(found, "KOKKOS"); } @@ -149,7 +150,7 @@ TEST_F(LAMMPS_plain, TestStyles) found = lmp->match_style("atom", "sph"); EXPECT_STREQ(found, "SPH"); found = lmp->match_style("atom", "i_don't_exist"); - EXPECT_STREQ(found, NULL); + EXPECT_STREQ(found, nullptr); } // test fixture for OpenMP with 2 threads diff --git a/unittest/force-styles/test_main.cpp b/unittest/force-styles/test_main.cpp index 5b2663a6cf..1ad0b79455 100644 --- a/unittest/force-styles/test_main.cpp +++ b/unittest/force-styles/test_main.cpp @@ -47,7 +47,7 @@ void write_yaml_header(YamlWriter *writer, TestConfig *cfg, const char *version) writer->emit("lammps_version", version); // date_generated - std::time_t now = time(NULL); + std::time_t now = time(nullptr); std::string block = trim(ctime(&now)); writer->emit("date_generated", block); diff --git a/unittest/force-styles/yaml_writer.cpp b/unittest/force-styles/yaml_writer.cpp index feaa3d52eb..b1165ff821 100644 --- a/unittest/force-styles/yaml_writer.cpp +++ b/unittest/force-styles/yaml_writer.cpp @@ -31,9 +31,9 @@ YamlWriter::YamlWriter(const char *outfile) yaml_stream_start_event_initialize(&event, YAML_UTF8_ENCODING); yaml_emitter_emit(&emitter, &event); - yaml_document_start_event_initialize(&event, NULL, NULL, NULL, 0); + yaml_document_start_event_initialize(&event, nullptr, nullptr, nullptr, 0); yaml_emitter_emit(&emitter, &event); - yaml_mapping_start_event_initialize(&event, NULL, (yaml_char_t *)YAML_MAP_TAG, 1, + yaml_mapping_start_event_initialize(&event, nullptr, (yaml_char_t *)YAML_MAP_TAG, 1, YAML_ANY_MAPPING_STYLE); yaml_emitter_emit(&emitter, &event); } @@ -67,11 +67,11 @@ void YamlWriter::emit(const std::string &key, const int value) void YamlWriter::emit(const std::string &key, const std::string &value) { - yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, + yaml_scalar_event_initialize(&event, nullptr, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)key.c_str(), key.size(), 1, 0, YAML_PLAIN_SCALAR_STYLE); yaml_emitter_emit(&emitter, &event); - yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, + yaml_scalar_event_initialize(&event, nullptr, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)value.c_str(), value.size(), 1, 0, YAML_PLAIN_SCALAR_STYLE); yaml_emitter_emit(&emitter, &event); @@ -79,11 +79,11 @@ void YamlWriter::emit(const std::string &key, const std::string &value) void YamlWriter::emit_block(const std::string &key, const std::string &value) { - yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, + yaml_scalar_event_initialize(&event, nullptr, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)key.c_str(), key.size(), 1, 0, YAML_PLAIN_SCALAR_STYLE); yaml_emitter_emit(&emitter, &event); - yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, + yaml_scalar_event_initialize(&event, nullptr, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)value.c_str(), value.size(), 1, 0, YAML_LITERAL_SCALAR_STYLE); yaml_emitter_emit(&emitter, &event);