MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseInteractable.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 BASEINTERACTABLE_H
27 #define BASEINTERACTABLE_H
28 
29 #include <list>
30 #include <functional>
31 
32 #include "BaseObject.h"
33 #include "Math/Vector.h"
34 
35 class BaseParticle;
36 class ParticleSpecies;
37 class BaseInteraction;
38 class InteractionHandler;
51 {
52 public:
58 
64 
69  virtual ~BaseInteractable();
70 
74  virtual void read(std::istream& is) = 0;
75 
80  virtual void write(std::ostream& os) const = 0;
81 
85  unsigned int getIndSpecies() const;
86 
90  virtual void setIndSpecies(unsigned int indSpecies);
91 
95  const ParticleSpecies* getSpecies() const;
96 
100  void setSpecies(const ParticleSpecies* species);
101 
105  const Vec3D& getForce() const;
106 
110  const Vec3D& getTorque() const;
111 
115  void setForce(Vec3D force);
116 
120  void setTorque(Vec3D torque);
121 
125  void addForce(Vec3D addForce);
126 
130  void addTorque(Vec3D addTorque);
131 
135  const Vec3D& getPosition() const;
136 
140  const Vec3D& getOrientation() const;
141 
145  void setPosition(const Vec3D& position);
146 
150  void setOrientation(const Vec3D& orientation);
151 
155  virtual void move(const Vec3D& move);
156 
160  void rotate(const Vec3D& rotate);
161 
165  const std::list<BaseInteraction*>& getInteractions() const;
166 
171 
176 
182 
186  void setVelocity(const Vec3D& velocity);
187 
191  void setAngularVelocity(const Vec3D& angularVelocity);
192 
196  void addVelocity(const Vec3D& velocity);
197 
201  void addAngularVelocity(const Vec3D& angularVelocity);
202 
206  virtual const Vec3D& getVelocity() const;
207 
211  virtual const Vec3D& getAngularVelocity() const;
212 
217  void setPrescribedPosition(std::function<Vec3D (double)> prescribedPosition);
218 
223  void applyPrescribedPosition(double time);
224 
229  void setPrescribedVelocity(std::function<Vec3D (double)> prescribedVelocity);
230 
235  void applyPrescribedVelocity(double time);
236 
241  void setPrescribedOrientation(std::function<Vec3D (double)> prescribedOrientation);
242 
247  void applyPrescribedOrientation(double time);
248 
253  void setPrescribedAngularVelocity(std::function<Vec3D (double)> prescribedAngularVelocity);
254 
259  void applyPrescribedAngularVelocity(double time);
260 
267  virtual BaseInteraction* getInteractionWith(BaseParticle *P, Mdouble timeStamp, InteractionHandler* interactionHandler)=0;
268 
272  virtual const Vec3D getVelocityAtContact(const Vec3D& contact) const;
273 
277  void integrateBeforeForceComputation(double time, double timeStep);
278 
283  void integrateAfterForceComputation(double time, double timeStep);
284 
285 private:
290  std::function<Vec3D (double)> prescribedPosition_;
291 
296  std::function<Vec3D (double)> prescribedVelocity_;
297 
302  std::function<Vec3D (double)> prescribedOrientation_;
303 
308  std::function<Vec3D (double)> prescribedAngularVelocity_;
309 
315 
321 
326 
331 
336 
342 
346  unsigned int indSpecies_;
347 
352 
356  std::list<BaseInteraction*> interactions_;
357 };
358 #endif
359 
void rotate(const Vec3D &rotate)
Rotates this BaseInteractable.
std::function< Vec3D(double)> prescribedPosition_
void addVelocity(const Vec3D &velocity)
adds an increment to the velocity.
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
unsigned int indSpecies_
void applyPrescribedPosition(double time)
Computes the position from the user defined prescribed position function.
const Vec3D & getForce() const
Returns the force on this BaseInteractable.
std::function< Vec3D(double)> prescribedVelocity_
void setOrientation(const Vec3D &orientation)
Sets the orientation of this BaseInteractable.
bool removeInteraction(BaseInteraction *I)
Removes an interaction from this BaseInteractable.
void addInteraction(BaseInteraction *I)
Adds an interaction to this BaseInteractable.
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
void applyPrescribedAngularVelocity(double time)
Computes the angular velocity from the user defined prescribed angular velocity.
void setForce(Vec3D force)
Sets the force on this BaseInteractable.
It is an abstract base class due to the purely virtual functions declared below. Even if the function...
Definition: BaseObject.h:49
virtual const Vec3D getVelocityAtContact(const Vec3D &contact) const
Returns the velocity at the contact point, use by many force laws.
double Mdouble
void applyPrescribedOrientation(double time)
Computes the orientation from the user defined prescribed orientation function.
void setPrescribedPosition(std::function< Vec3D(double)> prescribedPosition)
Allows the position of an infinite mass interactable to be prescribed.
void integrateBeforeForceComputation(double time, double timeStep)
This is part of integrate routine for objects with infinite mass.
virtual BaseInteraction * getInteractionWith(BaseParticle *P, Mdouble timeStamp, InteractionHandler *interactionHandler)=0
Returns the interaction between this object and a given BaseParticle.
virtual const Vec3D & getAngularVelocity() const
Returns the angular velocity of this interactable.
virtual ~BaseInteractable()
Destructor, it simply destructs the BaseInteractable and all the objects it contains.
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
const Vec3D & getOrientation() const
Returns the orientation of this BaseInteractable.
Stores information about interactions between two interactable objects; often particles but could be ...
void setPrescribedOrientation(std::function< Vec3D(double)> prescribedOrientation)
Allows the orientation of the infinite mass interactbale to be prescribed.
void addAngularVelocity(const Vec3D &angularVelocity)
add an increment to the angular velocity.
void setSpecies(const ParticleSpecies *species)
Sets the species of this BaseInteractable.
virtual void read(std::istream &is)=0
Reads a BaseInteractable from an input stream.
const ParticleSpecies * species_
Container to store Interaction objects.
void setPrescribedVelocity(std::function< Vec3D(double)> prescribedVelocity)
Allows the velocity of an infinite mass interactable to be prescribed.
const Vec3D & getTorque() const
Returns the torque on this BaseInteractable.
std::list< BaseInteraction * > interactions_
std::function< Vec3D(double)> prescribedOrientation_
void addTorque(Vec3D addTorque)
Adds an amount to the torque on this BaseInteractable.
void copyInteractionsForPeriodicParticles(const BaseInteractable &p)
Copies interactions to this BaseInteractable whenever a periodic copy made.
virtual void setIndSpecies(unsigned int indSpecies)
Sets the index of the Species of this BaseInteractable.
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
void applyPrescribedVelocity(double time)
Computes the velocity from the user defined prescribed velocity function.
Defines the basic properties that a interactable object can have.
std::function< Vec3D(double)> prescribedAngularVelocity_
const std::list< BaseInteraction * > & getInteractions() const
Returns a reference to the list of interactions in this BaseInteractable.
unsigned int getIndSpecies() const
Returns the index of the Species of this BaseInteractable.
virtual void write(std::ostream &os) const =0
Write a BaseInteractable to an output stream.
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
void setPrescribedAngularVelocity(std::function< Vec3D(double)> prescribedAngularVelocity)
Allows the angular velocity of the infinite mass interactable to be prescribed.
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
void addForce(Vec3D addForce)
Adds an amount to the force on this BaseInteractable.
void setAngularVelocity(const Vec3D &angularVelocity)
set the angular velocity of the BaseInteractble.
void setTorque(Vec3D torque)
Sets the torque on this BaseInteractable.
BaseInteractable()
Default BaseInteractable constructor, it simply creates an empty BaseInteractable.
void integrateAfterForceComputation(double time, double timeStep)
This is part of the integration routine for objects with infinite mass.