MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SlidingFrictionInteraction.cc
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 
29 #include "Particles/BaseParticle.h"
30 #include "InteractionHandler.h"
31 #include <iomanip>
32 #include <fstream>
33 #include <DPMBase.h>
40  : BaseInteraction(P, I, timeStamp)
41 {
43 #ifdef DEBUG_CONSTRUCTOR
44  std::cout<<"SlidingFrictionInteraction::SlidingFrictionInteraction() finished"<<std::endl;
45 #endif
46 }
51  : BaseInteraction(p)
52 {
54 #ifdef DEBUG_CONSTRUCTOR
55  std::cout<<"SlidingFrictionInteraction::SlidingFrictionInteraction(const SlidingFrictionInteraction& p) finished"<<std::endl;
56 #endif
57 }
62 {
63 #ifdef DEBUG_DESTRUCTOR
64  std::cout<<"SlidingFrictionInteraction::~SlidingFrictionInteraction() finished"<<std::endl;
65 #endif
66 }
70 void SlidingFrictionInteraction::write(std::ostream& os) const
71 {
72  //BaseInteraction::write(os);
73  os << " slidingSpring " << slidingSpring_;
74 }
78 void SlidingFrictionInteraction::read(std::istream& is)
79 {
80  //BaseInteraction::read(is);
81  std::string dummy;
82  is >> dummy >> slidingSpring_;
83 }
88 {
89  //If tangential forces are absent
90  if (getAbsoluteNormalForce() == 0.0) return;
91 
92  const SlidingFrictionSpecies* species = getSpecies();//dynamic_cast
93 
94  if (species->getSlidingFrictionCoefficient() != 0.0)
95  {
96  //Compute the tangential component of relativeVelocity_
97  Vec3D tangentialRelativeVelocity = getRelativeVelocity() - getNormal() * getNormalRelativeVelocity();
98 
99  if (species->getSlidingStiffness() != 0.0)
100  {
101  //used to Integrate the spring
102  if (dynamic_cast<BaseParticle*>(getI())==0) //if particle-wall
103  slidingSpringVelocity_= tangentialRelativeVelocity;
104  else //if particle-particle
105  slidingSpringVelocity_= (tangentialRelativeVelocity - Vec3D::dot(slidingSpring_, getP()->getVelocity() - getI()->getVelocity()) * getNormal() / getDistance());
106 
107  //integrate(getHandler()->timeStep_);
109 
110  //Calculate test force acting on P including viscous force
111  tangentialForce_ = - species->getSlidingStiffness() * slidingSpring_ - species->getSlidingDissipation() * tangentialRelativeVelocity;
112 
113  //tangential forces are modelled by a spring-damper of elasticity kt and viscosity dispt (sticking),
114  //but the force is limited by Coulomb friction (sliding):
115  Mdouble tangentialForceSquared = tangentialForce_.getLengthSquared();
116  if (tangentialForceSquared <= mathsFunc::square(species->getSlidingFrictionCoefficientStatic() * getAbsoluteNormalForce()))
117  {
118  //if sticking (|ft|<=mu*|fn|), apply the force
120  }
121  else
122  {
123  //if sliding, resize the tangential force such that |ft|=mu*|fn|
124  tangentialForce_ *= species->getSlidingFrictionCoefficient() * getAbsoluteNormalForce() / std::sqrt(tangentialForceSquared);
126  //resize the tangential spring accordingly such ft=-k*delta-nu*relVel
127  slidingSpring_ = -(tangentialForce_ + species->getSlidingDissipation() * tangentialRelativeVelocity) / species->getSlidingStiffness();
128  }
129  }
130  else //if no spring stiffness is set
131  {
132 // if (species->getSlidingDissipation()==0.0)
133 // {
134 // std::cerr << "SlidingFrictionInteraction::getForce(): warning: both sliding stiffness and dissipation are zero" << std::endl;
135 // }
136  Mdouble tangentialRelativeVelocitySquared = tangentialRelativeVelocity.getLengthSquared();
137  if (tangentialRelativeVelocitySquared * mathsFunc::square(species->getSlidingDissipation()) <= mathsFunc::square(species->getSlidingFrictionCoefficientStatic() * getAbsoluteNormalForce()))
138  tangentialForce_=-species->getSlidingDissipation() * tangentialRelativeVelocity;
139  else //if sliding, set force to Coulomb limit
140  tangentialForce_=-(species->getSlidingFrictionCoefficient() * getAbsoluteNormalForce() / std::sqrt(tangentialRelativeVelocitySquared)) * tangentialRelativeVelocity;
141 
143  }
144  }
145 // else
146 // {
147 // std::cerr << "SlidingFrictionInteraction::getForce(): warning: sliding friction is zero" << std::endl;
148 // }
149 }
154 {
156 }
161 {
163 }
168 {
170  return -slidingSpring_.getLength();
171 }
176 {
177  return tangentialForce_;
178 }
183 {
184  return dynamic_cast<const SlidingFrictionSpecies*>(getBaseSpecies());
185 }
190 {
191  return "SlidingFriction";
192 }
197 {
201 }
202 
204 {
205  slidingSpring_=rotationMatrix*slidingSpring_;
207  tangentialForce_=rotationMatrix*tangentialForce_;
208 }
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.cc:304
void rotateHistory(Matrix3D &rotationMatrix)
When periodic particles are used, some interactions need certain history properties rotated (e...
void write(std::ostream &os) const
Interaction write function, which accepts an std::ostream as input.
Mdouble getSlidingFrictionCoefficientStatic() const
Allows the static Coulomb friction coefficient to be accessed.
Vec3D slidingSpringVelocity_
Stores the rate at which the sliding spring compressed or relaxed. Set in the member function compute...
InteractionHandler * getHandler() const
Gets a point to the interaction handlers to which this interaction belongs.
void reverseHistory()
A useful feature if one wants to return to the initial state of the spring. However, reverse history decrements the current state to the state corresponding to previous time step. Decrements the value of slidingSpring_.
SlidingFrictionInteraction(BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp)
Constructor.
const Vec3D & getRelativeVelocity() const
Returns a constant reference to a vector of relative velocity.
Computes the forces corresponding to sliding friction.
double Mdouble
virtual ~SlidingFrictionInteraction()
Destructor.
void setZero()
Sets all elements to zero.
Definition: Vector.cc:52
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:187
T square(T val)
squares a number
Definition: ExtendedMath.h:91
void read(std::istream &is)
Interaction read function, which accepts an std::istream as input.
Stores information about interactions between two interactable objects; often particles but could be ...
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Definition: Vector.cc:427
Vec3D tangentialForce_
Computes the tangential force such that . Set and computed in computeFrictionForce().
void computeFrictionForce()
Computes the tangential force generated due to compression in the sliding spring. Does take into acco...
Mdouble getNormalRelativeVelocity() const
Returns a double which is the norm (length) of the relative velocity vector.
const BaseSpecies * getBaseSpecies() const
Return a constant point to BaseSpecies of the interaction.
const SlidingFrictionSpecies * getSpecies() const
Returns a const pointer of type SlidingFrictionSpecies*.
Vec3D slidingSpring_
Stores the amount of sliding spring ( ) compression from the expression . Set in the member function ...
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
void integrate(Mdouble timeStep)
Increments the amount of compression in sliding spring.
Mdouble getTangentialOverlap() const
Returns the amount of tangential overlap which is needed by BaseInteraction::writeToFstat().
std::string getBaseName() const
Returns the type/name of interaction (sliding friction interaction)
void addForce(Vec3D force)
add an force increment to the total force.
SlidingFrictionSpecies contains the parameters used to describe sliding friction. ...
BaseInteractable * getI()
Mdouble getDistance() const
Returns an Mdouble which is the norm (length) of distance vector.
Mdouble getElasticEnergy() const
Returns the amount of elastic energy stored in sliding spring.
Mdouble getSlidingStiffness() const
Allows the spring constant to be accessed.
Mdouble getSlidingDissipation() const
Allows the tangential viscosity to be accessed.
Defines the basic properties that a interactable object can have.
const Vec3D getTangentialForce() const
Returns the sliding friction force vector.
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
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:512
Mdouble getTimeStep() const
Allows the time step dt to be accessed.
Definition: DPMBase.cc:368
Mdouble getSlidingFrictionCoefficient() const
Allows the (dynamic) Coulomb friction coefficient to be accessed.
Mdouble getAbsoluteNormalForce() const
Returns the absolute value of the norm (length) of the Normal force vector.