MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IntersectionOfWalls Class Reference

A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's. More...

#include <IntersectionOfWalls.h>

+ Inheritance diagram for IntersectionOfWalls:

Classes

struct  normalAndPosition
 

Public Member Functions

 IntersectionOfWalls ()
 Default constructor. More...
 
 IntersectionOfWalls (const IntersectionOfWalls &other)
 Copy constructor. More...
 
 IntersectionOfWalls (const std::vector< normalAndPosition > &walls, const ParticleSpecies *species)
 Constructor setting values. More...
 
 ~IntersectionOfWalls () override
 Destructor. More...
 
IntersectionOfWallsoperator= (const IntersectionOfWalls &other)
 
IntersectionOfWallscopy () const override
 Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism. More...
 
void clear ()
 Removes all parts of the walls. More...
 
void setSpecies (const ParticleSpecies *species)
 sets species of subwalls as well More...
 
void setHandler (WallHandler *wallHandler) override
 A function which sets the WallHandler for this BaseWall. More...
 
unsigned int getNumberOfObjects ()
 Returns the number of objects. More...
 
void addObject (Vec3D normal, Vec3D point)
 Adds a wall to the set of infinite walls, given a normal vector pointing into the wall (i.e. out of the simulation domain), going through the point, so that normal*x=normal*point. More...
 
void addObject (Quaternion orientation, Vec3D position)
 
void add3PointObject (Vec3D PointA, Vec3D PointB, Vec3D PointC)
 
void setPointsAndLines (unsigned int n)
 
void addTetraSTL (Vec3D PointA, Vec3D PointB, Vec3D PointC, Vec3D WallNormal, Mdouble Thickness, int wallidentifier)
 constructs a tetrahedron for an STL file input More...
 
void addTetra (const Vec3D &PointA, const Vec3D &PointB, const Vec3D &PointC, Mdouble &Thickness)
 constructs a tetrahedron from 3 input coordinates More...
 
void addPlate (const Vec3D &PointA, const Vec3D &PointB, const Vec3D &PointC, const Vec3D &WallNormal, const Mdouble &Thickness, int wallidentifier)
 
MERCURY_DEPRECATED void addObject (Vec3D normal, Mdouble position)
 Adds a wall to the set of finite walls, given an normal vector pointing into the wall (i.e. out of the flow domain), to give a plane defined by normal*x=position. More...
 
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, and extends infinitely in the PrismAxis direction. Note that if you view from inside of your geometry, the shape formed by points has to be convex, otherwise it will not create the wall correctly. More...
 
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 direction. Note that if you view from inside of your geometry, the shape formed by points has to be convex, otherwise it will not create the wall correctly. More...
 
void createOpenPrism (std::vector< Vec3D > points)
 Creates an open prism which is a polygon between the points, except the first and last point, and extends infinitely in the direction perpendicular to the first and second wall. Note that if you view from inside of your geometry, the shape formed by points has to be convex, otherwise it will not create the wall correctly. More...
 
void createPrism (std::vector< Vec3D > points)
 Creates an open prism which is a polygon between the points and extends infinitely in the direction perpendicular to the first and second wall. Note that if you view from inside of your geometry, the shape formed by points has to be convex, otherwise it will not create the wall correctly. More...
 
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. If there is a collision, also return the normal vector. More...
 
bool getDistanceAndNormal (const Vec3D &position, Mdouble wallInteractionRadius, Mdouble &distance, Vec3D &normal_return) const
 Compute the distance from the wall for a given BaseParticle and return if there is an interaction. If there is an interaction, also return the normal vector. More...
 
void read (std::istream &is) override
 Move the IntersectionOfWalls to a new position, which is a Vec3D from the old position. More...
 
void write (std::ostream &os) const override
 Writes an IntersectionOfWalls to an output stream, for example a restart file. More...
 
std::string getName () const override
 Returns the name of the object, here the string "IntersectionOfWalls". More...
 
void writeVTK (VTKContainer &vtk) const override
 
- Public Member Functions inherited from BaseWall
 BaseWall ()
 Default constructor. More...
 
 BaseWall (const BaseWall &w)
 Copy constructor. More...
 
 ~BaseWall () override
 Default destructor. More...
 
