MercuryDPM
Alpha
|
Variation on the PeriodicBoundary with maser-like properties. More...
#include <MaserBoundary.h>
Public Member Functions | |
MaserBoundary * | copy () const |
Creates a copy on the heap. More... | |
void | set (Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight) |
Sets all boundary properties at once. More... | |
void | read (std::istream &is) |
reads boundary properties from istream More... | |
void | write (std::ostream &os) const |
writes boundary properties to ostream More... | |
virtual std::string | getName () const |
Returns the name of the object. More... | |
Mdouble | getDistance (BaseParticle &p) |
Returns the distance of the wall to the particle. More... | |
Mdouble | getDistance (const Vec3D &position) |
Returns the distance of the wall to the position. More... | |
void | shiftPosition (BaseParticle *p) |
shifts the particle to its 'periodic' position More... | |
void | createPeriodicParticles (BaseParticle *p, ParticleHandler &pH) |
Creates periodic particle when the particle is a maser particle and is sufficiently close to one of the boundary walls. More... | |
bool | checkBoundaryAfterParticleMoved (BaseParticle *p, ParticleHandler &pH) |
Shifts the particle to its 'periodic' position if it is a maser particle and has crossed either of the walls. Creates a 'normal' particle at its current position if it is a maser particle which crossed the RIGHT boundary wall. More... | |
void | addParticleToMaser (BaseParticle *p) |
Converts a 'normal' particle into a maser particle. 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... | |
BoundaryHandler * | getHandler () 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_ |
Normal unit vector of both maser walls. Points in the flowing direction. More... | |
Mdouble | distanceLeft_ |
position of left boundary wall, s.t. normal*x=position_left More... | |
Mdouble | distanceRight_ |
position of right boundary wall, s.t. normal*x=position_right More... | |
bool | closestToLeftBoundary_ |
Dummy variable used when checking the proximity of particles to the boundary walls. TRUE if closest wall is the left boundary wall. More... | |
Vec3D | shift_ |
Direction in which particles are to be shifted when they cross the boundary. More... | |
std::map< const ParticleSpecies *, const ParticleSpecies * > | speciesConversionNormalToMaser_ |
List of 'normal' particles' species, and their maser counterparts. More... | |
std::map< const ParticleSpecies *, const ParticleSpecies * > | speciesConversionMaserToNormal_ |
List of 'maser' particles' species, and their normal counterparts. More... | |
Variation on the PeriodicBoundary with maser-like properties.
Creates a boundary which is similar to a PeriodicBoundary, except that particles which leave
Definition at line 44 of file MaserBoundary.h.
void MaserBoundary::addParticleToMaser | ( | BaseParticle * | p | ) |
Converts a 'normal' particle into a maser particle.
Turns given particle into a 'maser particle' by changing its species into a 'maser particle' copy species. If the particle species is not yet in the std::map speciesConversionNormalToMaser_, it and its maser copy species are added. This function should be called at the beginning of the simulation, right after actually filling the maser with particles, flagging each particle as one belonging to the maser.
[in,out] | p | The particle which is added to the maser. Its species is 'changed' to the maser copy species. |
Definition at line 307 of file MaserBoundary.cc.
References ParticleSpecies::copy(), BaseHandler< T >::copyAndAddObject(), BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), BaseObject::getId(), BaseInteractable::getSpecies(), INFO, logger, BaseParticle::setSpecies(), speciesConversionMaserToNormal_, speciesConversionNormalToMaser_, DPMBase::speciesHandler, and VERBOSE.
bool MaserBoundary::checkBoundaryAfterParticleMoved | ( | BaseParticle * | p, |
ParticleHandler & | pH | ||
) |
Shifts the particle to its 'periodic' position if it is a maser particle and has crossed either of the walls. Creates a 'normal' particle at its current position if it is a maser particle which crossed the RIGHT boundary wall.
Checks whether given particle has crossed the closest wall, and if so, shifts its position so as to have it appear at the other wall
[in] | p | The particle to be checked and possibly shifted |
pH | The ParticleHandler, which is unused in this implementation |
Apparently, somewhere in the ages past, at some time, there has existed a piece of code which prevents the particles crossing the periodic boundary on the left side from reappearing on the right. This was taken out somewhere between the dark ages an the current one (feb. 2015) and should be put back in. Only causes errors very rarely, and not in the compiler but rather in the actual physics going on (So its not detected by the MaserSelfTest). The current arrangement mainly causes problems with particles which oscillate on the boundary, continuously crossing from left to right and back. A visual consideration of this problem can be found in Documentation/Images/Maser_unperiodic_behaviour.jpg, which, granted, is appalling in its own right, but has yet to suffice in awaitance of a better (i.e. clearer) drawing. Therefore:
Create a new diagram explaining the problems with the previous (NOW: CURRENT!) implementation, and the exact differences between the two. I.e., an improved version of Documentation/Images/Maser_unperiodic_behaviour.jpg. (BvdH)
Definition at line 236 of file MaserBoundary.cc.
References closestToLeftBoundary_, BaseHandler< T >::copyAndAddObject(), DEBUG, getDistance(), BaseHandler< T >::getNumberOfObjects(), BaseInteractable::getSpecies(), logger, BaseParticle::setSpecies(), shiftPosition(), and speciesConversionMaserToNormal_.
|
virtual |
Creates a copy on the heap.
Copy method, creates a copy of the object on the heap and returns a pointer to it.
Implements BaseBoundary.
Definition at line 40 of file MaserBoundary.cc.
void MaserBoundary::createPeriodicParticles | ( | BaseParticle * | p, |
ParticleHandler & | pH | ||
) |
Creates periodic particle when the particle is a maser particle and is sufficiently close to one of the boundary walls.
Checks the distance of given particle to the closest of both walls, and creates a periodic copy of the particle if needed (i.e. if the particle is closer to the periodic wall than the radius of the largest particle in the system).
[in] | p | Particle to be checked and possibly periodically copied |
[in,out] | pH | System's ParticleHandler, (1) from which the interaction radius of its largest particle is retrieved to determine the maximum distance from the wall at which a particle should still have a periodic copy created, and (2) to which a possible periodic copy of the particle will be added |
Definition at line 165 of file MaserBoundary.cc.
References ParticleHandler::addObject(), closestToLeftBoundary_, BaseParticle::copy(), BaseInteractable::copyInteractionsForPeriodicParticles(), getDistance(), BaseParticle::getInteractionRadius(), ParticleHandler::getLargestParticle(), BaseParticle::getPeriodicFromParticle(), BaseInteractable::getSpecies(), BaseParticle::setPeriodicFromParticle(), shiftPosition(), and speciesConversionMaserToNormal_.
Mdouble MaserBoundary::getDistance | ( | BaseParticle & | p | ) |
Returns the distance of the wall to the particle.
Returns the distance to the closest wall of the boundary to the particle, , and sets closestToLeftBoundary_ = true if the left wall is the wall closest to the particle.
[in] | p | A reference to the particle of which the distance to the boundary wall is to be calculated |
Definition at line 93 of file MaserBoundary.cc.
References BaseInteractable::getPosition().
Referenced by checkBoundaryAfterParticleMoved(), and createPeriodicParticles().
Returns the distance of the wall to the position.
Returns the distance to the wall closest to the position, and sets closestToLeftBoundary_ = true if the left wall is the wall closest to the position.
[in] | position | (A reference to) the position of which the distance to the boundary wall is to be calculated |
Definition at line 104 of file MaserBoundary.cc.
References closestToLeftBoundary_, distanceLeft_, distanceRight_, Vec3D::dot(), and normal_.
|
virtual |
Returns the name of the object.
Returns the name of the object class
Implements BaseObject.
Definition at line 82 of file MaserBoundary.cc.
|
virtual |
reads boundary properties from istream
Reads the boundary properties from an istream
[in,out] | is | the istream |
Implements BaseBoundary.
Definition at line 64 of file MaserBoundary.cc.
References BaseBoundary::read().
Sets all boundary properties at once.
Set all the properties of the boundary at once.
[in] | normal | Normal unit vector of the (parallel) boundary walls |
[in] | distanceLeft | The distance of the left wall to the origin |
[in] | distanceRight | The distance of the right wall to the origin |
Definition at line 51 of file MaserBoundary.cc.
References distanceLeft_, distanceRight_, normal_, and shift_.
void MaserBoundary::shiftPosition | ( | BaseParticle * | p | ) |
shifts the particle to its 'periodic' position
Shifts the particle (using the closestToLeftBoundary_ value)
[in] | p | A pointer to the particle which will be shifted. |
Definition at line 138 of file MaserBoundary.cc.
References closestToLeftBoundary_, BaseInteractable::move(), and shift_.
Referenced by checkBoundaryAfterParticleMoved(), and createPeriodicParticles().
|
virtual |
writes boundary properties to ostream
Writes boundary's properties to an ostream
[in] | os | the ostream |
Implements BaseBoundary.
Definition at line 73 of file MaserBoundary.cc.
References BaseBoundary::write().
|
private |
Dummy variable used when checking the proximity of particles to the boundary walls. TRUE if closest wall is the left boundary wall.
Definition at line 122 of file MaserBoundary.h.
Referenced by checkBoundaryAfterParticleMoved(), createPeriodicParticles(), getDistance(), and shiftPosition().
|
private |
position of left boundary wall, s.t. normal*x=position_left
Definition at line 113 of file MaserBoundary.h.
Referenced by getDistance(), and set().
|
private |
position of right boundary wall, s.t. normal*x=position_right
Definition at line 117 of file MaserBoundary.h.
Referenced by getDistance(), and set().
|
private |
Normal unit vector of both maser walls. Points in the flowing direction.
Definition at line 109 of file MaserBoundary.h.
Referenced by getDistance(), and set().
|
private |
Direction in which particles are to be shifted when they cross the boundary.
I.e., the vector pointing from a point the left boundary wall to the equivalent point on the right one.
Definition at line 128 of file MaserBoundary.h.
Referenced by set(), and shiftPosition().
|
private |
List of 'maser' particles' species, and their normal counterparts.
Definition at line 138 of file MaserBoundary.h.
Referenced by addParticleToMaser(), checkBoundaryAfterParticleMoved(), and createPeriodicParticles().
|
private |
List of 'normal' particles' species, and their maser counterparts.
Definition at line 133 of file MaserBoundary.h.
Referenced by addParticleToMaser().