|
HG-MD
1
|
Defines a pair of periodic walls. More...
#include <CWall.h>

Public Member Functions | |
| CWallPeriodic () | |
| CWallPeriodic (const CWallPeriodic &p) | |
| void | set (Vec3D normal_, Mdouble position_left_, Mdouble position_right_) |
| Defines a periodic wall, given a normal vector s.t. | |
| void | set (Vec3D normal_, Mdouble position_left_, Mdouble position_right_, Vec3D shift_direction) |
| For general parallelogramic domains, the direction of the shift vector has to be set manually. | |
| void | move_left (Mdouble position_) |
| Allows the left periodic wall to be moved to a new position and automatically changes its shift value. | |
| void | move_right (Mdouble position_) |
| Allows the right periodic wall to be moved to a new position and automatically changes its shift value. | |
| Mdouble | distance (Particle &P) |
| Returns the distance of the wall to the particle, and sets left_wall = true, if the left wall is the wall closest to the particle. | |
| Mdouble | distance (Vec3D &P) |
| void | shift_position (Vec3D &Position) |
| shifts the particle (after distance set the left_wall value) | |
| Vec3D | get_shifted_position (Vec3D &Position) |
| returns the shifted particle w/o actually shifting | |
| void | shift_positions (Vec3D &PI, Vec3D &PJ) |
| shifts two particles | |
| void | get_close_together (Vec3D &P, Vec3D &Q) |
| shift P such that it is closest to Q | |
| void | read (std::istream &is) |
| reads wall | |
| void | print (std::ostream &os, bool print_all=false) |
| outputs wall | |
| Vec3D & | get_normal () |
| void | set_normal (Vec3D new_) |
| bool | get_left_wall () const |
Private Attributes | |
| bool | left_wall |
| true if closest wall is the left wall | |
| Vec3D | normal |
| outward unit normal vector for right wall | |
| Mdouble | position_left |
| position of left wall, s.t. normal*x=position_left | |
| Mdouble | position_right |
| position of right wall, s.t. normal*x=position_right | |
| Mdouble | factor |
| This is the normal to rescale to unit vectoers. | |
| Vec3D | shift |
| shift from left to right boundary | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const CWallPeriodic &w) |
| writes wall | |
| std::istream & | operator>> (std::istream &is, CWallPeriodic &w) |
| reads wall | |
Defines a pair of periodic walls.
The particles are in {x: position_left<=normal*x <position_right}, with normal being the outward unit normal vector of the right wall. If a particle moves outside these boundaries, it will be shifted.
| CWallPeriodic::CWallPeriodic | ( | ) | [inline] |
{}
| CWallPeriodic::CWallPeriodic | ( | const CWallPeriodic & | p | ) | [inline] |
References factor, left_wall, normal, position_left, position_right, and shift.
{
left_wall = p.left_wall;
normal = p.normal;
position_left = p.position_left;
position_right = p.position_right;
factor = p.factor;
shift = p.shift;
}
| Mdouble CWallPeriodic::distance | ( | Particle & | P | ) | [inline] |
Returns the distance of the wall to the particle, and sets left_wall = true, if the left wall is the wall closest to the particle.
Since this function should be called before calculating any Particle-Wall interactions, it can also be used to set the shift vector in case of curved walls.
References Particle::get_Position().
{
return distance(P.get_Position());
}
| Mdouble CWallPeriodic::distance | ( | Vec3D & | P | ) | [inline] |
References left_wall, normal, position_left, and position_right.
{
Mdouble position = Dot(P, normal);
if (position - position_left < position_right - position) {
left_wall = true;
return position - position_left;
} else {
left_wall = false;
return position_right - position;
}
}
| void CWallPeriodic::get_close_together | ( | Vec3D & | P, |
| Vec3D & | Q | ||
| ) | [inline] |
shift P such that it is closest to Q
References Vec3D::GetLength2, normal, shift, and sqr.
| bool CWallPeriodic::get_left_wall | ( | ) | const [inline] |
| Vec3D& CWallPeriodic::get_normal | ( | ) | [inline] |
| Vec3D CWallPeriodic::get_shifted_position | ( | Vec3D & | Position | ) | [inline] |
| void CWallPeriodic::move_left | ( | Mdouble | position_ | ) | [inline] |
Allows the left periodic wall to be moved to a new position and automatically changes its shift value.
References factor, normal, position_left, position_right, and shift.
{
position_left=position_*factor;
shift = normal * (position_right - position_left);
}
| void CWallPeriodic::move_right | ( | Mdouble | position_ | ) | [inline] |
Allows the right periodic wall to be moved to a new position and automatically changes its shift value.
References factor, normal, position_left, position_right, and shift.
{
position_right=position_*factor;
shift = normal * (position_right - position_left);
}
| void CWallPeriodic::print | ( | std::ostream & | os, |
| bool | print_all = false |
||
| ) | [inline] |
outputs wall
References left_wall, normal, position_left, position_right, and shift.
{
os << "periodic_wall( normal:" << normal
<< ", position_left:" << position_left
<< ", position_right:" << position_right;
if (print_all) os << ", shift:" << shift << ", left_wall:" << left_wall;
os << ")";
}
| void CWallPeriodic::read | ( | std::istream & | is | ) | [inline] |
reads wall
References normal, position_left, position_right, and shift.
{
string dummy;
is >> dummy >> normal >> dummy >> position_left >> dummy >> position_right >> dummy >> shift;
}
| void CWallPeriodic::set | ( | Vec3D | normal_, |
| Mdouble | position_left_, | ||
| Mdouble | position_right_ | ||
| ) | [inline] |
Defines a periodic wall, given a normal vector s.t.
all particles are within {x: position_left<=normal*x<position_right}. The shift vector is set assuming that the domain is rectangular (shift parallel to normal).
References factor, normal, position_left, position_right, and shift.
{
// factor is used to set normal to unit length
factor = 1. / sqrt(Dot(normal_, normal_));
normal = normal_ * factor;
position_left = position_left_ * factor;
position_right = position_right_ * factor;
shift = normal * (position_right - position_left);
}
| void CWallPeriodic::set | ( | Vec3D | normal_, |
| Mdouble | position_left_, | ||
| Mdouble | position_right_, | ||
| Vec3D | shift_direction | ||
| ) | [inline] |
For general parallelogramic domains, the direction of the shift vector has to be set manually.
References factor, normal, position_left, position_right, and shift.
{
// factor is used to set normal to unit length
factor = 1. / sqrt(Dot(normal_, normal_));
normal = normal_ * factor;
position_left = position_left_ * factor;
position_right = position_right_ * factor;
// factor is used to set shift vector to correct length
factor = (position_right - position_left) * Dot(shift_direction, normal);
shift = shift_direction * factor;
}
| void CWallPeriodic::set_normal | ( | Vec3D | new_ | ) | [inline] |
| void CWallPeriodic::shift_position | ( | Vec3D & | Position | ) | [inline] |
| void CWallPeriodic::shift_positions | ( | Vec3D & | PI, |
| Vec3D & | PJ | ||
| ) | [inline] |
| std::ostream& operator<< | ( | std::ostream & | os, |
| const CWallPeriodic & | w | ||
| ) | [friend] |
writes wall
{
os<< "normal " << w.normal
<< " pos_left " << w.position_left
<< " pos_right " << w.position_right
<< " shift " << w.shift;
return os;
}
| std::istream& operator>> | ( | std::istream & | is, |
| CWallPeriodic & | w | ||
| ) | [friend] |
reads wall
{
is >> w.normal >> w.position_left >> w.position_right >> w.shift;
return is;
}
Mdouble CWallPeriodic::factor [private] |
This is the normal to rescale to unit vectoers.
Referenced by CWallPeriodic(), move_left(), move_right(), and set().
bool CWallPeriodic::left_wall [private] |
true if closest wall is the left wall
Referenced by CWallPeriodic(), distance(), get_left_wall(), get_shifted_position(), print(), shift_position(), and shift_positions().
Vec3D CWallPeriodic::normal [private] |
outward unit normal vector for right wall
Referenced by CWallPeriodic(), distance(), get_close_together(), get_normal(), move_left(), move_right(), print(), read(), set(), and set_normal().
Mdouble CWallPeriodic::position_left [private] |
position of left wall, s.t. normal*x=position_left
Referenced by CWallPeriodic(), distance(), move_left(), move_right(), print(), read(), and set().
Mdouble CWallPeriodic::position_right [private] |
position of right wall, s.t. normal*x=position_right
Referenced by CWallPeriodic(), distance(), move_left(), move_right(), print(), read(), and set().
Vec3D CWallPeriodic::shift [private] |
shift from left to right boundary
Referenced by CWallPeriodic(), get_close_together(), get_shifted_position(), move_left(), move_right(), print(), read(), set(), shift_position(), and shift_positions().
1.7.6.1