MercuryDPM  Trunk
 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-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 #ifndef SPECIES_H
27 #define SPECIES_H
28 
29 #include "MixedSpecies.h"
30 #include "ParticleSpecies.h"
34 
35 class BaseInteraction;
36 
128 template<class NormalForceSpecies, class FrictionForceSpecies = EmptyFrictionSpecies, class AdhesiveForceSpecies = EmptyAdhesiveSpecies>
129 class Species final
131 {
132 public:
134 
143 
144 
146  Species();
147 
149  Species(const Species& s);
150 
152  virtual ~Species();
153 
158 
162  void copyInto(BaseSpecies* bs) const final;
163 
168  BaseSpecies* copyMixed() const final;
169 
171  void read(std::istream& is) final;
172 
174  void write(std::ostream& os) const final;
175 
177  std::string getName() const final;
178 
184  getNewInteraction(BaseInteractable* const P, BaseInteractable* const I, unsigned timeStamp) const final;
185 
186  //used to create a dummy for MPI purposes (I need a prototype of the interaction)
187  BaseInteraction* getEmptyInteraction() const final;
188 
189  void deleteEmptyInteraction(BaseInteraction* interaction) const final;
190 
194  bool getUseAngularDOFs() const final;
195 
199  void mixAll(BaseSpecies* const S, BaseSpecies* const T);
200 
201 };
202 
204 Species<NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies>::Species()
205  : ParticleSpecies(this,this,this), NormalForceSpecies(), FrictionForceSpecies(), AdhesiveForceSpecies()
206 {
207  logger(DEBUG, "Species::Species() finished");
208 }
209 
213 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
216 {
217  normalForce_ = this;
218  frictionForce_ = this;
219  adhesiveForce_ = this;
223  logger(DEBUG, "Species::Species(const Species &p) finished");
224 }
225 
226 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
228 {
229  logger(DEBUG, "Species::~Species() finished");
230 }
231 
239 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
242 ::copy() const
243 {
244  return new Species(*this);
245 }
246 
248 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
250 ::copyMixed() const
251 {
253 }
254 
264 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
267 {
268  if (bs == nullptr)
269  {
270  logger(WARN, "Error in %::copyInto: cannot copy into a nullptr");
271  return;
272  }
274  if (s == nullptr)
275  {
276  logger(WARN, "Error in %::copyInto: copying of % failed", getName(), s->getName());
277  return;
278  }
279  *s = *this;
280 }
281 
288 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
290 ::write(std::ostream& os) const
291 {
293  NormalForceSpecies::write(os);
294  FrictionForceSpecies::write(os);
295  AdhesiveForceSpecies::write(os);
296 }
297 
301 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
303 {
305  NormalForceSpecies::read(is);
306  FrictionForceSpecies::read(is);
307  AdhesiveForceSpecies::read(is);
308 }
309 
324 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
326 {
327  return NormalForceSpecies::getBaseName()
328  + FrictionForceSpecies::getBaseName()
329  + AdhesiveForceSpecies::getBaseName() + "Species";
330 }
331 
340 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
343  BaseInteractable* const I,
344  unsigned timeStamp) const
345 {
346  return new InteractionType(P, I, timeStamp);
347 }
348 
349 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
351 {
353 }
354 
355 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
357  BaseInteraction* interaction) const
358 {
361  delete interactionDestroyer;
362 }
363 
370 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
372 {
373  return FrictionForceSpecies::getUseAngularDOFs();
374 }
375 
384 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
386  BaseSpecies* const T UNUSED)
387 {
388  logger(ERROR, "%::mix() This function should not be called", getName());
389 }
390 
391 #endif
std::string getName(int argc, char *argv[])
extracts the file name from the command line input
void setBaseSpecies(BaseSpecies *baseSpecies)
Definition: BaseForce.h:40
void read(std::istream &is) final
Called by SpeciesHandler::readAndAddObject.
Definition: Species.h:302
Interaction< typename NormalForceSpecies::InteractionType, typename FrictionForceSpecies::InteractionType, typename AdhesiveForceSpecies::InteractionType > InteractionType
Definition: Species.h:142
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:49
BaseNormalForce * normalForce_
A pointer to the normal force parameters This pointer is used by the Interaction's to get a pointer ...
Definition: BaseSpecies.h:173
LL< Log::DEBUG > DEBUG
Debug information.
Definition: Logger.cc:58
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Defines a contact force orthogonal to the contact normal.
void copyInto(BaseSpecies *bs) const final
Definition: Species.h:266
Defines a contact force parallel to the contact normal.
bool getUseAngularDOFs() const final
Returns true if torques have to be calculated.
Definition: Species.h:371
Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > * copy() const final
Creates a deep copy of the Species from which it is called.
Definition: Species.h:242
BaseAdhesiveForce * adhesiveForce_
A pointer to the adhesive force parameters This pointer is used by the Interaction's to get a pointe...
Definition: BaseSpecies.h:187
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:53
Stores information about interactions between two interactable objects; often particles but could be ...
Defines a short-range (non-contact) force parallel to the contact normal, usually adhesive...
Species()
The default constructor.
Definition: Species.h:204
LL< Log::WARN > WARN
Warning log level.
Definition: Logger.cc:54
void deleteEmptyInteraction(BaseInteraction *interaction) const final
Definition: Species.h:356
#define UNUSED
Definition: GeneralDefine.h:39
std::string getName() const final
Returns the name of the Species as it is used in the restart file.
Definition: Species.h:325
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > MixedSpeciesType
The correct MixedSpecies type for this Species.
Definition: Species.h:141
BaseInteraction * getEmptyInteraction() const final
Definition: Species.h:350
Contains contact force properties for contacts between particles with two different species...
Definition: MixedSpecies.h:42
BaseFrictionForce * frictionForce_
A pointer to the friction force parameters This pointer is used by the Interaction's to get a pointe...
Definition: BaseSpecies.h:180
void mixAll(BaseSpecies *const S, BaseSpecies *const T)
This function should not be called.
Definition: Species.h:385
Defines the basic properties that a interactable object can have.
BaseInteraction * getNewInteraction(BaseInteractable *const P, BaseInteractable *const I, unsigned 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:342
Contains material and contact force properties.
Definition: Interaction.h:42
void write(std::ostream &os) const override
Writes the species properties to an output stream.
void write(std::ostream &os) const final
Writes the Species properties to an output stream.
Definition: Species.h:290
BaseSpecies * copyMixed() const final
Creates a new MixedSpecies with the same force properties as the Species from which it is called...
Definition: Species.h:250
virtual ~Species()
The default destructor.
Definition: Species.h:227
Contains information about the contact between two interactables, BaseInteraction::P_ and BaseInterac...
Definition: Interaction.h:115
void read(std::istream &is) override
Reads the species properties from an input stream.