MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CylindricalWall.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 
26 #include <limits>
27 
28 #include "CylindricalWall.h"
29 #include "InteractionHandler.h"
30 #include "Particles/BaseParticle.h"
31 
33  : BaseWall()
34 {
35  radius_ = std::numeric_limits<double>::quiet_NaN();
36 #ifdef DEBUG_CONSTRUCTOR
37  std::cout<<"CylindricalWall () finished"<<std::endl;
38 #endif
39 }
40 
42  : BaseWall(p)
43 {
44  radius_ = p.radius_;
45 #ifdef DEBUG_CONSTRUCTOR
46  std::cout<<"CylindricalWall (const CylindricalWall &p) finished"<<std::endl;
47 #endif
48 }
49 
51  : BaseWall()
52 {
53  this->radius_ = radius;
54 #ifdef DEBUG_CONSTRUCTOR
55  std::cout<<"CylindricalWall (double radius) finished"<<std::endl;
56 #endif
57 }
58 
61 {
62  return new CylindricalWall(*this);
63 }
64 
67 {
68  this->radius_ = radius;
69 }
70 
72 bool CylindricalWall::getDistanceAndNormal(const BaseParticle& P, Mdouble& distance, Vec3D& normal_return) const
73 {
74  double R = sqrt(pow(P.getPosition().X, 2) + pow(P.getPosition().Y, 2));
75  distance = radius_ - R;
76  if (distance >= P.getRadius())
77  return false;
78 
79  normal_return.X = P.getPosition().X;
80  normal_return.Y = P.getPosition().Y;
81  normal_return.Z = 0.0;
82  normal_return /= normal_return.getLength();
83 
84  return true;
85 }
86 
88 void CylindricalWall::read(std::istream& is)
89 {
90  BaseWall::read(is);
91  std::string dummy;
92  is >> dummy >> radius_;
93 }
94 
95 void CylindricalWall::oldRead(std::istream& is)
96 {
97  std::string dummy;
98  is >> dummy >> radius_;
99 }
100 
102 void CylindricalWall::write(std::ostream& os) const
103 {
104  BaseWall::write(os);
105  os << " radius " << radius_;
106 }
107 
108 std::string CylindricalWall::getName() const
109 {
110  return "CylindricalWall";
111 }
112 
115 {
116  return radius_;
117 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Mdouble X
the vector components
Definition: Vector.h:65
double Mdouble
Definition: GeneralDefine.h:34
void write(std::ostream &os) const override
Function that writes a BaseWall to an output stream, usually a restart file.
Definition: BaseWall.cc:102
std::string getName() const override
Returns the name of the object.
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Definition: Vector.cc:331
void oldRead(std::istream &is)
CylindricalWall * copy() const override
Wall copy method. It calls the copy contrustor of this Wall, usefull for polymorfism.
void write(std::ostream &os) const override
outputs wall
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:345
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
bool getDistanceAndNormal(const BaseParticle &P, Mdouble &distance, Vec3D &normal_return) const override
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.
Definition: Vector.h:49
void set(Mdouble radius)
Defines a standard wall, given an outward normal vector s. t. normal*x=position.
double getRadius() const
access function for radius
void read(std::istream &is) override
reads wall
Mdouble Z
Definition: Vector.h:65