MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AxisymmetricIntersectionOfWalls.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
27 #include "Particles/BaseParticle.h"
28 
30 {
31  logger(DEBUG, "AxisymmetricIntersectionOfWalls() finished");
32 }
33 
38  : IntersectionOfWalls(other)
39 {
40  logger(DEBUG, "AxisymmetricIntersectionOfWalls(const AxisymmetricIntersectionOfWalls &p) finished");
41 }
42 
44 {
45  logger(DEBUG, "~AxisymmetricIntersectionOfWalls() finished.");
46 }
47 
52 {
53  if (this == &other)
54  {
55  return *this;
56  }
57  else
58  {
59  return *(other.copy());
60  }
61 }
62 
67 {
68  return new AxisymmetricIntersectionOfWalls(*this);
69 }
70 
82 {
83  //transform to axisymmetric coordinates
84  //move the coordinate system to the axis origin, so pOrigin=(xhat,yhat,zhat)
85  Vec3D pOrigin = p.getPosition() -getPosition();
86  Mdouble normal = Vec3D::dot(pOrigin, getOrientation());
87  //tangential is the projection into the (xhat,yhat) plane
88  Vec3D tangentialUnitVector = pOrigin - normal * getOrientation();
89  Mdouble tangential = tangentialUnitVector.getLength();
90  if (tangential!=0.0)
91  tangentialUnitVector /= tangential;
92  else //in this case the tangential vector is irrelevant
93  logger(WARN, "Warning: Particle % is exactly on the symmetry axis of wall %", p.getIndex(), getIndex());
94  Vec3D transformedPosition = Vec3D(tangential, 0.0, normal); //now P=(r,phi,zhat) is cylindrical
95  Vec3D transformedNormal;
96  //determine wall distance, normal and contact in axissymmetric coordinates
97  //and transform from axisymmetric coordinates
98  if (!IntersectionOfWalls::getDistanceAndNormal(transformedPosition, p.getWallInteractionRadius(), distance, transformedNormal))
99  {
100  //if not in contact
101  return false;
102  }
103  else
104  {
105  //if in contact
106  normalReturn = transformedNormal.Z * getOrientation() + transformedNormal.X * tangentialUnitVector;
107  return true;
108  }
109 }
110 
116 {
118 }
119 
124 void AxisymmetricIntersectionOfWalls::write(std::ostream& os) const
125 {
127 }
128 
133 {
134  return "AxisymmetricIntersectionOfWalls";
135 }
136 
137 
147 {
148  Mdouble distance;
149  Vec3D normal;
150 
151  if (getDistanceAndNormal(*p,distance,normal))
152  {
153  BaseInteraction* c = interactionHandler->getInteraction(p, this, timeStamp);
154  c->setNormal(-normal);
155  c->setDistance(distance);
156  c->setOverlap(p->getRadius() - distance);
158  c->setContactPoint(p->getPosition()-(p->getRadius()- 0.5 * c->getOverlap())*c->getNormal());
159  return c;
160  }
161  else
162  {
163  return 0;
164  }
165 }
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.cc:106
void setNormal(Vec3D normal)
Sets the normal vector between the two interacting objects.
Mdouble X
the vector components
Definition: Vector.h:52
A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void setOverlap(Mdouble overlap)
Set the overlap between the two interacting object.
BaseInteraction * getInteraction(BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp)
Returns the Interaction between the BaseInteractable's P and I.
void write(std::ostream &os) const final
outputs wall
double Mdouble
bool getDistanceAndNormal(const BaseParticle &P, Mdouble &distance, Vec3D &normal_return) const final
Computes the distance from the wall for a given BaseParticle and returns true if there is a collision...
BaseInteraction * getInteractionWith(BaseParticle *P, Mdouble timeStamp, InteractionHandler *interactionHandler) final
Get the interaction between this AxisymmetricIntersectionOfWalls and a given BaseParticle at a given ...
void setContactPoint(Vec3D contactPoint)
Set the location of the contact point between the two interacting objects.
std::string getName() const final
Returns the name of the object.
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...
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:187
void setDistance(Mdouble distance)
Sets the interaction distance between the two interacting objects.
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
const Vec3D & getOrientation() const
Returns the orientation of this BaseInteractable.
Stores information about interactions between two interactable objects; often particles but could be ...
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Definition: Vector.cc:427
Mdouble getWallInteractionRadius() const
Returns the interaction radius for interaction with walls. See also BaseParticle::getInteractionRadiu...
void read(std::istream &is)
Reads an IntersectionOfWalls from an input stream, for example a restart file.
AxisymmetricIntersectionOfWalls * copy() const final
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
Container to store Interaction objects.
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
Mdouble getRadius() const
Returns the particle's radius_.
AxisymmetricIntersectionOfWalls & operator=(const AxisymmetricIntersectionOfWalls &other)
Copy assignment operator.
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
void read(std::istream &is) final
reads wall
A AxisymmetricIntersectionOfWalls is a axisymmetric wall, defined by rotating a twodimensional Inters...
void write(std::ostream &os) const
Writes an IntersectionOfWalls to an output stream, for example a restart file.
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble Z
Definition: Vector.h:52