MPIInteraction.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #ifndef MPIINTERACTION_H
6 #define MPIINTERACTION_H
7 
15 #include "Logger.h"
16 #include "MpiDataClass.h"
17 
18 template<class NormalForceSpecies, class FrictionForceSpecies, class AdhesiveForceSpecies>
19 class Interaction;
20 
21 //A monster of a template class, but it is rather universal for all interactions, saves a lot of typing
22 //In terms of memory it is not as efficient as declaring a class for every interaction type, this due to extra padding concerning
23 //the empty class. the extra memory used in the transmission is less than 8 bytes per interaction.
24 //Below all is used to create the MPIHistoryInteraction class which is a lean version to the actual interaction, containing only the history parameters
25 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
27 {
28 public:
30 
31  unsigned int P;
32  unsigned int I;
33  unsigned int speciesId;
35  unsigned timeStamp;
38 
39 
40  typename std::conditional<
41  //If true, enable sliding
44 
45  //Friction
46  typename std::conditional<
47  //if true, enable rolling
49 
50  typename std::conditional<
51  //if true, enable torsion
53 
54  //Contact
55  typename std::conditional<
56  //if true, enablel wasInContact
59  ||
61 
62  //Bonded
63  typename std::conditional<
64  //if true, enable bonded
66 
67  //Liquidbridge
68  typename std::conditional<
69  //if true, enable liquidbridgeVolume
71 
72  //MaxOverlap
73  typename std::conditional<
74  //if true, enable max overlap
76 
79 
80  void copyToInteraction(
82  const bool resetPointers);
83 
84  //Sliding
85  template<class DUMMY= FrictionForceInteraction>
89  {
90  slidingSpring = interaction->FrictionForceInteraction::getSlidingSpring();
91  }
92 
93  //Sliding
94  template<class DUMMY= FrictionForceInteraction>
98  {
99  interaction->FrictionForceInteraction::setSlidingSpring(slidingSpring);
100  }
101 
102  //No sliding
103  template<class DUMMY = FrictionForceInteraction>
104  typename std::enable_if<!(std::is_base_of<SlidingFrictionInteraction, DUMMY>::value), void>::type
107  {
108  }
109 
110  //No sliding
111  template<class DUMMY = FrictionForceInteraction>
112  typename std::enable_if<!(std::is_base_of<SlidingFrictionInteraction, DUMMY>::value), void>::type
115  {
116  }
117 
118 
119  //Friction
120  template<class DUMMY= FrictionForceInteraction>
124  {
125  rollingSpring = interaction->FrictionForceInteraction::getRollingSpring();
126  torsionSpring = interaction->FrictionForceInteraction::getTorsionSpring();
127  }
128 
129  //Friction
130  template<class DUMMY= FrictionForceInteraction>
134  {
135  interaction->FrictionForceInteraction::setRollingSpring(rollingSpring);
136  interaction->FrictionForceInteraction::setTorsionSpring(torsionSpring);
137  }
138 
139  //No friction
140  template<class DUMMY = FrictionForceInteraction>
141  typename std::enable_if<!(std::is_base_of<FrictionInteraction, DUMMY>::value), void>::type
144  {
145  }
146 
147  //No friction
148  template<class DUMMY = FrictionForceInteraction>
149  typename std::enable_if<!(std::is_base_of<FrictionInteraction, DUMMY>::value), void>::type
152  {
153  }
154 
155  //Contact
156  template<class DUMMY = AdhesiveForceInteraction>
157  typename std::enable_if<(
163  {
164  wasInContact = interaction->AdhesiveForceInteraction::getWasInContact();
165  }
166 
167  //Contact
168  template<class DUMMY = AdhesiveForceInteraction>
169  typename std::enable_if<(
175  {
176  interaction->AdhesiveForceInteraction::setWasInContact(wasInContact);
177  }
178 
179  //No contact
180  template<class DUMMY = AdhesiveForceInteraction>
181  typename std::enable_if<!(
187  {
188  }
189 
190  //No contact
191  template<class DUMMY = AdhesiveForceInteraction>
192  typename std::enable_if<!(
198  {
199  }
200 
201  //Bonded
202  template<class DUMMY = AdhesiveForceInteraction>
203  typename std::enable_if<(std::is_base_of<BondedInteraction, DUMMY>::value), void>::type
206  {
207  bonded = interaction->AdhesiveForceInteraction::getBonded();
208  }
209 
210  //Bonded
211  template<class DUMMY = AdhesiveForceInteraction>
212  typename std::enable_if<(std::is_base_of<BondedInteraction, DUMMY>::value), void>::type
214  {
215  interaction->AdhesiveForceInteraction::setBonded(bonded);
216  }
217 
218  //No bonded
219  template<class DUMMY = AdhesiveForceInteraction>
220  typename std::enable_if<!(std::is_base_of<BondedInteraction, DUMMY>::value), void>::type
223  {
224  }
225 
226  //No bonded
227  template<class DUMMY = AdhesiveForceInteraction>
228  typename std::enable_if<!(std::is_base_of<BondedInteraction, DUMMY>::value), void>::type
230  {
231  }
232 
233  //Liquidbridge
234  template<class DUMMY = AdhesiveForceInteraction>
238  {
239  liquidbridgeVolume = interaction->AdhesiveForceInteraction::getLiquidBridgeVolume();
240  }
241 
242  //Liquidbridge
243  template<class DUMMY = AdhesiveForceInteraction>
247  {
248  interaction->AdhesiveForceInteraction::setLiquidBridgeVolume(liquidbridgeVolume);
249  }
250 
251  //No Liquidbridge
252  template<class DUMMY = AdhesiveForceInteraction>
256  {
257  }
258 
259  //No Liquidbridge
260  template<class DUMMY = AdhesiveForceInteraction>
264  {
265  }
266 
267  //Max overlap
268  template<class DUMMY = NormalForceInteraction>
272  {
273  maxOverlap = interaction->NormalForceInteraction::getMaxOverlap();
274  }
275 
276  //Max overlap
277  template<class DUMMY = NormalForceInteraction>
281  {
282  interaction->NormalForceInteraction::setMaxOverlap(maxOverlap);
283  }
284 
285  //Max overlap
286  template<class DUMMY = NormalForceInteraction>
290  {
291  }
292 
293  //Max overlap
294  template<class DUMMY = NormalForceInteraction>
298  {
299  }
300 
301 };
302 
303 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
305 {
306 }
307 
308 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
311 {
312  //logger.assert_debug(interaction->getP()->getId(),"Trying to copy an unreal interaction: P is not defined");
313  //logger.assert_debug(interaction->getP()->getId(),"Trying to copy an unreal interaction: I is not defined");
314 
315  if (interaction->getP() == nullptr) logger(WARN, "P is not defined!!");
316  if (interaction->getI() == nullptr) logger(WARN, "I is not defined!!");
317  P = interaction->getP()->getId();
318  I = interaction->getI()->getId();
319 
320  if (dynamic_cast<const BaseParticle*>(interaction->getI()) == nullptr)
321  {
322  isWallInteraction = true;
323  }
324  else
325  {
326  isWallInteraction = false;
327  }
328 
329  timeStamp = interaction->getTimeStamp();
330  force = interaction->getForce();
331  torque = interaction->getTorque();
332  getSlidingSpring(interaction);
333  getFrictionSprings(interaction);
334  getWasInContact(interaction);
335  getBonded(interaction);
336  getLiquidBridge(interaction);
337  getMaximumOverlap(interaction);
338 }
339 
340 
341 template<class NormalForceInteraction, class FrictionForceInteraction, class AdhesiveForceInteraction>
344  const bool resetPointers)
345 {
346  //Basic interaction values
347  BaseInteraction* basicInteraction = static_cast<BaseInteraction*>(interaction);
348  basicInteraction->setBasicMPIInteractionValues(P, I, timeStamp, force, torque, isWallInteraction, resetPointers);
349 
350  //Specific history interaction values, interaction type denpendent
351  setSlidingSpring(interaction);
352  setFrictionSprings(interaction);
353  setWasInContact(interaction);
354  setBonded(interaction);
355  setLiquidBridge(interaction);
356  setMaximumOverlap(interaction);
357 }
358 
359 
360 #endif
double Mdouble
Definition: GeneralDefine.h:13
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
LL< Log::WARN > WARN
Warning log level.
Definition: Logger.cc:33
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:39
void setBasicMPIInteractionValues(int P, int I, unsigned timeStamp, Vec3D force, Vec3D torque, bool isWallInteraction, bool resetPointers)
Definition: BaseInteraction.cc:944
const Vec3D & getForce() const
Gets the current force (vector) between the two interacting objects.
Definition: BaseInteraction.h:189
const Vec3D & getTorque() const
Gets the current torque (vector) between the two interacting objects.
Definition: BaseInteraction.h:197
Mdouble getTimeStamp() const
Returns an Mdouble which is the time stamp of the interaction.
Definition: BaseInteraction.h:298
BaseInteractable * getI()
Returns a pointer to the second object involved in the interaction (often a wall or a particle).
Definition: BaseInteraction.h:264
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
Definition: BaseInteraction.h:253
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:104
Definition: BaseParticle.h:33
Data class to send an empty class over MPI.
Definition: MpiDataClass.h:110
Contains information about the contact between two interactables, BaseInteraction::P_ and BaseInterac...
Definition: Interaction.h:95
Definition: MPIInteraction.h:27
bool isWallInteraction
Definition: MPIInteraction.h:34
unsigned int P
Definition: MPIInteraction.h:31
std::enable_if<(std::is_base_of< BondedInteraction, DUMMY >::value), void >::type getBonded(const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:204
std::enable_if< std::is_base_of< FrictionInteraction, DUMMY >::value, void >::type getFrictionSprings(const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:122
unsigned timeStamp
Definition: MPIInteraction.h:35
Vec3D torque
Definition: MPIInteraction.h:37
std::enable_if<(std::is_base_of< LinearPlasticViscoelasticInteraction, DUMMY >::value), void >::type setMaximumOverlap(Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:279
std::enable_if< std::is_base_of< SlidingFrictionInteraction, DUMMY >::value, void >::type setSlidingSpring(Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:96
void copyToInteraction(Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction, const bool resetPointers)
Definition: MPIInteraction.h:342
std::enable_if<(std::is_base_of< BondedInteraction, DUMMY >::value), void >::type setBonded(Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:213
std::enable_if<(std::is_base_of< LiquidMigrationWilletInteraction, DUMMY >::value||std::is_base_of< LiquidBridgeWilletInteraction, DUMMY >::value||std::is_base_of< IrreversibleAdhesiveInteraction, DUMMY >::value), void >::type setWasInContact(Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:173
std::enable_if<!(std::is_base_of< LiquidMigrationWilletInteraction, DUMMY >::value), void >::type getLiquidBridge(const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:254
std::conditional< std::is_base_of< FrictionInteraction, FrictionForceInteraction >::value, Vec3D, Empty >::type rollingSpring
Definition: MPIInteraction.h:48
std::enable_if<(std::is_base_of< LiquidMigrationWilletInteraction, DUMMY >::value), void >::type setLiquidBridge(Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:245
Vec3D force
Definition: MPIInteraction.h:36
std::enable_if<!(std::is_base_of< LinearPlasticViscoelasticInteraction, DUMMY >::value), void >::type getMaximumOverlap(const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:288
std::enable_if<!(std::is_base_of< FrictionInteraction, DUMMY >::value), void >::type getFrictionSprings(const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:142
std::enable_if<!(std::is_base_of< LinearPlasticViscoelasticInteraction, DUMMY >::value), void >::type setMaximumOverlap(Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:296
std::enable_if<!(std::is_base_of< FrictionInteraction, DUMMY >::value), void >::type setFrictionSprings(Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:150
std::conditional< std::is_base_of< FrictionInteraction, FrictionForceInteraction >::value, Vec3D, Empty >::type torsionSpring
Definition: MPIInteraction.h:52
std::enable_if<!(std::is_base_of< SlidingFrictionInteraction, DUMMY >::value), void >::type getSlidingSpring(const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:105
std::conditional< std::is_base_of< SlidingFrictionInteraction, FrictionForceInteraction >::value, Vec3D, Empty >::type slidingSpring
Definition: MPIInteraction.h:43
std::conditional< std::is_base_of< BondedInteraction, AdhesiveForceInteraction >::value, bool, Empty >::type bonded
Definition: MPIInteraction.h:65
std::conditional<(std::is_base_of< LiquidMigrationWilletInteraction, AdhesiveForceInteraction >::value||std::is_base_of< LiquidBridgeWilletInteraction, AdhesiveForceInteraction >::value||std::is_base_of< IrreversibleAdhesiveInteraction, AdhesiveForceInteraction >::value), bool, Empty >::type wasInContact
Definition: MPIInteraction.h:60
void copyFromInteraction(const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:309
std::enable_if<!(std::is_base_of< LiquidMigrationWilletInteraction, DUMMY >::value||std::is_base_of< LiquidBridgeWilletInteraction, DUMMY >::value||std::is_base_of< IrreversibleAdhesiveInteraction, DUMMY >::value), void >::type getWasInContact(const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:185
unsigned int speciesId
Definition: MPIInteraction.h:33
std::enable_if< std::is_base_of< SlidingFrictionInteraction, DUMMY >::value, void >::type getSlidingSpring(const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:87
std::conditional< std::is_base_of< LinearPlasticViscoelasticInteraction, NormalForceInteraction >::value, Mdouble, Empty >::type maxOverlap
Definition: MPIInteraction.h:75
std::enable_if<(std::is_base_of< LiquidMigrationWilletInteraction, DUMMY >::value||std::is_base_of< LiquidBridgeWilletInteraction, DUMMY >::value||std::is_base_of< IrreversibleAdhesiveInteraction, DUMMY >::value), void >::type getWasInContact(const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:161
std::enable_if<(std::is_base_of< LinearPlasticViscoelasticInteraction, DUMMY >::value), void >::type getMaximumOverlap(const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:270
std::enable_if<!(std::is_base_of< LiquidMigrationWilletInteraction, DUMMY >::value), void >::type setLiquidBridge(Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:262
std::enable_if< std::is_base_of< FrictionInteraction, DUMMY >::value, void >::type setFrictionSprings(Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:132
std::enable_if<!(std::is_base_of< LiquidMigrationWilletInteraction, DUMMY >::value||std::is_base_of< LiquidBridgeWilletInteraction, DUMMY >::value||std::is_base_of< IrreversibleAdhesiveInteraction, DUMMY >::value), void >::type setWasInContact(Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:196
unsigned int I
Definition: MPIInteraction.h:32
std::enable_if<(std::is_base_of< LiquidMigrationWilletInteraction, DUMMY >::value), void >::type getLiquidBridge(const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:236
std::enable_if<!(std::is_base_of< BondedInteraction, DUMMY >::value), void >::type getBonded(const Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:221
MPIInteraction()
Definition: MPIInteraction.h:304
std::enable_if<!(std::is_base_of< SlidingFrictionInteraction, DUMMY >::value), void >::type setSlidingSpring(Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:113
std::conditional< std::is_base_of< LiquidMigrationWilletInteraction, AdhesiveForceInteraction >::value, Mdouble, Empty >::type liquidbridgeVolume
Definition: MPIInteraction.h:70
std::enable_if<!(std::is_base_of< BondedInteraction, DUMMY >::value), void >::type setBonded(Interaction< NormalForceInteraction, FrictionForceInteraction, AdhesiveForceInteraction > *interaction)
Definition: MPIInteraction.h:229
Definition: Kernel/Math/Vector.h:30
#define I
Definition: main.h:127
squared absolute value
Definition: GlobalFunctions.h:87
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:77
type
Definition: compute_granudrum_aor.py:141