1 /* ---------------------------------------------------------------------- 2 This is the 3 4 ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗████████╗███████╗ 5 ██║ ██║██╔════╝ ██╔════╝ ██╔════╝ ██║ ██║╚══██╔══╝██╔════╝ 6 ██║ ██║██║ ███╗██║ ███╗██║ ███╗███████║ ██║ ███████╗ 7 ██║ ██║██║ ██║██║ ██║██║ ██║██╔══██║ ██║ ╚════██║ 8 ███████╗██║╚██████╔╝╚██████╔╝╚██████╔╝██║ ██║ ██║ ███████║ 9 ╚══════╝╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝® 10 11 DEM simulation engine, released by 12 DCS Computing Gmbh, Linz, Austria 13 http://www.dcs-computing.com, office@dcs-computing.com 14 15 LIGGGHTS® is part of CFDEM®project: 16 http://www.liggghts.com | http://www.cfdem.com 17 18 Core developer and main author: 19 Christoph Kloss, christoph.kloss@dcs-computing.com 20 21 LIGGGHTS® is open-source, distributed under the terms of the GNU Public 22 License, version 2 or later. It is distributed in the hope that it will 23 be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 24 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have 25 received a copy of the GNU General Public License along with LIGGGHTS®. 26 If not, see http://www.gnu.org/licenses . See also top-level README 27 and LICENSE files. 28 29 LIGGGHTS® and CFDEM® are registered trade marks of DCS Computing GmbH, 30 the producer of the LIGGGHTS® software and the CFDEM®coupling software 31 See http://www.cfdem.com/terms-trademark-policy for details. 32 33 ------------------------------------------------------------------------- 34 Contributing author and copyright for this file: 35 36 Christoph Kloss (DCS Computing GmbH, Linz) 37 Christoph Kloss (JKU Linz) 38 Philippe Seil (JKU Linz) 39 Richard Berger (JKU Linz) 40 41 Copyright 2012- DCS Computing GmbH, Linz 42 Copyright 2009-2015 JKU Linz 43 ------------------------------------------------------------------------- */ 44 45 #ifndef LMP_BOUNDING_BOX 46 #define LMP_BOUNDING_BOX 47 48 #include "mpi_liggghts.h" 49 50 namespace LAMMPS_NS 51 { 52 53 class BoundingBox 54 { 55 friend class FixNeighlistMesh; 56 57 public: 58 59 BoundingBox(); 60 BoundingBox(double xLo, double xHi, double yLo, double yHi, double zLo, double zHi); 61 virtual ~BoundingBox(); 62 63 void reset(); 64 extendToContain(double const * pt)65 void extendToContain(double const *pt) 66 { 67 if(initGiven){ 68 if(pt[0] < xLo) xLo = pt[0]; 69 else if(pt[0] > xHi) xHi = pt[0]; 70 71 if(pt[1] < yLo) yLo = pt[1]; 72 else if(pt[1] > yHi) yHi = pt[1]; 73 74 if(pt[2] < zLo) zLo = pt[2]; 75 else if(pt[2] > zHi) zHi = pt[2]; 76 } else{ 77 xLo = pt[0]; xHi = pt[0]; 78 yLo = pt[1]; yHi = pt[1]; 79 zLo = pt[2]; zHi = pt[2]; 80 initGiven = true; 81 } 82 } 83 extendToParallel(MPI_Comm comm)84 void extendToParallel(MPI_Comm comm) 85 { 86 double limit[6]; 87 limit[0] = -xLo; 88 limit[1] = xHi; 89 limit[2] = -yLo; 90 limit[3] = yHi; 91 limit[4] = -zLo; 92 limit[5] = zHi; 93 94 MPI_Max_Vector(limit,6,comm); 95 96 xLo = -limit[0]; 97 xHi = limit[1]; 98 yLo = -limit[2]; 99 yHi = limit[3]; 100 zLo = -limit[4]; 101 zHi = limit[5]; 102 } 103 104 void extrude(double length, const double * vec); 105 getBoxBounds(double * lo,double * hi)106 void getBoxBounds(double *lo,double *hi) 107 { 108 lo[0] = xLo; 109 lo[1] = yLo; 110 lo[2] = zLo; 111 hi[0] = xHi; 112 hi[1] = yHi; 113 hi[2] = zHi; 114 } 115 getVolume()116 double getVolume() 117 { return (zHi-zLo)*(yHi-yLo)*(xHi-xLo); } 118 getExtent(double extent[3])119 void getExtent(double extent[3]) const { 120 extent[0] = xHi - xLo; 121 extent[1] = yHi - yLo; 122 extent[2] = zHi - zLo; 123 } 124 125 void extendByDelta(double delta); 126 getBoxBoundsExtendedByDelta(double * lo,double * hi,double delta)127 void getBoxBoundsExtendedByDelta(double *lo,double *hi,double delta) 128 { 129 lo[0] = xLo-delta; 130 lo[1] = yLo-delta; 131 lo[2] = zLo-delta; 132 hi[0] = xHi+delta; 133 hi[1] = yHi+delta; 134 hi[2] = zHi+delta; 135 } 136 shrinkToSubbox(double * sublo,double * subhi)137 void shrinkToSubbox(double *sublo,double *subhi) 138 { 139 if(xLo < sublo[0]) 140 xLo = sublo[0]; 141 if(xHi > subhi[0]) 142 xHi = subhi[0]; 143 144 if(yLo < sublo[1]) 145 yLo = sublo[1]; 146 if(yHi > subhi[1]) 147 yHi = subhi[1]; 148 149 if(zLo < sublo[2]) 150 zLo = sublo[2]; 151 if(zHi > subhi[2]) 152 zHi = subhi[2]; 153 } 154 isInitialized()155 bool isInitialized() 156 { return initGiven; } 157 isInside(double * p)158 bool isInside(double *p) 159 { 160 // check bbox 161 // test for >= and < as in Domain class 162 return (p[0] >= xLo && p[0] < xHi && 163 p[1] >= yLo && p[1] < yHi && 164 p[2] >= zLo && p[2] < zHi); 165 } 166 isDirty()167 bool isDirty() const { 168 return dirty; 169 } 170 setDirty(bool value)171 void setDirty(bool value) { 172 dirty = value; 173 } 174 175 private: 176 177 double xLo, xHi, yLo, yHi, zLo, zHi; 178 179 bool initGiven; 180 bool dirty; 181 }; 182 183 } /* LAMMPS_NS */ 184 #endif /* BOUNDINGBOX_H_ */ 185