MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseParticle.cc
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 #include "BaseParticle.h"
27 #include "DPMBase.h"
28 
35 {
36  handler_ = nullptr;
38  radius_ = 1.0;
39  invMass_ = 1.0;
40  invInertia_ = MatrixSymmetric3D(1, 0, 0, 1, 0, 1);
41 
42  periodicFromParticle_ = nullptr;
43  isMPIParticle_ = false;
44  isInMPIDomain_ = false;
45  isInPeriodicDomain_ = false;
47  isMaserParticle_ = false;
49  periodicComplexity_ = std::vector<int>(0);
50  previousPeriodicComplexity_ = std::vector<int>(0);
51 #ifdef CONTACT_LIST_HGRID
52  firstPossibleContact = nullptr;
53 #endif
54  hGridNextObject_ = nullptr;
55  hGridPrevObject_ = nullptr;
56 
57  hGridCell.setHGridLevel(99999);
58  hGridCell.setHGridX(99999);
59  hGridCell.setHGridY(99999);
60  hGridCell.setHGridZ(99999);
61 
62  info_ = std::numeric_limits<double>::quiet_NaN();
63 
64  logger(DEBUG, "BaseParticle::BaseParticle() finished");
65 }
66 
76  : BaseInteractable(p)
77 {
78  handler_ = nullptr;
80  radius_ = p.radius_;
81  invMass_ = p.getInvMass();
83 
84  hGridNextObject_ = nullptr;
85  hGridPrevObject_ = nullptr;
86 
88  hGridCell.setHGridX(99999);
89  hGridCell.setHGridY(99999);
90  hGridCell.setHGridZ(99999);
91 
99  //periodicComplexity_ = p.periodicComplexity_;
100  //previousPeriodicComplexity_ = p.previousPeriodicComplexity_;
101 #ifdef CONTACT_LIST_HGRID
102  firstPossibleContact = nullptr;
103 #endif
104 
105  info_ = p.info_;
106  logger(DEBUG, "BaseParticle::BaseParticle(BaseParticle &p) finished");
107 }
108 
110  : BaseParticle()
111 {
112  setSpecies(s);
113 #ifdef CONTACT_LIST_HGRID
114  firstPossibleContact = nullptr;
115 #endif
116  logger(DEBUG, "BaseParticle::BaseParticle(BaseSpecies &s) finished");
117 }
118 
124 {
125 
126  if (getHandler() != nullptr)
127  {
129  if (isFixed())
131  }
132  logger(DEBUG, "BaseParticle::~BaseParticle() of particle % finished.", getId());
133 
134 }
135 
142 {
143  if (handler_ == nullptr)
144  {
145  logger(ERROR, "[BaseParticle::getVolume] no particle handler specified");
146  return 0;
147  }
148  switch (getParticleDimensions())
149  {
150  case 3:
151  return (4.0 / 3.0 * constants::pi * radius_ * radius_ * radius_);
152  case 2:
153  return (constants::pi * radius_ * radius_);
154  case 1:
155  return (2.0 * radius_);
156  default:
157  logger(ERROR, "[BaseParticle::getVolume] dimension of the particle is not set");
158  return 0;
159  }
160 }
161 
166 {
167  invMass_ = 0.0;
168  invInertia_ = MatrixSymmetric3D(0, 0, 0, 0, 0, 0);
169  setVelocity(Vec3D(0.0, 0.0, 0.0));
170  setAngularVelocity(Vec3D(0.0, 0.0, 0.0));
171  if (getHandler())
173 }
174 
176 {
177  //make mpi-dependent so the compiler can optimise
178 #ifdef MERCURY_USE_MPI
179  return isMPIParticle_;
180 #else
181  return false;
182 #endif
183 }
184 
186 {
187  isMPIParticle_ = flag;
188 }
189 
191 {
192  communicationComplexity_ = complexity;
193 }
194 
196 {
198 }
199 
200 void BaseParticle::setPeriodicComplexity(std::vector<int> complexity)
201 {
202  periodicComplexity_ = complexity;
203 }
204 
205 
206 void BaseParticle::setPeriodicComplexity(int index, int value)
207 {
208  //hack: generally you'd add particles after declaring the boundaries
209  //but no official programming guildelines rules have been setup for that
210  //So incase that doesnt happen we need to resize this periodicComplexity
211  if (periodicComplexity_.empty())
212  {
213  int numberOfPeriodicBoundaries = getHandler()->getDPMBase()->periodicBoundaryHandler.getSize();
214  if (numberOfPeriodicBoundaries > 0)
215  {
216  //First initialisation of the periodic complexity assumes the particle is completely
217  //within the real domain
218  periodicComplexity_ = std::vector<int>(numberOfPeriodicBoundaries, 2);
219  }
220  }
221 
222  periodicComplexity_[index] = value;
223 }
224 
225 const std::vector<int>& BaseParticle::getPeriodicComplexity()
226 {
227  //TODO resolve this hack
228  //hack: generally you'd add particles after declaring the boundaries
229  //but no official programming guildelines rules have been setup for that
230  //So incase that doesnt happen we need to resize this periodicComplexity
231  if (periodicComplexity_.empty())
232  {
233  const unsigned numberOfPeriodicBoundaries = getHandler()->getDPMBase()->periodicBoundaryHandler.getSize();
234  if (numberOfPeriodicBoundaries > 0)
235  {
236  periodicComplexity_.resize(numberOfPeriodicBoundaries, 0);
237  }
238  }
239  return periodicComplexity_;
240 }
241 
243 {
244  //hack: generally you'd add particles after declaring the boundaries
245  //but no official programming guildelines rules have been setup for that
246  //So incase that doesnt happen we need to resize this periodicComplexity
248  if (periodicComplexity_.empty())
249  {
250  const unsigned numberOfPeriodicBoundaries = getHandler()->getDPMBase()->periodicBoundaryHandler.getSize();
251  if (numberOfPeriodicBoundaries > 0)
252  {
253  periodicComplexity_.resize(numberOfPeriodicBoundaries, 0);
254  }
255  }
256 
257  return periodicComplexity_[index];
258 }
259 
260 void BaseParticle::setPreviousPeriodicComplexity(std::vector<int> complexity)
261 {
262  previousPeriodicComplexity_ = complexity;
263 }
264 
265 const std::vector<int>& BaseParticle::getPreviousPeriodicComplexity() const
266 {
268 }
269 
271 {
272  return isInMPIDomain_;
273 }
274 
276 {
277  isInMPIDomain_ = flag;
278 }
279 
280 
282 {
283  return isInPeriodicDomain_;
284 }
285 
287 {
288  isInPeriodicDomain_ = flag;
289 }
290 
292 {
294 }
295 
297 {
299 }
300 
302 {
303  return isMaserParticle_;
304 }
305 
307 {
308  isMaserParticle_ = flag;
309 }
310 
317 {
318  invMass_ = 1.0;
319  getSpecies()->computeMass(this);
320  if (getHandler())
322 }
323 
330 void BaseParticle::write(std::ostream& os) const
331 {
333  os << " radius " << radius_
334  << " invMass " << invMass_;
335  //invMass_ is a computed value, but needs to be stored to see if a particle is fixed
336 }
337 
342 std::string BaseParticle::getName() const
343 {
344  return "BaseParticle";
345 }
346 
348 {
349  info_ = info;
350 }
351 
353 {
354  if (std::isnan(info_))
355  return getSpecies()->getId();
356  else
357  return info_;
358 }
359 
368 void BaseParticle::read(std::istream& is)
369 {
371  std::string dummy;
372  is >> dummy >> radius_ >> dummy >> invMass_;// >> dummy >> invInertia_;
373 }
374 
380 void BaseParticle::oldRead(std::istream& is)
381 {
382  logger(DEBUG, "reading particle old-style");
383  static unsigned int id = 0;
384  unsigned int indSpecies = 0;
385  unsigned int numberOfContacts = 0;
386  Vec3D orientation;
387  Vec3D position;
388  Vec3D velocity;
389  Vec3D angularVelocity;
390  double invInertiaScalar;
391  double dummy = 0;
392  is >> position >> velocity >> radius_ >> orientation >> angularVelocity;
393  is >> invMass_ >> invInertiaScalar >> numberOfContacts;
395  for (unsigned int i = 0; i < 12 * numberOfContacts; ++i)
396  {
397  is >> dummy;
398  }
399  is >> indSpecies;
400  setPosition(position);
401  setVelocity(velocity);
402  Quaternion q;
403  q.setEuler(orientation);
404  setOrientation(q);
405  setAngularVelocity(angularVelocity);
406  invInertia_.XX = invInertiaScalar;
407  invInertia_.YY = invInertiaScalar;
408  invInertia_.ZZ = invInertiaScalar;
410  setId(id);
411  setIndex(id);
412  id++;
413 }
414 
420 void BaseParticle::printHGrid(std::ostream& os) const
421 {
422  os << "Particle( HGRID_Level:" << hGridCell.getHGridLevel()
423  << ", HGRID_x:" << hGridCell.getHGridX()
424  << ", HGRID_y:" << hGridCell.getHGridY()
425  << ", HGRID_z:" << hGridCell.getHGridZ()
426  << ")";
427 }
428 
429 #ifdef CONTACT_LIST_HGRID
430 
434 PossibleContact* BaseParticle::getFirstPossibleContact() const
435 {
436  return firstPossibleContact;
437 }
438 #endif
439 
445 {
446  if (isFixed())
447  return 0.0;
448  else
449  return 0.5 * getMass() * getVelocity().getLengthSquared();
450 }
451 
453 {
454  if (isFixed())
455  return 0.0;
456  else
458 }
459 
464 const Vec3D
466  Mdouble t) const
467 {
469  if (xmax > xmin && fabs(disp.X) > .5 * (xmax - xmin))
470  {
471  if (disp.X > 0)
472  disp.X -= xmax - xmin;
473  else
474  disp.X += xmax - xmin;
475  }
476  if (ymax > ymin && fabs(disp.Y) > .5 * (ymax - ymin))
477  {
478  if (disp.Y > 0)
479  disp.Y -= ymax - ymin;
480  else
481  disp.Y += ymax - ymin;
482  }
483  if (zmax > zmin && fabs(disp.Z) > .5 * (zmax - zmin))
484  {
485  if (disp.Z > 0)
486  disp.Z -= zmax - zmin;
487  else
488  disp.Z += zmax - zmin;
489  }
490  disp /= t;
491  return disp;
492 }
493 
498 {
499 
500 }
501 
507 {
509 }
510 
512 {
513  invInertia_ = inverseInertia;
514 }
515 
521 {
523 } //> i.e. no rotations
524 
528 #ifdef CONTACT_LIST_HGRID
529 
530 void BaseParticle::setFirstPossibleContact(PossibleContact* PC)
531 {
532  firstPossibleContact = PC;
533 }
534 #endif
535 
543 {
544  radius_ = radius;
545  if (getHandler())
546  {
547  getSpecies()->computeMass(this);
548  getHandler()->checkExtrema(this);
549  }
550 }
551 
557 {
558  logger(WARN, "WARNING: Do not use particle->setMass, instead use "
559  "particleSpecies->computeMass, since this function can cause "
560  "inconsistencies between the mass, density and radius of this particle!");
561  logger.assert_always(mass > 0.0 && !isFixed(),
562  "Error in BaseParticle::setMass, the given mass to be set must be positive.");
563 
564  invMass_ = 1.0 / mass;
565 }
566 
568 {
570 }
571 
572 
578 {
579  if (mass > 0.0 && !isFixed())
580  {
581  invMass_ = 1.0 / mass;
582  }
583  else
584  {
585  logger(ERROR, "Error in BaseParticle::setMass, the given mass to be set must be positive.");
586  }
587 }
588 
594 {
595  displacement_ = disp;
596 }
597 
603 {
604  previousPosition_ = pos;
605 }
606 
612 void BaseParticle::movePrevious(const Vec3D& posMove)
613 {
614  previousPosition_ += posMove;
615 }
616 
623 {
624  addVelocity(vel);
625 }
626 
633 {
634  addAngularVelocity(angVel);
635 }
636 
642 {
643  displacement_ += addDisp;
644 }
645 
652 {
653  handler_ = handler;
654  setSpecies(getHandler()->getDPMBase()->speciesHandler.getObject(getIndSpecies()));
655 }
656 
662 {
663  return handler_;
664 }
665 
679  InteractionHandler* const interactionHandler)
680 {
681  //get the normal (from P away from the contact)
682  const Vec3D branchVector = P->getPosition() - getPosition();
683  //Get the square of the distance between particle i and particle j
684  const Mdouble distanceSquared = Vec3D::getLengthSquared(branchVector);
685  //const auto species = interactionHandler->getDPMBase()->speciesHandler.getMixedObject(getSpecies(),P->getSpecies());
686  const Mdouble sumOfInteractionRadii = getSumOfInteractionRadii(P);
687  if (distanceSquared >= sumOfInteractionRadii * sumOfInteractionRadii) {
688  return nullptr;
689  }
690  BaseInteraction* const C = interactionHandler->getInteraction(P, this, timeStamp);
691  const Mdouble distance = std::sqrt(distanceSquared);
692  C->setNormal(branchVector / distance);
693  C->setOverlap(P->getRadius() + getRadius() - distance);
694  C->setDistance(distance);
695  C->setContactPoint(P->getPosition() - (P->getRadius() - 0.5 * C->getOverlap()) * C->getNormal());
697  //Mdouble ratio=P->getRadius()/(getRadius()+P->getRadius());
698  //C->setContactPoint(P->getPosition() - (P->getRadius() - ratio * C->getOverlap()) * C->getNormal());
699  return C;
700 }
701 
708 void BaseParticle::integrateBeforeForceComputation(double time, double timeStep)
709 {
714  if (getInvMass() == 0.0)
715  {
717  }
718  else
719  {
720 #ifdef MERCURY_USE_MPI
721  //For periodic particles in parallel the previous position is required
723 #endif
724  accelerate(getForce() * getInvMass() * 0.5 * timeStep);
725  const Vec3D displacement = getVelocity() * timeStep;
726  move(displacement);
727  DPMBase* const dpm = getHandler()->getDPMBase();
728  if (!dpm->getHGridUpdateEachTimeStep())
729  {
730  dpm->hGridUpdateMove(this, displacement.getLengthSquared());
731  }
732  if (dpm->getRotation())
733  {
735  getOrientation().rotateInverseInertiaTensor(getInvInertia()) * getTorque() * 0.5 * timeStep);
736  //apply to rotation quaternion q: q = normalise(q + \tilde{C}\omega*timeStep) (see Wouter's notes)
737  rotate(getAngularVelocity() * timeStep);
738  }
739  }
740 }
741 
748 void BaseParticle::integrateAfterForceComputation(double time, double timeStep)
749 {
750  if (getInvMass() == 0.0)
751  {
752  //Updates a baseParticle with a prescribed motion
754  }
755  else
756  {
757  accelerate(getForce() * getInvMass() * 0.5 * timeStep);
758  if (getHandler()->getDPMBase()->getRotation())
759  {
761  getOrientation().rotateInverseInertiaTensor(getInvInertia()) * getTorque() * 0.5 * timeStep);
762  }
763  }
764 }
765 
771 {
773 }
774 
780 void BaseParticle::setIndSpecies(unsigned int indSpecies)
781 {
782  if (handler_ != nullptr)
783  {
784  //BaseInteractable::setIndSpecies(indSpecies);
787  }
788  else
789  {
791  logger(ERROR, "setIndSpecies called on a particle with no particle handler.\n"
792  "Therefore I can't request the given species from the species handler.\n"
793  " PartID = %", getId());
794  }
795 }
796 
805 {
808  //set pointer to the ParticleHandler handler_, which is needed to retrieve
809  //species information
810  //\todo maybe these if statements should throw warnings
811  if (handler_ == nullptr)
812  {
813  SpeciesHandler* sH = species->getHandler();
814  DPMBase* dB = sH->getDPMBase();
815  if (dB != nullptr)
816  {
818  }
819  }
820 }
821 
823 {
824  return 0;
825 }
826 
827 std::string BaseParticle::getTypeVTK(unsigned i) const
828 {
829  return "";
830 }
831 
832 std::string BaseParticle::getNameVTK(unsigned i) const
833 {
834  return "";
835 }
836 
837 std::vector<Mdouble> BaseParticle::getFieldVTK(unsigned i) const
838 {
839  return std::vector<Mdouble>();
840 }
841 
843 { return Vec3D(0, 0, 0); }
844 
846 { return 0; }
847 
849 { return 0; }
850 
851 bool BaseParticle::isInContactWith(const BaseParticle* const P) const
852 {
853  if (P->getName() != "Superquadric")
854  {
857  }
858  return P->isInContactWith(this);
859 }
860 
863  if (isFixed()) return;
864  if (getParticleDimensions()==3) {
865  invMass_ = 1.0 / (4.0 / 3.0 * constants::pi * getRadius() * getRadius() * getRadius() * s.getDensity());
866  invInertia_ = MatrixSymmetric3D(1, 0, 0, 1, 0, 1) / (.4 * getMass() * mathsFunc::square(getRadius()));
867  } else {
868  invMass_ = 1.0 / (constants::pi * getRadius() * getRadius() * s.getDensity());
869  invInertia_ = MatrixSymmetric3D(1, 0, 0, 1, 0, 1) / (.5 * getMass() * mathsFunc::square(getRadius()));
870  }
871 };
Mdouble getKineticEnergy() const
Calculates the particle's translational kinetic energy.
Implementation of a 3D quaternion (by Vitaliy).
Definition: Quaternion.h:62
Container to store all ParticleSpecies.
void read(std::istream &is) override
Particle read function, which accepts an std::istream as input.
void setIndex(unsigned int index)
Allows one to assign an index to an object in the handler/container.
Definition: BaseObject.cc:64
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:125
void addDisplacement(const Vec3D &addDisp)
Adds a vector to the particle's displacement_.
void checkExtremaOnDelete(BaseParticle *P)
Checks if the extrema of this ParticleHandler needs updating when a particle is deleted.
bool isInPeriodicDomain() const
Indicates if the particle is in the periodic boundary communication zone.
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
MatrixSymmetric3D getInvInertia() const
Returns the inverse of the particle's inertia tensor.
Definition: BaseParticle.h:286
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:72
void setNormal(Vec3D normal)
Sets the normal vector between the two interacting objects.
Mdouble X
the vector components
Definition: Vector.h:65
MERCURY_DEPRECATED void setIndSpecies(unsigned int indSpecies) override
void addVelocity(const Vec3D &velocity)
adds an increment to the velocity.
void setPreviousPeriodicComplexity(std::vector< int > complexity)
Set the previous periodic communication complexity of the paritcle.
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
virtual void setInertia()
Mdouble getRotationalEnergy() const
Calculates the particle's rotational kinetic energy.
bool isMaserParticle() const
Indicates if this particle belongs to the maser boundary.
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
void setInMPIDomain(bool flag)
Flags the status of the particle if wether it is in the communication zone or not.
virtual Mdouble getVolume() const
Get Particle volume function, which required a reference to the Species vector. It returns the volume...
void setInfiniteInertia()
Sets the particle's inertia_ to 'infinite' (1e20) and its invInertia_ to 0.
int getHGridX() const
Definition: HGridCell.h:56
virtual bool isInContactWith(const BaseParticle *P) const
Get whether or not this particle is in contact with the given particle.
Vec3D getAngularMomentum() const
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void setOverlap(Mdouble overlap)
Set the overlap between the two interacting object.
double Mdouble
Definition: GeneralDefine.h:34
void setDisplacement(const Vec3D &disp)
Sets the particle's displacement (= difference between current position and that of the previous time...
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
void checkExtrema(BaseParticle *P)
Checks if the extrema of this ParticleHandler needs updating.
bool isInMPIDomain_
returns true if the particle acts as an MPI particle instead of a real particle
Definition: BaseParticle.h:683
int getHGridY() const
Definition: HGridCell.h:66
Mdouble info_
Definition: BaseParticle.h:702
const std::vector< int > & getPreviousPeriodicComplexity() const
Sets the previous periodic communication complexity of the particle.
BaseInteraction * getInteractionWith(BaseParticle *P, unsigned timeStamp, InteractionHandler *interactionHandler) override
Checks if particle is in interaction with given particle P, and if so, returns vector of pointer to t...
unsigned int getParticleDimensions() const
Returns the particle dimensionality.
Definition: DPMBase.cc:1427
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
void setHandler(ParticleHandler *handler)
Sets the pointer to the particle's ParticleHandler.
void setCommunicationComplexity(unsigned complexity)
Set the communication complexity of the particle.
ParticleHandler * handler_
Inverse Particle inverse inertia (for computation optimization)
Definition: BaseParticle.h:662
virtual Mdouble getExponentEps1() const
Only ustilised in case of superquadric particles. Had to create a virtual function to allow function ...
Mdouble invMass_
Particle radius_.
Definition: BaseParticle.h:653
bool isPeriodicGhostParticle_
bool that indicates if a particle is in the periodic domain of any boundary
Definition: BaseParticle.h:688
Mdouble getSumOfInteractionRadii(const BaseParticle *particle) const
returns the sum of the radii plus the interactionDistance
Definition: BaseParticle.h:376
virtual Vec3D getAxes() const
Only ustilised in case of superquadric particles. Had to create a virtual function to allow function ...
void integrateBeforeForceComputation(double time, double timeStep)
This is part of integrate routine for objects with infinite mass.
void setZero()
Sets all elements to zero.
Definition: Vector.cc:43
void setInverseInertia(MatrixSymmetric3D inverseInertia)
Sets the particle's inertia_ (and adjusts invInertia_ accordingly)
void setContactPoint(Vec3D contactPoint)
Set the location of the contact point between the two interacting objects.
void computeMass(BaseParticle *p) const
Compute Particle mass function, which required a reference to the Species vector. It computes the Par...
void unfix()
Unfix Particle function, which required a reference to the Species vector. It unfixes a Particle by c...
MatrixSymmetric3D invInertia_
Inverse Particle mass (for computation optimization)
Definition: BaseParticle.h:654
virtual Mdouble getExponentEps2() const
Only ustilised in case of superquadric particles. Had to create a virtual function to allow function ...
virtual const Vec3D & getAngularVelocity() const
Returns the angular velocity of this interactable.
void setSpecies(const ParticleSpecies *species)
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
const Vec3D & getForce() const
Returns the force on this BaseInteractable.
MERCURY_DEPRECATED void setMass(Mdouble mass)
Sets the particle's mass.
ParticleHandler * getHandler() const
Returns pointer to the particle's ParticleHandler.
std::string getName() const override
Returns the name of the object.
virtual void computeMass(const ParticleSpecies &s)
Computes the particle's (inverse) mass and inertia.
void accelerate(const Vec3D &vel)
Increases the particle's velocity_ by the given vector.
void setDistance(Mdouble distance)
Sets the interaction distance between the two interacting objects.
virtual bool getHGridUpdateEachTimeStep() const
Definition: DPMBase.cc:1678
Mdouble getLengthSquared() const
Calculates the squared length of this Vec3D: .
Definition: Vector.cc:184
Mdouble getInvMass() const override
Returns the inverse of the particle's mass.
Definition: BaseParticle.h:293
Stores information about interactions between two interactable objects; often particles but could be ...
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
void removedFixedParticle()
Decrement of the number of fixed particles.
void addAngularVelocity(const Vec3D &angularVelocity)
add an increment to the angular velocity.
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:99
void setSpecies(const ParticleSpecies *species)
Sets the species of this BaseInteractable.
void printHGrid(std::ostream &os) const
Adds particle's HGrid level and cell coordinates to an ostream.
virtual void setInfo(Mdouble info)
Sets some user-defined information about this object (by default, species ID).
void integrateBeforeForceComputation(double time, double timeStep)
First step of Velocity Verlet integration.
void setMassForP3Statistics(Mdouble mass)
Sets the particle's mass This function should not be used, but is necessary to extend the CG toolbox ...
Vec3D displacement_
Indicates if this particle belongs to the maser boundary or is released into the wide open world...
Definition: BaseParticle.h:693
HGridCell hGridCell
All hGrid-information: the cell (x,y,z,level), and the previous and next particle in this cell compar...
Definition: BaseParticle.h:673
void write(std::ostream &os) const override
Write a BaseInteractable to an output stream.
unsigned communicationComplexity_
returns true if it flagged as being in MPI domain
Definition: BaseParticle.h:684
bool isInMPIDomain()
Indicates if the particle is in the communication zone of the mpi domain.
Mdouble getMass() const
Returns the particle's mass.
Definition: BaseParticle.h:322
const Mdouble pi
Definition: ExtendedMath.h:45
void setEuler(const Vec3D &e)
Convert Euler angles to a quaternion. See Wikipedia for details.
Definition: Quaternion.cc:473
void setPreviousPosition(const Vec3D &pos)
Sets the particle's position in the previous time step.
BaseInteraction * getInteraction(BaseInteractable *P, BaseInteractable *I, unsigned timeStamp)
Returns the Interaction between the BaseInteractable's P and I.
bool isInPeriodicDomain_
Definition: BaseParticle.h:687
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1349
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
void write(std::ostream &os) const override
Particle print function, which accepts an std::ostream as input.
void addedFixedParticle()
Increment of the number of fixed particles.
Container to store Interaction objects.
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
MatrixSymmetric3D inverse() const
Computes the inverse of a matrix; exits if the inverse doesn't exist.
~BaseParticle() override
Particle destructor, needs to be implemented and checked if it removes tangential spring information...
void setZero()
Sets all elements to zero.
BaseParticle * hGridPrevObject_
Pointer to the next Particle in the same HGrid cell.
Definition: BaseParticle.h:676
void setHGridZ(int HGridZ)
Definition: HGridCell.h:81
Vec3D previousPosition_
Displacement (only used in StatisticsVector, StatisticsPoint)
Definition: BaseParticle.h:694
BaseParticle * hGridNextObject_
Definition: BaseParticle.h:675
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:345
virtual std::vector< Mdouble > getFieldVTK(unsigned i) const
bool isFixed() const override
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...
Definition: BaseParticle.h:93
void setHGridY(int HGridY)
Definition: HGridCell.h:71
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1319
const Vec3D getDisplacement2(Mdouble xmin, Mdouble xmax, Mdouble ymin, Mdouble ymax, Mdouble zmin, Mdouble zmax, Mdouble t) const
void setHGridX(int HGridX)
Definition: HGridCell.h:61
bool isPeriodicGhostParticle() const
Indicates if this particle is a ghost in the periodic boundary.
Container to store all BaseParticle.
static Mdouble getDistanceSquared(const Vec3D &a, const Vec3D &b)
Calculates the squared distance between two Vec3D: .
Definition: Vector.h:295
Mdouble Y
Definition: Vector.h:65
void setMaserParticle(bool flag)
Flags the status of the particle if it belongs to the maser boundary or not.
const std::vector< int > & getPeriodicComplexity()
Obtains the periodic communication complexity of the particle.
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
virtual std::string getTypeVTK(unsigned i) const
BaseParticle()
Basic Particle constructor, creates an Particle at (0,0,0) with radius, mass and inertia equal to 1...
Definition: BaseParticle.cc:33
const Vec3D & getTorque() const
Returns the torque on this BaseInteractable.
virtual void rotate(const Vec3D &angularVelocityDt)
Rotates this BaseInteractable.
unsigned getCommunicationComplexity()
Obtains the communication complexity of the particle.
virtual void oldRead(std::istream &is)
Mdouble radius_
Definition: BaseParticle.h:652
void setPeriodicComplexity(std::vector< int > complexity)
Set the periodic communication complexity of the particle.
const Vec3D & getPreviousPosition() const
Returns the particle's position in the previous time step.
Definition: BaseParticle.h:400
bool isMPIParticle() const
Indicates if this particle is a ghost in the MPI domain.
void setMPIParticle(bool flag)
Flags the mpi particle status.
MatrixSymmetric3D getInertia() const
Definition: BaseParticle.h:328
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.h:316
void setPeriodicGhostParticle(bool flag)
Flags the status of the particle to be a ghost in periodic boundary or not.
bool isMaserParticle_
Indicates the periodic complexity at current time step. Used to update periodic status.
Definition: BaseParticle.h:691
int getHGridZ() const
Definition: HGridCell.h:76
Defines the basic properties that a interactable object can have.
static MatrixSymmetric3D inverse(const MatrixSymmetric3D &A)
Computes the inverse of a matrix; exits if the inverse doesn't exist.
Mdouble getDensity() const
Allows density_ to be accessed.
void setOrientation(const Quaternion &orientation)
Sets the orientation of this BaseInteractable.
virtual std::string getNameVTK(unsigned i) const
void angularAccelerate(const Vec3D &angVel)
Increases the particle's angularVelocity_ by the given vector.
std::vector< int > periodicComplexity_
Indicates the periodic complexity at previous time step.
Definition: BaseParticle.h:690
virtual void hGridUpdateMove(BaseParticle *, Mdouble)
Definition: DPMBase.cc:1893
Class that describes a possible contact between two BaseParticle.
void integrateAfterForceComputation(double time, double timeStep)
Second step of Velocity Verlet integration.
bool isMPIParticle_
Pointer to originating Particle.
Definition: BaseParticle.h:682
unsigned int getIndSpecies() const
Returns the index of the species associated with the interactable object.
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
Definition: Vector.h:49
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
T square(const T val)
squares a number
Definition: ExtendedMath.h:104
void setHGridLevel(unsigned int HGridLevel)
Definition: HGridCell.h:91
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
BaseParticle * periodicFromParticle_
Pointer to the previous Particle in the same HGrid cell.
Definition: BaseParticle.h:679
unsigned int getHGridLevel() const
Returns particle's HGrid level.
Definition: BaseParticle.h:234
virtual unsigned getNumberOfFieldsVTK() const
unsigned int getParticleDimensions() const
Returns the particle's dimensions (either 2 or 3).
void setInPeriodicDomain(bool flag)
Flags the status of the particle wether it is in the periodic communication zone or not...
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
std::vector< int > previousPeriodicComplexity_
Indicates if the particle is a ghost particle of a periodic particle.
Definition: BaseParticle.h:689
Mdouble Z
Definition: Vector.h:65
void setAngularVelocity(const Vec3D &angularVelocity)
set the angular velocity of the BaseInteractble.
bool getRotation() const
Indicates whether particle rotation is enabled or disabled.
Definition: DPMBase.h:545
unsigned int getHGridLevel() const
Definition: HGridCell.h:86
virtual Mdouble getInfo() const
Returns some user-defined information about this object (by default, species ID). ...
void read(std::istream &is) override
Reads a BaseInteractable from an input stream.
Implementation of a 3D symmetric matrix.
void integrateAfterForceComputation(double time, double timeStep)
This is part of the integration routine for objects with infinite mass.
void setId(unsigned long id)
Assigns a unique identifier to each object in the handler (container) which remains constant even aft...
Definition: BaseObject.cc:72
Mdouble XX
The six distinctive matrix elements.
void movePrevious(const Vec3D &posMove)
Adds a vector to the particle's previousPosition_.
virtual void setIndSpecies(unsigned int indSpecies)
Sets the index of the Species of this BaseInteractable.
void fixParticle()
Fix Particle function. It fixes a Particle by setting its inverse mass and inertia and velocities to ...