revision: v0.14
Mercury3D.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #ifndef MERCURY3D_H
27 #define MERCURY3D_H
28 
29 #include "MercuryBase.h"
30 
31 class ClusterGenerator;
32 
36 class Mercury3D : public MercuryBase
37 {
38 public:
39 
43  Mercury3D();
44 
48  explicit Mercury3D(const DPMBase& other);
49 
53  Mercury3D(const Mercury3D& other);
54 
58  void constructor();
59 
63  std::vector<BaseParticle*> hGridFindParticleContacts(const BaseParticle* obj) override;
64 
65 protected:
69  void hGridFindContactsWithinTargetCell(int x, int y, int z, unsigned int l);
70 
74  void hGridFindContactsWithTargetCell(int x, int y, int z, unsigned int l, BaseParticle* obj);
75 
79  void computeWallForces(BaseWall* w) override;
80 
84  void hGridFindParticlesWithTargetCell(int x, int y, int z, unsigned int l, BaseParticle* obj,
85  std::vector<BaseParticle*>& list);
86 
90  void hGridGetInteractingParticleList(BaseParticle* obj, std::vector<BaseParticle*>& list) override;
91 
95  void computeInternalForces(BaseParticle* obj) override;
96 
100  bool hGridHasContactsInTargetCell(int x, int y, int z, unsigned int l, const BaseParticle* obj) const;
101 
105  bool hGridHasParticleContacts(const BaseParticle* obj) override;
106 
110  void hGridRemoveParticle(BaseParticle* obj) override;
111 
115  void hGridUpdateParticle(BaseParticle* obj) override;
116 
117 #ifdef CONTACT_LIST_HGRID
118 
121  void InsertCell(int x, int y, int z, unsigned int l, BaseParticle* obj);
122 
126  void InsertObjAgainstGrid(BaseParticle* obj);
127 #endif
128 };
129 
130 #endif
HGridCell::equals
bool equals(int x, int y, int z, unsigned int level) const
Checks if the given (x,y,z,level) is the same as the ones in this cell.
Definition: HGridCell.h:39
BaseParticle::setHGridY
void setHGridY(const int y)
Sets the particle's HGrid cell Y-coordinate.
Definition: BaseParticle.h:457
mathsFunc::square
T square(const T val)
squares a number
Definition: ExtendedMath.h:106
MercuryBase::getHGrid
HGrid * getHGrid()
Gets the HGrid used by this problem.
Definition: MercuryBase.h:311
BaseParticle::setHGridNextObject
void setHGridNextObject(BaseParticle *p)
Sets the pointer to the next object in the particle's HGrid cell & level.
Definition: BaseParticle.h:480
BaseParticle::setHGridX
void setHGridX(const int x)
Sets the particle's HGrid cell X-coordinate.
Definition: BaseParticle.h:449
BaseParticle::getHGridLevel
unsigned int getHGridLevel() const
Returns particle's HGrid level.
Definition: BaseParticle.h:234
BaseParticle::getPeriodicFromParticle
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Definition: BaseParticle.h:341
DPMBase::setParticleDimensions
void setParticleDimensions(unsigned int particleDimensions)
Sets the particle dimensionality.
Definition: DPMBase.cc:1439
BaseWall
Basic class for walls.
Definition: BaseWall.h:48
logger
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
Mercury3D::hGridUpdateParticle
void hGridUpdateParticle(BaseParticle *obj) override
Updates the cell (not the level) of a BaseParticle.
Definition: Mercury3D.cc:361
HGrid
In the HGrid class, here all information about the HGrid is stored.
Definition: HGrid.h:43
HGrid::getOccupiedLevelsMask
int getOccupiedLevelsMask() const
Gets the integer that represents which levels are occupied.
Definition: HGrid.h:213
Vec3D::X
Mdouble X
the vector components
Definition: Vector.h:65
Mercury3D::hGridHasParticleContacts
bool hGridHasParticleContacts(const BaseParticle *obj) override
Tests if a BaseParticle has any contacts in the HGrid.
Definition: Mercury3D.cc:485
Mercury3D::hGridFindContactsWithTargetCell
void hGridFindContactsWithTargetCell(int x, int y, int z, unsigned int l, BaseParticle *obj)
Finds contacts between the BaseParticle and the target cell.
Definition: Mercury3D.cc:118
Mercury3D::hGridRemoveParticle
void hGridRemoveParticle(BaseParticle *obj) override
Removes a BaseParticle from the HGrid.
Definition: Mercury3D.cc:422
Mercury3D::hGridFindContactsWithinTargetCell
void hGridFindContactsWithinTargetCell(int x, int y, int z, unsigned int l)
Finds contacts between particles in the target cell.
Definition: Mercury3D.cc:73
Mercury3D
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:37
Mercury3D::hGridGetInteractingParticleList
void hGridGetInteractingParticleList(BaseParticle *obj, std::vector< BaseParticle * > &list) override
Obtains all neighbour particles of a given object, obtained from the hgrid.
Definition: Mercury3D.cc:166
DPMBase::computeForcesDueToWalls
void computeForcesDueToWalls(BaseParticle *, BaseWall *)
Computes the forces on the particles due to the walls (normals are outward normals)
Definition: DPMBase.cc:3094
HGrid::getInvCellSize
double getInvCellSize(unsigned int i) const
Gets 1/cellSize for the cells on level i.
Definition: HGrid.h:178
INFO
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
Mercury3D::hGridHasContactsInTargetCell
bool hGridHasContactsInTargetCell(int x, int y, int z, unsigned int l, const BaseParticle *obj) const
Tests if the BaseParticle has contacts with other Particles in the target cell.
Definition: Mercury3D.cc:456
Mercury3D::constructor
void constructor()
Function that sets the SystemDimension and ParticleDimension to 3.
Definition: Mercury3D.cc:59
BaseParticle::getHGridY
int getHGridY() const
Returns particle's HGrid cell Y-coordinate.
Definition: BaseParticle.h:272
Mercury3D::Mercury3D
Mercury3D()
This is the default constructor. All it does is set sensible defaults.
Definition: Mercury3D.cc:29
Vec3D
Definition: Vector.h:50
MercuryBase::getHGridMethod
HGridMethod getHGridMethod() const
Gets whether the HGrid in this MercuryBase is BOTTOMUP or TOPDOWN.
Definition: MercuryBase.h:204
BaseParticle::getHGridNextObject
BaseParticle * getHGridNextObject() const
Returns pointer to next object in particle's HGrid level & cell.
Definition: BaseParticle.h:242
Mdouble
double Mdouble
Definition: GeneralDefine.h:34
HGrid::computeHashBucketIndex
unsigned int computeHashBucketIndex(int x, int y, int z, unsigned int l) const
Computes hash bucket index in range [0, NUM_BUCKETS-1] for a 3D domain.
Definition: HGrid.h:76
Mercury3D::hGridFindParticleContacts
std::vector< BaseParticle * > hGridFindParticleContacts(const BaseParticle *obj) override
Returns all particles that have a contact with a given particle.
Definition: Mercury3D.cc:544
BaseParticle::setHGridZ
void setHGridZ(const int z)
Sets the particle's HGrid cell Z-coordinate.
Definition: BaseParticle.h:465
Mercury3D::hGridFindParticlesWithTargetCell
void hGridFindParticlesWithTargetCell(int x, int y, int z, unsigned int l, BaseParticle *obj, std::vector< BaseParticle * > &list)
Finds particles within target cell and stores them in a list.
Definition: Mercury3D.cc:146
BaseParticle::getHGridPrevObject
BaseParticle * getHGridPrevObject() const
Returns pointer to previous object in particle's HGrid level & cell.
Definition: BaseParticle.h:250
double
VERBOSE
LL< Log::VERBOSE > VERBOSE
Verbose information.
Definition: Logger.cc:57
MercuryBase
This is the base class for both Mercury2D and Mercury3D. Note the actually abstract grid is defined i...
Definition: MercuryBase.h:126
MercuryBase::hGridRebuild
void hGridRebuild()
This sets up the parameters required for the contact model.
Definition: MercuryBase.cc:204
Log::FATAL
@ FATAL
HGrid::getCellSize
double getCellSize(unsigned int i) const
Gets the size of the cells at the given level.
Definition: HGrid.h:147
TOPDOWN
@ TOPDOWN
Definition: MercuryBase.h:45
BaseParticle::getHGridX
int getHGridX() const
Returns particle's HGrid cell X-coordinate.
Definition: BaseParticle.h:265
Mercury3D::computeWallForces
void computeWallForces(BaseWall *w) override
Compute contacts with a wall.
Definition: Mercury3D.cc:615
Vec3D::Y
Mdouble Y
Definition: Vector.h:65
HGrid::setBucketIsChecked
void setBucketIsChecked(unsigned int i)
Sets that the bucket with the given index is checked to true.
Definition: HGrid.h:124
HGrid::getBucketIsChecked
bool getBucketIsChecked(unsigned int i) const
Gets whether or not the bucket with index i is checked.
Definition: HGrid.h:132
HGrid::setFirstBaseParticleInBucket
void setFirstBaseParticleInBucket(unsigned int i, BaseParticle *p)
Sets the first particle in bucket i to be the given BaseParticle.
Definition: HGrid.h:117
HGrid::getNumberOfLevels
unsigned long getNumberOfLevels() const
Gets the number of levels of this HGrid.
Definition: HGrid.h:206
BaseParticle
Definition: BaseParticle.h:54
BaseParticle::getMaxInteractionRadius
Mdouble getMaxInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e....
Definition: BaseParticle.h:362
BaseParticle::getHGridCell
const HGridCell & getHGridCell() const
Definition: BaseParticle.h:648
DPMBase::computeWallForces
virtual void computeWallForces(BaseWall *w)
Definition: DPMBase.cc:5263
Vec3D::getDistanceSquared
static Mdouble getDistanceSquared(const Vec3D &a, const Vec3D &b)
Calculates the squared distance between two Vec3D: .
Definition: Vector.h:295
MercuryBase.h
BaseParticle::isFixed
bool isFixed() const override
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...
Definition: BaseParticle.h:93
Vec3D::Z
Mdouble Z
Definition: Vector.h:65
Mercury3D::computeInternalForces
void computeInternalForces(BaseParticle *obj) override
Finds contacts with the BaseParticle; avoids multiple checks.
Definition: Mercury3D.cc:224
BaseWall::isLocal
virtual bool isLocal(Vec3D &min, Vec3D &max) const
Definition: BaseWall.h:137
MercuryBase::hGridNeedsRebuilding
bool hGridNeedsRebuilding()
Gets if the HGrid needs rebuilding before anything else happens.
Definition: MercuryBase.cc:496
Mercury3D.h
ClusterGenerator
This class allows the user to create clusters of particles. All particles will be of LinearPlasticVis...
Definition: ClusterGenerator.h:39
BaseParticle.h
BaseParticle::getHGridZ
int getHGridZ() const
Returns particle's HGrid cell Z-coordinate.
Definition: BaseParticle.h:279
DPMBase::areInContact
static bool areInContact(const BaseParticle *pI, const BaseParticle *pJ)
Checks if two particle are in contact or is there any positive overlap.
Definition: DPMBase.cc:1652
BaseParticle::setHGridPrevObject
void setHGridPrevObject(BaseParticle *p)
Sets the pointer to the previous object in the particle's HGrid cell & level.
Definition: BaseParticle.h:488
HGrid::getFirstBaseParticleInBucket
const BaseParticle * getFirstBaseParticleInBucket(unsigned int i) const
Gets the first BaseParticle in the given bucket, const version.
Definition: HGrid.h:162
BaseInteractable::getPosition
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
DPMBase::computeInternalForce
virtual void computeInternalForce(BaseParticle *, BaseParticle *)
Computes the forces between two particles (internal in the sense that the sum over all these forces i...
Definition: DPMBase.cc:3019
DPMBase
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:76
DPMBase::setSystemDimensions
void setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1408