Species.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, 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 
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)
188 
189  void deleteEmptyInteraction(BaseInteraction* interaction) const final;
190 
194  bool getUseAngularDOFs() const final;
195 
199  void mixAll(BaseSpecies* const S, BaseSpecies* const T) final;
200 
201  void actionsAfterTimeStep(BaseParticle* particle) const final {
202  NormalForceSpecies::actionsAfterTimeStep(particle);
203  }
204 };
205 
206 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
209 {
210  logger(DEBUG, "Species::Species() finished");
211 }
212 
216 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
219 {
220  normalForce_ = this;
221  frictionForce_ = this;
222  adhesiveForce_ = this;
226  logger(DEBUG, "Species::Species(const Species &p) finished");
227 }
228 
229 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
231 {
232  logger(DEBUG, "Species::~Species() finished");
233 }
234 
242 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
245 ::copy() const
246 {
247  return new Species(*this);
248 }
249 
251 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
253 ::copyMixed() const
254 {
256 }
257 
267 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
270 {
271  if (bs == nullptr)
272  {
273  logger(WARN, "Error in %::copyInto: cannot copy into a nullptr");
274  return;
275  }
277  if (s == nullptr)
278  {
279  logger(WARN, "Error in %::copyInto: copying of species failed", getName());
280  return;
281  }
282  *s = *this;
283 }
284 
291 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
293 ::write(std::ostream& os) const
294 {
296  NormalForceSpecies::write(os);
297  FrictionForceSpecies::write(os);
298  AdhesiveForceSpecies::write(os);
299 }
300 
304 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
306 {
308  NormalForceSpecies::read(is);
309  FrictionForceSpecies::read(is);
310  AdhesiveForceSpecies::read(is);
311 }
312 
327 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
329 {
330  return NormalForceSpecies::getBaseName()
331  + FrictionForceSpecies::getBaseName()
332  + AdhesiveForceSpecies::getBaseName() + "Species";
333 }
334 
343 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
346  BaseInteractable* const I,
347  unsigned timeStamp) const
348 {
349  return new InteractionType(P, I, timeStamp);
350 }
351 
352 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
354 {
356 }
357 
358 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
360  BaseInteraction* interaction) const
361 {
364  delete interactionDestroyer;
365 }
366 
373 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
375 {
376  return FrictionForceSpecies::getUseAngularDOFs();
377 }
378 
387 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
389  BaseSpecies* const T UNUSED)
390 {
391  logger(ERROR, "%::mix() This function should not be called", getName());
392 }
393 
394 #endif
std::string getName(int argc, char *argv[])
Definition: CombineParallelDataFiles.cpp:12
#define UNUSED
Definition: GeneralDefine.h:39
LL< Log::DEBUG > DEBUG
Debug information.
Definition: Logger.cc:58
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:53
LL< Log::WARN > WARN
Warning log level.
Definition: Logger.cc:54
@ DEBUG
Defines a short-range (non-contact) force parallel to the contact normal, usually adhesive.
void setBaseSpecies(BaseSpecies *baseSpecies)
Definition: BaseForce.h:40
Defines the basic properties that a interactable object can have.
Definition: BaseInteractable.h:55
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:60
Definition: BaseParticle.h:54
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:50
BaseAdhesiveForce * adhesiveForce_
A pointer to the adhesive force parameters \detail This pointer is used by the Interaction's to get a...
Definition: BaseSpecies.h:187
BaseFrictionForce * frictionForce_
A pointer to the friction force parameters \detail This pointer is used by the Interaction's to get a...
Definition: BaseSpecies.h:180
BaseNormalForce * normalForce_
A pointer to the normal force parameters \detail This pointer is used by the Interaction's to get a p...
Definition: BaseSpecies.h:173
In case one doesn't want to have an adhesive (short range non contact) interaction between the intera...
Definition: EmptyAdhesiveInteraction.h:45
Defines a contact force orthogonal to the contact normal.
Contains information about the contact between two interactables, BaseInteraction::P_ and BaseInterac...
Definition: Interaction.h:116
Contains contact force properties for contacts between particles with two different species.
Definition: MixedSpecies.h:43
Defines a contact force parallel to the contact normal.
Definition: ParticleSpecies.h:37
void write(std::ostream &os) const override
Writes the species properties to an output stream.
Definition: ParticleSpecies.cc:77
void read(std::istream &is) override
Reads the species properties from an input stream.
Definition: ParticleSpecies.cc:89
Contains material and contact force properties.
Definition: Species.h:35
void write(std::ostream &os) const final
Writes the Species properties to an output stream.
Definition: Species.h:293
void mixAll(BaseSpecies *const S, BaseSpecies *const T) final
This function should not be called.
Definition: Species.h:388
BaseSpecies * copyMixed() const final
Creates a new MixedSpecies with the same force properties as the Species from which it is called.
Definition: Species.h:253
virtual ~Species()
The default destructor.
Definition: Species.h:230
void actionsAfterTimeStep(BaseParticle *particle) const final
Definition: Species.h:201
BaseInteraction * getEmptyInteraction() const final
Definition: Species.h:353
MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > MixedSpeciesType
The correct MixedSpecies type for this Species.
Definition: Species.h:141
void copyInto(BaseSpecies *bs) const final
Definition: Species.h:269
bool getUseAngularDOFs() const final
Returns true if torques have to be calculated.
Definition: Species.h:374
Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies > * copy() const final
Creates a deep copy of the Species from which it is called.
Definition: Species.h:245
Interaction< typename NormalForceSpecies::InteractionType, typename FrictionForceSpecies::InteractionType, typename AdhesiveForceSpecies::InteractionType > InteractionType
Definition: Species.h:142
Species()
The default constructor.
Definition: Species.h:207
void deleteEmptyInteraction(BaseInteraction *interaction) const final
Definition: Species.h:359
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,...
Definition: Species.h:345
Species(const Species &s)
The default copy constructor.
Definition: Species.h:217
void read(std::istream &is) final
Called by SpeciesHandler::readAndAddObject.
Definition: Species.h:305
std::string getName() const final
Returns the name of the Species as it is used in the restart file.
Definition: Species.h:328
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:73