MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseInteraction.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 BASEINTERACTION_H
27 #define BASEINTERACTION_H
28 
29 #include "BaseObject.h"
30 #include "Math/Vector.h"
31 #include "Math/Matrix.h"
32 
33 class InteractionHandler;
34 class BaseParticle;
35 class BaseSpecies;
36 class BaseInteractable;
37 
52 {
53 public:
59 
62 
64  virtual ~BaseInteraction();
65 
69  virtual void computeForce();
70 
74  virtual void read(std::istream& is);
75 
79  virtual void write(std::ostream& os) const;
80 
84  void writeToFStat(std::ostream& os) const;
85 
89  virtual std::string getName() const;
90 
94  virtual Mdouble getElasticEnergy() const;
95 
99  void setDistance(Mdouble distance);
100 
104  void setNormal(Vec3D normal);
105 
109  void setOverlap(Mdouble overlap);
110 
114  void setContactPoint(Vec3D contactPoint);
115 
119  void setTimeStamp(Mdouble timeStamp);
120 
124  void setSpecies(BaseSpecies *species);
125 
129  void setP(BaseInteractable* P);
130 
134  void setI(BaseInteractable* I);
135 
139  void setHandler(InteractionHandler* handler);
140 
145 
149  const Vec3D& getForce() const;
150 
154  const Vec3D& getTorque() const;
155 
159  const Vec3D& getNormal() const;
160 
164  const Vec3D& getContactPoint() const;
165 
169  Mdouble getOverlap() const;
170 
174  void removeFromHandler();
175 
179  void copySwitchPointer(const BaseInteractable* original, BaseInteractable* ghost) const;
180 
186 
191 
192  /*
193  * \brief Returns a pointer to the second object involved in the interaction (often a wall or a particle).
194  */
196 
197  /*
198  * \brief Returns a constant pointer to the first object involved in the interaction.
199  */
200  const BaseInteractable* getP() const;
201 
205  const BaseInteractable* getI() const;
206 
210  Mdouble getTimeStamp() const;
211 
215  virtual void integrate(Mdouble timeStep);
216 
220  virtual Mdouble getTangentialOverlap() const;
221 
225  Mdouble getDistance() const;
226 
230  const Vec3D& getRelativeVelocity() const;
231 
236 
241 
242 
246  virtual BaseInteraction* copy() const = 0;
247 
248 protected:
249 
253  virtual const Vec3D getTangentialForce() const;
254 
258  Mdouble getEffectiveRadius() const;
259 
264 
265 protected:
266 
267  //functions that only the derived Interactions have to know about:
271  void addForce(Vec3D force);
272 
273  /*
274  * \brief add a torque increment to the total torque.
275  */
276  void addTorque(Vec3D torque);
277 
278  //these functions are only used for normal forces and should be made private by the normal forces:
279 
283  void setForce(Vec3D force);
284 
288  void setTorque(Vec3D torque);
289 
293  void setRelativeVelocity(Vec3D relativeVelocity);
294 
298  void setNormalRelativeVelocity(Mdouble normalRelativeVelocit);
299 
303  void setAbsoluteNormalForce(Mdouble absoluteNormalForce);
304 
308  const BaseSpecies* getBaseSpecies() const;
309 
310 
314  virtual void reverseHistory();
315 
316 public:
317 
323  virtual void rotateHistory(Matrix3D& rotationMatrix);
324 
325 private:
326 
327 
332 
337 
342 
347 
348 
349 
354 
359 
364 
369 
374 
379 
384 
389 
394 
399 };
400 #endif
const Vec3D & getForce() const
Gets the current force (vector) between the two interacting objects.
BaseInteractable * I_
Mdouble getEffectiveRadius() const
Returns a Mdouble to the effective radius of the interaction. (Not corrected for the overlap) ...
void setNormal(Vec3D normal)
Sets the normal vector between the two interacting objects.
void copySwitchPointer(const BaseInteractable *original, BaseInteractable *ghost) const
This copies the interactions of the original particle and replaces the original with the ghost copy...
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:44
InteractionHandler * getHandler() const
Gets a point to the interaction handlers to which this interaction belongs.
void setOverlap(Mdouble overlap)
Set the overlap between the two interacting object.
virtual BaseInteraction * copy() const =0
Makes a copy of the interaction and returns a pointer to the copy.
BaseSpecies * species_
void setI(BaseInteractable *I)
Sets the second object involved in the interaction (often particle or wall).
It is an abstract base class due to the purely virtual functions declared below. Even if the function...
Definition: BaseObject.h:49
const Vec3D & getRelativeVelocity() const
Returns a constant reference to a vector of relative velocity.
double Mdouble
virtual void reverseHistory()
When periodic particles some interaction need certain history properties reversing. This is the function for that.
void setRelativeVelocity(Vec3D relativeVelocity)
set the relative velocity of the current of the interactions.
void setContactPoint(Vec3D contactPoint)
Set the location of the contact point between the two interacting objects.
void addTorque(Vec3D torque)
void removeFromHandler()
Removes this interaction from its interaction hander.
void setForce(Vec3D force)
set total force (this is used by the normal force, tangential forces are added use addForce) ...
void setNormalRelativeVelocity(Mdouble normalRelativeVelocit)
set the normal component of the relative velocity.
void setDistance(Mdouble distance)
Sets the interaction distance between the two interacting objects.
Mdouble getTimeStamp() const
Returns an Mdouble which is the time stamp of the interaction.
void setSpecies(BaseSpecies *species)
Set the Species of the interaction; note this can either be a Species or MixedSpecies.
void gatherContactStatistics()
Stores information about interactions between two interactable objects; often particles but could be ...
BaseInteractable * P_
const Vec3D & getContactPoint() const
Gets constant reference to contact point (vector).
Mdouble getNormalRelativeVelocity() const
Returns a double which is the norm (length) of the relative velocity vector.
virtual ~BaseInteraction()
The default destructor.
BaseInteraction(BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp)
A constructor takes the BaseInteractable objects which are interacting (come into contact) and time t...
void setTimeStamp(Mdouble timeStamp)
Updates the time step of the interacting. Note, timesteps used to find completed interactions.
virtual void rotateHistory(Matrix3D &rotationMatrix)
When periodic particles are used, some interactions need certain history properties rotated (e...
const BaseSpecies * getBaseSpecies() const
Return a constant point to BaseSpecies of the interaction.
Container to store Interaction objects.
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
void setHandler(InteractionHandler *handler)
Sets the pointer to the interaction hander which is storing this interaction.
void setP(BaseInteractable *P)
Sets the first object involved in the interaction (normally a particle).
void setTorque(Vec3D torque)
set the total force (this is used by the normal force, tangential torques are added use addTorque) ...
virtual const Vec3D getTangentialForce() const
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
void addForce(Vec3D force)
add an force increment to the total force.
void setAbsoluteNormalForce(Mdouble absoluteNormalForce)
the absolute values of the norm (length) of the normal force
Mdouble normalRelativeVelocity_
BaseInteractable * getI()
Mdouble getDistance() const
Returns an Mdouble which is the norm (length) of distance vector.
virtual void integrate(Mdouble timeStep)
integrates variables of the interaction which need to be integrate e.g. the tangential overlap...
virtual std::string getName() const
Virtual function which allows interactions to be named.
const Vec3D & getTorque() const
Gets the current torque (vector) between the two interacting objects.
virtual void read(std::istream &is)
Interaction read function, which accepts an std::istream as input.
Defines the basic properties that a interactable object can have.
virtual Mdouble getElasticEnergy() const
Returns a Mdouble which is the current about of Elastic energy in the interaction.
Mdouble absoluteNormalForce_
virtual void computeForce()
Virtual function that contains the force law between the two objects interacting. ...
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
Implementation of a 3D matrix.
Definition: Matrix.h:36
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual Mdouble getTangentialOverlap() const
get the length of the current tangential overlap
virtual void write(std::ostream &os) const
Interaction print function, which accepts an std::ostream as input.
Mdouble getEffectiveCorrectedRadius()
Returns a Mdouble to the effective radius corrected for the overlaps of the particles.
void writeToFStat(std::ostream &os) const
Writes forces data to the FStat file.
InteractionHandler * handler_
Mdouble getAbsoluteNormalForce() const
Returns the absolute value of the norm (length) of the Normal force vector.