diff --git a/src/accelerator_kokkos.h b/src/accelerator_kokkos.h index ddaff2ce1c..0c9c121568 100644 --- a/src/accelerator_kokkos.h +++ b/src/accelerator_kokkos.h @@ -86,6 +86,7 @@ class ModifyKokkos : public Modify { class DAT { public: typedef double tdual_xfloat_1d; + typedef int t_int_1d; typedef int tdual_int_2d; }; diff --git a/src/domain.cpp b/src/domain.cpp index 5bf75bc8cb..f50117217d 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -1504,6 +1504,46 @@ void Domain::add_region(int narg, char **arg) if (strcmp(arg[1],"none") == 0) error->all(FLERR,"Unknown region style"); + if (lmp->suffix_enable) { + if (lmp->suffix) { + char estyle[256]; + sprintf(estyle,"%s/%s",arg[1],lmp->suffix); + + if (0) return; + +#define REGION_CLASS +#define RegionStyle(key,Class) \ + else if (strcmp(estyle,#key) == 0) { \ + regions[nregion] = new Class(lmp,narg,arg); \ + regions[nregion]->init(); \ + nregion++; \ + return; \ + } +#include "style_region.h" +#undef RegionStyle +#undef REGION_CLASS + } + + if (lmp->suffix2) { + char estyle[256]; + sprintf(estyle,"%s/%s",arg[1],lmp->suffix2); + + if (0) return; + +#define REGION_CLASS +#define RegionStyle(key,Class) \ + else if (strcmp(estyle,#key) == 0) { \ + regions[nregion] = new Class(lmp,narg,arg); \ + regions[nregion]->init(); \ + nregion++; \ + return; \ + } +#include "style_region.h" +#undef RegionStyle +#undef REGION_CLASS + } + } + #define REGION_CLASS #define RegionStyle(key,Class) \ else if (strcmp(arg[1],#key) == 0) \ diff --git a/src/fix_setforce.cpp b/src/fix_setforce.cpp index 0fe56e7548..aff8f117c5 100644 --- a/src/fix_setforce.cpp +++ b/src/fix_setforce.cpp @@ -107,6 +107,8 @@ FixSetForce::FixSetForce(LAMMPS *lmp, int narg, char **arg) : FixSetForce::~FixSetForce() { + if (copymode) return; + delete [] xstr; delete [] ystr; delete [] zstr; diff --git a/src/fix_setforce.h b/src/fix_setforce.h index e18a34ea4a..a445f342ed 100644 --- a/src/fix_setforce.h +++ b/src/fix_setforce.h @@ -27,18 +27,18 @@ namespace LAMMPS_NS { class FixSetForce : public Fix { public: FixSetForce(class LAMMPS *, int, char **); - ~FixSetForce(); + virtual ~FixSetForce(); int setmask(); - void init(); + virtual void init(); void setup(int); void min_setup(int); - void post_force(int); + virtual void post_force(int); void post_force_respa(int, int, int); void min_post_force(int); double compute_vector(int); double memory_usage(); - private: + protected: double xvalue,yvalue,zvalue; int varflag,iregion; char *xstr,*ystr,*zstr; diff --git a/src/region.cpp b/src/region.cpp index b8489401f2..ea0b6f1bc5 100644 --- a/src/region.cpp +++ b/src/region.cpp @@ -40,12 +40,16 @@ Region::Region(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) varshape = 0; xstr = ystr = zstr = tstr = NULL; dx = dy = dz = 0.0; + + copymode = 0; } /* ---------------------------------------------------------------------- */ Region::~Region() { + if (copymode) return; + delete [] id; delete [] style; @@ -128,6 +132,15 @@ int Region::match(double x, double y, double z) return !(inside(x,y,z) ^ interior); } +/* ---------------------------------------------------------------------- + generate error if Kokkos function defaults to base class +------------------------------------------------------------------------- */ + +void Region::match_all_kokkos(int, DAT::t_int_1d) +{ + error->all(FLERR,"Can only use Kokkos supported regions with Kokkos package"); +} + /* ---------------------------------------------------------------------- generate list of contact points for interior or exterior regions if region has variable shape, invoke shape_update() once per timestep diff --git a/src/region.h b/src/region.h index 3249cf5d8b..f688579ede 100644 --- a/src/region.h +++ b/src/region.h @@ -15,6 +15,7 @@ #define LMP_REGION_H #include "pointers.h" +#include "accelerator_kokkos.h" namespace LAMMPS_NS { @@ -31,6 +32,8 @@ class Region : protected Pointers { int varshape; // 1 if region shape changes over time int dynamic; // 1 if position/orient changes over time + int copymode; // 1 if copy of original class + // contact = particle near region surface struct Contact { @@ -59,11 +62,14 @@ class Region : protected Pointers { virtual void shape_update() {} virtual void pretransform(); + // Kokkos function, implemented by each Kokkos region + + virtual void match_all_kokkos(int, DAT::t_int_1d); + protected: void add_contact(int, double *, double, double, double); void options(int, char **); - private: int moveflag,rotateflag; // 1 if position/orientation changes double point[3],axis[3],runit[3]; diff --git a/src/region_block.cpp b/src/region_block.cpp index c06eeda544..f866903f3d 100644 --- a/src/region_block.cpp +++ b/src/region_block.cpp @@ -103,6 +103,8 @@ RegBlock::RegBlock(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg) RegBlock::~RegBlock() { + if (copymode) return; + delete [] contact; } diff --git a/src/region_block.h b/src/region_block.h index 472c4460f3..fb9dcb3f5e 100644 --- a/src/region_block.h +++ b/src/region_block.h @@ -34,7 +34,7 @@ class RegBlock : public Region { int surface_interior(double *, double); int surface_exterior(double *, double); - private: + protected: double xlo,xhi,ylo,yhi,zlo,zhi; };