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)
 
MERCURYDPM_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...
 
virtual void actionsOnRestart ()
 No implementation but can be overidden in its derived classes. More...
 
virtual void actionsAfterParticleGhostUpdate ()
 No implementation but can be overidden in its derived classes. More...
 
virtual void handleParticleAddition (unsigned int id, BaseParticle *p)
 Handles the addition of particles to the particleHandler. More...
 
virtual void handleParticleRemoval (unsigned int id)
 Handles the addition of particles to the particleHandler. More...
 
virtual void checkInteractions (InteractionHandler *interactionHandler, unsigned int timeStamp)
 Check if all interactions are valid. More...
 
bool getVTKVisibility () const
 
void setVTKVisibility (bool vtkVisibility)
 
void addRenderedWall (BaseWall *w)
 
BaseWallgetRenderedWall (size_t i) const
 
std::vector< BaseWall * > getRenderedWalls () const
 
void removeRenderedWalls ()
 
void renderWall (VTKContainer &vtk)
 
void addParticlesAtWall (unsigned numElements=50)
 
void setVelocityControl (Vec3D forceGoal, Vec3D gainFactor, Vec3D baseVelocity)
 
virtual void writeWallDetailsVTK (VTKData &data) const
 
virtual void computeWear ()
 
- 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...
 
virtual 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...
 
virtual 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...
 
virtual 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
 
virtual bool isFaceContact (const Vec3D &normal) 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);
RowVector3d w
Definition: Matrix_resize_int.cpp:3
A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's.
Definition: IntersectionOfWalls.h:38
Definition: Kernel/Math/Vector.h:30

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).

Constructor & Destructor Documentation

◆ IntersectionOfWalls() [1/3]

IntersectionOfWalls::IntersectionOfWalls ( )

Default constructor.

13 {
14  logger(DEBUG, "IntersectionOfWalls() constructed.");
15 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ DEBUG

References DEBUG, and logger.

Referenced by copy().

◆ IntersectionOfWalls() [2/3]

IntersectionOfWalls::IntersectionOfWalls ( const IntersectionOfWalls other)

Copy constructor.

Parameters
[in]otherThe IntersectionOfWalls that must be copied.
21  : BaseWall(other)
22 {
23  wallObjects_ = other.wallObjects_;
24  for (auto& wall : wallObjects_)
25  {
26  if (getHandler() != nullptr)
27  wall.setHandler(getHandler());
28  }
29  A_ = other.A_;
30  AB_ = other.AB_;
31  C_ = other.C_;
32  logger(DEBUG, "IntersectionOfWalls(IntersectionOfWalls&) constructed.");
33 }
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:113
BaseWall()
Default constructor.
Definition: BaseWall.cc:15
std::vector< Vec3D > AB_
A vector that stores the direction of the intersecting lines between two different InfiniteWall.
Definition: IntersectionOfWalls.h:213
std::vector< InfiniteWall > wallObjects_
The wall "segments"/directions that together make up the finite wall.
Definition: IntersectionOfWalls.h:198
std::vector< Vec3D > A_
A vector that stores a point for each intersecting line between two different InfiniteWall.
Definition: IntersectionOfWalls.h:206
std::vector< Vec3D > C_
A vector that stores the intersection point of three different InfiniteWall.
Definition: IntersectionOfWalls.h:221

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

◆ IntersectionOfWalls() [3/3]

IntersectionOfWalls::IntersectionOfWalls ( const std::vector< normalAndPosition > &  walls,
const ParticleSpecies species 
)

Constructor setting values.

37 {
38  setSpecies(species);
39  for (auto wall : walls)
40  {
41  addObject(wall.normal, wall.position);
42  }
43 }
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:117
void setSpecies(const ParticleSpecies *species)
sets species of subwalls as well
Definition: IntersectionOfWalls.cc:51

References addObject(), and setSpecies().

◆ ~IntersectionOfWalls()

IntersectionOfWalls::~IntersectionOfWalls ( )
override

Destructor.

47 {
48  logger(DEBUG, "~IntersectionOfWalls() has been called.");
49 }

References DEBUG, and logger.

Member Function Documentation

◆ add3PointObject()

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

139 {
140  Vec3D SubtB = PointA - PointB;
141  Vec3D SubtC = PointA - PointC;
142 
143  Vec3D WallNormal = Vec3D::cross(SubtB, SubtC);
144  //Check if walls coordinates inline, if true Do not build wall and give error message.
145  if (WallNormal.getLengthSquared() == 0.0)
146  {
147  logger(ERROR,
148  "Error Building IntersectionOfWalls::add3PointObject out of 3 coordinates. Coordinates are in line, Wall not constructed.");
149  }
150  else
151  {
152  addObject(WallNormal, PointA);
153  }
154 
155 }
@ ERROR
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Kernel/Math/Vector.h:324
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:143

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

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

◆ addObject() [1/3]

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_.

319 {
320  //n is the index of the new wall
321  std::size_t n = wallObjects_.size();
322  InfiniteWall w;
323  if (getSpecies()) w.setSpecies(getSpecies());
324  w.setOrientation(orientation);
325  w.setPosition(position);
326  wallObjects_.push_back(w);
328 }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
Definition: BaseInteractable.h:87
A infinite wall fills the half-space {point: (position_-point)*normal_<=0}.
Definition: InfiniteWall.h:27
void setPointsAndLines(unsigned int n)
Definition: IntersectionOfWalls.cc:330

References BaseInteractable::getSpecies(), n, setPointsAndLines(), w, and wallObjects_.

◆ addObject() [2/3]

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.
433 {
434  //logger(WARN, "This function is deprecated, use IntersectionOfWalls::addObject(Vec3D, Vec3D) instead.");
435  addObject(normal, position * normal);
436 }
void normal(const Vector< double > &x, Vector< double > &normal)
Definition: free_surface_rotation.cc:65

References addObject(), and WallFunction::normal().

◆ addObject() [3/3]

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_.

118 {
119  normal.normalise();
120 
121  //n is the index of the new wall
122  std::size_t n = wallObjects_.size();
123  InfiniteWall w;
124  if (getSpecies()) w.setSpecies(getSpecies());
125  w.set(normal, point);
126  wallObjects_.push_back(w);
128 }

References BaseInteractable::getSpecies(), n, WallFunction::normal(), setPointsAndLines(), w, and wallObjects_.

Referenced by add3PointObject(), ChuteWithHopper::addHopper(), addObject(), VerticalMixerAngledBlades::addPrettyBlades(), NautaMixer::addScrew(), ChuteWithWedge::addWedge(), createOpenPrism(), createPrism(), GranuDrum::GranuDrum(), GranuHeap::GranuHeap(), IntersectionOfWalls(), read(), WallHandler::readAndCreateOldObject(), RotatingDrumBidisperseInitialise::RotatingDrumBidisperseInitialise(), ContractionWithPeriodicInflow::set_symmetric_contraction(), ChuteWithPeriodicInflowAndContraction::set_symmetric_contraction(), ChuteWithContraction::set_symmetric_contraction(), T_protectiveWall::setupInitialConditions(), AxisymmetricHopper::setupInitialConditions(), RotatingDrumWet::setupInitialConditions(), VerticalMixer::setupInitialConditions(), MaserRepeatedOutInMPI2Test::setupInitialConditions(), PeriodicBounaryEnteringMPIDomainTest::setupInitialConditions(), HourGlass::setupInitialConditions(), GetDistanceAndNormalForIntersectionOfWalls::setupInitialConditions(), Drum::setupInitialConditions(), Silo::setupInitialConditions(), UnionOfWalls::setupInitialConditions(), RotatingDrum::setupInitialConditions(), protectiveWall::setupInitialConditions(), Tutorial11::setupInitialConditions(), Tutorial8::setupInitialConditions(), and FullRestartTest::setupInitialConditions().

◆ addPlate()

void IntersectionOfWalls::addPlate ( const Vec3D PointA,
const Vec3D PointB,
const Vec3D PointC,
const Vec3D WallNormal,
const Mdouble Thickness,
int  wallidentifier 
)
278 {
279 
280  //Check if walls coordinates inline, if true Do not build wall and give error message. But keep continuing
281  if (WallNormal.getLengthSquared() == 0.0)
282  {
283  logger(WARN, "Error Building Plate number % out of 3 coordinates. Coordinates are in line, Wall not "
284  "constructed.", wallidentifier);
285  }
286  else
287  {
288  Vec3D PointAT = PointA - WallNormal * Thickness;
289  Vec3D PointBT = PointB - WallNormal * Thickness;
290  Vec3D PointCT = PointC - WallNormal * Thickness;
291 
292  //generate the base wall first through the input coordinates
293  add3PointObject(PointC, PointB, PointA);
294 
295  //add sidewalls
296  add3PointObject(PointA, PointB, PointAT);
297  add3PointObject(PointB, PointC, PointBT);
298  add3PointObject(PointC, PointA, PointCT);
299 
300 
301  //add opposite wall
302  add3PointObject(PointAT, PointBT, PointCT);
303 
304 
305  }
306 
307 
308 }
@ WARN
void add3PointObject(Vec3D PointA, Vec3D PointB, Vec3D PointC)
Definition: IntersectionOfWalls.cc:138

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

◆ addTetra()

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

240 {
241 
242  //generate other coordinate by finding the centre and shift it the distance thickness in the normal direction
243  //calculate normal
244  Vec3D SubtB = PointA - PointB;
245  Vec3D SubtC = PointA - PointC;
246 
247  Vec3D WallNormal = Vec3D::cross(SubtB, SubtC);
248 
249  //Check if walls coordinates inline, if true Do not build wall and give error message.
250  if (WallNormal.getLengthSquared() == 0.0)
251  {
252  logger(ERROR,
253  "Error Building IntersectionOfWalls::addTetra out of 3 coordinates. "
254  "Coordinates are in line, Wall not constructed.");
255  }
256  else
257  {
258  //calculate centroid
259  Vec3D mid = (PointA + PointB + PointC) / 3.0;
260  //shift centroid in normal direction
261  Vec3D midT = mid + WallNormal * Thickness;
262  //generate the base wall first through the input coordinates
263  add3PointObject(PointC, PointB, PointA);
264 
265  //add sidewalls
266  add3PointObject(PointA, midT, PointB);
267  add3PointObject(PointB, midT, PointC);
268  add3PointObject(PointC, midT, PointA);
269  }
270 }

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

◆ addTetraSTL()

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.

172 {
173  //Check if wall coordinates inline, if true Do not build wall and give error message. But keep continuing
174  if (WallNormal.getLengthSquared() == 0.0)
175  {
176  logger(WARN, "Error Building Plate number % out of 3 coordinates. Coordinates are in line, Wall not "
177  "constructed", wallidentifier);
178  }
179  else
180  {
181  //do a check whether the normal follows the RHR (Right Hand Rule) or not
182  //todo: Bert Use this check a lot, possibly make a function of this
183  Vec3D SubtB = PointA - PointB;
184  Vec3D SubtC = PointA - PointC;
185 
186  Vec3D WallNormalRHR = Vec3D::cross(SubtB, SubtC);
187 
188  //normalise for easy check
189  WallNormalRHR.normalise();
190  WallNormal.normalise();
191 
192  //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
193  Mdouble RHRcheck = Vec3D::dot(WallNormalRHR, WallNormal);
194  //todo: Bert Officially need to check for other answers than 1, however, it will either be -1 or 1 in ideal case
195 
196  if (RHRcheck == 1)
197  {
198  //calculate centroid
199  Vec3D mid = (PointA + PointB + PointC) / 3.0;
200  //shift centroid in normal direction
201  //mental note: if Same direction as STL normal it should be subtracted to go IN the wall
202  Vec3D midT = mid - WallNormalRHR * Thickness;
203  //generate the base wall first through the input coordinates
204  add3PointObject(PointA, PointC, PointB);
205 
206  //add sidewalls
207  add3PointObject(PointA, midT, PointC);
208  add3PointObject(PointC, midT, PointB);
209  add3PointObject(PointB, midT, PointA);
210  }
211  else
212  {
213  //calculate centroid
214  Vec3D mid = (PointA + PointB + PointC) / 3.0;
215  //shift centroid in normal direction
216  //mental note: if opposite direction as STL normal it should be added to go IN the wall
217  Vec3D midT = mid + WallNormalRHR * Thickness;
218  //generate the base wall first through the input coordinates
219  add3PointObject(PointA, PointB, PointC);
220 
221  //add sidewalls
222  add3PointObject(PointA, midT, PointB);
223  add3PointObject(PointB, midT, PointC);
224  add3PointObject(PointC, midT, PointA);
225  }
226 
227  }
228 }
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:56
void normalise()
Makes this Vec3D unit length.
Definition: Vector.cc:103

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

◆ clear()

void IntersectionOfWalls::clear ( )

Removes all parts of the walls.

82 {
83  wallObjects_.clear();
84  A_.clear();
85  AB_.clear();
86  C_.clear();
88 }
void removeRenderedWalls()
Definition: BaseWall.cc:541

References A_, AB_, C_, BaseWall::removeRenderedWalls(), and wallObjects_.

Referenced by createOpenPrism().

◆ copy()

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.

77 {
78  return new IntersectionOfWalls(*this);
79 }
IntersectionOfWalls()
Default constructor.
Definition: IntersectionOfWalls.cc:12

References IntersectionOfWalls().

Referenced by operator=().

◆ createOpenPrism() [1/2]

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).

475 {
476  Vec3D prismAxis = Vec3D::cross(
477  Vec3D::getUnitVector(points[1] - points[0]),
478  Vec3D::getUnitVector(points[2] - points[0]));
479  createOpenPrism(points, prismAxis);
480 }
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:446
static Vec3D getUnitVector(const Vec3D &a)
Returns a unit Vec3D based on a.
Definition: Vector.cc:364

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

◆ createOpenPrism() [2/2]

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.

447 {
448  clear();
449  //note: use i+1 < points.size() instead of i < points.size()-1, otherwise it creates havoc if point has zero entries.
450  for (unsigned int i = 0; i + 1 < points.size(); i++)
451  addObject(Vec3D::cross(points[i] - points[i + 1], prismAxis), points[i]);
452 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
void clear()
Removes all parts of the walls.
Definition: IntersectionOfWalls.cc:81

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

Referenced by VerticalMixerStraightBlades::addBlades(), VerticalMixerAngledBlades::addBlades(), createOpenPrism(), createPrism(), HourGlass2D::setupInitialConditions(), HourGlass::setupInitialConditions(), Tutorial11::setupInitialConditions(), and MovingIntersectionOfWallsUnitTest_Basic::setupInitialConditions().

◆ createPrism() [1/2]

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).

490 {
491  Vec3D prismAxis = Vec3D::cross(
492  Vec3D::getUnitVector(points[1] - points[0]),
493  Vec3D::getUnitVector(points[2] - points[0]));
494  createPrism(points, prismAxis);
495 }
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:461

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

◆ createPrism() [2/2]

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.

462 {
463  createOpenPrism(points, prismAxis);
464  addObject(Vec3D::cross(points.back() - points.front(), prismAxis), points.front());
465 }

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

Referenced by VerticalMixerAngledBlades::addPrettyBlades(), createPrism(), and Tutorial12::setupInitialConditions().

◆ getDistanceAndNormal() [1/2]

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.

512 {
513  //transform coordinates into position-orientation frame
514  Vec3D position = p.getPosition() - getPosition();
515  getOrientation().rotateBack(position);
518  if (getDistanceAndNormal(position, p.getRadius() + s->getInteractionDistance(), distance, normal_return))
519  {
520  getOrientation().rotate(normal_return);
521  return true;
522  }
523  else
524  {
525  return false;
526  }
527 }
float * p
Definition: Tutorial_Map_using.cpp:9
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:733
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Definition: BaseInteractable.h:209
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:197
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:29
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1433
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:511
void rotate(Vec3D &position) const
Definition: Quaternion.cc:550
void rotateBack(Vec3D &position) const
Definition: Quaternion.cc:597
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
Definition: SpeciesHandler.h:52
RealScalar s
Definition: level1_cplx_impl.h:130

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

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

◆ getDistanceAndNormal() [2/2]

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.
548 {
549  if (wallObjects_.empty())
550  {
551  logger(DEBUG, "Empty IntersectionOfWalls");
552  return false;
553  }
554 
555  distance = -1e20;
556  Mdouble distance2 = -1e20;
557  Mdouble distance3 = -1e20;
558  Mdouble distanceCurrent;
559  unsigned int id = 0;
560  unsigned int id2 = 0;
561  unsigned int id3 = 0;
562 
563  //For each wall we calculate the distance (distanceCurrent). To compute The walls with the minimal overlap
564  //The object has to touch each wall each wall (distanceCurrent) and keep the minimum distance (distance) and wall index (id
565  for (unsigned int i = 0; i < wallObjects_.size(); i++)
566  {
567  // Calculate distance to each wall (distanceCurrent);
568  distanceCurrent = wallObjects_[i].getDistance(position);
569  // The object has to touch each wall (distanceCurrent >= wallInteractionRadius), otherwise return false (i.e. no contact)
570  // This means that for each InfiniteWall in wallObjects_, the particle is either "inside"
571  // the wall or touching it. If not, there is no interaction.
572  if (distanceCurrent >= wallInteractionRadius)
573  {
574  return false;
575  }
576  // Find out which of the InfiniteWalls is interacting with the particle.
577  // Keep the minimum distance (distance) and wall index (id)
578  // and store up to two walls (id2, id3) and their distances (distance2, distance3),
579  // if the possible contact point is near the intersection between id and id2 (and id3)
580  if (distanceCurrent > distance)
581  {
582  if (distance > -wallInteractionRadius) //if distance was set previously
583  {
584  if (distance2 > -wallInteractionRadius) //if distance2 was set previously
585  {
586  distance3 = distance2;
587  id3 = id2;
588  }
589  distance2 = distance;
590  id2 = id;
591  }
592  distance = distanceCurrent;
593  id = i;
594  }
595  else if (distanceCurrent < -wallInteractionRadius)
596  {
597  continue;
598  }
599  else if (distanceCurrent > distance2)
600  {
601  if (distance2 > -wallInteractionRadius) //if distance2 was set previously
602  {
603  distance3 = distance2;
604  id3 = id2;
605  }
606  distance2 = distanceCurrent;
607  id2 = i;
608  }
609  else if (distanceCurrent > distance3)
610  {
611  distance3 = distanceCurrent;
612  id3 = i;
613  }
614  }
615 
616  //If we are here, the closest wall is id;
617  //if distance2>-P.Radius (and distance3>-P.Radius), the possible contact point
618  // is near the intersection between id and id2 (and id3)
619  if (distance2 > -wallInteractionRadius)
620  {
621  //D is the point on wall id closest to P
622  Vec3D D = position + wallObjects_[id].getNormal() * distance;
623  //If the distance of D to id2 is positive, the contact is with the intersection
624  bool intersection_with_id2 = (wallObjects_[id2].getDistance(D) > 0.0);
625 
626  if (distance3 > -wallInteractionRadius && (wallObjects_[id3].getDistance(D) > 0.0))
627  {
628  //E is the point on wall id2 closest to P
629  Vec3D E = position + wallObjects_[id2].getNormal() * distance2;
630  //If the distance of D to id2 is positive, the contact is with the intersection
631  bool intersection_with_id3 = (wallObjects_[id3].getDistance(E) > 0.0);
632 
633  if (intersection_with_id2)
634  {
635  if (intersection_with_id3)
636  {
637  //possible contact is with intersection of id,id2,id3
638  //we know id2<id3
639  if (id2 > id3)
640  {
641  auto id = id2;
642  id2 = id3;
643  id3 = id;
644  }
645  unsigned int index =
646  (id < id2) ? ((id3 - 2) * (id3 - 1) * id3 / 6 + (id2 - 1) * id2 / 2 + id) :
647  (id < id3) ? ((id3 - 2) * (id3 - 1) * id3 / 6 + (id - 1) * id / 2 + id2) :
648  ((id - 2) * (id - 1) * id / 6 + (id3 - 1) * id3 / 2 + id2);
649  normal_return = position - C_[index];
650  distance = sqrt(normal_return.getLengthSquared());
651  if (distance <= wallInteractionRadius) //note what if nan?
652  {
653  normal_return /= -distance;
654  return true; //contact with id,id2,id3
655  }
656  else
657  {
658  if (distance == distance)
659  return false;
660  }
661  }
662  }
663  else
664  {
665  intersection_with_id2 = true;
666  distance2 = distance3;
667  id2 = id3;
668  }
669  }
670 
671  if (intersection_with_id2)
672  { //possible contact is with intersection of id,id2
673  unsigned int index = (id > id2) ? ((id - 1) * id / 2 + id2) : ((id2 - 1) * id2 / 2 + id);
674  Vec3D AC = position - A_[index];
675  normal_return = AC - AB_[index] * Vec3D::dot(AC, AB_[index]);
676  distance = sqrt(normal_return.getLengthSquared());
677  if (distance <= wallInteractionRadius) //note what if nan?
678  {
679  normal_return /= -distance;
680  return true; //contact with id,id2,id3
681  }
682  else
683  {
684  if (distance == distance)
685  return false;
686  }
687  }
688  }
689  //contact is with id
690  normal_return = wallObjects_[id].getNormal();
691  return true;
692 }
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
dominoes D
Definition: Domino.cpp:55
double E
Elastic modulus.
Definition: TwenteMeshGluing.cpp:68

