MercuryDPM  Alpha
 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 #ifdef CONTACT_LIST_HGRID
42 class PossibleContact;
43 #endif
44 
50 {
51 public:
55  BaseParticle();
56 
60  BaseParticle(const BaseParticle &p);
61 
65  virtual ~BaseParticle();
66 
70  virtual BaseParticle* copy() const;
71 
75  Mdouble getVolume() const;
76 
80  void fixParticle();
81 
85  bool isFixed() const;
86 
90  void unfix();
91 
95  virtual void read(std::istream& is);
96 
103  virtual void oldRead(std::istream& is);
104 
108  virtual void write(std::ostream& os) const;
109 
113  virtual std::string getName() const;
114 
118  void printHGrid(std::ostream& os) const;
119 
123  unsigned int getHGridLevel() const;
124 
129 
134 
135 #ifdef CONTACT_LIST_HGRID
136 
140  PossibleContact* getFirstPossibleContact() const;
141 #endif
142 
146  int getHGridX() const;
147 
151  int getHGridY() const;
152 
156  int getHGridZ() const;
157 
161  Mdouble getInertia() const;
162 
166  Mdouble getInvInertia() const;
167 
171  Mdouble getInvMass() const;
172 
176  Mdouble getKineticEnergy() const;
177 
181  Mdouble getMass() const;
182 
187 
191  Mdouble getRadius() const;
192 
198 
204 
208  const Vec3D& getDisplacement() const;
209 
213  const Vec3D& getPreviousPosition() const;
214 
220  const Vec3D getDisplacement2(Mdouble xmin, Mdouble xmax, Mdouble ymin, Mdouble ymax, Mdouble zmin, Mdouble zmax, Mdouble t) const;
221 
225  void setInertia(const Mdouble newInertia);
226 
231  void setInfiniteInertia();
232 
238 
242  void setHGridX(const int x);
243 
247  void setHGridY(const int y);
248 
252  void setHGridZ(const int z);
253 
257  void setHGridLevel(const unsigned int level);
258 
264 
270 
271 #ifdef CONTACT_LIST_HGRID
272 
275  void setFirstPossibleContact(PossibleContact* PC);
276 #endif
277 
282  void setRadius(const Mdouble radius);
283 
290  void setMass(const Mdouble mass);
291 
297  void setMassForP3Statistics(const Mdouble mass);
298 
303  void setDisplacement(const Vec3D& disp);
304 
308  void setPreviousPosition(const Vec3D& pos);
309 
313  void movePrevious(const Vec3D& posMove);
314 
318  void accelerate(const Vec3D& vel);
319 
323  void angularAccelerate(const Vec3D& angVel);
324 
328  void addDisplacement(const Vec3D& addDisp);
329 
333  void setHandler(ParticleHandler* handler);
334 
338  ParticleHandler* getHandler() const;
339 
344  std::vector<BaseInteraction*> getInteractionWith(BaseParticle *P, Mdouble timeStamp, InteractionHandler* interactionHandler);
345 
351  void integrateBeforeForceComputation(double time, double timeStep);
352 
357  void integrateAfterForceComputation(double time, double timeStep);
358 
362  unsigned int getParticleDimensions() const;
363 
368  void setIndSpecies(unsigned int indSpecies);
369 
374  void setSpecies(const ParticleSpecies* species);
376 
377  virtual unsigned getNumberOfFieldsVTK() const;
378 
379  virtual std::string getTypeVTK(unsigned i) const;
380 
381  virtual std::string getNameVTK(unsigned i) const;
382 
383  virtual std::vector<Mdouble> getFieldVTK(unsigned i) const;
384 
385 private:
386 
391 
392 #ifdef CONTACT_LIST_HGRID
393 
396  PossibleContact* firstPossibleContact;
397 #endif
398 
401  unsigned int HGridLevel_;
404 
412 
415 
421  friend class ParticleSpecies;
422 // //friend class HGrid;
423 // template<class T>
424 // friend class StatisticsVector;
425 };
426 #endif
Mdouble getKineticEnergy() const
Calculates the particle's kinetic energy.
Container to store all ParticleSpecies.
void setMassForP3Statistics(const Mdouble mass)
Sets the particle's mass This function should not be used, but is necessary to extend the CG toolbox ...
void addDisplacement(const Vec3D &addDisp)
Adds a vector to the particle's displacement_.
Mdouble invInertia_
Particle inertia_.
Definition: BaseParticle.h:409
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.
MERCURY_DEPRECATED 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:406
ParticleHandler * handler_
Pointer to the particle's ParticleHandler container.
Definition: BaseParticle.h:390
Mdouble invMass_
Particle mass_.
Definition: BaseParticle.h:407
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:37
Mdouble getWallInteractionRadius() const
Returns the interaction radius for interaction with walls. See also BaseParticle::getInteractionRadiu...
int HGridX_
Hgrid attributes.
Definition: BaseParticle.h:400
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:402
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:408
Vec3D displacement_
Pointer to originating Particle.
Definition: BaseParticle.h:413
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:401
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:414
BaseParticle * HGridPrevObject_
Pointer to the next Particle in the same HGrid cell.
Definition: BaseParticle.h:403
Mdouble getInertia() const
Returns the particle's inertia_.
MERCURY_DEPRECATED void setIndSpecies(unsigned int indSpecies)
Mdouble getRadius() const
Returns the particle's radius_.
virtual std::vector< Mdouble > getFieldVTK(unsigned i) const
const Vec3D getDisplacement2(Mdouble xmin, Mdouble xmax, Mdouble ymin, Mdouble ymax, Mdouble zmin, Mdouble zmax, Mdouble t) const
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_.
virtual std::string getTypeVTK(unsigned i) const
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:410
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.
virtual std::string getNameVTK(unsigned i) const
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:411
unsigned int getHGridLevel() const
Returns particle's HGrid level.
virtual unsigned getNumberOfFieldsVTK() const
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.
std::vector< 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...