forked from lijiext/lammps
apply new utility function to most places creating new styles
This commit is contained in:
parent
9166001041
commit
d640c712f8
|
@ -39,6 +39,7 @@
|
|||
#include "math_const.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef LMP_USER_INTEL
|
||||
#include "neigh_request.h"
|
||||
|
@ -509,7 +510,7 @@ AtomVec *Atom::new_avec(const char *style, int trysuffix, int &sflag)
|
|||
return avec_creator(lmp);
|
||||
}
|
||||
|
||||
error->all(FLERR,"Unknown atom style");
|
||||
error->all(FLERR,utils::check_packages_for_style("atom",style,lmp).c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "fix.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
|
@ -96,7 +97,7 @@ void AtomVecBody::process_args(int narg, char **arg)
|
|||
#undef BodyStyle
|
||||
#undef BODY_CLASS
|
||||
|
||||
else error->all(FLERR,"Unknown body style");
|
||||
else error->all(FLERR,utils::check_packages_for_style("body",arg[0],lmp).c_str());
|
||||
|
||||
bptr->avec = this;
|
||||
icp = bptr->icp;
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "math_const.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
@ -1714,6 +1715,9 @@ void Domain::add_region(int narg, char **arg)
|
|||
return;
|
||||
}
|
||||
|
||||
if (strcmp(arg[1],"none") == 0)
|
||||
error->all(FLERR,"Unrecognized region style 'none'");
|
||||
|
||||
if (find_region(arg[0]) >= 0) error->all(FLERR,"Reuse of region ID");
|
||||
|
||||
// extend Region list if necessary
|
||||
|
@ -1752,12 +1756,10 @@ void Domain::add_region(int narg, char **arg)
|
|||
}
|
||||
}
|
||||
|
||||
if (strcmp(arg[1],"none") == 0) error->all(FLERR,"Unknown region style");
|
||||
if (region_map->find(arg[1]) != region_map->end()) {
|
||||
RegionCreator region_creator = (*region_map)[arg[1]];
|
||||
regions[nregion] = region_creator(lmp, narg, arg);
|
||||
}
|
||||
else error->all(FLERR,"Unknown region style");
|
||||
} else error->all(FLERR,utils::check_packages_for_style("region",arg[1],lmp).c_str());
|
||||
|
||||
// initialize any region variables via init()
|
||||
// in case region is used between runs, e.g. to print a variable
|
||||
|
|
|
@ -258,9 +258,7 @@ Pair *Force::new_pair(const char *style, int trysuffix, int &sflag)
|
|||
return pair_creator(lmp);
|
||||
}
|
||||
|
||||
char str[128];
|
||||
sprintf(str,"Unknown pair style %s",style);
|
||||
error->all(FLERR,str);
|
||||
error->all(FLERR,utils::check_packages_for_style("pair",style,lmp).c_str());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -373,9 +371,7 @@ Bond *Force::new_bond(const char *style, int trysuffix, int &sflag)
|
|||
return bond_creator(lmp);
|
||||
}
|
||||
|
||||
char str[128];
|
||||
sprintf(str,"Unknown bond style %s",style);
|
||||
error->all(FLERR,str);
|
||||
error->all(FLERR,utils::check_packages_for_style("bond",style,lmp).c_str());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -454,9 +450,7 @@ Angle *Force::new_angle(const char *style, int trysuffix, int &sflag)
|
|||
return angle_creator(lmp);
|
||||
}
|
||||
|
||||
char str[128];
|
||||
sprintf(str,"Unknown angle style %s",style);
|
||||
error->all(FLERR,str);
|
||||
error->all(FLERR,utils::check_packages_for_style("angle",style,lmp).c_str());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -536,9 +530,7 @@ Dihedral *Force::new_dihedral(const char *style, int trysuffix, int &sflag)
|
|||
return dihedral_creator(lmp);
|
||||
}
|
||||
|
||||
char str[128];
|
||||
sprintf(str,"Unknown dihedral style %s",style);
|
||||
error->all(FLERR,str);
|
||||
error->all(FLERR,utils::check_packages_for_style("dihedral",style,lmp).c_str());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -617,9 +609,7 @@ Improper *Force::new_improper(const char *style, int trysuffix, int &sflag)
|
|||
return improper_creator(lmp);
|
||||
}
|
||||
|
||||
char str[128];
|
||||
sprintf(str,"Unknown improper style %s",style);
|
||||
error->all(FLERR,str);
|
||||
error->all(FLERR,utils::check_packages_for_style("improper",style,lmp).c_str());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -702,9 +692,7 @@ KSpace *Force::new_kspace(const char *style, int trysuffix, int &sflag)
|
|||
return kspace_creator(lmp);
|
||||
}
|
||||
|
||||
char str[128];
|
||||
sprintf(str,"Unknown kspace style %s",style);
|
||||
error->all(FLERR,str);
|
||||
error->all(FLERR,utils::check_packages_for_style("kspace",style,lmp).c_str());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -893,11 +893,8 @@ void Modify::add_fix(int narg, char **arg, int trysuffix)
|
|||
fix[ifix] = fix_creator(lmp,narg,arg);
|
||||
}
|
||||
|
||||
if (fix[ifix] == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Unknown fix style %s",arg[2]);
|
||||
error->all(FLERR,str);
|
||||
}
|
||||
if (fix[ifix] == NULL)
|
||||
error->all(FLERR,utils::check_packages_for_style("fix",arg[2],lmp).c_str());
|
||||
|
||||
// check if Fix is in restart_global list
|
||||
// if yes, pass state info to the Fix so it can reset itself
|
||||
|
@ -1195,11 +1192,8 @@ void Modify::add_compute(int narg, char **arg, int trysuffix)
|
|||
compute[ncompute] = compute_creator(lmp,narg,arg);
|
||||
}
|
||||
|
||||
if (compute[ncompute] == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Unknown compute style %s",arg[2]);
|
||||
error->all(FLERR,str);
|
||||
}
|
||||
if (compute[ncompute] == NULL)
|
||||
error->all(FLERR,utils::check_packages_for_style("compute",arg[2],lmp).c_str());
|
||||
|
||||
ncompute++;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "write_restart.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
|
@ -585,8 +586,7 @@ void Output::add_dump(int narg, char **arg)
|
|||
if (dump_map->find(arg[2]) != dump_map->end()) {
|
||||
DumpCreator dump_creator = (*dump_map)[arg[2]];
|
||||
dump[ndump] = dump_creator(lmp, narg, arg);
|
||||
}
|
||||
else error->all(FLERR,"Unknown dump style");
|
||||
} else error->all(FLERR,utils::check_packages_for_style("dump",arg[2],lmp).c_str());
|
||||
|
||||
every_dump[ndump] = force->inumeric(FLERR,arg[3]);
|
||||
if (every_dump[ndump] <= 0) error->all(FLERR,"Illegal dump command");
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "variable.h"
|
||||
#include "error.h"
|
||||
#include "memory.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
|
@ -266,7 +267,7 @@ void ReadDump::setup_reader(int narg, char **arg)
|
|||
|
||||
// unrecognized style
|
||||
|
||||
else error->all(FLERR,"Unknown dump reader style");
|
||||
else error->all(FLERR,utils::check_packages_for_style("reader",readerstyle,lmp).c_str());
|
||||
|
||||
// pass any arguments to readers
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ void utils::sfgets(const char *srcname, int srcline, char *s, int size,
|
|||
std::string utils::check_packages_for_style(std::string style,
|
||||
std::string name, LAMMPS *lmp)
|
||||
{
|
||||
std::string errmsg = "Unrecognized " + style + " style " + name;
|
||||
std::string errmsg = "Unrecognized " + style + " style '" + name + "'";
|
||||
const char *pkg = lmp->match_style(style.c_str(),name.c_str());
|
||||
|
||||
if (pkg) {
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "input.h"
|
||||
#include "update.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
|
@ -64,7 +65,7 @@ void WriteDump::command(int narg, char **arg)
|
|||
#include "style_dump.h"
|
||||
#undef DUMP_CLASS
|
||||
|
||||
else error->all(FLERR,"Unknown dump style");
|
||||
else error->all(FLERR,utils::check_packages_for_style("dump",arg[1],lmp).c_str());
|
||||
|
||||
if (modindex < narg) dump->modify_params(narg-modindex-1,&arg[modindex+1]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue