MercuryDPM  0.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InfiniteWall.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 
30 
31 #ifndef INFINITEWALL_H
32 #define INFINITEWALL_H
33 
42 class InfiniteWall : public BaseWall
43 {
44  public:
46  {
47  #ifdef CONSTUCTOR_OUTPUT
48  std::cout<<"InfiniteWall () finished"<<std::endl;
49  #endif
50  }
51 
53  {
54  normal=p.normal;
56  factor=p.factor;
57  #ifdef CONSTUCTOR_OUTPUT
58  std::cout<<"InfiniteWall (const InfiniteWall &p) finished"<<std::endl;
59  #endif
60  }
61 
63  InfiniteWall* copy() const
64  {
65  return new InfiniteWall(*this);
66  }
67 
68  void clear()
69  {
70  indSpecies = 0;
72  }
73 
75  void set(Vec3D normal_, Mdouble position_)
76  {
77  //factor is used to set n to unit length
78  factor = 1. / sqrt(Dot(normal_, normal_));
79  normal = normal_ * factor;
80  position = position_ * factor;
81  }
82 
84  void move(Mdouble position_) {
85  position=position_*factor;
86  }
87 
89  void move(Vec3D velocity_, Mdouble dt) {
90  velocity=velocity_;
91  position+=Dot(velocity,normal)*dt;
92  }
93 
95  void move_time(Mdouble dt) {
96  position+=Dot(velocity,normal)*dt;
97  }
98 
99 
101  Mdouble get_distance(const Vec3D &Position) {return position - Dot(Position, normal);}
102 
104  bool get_distance_and_normal(BaseParticle &P, Mdouble &distance, Vec3D &normal_return)
105  {
106  distance = get_distance(P.get_Position());
107  if (distance>=P.get_WallInteractionRadius())
108  return false;
109  normal_return = normal;
110  return true;
111  }
112 
114  void read(std::istream& is) {
115  std::string dummy;
116  is >> dummy >> normal >> dummy >> position >> dummy >> velocity;
117  }
118 
120  void print(std::ostream& os) const {
121  os << "InfiniteWall normal " << normal << " position " << position;
122  //\todo{species should be written}
123  //optional output
124  if (velocity.GetLength2()) os << " velocity " << velocity;
125  }
126 
128  Vec3D get_Normal() const {return normal;}
130  Mdouble get_Position() const {return position;}
131 
133  Vec3D get_Velocity() const {return velocity;}
134 
135 private:
136  Vec3D normal; //<outward unit normal vector
137  Mdouble position; //<position n*x=p
138  Mdouble factor; //<This is the normal to rescale to unit vectoers.
139 };
140 
141 #endif
void read(std::istream &is)
reads wall
Definition: InfiniteWall.h:114
void move_time(Mdouble dt)
Allows the wall to be moved with time.
Definition: InfiniteWall.h:95
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: InfiniteWall.h:104
Mdouble get_Position() const
access function for position
Definition: InfiniteWall.h:130
Vec3D velocity
velocity of the wall (used to calculate the relative velocity in the force calculation) ...
Definition: BaseWall.h:114
Mdouble factor
Definition: InfiniteWall.h:138
InfiniteWall(const InfiniteWall &p)
Definition: InfiniteWall.h:52
friend Mdouble GetLength2(const Vec3D &A)
Definition: Vector.h:183
InfiniteWall * copy() const
Wall copy method. It calls the copy contrustor of this Wall, usefull for polymorfism.
Definition: InfiniteWall.h:63
Mdouble get_distance(const Vec3D &Position)
Returns the distance of the wall to the particle.
Definition: InfiniteWall.h:101
Vec3D get_Velocity() const
access function for velocity
Definition: InfiniteWall.h:133
double Mdouble
Definition: ExtendedMath.h:33
Mdouble get_WallInteractionRadius() const
void move(Mdouble position_)
Allows the wall to be moved to a new position.
Definition: InfiniteWall.h:84
void clear()
Definition: InfiniteWall.h:68
const Vec3D & get_Position() const
void set(Vec3D normal_, Mdouble position_)
Defines a standard wall, given an outward normal vector s. t. normal*x=position.
Definition: InfiniteWall.h:75
Mdouble position
Definition: InfiniteWall.h:137
void set_zero()
Definition: Vector.h:55
int indSpecies
Definition: BaseWall.h:36
This is a class defining walls.
Definition: InfiniteWall.h:42
void move(Vec3D velocity_, Mdouble dt)
Allows the wall to be moved to a new position (also orthogonal to the normal), and setting the veloci...
Definition: InfiniteWall.h:89
void print(std::ostream &os) const
outputs wall
Definition: InfiniteWall.h:120
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:40
Vec3D get_Normal() const
access function for normal
Definition: InfiniteWall.h:128