MercuryDPM  0.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FiniteAxisSymmetricWall.h
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 
26 #ifndef FINITEAXISSYMETRICWALL_H
27 #define FINITEAXISSYMETRICWALL_H
28 
29 #include "FiniteWall.h"
30 
33 {
34  public:
36  {
40  #ifdef CONSTUCTOR_OUTPUT
41  std::cout<<"FiniteAxisSymmetricWall() finished"<<std::endl;
42  #endif
43  }
44 
46  {
50  #ifdef CONSTUCTOR_OUTPUT
51  std::cout<<"FiniteAxisSymmetricWall(const FiniteAxisSymmetricWall &p) finished"<<std::endl;
52  #endif
53  }
54 
57  {
58  return new FiniteAxisSymmetricWall(*this);
59  }
60 
61  bool get_distance_and_normal(BaseParticle &P, Mdouble &distance, Vec3D &normal_return)
62  {
64  //transform to axisymmetric coordinates
65  Vec3D PO = P.get_Position() - axisOrigin; //move the coordinate system to the axis origin, so P0=(xhat,yhat,zhat)
66  Vec3D tangential = PO-P.get_Position().Z*axisOrientation; //tangential is the projection into the (xhat,yhat) plane
67  P.set_Position(Vec3D(tangential.GetLength(),0.0,Dot(axisOrientation,PO))); //now P=(r,phi,zhat) is cylindrical
68  tangential /= P.get_Position().X;
69  Vec3D normal_axisymmetric_coordinates;
70  //determine wall distance, normal and contact in axissymmetric coordinates
71  //and transform from axisymmetric coordinates
72  if(!FiniteWall::get_distance_and_normal(P, distance, normal_axisymmetric_coordinates))
73  {
74  //if not in contact
75  P.set_Position(PO + axisOrigin);
76  return false;
77  } else {
78  //if in contact
79  normal_return = normal_axisymmetric_coordinates.Z * axisOrientation + tangential*normal_axisymmetric_coordinates.X;
81  if (!velocity.is_zero()) { //assuming most walls have zero velocity, this if statement saves time
82  Vec3D angular = Cross(axisOrientation,tangential);
84  }
85  P.set_Position(PO + axisOrigin);
86  //std::cout << P.get_Position() << " v " << get_Velocity() << " cv " << velocity << std::endl;
87  return true;
88  }
89  }
90 
92  void setSymmetryAxis(Vec3D new_axisOrigin, Vec3D new_axisOrientation) {
93  axisOrigin = new_axisOrigin;
94  axisOrientation = new_axisOrientation;
96  }
97 
99  void read(std::istream& is)
100  {
101  std::string dummy;
103  FiniteWall::read(is);
104  }
105 
107  void print(std::ostream& os) const
108  {
109  os << "FiniteAxisSymmetricWall axisOrigin "<<axisOrigin<<" axisOrientation "<<axisOrientation<<" ";
110  FiniteWall::print(os);
111  }
112 
116 
118  void moveAxisOrigin(Vec3D velocity_, Mdouble dt) {
119  velocity=velocity_;
120  axisOrigin+=velocity*dt;
121  }
122 
123  Vec3D getAxisOrigin() const {return axisOrigin;}
124 
125  private:
129 };
130 
131 #endif
bool get_distance_and_normal(BaseParticle &P, Mdouble &distance, Vec3D &normal_return)
Mdouble X
Definition: Vector.h:44
void read(std::istream &is)
reads wall
Definition: FiniteWall.h:233
void print(std::ostream &os) const
outputs wall
bool is_zero()
Definition: Vector.h:60
void normalize()
Definition: Vector.h:152
Vec3D velocity
velocity of the wall (used to calculate the relative velocity in the force calculation) ...
Definition: BaseWall.h:114
Matrix3D Cross(const Vec3D &A, const Matrix3D &B)
Definition: Matrix.h:198
bool get_distance_and_normal(BaseParticle &P, Mdouble &distance, Vec3D &normal_return)
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: FiniteWall.h:150
void moveAxisOrigin(Vec3D velocity_, Mdouble dt)
Allows the wall to be moved to a new position, and sets the velocity.
double Mdouble
Definition: ExtendedMath.h:33
FiniteAxisSymmetricWall(const FiniteAxisSymmetricWall &p)
FiniteAxisSymmetricWall * copy() const
Wall copy method. It calls the copy contrustor of this Wall, usefull for polymorfism.
const Vec3D & get_Position() const
Mdouble Y
Definition: Vector.h:44
void set_zero()
Definition: Vector.h:55
void setSymmetryAxis(Vec3D new_axisOrigin, Vec3D new_axisOrientation)
Defines an axisymmetric wall.
Mdouble GetLength() const
Definition: Vector.h:248
void read(std::istream &is)
reads wall
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:40
void print(std::ostream &os) const
outputs wall
Definition: FiniteWall.h:250
void set_Position(const Vec3D &_new)
Mdouble Z
Definition: Vector.h:44