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

#include <VChute.h>

+ Inheritance diagram for VChute:

Public Member Functions

 VChute ()
 
 VChute (const VChute &other)
 
 VChute (Mdouble length, Mdouble width, Mdouble alpha)
 
 ~VChute () override
 
void set (Mdouble length, Mdouble width, Mdouble alpha)
 
VChutecopy () const override
 Pure virtual function that can be overwritten in inherited classes in order to copy a BaseWall. More...
 
bool getDistanceAndNormal (const BaseParticle &p, Mdouble &distance, Vec3D &normal_return) const override
 Pure virtual function that computes the distance of a BaseParticle to this wall and returns the normal of this wall if there is a collision. More...
 
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...
 
void read (std::istream &is) override
 
void write (std::ostream &os) const override
 
std::string getName () 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
 
virtual void setHandler (WallHandler *handler)
 A function which sets the WallHandler for this BaseWall. More...
 
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)
 
virtual void writeVTK (VTKContainer &vtk) const
 
void getVTK (std::vector< Vec3D > &points, std::vector< std::vector< double >> &triangleStrips)
 
const Vec3D getAxis () const
 
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
 
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
 

Private Attributes

Mdouble l_
 
Mdouble w_
 
Mdouble alpha_
 

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

Definition at line 34 of file VChute.h.

Constructor & Destructor Documentation

VChute::VChute ( )

Definition at line 33 of file VChute.cc.

References alpha_, l_, constants::pi, and w_.

Referenced by copy().

34 {
35  l_ = 1.0;
36  w_ = 1.0;
37  alpha_ = 20.0 / 180.0 * constants::pi;
38 }
Mdouble l_
Definition: VChute.h:62
const Mdouble pi
Definition: ExtendedMath.h:45
Mdouble alpha_
Definition: VChute.h:64
Mdouble w_
Definition: VChute.h:63
VChute::VChute ( const VChute other)

Definition at line 40 of file VChute.cc.

References alpha_, l_, and w_.

40  : BaseWall(other)
41 {
42  l_ = other.l_;
43  w_ = other.w_;
44  alpha_ = other.alpha_;
45 }
Mdouble l_
Definition: VChute.h:62
Mdouble alpha_
Definition: VChute.h:64
BaseWall()
Default constructor.
Definition: BaseWall.cc:36
Mdouble w_
Definition: VChute.h:63
VChute::VChute ( Mdouble  length,
Mdouble  width,
Mdouble  alpha 
)

Definition at line 47 of file VChute.cc.

References alpha_, l_, and w_.

48 {
49  l_ = length;
50  w_ = width;
51  alpha_ = alpha;
52 }
Mdouble l_
Definition: VChute.h:62
Mdouble alpha_
Definition: VChute.h:64
Mdouble w_
Definition: VChute.h:63
VChute::~VChute ( )
overridedefault

Member Function Documentation

VChute * VChute::copy ( ) const
overridevirtual

Pure virtual function that can be overwritten in inherited classes in order to copy a BaseWall.

Returns
A pointer to the new BaseWall.

Implements BaseWall.

Definition at line 63 of file VChute.cc.

References VChute().

64 {
65  return new VChute(*this);
66 }
VChute()
Definition: VChute.cc:33
bool VChute::getDistanceAndNormal ( const BaseParticle P,
Mdouble distance,
Vec3D normal_return 
) const
overridevirtual

Pure virtual function that computes the distance of a BaseParticle to this wall and returns the normal of this wall if there is a collision.

Beware, the distance and normal are output parameters, not return values!

Parameters
[in]PReference to the BaseParticle we want to compute the distance to the BaseWall of.
[out]distanceDistance of the BaseParticle to the BaseWall.
[out]normal_returnThe normal of the wall. Is only given if there is a collision.
Returns
A boolean which indicates if there is a collision between the BaseParticle and the wall.

Implements BaseWall.

Definition at line 68 of file VChute.cc.

References alpha_, mathsFunc::cos(), Vec3D::getLength(), BaseInteractable::getPosition(), BaseParticle::getWallInteractionRadius(), l_, logger, mathsFunc::sin(), mathsFunc::tan(), WARN, Vec3D::X, Vec3D::Y, and Vec3D::Z.

Referenced by getInteractionWith().

