revision: v0.14
BaseWall.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 BASEWALL_H
27 #define BASEWALL_H
28 
29 #include "BaseInteractable.h"
31 
32 class WallHandler;
33 
34 class BaseParticle;
35 
37 {
38  std::vector<Vec3D> points;
39  std::vector<std::vector<double>> triangleStrips;
40 };
41 
47 class BaseWall : public BaseInteractable
48 {
49 public:
53  BaseWall();
54 
58  BaseWall(const BaseWall& w);
59 
63  ~BaseWall() override;
64 
69  virtual BaseWall* copy() const = 0;
70 
74  void read(std::istream& is) override;
75 
79  void write(std::ostream& os) const override;
80 
89  virtual bool getDistanceAndNormal(const BaseParticle& P, Mdouble& distance, Vec3D& normal_return) const = 0;
90 
91 
92  virtual bool
93  getDistanceNormalOverlap(const BaseParticle& P, Mdouble& distance, Vec3D& normal_return, Mdouble& overlap) const;
94 
95  virtual bool getDistanceNormalOverlapSuperquadric(const SuperQuadricParticle& p, Mdouble& distance, Vec3D& normal_return,
96  Mdouble& overlap) const;
97 
98  virtual Vec3D
99  getFurthestPointSuperQuadric(const Vec3D& normalBodyFixed, const Vec3D& axes, Mdouble eps1, Mdouble eps2) const;
100 
104  virtual void setHandler(WallHandler* handler);
105 
109  WallHandler* getHandler() const;
110 
115  void setIndSpecies(unsigned int indSpecies) override;
116 
121  void setSpecies(const ParticleSpecies* species);
122 
127  bool isFixed() const override;
128 
132  void setForceControl(Vec3D forceGoal, Vec3D gainFactor, Vec3D baseVelocity={0,0,0});
133 
137  virtual bool isLocal(Vec3D& min, Vec3D& max) const
138  { return false; }
139 
140  // returns the point intersecting a wall (x-p).n=0 and a line x=p0+t(p1-p0)
141  bool getLinePlaneIntersect(Vec3D& intersect, const Vec3D& p0, const Vec3D& p1, const Vec3D& n, const Vec3D& p);
142  bool isInsideWallVTK(const Vec3D& point, const Vec3D& normal, const Vec3D& position) const;
146 
150  void projectOntoWallVTK(Vec3D& point0, const Vec3D& point1, const Vec3D& normal, const Vec3D& position) const;
151 
156  void intersectVTK(std::vector<Vec3D>& points, Vec3D normal, Vec3D position) const;
157 
158 
159  virtual BaseInteraction*
160  getInteractionWithSuperQuad(SuperQuadricParticle* p, unsigned timeStamp, InteractionHandler* interactionHandler);
161 
167  virtual void writeVTK(VTKContainer& vtk) const;
168 
169  void getVTK(std::vector<Vec3D>& points, std::vector<std::vector<double>>& triangleStrips)
170  {}
171 
172  const Vec3D getAxis() const;
173 
176  getInteractionWith(BaseParticle* p, unsigned timeStamp, InteractionHandler* interactionHandler) override;
177 
183  virtual void actionsOnRestart() {}
184 
193 
202  virtual void handleParticleAddition(unsigned int id, BaseParticle* p) {}
203 
211  virtual void handleParticleRemoval(unsigned int id) {}
212 
219  virtual void checkInteractions(InteractionHandler* interactionHandler, unsigned int timeStamp) {}
220 
221  bool getVTKVisibility() const;
222 
223  void setVTKVisibility(bool vtkVisibility);
224 
228  static void addToVTK(const std::vector<Vec3D>& points, VTKContainer& vtk);
229 
230  //todo how do i write a copy and add function?
231  void addRenderedWall(BaseWall* w);
232 
233  BaseWall* getRenderedWall(size_t i) const;
234 
235  void removeRenderedWalls();
236 
237  void renderWall(VTKContainer& vtk);
238 
239  void addParticlesAtWall(unsigned numElements = 50);
240 
241  void setVelocityControl(Vec3D forceGoal, Vec3D gainFactor, Vec3D baseVelocity);
242 
243 private:
248 
249  bool vtkVisibility_ = true;
250 
254  std::vector<BaseWall*> renderedWalls_;
255 
256 };
257 
258 #endif
BaseWall::BaseWall
BaseWall()
Default constructor.
Definition: BaseWall.cc:36
BaseWall::setIndSpecies
void setIndSpecies(unsigned int indSpecies) override
Define the species of this wall using the index of the species in the SpeciesHandler in this DPMBase.
Definition: BaseWall.cc:144
BaseObject::getGroupId
unsigned getGroupId() const
Definition: BaseObject.h:137
BaseWall::addToVTK
static void addToVTK(const std::vector< Vec3D > &points, VTKContainer &vtk)
Takes the points provided and adds a triangle strip connecting these points to the vtk container.
Definition: BaseWall.cc:471
Vec3D::multiplyElementwise
Vec3D multiplyElementwise(const Vec3D &a) const
Definition: Vector.h:132
BaseWall::actionsOnRestart
virtual void actionsOnRestart()
No implementation but can be overidden in its derived classes.
Definition: BaseWall.h:183
BaseWall::~BaseWall
~BaseWall() override
Default destructor.
Definition: BaseWall.cc:66
InteractionHandler
Container to store Interaction objects.
Definition: InteractionHandler.h:44
BaseSpecies::getHandler
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:99
BaseObject::getName
virtual std::string getName() const =0
A purely virtual function.
BaseWall::actionsAfterParticleGhostUpdate
virtual void actionsAfterParticleGhostUpdate()
No implementation but can be overidden in its derived classes.
Definition: BaseWall.h:192
BaseInteractable::setPosition
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:239
BaseInteractable::addTorque
void addTorque(const Vec3D &addTorque)
Adds an amount to the torque on this BaseInteractable.
Definition: BaseInteractable.cc:132
BaseWall
Basic class for walls.
Definition: BaseWall.h:48
logger
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
BaseWall::vtkVisibility_
bool vtkVisibility_
Definition: BaseWall.h:249
BaseInteractable::getForce
const Vec3D & getForce() const
Returns the force on this BaseInteractable.
Definition: BaseInteractable.h:126
Quaternion::q1
Mdouble q1
the first component of the quaternion q = (q0,q1,q2,q3)
Definition: Quaternion.h:73
BaseParticle::getExponentEps2
virtual Mdouble getExponentEps2() const
Only ustilised in case of superquadric particles. Had to create a virtual function to allow function ...
Definition: BaseParticle.cc:848
Vec3D::X
Mdouble X
the vector components
Definition: Vector.h:65
BaseWall::handler_
WallHandler * handler_
Definition: BaseWall.h:247
Vec3D::dot
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
BaseWall::write
void write(std::ostream &os) const override
Function that writes a BaseWall to an output stream, usually a restart file.
Definition: BaseWall.cc:102
BaseWall::renderedWalls_
std::vector< BaseWall * > renderedWalls_
Definition: BaseWall.h:254
BaseWall::getFurthestPointSuperQuadric
virtual Vec3D getFurthestPointSuperQuadric(const Vec3D &normalBodyFixed, const Vec3D &axes, Mdouble eps1, Mdouble eps2) const
Definition: BaseWall.cc:547
BaseHandler::getSize
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
BaseInteractable::getOrientation
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Definition: BaseInteractable.h:230
BaseWall::setVTKVisibility
void setVTKVisibility(bool vtkVisibility)
Definition: BaseWall.cc:518
BaseInteractable::getIndSpecies
unsigned int getIndSpecies() const
Returns the index of the species associated with the interactable object.
Definition: BaseInteractable.h:88
INFO
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
ParticleSpecies
Definition: ParticleSpecies.h:37
BaseInteractable::setIndSpecies
virtual void setIndSpecies(unsigned int indSpecies)
Sets the index of the Species of this BaseInteractable.
Definition: BaseInteractable.h:98
BaseInteractable
Defines the basic properties that a interactable object can have.
Definition: BaseInteractable.h:55
VTKContainer::triangleStrips
std::vector< std::vector< double > > triangleStrips
Definition: BaseWall.h:39
BaseWall::checkInteractions
virtual void checkInteractions(InteractionHandler *interactionHandler, unsigned int timeStamp)
Check if all interactions are valid.
Definition: BaseWall.h:219
BaseInteractable::setPrescribedVelocity
void setPrescribedVelocity(const std::function< Vec3D(double)> &prescribedVelocity)
Allows the velocity of an infinite mass interactable to be prescribed.
Definition: BaseInteractable.cc:444
BaseParticle::setRadius
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species)
Definition: BaseParticle.cc:542
Vec3D
Definition: Vector.h:50
BaseInteraction::setDistance
void setDistance(Mdouble distance)
Sets the interaction distance between the two interacting objects.
Definition: BaseInteraction.cc:219
BaseInteraction::getContactPoint
const Vec3D & getContactPoint() const
Gets constant reference to contact point (vector).
Definition: BaseInteraction.h:234
BaseWall::addRenderedWall
void addRenderedWall(BaseWall *w)
Definition: BaseWall.cc:554
BaseInteraction
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:60
WallHandler
Container to store all BaseWall.
Definition: WallHandler.h:43
BaseWall::isFixed
bool isFixed() const override
Definition: BaseWall.cc:188
BaseWall::copy
virtual BaseWall * copy() const =0
Pure virtual function that can be overwritten in inherited classes in order to copy a BaseWall.
BaseParticle::getRadius
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:348
SuperQuadricParticle.h
BaseParticle::getAxes
virtual Vec3D getAxes() const
Only ustilised in case of superquadric particles. Had to create a virtual function to allow function ...
Definition: BaseParticle.cc:842
SpeciesHandler
Container to store all ParticleSpecies.
Definition: SpeciesHandler.h:37
double
DPMBase::getMax
Vec3D getMax() const
Definition: DPMBase.h:643
ERROR
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:53
BaseWall::getVTKVisibility
bool getVTKVisibility() const
Definition: BaseWall.cc:513
BaseParticle::setSpecies
void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:804
BaseWall::getAxis
const Vec3D getAxis() const
Definition: BaseWall.cc:503
BaseInteraction::getOverlap
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
Definition: BaseInteraction.h:240
DPMBase::getTime
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:805
BaseWall::projectOntoWallVTK
void projectOntoWallVTK(Vec3D &point0, const Vec3D &point1, const Vec3D &normal, const Vec3D &position) const
Definition: BaseWall.cc:233
BaseInteraction::getNormal
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
Definition: BaseInteraction.h:226
BaseInteraction::setOverlap
void setOverlap(Mdouble overlap)
Set the overlap between the two interacting object.
Definition: BaseInteraction.cc:229
Quaternion::q2
Mdouble q2
the second component of the quaternion q = (q0,q1,q2,q3)
Definition: Quaternion.h:77
WARN
LL< Log::WARN > WARN
Warning log level.
Definition: Logger.cc:54
Log::FATAL
@ FATAL
DPMBase::speciesHandler
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1385
BaseInteractable::read
void read(std::istream &is) override
Reads a BaseInteractable from an input stream.
Definition: BaseInteractable.cc:244
BaseObject::getIndex
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
BaseWall::renderWall
void renderWall(VTKContainer &vtk)
Definition: BaseWall.cc:570
DPMBase.h
BaseInteractable::addForce
void addForce(const Vec3D &addForce)
Adds an amount to the force on this BaseInteractable.
Definition: BaseInteractable.cc:116
SphericalParticle
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:37
DPMBase::wallHandler
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1405
BaseWall::getRenderedWall
BaseWall * getRenderedWall(size_t i) const
Definition: BaseWall.cc:565
BaseWall::setHandler
virtual void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
Definition: BaseWall.cc:127
BaseWall::handleParticleAddition
virtual void handleParticleAddition(unsigned int id, BaseParticle *p)
Handles the addition of particles to the particleHandler.
Definition: BaseWall.h:202
Vec3D::Y
Mdouble Y
Definition: Vector.h:65
InteractionHandler::getInteraction
BaseInteraction * getInteraction(BaseInteractable *P, BaseInteractable *I, unsigned timeStamp)
Returns the Interaction between the BaseInteractable's P and I.
Definition: InteractionHandler.cc:149
VTKContainer
Definition: BaseWall.h:37
BaseInteraction::setContactPoint
void setContactPoint(Vec3D contactPoint)
Set the location of the contact point between the two interacting objects.
Definition: BaseInteraction.cc:238
Vec3D::min
static Vec3D min(const Vec3D &a, const Vec3D &b)
Calculates the pointwise minimum of two Vec3D.
Definition: Vector.cc:102
BaseWall::isInsideWallVTK
bool isInsideWallVTK(const Vec3D &point, const Vec3D &normal, const Vec3D &position) const
Definition: BaseWall.cc:222
BaseWall.h
BaseWall::getDistanceNormalOverlapSuperquadric
virtual bool getDistanceNormalOverlapSuperquadric(const SuperQuadricParticle &p, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const
Definition: BaseWall.cc:540
VTKContainer::points
std::vector< Vec3D > points
Definition: BaseWall.h:38
constants::i
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
BaseWall::setSpecies
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:171
BaseInteraction::setNormal
void setNormal(Vec3D normal)
Sets the normal vector between the two interacting objects.
Definition: BaseInteraction.cc:210
Quaternion
This class contains the 4 components of a quaternion and the standard operators and functions needed ...
Definition: Quaternion.h:63
BaseParticle::getExponentEps1
virtual Mdouble getExponentEps1() const
Only ustilised in case of superquadric particles. Had to create a virtual function to allow function ...
Definition: BaseParticle.cc:845
BaseHandler::getObject
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
BaseWall::setForceControl
void setForceControl(Vec3D forceGoal, Vec3D gainFactor, Vec3D baseVelocity={0, 0, 0})
Slowly adjusts the force on a wall towards a specified goal, by adjusting (prescribing) the velocity ...
Definition: BaseWall.cc:198
BaseObject::getId
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:125
BaseWall::intersectVTK
void intersectVTK(std::vector< Vec3D > &points, Vec3D normal, Vec3D position) const
Definition: BaseWall.cc:243
BaseHandler::getDPMBase
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
BaseParticle
Definition: BaseParticle.h:54
BaseInteractable::setSpecies
void setSpecies(const ParticleSpecies *species)
Sets the species of this BaseInteractable.
Definition: BaseInteractable.cc:185
BaseInteractable::getInteractions
const std::vector< BaseInteraction * > & getInteractions() const
Returns a list of interactions which belong to this interactable.
Definition: BaseInteractable.h:277
Quaternion::rotateBack
void rotateBack(Vec3D &position) const
Definition: Quaternion.cc:592
DPMBase::getMin
Vec3D getMin() const
Definition: DPMBase.h:637
n
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
BaseWall::writeVTK
virtual void writeVTK(VTKContainer &vtk) const
Definition: BaseWall.cc:466
Vec3D::cross
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
BaseWall::getHandler
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:136
SuperQuadricParticle
Definition: SuperQuadricParticle.h:56
Quaternion::rotate
void rotate(Vec3D &position) const
Definition: Quaternion.cc:563
BaseWall::setVelocityControl
void setVelocityControl(Vec3D forceGoal, Vec3D gainFactor, Vec3D baseVelocity)
Definition: BaseWall.cc:591
Quaternion::q3
Mdouble q3
the third component of the quaternion q = (q0,q1,q2,q3)
Definition: Quaternion.h:81
WallHandler::createObject
static BaseWall * createObject(const std::string &type)
Create a new wall, with the type given as a string (required for restarting).
Definition: WallHandler.cc:123
BaseInteractable::write
void write(std::ostream &os) const override
Write a BaseInteractable to an output stream.
Definition: BaseInteractable.cc:274
BaseWall::read
void read(std::istream &is) override
Function that reads a BaseWall from an input stream, usually a restart file.
Definition: BaseWall.cc:80
BaseParticle::isSphericalParticle
virtual bool isSphericalParticle() const
Definition: BaseParticle.h:645
DPMBase::particleHandler
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1395
Vec3D::Z
Mdouble Z
Definition: Vector.h:65
BaseWall::getDistanceNormalOverlap
virtual bool getDistanceNormalOverlap(const BaseParticle &P, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const
Definition: BaseWall.cc:523
BaseWall::handleParticleRemoval
virtual void handleParticleRemoval(unsigned int id)
Handles the addition of particles to the particleHandler.
Definition: BaseWall.h:211
BaseWall::isLocal
virtual bool isLocal(Vec3D &min, Vec3D &max) const
Definition: BaseWall.h:137
BaseWall::removeRenderedWalls
void removeRenderedWalls()
Definition: BaseWall.cc:559
BaseWall::getLinePlaneIntersect
bool getLinePlaneIntersect(Vec3D &intersect, const Vec3D &p0, const Vec3D &p1, const Vec3D &n, const Vec3D &p)
Definition: BaseWall.cc:206
BaseWall::addParticlesAtWall
void addParticlesAtWall(unsigned numElements=50)
Definition: BaseWall.cc:598
BaseWall::getVTK
void getVTK(std::vector< Vec3D > &points, std::vector< std::vector< double >> &triangleStrips)
Definition: BaseWall.h:169
BaseInteractable.h
BaseWall::getInteractionWith
BaseInteraction * getInteractionWith(BaseParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler) override
Returns the interaction between this wall and a given particle, nullptr if there is no interaction.
Definition: BaseWall.cc:369
helpers::isNext
bool isNext(std::istream &is, const std::string name)
Definition: Helpers.cc:957
BaseWall::getInteractionWithSuperQuad
virtual BaseInteraction * getInteractionWithSuperQuad(SuperQuadricParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler)
Definition: BaseWall.cc:494
BaseInteractable::getPosition
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
BaseWall::getDistanceAndNormal
virtual bool getDistanceAndNormal(const BaseParticle &P, Mdouble &distance, Vec3D &normal_return) const =0
Pure virtual function that computes the distance of a BaseParticle to this wall and returns the norma...
DPMBase
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:76