HG-MD  1
Public Member Functions | Private Attributes | Friends
CWallPeriodic Class Reference

Defines a pair of periodic walls. More...

#include <CWall.h>

Collaboration diagram for CWallPeriodic:
Collaboration graph
[legend]

List of all members.

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
Vec3Dget_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

Detailed Description

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.


Constructor & Destructor Documentation

{}

Member Function Documentation

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());
  }

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.

                                                   {
                Mdouble PQdotn = Dot(P-Q, normal);
                Mdouble shift_norm2 = shift.GetLength2();
                //Check if P is so far from Q that a shift would move it closer
                if (sqr(PQdotn) > .25 * shift_norm2) {
                        //Now determine the direction of the shift
                        if (PQdotn>0.0) P -= shift;
                        else P += shift;
                }
        }
bool CWallPeriodic::get_left_wall ( ) const [inline]

References left_wall.

{return left_wall;}

References normal.

{return normal;}

returns the shifted particle w/o actually shifting

References left_wall, and shift.

                                                    {
                if (left_wall) {
                        return Position + shift;
                }
                else {
                        return Position - shift;
                }
        }
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.

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.

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]

References normal.

{normal=new_;}
void CWallPeriodic::shift_position ( Vec3D Position) [inline]

shifts the particle (after distance set the left_wall value)

References left_wall, and shift.

                                             {
                if (left_wall) {
                        Position += shift;
                        left_wall = false;
                }
                else {
                        Position -= shift;
                        left_wall = true;
                }
        }
void CWallPeriodic::shift_positions ( Vec3D PI,
Vec3D PJ 
) [inline]

shifts two particles

References left_wall, and shift.

                                                   {
                if (left_wall) {
                        PI += shift;
                        PJ += shift;
                        left_wall = false;
                }
                else {
                        PI -= shift;
                        PJ -= shift;
                        left_wall = true;
                }
        }

Friends And Related Function Documentation

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;
        }

Member Data Documentation

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().

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().

position of left wall, s.t. normal*x=position_left

Referenced by CWallPeriodic(), distance(), move_left(), move_right(), print(), read(), and set().

position of right wall, s.t. normal*x=position_right

Referenced by CWallPeriodic(), distance(), move_left(), move_right(), print(), read(), and set().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines