MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DeletionBoundary Class Reference

Used for removing particles from the problem. Inherits from BaseBoundary. More...

#include <DeletionBoundary.h>

+ Inheritance diagram for DeletionBoundary:

Public Member Functions

 DeletionBoundary ()
 default constructor More...
 
 ~DeletionBoundary ()
 destructor More...
 
DeletionBoundarycopy () const
 Copy method; creates copy on the heap and returns a pointer to it. More...
 
void set (const Vec3D &normal, Mdouble distance)
 Sets boundary position based on a normal and distance. More...
 
void move (Mdouble position)
 Sets the boundary's distance property to the given one. More...
 
Mdouble getDistance (const Vec3D &position) const
 Returns the shortest distance between the boundary and given position. More...
 
bool checkBoundaryAfterParticleMoved (BaseParticle *p, ParticleHandler &pH)
 Checks if particle passed the boundary and deletes the particle if so. More...
 
void read (std::istream &is)
 Reads some boundary properties from an std::istream. More...
 
MERCURY_DEPRECATED void oldRead (std::istream &is)
 Deprecated read method. use DeletionBoundary::read() instead. More...
 
void write (std::ostream &os) const
 Writes the boundary properties to an std::ostream. More...
 
virtual std::string getName () const
 Returns the name of the object. More...
 
- Public Member Functions inherited from BaseBoundary
 BaseBoundary ()
 default constructor. More...
 
 BaseBoundary (const BaseBoundary &b)
 copy constructor More...
 
virtual ~BaseBoundary ()
 destructor More...
 
virtual void createPeriodicParticles (BaseParticle *P UNUSED, ParticleHandler &pH UNUSED)
 Creates periodic copies of given particle in case of periodic boundaries. More...
 
virtual bool checkBoundaryAfterParticleMoved (BaseParticle *P UNUSED, ParticleHandler &pH UNUSED)
 Checks if given particle passed the boundary. More...
 
virtual void checkBoundaryBeforeTimeStep (DPMBase *md UNUSED)
 Fills a (3D) boundary with particles. More...
 
void setHandler (BoundaryHandler *handler)
 Sets the boundary's BoundaryHandler. More...
 
BoundaryHandlergetHandler () const
 Returns the boundary's BoundaryHandler. More...
 
- Public Member Functions inherited from BaseObject
 BaseObject ()
 Default constructor. More...
 
 BaseObject (const BaseObject &p)
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()
 virtual destructor More...
 
