MercuryDPM  0.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InfiniteWallWithHole Class Reference

This is a class defining walls. More...

#include <InfiniteWallWithHole.h>

+ Inheritance diagram for InfiniteWallWithHole:

Public Member Functions

 InfiniteWallWithHole ()
 
 InfiniteWallWithHole (Vec3D normal, Mdouble position, Mdouble holeRadius)
 
 InfiniteWallWithHole (const InfiniteWallWithHole &p)
 
InfiniteWallWithHolecopy () const
 Wall copy method. It calls the copy contrustor of this Wall, usefull for polymorfism. More...
 
void clear ()
 
void set (Vec3D normal_, Mdouble position_, Mdouble holeRadius_)
 Defines a standard wall, given an outward normal vector s. t. normal*x=position. More...
 
void move (Mdouble position_)
 Allows the wall to be moved to a new position. More...
 
void move (Vec3D velocity_, Mdouble dt)
 Allows the wall to be moved to a new position (also orthogonal to the normal), and setting the velocity. More...
 
void move_time (Mdouble dt)
 Allows the wall to be moved with time. More...
 
Mdouble get_wallDistance (const Vec3D &Position)
 Returns the distance of the wall to the particle. More...
 
Mdouble get_holeDistance (const Vec3D &Position)
 
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. More...
 
void read (std::istream &is)
 reads wall More...
 
void print (std::ostream &os) const
 outputs wall More...
 
Vec3D get_Normal ()
 access function for normal More...
 
Mdouble get_Position ()
 access function for position More...
 
Vec3D get_Velocity () const
 access function for velocity More...
 
void set_Velocity (Vec3D new_)
 access function for velocity More...
 
- Public Member Functions inherited from BaseWall
 BaseWall ()
 
 BaseWall (const BaseWall &p)
 
virtual ~BaseWall ()
 
virtual bool get_distance_and_normal (BaseParticle &P UNUSED, Mdouble &distance UNUSED, Vec3D &normal_return UNUSED)=0
 
void set_Velocity (Vec3D new_)
 access function for velocity More...
 
virtual void read (std::istream &is UNUSED)=0
 
virtual void print (std::ostream &os UNUSED) const =0
 
virtual void moveInHandler (int newPos)
 
int getIndSpecies () const
 
void setIndSpecies (const int _new)
 
const Vec3Dget_Force () const
 
const Vec3Dget_Torque () const
 
void set_Force (Vec3D _new)
 
void set_Torque (Vec3D _new)
 
void set_Index (int index)
 
void set_Id (int id)
 
void add_Force (Vec3D _new)
 
void add_Torque (Vec3D _new)
 

Private Attributes

Vec3D normal
 
Mdouble position
 
Mdouble factor
 
Vec3D velocity
 velocity of the wall (used to calculate the relative velocity in the force calculation) More...
 
Mdouble holeRadius
 

Additional Inherited Members

- Public Attributes inherited from BaseWall
int indSpecies
 
- Protected Attributes inherited from BaseWall
Vec3D velocity
 velocity of the wall (used to calculate the relative velocity in the force calculation) More...
 

Detailed Description

This is a class defining walls.

It defines the interaction of regular walls and periodic walls with particles as defined in Particle Modifications: Definition of a wall (planar or finite). A standard wall is a plane defined as {x: normal*x=position}, with normal being the outward unit normal vector of the wall. A particle touches a standard wall if position-normal*x<=radius. A finite wall is convex polygon defined by a set of normals normal_i and positions position_i. A particle touches a finite wall if position_i-normal_i*x<=radius for all i.

