MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Species.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 SPECIES_H
27 #define SPECIES_H
28 #include "MixedSpecies.h"
29 #include "ParticleSpecies.h"
33 class BaseInteraction;
34 
126 template<class NormalForceSpecies, class FrictionForceSpecies = EmptyFrictionSpecies, class AdhesiveForceSpecies = EmptyAdhesiveSpecies>
128 {
129 public:
131 
140 
142  Species();
143 
145  Species(const Species &s);
146 
148  virtual ~Species();
149 
154 
159  BaseSpecies* copyMixed() const final;
160 
162  void read(std::istream& is) final;
163 
165  void write(std::ostream& os) const final;
166 
168  std::string getName() const final;
169 
175 
179  bool getUseAngularDOFs() const final;
180 
184  void mixAll(BaseSpecies * const S, BaseSpecies * const T);
185 
187  Mdouble getInteractionDistance() const final;
188 };
189 
191 Species<NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies>::Species()
192 : ParticleSpecies(), NormalForceSpecies(), FrictionForceSpecies(), AdhesiveForceSpecies()
193 {
194 #ifdef DEBUG_CONSTRUCTOR
195  std::cout << "Species::Species() finished" << std::endl;
196 #endif
197 }
198 
202 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
205 {
206 #ifdef DEBUG_CONSTRUCTOR
207  std::cout << "Species::Species(const Species &p) finished" << std::endl;
208 #endif
209 }
210 
211 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
213 {
214 #ifdef DEBUG_DESTRUCTOR
215  std::cout << "Species::~Species() finished" << std::endl;
216 #endif
217 }
218 
226 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
228 ::copy() const
229 {
230  return new Species(*this);
231 }
232 
234 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
236 ::copyMixed() const
237 {
239 }
240 
247 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
249 ::write(std::ostream& os) const
250 {
252  NormalForceSpecies::write(os);
253  FrictionForceSpecies::write(os);
254  AdhesiveForceSpecies::write(os);
255 }
256 
260 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
262 {
264  NormalForceSpecies::read(is);
265  FrictionForceSpecies::read(is);
266  AdhesiveForceSpecies::read(is);
267 }
268 
283 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
285 {
286  return NormalForceSpecies::getBaseName()
287  + FrictionForceSpecies::getBaseName()
288  + AdhesiveForceSpecies::getBaseName() + "Species";
289 }
290 
299 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
301 {
302  return new InteractionType(P, I, timeStamp);
303 }
304 
311 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
313 {
314  return FrictionForceSpecies::getUseAngularDOFs();
315 }
316 
325 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
327 {
328  logger(ERROR, "%::mix() This function should not be called", getName());
329 }
330 
332 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
334 {
335  return AdhesiveForceSpecies::getInteractionDistance();
336 }
337 #endif
void read(std::istream &is) final
Called by SpeciesHandler::readObject.
Definition: Species.h:261
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:44
BaseInteraction * getNewInteraction(BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp) const final
When a contact between two particles is determined, an Interaction object is created, as the type of Interaction depends on the Species type.
Definition: Species.h:300
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Defines a contact force orthogonal to the contact normal.
Interaction< typename NormalForceSpecies::InteractionType, typename FrictionForceSpecies::InteractionType, typename AdhesiveForceSpecies::InteractionType > InteractionType
Definition: Species.h:139
Defines a contact force parallel to the contact normal.
double Mdouble
bool getUseAngularDOFs() const final
Returns true if torques have to be calculated.
Definition: Species.h:312
Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > * copy() const final
Creates a deep copy of the Species from which it is called.
Definition: Species.h:228
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:51
Stores information about interactions between two interactable objects; often particles but could be ...
Mdouble getInteractionDistance() const final
Returns the particle distance below which adhesive forces can occur (needed for contact detection) ...
Definition: Species.h:333
Defines a short-range (non-contact) force parallel to the contact normal, usually adhesive...
Species()
The default constructor.
Definition: Species.h:191
#define UNUSED
Definition: GeneralDefine.h:39
void write(std::ostream &os) const
Writes the species properties to an output stream.
std::string getName() const final
Returns the name of the Species as it is used in the restart file.
Definition: Species.h:284
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > MixedSpeciesType
The correct MixedSpecies type for this Species.
Definition: Species.h:138
void read(std::istream &is)
Reads the species properties from an input stream.
Contains contact force properties for contacts between particles with two different species...
Definition: MixedSpecies.h:40
void mixAll(BaseSpecies *const S, BaseSpecies *const T)
This function should not be called.
Definition: Species.h:326
Defines the basic properties that a interactable object can have.
Contains material and contact force properties.
Definition: Interaction.h:35
void write(std::ostream &os) const final
Writes the Species properties to an output stream.
Definition: Species.h:249
BaseSpecies * copyMixed() const final
Creates a new MixedSpecies with the same force properties as the Species from which it is called...
Definition: Species.h:236
virtual ~Species()
The default destructor.
Definition: Species.h:212
Contains information about the contact between two interactables, BaseInteraction::P_ and BaseInterac...
Definition: Interaction.h:107