MercuryDPM  0.10
 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 "../ExtendedMath.h"
32 #include "../Vector.h"
33 
34 class ParticleHandler;
35 class HGrid;
36 class CSpecies;
37 
38 #ifdef ContactListHgrid
39  class PossibleContact;
40 #endif
41 
43 {
44 public:
46  BaseParticle();
47 
49  BaseParticle(const BaseParticle &p);
50 
52  virtual ~BaseParticle();
53 
55  virtual BaseParticle* copy() const;
56 
58  Mdouble get_Volume(std::vector<CSpecies>& Species) const;
59 
61  void fixParticle();
62 
64  bool isFixed();
65 
67  void unfix(std::vector<CSpecies>& Species);
68 
70  void compute_particle_mass(std::vector<CSpecies>& Species);
71 
73  friend inline std::ostream& operator<<(std::ostream& os, const BaseParticle &b);
74 
76  friend inline std::istream& operator>>(std::istream& is, BaseParticle &b);
77 
79  virtual void read(std::istream& is);
80 
82  virtual void print(std::ostream& os) const;
83 
84  virtual void moveInHandler(int newPos);
85 
86  void print_HGRID(std::ostream& os);
87 
88  int get_HGRID_Level() const;
91 #ifdef ContactListHgrid
92  PossibleContact* get_FirstPossibleContact() const;
93 #endif
94  int get_HGRID_x() const;
95  int get_HGRID_y() const;
96  int get_HGRID_z() const;
97  int get_Index() const;
98  Mdouble get_Inertia() const;
99  Mdouble get_InvInertia() const;
100  Mdouble get_InvMass() const;
101  Mdouble get_KineticEnergy() const;
102  Mdouble get_Mass() const;
104  const Vec3D& get_Position() const;
105  Mdouble get_Radius() const;
108  int get_Species() const;
109  int get_IndSpecies() const;
110  int get_Id() const;
111  const Vec3D& get_Velocity() const;
112  const Vec3D& get_Angle() const;
113  const Vec3D& get_AngularVelocity() const;
114  const Vec3D& get_Force() const;
115  const Vec3D& get_Torque() const;
116  const Vec3D& get_Displacement() const;
117  const Vec3D& get_PreviousPosition() const;
118  ParticleHandler* getHandler() const;
119  const Vec3D get_Displacement2 (Mdouble xmin, Mdouble xmax, Mdouble ymin, Mdouble ymax, Mdouble zmin, Mdouble zmax, Mdouble t) const;
120 
121  void set_inertia (const Mdouble _new);
122  void set_infiniteInertia ();
124  void set_species (const int _new);
125  void set_Index (const int _new);
126  void set_HGRID_x (const int _new);
127  void set_HGRID_y (const int _new);
128  void set_HGRID_z (const int _new);
129  void set_HGRID_Level (const int _new);
130  void set_HGRID_NextObject (BaseParticle* _new);
131  void set_HGRID_PrevObject (BaseParticle* _new);
132 #ifdef ContactListHgrid
133  void set_FirstPossibleContact (const PossibleContact* PC);
134 #endif
135  void set_Radius (const Mdouble _new);
136  void set_IndSpecies (const int _new);
137  void set_Id (const int _new);
138  void set_Mass (const Mdouble _new);
139  void set_Velocity (const Vec3D& _new);
140  void set_Position (const Vec3D& _new);
141  void set_Displacement (const Vec3D& _new);
142  void set_PreviousPosition (const Vec3D& _new);
143  void set_Angle (const Vec3D& _new);
144  void set_AngularVelocity (const Vec3D& _new);
145  void set_Force (const Vec3D& _new);
146  void set_Torque (const Vec3D& _new);
147 
149 
150  void move (const Vec3D& _new);
151  void movePrevious (const Vec3D& _new);
152  void accelerate (const Vec3D& _new);
153  void rotate (const Vec3D& _new);
154  void angularAccelerate (const Vec3D& _new);
155  void add_Displacement (const Vec3D& _new);
156  void add_Force (const Vec3D& _new);
157  void add_Torque (const Vec3D& _new);
158 
159 #ifdef USE_SIMPLE_VERLET_INTEGRATION
160  void set_PrevPosition (const Vec3D& _new);
161  void prevMove (const Vec3D& _new);
162  const Vec3D& get_PrevPosition();
163 #endif
164 
165 private:
166 #ifdef ContactListHgrid
167  PossibleContact* firstPossibleContact;
168 #endif
169 
171  //HGrid* hGrid;
172 
178 
180  int _index;
188  int _id;
189 
194 
197 
200 #ifdef USE_SIMPLE_VERLET_INTEGRATION
201  Vec3D prevPosition;
202 #endif
203 };
204 
205 inline std::ostream& operator<<(std::ostream& os, const BaseParticle &p)
206 {
207  p.print(os);
208  return os;
209 }
210 
211 inline std::istream& operator>>(std::istream& is, BaseParticle &p)
212 {
213  p.read(is);
214  return(is);
215 }
216 
217 #endif
int get_Species() const
Vec3D velocity
Current particle position.
Definition: BaseParticle.h:193
void set_inertia(const Mdouble _new)
int HGRID_x
Hgrid attributes.
Definition: BaseParticle.h:174
BaseParticle * periodicFromParticle
Particle radius.
Definition: BaseParticle.h:186
void set_HGRID_x(const int _new)
Mdouble get_KineticEnergy() const
void add_Torque(const Vec3D &_new)
void set_Force(const Vec3D &_new)
void set_species(const int _new)
void set_HGRID_PrevObject(BaseParticle *_new)
BaseParticle * get_HGRID_PrevObject() const
std::istream & operator>>(std::istream &is, BaseParticle &p)
Definition: BaseParticle.h:211
const Vec3D & get_Velocity() const
ParticleHandler * handler
Definition: BaseParticle.h:170
Mdouble get_InteractionRadius() const
void rotate(const Vec3D &_new)
void set_PreviousPosition(const Vec3D &_new)
void compute_particle_mass(std::vector< CSpecies > &Species)
Compute Particle mass function, which required a reference to the Species vector. It copmuters the Pa...
Mdouble inertia
Inverse Particle mass (for computation optimization)
Definition: BaseParticle.h:183
int get_IndSpecies() const
Mdouble mass
Index of the Particle in the ParticleHandler, used for outputting fstat data.
Definition: BaseParticle.h:181
Mdouble radius
Inverse Particle inverse inertia (for computation optimization)
Definition: BaseParticle.h:185
int _id
Index of the Species of this Particle.
Definition: BaseParticle.h:188
void angularAccelerate(const Vec3D &_new)
BaseParticle * get_PeriodicFromParticle() const
void setHandler(ParticleHandler *handler)
BaseParticle * HGRID_PrevObject
Pointer to the next Particle in the same HGrid cell.
Definition: BaseParticle.h:177
virtual void print(std::ostream &os) const
Particle print function, which accepts an os std::stringstream as input.
void set_HGRID_z(const int _new)
int get_HGRID_z() const
friend std::ostream & operator<<(std::ostream &os, const BaseParticle &b)
writes wall
Definition: BaseParticle.h:205
Vec3D angularVelocity
Current angular position.
Definition: BaseParticle.h:191
int get_Index() const
Mdouble get_InvInertia() const
BaseParticle * get_HGRID_NextObject() const
Vec3D angle
non changing identifier of particle
Definition: BaseParticle.h:190
ParticleHandler * getHandler() const
void set_Index(const int _new)
const Vec3D & get_Force() const
Mdouble invInertia
Particle inertia.
Definition: BaseParticle.h:184
bool isFixed()
Is fixed Particle function. It returns wether a Particle is fixed or not, by cheking its inverse Mass...
Mdouble get_Radius() const
void set_periodicFromParticle(BaseParticle *_new)
int get_HGRID_x() const
Mdouble get_Mass() const
Mdouble get_InvMass() const
const Vec3D get_Displacement2(Mdouble xmin, Mdouble xmax, Mdouble ymin, Mdouble ymax, Mdouble zmin, Mdouble zmax, Mdouble t) const
virtual void read(std::istream &is)
Particle read function, which accepts an os std::stringstream as input.
Vec3D previousPosition
Displacement (only used in StatisticsVector, StatisticsPoint)
Definition: BaseParticle.h:199
virtual ~BaseParticle()
Particle destructor, needs to be implemented and checked if it removes tangential spring information...
double Mdouble
Definition: ExtendedMath.h:33
This is the HGRID class - This is the actually HGRID code.
Definition: HGRID.h:39
int get_Id() const
void set_IndSpecies(const int _new)
void set_HGRID_y(const int _new)
Mdouble get_WallInteractionRadius() const
int _index
Pointer to the previous Particle in the same HGrid cell.
Definition: BaseParticle.h:180
void add_Force(const Vec3D &_new)
void set_infiniteInertia()
Vec3D torque
Interaction force.
Definition: BaseParticle.h:196
int HGRID_Level
Cell position in the grid.
Definition: BaseParticle.h:175
const Vec3D & get_PreviousPosition() const
void set_HGRID_Level(const int _new)
const Vec3D & get_Displacement() const
void move(const Vec3D &_new)
Vec3D displacement
Torque.
Definition: BaseParticle.h:198
friend std::istream & operator>>(std::istream &is, BaseParticle &b)
reads wall
Definition: BaseParticle.h:211
const Vec3D & get_Position() const
Container to store all BaseParticle.
std::ostream & operator<<(std::ostream &os, const BaseParticle &p)
Definition: BaseParticle.h:205
void set_Radius(const Mdouble _new)
BaseParticle * HGRID_NextObject
Grid level for the object.
Definition: BaseParticle.h:176
void set_Velocity(const Vec3D &_new)
Mdouble invMass
Particle mass.
Definition: BaseParticle.h:182
BaseParticle()
Basic Particle contructors, creates an Particle at (0,0,0) with radius, mass and inertia equal to 1...
Definition: BaseParticle.cc:37
const Vec3D & get_Torque() const
Vec3D position
Current angular velocity.
Definition: BaseParticle.h:192
void movePrevious(const Vec3D &_new)
void unfix(std::vector< CSpecies > &Species)
Unfix Particle function, which required a reference to the Species vector. It un fixes a Particle by ...
Mdouble get_Volume(std::vector< CSpecies > &Species) const
Get Particle volume function, which required a reference to the Species vector. It returns the volume...
void set_AngularVelocity(const Vec3D &_new)
int get_HGRID_y() const
void print_HGRID(std::ostream &os)
void set_Angle(const Vec3D &_new)
void set_Displacement(const Vec3D &_new)
virtual void moveInHandler(int newPos)
int indSpecies
Pointer to originating Particle.
Definition: BaseParticle.h:187
void set_Torque(const Vec3D &_new)
Mdouble get_Inertia() const
const Vec3D & get_Angle() const
Vec3D force
Current particle velocity.
Definition: BaseParticle.h:195
void set_HGRID_NextObject(BaseParticle *_new)
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:40
Stores properties of the particles and the contact models such as the elastic modulus.
Definition: CSpecies.h:56
void set_Position(const Vec3D &_new)
void accelerate(const Vec3D &_new)
void set_Id(const int _new)
int get_HGRID_Level() const
virtual BaseParticle * copy() const
Particle copy method. It calls to copy contrustor of this Particle, usefull for polymorfism.
void add_Displacement(const Vec3D &_new)
void fixParticle()
Fix Particle function. It fixes a Particle by setting its inverse mass and inertia and velocities to ...
void set_Mass(const Mdouble _new)
const Vec3D & get_AngularVelocity() const