References A_, AB_, C_, D, DEBUG, Vec3D::dot(), Global_Physical_Variables::E, Vec3D::getLengthSquared(), i, logger, sqrt(), and wallObjects_.

◆ getName()

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.

769 {
770  return "IntersectionOfWalls";
771 }

◆ getNumberOfObjects()

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.

105 {
106  return wallObjects_.size();
107 }

References wallObjects_.

◆ operator=()

IntersectionOfWalls & IntersectionOfWalls::operator= ( const IntersectionOfWalls other)

Copy assignment operator.

Parameters
[in]otherThe IntersectionOfWalls that must be copied.
64 {
65  logger(DEBUG, "IntersectionOfWalls::operator= called.");
66  if (this == &other)
67  {
68  return *this;
69  }
70  return *(other.copy());
71 }
IntersectionOfWalls * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
Definition: IntersectionOfWalls.cc:76

References copy(), DEBUG, and logger.

◆ read()

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.

 \param[in] move A reference to a Vec3D that denotes the direction and length
 it should be moved with.
 \details 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
&zwj;/

void IntersectionOfWalls::move(const Vec3D& move) { BaseInteractable::move(move); for (Vec3D& a : A_) { a += move; } for (Vec3D& c : C_) { c += move; } for (InfiniteWall& o : wallObjects_) { o.move(move); } }

