MercuryDPM  Alpha
 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 <vector>
30 #include "BaseObject.h"
31 #include "Math/Vector.h"
32 #include "Math/Matrix.h"
33 
34 class InteractionHandler;
35 class BaseParticle;
36 class BaseSpecies;
37 class BaseInteractable;
38 
53 {
54 public:
60 
63 
66 
68  virtual ~BaseInteraction();
69 
76  virtual void actionsOnErase() {};
77 
81  virtual void computeForce();
82 
86  virtual void read(std::istream& is);
87 
91  virtual void write(std::ostream& os) const;
92 
96  void writeToFStat(std::ostream& os) const;
97 
101  virtual std::string getName() const;
102 
106  virtual Mdouble getElasticEnergy() const;
107 
111  void setDistance(Mdouble distance);
112 
116  void setNormal(Vec3D normal);
117 
121  void setOverlap(Mdouble overlap);
122 
126  void setContactPoint(Vec3D contactPoint);
127 
131  void setTimeStamp(Mdouble timeStamp);
132 
136  void setSpecies(BaseSpecies *species);
137 
141  void setP(BaseInteractable* P);
142 
146  void setI(BaseInteractable* I);
147 
151  void setHandler(InteractionHandler* handler);
152 
157 
161  const Vec3D& getForce() const;
162 
166  const Vec3D& getTorque() const;
167 
171  const Vec3D& getNormal() const;
172 
176  const Vec3D& getContactPoint() const;
177 
181  Mdouble getOverlap() const;
182 
186  Mdouble getContactRadius() const;
187 
191  void removeFromHandler();
192 
196  void copySwitchPointer(const BaseInteractable* original, BaseInteractable* ghost) const;
197 
203 
208 
209  /*
210  * \brief Returns a pointer to the second object involved in the interaction (often a wall or a particle).
211  */
213 
214  /*
215  * \brief Returns a constant pointer to the first object involved in the interaction.
216  */
217  const BaseInteractable* getP() const;
218 
222  const BaseInteractable* getI() const;
223 
227  Mdouble getTimeStamp() const;
228 
232  virtual void integrate(Mdouble timeStep);
233 
237  virtual Mdouble getTangentialOverlap() const;
238 
242  Mdouble getDistance() const;
243 
247  const Vec3D& getRelativeVelocity() const;
248 
253 
258 
262  virtual BaseInteraction* copy() const = 0;
263 
264  unsigned int getMultiContactIdentifier() const;
265 
267 
273  virtual void rotateHistory(Matrix3D& rotationMatrix);
274 
275  virtual void actionsAfterTimeStep();
276 
277  virtual unsigned getNumberOfFieldsVTK() const;
278 
279  virtual std::string getTypeVTK(unsigned i) const;
280 
281  virtual std::string getNameVTK(unsigned i) const;
282 
283  virtual std::vector<Mdouble> getFieldVTK(unsigned i) const;
284 
288  void setForce(Vec3D force);
289 
290 protected:
291 
295  virtual const Vec3D getTangentialForce() const;
296 
300  Mdouble getEffectiveRadius() const;
301 
305  Mdouble getEffectiveMass() const;
306 
311 
312  //functions that only the derived Interactions have to know about:
316  void addForce(Vec3D force);
317 
318  /*
319  * \brief add a torque increment to the total torque.
320  */
321  void addTorque(Vec3D torque);
322 
323  //these functions are only used for normal forces and should be made private by the normal forces:
324 
328  void setTorque(Vec3D torque);
329 
333  void setRelativeVelocity(Vec3D relativeVelocity);
334 
338  void setNormalRelativeVelocity(Mdouble normalRelativeVelocit);
339 
343  void setAbsoluteNormalForce(Mdouble absoluteNormalForce);
344 
348  const BaseSpecies* getBaseSpecies() const;
349 
350  virtual Mdouble getElasticEnergyAtEquilibrium(Mdouble adhesiveForce) const {return 0;}
351 
355  virtual void reverseHistory();
356 
357 private:
358 
359 
364 
369 
374 
379 
380 
381 
386 
391 
396 
401 
406 
411 
417 
422 
427 
432 
433 private:
438 };
439 #endif
const Vec3D & getForce() const
Gets the current force (vector) between the two interacting objects.
BaseInteractable * I_
virtual void actionsOnErase()
If an interaction needs to do something before it gets erased, add it here. E.g. Liquid bridges ruptu...
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.
virtual void actionsAfterTimeStep()
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) ...
virtual std::vector< Mdouble > getFieldVTK(unsigned i) const
void setNormalRelativeVelocity(Mdouble normalRelativeVelocit)
set the normal component of the relative velocity.
BaseInteraction()
Empty constructor.
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.
void setMultiContactIdentifier(unsigned int multiContactIdentifier_)
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.
virtual std::string getTypeVTK(unsigned i) const
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.
virtual std::string getNameVTK(unsigned i) const
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_
unsigned multiContactIdentifier_
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 Mdouble getElasticEnergyAtEquilibrium(Mdouble adhesiveForce) const
Mdouble getContactRadius() const
Returns a Mdouble with the current contact between the two interacting objects.
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.
unsigned int getMultiContactIdentifier() const
Mdouble getEffectiveMass() const
Returns a Mdouble to the effective radius of the interaction. (Not corrected for the overlap) ...
InteractionHandler * handler_
virtual unsigned getNumberOfFieldsVTK() const
Mdouble getAbsoluteNormalForce() const
Returns the absolute value of the norm (length) of the Normal force vector.