MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseParticle.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, 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 BASEPARTICLE_H
27 #define BASEPARTICLE_H
28 
29 #include <vector>
30 #include <iostream>
31 #include "Math/ExtendedMath.h"
32 #include "Math/Vector.h"
33 #include "BaseInteractable.h"
34 //#include "InteractionHandler.h"
35 
36 class ParticleHandler;
37 class SpeciesHandler;
38 class HGrid;
39 class BaseInteraction;
40 
41 
42 #ifdef CONTACT_LIST_HGRID
43 class PossibleContact;
44 #endif
45 
51 {
52 public:
56  BaseParticle();
57 
61  BaseParticle(const BaseParticle &p);
62 
66  virtual ~BaseParticle();
67 
71  virtual BaseParticle* copy() const;
72 
76  Mdouble getVolume() const;
77 
81  void fixParticle();
82 
86  bool isFixed() const;
87 
91  void unfix();
92 
96  virtual void read(std::istream& is);
97 
104  virtual void oldRead(std::istream& is);
105 
109  virtual void write(std::ostream& os) const;
110 
114  virtual std::string getName() const;
115 
119  void printHGrid(std::ostream& os) const;
120 
124  unsigned int getHGridLevel() const;
125 
130 
135 
136 #ifdef CONTACT_LIST_HGRID
137 
141  PossibleContact* getFirstPossibleContact() const;
142 #endif
143 
147  int getHGridX() const;
148 
152  int getHGridY() const;
153 
157  int getHGridZ() const;
158 
162  Mdouble getInertia() const;
163 
167  Mdouble getInvInertia() const;
168 
172  Mdouble getInvMass() const;
173 
177  Mdouble getKineticEnergy() const;
178 
182  Mdouble getMass() const;
183 
188 
192  Mdouble getRadius() const;
193 
199 
205 
209  const Vec3D& getDisplacement() const;
210 
214  const Vec3D& getPreviousPosition() const;
215 
221  const Vec3D getDisplacement2(Mdouble xmin, Mdouble xmax, Mdouble ymin, Mdouble ymax, Mdouble zmin, Mdouble zmax, Mdouble t) const;
222 
226  void setInertia(const Mdouble newInertia);
227 
232  void setInfiniteInertia();
233 
239 
243  void setHGridX(const int x);
244 
248  void setHGridY(const int y);
249 
253  void setHGridZ(const int z);
254 
258  void setHGridLevel(const unsigned int level);
259 
265 
271 
272 #ifdef CONTACT_LIST_HGRID
273 
276  void setFirstPossibleContact(PossibleContact* PC);
277 #endif
278 
283  void setRadius(const Mdouble radius);
284 
291  //MERCURY_DEPRECATED
292  void setMass(const Mdouble mass);
293 
294 
299  void setDisplacement(const Vec3D& disp);
300 
304  void setPreviousPosition(const Vec3D& pos);
305 
309  void movePrevious(const Vec3D& posMove);
310 
314  void accelerate(const Vec3D& vel);
315 
319  void angularAccelerate(const Vec3D& angVel);
320 
324  void addDisplacement(const Vec3D& addDisp);
325 
329  void setHandler(ParticleHandler* handler);
330 
334  ParticleHandler* getHandler() const;
335 
340  BaseInteraction* getInteractionWith(BaseParticle *P, Mdouble timeStamp, InteractionHandler* interactionHandler);
341 
347  void integrateBeforeForceComputation(double time, double timeStep);
348 
353  void integrateAfterForceComputation(double time, double timeStep);
354 
358  unsigned int getParticleDimensions() const;
359 
364  void setIndSpecies(unsigned int indSpecies);
365 
370  void setSpecies(const ParticleSpecies* species);
372 
373 private:
374 
379 
380 #ifdef CONTACT_LIST_HGRID
381 
384  PossibleContact* firstPossibleContact;
385 #endif
386 
389  unsigned int HGridLevel_;
392 
400 
403 
410  friend class ParticleSpecies;
411 };
412 #endif
Mdouble getKineticEnergy() const
Calculates the particle's kinetic energy.
Container to store all ParticleSpecies.
void addDisplacement(const Vec3D &addDisp)
Adds a vector to the particle's displacement_.
Mdouble invInertia_
Particle inertia_.
Definition: BaseParticle.h:397
Mdouble getVolume() const
Get Particle volume function, which required a reference to the Species vector. It returns the volume...
void setInfiniteInertia()
Sets the particle's inertia_ to 'infinite' (1e20) and its invInertia_ to 0.
void setHGridLevel(const unsigned int level)
Sets the particle's HGrid level.
void setInertia(const Mdouble newInertia)
Sets the particle's inertia_ (and adjusts invInertia_ accordingly)
void setDisplacement(const Vec3D &disp)
Sets the particle's displacement (= difference between current position and that of the previous time...
const Vec3D & getPreviousPosition() const
Returns the particle's position in the previous time step.
void setMass(const Mdouble mass)
Sets the particle's mass.
void setHandler(ParticleHandler *handler)
Sets the pointer to the particle's ParticleHandler.
double Mdouble
void setHGridY(const int y)
Sets the particle's HGrid cell Y-coordinate.
Mdouble mass_
Pointer to the previous Particle in the same HGrid cell.
Definition: BaseParticle.h:394
ParticleHandler * handler_
Pointer to the particle's ParticleHandler container.
Definition: BaseParticle.h:378
Mdouble invMass_
Particle mass_.
Definition: BaseParticle.h:395
void setHGridNextObject(BaseParticle *p)
Sets the pointer to the next object in the particle's HGrid cell & level.
void setPeriodicFromParticle(BaseParticle *p)
Assigns the pointer to the 'original' particle this one's a periodic copy of.
void unfix()
Unfix Particle function, which required a reference to the Species vector. It unfixes a Particle by c...
void setSpecies(const ParticleSpecies *species)
int getHGridY() const
Returns particle's HGrid cell Y-coordinate.
void setHGridX(const int x)
Sets the particle's HGrid cell X-coordinate.
ParticleHandler * getHandler() const
Returns pointer to the particle's ParticleHandler.
Mdouble getInvMass() const
Returns the particle's invMass_.
void accelerate(const Vec3D &vel)
Increases the particle's velocity_ by the given vector.
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
Stores information about interactions between two interactable objects; often particles but could be ...
#define MERCURY_DEPRECATED
Definition: GeneralDefine.h:35
Mdouble getWallInteractionRadius() const
Returns the interaction radius for interaction with walls. See also BaseParticle::getInteractionRadiu...
int HGridX_
Hgrid attributes.
Definition: BaseParticle.h:388
virtual std::string getName() const
Returns the name of the object.
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
BaseParticle * HGridNextObject_
Grid level for the object.
Definition: BaseParticle.h:390
void printHGrid(std::ostream &os) const
Adds particle's HGrid level and cell coordinates to an ostream.
const Vec3D & getDisplacement() const
Returns the particle's displacement relative to the previous time step.
void integrateBeforeForceComputation(double time, double timeStep)
First step of Velocity Verlet integration.
Mdouble inertia_
Inverse Particle mass (for computation optimization)
Definition: BaseParticle.h:396
Vec3D displacement_
Pointer to originating Particle.
Definition: BaseParticle.h:401
virtual void read(std::istream &is)
Particle read function, which accepts an std::istream as input.
Mdouble getMass() const
Returns the particle's mass_.
virtual ~BaseParticle()
Particle destructor, needs to be implemented and checked if it removes tangential spring information...
Definition: BaseParticle.cc:98
void setPreviousPosition(const Vec3D &pos)
Sets the particle's position in the previous time step.
In the HGrid class, here all information about the HGrid is stored.
Definition: HGrid.h:41
unsigned int HGridLevel_
Cell position in the grid.
Definition: BaseParticle.h:389
int getHGridZ() const
Returns particle's HGrid cell Z-coordinate.
Container to store Interaction objects.
void setHGridZ(const int z)
Sets the particle's HGrid cell Z-coordinate.
Vec3D previousPosition_
Displacement (only used in StatisticsVector, StatisticsPoint)
Definition: BaseParticle.h:402
BaseParticle * HGridPrevObject_
Pointer to the next Particle in the same HGrid cell.
Definition: BaseParticle.h:391
Mdouble getInertia() const
Returns the particle's inertia_.
MERCURY_DEPRECATED void setIndSpecies(unsigned int indSpecies)
Mdouble getRadius() const
Returns the particle's radius_.
const Vec3D getDisplacement2(Mdouble xmin, Mdouble xmax, Mdouble ymin, Mdouble ymax, Mdouble zmin, Mdouble zmax, Mdouble t) const
BaseInteraction * getInteractionWith(BaseParticle *P, Mdouble timeStamp, InteractionHandler *interactionHandler)
Checks if particle is in interaction with given particle P, and if so, returns pointer to the associa...
Container to store all BaseParticle.
virtual void write(std::ostream &os) const
Particle print function, which accepts an std::ostream as input.
Mdouble getInvInertia() const
Returns the particle's invInertia_.
BaseParticle()
Basic Particle constructor, creates an Particle at (0,0,0) with radius, mass and inertia equal to 1...
Definition: BaseParticle.cc:38
virtual MERCURY_DEPRECATED void oldRead(std::istream &is)
deprecated version of the read function.
Mdouble radius_
Inverse Particle inverse inertia (for computation optimization)
Definition: BaseParticle.h:398
void setHGridPrevObject(BaseParticle *p)
Sets the pointer to the previous object in the particle's HGrid cell & level.
Defines the basic properties that a interactable object can have.
void angularAccelerate(const Vec3D &angVel)
Increases the particle's angularVelocity_ by the given vector.
BaseParticle * getHGridPrevObject() const
Returns pointer to previous object in particle's HGrid level & cell.
Class that describes a possible contact between two BaseParticle.
void integrateAfterForceComputation(double time, double timeStep)
Second step of Velocity Verlet integration.
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
BaseParticle * getHGridNextObject() const
Returns pointer to next object in particle's HGrid level & cell.
BaseParticle * periodicFromParticle_
Particle radius_.
Definition: BaseParticle.h:399
unsigned int getHGridLevel() const
Returns particle's HGrid level.
unsigned int getParticleDimensions() const
Returns the particle's dimensions (either 2 or 3).
bool isFixed() const
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...
Mdouble getInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
virtual BaseParticle * copy() const
Particle copy method. It calls to copy constructor of this Particle, useful for polymorfism.
void movePrevious(const Vec3D &posMove)
Adds a vector to the particle's previousPosition_.
void fixParticle()
Fix Particle function. It fixes a Particle by setting its inverse mass and inertia and velocities to ...
int getHGridX() const
Returns particle's HGrid cell X-coordinate.