Skip to content

Commit

Permalink
fix: avoid using namespace std; in header files
Browse files Browse the repository at this point in the history
Signed-off-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
  • Loading branch information
e-kwsm committed Apr 2, 2023
1 parent 3ac8c4c commit dbfa586
Show file tree
Hide file tree
Showing 23 changed files with 152 additions and 190 deletions.
2 changes: 0 additions & 2 deletions source/api_cc/include/AtomMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include <vector>

// using namespace std;

namespace deepmd {
class AtomMap {
public:
Expand Down
2 changes: 0 additions & 2 deletions source/api_cc/include/version.h.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#pragma once

#include <string>
// using namespace std;


const std::string global_install_prefix="@CMAKE_INSTALL_PREFIX@";
const std::string global_git_summ="@GIT_SUMM@";
Expand Down
2 changes: 0 additions & 2 deletions source/ipi/include/Convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include <string>
#include <vector>

// using namespace std;

template <typename VALUETYPE>
class Convert {
public:
Expand Down
1 change: 0 additions & 1 deletion source/ipi/include/XyzFileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <string>
#include <vector>
// using namespace std;

namespace XyzFileManager {

Expand Down
2 changes: 0 additions & 2 deletions source/lib/include/SimulationRegion_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

#include "errors.h"

// using namespace std;

template <typename VALUETYPE>
SimulationRegion<VALUETYPE>::~SimulationRegion() {}

Expand Down
63 changes: 31 additions & 32 deletions source/md/include/AdWeight.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include <vector>

using namespace std;

#ifdef HIGH_PREC
typedef double VALUETYPE;
#else
Expand All @@ -13,29 +11,29 @@ typedef float VALUETYPE;
class AdWeight {
public:
AdWeight(const VALUETYPE& pl);
virtual void zone_tag(vector<int>& tag,
const vector<VALUETYPE>& coord) const = 0;
virtual void atom_weight(vector<VALUETYPE>& weight,
vector<VALUETYPE>& weight_x,
const vector<VALUETYPE>& coord) const = 0;
virtual vector<VALUETYPE> get_center() const = 0;
void sel_nn_atom(vector<VALUETYPE>& nn_coord,
vector<int>& nn_type,
vector<int>& nn_idx,
vector<int>& nn_tag,
const vector<VALUETYPE>& dcoord,
const vector<int>& dtype) const;
void force_intpl(vector<VALUETYPE>& of,
const vector<VALUETYPE>& dcoord,
const vector<VALUETYPE>& ff_force,
const vector<VALUETYPE>& nn_force,
const vector<int>& nn_idx) const;
void force_intpl(vector<VALUETYPE>& of,
const vector<VALUETYPE>& dcoord,
const vector<VALUETYPE>& ff_bd_force,
const vector<VALUETYPE>& ff_nb_force,
const vector<VALUETYPE>& nn_force,
const vector<int>& nn_idx) const;
virtual void zone_tag(std::vector<int>& tag,
const std::vector<VALUETYPE>& coord) const = 0;
virtual void atom_weight(std::vector<VALUETYPE>& weight,
std::vector<VALUETYPE>& weight_x,
const std::vector<VALUETYPE>& coord) const = 0;
virtual std::vector<VALUETYPE> get_center() const = 0;
void sel_nn_atom(std::vector<VALUETYPE>& nn_coord,
std::vector<int>& nn_type,
std::vector<int>& nn_idx,
std::vector<int>& nn_tag,
const std::vector<VALUETYPE>& dcoord,
const std::vector<int>& dtype) const;
void force_intpl(std::vector<VALUETYPE>& of,
const std::vector<VALUETYPE>& dcoord,
const std::vector<VALUETYPE>& ff_force,
const std::vector<VALUETYPE>& nn_force,
const std::vector<int>& nn_idx) const;
void force_intpl(std::vector<VALUETYPE>& of,
const std::vector<VALUETYPE>& dcoord,
const std::vector<VALUETYPE>& ff_bd_force,
const std::vector<VALUETYPE>& ff_nb_force,
const std::vector<VALUETYPE>& nn_force,
const std::vector<int>& nn_idx) const;

private:
VALUETYPE protect_level;
Expand All @@ -44,19 +42,20 @@ class AdWeight {
// slab model, axis x
class SlabWeight : public AdWeight {
public:
SlabWeight(const vector<VALUETYPE>& box,
SlabWeight(const std::vector<VALUETYPE>& box,
const VALUETYPE& rnn,
const VALUETYPE& rhy,
const VALUETYPE& rc,
const VALUETYPE& protect_level = 1e-3);
virtual void zone_tag(vector<int>& tag, const vector<VALUETYPE>& coord) const;
virtual void atom_weight(vector<VALUETYPE>& weight,
vector<VALUETYPE>& weight_x,
const vector<VALUETYPE>& coord) const;
virtual vector<VALUETYPE> get_center() const { return center; }
virtual void zone_tag(std::vector<int>& tag,
const std::vector<VALUETYPE>& coord) const;
virtual void atom_weight(std::vector<VALUETYPE>& weight,
std::vector<VALUETYPE>& weight_x,
const std::vector<VALUETYPE>& coord) const;
virtual std::vector<VALUETYPE> get_center() const { return center; }

private:
vector<VALUETYPE> center;
std::vector<VALUETYPE> center;
VALUETYPE rnn;
VALUETYPE rhy;
VALUETYPE rc;
Expand Down
54 changes: 26 additions & 28 deletions source/md/include/Convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,36 @@
#include <string>
#include <vector>

using namespace std;

template <typename VALUETYPE>
class Convert {
public:
Convert(const vector<string>& atomname,
map<string, int>& name_type_map,
map<string, VALUETYPE>& name_mass_map,
map<string, VALUETYPE>& name_charge_map,
Convert(const std::vector<std::string>& atomname,
std::map<std::string, int>& name_type_map,
std::map<std::string, VALUETYPE>& name_mass_map,
std::map<std::string, VALUETYPE>& name_charge_map,
const bool sort = true);
void gro2nnp(vector<VALUETYPE>& coord,
vector<VALUETYPE>& veloc,
vector<VALUETYPE>& box,
const vector<vector<double> >& posi,
const vector<vector<double> >& velo,
const vector<double>& box_size) const;
void nnp2gro(vector<vector<double> >& posi,
vector<vector<double> >& velo,
vector<double>& box_size,
const vector<VALUETYPE>& coord,
const vector<VALUETYPE>& veloc,
const vector<VALUETYPE>& box) const;
void idx_gro2nnp(vector<int>& out, const vector<int>& in) const;
void idx_nnp2gro(vector<int>& out, const vector<int>& in) const;
const vector<int>& get_type() const { return atype; }
const vector<VALUETYPE>& get_mass() const { return amass; }
const vector<VALUETYPE>& get_charge() const { return acharge; }
void gro2nnp(std::vector<VALUETYPE>& coord,
std::vector<VALUETYPE>& veloc,
std::vector<VALUETYPE>& box,
const std::vector<std::vector<double> >& posi,
const std::vector<std::vector<double> >& velo,
const std::vector<double>& box_size) const;
void nnp2gro(std::vector<std::vector<double> >& posi,
std::vector<std::vector<double> >& velo,
std::vector<double>& box_size,
const std::vector<VALUETYPE>& coord,
const std::vector<VALUETYPE>& veloc,
const std::vector<VALUETYPE>& box) const;
void idx_gro2nnp(std::vector<int>& out, const std::vector<int>& in) const;
void idx_nnp2gro(std::vector<int>& out, const std::vector<int>& in) const;
const std::vector<int>& get_type() const { return atype; }
const std::vector<VALUETYPE>& get_mass() const { return amass; }
const std::vector<VALUETYPE>& get_charge() const { return acharge; }

private:
vector<int> idx_map_nnp2gro;
vector<int> idx_map_gro2nnp;
vector<int> atype;
vector<VALUETYPE> amass;
vector<VALUETYPE> acharge;
std::vector<int> idx_map_nnp2gro;
std::vector<int> idx_map_gro2nnp;
std::vector<int> atype;
std::vector<VALUETYPE> amass;
std::vector<VALUETYPE> acharge;
};
2 changes: 0 additions & 2 deletions source/md/include/Gaussian.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#include "RandomGenerator.h"

using namespace std;

class Gaussian {
public:
void set_seed(unsigned long seed);
Expand Down
12 changes: 5 additions & 7 deletions source/md/include/HarmonicAngle.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#include "SimulationRegion.h"

using namespace std;

#ifdef HIGH_PREC
typedef double VALUETYPE;
#else
Expand All @@ -18,12 +16,12 @@ class HarmonicAngle {

public:
void compute(VALUETYPE& ener,
vector<VALUETYPE>& force,
vector<VALUETYPE>& virial,
const vector<VALUETYPE>& coord,
const vector<int>& atype,
std::vector<VALUETYPE>& force,
std::vector<VALUETYPE>& virial,
const std::vector<VALUETYPE>& coord,
const std::vector<int>& atype,
const SimulationRegion<VALUETYPE>& region,
const vector<int>& alist);
const std::vector<int>& alist);

private:
VALUETYPE ka, tt;
Expand Down
12 changes: 5 additions & 7 deletions source/md/include/HarmonicBond.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#include "SimulationRegion.h"

using namespace std;

#ifdef HIGH_PREC
typedef double VALUETYPE;
#else
Expand All @@ -18,12 +16,12 @@ class HarmonicBond {

public:
void compute(VALUETYPE& ener,
vector<VALUETYPE>& force,
vector<VALUETYPE>& virial,
const vector<VALUETYPE>& coord,
const vector<int>& atype,
std::vector<VALUETYPE>& force,
std::vector<VALUETYPE>& virial,
const std::vector<VALUETYPE>& coord,
const std::vector<int>& atype,
const SimulationRegion<VALUETYPE>& region,
const vector<int>& blist);
const std::vector<int>& blist);

private:
VALUETYPE kk, bb;
Expand Down
21 changes: 10 additions & 11 deletions source/md/include/Integrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@

#include "Gaussian.h"
#include "UnitManager.h"
using namespace std;

template <typename VALUETYPE>
class Integrator {
public:
Integrator() : massConst(UnitManager::IntegratorMassConstant){};

public:
void stepVeloc(vector<VALUETYPE>& vv,
const vector<VALUETYPE>& ff,
const vector<VALUETYPE>& mass,
void stepVeloc(std::vector<VALUETYPE>& vv,
const std::vector<VALUETYPE>& ff,
const std::vector<VALUETYPE>& mass,
const double& dt,
const vector<int>& freez = vector<int>()) const;
void stepCoord(vector<VALUETYPE>& rr,
const vector<VALUETYPE>& vv,
const std::vector<int>& freez = std::vector<int>()) const;
void stepCoord(std::vector<VALUETYPE>& rr,
const std::vector<VALUETYPE>& vv,
const double& dt) const;

private:
Expand All @@ -34,14 +33,14 @@ class ThermostatLangevin {
void reinit(const VALUETYPE T = 300.,
const VALUETYPE tau = 1.,
const long long int seed = 0);
void stepOU(vector<VALUETYPE>& vv,
const vector<VALUETYPE>& mass,
void stepOU(std::vector<VALUETYPE>& vv,
const std::vector<VALUETYPE>& mass,
const double& dt,
const vector<int>& freez = vector<int>()) const;
const std::vector<int>& freez = std::vector<int>()) const;

private:
mutable Gaussian gaussian;
string scheme;
std::string scheme;
VALUETYPE temperature;
VALUETYPE gamma;
VALUETYPE sigma;
Expand Down
12 changes: 5 additions & 7 deletions source/md/include/LJInter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#include "SimulationRegion.h"

using namespace std;

#ifdef HIGH_PREC
typedef double VALUETYPE;
#else
Expand All @@ -18,12 +16,12 @@ class LJInter {

public:
void compute(VALUETYPE& ener,
vector<VALUETYPE>& force,
vector<VALUETYPE>& virial,
const vector<VALUETYPE>& coord,
const vector<int>& atype,
std::vector<VALUETYPE>& force,
std::vector<VALUETYPE>& virial,
const std::vector<VALUETYPE>& coord,
const std::vector<int>& atype,
const SimulationRegion<VALUETYPE>& region,
const vector<vector<int> >& nlist);
const std::vector<std::vector<int> >& nlist);

private:
VALUETYPE c6, c12, rc, rc2, one_over_6, one_over_12, one_over_rc6,
Expand Down
12 changes: 5 additions & 7 deletions source/md/include/LJTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#include "Tabulated.h"

using namespace std;

#ifdef HIGH_PREC
typedef double VALUETYPE;
#else
Expand All @@ -18,12 +16,12 @@ class LJTab {

public:
void compute(VALUETYPE& ener,
vector<VALUETYPE>& force,
vector<VALUETYPE>& virial,
const vector<VALUETYPE>& coord,
const vector<int>& atype,
std::vector<VALUETYPE>& force,
std::vector<VALUETYPE>& virial,
const std::vector<VALUETYPE>& coord,
const std::vector<int>& atype,
const SimulationRegion<VALUETYPE>& region,
const vector<vector<int> >& nlist) {
const std::vector<std::vector<int> >& nlist) {
lj_tab.compute(ener, force, virial, coord, atype, region, nlist);
};

Expand Down
10 changes: 4 additions & 6 deletions source/md/include/MaxShift.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#include "SimulationRegion.h"

using namespace std;

#ifdef HIGH_PREC
typedef double VALUETYPE;
#else
Expand All @@ -14,16 +12,16 @@ typedef float VALUETYPE;

class MaxShift {
public:
MaxShift(const vector<VALUETYPE>& dcoord, const VALUETYPE& shell);
MaxShift(const std::vector<VALUETYPE>& dcoord, const VALUETYPE& shell);

bool rebuild(const vector<VALUETYPE>& coord,
bool rebuild(const std::vector<VALUETYPE>& coord,
const SimulationRegion<VALUETYPE>& region);

private:
VALUETYPE
max_shift2(const vector<VALUETYPE>& coord,
max_shift2(const std::vector<VALUETYPE>& coord,
const SimulationRegion<VALUETYPE>& region);
vector<VALUETYPE> record;
std::vector<VALUETYPE> record;
VALUETYPE shell;
VALUETYPE max_allow2;
};
Loading

0 comments on commit dbfa586

Please sign in to comment.