MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Interaction.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 INTERACTION_H
27 #define INTERACTION_H
28 
31 #include "InteractionHandler.h"
32 #include "BaseInteractable.h"
33 
34 class BaseInteractable;
35 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies> class Species;
36 
105 //this class combines normal and tangential force laws
106 template<class NormalForceInteraction, class FrictionForceInteraction=EmptyFrictionInteraction, class AdhesiveForceInteraction=EmptyAdhesiveInteraction>
108 {
109 public:
110 
113 
115  Interaction(const Interaction &p);
116 
118  virtual ~Interaction();
119 
122 
124  void computeForce() final;
125 
127  void read(std::istream& is) final;
128 
130  void write(std::ostream& os) const final;
131 
133  std::string getName() const final;
134 
136  Mdouble getElasticEnergy() const final;
137 
139  void integrate(Mdouble timeStep) final;
140 
142  void reverseHistory() final;
143 
144  void rotateHistory(Matrix3D& rotationMatrix) final;
145 
146  void actionsAfterTimeStep();
147 
151  Mdouble getElasticEnergyAtEquilibrium(Mdouble adhesiveForce) const;
152 };
153 
154 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
156 : BaseInteraction(P, I, timeStamp), NormalForceInteraction(P, I, timeStamp), FrictionForceInteraction(P, I, timeStamp), AdhesiveForceInteraction(P, I, timeStamp)
157 {
158 #ifdef DEBUG_CONSTRUCTOR
159  std::cout<<"Interaction::Interaction() finished"<<std::endl;
160 #endif
161 }
162 
163 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
166 {
167 #ifdef DEBUG_CONSTRUCTOR
168  std::cout<<"Interaction::Interaction(const Interaction &p finished"<<std::endl;
169 #endif
170 }
171 
172 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
174 {
175 #ifdef DEBUG_DESTRUCTOR
176  std::cout<<"Interaction::~Interaction() finished"<<std::endl;
177 #endif
178 }
179 
183 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
185 {
186  return new Interaction(*this);
187 }
188 
193 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
195 {
196  NormalForceInteraction::write(os);
197  FrictionForceInteraction::write(os);
198  AdhesiveForceInteraction::write(os);
199 }
200 
205 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
207 {
208  NormalForceInteraction::read(is);
209  FrictionForceInteraction::read(is);
210  AdhesiveForceInteraction::read(is);
211 }
212 
218 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
220 {
221  NormalForceInteraction::reverseHistory();
222  FrictionForceInteraction::reverseHistory();
223  AdhesiveForceInteraction::reverseHistory();
224 }
225 
226 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
228 {
229  NormalForceInteraction::rotateHistory(rotationMatrix);
230  FrictionForceInteraction::rotateHistory(rotationMatrix);
231  AdhesiveForceInteraction::rotateHistory(rotationMatrix);
232 }
233 
238 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
240 {
241  return NormalForceInteraction::getBaseName() + FrictionForceInteraction::getBaseName() + AdhesiveForceInteraction::getBaseName() + "Interaction";
242 }
243 
249 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
251 {
252  FrictionForceInteraction::integrate(timeStep);
253 }
254 
263 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
265 {
266  NormalForceInteraction::computeNormalForce();
267  FrictionForceInteraction::computeFrictionForce();
268  AdhesiveForceInteraction::computeAdhesionForce();
269 }
270 
277 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
279 {
280  return NormalForceInteraction::getElasticEnergy() + FrictionForceInteraction::getElasticEnergy() + AdhesiveForceInteraction::getElasticEnergy();
281 }
282 
283 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
285 {
286  AdhesiveForceInteraction::actionsAfterTimeStep();
287 }
288 
292 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
294 {
295  return NormalForceInteraction::getElasticEnergyAtEquilibrium(adhesiveForce);
296 };
297 
298 #endif
Mdouble getElasticEnergy() const final
Returns the elastic energy stored in the Interaction.
Definition: Interaction.h:278
double Mdouble
void read(std::istream &is) final
Read Interaction properties from a file.
Definition: Interaction.h:206
Stores information about interactions between two interactable objects; often particles but could be ...
void integrate(Mdouble timeStep) final
Integrates the time-dependent parameters of the contact force.
Definition: Interaction.h:250
Mdouble getElasticEnergyAtEquilibrium(Mdouble adhesiveForce) const
returns the overlap at which the repulsive elastic force equals a given adhesive force; to be impleme...
Definition: Interaction.h:293
std::string getName() const final
Returns the name of the Interaction.
Definition: Interaction.h:239
void actionsAfterTimeStep()
Definition: Interaction.h:284
void reverseHistory() final
Reverses the parameters of the contact force.
Definition: Interaction.h:219
Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > * copy() const final
Creates a copy of this Interaction.
Definition: Interaction.h:184
Interaction(BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp)
The default constructor.
Definition: Interaction.h:155
virtual ~Interaction()
The default destructor.
Definition: Interaction.h:173
void rotateHistory(Matrix3D &rotationMatrix) final
Definition: Interaction.h:227
void computeForce() final
Computes the normal, tangential, and adhesive forces.
Definition: Interaction.h:264
Defines the basic properties that a interactable object can have.
Contains material and contact force properties.
Definition: Interaction.h:35
Implementation of a 3D matrix.
Definition: Matrix.h:36
void write(std::ostream &os) const final
Writes Interaction properties to a file.
Definition: Interaction.h:194
Contains information about the contact between two interactables, BaseInteraction::P_ and BaseInterac...
Definition: Interaction.h:107