69 {
70  /* define shortcuts */
71  const Mdouble x0 = p.getPosition().X;
72  const Mdouble y0 = p.getPosition().Y;
73  const Mdouble z0 = p.getPosition().Z;
74  const Mdouble ra = p.getWallInteractionRadius(this); // note, not getRadius()
75 
76  /* Has the particle flown off the ends of the chute? */
77  if (x0 < -ra || x0 > l_ + ra)
78  return false;
79 
80  /* Don't bother bounding in the y, z directions. The wall is linear, so
81  * calculating collisions isn't that expensive anyway. */
82  /*
83  if (fabs(y0) > w_ + ra
84  || z0 < -ra || z0 > tan(alpha_)*(w_ + ra) + ra ) {
85  return false;
86  }
87  */
88 
89  /* Get the distance and normal. */
90  // Newton is unnecessary, because linear problem.
91  // The special case y0==0 is problematic because it means double-contact, but
92  // let's just hope it doesn't come up. (TODO)
93  Mdouble q;
94  Mdouble distanceSquared;
95  if (y0 > 0)
96  {
97  q = y0 * pow(cos(alpha_), 2) + z0 * tan(alpha_);
98  distanceSquared = pow(
99  y0 * (pow(cos(alpha_), 2) - 1) + z0 * sin(alpha_) * cos(alpha_), 2)
100  + pow(
101  y0 * sin(alpha_) * cos(alpha_) + z0 * (pow(sin(alpha_), 2) - 1), 2);
102  }
103  else if (y0 < 0)
104  {
105  q = y0 * pow(cos(alpha_), 2) - z0 * tan(alpha_);
106  distanceSquared = pow(
107  y0 * (pow(cos(alpha_), 2) - 1) - z0 * sin(alpha_) * cos(alpha_), 2)
108  + pow(
109  -y0 * sin(alpha_) * cos(alpha_) + z0 * (pow(sin(alpha_), 2) - 1), 2);
110  }
111  else
112  {
113  /* The case y=0 requires special handling... */
114 
115  /* In the past, this case simply triggered an error and died. */
116  // return false;
117 
118  /* If the particle has y=0 then it is in contact with both sides of the
119  * V-chute; both sides will exert a force on the particle
120  * simultaneously. This is difficult to handle. I shall assume that the
121  * resultant force is exactly upwards, as though the particle was in
122  * contact with a flat plane (z=0).
123  * TODO try to make this more realistic
124  */
125  logger(WARN, "y0 == 0, dangerous");
126  q = 0;
127  distanceSquared = pow(z0, 2);
128  }
129 
130  //If distance is too large there is no contact
131  if (distanceSquared >= pow(p.getWallInteractionRadius(this), 2))
132  {
133  return false;
134  }
135 
136  Vec3D ContactPoint;
137  distance = sqrt(distanceSquared);
138  ContactPoint.X = x0;
139  ContactPoint.Y = q;
140  ContactPoint.Z = fabs(q) * tan(alpha_);
141  normal_return = ContactPoint - p.getPosition();
142  normal_return /= normal_return.getLength();
143  return true;
144 
145 }
Mdouble X
the vector components
Definition: Vector.h:65
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
double Mdouble
Definition: GeneralDefine.h:34
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Definition: Vector.cc:331
Mdouble l_
Definition: VChute.h:62
Mdouble cos(Mdouble x)
Definition: ExtendedMath.cc:64
Mdouble sin(Mdouble x)
Definition: ExtendedMath.cc:44
T tan(T x)
Definition: ExtendedMath.h:178
Mdouble alpha_
Definition: VChute.h:64
Mdouble Y
Definition: Vector.h:65
Definition: Vector.h:49
Mdouble Z
Definition: Vector.h:65
BaseInteraction * VChute::getInteractionWith ( BaseParticle p,
unsigned  timeStamp,
InteractionHandler interactionHandler 
)
overridevirtual

Returns the interaction between this wall and a given particle, nullptr if there is no interaction.

Parameters
[in]pPointer to the BaseParticle which we want to check the interaction for.
[in]timeStampThe time at which we want to look at the interaction.
[in]interactionHandlerA pointer to the InteractionHandler in which the interaction can be found.
Returns
A pointer to the BaseInteraction that happened between this BaseWall and the BaseParticle at the timeStamp.
Todo:
Hacked please fix
Todo:
{DK: What is the contact point for interactions with walls}

Reimplemented from BaseWall.

Definition at line 148 of file VChute.cc.