virtual void moveInHandler (const unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (const unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (const unsigned int id)
 Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler. More...
 
unsigned int getIndex () const
 Returns the index of the object in the handler. More...
 
unsigned int getId () const
 Returns the unique identifier of any particular object. More...
 

Private Attributes

Vec3D normal_
 outward unit normal vector More...
 
Mdouble scaleFactor_
 This is the factor to rescale the given normal vector to a unit vectors. More...
 
Mdouble distance_
 The boundary's distance from the origin. More...
 

Detailed Description

Used for removing particles from the problem. Inherits from BaseBoundary.

Definition at line 40 of file DeletionBoundary.h.

Constructor & Destructor Documentation

DeletionBoundary::DeletionBoundary ( )

default constructor

Default constructor (calls the parent-constructor of BaseBoundary as well)

Definition at line 35 of file DeletionBoundary.cc.

References distance_, and scaleFactor_.

Referenced by copy().

36  : BaseBoundary()
37 {
38  distance_ = std::numeric_limits<double>::quiet_NaN();
39  scaleFactor_ = std::numeric_limits<double>::quiet_NaN();
40 #ifdef DEBUG_CONSTRUCTOR
41  std::cout<<"DeletionBoundary::DeletionBoundary() finished"<<std::endl;
42 #endif
43 }
Mdouble scaleFactor_
This is the factor to rescale the given normal vector to a unit vectors.
Mdouble distance_
The boundary's distance from the origin.
BaseBoundary()
default constructor.
Definition: BaseBoundary.cc:32
DeletionBoundary::~DeletionBoundary ( )

destructor

Destructor

Definition at line 48 of file DeletionBoundary.cc.

49 {
50 #ifdef DEBUG_DESTRUCTOR
51  std::cout<<"DeletionBoundary::~DeletionBoundary() finished"<<std::endl;
52 #endif
53 }

Member Function Documentation

bool DeletionBoundary::checkBoundaryAfterParticleMoved ( BaseParticle p,
ParticleHandler pH 
)

Checks if particle passed the boundary and deletes the particle if so.

Checks if particle has passed the boundary, and if so, deletes the particle.

Parameters
[in]ppointer to the particle which is to be checked
[out]pHthe particle's ParticleHandler, from which the particle is removed in case it has passed the boundary.
Returns
TRUE if the particle has actually passed the boundary and is thus deleted.

Definition at line 114 of file DeletionBoundary.cc.

References getDistance(), BaseObject::getIndex(), BaseInteractable::getPosition(), and ParticleHandler::removeObject().

115 {
116  if (getDistance(p->getPosition()) < 0)
117  {
118  pH.removeObject(p->getIndex());
119  return true;
120  }
121  else
122  return false;
123 }
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.cc:106
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Mdouble getDistance(const Vec3D &position) const
Returns the shortest distance between the boundary and given position.
virtual void removeObject(unsigned const int id)
Removes a BaseParticle from the ParticleHandler.
DeletionBoundary * DeletionBoundary::copy ( ) const
virtual

Copy method; creates copy on the heap and returns a pointer to it.

Copy function, which creates a copy and returns a pointer to that copy (on the heap)

Returns
pointer to the copy

Implements BaseBoundary.

Definition at line 60 of file DeletionBoundary.cc.

References DeletionBoundary().

61 {
62  return new DeletionBoundary(*this);
63 }
DeletionBoundary()
default constructor
Mdouble DeletionBoundary::getDistance ( const Vec3D position) const

Returns the shortest distance between the boundary and given position.

Calculates the shortest distance between the wall and given position.

Parameters
[in]positionthe position of which the distance should be calculated.

Definition at line 100 of file DeletionBoundary.cc.

References distance_, Vec3D::dot(), and normal_.

Referenced by checkBoundaryAfterParticleMoved().

101  {
102  return distance_ - Vec3D::dot(position, normal_);
103 }
Vec3D normal_
outward unit normal vector
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:187
Mdouble distance_
The boundary's distance from the origin.
std::string DeletionBoundary::getName ( ) const
virtual

Returns the name of the object.

Returns the object's class name (i.e. 'DeletionBoundary').

Returns
the object's class name

Implements BaseObject.

Definition at line 165 of file DeletionBoundary.cc.

166 {
167  return "DeletionBoundary";
168 }
void DeletionBoundary::move ( Mdouble  distance)

Sets the boundary's distance property to the given one.

Resets the boundary's 'distance' from the origin to be the one given.

Parameters
[in]distancethe new 'distance' between boundary and origin. see also comments of DeletionBoundary::set().

Definition at line 91 of file DeletionBoundary.cc.

References distance_, and scaleFactor_.

92 {
93  distance_ = distance * scaleFactor_;
94 }
Mdouble scaleFactor_
This is the factor to rescale the given normal vector to a unit vectors.
Mdouble distance_
The boundary's distance from the origin.
void DeletionBoundary::oldRead ( std::istream &  is)

Deprecated read method. use DeletionBoundary::read() instead.

the deprecated version of the read-method. Should not be used by new users!

Deprecated:
Should be gone by Mercury 2.0. Use DeletionBoundary::read() instead.

Definition at line 143 of file DeletionBoundary.cc.

References distance_, normal_, and scaleFactor_.

144 {
145  std::string dummy;
146  is >> dummy >> normal_ >> dummy >> scaleFactor_ >> dummy >> distance_;
147 }
Vec3D normal_
outward unit normal vector
Mdouble scaleFactor_
This is the factor to rescale the given normal vector to a unit vectors.
Mdouble distance_
The boundary's distance from the origin.
void DeletionBoundary::read ( std::istream &  is)
virtual

Reads some boundary properties from an std::istream.

Reads a number of boundary properties from the given std::istream.

Parameters
[in,out]isthe istream

Implements BaseBoundary.

Definition at line 129 of file DeletionBoundary.cc.

References distance_, normal_, BaseBoundary::read(), and scaleFactor_.

130 {
131  BaseBoundary::read(is);
132  std::string dummy;
133  is >> dummy >> normal_
134  >> dummy >> scaleFactor_
135  >> dummy >> distance_;
136 }
Vec3D normal_
outward unit normal vector
Mdouble scaleFactor_
This is the factor to rescale the given normal vector to a unit vectors.
Mdouble distance_
The boundary's distance from the origin.
void read(std::istream &is)=0
Reads the object's id_ from given istream NB: purely virtual function.
Definition: BaseBoundary.cc:67
void DeletionBoundary::set ( const Vec3D normal,
Mdouble  distance 
)

Sets boundary position based on a normal and distance.

Defines the placing of the (2D) boundary based on the given normal and distance.

Parameters
[in]normalboundary normal vector
[in]distance'distance' between the origin and the boundary, such that the following relation is satisfied:

\[ \mathbf{r} \cdot \mathbf{\hat{n}} = d \]

in which \( \mathbf{\hat{n}} \) and \( d \) are the given normal vector and distance, respectively. NB: If the distance is the ACTUAL distance from the origin, the normal vector must be of UNIT LENGTH for the placing of the boundary to be done correctly.

Definition at line 79 of file DeletionBoundary.cc.

References distance_, Vec3D::dot(), normal_, and scaleFactor_.

80 {
81  scaleFactor_ = 1. / std::sqrt(Vec3D::dot(normal, normal));
82  normal_ = normal * scaleFactor_;
83  distance_ = distance * scaleFactor_;
84 }
Vec3D normal_
outward unit normal vector
Mdouble scaleFactor_
This is the factor to rescale the given normal vector to a unit vectors.
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:187
Mdouble distance_
The boundary's distance from the origin.
void DeletionBoundary::write ( std::ostream &  os) const
virtual

Writes the boundary properties to an std::ostream.

Writes the boundary properties to an std::ostream.

Parameters
[out]osthe ostream the properties are to be written to.

Implements BaseBoundary.

Definition at line 153 of file DeletionBoundary.cc.

References distance_, normal_, scaleFactor_, and BaseBoundary::write().

154  {
156  os << " normal " << normal_
157  << " scaleFactor " << scaleFactor_
158  << " distance " << distance_;
159 }
Vec3D normal_
outward unit normal vector
void write(std::ostream &os) const =0
Adds object's id_ to given ostream NB: purely virtual function.
Definition: BaseBoundary.cc:76
Mdouble scaleFactor_
This is the factor to rescale the given normal vector to a unit vectors.
Mdouble distance_
The boundary's distance from the origin.

Member Data Documentation

Mdouble DeletionBoundary::distance_
private

The boundary's distance from the origin.

Definition at line 114 of file DeletionBoundary.h.

Referenced by DeletionBoundary(), getDistance(), move(), oldRead(), read(), set(), and write().

Vec3D DeletionBoundary::normal_
private

outward unit normal vector

Definition at line 101 of file DeletionBoundary.h.

Referenced by getDistance(), oldRead(), read(), set(), and write().

Mdouble DeletionBoundary::scaleFactor_
private

This is the factor to rescale the given normal vector to a unit vectors.

NB: Not only the normal vector is rescaled by this factor, also the 'distance' from the origin of the boundary is scaled by this factor! Also, once the boundary position is set with DeletionBoundary::set(), the arguments of any reset of the distance_ property (i.e. usage of DeletionBoundary::move()) will be rescaled by the same factor!

Definition at line 110 of file DeletionBoundary.h.

Referenced by DeletionBoundary(), move(), oldRead(), read(), set(), and write().


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