From 35769609d95cc2fa70abb0f68f8c8087129de46e Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 18 Jan 2013 20:55:26 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@9301 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/region.h | 3 +-- src/region_intersect.cpp | 29 +++++++++++++++++++++++++++-- src/region_intersect.h | 2 ++ src/region_union.cpp | 32 +++++++++++++++++++++++++++++--- src/region_union.h | 2 ++ 5 files changed, 61 insertions(+), 7 deletions(-) diff --git a/src/region.h b/src/region.h index 8f79590258..0a1d888a98 100644 --- a/src/region.h +++ b/src/region.h @@ -28,6 +28,7 @@ class Region : protected Pointers { double extent_ylo,extent_yhi; double extent_zlo,extent_zhi; int bboxflag; // 1 if bounding box is computable + int varshape; // 1 if region shape changes over time // contact = particle near region surface @@ -56,8 +57,6 @@ class Region : protected Pointers { virtual void shape_update() {} protected: - int varshape; // 1 if region shape changes over time - void add_contact(int, double *, double, double, double); void options(int, char **); diff --git a/src/region_intersect.cpp b/src/region_intersect.cpp index 736ec3c6e1..bae73952d3 100644 --- a/src/region_intersect.cpp +++ b/src/region_intersect.cpp @@ -42,10 +42,14 @@ RegIntersect::RegIntersect(LAMMPS *lmp, int narg, char **arg) : list[nregion++] = iregion; } - // extent of intersection of regions - // has bounding box if interior and any sub-region has bounding box + // this region is variable shape if any of sub-regions are Region **regions = domain->regions; + for (int ilist = 0; ilist < nregion; ilist++) + if (regions[list[ilist]]->varshape) varshape = 1; + + // extent of intersection of regions + // has bounding box if interior and any sub-region has bounding box bboxflag = 0; for (int ilist = 0; ilist < nregion; ilist++) @@ -91,6 +95,16 @@ RegIntersect::~RegIntersect() delete [] contact; } +/* ---------------------------------------------------------------------- */ + +void RegIntersect::init() +{ + Region::init(); + Region **regions = domain->regions; + for (int ilist = 0; ilist < nregion; ilist++) + regions[list[ilist]]->init(); +} + /* ---------------------------------------------------------------------- return 1 if region is dynamic, 0 if static dynamic if any sub-region is dynamic, else static @@ -206,3 +220,14 @@ int RegIntersect::surface_exterior(double *x, double cutoff) return n; } + +/* ---------------------------------------------------------------------- + change region shape of all sub-regions +------------------------------------------------------------------------- */ + +void RegIntersect::shape_update() +{ + Region **regions = domain->regions; + for (int ilist = 0; ilist < nregion; ilist++) + regions[list[ilist]]->shape_update(); +} diff --git a/src/region_intersect.h b/src/region_intersect.h index a8bd460f34..62946a65c0 100644 --- a/src/region_intersect.h +++ b/src/region_intersect.h @@ -28,10 +28,12 @@ class RegIntersect : public Region { public: RegIntersect(class LAMMPS *, int, char **); ~RegIntersect(); + void init(); int dynamic_check(); int inside(double, double, double); int surface_interior(double *, double); int surface_exterior(double *, double); + void shape_update(); private: int nregion; diff --git a/src/region_union.cpp b/src/region_union.cpp index ca1e693f37..3741e8fdd1 100644 --- a/src/region_union.cpp +++ b/src/region_union.cpp @@ -38,14 +38,19 @@ RegUnion::RegUnion(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg) int iregion; for (int iarg = 0; iarg < n; iarg++) { iregion = domain->find_region(arg[iarg+3]); - if (iregion == -1) error->all(FLERR,"Region union region ID does not exist"); + if (iregion == -1) + error->all(FLERR,"Region union region ID does not exist"); list[nregion++] = iregion; } - // extent of union of regions - // has bounding box if interior and all sub-regions have bounding box + // this region is variable shape if any of sub-regions are Region **regions = domain->regions; + for (int ilist = 0; ilist < nregion; ilist++) + if (regions[list[ilist]]->varshape) varshape = 1; + + // extent of union of regions + // has bounding box if interior and all sub-regions have bounding box bboxflag = 1; for (int ilist = 0; ilist < nregion; ilist++) @@ -82,6 +87,16 @@ RegUnion::~RegUnion() delete [] contact; } +/* ---------------------------------------------------------------------- */ + +void RegUnion::init() +{ + Region::init(); + Region **regions = domain->regions; + for (int ilist = 0; ilist < nregion; ilist++) + regions[list[ilist]]->init(); +} + /* ---------------------------------------------------------------------- return 1 if region is dynamic, 0 if static dynamic if any sub-region is dynamic, else static @@ -197,3 +212,14 @@ int RegUnion::surface_exterior(double *x, double cutoff) return n; } + +/* ---------------------------------------------------------------------- + change region shape of all sub-regions +------------------------------------------------------------------------- */ + +void RegUnion::shape_update() +{ + Region **regions = domain->regions; + for (int ilist = 0; ilist < nregion; ilist++) + regions[list[ilist]]->shape_update(); +} diff --git a/src/region_union.h b/src/region_union.h index 44d99375c9..6d0ec063cf 100644 --- a/src/region_union.h +++ b/src/region_union.h @@ -28,10 +28,12 @@ class RegUnion : public Region { public: RegUnion(class LAMMPS *, int, char **); ~RegUnion(); + void init(); int dynamic_check(); int inside(double, double, double); int surface_interior(double *, double); int surface_exterior(double *, double); + void shape_update(); private: int nregion;