Todo:
remove access to set Nwalls and wall set etc.. and add function add_wall. This would have stoped a lot of bugs in my own (Anthony's) driver codes.

Definition at line 42 of file InfiniteWallWithHole.h.

Constructor & Destructor Documentation

InfiniteWallWithHole::InfiniteWallWithHole ( )
inline

Definition at line 45 of file InfiniteWallWithHole.h.

References Vec3D::set_zero(), and velocity.

Referenced by copy().

45  : BaseWall()
46  {
48  #ifdef CONSTUCTOR_OUTPUT
49  std::cout<<"InfiniteWall () finished"<<std::endl;
50  #endif
51  }
BaseWall()
Definition: BaseWall.h:38
void set_zero()
Definition: Vector.h:55
Vec3D velocity
velocity of the wall (used to calculate the relative velocity in the force calculation) ...
InfiniteWallWithHole::InfiniteWallWithHole ( Vec3D  normal,
Mdouble  position,
Mdouble  holeRadius 
)
inline

Definition at line 53 of file InfiniteWallWithHole.h.

References holeRadius, normal, position, Vec3D::set_zero(), and velocity.

53  : BaseWall()
54  {
55  this->normal=normal;
56  this->position=position;
57  this->holeRadius=holeRadius;
59  #ifdef CONSTUCTOR_OUTPUT
60  std::cout<<"InfiniteWallWithHole(Vec3D normal, Mdouble position, Mdouble holeRadius) finished"<<std::endl;
61  #endif
62  }
BaseWall()
Definition: BaseWall.h:38
void set_zero()
Definition: Vector.h:55
Vec3D velocity
velocity of the wall (used to calculate the relative velocity in the force calculation) ...
InfiniteWallWithHole::InfiniteWallWithHole ( const InfiniteWallWithHole p)
inline

Definition at line 64 of file InfiniteWallWithHole.h.

References factor, holeRadius, normal, position, and velocity.

64  : BaseWall(p)
65  {
66  normal=p.normal;
68  factor=p.factor;
71  #ifdef CONSTUCTOR_OUTPUT
72  std::cout<<"InfiniteWall (const InfiniteWall &p) finished"<<std::endl;
73  #endif
74  }
BaseWall()
Definition: BaseWall.h:38
Vec3D velocity
velocity of the wall (used to calculate the relative velocity in the force calculation) ...

Member Function Documentation

void InfiniteWallWithHole::clear ( )
inlinevirtual

Reimplemented from BaseWall.

Definition at line 82 of file InfiniteWallWithHole.h.

References BaseWall::indSpecies, Vec3D::set_zero(), and velocity.

83  {
84  indSpecies = 0;
86  }
void set_zero()
Definition: Vector.h:55
Vec3D velocity
velocity of the wall (used to calculate the relative velocity in the force calculation) ...
int indSpecies
Definition: BaseWall.h:36
InfiniteWallWithHole* InfiniteWallWithHole::copy ( ) const
inlinevirtual

Wall copy method. It calls the copy contrustor of this Wall, usefull for polymorfism.

Implements BaseWall.

Definition at line 77 of file InfiniteWallWithHole.h.

References InfiniteWallWithHole().

78  {
79  return new InfiniteWallWithHole(*this);
80  }
bool InfiniteWallWithHole::get_distance_and_normal ( BaseParticle P,
Mdouble distance,
Vec3D normal_return 
)
inline

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 at line 120 of file InfiniteWallWithHole.h.

References get_holeDistance(), BaseParticle::get_Position(), BaseParticle::get_Radius(), get_wallDistance(), Vec3D::GetLength(), holeRadius, normal, position, Vec3D::X, Vec3D::Y, and Vec3D::Z.

121  {
122  double wallDistance = get_wallDistance(P.get_Position());
123  if (wallDistance>=P.get_Radius())
124  return false;
125 
126  double holeDistance=get_holeDistance(P.get_Position());
127  if (holeDistance>=P.get_Radius())
128  return false;
129 
130 
131  if(wallDistance>0&&holeDistance>0)
132  {
133  distance=sqrt(pow(wallDistance,2)+pow(holeDistance,2));
134  Vec3D ContactPoint;
135  double alpha=atan2(P.get_Position().Y,P.get_Position().X);
136  ContactPoint.X=holeRadius*cos(alpha);
137  ContactPoint.Y=holeRadius*sin(alpha);
138  ContactPoint.Z=position;
139  //std::cout<<"ContactPoint="<<ContactPoint<<" Particle position="<<P.get_Position()<<std::endl;
140  normal_return=ContactPoint-P.get_Position();
141  normal_return/=normal_return.GetLength();
142  //std::cout<<"Corner collision normal="<<normal_return<<std::endl;
143  return true;
144  }
145  else if(wallDistance>holeDistance)
146  {
147  distance=wallDistance;
148  normal_return = normal;
149  //std::cout<<"Wall collision normal="<<normal_return<<std::endl;
150  return true;
151  }
152  else
153  {
154  distance=holeDistance;
155  normal_return.X=P.get_Position().X/(holeRadius-holeDistance);
156  normal_return.Y=P.get_Position().Y/(holeRadius-holeDistance);;
157  normal_return.Z=0;
158  //std::cout<<"Hole collision normal="<<normal_return<<std::endl;
159  return true;
160  }
161  }
Mdouble X
Definition: Vector.h:44
Mdouble get_Radius() const
Mdouble get_holeDistance(const Vec3D &Position)
const Vec3D & get_Position() const
Mdouble Y
Definition: Vector.h:44
Mdouble GetLength() const
Definition: Vector.h:248
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:40
Mdouble Z
Definition: Vector.h:44
Mdouble get_wallDistance(const Vec3D &Position)
Returns the distance of the wall to the particle.
Mdouble InfiniteWallWithHole::get_holeDistance ( const Vec3D Position)
inline

Definition at line 117 of file InfiniteWallWithHole.h.

References holeRadius, Vec3D::X, and Vec3D::Y.

Referenced by get_distance_and_normal().

117 {return holeRadius-sqrt(pow(Position.X,2)+pow(Position.Y,2));}
Mdouble X
Definition: Vector.h:44
Mdouble Y
Definition: Vector.h:44
Vec3D InfiniteWallWithHole::get_Normal ( )
inline

access function for normal

Definition at line 177 of file InfiniteWallWithHole.h.

References normal.

177 {return normal;}
Mdouble InfiniteWallWithHole::get_Position ( )
inline

access function for position

Definition at line 179 of file InfiniteWallWithHole.h.

References position.

179 {return position;}
Vec3D InfiniteWallWithHole::get_Velocity ( ) const
inlinevirtual

access function for velocity

Implements BaseWall.

Definition at line 181 of file InfiniteWallWithHole.h.

References velocity.

181 {return velocity;}
Vec3D velocity
velocity of the wall (used to calculate the relative velocity in the force calculation) ...
Mdouble InfiniteWallWithHole::get_wallDistance ( const Vec3D Position)
inline

Returns the distance of the wall to the particle.

Definition at line 115 of file InfiniteWallWithHole.h.

References normal, and position.

Referenced by get_distance_and_normal().

115 {return position - Dot(Position, normal);}
void InfiniteWallWithHole::move ( Mdouble position_  )
inlinevirtual

Allows the wall to be moved to a new position.

Reimplemented from BaseWall.

Definition at line 99 of file InfiniteWallWithHole.h.

References factor, and position.

99  {
100  position=position_*factor;
101  }
void InfiniteWallWithHole::move ( Vec3D velocity_  ,
Mdouble dt   
)
inlinevirtual

Allows the wall to be moved to a new position (also orthogonal to the normal), and setting the velocity.

Reimplemented from BaseWall.

Definition at line 104 of file InfiniteWallWithHole.h.

References normal, position, and velocity.

104  {
105  velocity=velocity_;
106  position+=Dot(velocity,normal)*dt;
107  }
Vec3D velocity
velocity of the wall (used to calculate the relative velocity in the force calculation) ...
void InfiniteWallWithHole::move_time ( Mdouble dt  )
inlinevirtual

Allows the wall to be moved with time.

Reimplemented from BaseWall.

Definition at line 110 of file InfiniteWallWithHole.h.

References normal, position, and velocity.

110  {
111  position+=Dot(velocity,normal)*dt;
112  }
Vec3D velocity
velocity of the wall (used to calculate the relative velocity in the force calculation) ...
void InfiniteWallWithHole::print ( std::ostream &  os) const
inline

outputs wall

Definition at line 170 of file InfiniteWallWithHole.h.

References Vec3D::GetLength2, holeRadius, normal, position, and velocity.

170  {
171  os << "InfiniteWallWithHole normal " << normal << " position " << position<< " holeRadius "<<holeRadius;
172  //optional output
173  if (velocity.GetLength2()) os << " velocity " << velocity;
174  }
friend Mdouble GetLength2(const Vec3D &A)
Definition: Vector.h:183
Vec3D velocity
velocity of the wall (used to calculate the relative velocity in the force calculation) ...
void InfiniteWallWithHole::read ( std::istream &  is)
inline

reads wall

Definition at line 164 of file InfiniteWallWithHole.h.

References normal, position, and velocity.

164  {
165  std::string dummy;
166  is >> dummy >> normal >> dummy >> position >> dummy >> velocity;
167  }
Vec3D velocity
velocity of the wall (used to calculate the relative velocity in the force calculation) ...
void InfiniteWallWithHole::set ( Vec3D  normal_,
Mdouble  position_,
Mdouble  holeRadius_ 
)
inline

Defines a standard wall, given an outward normal vector s. t. normal*x=position.

Definition at line 89 of file InfiniteWallWithHole.h.

References factor, holeRadius, normal, and position.

90  {
91  //factor is used to set n to unit length
92  factor = 1. / sqrt(Dot(normal_, normal_));
93  normal = normal_ * factor;
94  position = position_ * factor;
95  holeRadius=holeRadius_;
96  }
void InfiniteWallWithHole::set_Velocity ( Vec3D  new_)
inline

access function for velocity

Definition at line 183 of file InfiniteWallWithHole.h.

References velocity.

183 {velocity = new_;}
Vec3D velocity
velocity of the wall (used to calculate the relative velocity in the force calculation) ...

Member Data Documentation

Mdouble InfiniteWallWithHole::factor
private

Definition at line 188 of file InfiniteWallWithHole.h.

Referenced by InfiniteWallWithHole(), move(), and set().

Mdouble InfiniteWallWithHole::holeRadius
private
Vec3D InfiniteWallWithHole::normal
private
Mdouble InfiniteWallWithHole::position
private
Vec3D InfiniteWallWithHole::velocity
private

velocity of the wall (used to calculate the relative velocity in the force calculation)

Definition at line 189 of file InfiniteWallWithHole.h.

Referenced by clear(), get_Velocity(), InfiniteWallWithHole(), move(), move_time(), print(), read(), and set_Velocity().


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