MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SimpleDrumSuperquadrics.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
27 #include "Particles/BaseParticle.h"
28 #include "WallHandler.h"
29 #include "DPMBase.h"
30 
32 {
33  logger(DEBUG, "SimpleDrumSuperquadrics() finished");
34  radius_ = 1;
35  wall.set({1,0,0}, {1,0,0});
36 }
37 
42  : BaseWall(other)
43 {
44  wall = other.wall;
45  radius_ = other.radius_;
46  logger(DEBUG, "AxisymmetricIntersectionOfWalls(const AxisymmetricIntersectionOfWalls &p) finished");
47 }
48 
50 {
51  logger(DEBUG, "SimpleDrumSuperquadricsuadrics() finished.");
52 }
53 
59 {
60  if (this == &other)
61  {
62  return *this;
63  }
64  else
65  {
66  return *(other.copy());
67  }
68 }
69 
74 {
75  return new SimpleDrumSuperquadrics(*this);
76 }
77 
89  Vec3D& normalReturn) const
90 {
91  Vec3D normalDirection = p.getPosition();
92  normalDirection.Y = 0;
93  normalDirection.normalise();
94  wall.set(normalDirection, normalDirection * radius_);
95  logger(DEBUG, "setting wall to %, %", normalDirection, normalDirection * radius_);
96  logger(DEBUG, "angular velocity of wall: %", getAngularVelocity());
97  //determine wall distance, normal and contact in axissymmetric coordinates
98  //and transform from axisymmetric coordinates
99  return (wall.getDistanceAndNormal(p, distance, normalReturn));
100 }
101 
103  Mdouble& overlap) const
104 {
105  Vec3D normalDirection = p.getPosition();
106  normalDirection.Y = 0;
107  if (normalDirection.getLengthSquared() < 1e-2)
108  return false;
109  normalDirection.normalise();
110  wall.set(normalDirection, normalDirection * radius_);
111  logger(DEBUG, "setting wall to [%], [%]", normalDirection, normalDirection * radius_);
112  return wall.getDistanceNormalOverlapSuperquadric(p, distance, normal_return, overlap);
113 }
114 
119 void SimpleDrumSuperquadrics::read(std::istream& is)
120 {
121  BaseWall::read(is);
122  wall.read(is);
123  is >> radius_;
124 }
125 
130 void SimpleDrumSuperquadrics::write(std::ostream& os) const
131 {
132  BaseWall::write(os);
133  wall.write(os);
134  os << radius_;
135 }
136 
141 {
142  return "SimpleDrumSuperquadrics";
143 }
144 
146 {
148 }
void write(std::ostream &os) const final
outputs wall
~SimpleDrumSuperquadrics() override
Destructor.
const Vec3D & getPosition() const
Returns the position 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...
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
void normalise()
Makes this Vec3D unit length.
Definition: Vector.cc:123
SimpleDrumSuperquadrics & operator=(const SimpleDrumSuperquadrics &other)
Copy assignment operator.
void write(std::ostream &os) const override
Function that writes a BaseWall to an output stream, usually a restart file.
Definition: BaseWall.cc:102
virtual const Vec3D & getAngularVelocity() const
Returns the angular velocity of this interactable.
bool getDistanceNormalOverlapSuperquadric(const SuperQuadricParticle &p, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const override
Compute the distance from the wall for a given BaseParticle and return if there is a collision...
bool getDistanceNormalOverlapSuperquadric(const SuperQuadricParticle &p, Mdouble &distance, Vec3D &normal_return, Mdouble &overlap) const override
std::string getName() const final
Returns the name of the object.
A drum in xz-direction with centre at the origin with a certain radius. Usable with superquadric part...
void read(std::istream &is) final
reads wall
SimpleDrumSuperquadrics()
Default constructor.
Basic class for walls.
Definition: BaseWall.h:47
void read(std::istream &is) override
Function that reads a BaseWall from an input stream, usually a restart file.
Definition: BaseWall.cc:80
Mdouble Y
Definition: Vector.h:65
void read(std::istream &is) override
Reads InfiniteWall from a restart file.
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...
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.h:316
void setOrientationViaNormal(Vec3D normal)
Sets the orientation of this BaseInteractable by defining the vector that results from the rotation o...
Definition: Vector.h:49
bool getDistanceAndNormal(const BaseParticle &P, Mdouble &distance, Vec3D &normal_return) const override
Computes the distance from the wall for a given BaseParticle and returns true if there is a collision...
SimpleDrumSuperquadrics * copy() const final
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.