MercuryDPM  Alpha
 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  // relativeVelocity = [v_p + (r_p-c) x w_p] - [v_i + (r_i-c) x w_i]
98  // tangentialRelativeVelocity = relativeVelocity - (relativeVelocity . n) n
99  Vec3D tangentialRelativeVelocity = getRelativeVelocity() - getNormal() * getNormalRelativeVelocity();
100 
101  if (species->getSlidingStiffness() != 0.0)
102  {
103  //used to Integrate the spring
104  if (dynamic_cast<BaseParticle*>(getI())==0) //if particle-wall
105  slidingSpringVelocity_= tangentialRelativeVelocity;
106  else //if particle-particle
107  slidingSpringVelocity_= (tangentialRelativeVelocity - Vec3D::dot(slidingSpring_, getP()->getVelocity() - getI()->getVelocity()) * getNormal() / getDistance());
108  // v_s = v_t - [xi . (v_p-v_i)/|r_pi|] n
109 
110  //integrate(getHandler()->timeStep_);
111  // xi = xi' + dt v_s
113  // Stefan does [EJECE-12/2008] sth. like xi = xi' - (xi . n) n + dt*v_t
114 
115  //Calculate test force acting on P including viscous force
116  tangentialForce_ = - species->getSlidingStiffness() * slidingSpring_ - species->getSlidingDissipation() * tangentialRelativeVelocity;
117 
118  //tangential forces are modelled by a spring-damper of elasticity kt and viscosity dispt (sticking),
119  //but the force is limited by Coulomb friction (sliding):
120  Mdouble tangentialForceSquared = tangentialForce_.getLengthSquared();
121  if (tangentialForceSquared <= mathsFunc::square(species->getSlidingFrictionCoefficientStatic() * getAbsoluteNormalForce()))
122  {
123  //if sticking (|ft|<=mu*|fn|), apply the force
125  }
126  else
127  {
128  //if sliding, resize the tangential force such that |ft|=mu*|fn|
129  tangentialForce_ *= species->getSlidingFrictionCoefficient() * getAbsoluteNormalForce() / std::sqrt(tangentialForceSquared);
131  //resize the tangential spring accordingly such ft=-k*delta-nu*relVel
132  slidingSpring_ = -(tangentialForce_ + species->getSlidingDissipation() * tangentialRelativeVelocity) / species->getSlidingStiffness();
133  }
134  }
135  else //if no spring stiffness is set
136  {
137 // if (species->getSlidingDissipation()==0.0)
138 // {
139 // std::cerr << "SlidingFrictionInteraction::getForce(): warning: both sliding stiffness and dissipation are zero" << std::endl;
140 // }
141  Mdouble tangentialRelativeVelocitySquared = tangentialRelativeVelocity.getLengthSquared();
142  if (tangentialRelativeVelocitySquared * mathsFunc::square(species->getSlidingDissipation()) <= mathsFunc::square(species->getSlidingFrictionCoefficientStatic() * getAbsoluteNormalForce()))
143  tangentialForce_=-species->getSlidingDissipation() * tangentialRelativeVelocity;
144  else //if sliding, set force to Coulomb limit
145  tangentialForce_=-(species->getSlidingFrictionCoefficient() * getAbsoluteNormalForce() / std::sqrt(tangentialRelativeVelocitySquared)) * tangentialRelativeVelocity;
146 
148  }
149  }
150 // else
151 // {
152 // std::cerr << "SlidingFrictionInteraction::getForce(): warning: sliding friction is zero" << std::endl;
153 // }
154 }
159 {
161 }
166 {
168 }
173 {
175  return -slidingSpring_.getLength();
176 }
181 {
182  return tangentialForce_;
183 }
188 {
189  return dynamic_cast<const SlidingFrictionSpecies*>(getBaseSpecies());
190 }
195 {
196  return "SlidingFriction";
197 }
198 
200 {
201  slidingSpring_ = slidingSpring;
202 }
203 
205 {
206  return slidingSpring_;
207 }
208 
213 {
217 }
218 
220 {
221  slidingSpring_=rotationMatrix*slidingSpring_;
223  tangentialForce_=rotationMatrix*tangentialForce_;
224 }
225 
227 {
228  slidingSpring_ += displacement;
229 }
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.cc:291
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:167
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:414
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*.
void setSlidingSpring(const Vec3D slidingSpring)
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.
void moveSlidingSpring(const Vec3D displacement)
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:543
Mdouble getTimeStep() const
Allows the time step dt to be accessed.
Definition: DPMBase.cc:465
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.