MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IrreversibleAdhesiveInteraction.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, 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 
40  unsigned timeStamp)
41  : BaseInteraction(P, I, timeStamp), ReversibleAdhesiveInteraction(P, I, timeStamp)
42 {
43  wasInContact_ = false;
44 #ifdef DEBUG_CONSTRUCTOR
45  std::cout<<"IrreversibleAdhesiveInteraction::IrreversibleAdhesiveInteraction() finished"<<std::endl;
46 #endif
47 }
48 
49 //used for mpi
52 {
53  wasInContact_ = false;
54 #ifdef DEBUG_CONSTRUCTOR
55  std::cout<<"IrreversibleAdhesiveInteraction::IrreversibleAdhesiveInteraction() finished"<<std::endl;
56 #endif
57 }
58 
64 {
67 #ifdef DEBUG_CONSTRUCTOR
68  std::cout<<"IrreversibleAdhesiveInteraction::IrreversibleAdhesiveInteraction(const IrreversibleAdhesiveInteraction &p finished"<<std::endl;
69 #endif
70 }
71 
76 {
77 #ifdef DEBUG_DESTRUCTOR
78  std::cout<<"IrreversibleAdhesiveInteraction::~IrreversibleAdhesiveInteraction() finished"<<std::endl;
79 #endif
80 }
81 
85 void IrreversibleAdhesiveInteraction::write(std::ostream& os) const
86 {
87  os << " wasInContact " << wasInContact_;
88 }
89 
94 {
95  std::string dummy;
96  is >> dummy >> wasInContact_;
97 }
98 
103 {
104  const IrreversibleAdhesiveSpecies* species = getSpecies();
105  if (getOverlap() >= 0)
106  {
107  wasInContact_ = true;
108  addForce(getNormal() * (-species->getAdhesionForceMax()));
109  }
110  else if (wasInContact_)
111  {
112  addForce(getNormal() * (-species->getAdhesionStiffness() * getOverlap() - species->getAdhesionForceMax()));
113  }
114 }
115 
120 {
121  return static_cast<const IrreversibleAdhesiveSpecies*>(getBaseSpecies()->getAdhesiveForce());
122 ;
123 }
124 
129 {
130  return "IrreversibleAdhesive";
131 }
132 
139 {
140  if (!wasInContact_)
141  return 0.0;
142  else if (getOverlap() <= 0)
143  return -0.5 * getSpecies()->getAdhesionStiffness() *
144  mathsFunc::square(getOverlap() + getBaseSpecies()->getInteractionDistance());
145  else
146  return -getSpecies()->getAdhesionForceMax() * getOverlap()
147  - 0.5 * getSpecies()->getAdhesionStiffness() * mathsFunc::square(getBaseSpecies()->getInteractionDistance());
148 }
149 
151 {
152  return wasInContact_;
153 }
154 
156 {
157  wasInContact_ = wasInContact;
158 }
double Mdouble
Definition: GeneralDefine.h:34
Mdouble getAdhesionForceMax() const
Allows the spring constant to be accessed.
BaseAdhesiveForce * getAdhesiveForce() const
Definition: BaseSpecies.h:152
Mdouble getElasticEnergy() const override
Returns the elastic energy stored in the adhesive spring.
Stores information about interactions between two interactable objects; often particles but could be ...
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
void computeAdhesionForce()
Computes the Adhesive force.
const BaseSpecies * getBaseSpecies() const
Return a constant point to BaseSpecies of the interaction.
void read(std::istream &is) override
Interaction read function, which accepts an std::istream as input.
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.
std::string getBaseName() const
Returns the name of the interaction, see Interaction.h.
IrreversibleAdhesiveSpecies contains the parameters used to describe a linear irreversible short-rang...
const IrreversibleAdhesiveSpecies * getSpecies() const
Returns a pointer to the adhesive force species IrreversibleAdhesiveSpecies.
Defines the basic properties that a interactable object can have.
bool wasInContact_
A history parameter to store if the particles were in contact or not. Useful to compute adhesive forc...
void write(std::ostream &os) const override
Interaction print function, which accepts an std::ostream as input.
Mdouble getAdhesionStiffness() const
Allows the spring constant to be accessed.
T square(const T val)
squares a number
Definition: ExtendedMath.h:104