/*!

Parameters
[in]isThe input stream from which the IntersectionOfWalls is read, usually a restart file.

Reimplemented from BaseWall.

Reimplemented in ScrewsymmetricIntersectionOfWalls.

726 {
727  BaseWall::read(is);
728  std::string dummy;
729  int n;
730  is >> dummy >> n;
731 
732  Vec3D normal;
733  Vec3D position;
734  for (int i = 0; i < n; i++)
735  {
736  is >> dummy;
737  if (dummy != "normal")
738  {
739  Quaternion orientation;
740  is >> position >> dummy >> orientation;
741  addObject(orientation, position);
742  }
743  else
744  {
745  is >> normal >> dummy >> position;
746  addObject(normal, position);
747  }
748  }
749 }
void read(std::istream &is) override
Function that reads a BaseWall from an input stream, usually a restart file.
Definition: BaseWall.cc:57
This class contains the 4 components of a quaternion and the standard operators and functions needed ...
Definition: Kernel/Math/Quaternion.h:42
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

References addObject(), i, n, WallFunction::normal(), BaseWall::read(), and oomph::Global_string_for_annotation::string().

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

◆ setHandler()

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.

91 {
92  BaseWall::setHandler(wallHandler);
93  for (InfiniteWall& w : wallObjects_)
94  {
95  w.setHandler(wallHandler);
96  }
97 }
virtual void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
Definition: BaseWall.cc:104

References BaseWall::setHandler(), w, and wallObjects_.

◆ setPointsAndLines()

void IntersectionOfWalls::setPointsAndLines ( unsigned int  n)
331 {
332  // AB[n*(n-1)/2+m] is the direction of the intersecting line between walls m and n, m<n
333  // A[n*(n-1)/2+m] is a point on the intersecting line between walls m and n, m<n
334  // See http://www.netcomuk.co.uk/~jenolive/vect18d.html for finding the line where two planes meet
335  AB_.resize(n * (n + 1) / 2); //0 + 1 + 2 + ... + indexNew, total number of walls you need
336  A_.resize(n * (n + 1) / 2);
337  for (std::size_t m = 0; m < n; m++)
338  {
339  std::size_t id = (n - 1) * n / 2 + m;
340  //first we cross the wall normals and normalise to obtain AB
341  AB_[id] = Vec3D::cross(wallObjects_[m].getNormal(), wallObjects_[n].getNormal());
342  AB_[id] /= sqrt(AB_[id].getLengthSquared());
343  //then we find a point A (using AB*x=0 as a third plane)
344  Mdouble invdet = 1.0 / (+wallObjects_[n].getNormal().X *
345  (wallObjects_[m].getNormal().Y * AB_[id].Z - AB_[id].Y * wallObjects_[m].getNormal().Z)
346  - wallObjects_[n].getNormal().Y * (wallObjects_[m].getNormal().X * AB_[id].Z -
347  wallObjects_[m].getNormal().Z * AB_[id].X)
348  + wallObjects_[n].getNormal().Z * (wallObjects_[m].getNormal().X * AB_[id].Y -
349  wallObjects_[m].getNormal().Y * AB_[id].X));
350 
351  A_[id] = Vec3D(+(wallObjects_[m].getNormal().Y * AB_[id].Z - AB_[id].Y * wallObjects_[m].getNormal().Z) *
353  - (wallObjects_[n].getNormal().Y * AB_[id].Z - wallObjects_[n].getNormal().Z * AB_[id].Y) *
355  + (wallObjects_[n].getNormal().Y * wallObjects_[m].getNormal().Z -
356  wallObjects_[n].getNormal().Z * wallObjects_[m].getNormal().Y) * 0.0,
357  -(wallObjects_[m].getNormal().X * AB_[id].Z - wallObjects_[m].getNormal().Z * AB_[id].X) *
359  + (wallObjects_[n].getNormal().X * AB_[id].Z - wallObjects_[n].getNormal().Z * AB_[id].X) *
361  - (wallObjects_[n].getNormal().X * wallObjects_[m].getNormal().Z -
362  wallObjects_[m].getNormal().X * wallObjects_[n].getNormal().Z) * 0.0,
363  +(wallObjects_[m].getNormal().X * AB_[id].Y - AB_[id].X * wallObjects_[m].getNormal().Y) *
365  - (wallObjects_[n].getNormal().X * AB_[id].Y - AB_[id].X * wallObjects_[n].getNormal().Y) *
367  + (wallObjects_[n].getNormal().X * wallObjects_[m].getNormal().Y -
368  wallObjects_[m].getNormal().X * wallObjects_[n].getNormal().Y) * 0.0) * invdet;
369  }
370 
371  // C[(n-2)*(n-1)*n/6+(m-1)*m/2+l] is a point intersecting walls l, m and n, l<m<n
372  C_.resize((n - 1) * n * (n + 1) / 6);
373  for (std::size_t m = 0; m < n; m++)
374  {
375  for (std::size_t l = 0; l < m; l++)
376  {
377  std::size_t id = (n - 2) * (n - 1) * n / 6 + (m - 1) * m / 2 + l;
378  Mdouble invdet = 1.0 / (+wallObjects_[n].getNormal().X *
379  (wallObjects_[m].getNormal().Y * wallObjects_[l].getNormal().Z -
380  wallObjects_[l].getNormal().Y * wallObjects_[m].getNormal().Z)
381  - wallObjects_[n].getNormal().Y *
382  (wallObjects_[m].getNormal().X * wallObjects_[l].getNormal().Z -
383  wallObjects_[m].getNormal().Z * wallObjects_[l].getNormal().X)
384  + wallObjects_[n].getNormal().Z *
385  (wallObjects_[m].getNormal().X * wallObjects_[l].getNormal().Y -
386  wallObjects_[m].getNormal().Y * wallObjects_[l].getNormal().X));
387  C_[id] = Vec3D(+(wallObjects_[m].getNormal().Y * wallObjects_[l].getNormal().Z -
388  wallObjects_[l].getNormal().Y * wallObjects_[m].getNormal().Z) *
390  - (wallObjects_[n].getNormal().Y * wallObjects_[l].getNormal().Z -
391  wallObjects_[n].getNormal().Z * wallObjects_[l].getNormal().Y) *
393  + (wallObjects_[n].getNormal().Y * wallObjects_[m].getNormal().Z -
394  wallObjects_[n].getNormal().Z * wallObjects_[m].getNormal().Y) *
395  Vec3D::dot(wallObjects_[l].getPosition(), wallObjects_[l].getNormal()),
396  -(wallObjects_[m].getNormal().X * wallObjects_[l].getNormal().Z -
397  wallObjects_[m].getNormal().Z * wallObjects_[l].getNormal().X) *
399  + (wallObjects_[n].getNormal().X * wallObjects_[l].getNormal().Z -
400  wallObjects_[n].getNormal().Z * wallObjects_[l].getNormal().X) *
402  - (wallObjects_[n].getNormal().X * wallObjects_[m].getNormal().Z -
403  wallObjects_[m].getNormal().X * wallObjects_[n].getNormal().Z) *
404  Vec3D::dot(wallObjects_[l].getPosition(), wallObjects_[l].getNormal()),
405  +(wallObjects_[m].getNormal().X * wallObjects_[l].getNormal().Y -
406  wallObjects_[l].getNormal().X * wallObjects_[m].getNormal().Y) *
408  - (wallObjects_[n].getNormal().X * wallObjects_[l].getNormal().Y -
409  wallObjects_[l].getNormal().X * wallObjects_[n].getNormal().Y) *
411  + (wallObjects_[n].getNormal().X * wallObjects_[m].getNormal().Y -
412  wallObjects_[m].getNormal().X * wallObjects_[n].getNormal().Y) *
413  Vec3D::dot(wallObjects_[l].getPosition(), wallObjects_[l].getNormal())) * invdet;
414  }
415  }
416 
417  logger(VERBOSE, "%", *this);
418  for (const InfiniteWall& w : wallObjects_)
419  logger(VERBOSE, "wallObject %, %", w.getNormal(), w.getPosition());
420  for (Vec3D v : A_)
421  logger(VERBOSE, "A %", v);
422  for (Vec3D v : AB_)
423  logger(VERBOSE, "AB %", v);
424  for (Vec3D v : C_)
425  logger(VERBOSE, "C %", v);
426 }
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
@ VERBOSE
#define X
Definition: icosphere.cpp:20
#define Z
Definition: icosphere.cpp:21
int * m
Definition: level2_cplx_impl.h:294
const char Y
Definition: test/EulerAngles.cpp:32

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

Referenced by addObject().

◆ setSpecies()

◆ write()

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.

756 {
757  BaseWall::write(os);
758  os << " numIntersectionOfWalls " << wallObjects_.size();
759  for (const auto& wallObject : wallObjects_)
760  {
761  os << " position " << wallObject.getPosition() << " orientation " << wallObject.getOrientation();
762  }
763 }
void write(std::ostream &os) const override
Function that writes a BaseWall to an output stream, usually a restart file.
Definition: BaseWall.cc:79

References wallObjects_, and BaseWall::write().

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

◆ writeVTK()

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.

774 {
777  for (auto wall = wallObjects_.begin(); wall != wallObjects_.end(); wall++)
778  {
779  std::vector<Vec3D> points;
780  wall->createVTK(points, min, max);
781  for (auto other = wallObjects_.begin(); other != wallObjects_.end(); other++)
782  {
783  if (other != wall)
784  {
785  intersectVTK(points, -other->getNormal(), other->getPosition());
786  }
787  }
788  //rotate into real frame
789  for (auto& p : points)
790  {
792  p += getPosition();
793  }
794  wall->addToVTK(points, vtk);
795  }
796 }
void intersectVTK(std::vector< Vec3D > &points, Vec3D normal, Vec3D position) const
Definition: BaseWall.cc:220
Vec3D getMax() const
Returns the maximum coordinates of the problem domain.
Definition: DPMBase.h:659
Vec3D getMin() const
Returns the minimum coordinates of the problem domain.
Definition: DPMBase.h:653
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23

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

Member Data Documentation

◆ A_

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.

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

◆ AB_

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.

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

◆ C_

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

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

◆ wallObjects_

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_.

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


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