References getDistanceAndNormal(), InteractionHandler::getInteraction(), BaseInteraction::getNormal(), BaseInteraction::getOverlap(), BaseInteractable::getPosition(), BaseParticle::getRadius(), BaseInteraction::setContactPoint(), BaseInteraction::setDistance(), BaseInteraction::setNormal(), and BaseInteraction::setOverlap().

149 {
150  Mdouble distance;
151  Vec3D normal;
152  if (getDistanceAndNormal(*p, distance, normal))
153  {
154  BaseInteraction* c = interactionHandler->getInteraction(p, this, timeStamp);
155  c->setNormal(-normal);
156  c->setDistance(distance);
157  c->setOverlap(p->getRadius() - distance);
158  c->setContactPoint(p->getPosition() - (p->getRadius() - 0.5 * c->getOverlap()) * c->getNormal());
160  return c;
161  }
162  else
163  return nullptr;
164 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
void setNormal(Vec3D normal)
Sets the normal vector between the two interacting objects.
void setOverlap(Mdouble overlap)
Set the overlap between the two interacting object.
double Mdouble
Definition: GeneralDefine.h:34
void setContactPoint(Vec3D contactPoint)
Set the location of the contact point between the two interacting objects.
void setDistance(Mdouble distance)
Sets the interaction distance between the two interacting objects.
Stores information about interactions between two interactable objects; often particles but could be ...
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
BaseInteraction * getInteraction(BaseInteractable *P, BaseInteractable *I, unsigned timeStamp)
Returns the Interaction between the BaseInteractable's P and I.
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:348
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
bool getDistanceAndNormal(const BaseParticle &p, Mdouble &distance, Vec3D &normal_return) const override
Pure virtual function that computes the distance of a BaseParticle to this wall and returns the norma...
Definition: VChute.cc:68
Definition: Vector.h:49
std::string VChute::getName ( ) const
overridevirtual
Returns
The string "VChute".

Implements BaseObject.

Definition at line 192 of file VChute.cc.

193 {
194  return "VChute";
195 }
void VChute::read ( std::istream &  is)
overridevirtual
Parameters
[in,out]isThe input stream from which the Coil is read.

Reimplemented from BaseWall.

Definition at line 169 of file VChute.cc.

References alpha_, l_, BaseWall::read(), and w_.

170 {
171  BaseWall::read(is);
172  std::string dummy;
173  is >> dummy >> l_
174  >> dummy >> w_
175  >> dummy >> alpha_;
176 }
Mdouble l_
Definition: VChute.h:62
Mdouble alpha_
Definition: VChute.h:64
void read(std::istream &is) override
Function that reads a BaseWall from an input stream, usually a restart file.
Definition: BaseWall.cc:80
Mdouble w_
Definition: VChute.h:63
void VChute::set ( Mdouble  length,
Mdouble  width,
Mdouble  alpha 
)

Definition at line 56 of file VChute.cc.

References alpha_, l_, and w_.

57 {
58  l_ = length;
59  w_ = width;
60  alpha_ = alpha;
61 }
Mdouble l_
Definition: VChute.h:62
Mdouble alpha_
Definition: VChute.h:64
Mdouble w_
Definition: VChute.h:63
void VChute::write ( std::ostream &  os) const
overridevirtual
Parameters
[in,out]osThe outpus stream to which the Coil is written.

Reimplemented from BaseWall.

Definition at line 181 of file VChute.cc.

References alpha_, l_, w_, and BaseWall::write().

182 {
183  BaseWall::write(os);
184  os << " Length " << l_
185  << " Width " << w_
186  << " alpha " << alpha_;
187 }
void write(std::ostream &os) const override
Function that writes a BaseWall to an output stream, usually a restart file.
Definition: BaseWall.cc:102
Mdouble l_
Definition: VChute.h:62
Mdouble alpha_
Definition: VChute.h:64
Mdouble w_
Definition: VChute.h:63

Member Data Documentation

Mdouble VChute::alpha_
private

Definition at line 64 of file VChute.h.

Referenced by getDistanceAndNormal(), read(), set(), VChute(), and write().

Mdouble VChute::l_
private

Definition at line 62 of file VChute.h.

Referenced by getDistanceAndNormal(), read(), set(), VChute(), and write().

Mdouble VChute::w_
private

Definition at line 63 of file VChute.h.

Referenced by read(), set(), VChute(), and write().


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