MercuryDPM  Beta
 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 
147 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
149 : BaseInteraction(P, I, timeStamp), NormalForceInteraction(P, I, timeStamp), FrictionForceInteraction(P, I, timeStamp), AdhesiveForceInteraction(P, I, timeStamp)
150 {
151 #ifdef DEBUG_CONSTRUCTOR
152  std::cout<<"Interaction::Interaction() finished"<<std::endl;
153 #endif
154 }
155 
156 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
159 {
160 #ifdef DEBUG_CONSTRUCTOR
161  std::cout<<"Interaction::Interaction(const Interaction &p finished"<<std::endl;
162 #endif
163 }
164 
165 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
167 {
168 #ifdef DEBUG_DESTRUCTOR
169  std::cout<<"Interaction::~Interaction() finished"<<std::endl;
170 #endif
171 }
172 
176 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
178 {
179  return new Interaction(*this);
180 }
181 
186 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
188 {
189  NormalForceInteraction::write(os);
190  FrictionForceInteraction::write(os);
191  AdhesiveForceInteraction::write(os);
192 }
193 
198 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
200 {
201  NormalForceInteraction::read(is);
202  FrictionForceInteraction::read(is);
203  AdhesiveForceInteraction::read(is);
204 }
205 
211 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
213 {
214  NormalForceInteraction::reverseHistory();
215  FrictionForceInteraction::reverseHistory();
216  AdhesiveForceInteraction::reverseHistory();
217 }
218 
219 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
221 {
222  NormalForceInteraction::rotateHistory(rotationMatrix);
223  FrictionForceInteraction::rotateHistory(rotationMatrix);
224  AdhesiveForceInteraction::rotateHistory(rotationMatrix);
225 }
226 
231 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
233 {
234  return NormalForceInteraction::getBaseName() + FrictionForceInteraction::getBaseName() + AdhesiveForceInteraction::getBaseName() + "Interaction";
235 }
236 
242 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
244 {
245  FrictionForceInteraction::integrate(timeStep);
246 }
247 
256 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
258 {
259  NormalForceInteraction::computeNormalForce();
260  FrictionForceInteraction::computeFrictionForce();
261  AdhesiveForceInteraction::computeAdhesionForce();
262 }
263 
270 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
272 {
273  return NormalForceInteraction::getElasticEnergy() + FrictionForceInteraction::getElasticEnergy() + AdhesiveForceInteraction::getElasticEnergy();
274 }
275 #endif
Mdouble getElasticEnergy() const final
Returns the elastic energy stored in the Interaction.
Definition: Interaction.h:271
double Mdouble
void read(std::istream &is) final
Read Interaction properties from a file.
Definition: Interaction.h:199
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:243
std::string getName() const final
Returns the name of the Interaction.
Definition: Interaction.h:232
void reverseHistory() final
Reverses the parameters of the contact force.
Definition: Interaction.h:212
Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > * copy() const final
Creates a copy of this Interaction.
Definition: Interaction.h:177
Interaction(BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp)
The default constructor.
Definition: Interaction.h:148
virtual ~Interaction()
The default destructor.
Definition: Interaction.h:166
void rotateHistory(Matrix3D &rotationMatrix) final
Definition: Interaction.h:220
void computeForce() final
Computes the normal, tangential, and adhesive forces.
Definition: Interaction.h:257
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:187
Contains information about the contact between two interactables, BaseInteraction::P_ and BaseInterac...
Definition: Interaction.h:107