split kspace style constructor into plain constructor and settings() method
This commit is contained in:
@ -665,14 +665,14 @@ Improper *Force::improper_match(const char *style)
|
||||
new kspace style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Force::create_kspace(int narg, char **arg, int trysuffix)
|
||||
void Force::create_kspace(const char *style, int trysuffix)
|
||||
{
|
||||
delete [] kspace_style;
|
||||
if (kspace) delete kspace;
|
||||
|
||||
int sflag;
|
||||
kspace = new_kspace(narg,arg,trysuffix,sflag);
|
||||
store_style(kspace_style,arg[0],sflag);
|
||||
kspace = new_kspace(style,trysuffix,sflag);
|
||||
store_style(kspace_style,style,sflag);
|
||||
|
||||
if (comm->style == 1 && !kspace_match("ewald",0))
|
||||
error->all(FLERR,
|
||||
@ -683,39 +683,39 @@ void Force::create_kspace(int narg, char **arg, int trysuffix)
|
||||
generate a kspace class
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
KSpace *Force::new_kspace(int narg, char **arg, int trysuffix, int &sflag)
|
||||
KSpace *Force::new_kspace(const char *style, int trysuffix, int &sflag)
|
||||
{
|
||||
if (trysuffix && lmp->suffix_enable) {
|
||||
if (lmp->suffix) {
|
||||
sflag = 1;
|
||||
char estyle[256];
|
||||
sprintf(estyle,"%s/%s",arg[0],lmp->suffix);
|
||||
sprintf(estyle,"%s/%s",style,lmp->suffix);
|
||||
if (kspace_map->find(estyle) != kspace_map->end()) {
|
||||
KSpaceCreator kspace_creator = (*kspace_map)[estyle];
|
||||
return kspace_creator(lmp, narg-1, &arg[1]);
|
||||
return kspace_creator(lmp);
|
||||
}
|
||||
}
|
||||
|
||||
if (lmp->suffix2) {
|
||||
sflag = 1;
|
||||
char estyle[256];
|
||||
sprintf(estyle,"%s/%s",arg[0],lmp->suffix2);
|
||||
sprintf(estyle,"%s/%s",style,lmp->suffix2);
|
||||
if (kspace_map->find(estyle) != kspace_map->end()) {
|
||||
KSpaceCreator kspace_creator = (*kspace_map)[estyle];
|
||||
return kspace_creator(lmp, narg-1, &arg[1]);
|
||||
return kspace_creator(lmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sflag = 0;
|
||||
if (strcmp(arg[0],"none") == 0) return NULL;
|
||||
if (kspace_map->find(arg[0]) != kspace_map->end()) {
|
||||
KSpaceCreator kspace_creator = (*kspace_map)[arg[0]];
|
||||
return kspace_creator(lmp, narg-1, &arg[1]);
|
||||
if (strcmp(style,"none") == 0) return NULL;
|
||||
if (kspace_map->find(style) != kspace_map->end()) {
|
||||
KSpaceCreator kspace_creator = (*kspace_map)[style];
|
||||
return kspace_creator(lmp);
|
||||
}
|
||||
|
||||
char str[128];
|
||||
sprintf(str,"Unknown kspace style %s",arg[0]);
|
||||
sprintf(str,"Unknown kspace style %s",style);
|
||||
error->all(FLERR,str);
|
||||
|
||||
return NULL;
|
||||
@ -726,9 +726,9 @@ KSpace *Force::new_kspace(int narg, char **arg, int trysuffix, int &sflag)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
template <typename T>
|
||||
KSpace *Force::kspace_creator(LAMMPS *lmp, int narg, char ** arg)
|
||||
KSpace *Force::kspace_creator(LAMMPS *lmp)
|
||||
{
|
||||
return new T(lmp, narg, arg);
|
||||
return new T(lmp);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -72,7 +72,7 @@ class Force : protected Pointers {
|
||||
typedef Angle *(*AngleCreator)(LAMMPS *);
|
||||
typedef Dihedral *(*DihedralCreator)(LAMMPS *);
|
||||
typedef Improper *(*ImproperCreator)(LAMMPS *);
|
||||
typedef KSpace *(*KSpaceCreator)(LAMMPS *,int,char**);
|
||||
typedef KSpace *(*KSpaceCreator)(LAMMPS *);
|
||||
|
||||
typedef std::map<std::string,PairCreator> PairCreatorMap;
|
||||
typedef std::map<std::string,BondCreator> BondCreatorMap;
|
||||
@ -123,8 +123,8 @@ class Force : protected Pointers {
|
||||
class Improper *new_improper(const char *, int, int &);
|
||||
class Improper *improper_match(const char *);
|
||||
|
||||
void create_kspace(int, char **, int);
|
||||
class KSpace *new_kspace(int, char **, int, int &);
|
||||
void create_kspace(const char *, int);
|
||||
class KSpace *new_kspace(const char *, int, int &);
|
||||
class KSpace *kspace_match(const char *, int);
|
||||
|
||||
void store_style(char *&, const char *, int);
|
||||
@ -148,7 +148,7 @@ class Force : protected Pointers {
|
||||
template <typename T> static Angle *angle_creator(LAMMPS *);
|
||||
template <typename T> static Dihedral *dihedral_creator(LAMMPS *);
|
||||
template <typename T> static Improper *improper_creator(LAMMPS *);
|
||||
template <typename T> static KSpace *kspace_creator(LAMMPS *, int, char **);
|
||||
template <typename T> static KSpace *kspace_creator(LAMMPS *);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -1633,7 +1633,8 @@ void Input::kspace_modify()
|
||||
|
||||
void Input::kspace_style()
|
||||
{
|
||||
force->create_kspace(narg,arg,1);
|
||||
force->create_kspace(arg[0],1);
|
||||
if (force->kspace) force->kspace->settings(narg-1,&arg[1]);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -30,7 +30,7 @@ using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
KSpace::KSpace(LAMMPS *lmp, int /*narg*/, char **/*arg*/) : Pointers(lmp)
|
||||
KSpace::KSpace(LAMMPS *lmp) : Pointers(lmp)
|
||||
{
|
||||
order_allocated = 0;
|
||||
energy = 0.0;
|
||||
|
||||
@ -92,7 +92,7 @@ class KSpace : protected Pointers {
|
||||
|
||||
double splittol; // tolerance for when to truncate splitting
|
||||
|
||||
KSpace(class LAMMPS *, int, char **);
|
||||
KSpace(class LAMMPS *);
|
||||
virtual ~KSpace();
|
||||
void triclinic_check();
|
||||
void modify_params(int, char **);
|
||||
@ -112,6 +112,7 @@ class KSpace : protected Pointers {
|
||||
|
||||
// general child-class methods
|
||||
|
||||
virtual void settings(int, char **) {};
|
||||
virtual void init() = 0;
|
||||
virtual void setup() = 0;
|
||||
virtual void setup_grid() {};
|
||||
|
||||
Reference in New Issue
Block a user