revision: v0.14
IntersectionOfWalls.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 INTERSECTIONOFWALLS_H
27 #define INTERSECTIONOFWALLS_H
28 
29 #include <vector>
30 #include "BaseWall.h"
31 #include "InfiniteWall.h"
32 #include "Math/Vector.h"
33 
59 {
60 public:
62  {
65  };
66 
71 
76 
80  IntersectionOfWalls(const std::vector<normalAndPosition>& walls, const ParticleSpecies* species);
81 
85  ~IntersectionOfWalls() override;
86 
91 
95  IntersectionOfWalls* copy() const override;
96 
100  void clear();
101 
103  void setSpecies(const ParticleSpecies* species);
104 
105  void setHandler(WallHandler* wallHandler) override;
106 
110  unsigned int getNumberOfObjects();
111 
116  void addObject(Vec3D normal, Vec3D point);
117 
118  void addObject(Quaternion orientation, Vec3D position);
119 
120  void add3PointObject(Vec3D PointA, Vec3D PointB, Vec3D PointC);
121 
122  void setPointsAndLines(unsigned int n);
123 
127  void addTetraSTL(Vec3D PointA, Vec3D PointB, Vec3D PointC, Vec3D WallNormal, Mdouble Thickness, int wallidentifier);
128 
132  void addTetra(const Vec3D& PointA, const Vec3D& PointB, const Vec3D& PointC, Mdouble& Thickness);
133 
134 
135  void addPlate(const Vec3D& PointA, const Vec3D& PointB, const Vec3D& PointC, const Vec3D& WallNormal,
136  const Mdouble& Thickness, int wallidentifier);
137 
144  void addObject(Vec3D normal, Mdouble position);
145 
151  void createOpenPrism(std::vector<Vec3D> points, Vec3D prismAxis);
152 
158  void createPrism(std::vector<Vec3D> points, Vec3D prismAxis);
159 
165  void createOpenPrism(std::vector<Vec3D> points);
166 
172  void createPrism(std::vector<Vec3D> points);
173 
178  bool getDistanceAndNormal(const BaseParticle& p, Mdouble& distance, Vec3D& normal_return) const override;
179 
184  bool getDistanceAndNormal(const Vec3D& position, Mdouble wallInteractionRadius, Mdouble& distance,
185  Vec3D& normal_return) const;
186 
191 // void move(const Vec3D& move) override;
192 
196  void read(std::istream& is) override;
197 
201  void write(std::ostream& os) const override;
202 
206  std::string getName() const override;
207 
208  void writeVTK(VTKContainer& vtk) const override;
209 
210 // void rotate(const Vec3D& rotate) override;
211 
212 protected:
219  std::vector<InfiniteWall> wallObjects_;
220 
221 private:
227  std::vector<Vec3D> A_;
228 
234  std::vector<Vec3D> AB_;
235 
236 protected:
242  std::vector<Vec3D> C_;
243 };
244 
245 #endif
Vec3D::getUnitVector
static Vec3D getUnitVector(const Vec3D &a)
Returns a unit Vec3D based on a.
Definition: Vector.cc:345
BaseInteractable::getSpecies
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
Definition: BaseInteractable.h:108
Y
@ Y
Definition: StatisticsVector.h:42
Vector.h
Vec3D::normalise
void normalise()
Makes this Vec3D unit length.
Definition: Vector.cc:123
BaseSpecies::getInteractionDistance
Mdouble getInteractionDistance() const
returns the largest separation distance at which adhesive short-range forces can occur.
Definition: BaseSpecies.h:146
IntersectionOfWalls::wallObjects_
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
Definition: IntersectionOfWalls.h:219
IntersectionOfWalls::addPlate
void addPlate(const Vec3D &PointA, const Vec3D &PointB, const Vec3D &PointC, const Vec3D &WallNormal, const Mdouble &Thickness, int wallidentifier)
Definition: IntersectionOfWalls.cc:296
IntersectionOfWalls
A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's.
Definition: IntersectionOfWalls.h:59
BaseInteractable::setPosition
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:239
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.
IntersectionOfWalls::read
void read(std::istream &is) override
Move the IntersectionOfWalls to a new position, which is a Vec3D from the old position.
Definition: IntersectionOfWalls.cc:745
IntersectionOfWalls::addObject
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given a normal vector pointing into the wall (i....
Definition: IntersectionOfWalls.cc:137
IntersectionOfWalls::getNumberOfObjects
unsigned int getNumberOfObjects()
Returns the number of objects.
Definition: IntersectionOfWalls.cc:124
IntersectionOfWalls::copy
IntersectionOfWalls * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
Definition: IntersectionOfWalls.cc:97
IntersectionOfWalls::setSpecies
void setSpecies(const ParticleSpecies *species)
sets species of subwalls as well
Definition: IntersectionOfWalls.cc:72
Vec3D::dot
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
IntersectionOfWalls::addTetraSTL
void addTetraSTL(Vec3D PointA, Vec3D PointB, Vec3D PointC, Vec3D WallNormal, Mdouble Thickness, int wallidentifier)
constructs a tetrahedron for an STL file input
Definition: IntersectionOfWalls.cc:190
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
SpeciesHandler::getMixedObject
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
Definition: SpeciesHandler.h:74
IntersectionOfWalls::normalAndPosition::position
Vec3D position
Definition: IntersectionOfWalls.h:64
IntersectionOfWalls::write
void write(std::ostream &os) const override
Writes an IntersectionOfWalls to an output stream, for example a restart file.
Definition: IntersectionOfWalls.cc:775
BaseInteractable::getOrientation
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Definition: BaseInteractable.h:230
ParticleSpecies
Definition: ParticleSpecies.h:37
Vec3D
Definition: Vector.h:50
BaseInteractable::setOrientation
void setOrientation(const Quaternion &orientation)
Sets the orientation of this BaseInteractable.
Definition: BaseInteractable.h:260
WallHandler
Container to store all BaseWall.
Definition: WallHandler.h:43
BaseSpecies
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:50
IntersectionOfWalls::~IntersectionOfWalls
~IntersectionOfWalls() override
Destructor.
Definition: IntersectionOfWalls.cc:67
BaseParticle::getRadius
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:348
IntersectionOfWalls::normalAndPosition::normal
Vec3D normal
Definition: IntersectionOfWalls.h:63
double
DPMBase::getMax
Vec3D getMax() const
Definition: DPMBase.h:643
VERBOSE
LL< Log::VERBOSE > VERBOSE
Verbose information.
Definition: Logger.cc:57
ERROR
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:53
IntersectionOfWalls::operator=
IntersectionOfWalls & operator=(const IntersectionOfWalls &other)
Definition: IntersectionOfWalls.cc:84
MERCURY_DEPRECATED
#define MERCURY_DEPRECATED
Definition: GeneralDefine.h:37
IntersectionOfWalls::getDistanceAndNormal
bool getDistanceAndNormal(const BaseParticle &p, Mdouble &distance, Vec3D &normal_return) const override
Compute the distance from the wall for a given BaseParticle and return if there is a collision....
Definition: IntersectionOfWalls.cc:531
IntersectionOfWalls::IntersectionOfWalls
IntersectionOfWalls()
Default constructor.
Definition: IntersectionOfWalls.cc:33
WARN
LL< Log::WARN > WARN
Warning log level.
Definition: Logger.cc:54
InfiniteWall.h
Log::FATAL
@ FATAL
DPMBase::speciesHandler
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1385
DPMBase.h
BaseWall::setHandler
virtual void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
Definition: BaseWall.cc:127
IntersectionOfWalls::C_
std::vector< Vec3D > C_
A vector that stores the intersection point of three different InfiniteWall.
Definition: IntersectionOfWalls.h:242
InfiniteWall
A infinite wall fills the half-space {point: (position_-point)*normal_<=0}.
Definition: InfiniteWall.h:48
VTKContainer
Definition: BaseWall.h:37
BaseWall.h
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
IntersectionOfWalls::A_
std::vector< Vec3D > A_
A vector that stores a point for each intersecting line between two different InfiniteWall.
Definition: IntersectionOfWalls.h:227
Quaternion
This class contains the 4 components of a quaternion and the standard operators and functions needed ...
Definition: Quaternion.h:63
IntersectionOfWalls::addTetra
void addTetra(const Vec3D &PointA, const Vec3D &PointB, const Vec3D &PointC, Mdouble &Thickness)
constructs a tetrahedron from 3 input coordinates
Definition: IntersectionOfWalls.cc:259
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
Vec3D::getLengthSquared
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.h:316
X
@ X
Definition: StatisticsVector.h:42
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
Vec3D::cross
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
IntersectionOfWalls::setHandler
void setHandler(WallHandler *wallHandler) override
A function which sets the WallHandler for this BaseWall.
Definition: IntersectionOfWalls.cc:110
IntersectionOfWalls::normalAndPosition
Definition: IntersectionOfWalls.h:62
BaseWall::getHandler
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:136
Quaternion::rotate
void rotate(Vec3D &position) const
Definition: Quaternion.cc:563
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
IntersectionOfWalls::writeVTK
void writeVTK(VTKContainer &vtk) const override
Definition: IntersectionOfWalls.cc:793
IntersectionOfWalls::AB_
std::vector< Vec3D > AB_
A vector that stores the direction of the intersecting lines between two different InfiniteWall.
Definition: IntersectionOfWalls.h:234
IntersectionOfWalls::clear
void clear()
Removes all parts of the walls.
Definition: IntersectionOfWalls.cc:102
IntersectionOfWalls::getName
std::string getName() const override
Returns the name of the object, here the string "IntersectionOfWalls".
Definition: IntersectionOfWalls.cc:788
WallHandler.h
IntersectionOfWalls.h
InfiniteWall::set
void set(Vec3D normal, Vec3D point)
Defines a standard wall, given an outward normal vector s.t. normal*x=normal*point for all x of the w...
Definition: InfiniteWall.cc:118
IntersectionOfWalls::createPrism
void createPrism(std::vector< Vec3D > points, Vec3D prismAxis)
Creates an open prism which is a polygon between the points and extends infinitely in the PrismAxis d...
Definition: IntersectionOfWalls.cc:481
IntersectionOfWalls::setPointsAndLines
void setPointsAndLines(unsigned int n)
Definition: IntersectionOfWalls.cc:350
InteractionHandler.h
BaseParticle.h
IntersectionOfWalls::createOpenPrism
void createOpenPrism(std::vector< Vec3D > points, Vec3D prismAxis)
Creates an open prism which is a polygon between the points, except the first and last point,...
Definition: IntersectionOfWalls.cc:466
Z
@ Z
Definition: StatisticsVector.h:42
BaseInteractable::getPosition
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
IntersectionOfWalls::add3PointObject
void add3PointObject(Vec3D PointA, Vec3D PointB, Vec3D PointC)
Definition: IntersectionOfWalls.cc:158