virtual bool getDistanceNormalOverlap (const BaseParticle &P, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const
 
virtual bool getDistanceNormalOverlapSuperquadric (const SuperQuadricParticle &p, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const
 
virtual Vec3D getFurthestPointSuperQuadric (const Vec3D &normalBodyFixed, const Vec3D &axes, Mdouble eps1, Mdouble eps2) const
 
WallHandlergetHandler () const
 A function which returns the WallHandler that handles this BaseWall. More...
 
void setIndSpecies (unsigned int indSpecies) override
 Define the species of this wall using the index of the species in the SpeciesHandler in this DPMBase. More...
 
void setSpecies (const ParticleSpecies *species)
 Defines the species of the current wall. More...
 
bool isFixed () const override
 
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 of the wall. More...
 
virtual bool isLocal (Vec3D &min, Vec3D &max) const
 
bool getLinePlaneIntersect (Vec3D &intersect, const Vec3D &p0, const Vec3D &p1, const Vec3D &n, const Vec3D &p)
 
bool isInsideWallVTK (const Vec3D &point, const Vec3D &normal, const Vec3D &position) const
 
void projectOntoWallVTK (Vec3D &point0, const Vec3D &point1, const Vec3D &normal, const Vec3D &position) const
 
void intersectVTK (std::vector< Vec3D > &points, Vec3D normal, Vec3D position) const
 
virtual BaseInteractiongetInteractionWithSuperQuad (SuperQuadricParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler)
 
void getVTK (std::vector< Vec3D > &points, std::vector< std::vector< double >> &triangleStrips)
 
const Vec3D getAxis () const
 
BaseInteractiongetInteractionWith (BaseParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler) override
 Returns the interaction between this wall and a given particle, nullptr if there is no interaction. More...
 
bool getVTKVisibility () const
 
void setVTKVisibility (bool vtkVisibility)
 
void addRenderedWall (BaseWall *w)
 
BaseWallgetRenderedWall (size_t i) const
 
void removeRenderedWalls ()
 
void renderWall (VTKContainer &vtk)
 
void addParticlesAtWall (unsigned numElements=50)
 
void setVelocityControl (Vec3D forceGoal, Vec3D gainFactor, Vec3D baseVelocity)
 
- Public Member Functions inherited from BaseInteractable
 BaseInteractable ()
 Default BaseInteractable constructor. More...
 
 BaseInteractable (const BaseInteractable &p)
 Copy constructor. More...
 
 ~BaseInteractable () override
 Destructor, it simply destructs the BaseInteractable and all the objects it contains. More...
 
unsigned int getIndSpecies () const
 Returns the index of the species associated with the interactable object. More...
 
const ParticleSpeciesgetSpecies () const
 Returns a pointer to the species of this BaseInteractable. More...
 
void setSpecies (const ParticleSpecies *species)
 Sets the species of this BaseInteractable. More...
 
const Vec3DgetForce () const
 Returns the force on this BaseInteractable. More...
 
const Vec3DgetTorque () const
 Returns the torque on this BaseInteractable. More...
 
void setForce (const Vec3D &force)
 Sets the force on this BaseInteractable. More...
 
void setTorque (const Vec3D &torque)
 Sets the torque on this BaseInteractable. More...
 
void addForce (const Vec3D &addForce)
 Adds an amount to the force on this BaseInteractable. More...
 
void addTorque (const Vec3D &addTorque)
 Adds an amount to the torque on this BaseInteractable. More...
 
void resetForceTorque (int numberOfOMPthreads)
 
void sumForceTorqueOMP ()
 
const Vec3DgetPosition () const
 Returns the position of this BaseInteractable. More...
 
const QuaterniongetOrientation () const
 Returns the orientation of this BaseInteractable. More...
 
void setPosition (const Vec3D &position)
 Sets the position of this BaseInteractable. More...
 
void setOrientationViaNormal (Vec3D normal)
 Sets the orientation of this BaseInteractable by defining the vector that results from the rotation of the (1,0,0) vector. More...
 
void setOrientationViaEuler (Vec3D eulerAngle)
 Sets the orientation of this BaseInteractable by defining the euler angles. More...
 
void setOrientation (const Quaternion &orientation)
 Sets the orientation of this BaseInteractable. More...
 
virtual void move (const Vec3D &move)
 Moves this BaseInteractable by adding an amount to the position. More...
 
virtual void rotate (const Vec3D &angularVelocityDt)
 Rotates this BaseInteractable. More...
 
const std::vector
< BaseInteraction * > & 
getInteractions () const
 Returns a list of interactions which belong to this interactable. More...
 
void addInteraction (BaseInteraction *I)
 Adds an interaction to this BaseInteractable. More...
 
bool removeInteraction (BaseInteraction *I)
 Removes an interaction from this BaseInteractable. More...
 
void copyInteractionsForPeriodicParticles (const BaseInteractable &p)
 Copies interactions to this BaseInteractable whenever a periodic copy made. More...
 
void setVelocity (const Vec3D &velocity)
 set the velocity of the BaseInteractable. More...
 
void setAngularVelocity (const Vec3D &angularVelocity)
 set the angular velocity of the BaseInteractble. More...
 
void addVelocity (const Vec3D &velocity)
 adds an increment to the velocity. More...
 
void addAngularVelocity (const Vec3D &angularVelocity)
 add an increment to the angular velocity. More...
 
virtual const Vec3DgetVelocity () const
 Returns the velocity of this interactable. More...
 
virtual const Vec3DgetAngularVelocity () const
 Returns the angular velocity of this interactable. More...
 
void setPrescribedPosition (const std::function< Vec3D(double)> &prescribedPosition)
 Allows the position of an infinite mass interactable to be prescribed. More...
 
void applyPrescribedPosition (double time)
 Computes the position from the user defined prescribed position function. More...
 
void setPrescribedVelocity (const std::function< Vec3D(double)> &prescribedVelocity)
 Allows the velocity of an infinite mass interactable to be prescribed. More...
 
void applyPrescribedVelocity (double time)
 Computes the velocity from the user defined prescribed velocity function. More...
 
void setPrescribedOrientation (const std::function< Quaternion(double)> &prescribedOrientation)
 Allows the orientation of the infinite mass interactbale to be prescribed. More...
 
void applyPrescribedOrientation (double time)
 Computes the orientation from the user defined prescribed orientation function. More...
 
void setPrescribedAngularVelocity (const std::function< Vec3D(double)> &prescribedAngularVelocity)
 Allows the angular velocity of the infinite mass interactable to be prescribed. More...
 
void applyPrescribedAngularVelocity (double time)
 Computes the angular velocity from the user defined prescribed angular velocity. More...
 
virtual const Vec3D getVelocityAtContact (const Vec3D &contact) const
 Returns the velocity at the contact point, use by many force laws. More...
 
void integrateBeforeForceComputation (double time, double timeStep)
 This is part of integrate routine for objects with infinite mass. More...
 
void integrateAfterForceComputation (double time, double timeStep)
 This is part of the integration routine for objects with infinite mass. More...
 
virtual Mdouble getInvMass () const
 
virtual Mdouble getCurvature (const Vec3D &labFixedCoordinates) const
 
- Public Member Functions inherited from BaseObject
 BaseObject ()=default
 Default constructor. More...
 
 BaseObject (const BaseObject &p)=default
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()=default
 virtual destructor More...
 
virtual void moveInHandler (unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (unsigned long id)
 Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler. More...
 
unsigned int getIndex () const
 Returns the index of the object in the handler. More...
 
unsigned int getId () const
 Returns the unique identifier of any particular object. More...
 
void setGroupId (unsigned groupId)
 
unsigned getGroupId () const
 

Protected Attributes

std::vector< InfiniteWallwallObjects_
 The wall "segments"/directions that together make up the finite wall. More...
 
std::vector< Vec3DC_
 A vector that stores the intersection point of three different InfiniteWall. More...
 

Private Attributes

std::vector< Vec3DA_
 A vector that stores a point for each intersecting line between two different InfiniteWall. More...
 
std::vector< Vec3DAB_
 A vector that stores the direction of the intersecting lines between two different InfiniteWall. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseWall
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. More...
 

Detailed Description

A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's.

It can be defined as the intersection of a set of InfiniteWall's, defined by the normal vector into the wall and a point on the wall. For example, the following gives a cube |x|<1 and |y|<1:

//for each wall, specify a normal and position vector
w.addObject(Vec3D(-1, 0, 0),Vec3D(1, 0, 0));
w.addObject(Vec3D(1, 0, 0),Vec3D(0, 0, 0));
w.addObject(Vec3D(0, -1, 0),Vec3D(0, 1, 0));
w.addObject(Vec3D(0, 1, 0),Vec3D(0, 0, 0));
wallHandler.copyAndAddObject(w);

A particle of radius *r* and position *x* touches an InfiniteWall with normal *n* and position *p* if \(p-n\cdot x\leq r\) (note 'touching particles' also includes particles that are completely enclosed inside the wall). A particle touches an IntersectionOfWalls if it touches all InfiniteWall objects (shown in the image below).

For a demonstration on how to use this class, see T8: Motion of a particle in a box with an obstacle and Flow through a 3D hourglass/silo (shown in the image below).

Definition at line 58 of file IntersectionOfWalls.h.

Constructor & Destructor Documentation

IntersectionOfWalls::IntersectionOfWalls ( )

Default constructor.

Definition at line 33 of file IntersectionOfWalls.cc.

References DEBUG, and logger.

Referenced by copy().

34 {
35  logger(DEBUG, "IntersectionOfWalls() constructed.");
36 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
IntersectionOfWalls::IntersectionOfWalls ( const IntersectionOfWalls other)

Copy constructor.

Parameters
[in]otherThe IntersectionOfWalls that must be copied.

Definition at line 41 of file IntersectionOfWalls.cc.

References A_, AB_, C_, DEBUG, BaseWall::getHandler(), logger, and wallObjects_.

42  : BaseWall(other)
43 {
44  wallObjects_ = other.wallObjects_;
45  for (auto& wall : wallObjects_)
46  {
47  if (getHandler() != nullptr)
48  wall.setHandler(getHandler());
49  }
50  A_ = other.A_;
51  AB_ = other.AB_;
52  C_ = other.C_;
53  logger(DEBUG, "IntersectionOfWalls(IntersectionOfWalls&) constructed.");
54 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:136
std::vector< Vec3D > C_
A vector that stores the intersection point of three different InfiniteWall.
std::vector< Vec3D > A_
A vector that stores a point for each intersecting line between two different InfiniteWall.
BaseWall()
Default constructor.
Definition: BaseWall.cc:36
std::vector< Vec3D > AB_
A vector that stores the direction of the intersecting lines between two different InfiniteWall...
IntersectionOfWalls::IntersectionOfWalls ( const std::vector< normalAndPosition > &  walls,
const ParticleSpecies species 
)

Constructor setting values.

Definition at line 56 of file IntersectionOfWalls.cc.

References addObject(), and setSpecies().

58 {
59  setSpecies(species);
60  for (auto wall : walls)
61  {
62  addObject(wall.normal, wall.position);
63  }
64 }
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given a normal vector pointing into the wall (i...
void setSpecies(const ParticleSpecies *species)
sets species of subwalls as well
IntersectionOfWalls::~IntersectionOfWalls ( )
override

Destructor.

Definition at line 67 of file IntersectionOfWalls.cc.

References DEBUG, and logger.

68 {
69  logger(DEBUG, "~IntersectionOfWalls() has been called.");
70 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")

Member Function Documentation

void IntersectionOfWalls::add3PointObject ( Vec3D  PointA,
Vec3D  PointB,
Vec3D  PointC 
)
Parameters
PointAfirst coordinate plane passes through;
PointBsecond coordinate plane passes through;
PointCthird coordinate plane passes through;

calls the IntersectionOfWalls::addObject(normal, point) by calculating the normal from these three coordinates

Definition at line 158 of file IntersectionOfWalls.cc.

References addObject(), Vec3D::cross(), ERROR, Vec3D::getLengthSquared(), and logger.

Referenced by addPlate(), addTetra(), and addTetraSTL().

159 {
160  Vec3D SubtB = PointA - PointB;
161  Vec3D SubtC = PointA - PointC;
162 
163  Vec3D WallNormal = Vec3D::cross(SubtB, SubtC);
164  //Check if walls coordinates inline, if true Do not build wall and give error message.
165  if (WallNormal.getLengthSquared() == 0.0)
166  {
167  logger(ERROR,
168  "Error Building IntersectionOfWalls::add3PointObject out of 3 coordinates. Coordinates are in line, Wall not constructed.");
169  }
170  else
171  {
172  addObject(WallNormal, PointA);
173  }
174 
175 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given a normal vector pointing into the wall (i...
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.h:316
Definition: Vector.h:49
void IntersectionOfWalls::addObject ( Vec3D  normal,
Vec3D  point 
)

Adds a wall to the set of infinite walls, given a normal vector pointing into the wall (i.e. out of the simulation domain), going through the point, so that normal*x=normal*point.

Parameters
[in]normalThe normal to this wallObject.
[in]pointOne of the points of the wallObject.

Adds a wall to the set of finite walls, given an outward unit normal vector s.t. normal*x=normal*point for all x of the wallObject. First make the InfiniteWall, then compute all intersections, which are then stored in A_, AB_ and C_.

Definition at line 137 of file IntersectionOfWalls.cc.

References BaseInteractable::getSpecies(), Vec3D::normalise(), InfiniteWall::set(), setPointsAndLines(), BaseWall::setSpecies(), and wallObjects_.

Referenced by add3PointObject(), ChuteWithHopper::addHopper(), addObject(), createOpenPrism(), createPrism(), IntersectionOfWalls(), read(), and WallHandler::readAndCreateOldObject().

138 {
139  normal.normalise();
140 
141  //n is the index of the new wall
142  std::size_t n = wallObjects_.size();
143  InfiniteWall w;
144  if (getSpecies()) w.setSpecies(getSpecies());
145  w.set(normal, point);
146  wallObjects_.push_back(w);
148 }
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
void normalise()
Makes this Vec3D unit length.
Definition: Vector.cc:123
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
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...
This is a class defining walls.
Definition: InfiniteWall.h:47
void setPointsAndLines(unsigned int n)
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:171
void IntersectionOfWalls::addObject ( Quaternion  orientation,
Vec3D  position 
)
Parameters
[in]normalThe normal to this wallObject.
[in]positionOne of the points of the wallObject.

Adds a wall to the set of finite walls, given an outward unit normal vector s.t. normal*x=normal*point for all x of the wallObject. First make the InfiniteWall, then compute all intersections, which are then stored in A_, AB_ and C_.

Definition at line 338 of file IntersectionOfWalls.cc.

References BaseInteractable::getSpecies(), BaseInteractable::setOrientation(), setPointsAndLines(), BaseInteractable::setPosition(), BaseWall::setSpecies(), and wallObjects_.

339 {
340  //n is the index of the new wall
341  std::size_t n = wallObjects_.size();
342  InfiniteWall w;
343  if (getSpecies()) w.setSpecies(getSpecies());
344  w.setOrientation(orientation);
345  w.setPosition(position);
346  wallObjects_.push_back(w);
348 }
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
This is a class defining walls.
Definition: InfiniteWall.h:47
void setOrientation(const Quaternion &orientation)
Sets the orientation of this BaseInteractable.
void setPointsAndLines(unsigned int n)
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:171
void IntersectionOfWalls::addObject ( Vec3D  normal,
Mdouble  position 
)

Adds a wall to the set of finite walls, given an normal vector pointing into the wall (i.e. out of the flow domain), to give a plane defined by normal*x=position.

Deprecated:
Don't use this function, instead use the function addObject(Vec3D, Vec3D).
Parameters
[in]normalThe normal to the wallObject.
[in]positionThe position of the wallObject in the direction of the normal vector.

Definition at line 452 of file IntersectionOfWalls.cc.

References addObject(), logger, and WARN.

453 {
454  logger(WARN, "This function is deprecated, use IntersectionOfWalls::addObject(Vec3D, Vec3D) instead.");
455  addObject(normal, position * normal);
456 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given a normal vector pointing into the wall (i...
void IntersectionOfWalls::addPlate ( const Vec3D PointA,
const Vec3D PointB,
const Vec3D PointC,
const Vec3D WallNormal,
const Mdouble Thickness,
int  wallidentifier 
)

Definition at line 296 of file IntersectionOfWalls.cc.

References add3PointObject(), and Vec3D::getLengthSquared().

298 {
299 
300  //Check if walls coordinates inline, if true Do not build wall and give error message. But keep continuing
301  if (WallNormal.getLengthSquared() == 0.0)
302  {
303  std::cout << "Error Building Plate number " << wallidentifier
304  << "out of 3 coordinates. Coordinates are in line, Wall not constructed." << std::endl;
305  }
306  else
307  {
308  Vec3D PointAT = PointA - WallNormal * Thickness;
309  Vec3D PointBT = PointB - WallNormal * Thickness;
310  Vec3D PointCT = PointC - WallNormal * Thickness;
311 
312  //generate the base wall first through the input coordinates
313  add3PointObject(PointC, PointB, PointA);
314 
315  //add sidewalls
316  add3PointObject(PointA, PointB, PointAT);
317  add3PointObject(PointB, PointC, PointBT);
318  add3PointObject(PointC, PointA, PointCT);
319 
320 
321  //add opposite wall
322  add3PointObject(PointAT, PointBT, PointCT);
323 
324 
325  }
326 
327 
328 }
void add3PointObject(Vec3D PointA, Vec3D PointB, Vec3D PointC)
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.h:316
Definition: Vector.h:49
void IntersectionOfWalls::addTetra ( const Vec3D PointA,
const Vec3D PointB,
const Vec3D PointC,
Mdouble Thickness 
)

constructs a tetrahedron from 3 input coordinates

Parameters
PointAfirst coordinate plane passes through;
PointBsecond coordinate plane passes through;
PointCthird coordinate plane passes through;
Thicknessthe height of the apex

constructs a tethrahedron with the apex in the direction according to the right hand rule

Definition at line 259 of file IntersectionOfWalls.cc.

References add3PointObject(), Vec3D::cross(), ERROR, Vec3D::getLengthSquared(), and logger.

260 {
261 
262  //generate other coordinate by finding the centre and shift it the distance thickness in the normal direction
263  //calculate normal
264  Vec3D SubtB = PointA - PointB;
265  Vec3D SubtC = PointA - PointC;
266 
267  Vec3D WallNormal = Vec3D::cross(SubtB, SubtC);
268 
269  //Check if walls coordinates inline, if true Do not build wall and give error message.
270  if (WallNormal.getLengthSquared() == 0.0)
271  {
272  logger(ERROR,
273  "Error Building IntersectionOfWalls::addTetra out of 3 coordinates. "
274  "Coordinates are in line, Wall not constructed.");
275  }
276  else
277  {
278  //calculate centroid
279  Vec3D mid = (PointA + PointB + PointC) / 3.0;
280  //shift centroid in normal direction
281  Vec3D midT = mid + WallNormal * Thickness;
282  //generate the base wall first through the input coordinates
283  add3PointObject(PointC, PointB, PointA);
284 
285  //add sidewalls
286  add3PointObject(PointA, midT, PointB);
287  add3PointObject(PointB, midT, PointC);
288  add3PointObject(PointC, midT, PointA);
289  }
290 }
void add3PointObject(Vec3D PointA, Vec3D PointB, Vec3D PointC)
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.h:316
Definition: Vector.h:49
void IntersectionOfWalls::addTetraSTL ( Vec3D  PointA,
Vec3D  PointB,
Vec3D  PointC,
Vec3D  WallNormal,
Mdouble  Thickness,
int  wallidentifier 
)

constructs a tetrahedron for an STL file input

Parameters
PointAfirst coordinate plane passes through;
PointBsecond coordinate plane passes through;
PointCthird coordinate plane passes through;
WallNormalthe normal of the wal of the plane, Please note that the Wallnormal input is defined inverse to other Mercury functions Due to the usage of this function for reading in STL files
Thicknessthe height of the apex
wallidentifierto identify which wall does not get constructed for bug finding in STL files

constructs a tethrahedron with the apex in minus normal direction.

Definition at line 190 of file IntersectionOfWalls.cc.

References add3PointObject(), Vec3D::cross(), Vec3D::dot(), Vec3D::getLengthSquared(), and Vec3D::normalise().

192 {
193  //Check if wall coordinates inline, if true Do not build wall and give error message. But keep continuing
194  if (WallNormal.getLengthSquared() == 0.0)
195  {
196  std::cout << "Error Building Plate number " << wallidentifier
197  << "out of 3 coordinates. Coordinates are in line, Wall not constructed." << std::endl;
198  }
199  else
200  {
201  //do a check whether the normal follows the RHR (Right Hand Rule) or not
202  //todo: Bert Use this check a lot, possibly make a function of this
203  Vec3D SubtB = PointA - PointB;
204  Vec3D SubtC = PointA - PointC;
205 
206  Vec3D WallNormalRHR = Vec3D::cross(SubtB, SubtC);
207 
208  //normalise for easy check
209  WallNormalRHR.normalise();
210  WallNormal.normalise();
211 
212  //if RHRchecl is 1, wall normal and RHR normal are in same direction, if -1 theyre not, then point B and C need to be swapped
213  Mdouble RHRcheck = Vec3D::dot(WallNormalRHR, WallNormal);
214  //todo: Bert Officially need to check for other answers than 1, however, it will either be -1 or 1 in ideal case
215 
216  if (RHRcheck == 1)
217  {
218  //calculate centroid
219  Vec3D mid = (PointA + PointB + PointC) / 3.0;
220  //shift centroid in normal direction
221  //mental note: if Same direction as STL normal it should be subtracted to go IN the wall
222  Vec3D midT = mid - WallNormalRHR * Thickness;
223  //generate the base wall first through the input coordinates
224  add3PointObject(PointA, PointC, PointB);
225 
226  //add sidewalls
227  add3PointObject(PointA, midT, PointC);
228  add3PointObject(PointC, midT, PointB);
229  add3PointObject(PointB, midT, PointA);
230  }
231  else
232  {
233  //calculate centroid
234  Vec3D mid = (PointA + PointB + PointC) / 3.0;
235  //shift centroid in normal direction
236  //mental note: if opposite direction as STL normal it should be added to go IN the wall
237  Vec3D midT = mid + WallNormalRHR * Thickness;
238  //generate the base wall first through the input coordinates
239  add3PointObject(PointA, PointB, PointC);
240 
241  //add sidewalls
242  add3PointObject(PointA, midT, PointB);
243  add3PointObject(PointB, midT, PointC);
244  add3PointObject(PointC, midT, PointA);
245  }
246 
247  }
248 }
void add3PointObject(Vec3D PointA, Vec3D PointB, Vec3D PointC)
double Mdouble
Definition: GeneralDefine.h:34
void normalise()
Makes this Vec3D unit length.
Definition: Vector.cc:123
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.h:316
Definition: Vector.h:49
void IntersectionOfWalls::clear ( )

Removes all parts of the walls.

Definition at line 102 of file IntersectionOfWalls.cc.

References A_, AB_, C_, and wallObjects_.

Referenced by createOpenPrism().

103 {
104  wallObjects_.clear();
105  A_.clear();
106  AB_.clear();
107  C_.clear();
108 }
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
std::vector< Vec3D > C_
A vector that stores the intersection point of three different InfiniteWall.
std::vector< Vec3D > A_
A vector that stores a point for each intersecting line between two different InfiniteWall.
std::vector< Vec3D > AB_
A vector that stores the direction of the intersecting lines between two different InfiniteWall...
IntersectionOfWalls * IntersectionOfWalls::copy ( ) const
overridevirtual

Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.

Returns
pointer to a IntersectionOfWalls object allocated using new.

Implements BaseWall.

Reimplemented in ScrewsymmetricIntersectionOfWalls.

Definition at line 97 of file IntersectionOfWalls.cc.

References IntersectionOfWalls().

Referenced by operator=().

98 {
99  return new IntersectionOfWalls(*this);
100 }
IntersectionOfWalls()
Default constructor.
void IntersectionOfWalls::createOpenPrism ( std::vector< Vec3D points,
Vec3D  prismAxis 
)

Creates an open prism which is a polygon between the points, except the first and last point, and extends infinitely in the PrismAxis direction. Note that if you view from inside of your geometry, the shape formed by points has to be convex, otherwise it will not create the wall correctly.

Parameters
[in]pointsA vector of 3D-vectors which contains the points between which the polygon is drawn.
[in]prismAxisA 3D-vector which represents the direction in which the prism is extended infinitely.

Create an open prism which is a polygon with no connection between the first and last point, and extending infinitely in the other direction, which is defined as PrismAxis. Do this by adding the walls between the consecutive points one by one.

Definition at line 466 of file IntersectionOfWalls.cc.

References addObject(), clear(), Vec3D::cross(), and constants::i.

Referenced by createOpenPrism(), and createPrism().

467 {
468  clear();
469  //note: use i+1 < points.size() instead of i < points.size()-1, otherwise it creates havoc if point has zero entries.
470  for (unsigned int i = 0; i + 1 < points.size(); i++)
471  addObject(Vec3D::cross(points[i] - points[i + 1], prismAxis), points[i]);
472 }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given a normal vector pointing into the wall (i...
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
void clear()
Removes all parts of the walls.
void IntersectionOfWalls::createOpenPrism ( std::vector< Vec3D points)

Creates an open prism which is a polygon between the points, except the first and last point, and extends infinitely in the direction perpendicular to the first and second wall. Note that if you view from inside of your geometry, the shape formed by points has to be convex, otherwise it will not create the wall correctly.

Parameters
[in]pointsA vector of 3D-vectors which contains the points between which the polygon is drawn.

Create an open prism which is a polygon with no connection between the first and last point, and extending infinitely in the direction perpendicular to the first and second wall. Do this by first computing in which direction the wall must be extended infinitely, then call createOpenPrism(points, prismAxis).

Definition at line 494 of file IntersectionOfWalls.cc.

References createOpenPrism(), Vec3D::cross(), and Vec3D::getUnitVector().

495 {
496  Vec3D prismAxis = Vec3D::cross(
497  Vec3D::getUnitVector(points[1] - points[0]),
498  Vec3D::getUnitVector(points[2] - points[0]));
499  createOpenPrism(points, prismAxis);
500 }
static Vec3D getUnitVector(const Vec3D &a)
Returns a unit Vec3D based on a.
Definition: Vector.cc:345
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...
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
Definition: Vector.h:49
void IntersectionOfWalls::createPrism ( std::vector< Vec3D points,
Vec3D  prismAxis 
)

Creates an open prism which is a polygon between the points and extends infinitely in the PrismAxis direction. Note that if you view from inside of your geometry, the shape formed by points has to be convex, otherwise it will not create the wall correctly.

Parameters
[in]pointsA vector of 3D-vectors which contains the points between which the polygon is drawn.
[in]prismAxisA 3D-vector which represents the direction in which the prism is extended infinitely.

Create an open prism which is a polygon and extending infinitely in the other direction, which is defined as PrismAxis. Do this by first creating an open prism and then connect the last and the first point.

Definition at line 481 of file IntersectionOfWalls.cc.

References addObject(), createOpenPrism(), and Vec3D::cross().

Referenced by createPrism().

482 {
483  createOpenPrism(points, prismAxis);
484  addObject(Vec3D::cross(points.back() - points.front(), prismAxis), points.front());
485 }
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given a normal vector pointing into the wall (i...
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...
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
void IntersectionOfWalls::createPrism ( std::vector< Vec3D points)

Creates an open prism which is a polygon between the points and extends infinitely in the direction perpendicular to the first and second wall. Note that if you view from inside of your geometry, the shape formed by points has to be convex, otherwise it will not create the wall correctly.

Parameters
[in]pointsA vector of 3D-vectors which contains the points between which the polygon is drawn.

Create an open prism which is a polygon, and extending infinitely in the direction perpendicular to the first and second wall. Do this by first computing in which direction the wall must be extended infinitely, then call createOpenPrism(points, prismAxis).

Definition at line 509 of file IntersectionOfWalls.cc.

References createPrism(), Vec3D::cross(), and Vec3D::getUnitVector().

510 {
511  Vec3D prismAxis = Vec3D::cross(
512  Vec3D::getUnitVector(points[1] - points[0]),
513  Vec3D::getUnitVector(points[2] - points[0]));
514  createPrism(points, prismAxis);
515 }
static Vec3D getUnitVector(const Vec3D &a)
Returns a unit Vec3D based on a.
Definition: Vector.cc:345
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
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: Vector.h:49
bool IntersectionOfWalls::getDistanceAndNormal ( const BaseParticle p,
Mdouble distance,
Vec3D normal_return 
) const
overridevirtual

Compute the distance from the wall for a given BaseParticle and return if there is a collision. If there is a collision, also return the normal vector.

Parameters
[in]pBaseParticle we want to calculate the distance and whether it collided of.
[out]distanceThe distance of the BaseParticle to this wall.
[out]normal_returnIf there was a collision, the normal vector to this wall will be placed here.
Returns
A boolean which says whether or not there was a collision.

This function computes whether or not there is a collision between a given BaseParticle and this IntersectionOfWalls. If there is a collision, this function also computes the distance between the BaseParticle and IntersectionOfWalls and the normal of the IntersectionOfWalls at the intersection point. It does this by calling IntersectionOfWalls::getDistanceAndNormal(const Vec3D& , Mdouble , Mdouble&, Vec3D&) const. Since this function should be called before calculating any Particle-Wall interactions, it can also be used to set the normal vector in case of curved walls.

Todo:
do this for all walls

Implements BaseWall.

Reimplemented in ScrewsymmetricIntersectionOfWalls.

Definition at line 531 of file IntersectionOfWalls.cc.

References BaseHandler< T >::getDPMBase(), BaseWall::getHandler(), BaseSpecies::getInteractionDistance(), SpeciesHandler::getMixedObject(), BaseInteractable::getOrientation(), BaseInteractable::getPosition(), BaseParticle::getRadius(), BaseInteractable::getSpecies(), Quaternion::rotate(), Quaternion::rotateBack(), and DPMBase::speciesHandler.

Referenced by HorizontalBaseScrew::getDistanceAndNormal(), ScrewsymmetricIntersectionOfWalls::getDistanceAndNormal(), and AxisymmetricIntersectionOfWalls::getDistanceAndNormal().

532 {
533  //transform coordinates into position-orientation frame
534  Vec3D position = p.getPosition() - getPosition();
535  getOrientation().rotateBack(position);
538  if (getDistanceAndNormal(position, p.getRadius() + s->getInteractionDistance(), distance, normal_return))
539  {
540  getOrientation().rotate(normal_return);
541  return true;
542  }
543  else
544  {
545  return false;
546  }
547 }
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:49
void rotateBack(Vec3D &position) const
Applies the inverse rotation to a position.
Definition: Quaternion.cc:592
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
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...
void rotate(Vec3D &position) const
Applies the rotation to a position.
Definition: Quaternion.cc:563
Mdouble getInteractionDistance() const
returns the largest separation distance at which adhesive short-range forces can occur.
Definition: BaseSpecies.h:146
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:136
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:345
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1319
Definition: Vector.h:49
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
bool IntersectionOfWalls::getDistanceAndNormal ( const Vec3D position,
Mdouble  wallInteractionRadius,
Mdouble distance,
Vec3D normal_return 
) const

Compute the distance from the wall for a given BaseParticle and return if there is an interaction. If there is an interaction, also return the normal vector.

Parameters
[in]positionThe position of the object there is possible an interaction with.
[in]wallInteractionRadiusThe maximum distance between the IntersectionOfWalls and the input argument position for which there is an interaction.
[out]distanceThe distance of the object at position to this wall.
[out]normal_returnIf there was an interaction, the normal vector to this wall will be placed here.
Returns
A boolean which says whether or not there was an interaction.

This function computes whether a particle at the given position (position) and radius (wallInteractionRadius) overlaps with the IntersectionOfWalls.

  • First, the distances to each InfiniteWall is computed, and the three walls with the largest distances (smallest overlaps) are identified (distance, distance2, distance3, id, id2, id3).
  • If the largest distance is bigger than the wallInteractionRadius, there is no contact. This, if any distance>wallInteractionRadius is detected we return false.
  • If the second-largest distance is bigger than the wallInteractionRadius, it is a face contact (contact with a single wall.
  • Otherwise, we need to determine if it is a edge or vertex contact. In the latter two cases, the function returns true, and the distance and normal vector is returned.

Definition at line 566 of file IntersectionOfWalls.cc.

References A_, AB_, C_, DEBUG, Vec3D::dot(), Vec3D::getLengthSquared(), constants::i, logger, and wallObjects_.

568 {
569  if (wallObjects_.empty())
570  {
571  logger(DEBUG, "Empty IntersectionOfWalls");
572  return false;
573  }
574 
575  distance = -1e20;
576  Mdouble distance2 = -1e20;
577  Mdouble distance3 = -1e20;
578  Mdouble distanceCurrent;
579  unsigned int id = 0;
580  unsigned int id2 = 0;
581  unsigned int id3 = 0;
582 
583  //For each wall we calculate the distance (distanceCurrent). To compute The walls with the minimal overlap
584  //The object has to touch each wall each wall (distanceCurrent) and keep the minimum distance (distance) and wall index (id
585  for (unsigned int i = 0; i < wallObjects_.size(); i++)
586  {
587  // Calculate distance to each wall (distanceCurrent);
588  distanceCurrent = wallObjects_[i].getDistance(position);
589  // The object has to touch each wall (distanceCurrent >= wallInteractionRadius), otherwise return false (i.e. no contact)
590  // This means that for each InfiniteWall in wallObjects_, the particle is either "inside"
591  // the wall or touching it. If not, there is no interaction.
592  if (distanceCurrent >= wallInteractionRadius)
593  {
594  return false;
595  }
596  // Find out which of the InfiniteWalls is interacting with the particle.
597  // Keep the minimum distance (distance) and wall index (id)
598  // and store up to two walls (id2, id3) and their distances (distance2, distance3),
599  // if the possible contact point is near the intersection between id and id2 (and id3)
600  if (distanceCurrent > distance)
601  {
602  if (distance > -wallInteractionRadius) //if distance was set previously
603  {
604  if (distance2 > -wallInteractionRadius) //if distance2 was set previously
605  {
606  distance3 = distance2;
607  id3 = id2;
608  }
609  distance2 = distance;
610  id2 = id;
611  }
612  distance = distanceCurrent;
613  id = i;
614  }
615  else if (distanceCurrent < -wallInteractionRadius)
616  {
617  continue;
618  }
619  else if (distanceCurrent > distance2)
620  {
621  if (distance2 > -wallInteractionRadius) //if distance2 was set previously
622  {
623  distance3 = distance2;
624  id3 = id2;
625  }
626  distance2 = distanceCurrent;
627  id2 = i;
628  }
629  else if (distanceCurrent > distance3)
630  {
631  distance3 = distanceCurrent;
632  id3 = i;
633  }
634  }
635 
636  //If we are here, the closest wall is id;
637  //if distance2>-P.Radius (and distance3>-P.Radius), the possible contact point
638  // is near the intersection between id and id2 (and id3)
639  if (distance2 > -wallInteractionRadius)
640  {
641  //D is the point on wall id closest to P
642  Vec3D D = position + wallObjects_[id].getNormal() * distance;
643  //If the distance of D to id2 is positive, the contact is with the intersection
644  bool intersection_with_id2 = (wallObjects_[id2].getDistance(D) > 0.0);
645 
646  if (distance3 > -wallInteractionRadius && (wallObjects_[id3].getDistance(D) > 0.0))
647  {
648  //E is the point on wall id2 closest to P
649  Vec3D E = position + wallObjects_[id2].getNormal() * distance2;
650  //If the distance of D to id2 is positive, the contact is with the intersection
651  bool intersection_with_id3 = (wallObjects_[id3].getDistance(E) > 0.0);
652 
653  if (intersection_with_id2)
654  {
655  if (intersection_with_id3)
656  {
657  //possible contact is with intersection of id,id2,id3
658  //we know id2<id3
659  if (id2 > id3)
660  {
661  auto id = id2;
662  id2 = id3;
663  id3 = id;
664  }
665  unsigned int index =
666  (id < id2) ? ((id3 - 2) * (id3 - 1) * id3 / 6 + (id2 - 1) * id2 / 2 + id) :
667  (id < id3) ? ((id3 - 2) * (id3 - 1) * id3 / 6 + (id - 1) * id / 2 + id2) :
668  ((id - 2) * (id - 1) * id / 6 + (id3 - 1) * id3 / 2 + id2);
669  normal_return = position - C_[index];
670  distance = sqrt(normal_return.getLengthSquared());
671  if (distance <= wallInteractionRadius) //note what if nan?
672  {
673  normal_return /= -distance;
674  return true; //contact with id,id2,id3
675  }
676  else
677  {
678  if (distance == distance)
679  return false;
680  }
681  }
682  }
683  else
684  {
685  intersection_with_id2 = true;
686  distance2 = distance3;
687  id2 = id3;
688  }
689  }
690 
691  if (intersection_with_id2)
692  { //possible contact is with intersection of id,id2
693  unsigned int index = (id > id2) ? ((id - 1) * id / 2 + id2) : ((id2 - 1) * id2 / 2 + id);
694  Vec3D AC = position - A_[index];
695  normal_return = AC - AB_[index] * Vec3D::dot(AC, AB_[index]);
696  distance = sqrt(normal_return.getLengthSquared());
697  if (distance <= wallInteractionRadius) //note what if nan?
698  {
699  normal_return /= -distance;
700  return true; //contact with id,id2,id3
701  }
702  else
703  {
704  if (distance == distance)
705  return false;
706  }
707  }
708  }
709  //contact is with id
710  normal_return = wallObjects_[id].getNormal();
711  return true;
712 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
std::vector< Vec3D > C_
A vector that stores the intersection point of three different InfiniteWall.
std::vector< Vec3D > A_
A vector that stores a point for each intersecting line between two different InfiniteWall.
std::vector< Vec3D > AB_
A vector that stores the direction of the intersecting lines between two different InfiniteWall...
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.h:316
Definition: Vector.h:49
std::string IntersectionOfWalls::getName ( ) const
overridevirtual

Returns the name of the object, here the string "IntersectionOfWalls".

Returns
The string "IntersectionOfWalls".

Implements BaseObject.

Reimplemented in ScrewsymmetricIntersectionOfWalls.

Definition at line 788 of file IntersectionOfWalls.cc.

789 {
790  return "IntersectionOfWalls";
791 }
unsigned int IntersectionOfWalls::getNumberOfObjects ( )

Returns the number of objects.

Suppose your simulation adds to an IntersectionOfWalls after a certain time or condition is met. Checking the number of objects is useful for checking if this has happened yet, when restarting.

Definition at line 124 of file IntersectionOfWalls.cc.

References wallObjects_.

125 {
126  return wallObjects_.size();
127 }
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
IntersectionOfWalls & IntersectionOfWalls::operator= ( const IntersectionOfWalls other)

Copy assignment operator.

Parameters
[in]otherThe IntersectionOfWalls that must be copied.

Definition at line 84 of file IntersectionOfWalls.cc.

References copy(), DEBUG, and logger.

85 {
86  logger(DEBUG, "IntersectionOfWalls::operator= called.");
87  if (this == &other)
88  {
89  return *this;
90  }
91  return *(other.copy());
92 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
IntersectionOfWalls * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
void IntersectionOfWalls::read ( std::istream &  is)
overridevirtual

Move the IntersectionOfWalls to a new position, which is a Vec3D from the old position.

Todo:
currently the IntersectionOfWall is special for moving and rotating; should we remove that specialty?

Reads an IntersectionOfWalls from an input stream, for example a restart file.

Parameters
[in]moveA reference to a Vec3D that denotes the direction and length it should be moved with.

A function that moves the InterSectionOfWalls in a certain direction by both moving the walls and all intersections. Note that the directions of the intersections are not moved since they don't change when moving the IntersectionOfWalls as a whole.

Todo:
We should use the position_ and orientation_ of the IntersectionOfWalls; that way, IntersectionOfWalls can be moved with the standard BaseInteractable::move function, getting rid of an anomaly in the code and removing the virtual from the move function.
Author
weinhartt
Parameters
[in]isThe input stream from which the IntersectionOfWalls is read, usually a restart file.

Reimplemented from BaseWall.

Reimplemented in ScrewsymmetricIntersectionOfWalls.

Definition at line 745 of file IntersectionOfWalls.cc.

References addObject(), constants::i, and BaseWall::read().

Referenced by HorizontalBaseScrew::read(), AxisymmetricIntersectionOfWalls::read(), and ScrewsymmetricIntersectionOfWalls::read().

746 {
747  BaseWall::read(is);
748  std::string dummy;
749  int n;
750  is >> dummy >> n;
751 
752  Vec3D normal;
753  Vec3D position;
754  for (int i = 0; i < n; i++)
755  {
756  is >> dummy;
757  if (dummy != "normal")
758  {
759  Quaternion orientation;
760  is >> position >> dummy >> orientation;
761  addObject(orientation, position);
762  }
763  else
764  {
765  is >> normal >> dummy >> position;
766  addObject(normal, position);
767  }
768  }
769 }
Implementation of a 3D quaternion (by Vitaliy).
Definition: Quaternion.h:62
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given a normal vector pointing into the wall (i...
void read(std::istream &is) override
Function that reads a BaseWall from an input stream, usually a restart file.
Definition: BaseWall.cc:80
Definition: Vector.h:49
void IntersectionOfWalls::setHandler ( WallHandler handler)
overridevirtual

A function which sets the WallHandler for this BaseWall.

Setting the WallHandler also sets the DPMBase and therefore the SpeciesHandler for the species. This wall's species pointer is updated to the new SpeciesHandler.

Parameters
[in]handler- A pointer to the WallHandler that we want to handle this wall.

Reimplemented from BaseWall.

Definition at line 110 of file IntersectionOfWalls.cc.

References BaseWall::setHandler(), and wallObjects_.

111 {
112  BaseWall::setHandler(wallHandler);
113  for (InfiniteWall& w : wallObjects_)
114  {
115  w.setHandler(wallHandler);
116  }
117 }
virtual void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
Definition: BaseWall.cc:127
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
This is a class defining walls.
Definition: InfiniteWall.h:47
void IntersectionOfWalls::setPointsAndLines ( unsigned int  n)

Definition at line 350 of file IntersectionOfWalls.cc.

References A_, AB_, C_, Vec3D::cross(), Vec3D::dot(), BaseInteractable::getPosition(), logger, VERBOSE, wallObjects_, X, Y, and Z.

Referenced by addObject().

351 {
352  // AB[n*(n-1)/2+m] is the direction of the intersecting line between walls m and n, m<n
353  // A[n*(n-1)/2+m] is a point on the intersecting line between walls m and n, m<n
354  // See http://www.netcomuk.co.uk/~jenolive/vect18d.html for finding the line where two planes meet
355  AB_.resize(n * (n + 1) / 2); //0 + 1 + 2 + ... + indexNew, total number of walls you need
356  A_.resize(n * (n + 1) / 2);
357  for (std::size_t m = 0; m < n; m++)
358  {
359  std::size_t id = (n - 1) * n / 2 + m;
360  //first we cross the wall normals and normalise to obtain AB
361  AB_[id] = Vec3D::cross(wallObjects_[m].getNormal(), wallObjects_[n].getNormal());
362  AB_[id] /= sqrt(AB_[id].getLengthSquared());
363  //then we find a point A (using AB*x=0 as a third plane)
364  Mdouble invdet = 1.0 / (+wallObjects_[n].getNormal().X *
365  (wallObjects_[m].getNormal().Y * AB_[id].Z - AB_[id].Y * wallObjects_[m].getNormal().Z)
366  - wallObjects_[n].getNormal().Y * (wallObjects_[m].getNormal().X * AB_[id].Z -
367  wallObjects_[m].getNormal().Z * AB_[id].X)
368  + wallObjects_[n].getNormal().Z * (wallObjects_[m].getNormal().X * AB_[id].Y -
369  wallObjects_[m].getNormal().Y * AB_[id].X));
370 
371  A_[id] = Vec3D(+(wallObjects_[m].getNormal().Y * AB_[id].Z - AB_[id].Y * wallObjects_[m].getNormal().Z) *
372  Vec3D::dot(wallObjects_[n].getPosition(), wallObjects_[n].getNormal())
373  - (wallObjects_[n].getNormal().Y * AB_[id].Z - wallObjects_[n].getNormal().Z * AB_[id].Y) *
374  Vec3D::dot(wallObjects_[m].getPosition(), wallObjects_[m].getNormal())
375  + (wallObjects_[n].getNormal().Y * wallObjects_[m].getNormal().Z -
376  wallObjects_[n].getNormal().Z * wallObjects_[m].getNormal().Y) * 0.0,
377  -(wallObjects_[m].getNormal().X * AB_[id].Z - wallObjects_[m].getNormal().Z * AB_[id].X) *
378  Vec3D::dot(wallObjects_[n].getPosition(), wallObjects_[n].getNormal())
379  + (wallObjects_[n].getNormal().X * AB_[id].Z - wallObjects_[n].getNormal().Z * AB_[id].X) *
380  Vec3D::dot(wallObjects_[m].getPosition(), wallObjects_[m].getNormal())
381  - (wallObjects_[n].getNormal().X * wallObjects_[m].getNormal().Z -
382  wallObjects_[m].getNormal().X * wallObjects_[n].getNormal().Z) * 0.0,
383  +(wallObjects_[m].getNormal().X * AB_[id].Y - AB_[id].X * wallObjects_[m].getNormal().Y) *
384  Vec3D::dot(wallObjects_[n].getPosition(), wallObjects_[n].getNormal())
385  - (wallObjects_[n].getNormal().X * AB_[id].Y - AB_[id].X * wallObjects_[n].getNormal().Y) *
386  Vec3D::dot(wallObjects_[m].getPosition(), wallObjects_[m].getNormal())
387  + (wallObjects_[n].getNormal().X * wallObjects_[m].getNormal().Y -
388  wallObjects_[m].getNormal().X * wallObjects_[n].getNormal().Y) * 0.0) * invdet;
389  }
390 
391  // C[(n-2)*(n-1)*n/6+(m-1)*m/2+l] is a point intersecting walls l, m and n, l<m<n
392  C_.resize((n - 1) * n * (n + 1) / 6);
393  for (std::size_t m = 0; m < n; m++)
394  {
395  for (std::size_t l = 0; l < m; l++)
396  {
397  std::size_t id = (n - 2) * (n - 1) * n / 6 + (m - 1) * m / 2 + l;
398  Mdouble invdet = 1.0 / (+wallObjects_[n].getNormal().X *
399  (wallObjects_[m].getNormal().Y * wallObjects_[l].getNormal().Z -
400  wallObjects_[l].getNormal().Y * wallObjects_[m].getNormal().Z)
401  - wallObjects_[n].getNormal().Y *
402  (wallObjects_[m].getNormal().X * wallObjects_[l].getNormal().Z -
403  wallObjects_[m].getNormal().Z * wallObjects_[l].getNormal().X)
404  + wallObjects_[n].getNormal().Z *
405  (wallObjects_[m].getNormal().X * wallObjects_[l].getNormal().Y -
406  wallObjects_[m].getNormal().Y * wallObjects_[l].getNormal().X));
407  C_[id] = Vec3D(+(wallObjects_[m].getNormal().Y * wallObjects_[l].getNormal().Z -
408  wallObjects_[l].getNormal().Y * wallObjects_[m].getNormal().Z) *
409  Vec3D::dot(wallObjects_[n].getPosition(), wallObjects_[n].getNormal())
410  - (wallObjects_[n].getNormal().Y * wallObjects_[l].getNormal().Z -
411  wallObjects_[n].getNormal().Z * wallObjects_[l].getNormal().Y) *
412  Vec3D::dot(wallObjects_[m].getPosition(), wallObjects_[m].getNormal())
413  + (wallObjects_[n].getNormal().Y * wallObjects_[m].getNormal().Z -
414  wallObjects_[n].getNormal().Z * wallObjects_[m].getNormal().Y) *
415  Vec3D::dot(wallObjects_[l].getPosition(), wallObjects_[l].getNormal()),
416  -(wallObjects_[m].getNormal().X * wallObjects_[l].getNormal().Z -
417  wallObjects_[m].getNormal().Z * wallObjects_[l].getNormal().X) *
418  Vec3D::dot(wallObjects_[n].getPosition(), wallObjects_[n].getNormal())
419  + (wallObjects_[n].getNormal().X * wallObjects_[l].getNormal().Z -
420  wallObjects_[n].getNormal().Z * wallObjects_[l].getNormal().X) *
421  Vec3D::dot(wallObjects_[m].getPosition(), wallObjects_[m].getNormal())
422  - (wallObjects_[n].getNormal().X * wallObjects_[m].getNormal().Z -
423  wallObjects_[m].getNormal().X * wallObjects_[n].getNormal().Z) *
424  Vec3D::dot(wallObjects_[l].getPosition(), wallObjects_[l].getNormal()),
425  +(wallObjects_[m].getNormal().X * wallObjects_[l].getNormal().Y -
426  wallObjects_[l].getNormal().X * wallObjects_[m].getNormal().Y) *
427  Vec3D::dot(wallObjects_[n].getPosition(), wallObjects_[n].getNormal())
428  - (wallObjects_[n].getNormal().X * wallObjects_[l].getNormal().Y -
429  wallObjects_[l].getNormal().X * wallObjects_[n].getNormal().Y) *
430  Vec3D::dot(wallObjects_[m].getPosition(), wallObjects_[m].getNormal())
431  + (wallObjects_[n].getNormal().X * wallObjects_[m].getNormal().Y -
432  wallObjects_[m].getNormal().X * wallObjects_[n].getNormal().Y) *
433  Vec3D::dot(wallObjects_[l].getPosition(), wallObjects_[l].getNormal())) * invdet;
434  }
435  }
436 
437  logger(VERBOSE, "%", *this);
438  for (const InfiniteWall& w : wallObjects_)
439  logger(VERBOSE, "wallObject %, %", w.getNormal(), w.getPosition());
440  for (Vec3D v : A_)
441  logger(VERBOSE, "A %", v);
442  for (Vec3D v : AB_)
443  logger(VERBOSE, "AB %", v);
444  for (Vec3D v : C_)
445  logger(VERBOSE, "C %", v);
446 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
std::vector< Vec3D > C_
A vector that stores the intersection point of three different InfiniteWall.
std::vector< Vec3D > A_
A vector that stores a point for each intersecting line between two different InfiniteWall.
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
std::vector< Vec3D > AB_
A vector that stores the direction of the intersecting lines between two different InfiniteWall...
This is a class defining walls.
Definition: InfiniteWall.h:47
Definition: Vector.h:49
void IntersectionOfWalls::setSpecies ( const ParticleSpecies species)

sets species of subwalls as well

Definition at line 72 of file IntersectionOfWalls.cc.

References BaseWall::setSpecies(), and wallObjects_.

Referenced by ChuteWithHopper::addHopper(), IntersectionOfWalls(), and WallHandler::readAndCreateOldObject().

73 {
74  BaseWall::setSpecies(species);
75  for (auto wall : wallObjects_)
76  {
77  wall.setSpecies(species);
78  }
79 }
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:171
void IntersectionOfWalls::write ( std::ostream &  os) const
overridevirtual

Writes an IntersectionOfWalls to an output stream, for example a restart file.

Parameters
[in]osThe output stream where the IntersectionOfWalls must be written to, usually a restart file.

Reimplemented from BaseWall.

Reimplemented in ScrewsymmetricIntersectionOfWalls.

Definition at line 775 of file IntersectionOfWalls.cc.

References wallObjects_, and BaseWall::write().

Referenced by HorizontalBaseScrew::write(), AxisymmetricIntersectionOfWalls::write(), and ScrewsymmetricIntersectionOfWalls::write().

776 {
777  BaseWall::write(os);
778  os << " numIntersectionOfWalls " << wallObjects_.size();
779  for (const auto& wallObject : wallObjects_)
780  {
781  os << " position " << wallObject.getPosition() << " orientation " << wallObject.getOrientation();
782  }
783 }
void write(std::ostream &os) const override
Function that writes a BaseWall to an output stream, usually a restart file.
Definition: BaseWall.cc:102
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
void IntersectionOfWalls::writeVTK ( VTKContainer vtk) const
overridevirtual

adds extra information to the points and triangleStrips vectors needed to plot the wall in vtk format

Parameters
pointsCoordinates of the vertices of the triangulated surfaces (in the VTK file this is called POINTS)
triangleStripsIndices of three vertices forming one triangulated surface (in the VTK file this is called CELL)

Reimplemented from BaseWall.

Reimplemented in ScrewsymmetricIntersectionOfWalls.

Definition at line 793 of file IntersectionOfWalls.cc.

References BaseHandler< T >::getDPMBase(), BaseWall::getHandler(), DPMBase::getMax(), DPMBase::getMin(), BaseInteractable::getOrientation(), BaseInteractable::getPosition(), BaseWall::intersectVTK(), Quaternion::rotate(), and wallObjects_.

794 {
795  Vec3D max = getHandler()->getDPMBase()->getMax()-getPosition();
796  Vec3D min = getHandler()->getDPMBase()->getMin()-getPosition();
797  for (auto wall = wallObjects_.begin(); wall != wallObjects_.end(); wall++)
798  {
799  std::vector<Vec3D> points;
800  wall->createVTK(points, min, max);
801  for (auto other = wallObjects_.begin(); other != wallObjects_.end(); other++)
802  {
803  if (other != wall)
804  {
805  intersectVTK(points, -other->getNormal(), other->getPosition());
806  }
807  }
808  //rotate into real frame
809  for (auto& p : points)
810  {
811  getOrientation().rotate(p);
812  p += getPosition();
813  }
814  wall->addToVTK(points, vtk);
815  }
816 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
void intersectVTK(std::vector< Vec3D > &points, Vec3D normal, Vec3D position) const
Definition: BaseWall.cc:243
Vec3D getMin() const
Definition: DPMBase.h:623
void rotate(Vec3D &position) const
Applies the rotation to a position.
Definition: Quaternion.cc:563
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:136
Vec3D getMax() const
Definition: DPMBase.h:629
Definition: Vector.h:49
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.

Member Data Documentation

std::vector<Vec3D> IntersectionOfWalls::A_
private

A vector that stores a point for each intersecting line between two different InfiniteWall.

A[n*(n-1)/2+m] is a point on the intersecting line between walls m and n, m<n.

Definition at line 227 of file IntersectionOfWalls.h.

Referenced by clear(), getDistanceAndNormal(), IntersectionOfWalls(), and setPointsAndLines().

std::vector<Vec3D> IntersectionOfWalls::AB_
private

A vector that stores the direction of the intersecting lines between two different InfiniteWall.

AB[n*(n-1)/2+m] is the direction of the intersecting line between walls m and n, m<n.

Definition at line 234 of file IntersectionOfWalls.h.

Referenced by clear(), getDistanceAndNormal(), IntersectionOfWalls(), and setPointsAndLines().

std::vector<Vec3D> IntersectionOfWalls::C_
protected

A vector that stores the intersection point of three different InfiniteWall.

C[(n-2)*(n-1)*n/6+(m-1)*m/2+l] is a point intersecting walls l, m and n, l<m<n

Definition at line 242 of file IntersectionOfWalls.h.

Referenced by clear(), getDistanceAndNormal(), IntersectionOfWalls(), and setPointsAndLines().

std::vector<InfiniteWall> IntersectionOfWalls::wallObjects_
protected

The wall "segments"/directions that together make up the finite wall.

An intersection of walls exists of a number of infinite walls that are cut of at the intersection points. These InfiniteWall are saved in this vector called iWObjects_.

Definition at line 219 of file IntersectionOfWalls.h.

Referenced by addObject(), clear(), getDistanceAndNormal(), getNumberOfObjects(), IntersectionOfWalls(), setHandler(), setPointsAndLines(), setSpecies(), write(), HorizontalBaseScrew::writeVTK(), AxisymmetricIntersectionOfWalls::writeVTK(), ScrewsymmetricIntersectionOfWalls::writeVTK(), and writeVTK().


The documentation for this class was generated from the following files: