|
Variation on the PeriodicBoundary which also has an outflow part. More...
#include <ConstantMassFlowMaserBoundary.h>
Public Member Functions | |
ConstantMassFlowMaserBoundary () | |
MaserBoundary constructor. More... | |
ConstantMassFlowMaserBoundary (const PeriodicBoundary &periodicBoundary) | |
Maserboundary constructor that takes a periodic boundary, and converts it to a maser boundary. More... | |
ConstantMassFlowMaserBoundary * | copy () const override |
Creates a copy of this maser on the heap. More... | |
void | set (Vec3D normal, Vec3D planewiseShift, Mdouble distanceLeft, Mdouble distanceRight) |
Sets all boundary properties at once and adds particles of the handler to the maser. This deactivates the Maser. More... | |
void | set (Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight) |
Sets the Maser's normal and positions, and sets the planewise shift to zero. This deactivates the Maser. More... | |
void | setPlanewiseShift (Vec3D planewiseShift) |
Sets a planewise direction to the shift. Doesn't change the normal or the positions. More... | |
void | setShift (Vec3D shift) |
Sets the shift of the Maser. Usually don't use this directly, use set() or setPlanewiseShift() instead. More... | |
void | read (std::istream &is) override |
reads boundary properties from istream More... | |
void | write (std::ostream &os) const override |
writes boundary properties to ostream More... | |
std::string | getName () const override |
Returns the name of the object. More... | |
void | createPeriodicParticle (BaseParticle *p, ParticleHandler &pH) override |
Creates periodic particles when the particle is a maser particle and is sufficiently close to one of the boundary walls. More... | |
void | createPeriodicParticles (ParticleHandler &pH) override |
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 | checkBoundaryAfterParticlesMove (ParticleHandler &pH) override |
Evaluates what the particles have to do after they have changed position. More... | |
void | addParticleToMaser (BaseParticle *p) |
Converts a 'normal' particle into a maser particle. More... | |
void | removeParticleFromMaser (BaseParticle *p) |
Convert a maser particle into a 'normal' particle. More... | |
bool | isMaserParticle (BaseParticle *p) const |
Returns true if the particle is a Maser particle, and false otherwise. More... | |
bool | isNormalParticle (BaseParticle *p) const |
Returns true if the particle is a Normal particle, and false otherwise. More... | |
void | actionsBeforeTimeLoop () override |
Does everything that needs to be done for this boundary between setupInitialConditions and the time loop, in this case, it activates the maser. More... | |
void | activateMaser () |
Opens the gap, and transforms particles to maser particles. Also calls turnOnCopying(). More... | |
void | closeMaser () |
Stops copying particles (and act merely as a chute) More... | |
bool | isActivated () const |
Returns whether the Maser is activated or not. More... | |
void | turnOnCopying () |
Start copying particles. More... | |
void | turnOffCopying () |
Stop copying particles. More... | |
bool | isCopying () const |
Returns whether the Maser is copying particles or not. More... | |
Mdouble | getDistanceLeft () const |
Mdouble | getDistanceRight () const |
Mdouble | getGapSize () const |
Public Member Functions inherited from BaseBoundary | |
BaseBoundary () | |
default constructor. More... | |
BaseBoundary (const BaseBoundary &b) | |
copy constructor More... | |
~BaseBoundary () override | |
destructor More... | |
virtual void | createPeriodicParticle (BaseParticle *p UNUSED, ParticleHandler &pH UNUSED) |
Creates a periodic particle in case of periodic boundaries in serial build. More... | |
virtual void | createPeriodicParticles (ParticleHandler &pH UNUSED) |
Creates periodic copies of given particle in case of periodic boundaries. More... | |
virtual void | checkBoundaryBeforeTimeStep (DPMBase *md) |
Virtual function that does things before each time step. More... | |
virtual void | modifyGhostAfterCreation (BaseParticle *particle, int i) |
virtual void | writeVTK (std::fstream &file) |
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 | |
Default constructor. More... | |
BaseObject (const BaseObject &p)=default | |
Copy constructor, copies all the objects BaseObject contains. More... | |
virtual | ~BaseObject ()=default |
virtual destructor More... | |
virtual void | moveInHandler (unsigned int index) |
Except that it is virtual, it does the same thing as setIndex() does. More... | |
void | setIndex (unsigned int index) |
Allows one to assign an index to an object in the handler/container. More... | |
void | setId (unsigned long 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... | |
void | setGroupId (unsigned groupId) |
unsigned | getGroupId () const |
Private Member Functions | |
void | shiftPosition (BaseParticle *p) const |
Shifts the particle to its 'periodic' position. More... | |
BaseParticle * | createGhostCopy (BaseParticle *p) const |
Creates a copy of the input particle, that gets removed again in DPMBase::removeDuplicatePeriodicParticles. More... | |
bool | isClosestToRightBoundary (const BaseParticle *const p) const |
Returns whether the given particle is closer to the right boundary of the periodic part. More... | |
Mdouble | getDistance (BaseParticle *p) const |
Returns the distance of the wall to the particle. 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... | |
Mdouble | gapSize_ |
distance between the right side of the periodic domain and the start of the outflow domain. 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... | |
bool | maserIsActivated_ |
Flag whether or not the gap is created and particles transformed already. More... | |
bool | maserIsCopying_ |
Flag whether or not the Maser is copying particles. More... | |
Variation on the PeriodicBoundary which also has an outflow part.
Creates a boundary which divides the domain into two parts: a periodic domain and an outflow domain, with a gap inbetween. Any particle flowing through the right of the periodic domain is moved to both the left side of the periodic domain (as with a PeriodicBoundary), and also copied the left side of the outflow domain. Furthermore, the particles near the right side of the periodic domain also exert forces on the left side of the outflow domain as if there were no gap. However, the outflow domain has no influence on the periodic domain. When an outflow particle tries to enter the gap between the periodic domain and the outflow domain, it gets removed.
There are two distinct properties of the state of the Maser. ‘Activated’ or ‘closed’ refer to whether the particles within the Maser have been set to the Maser species and whether they have been moved by the gapSize. Particles will be affected by the Maser (i.e. moved periodically) iff the Maser is activated. On the other hand, ‘copying’ refers to whether new particles are being produced by the Maser. Thus, a Maser that is activated but not copying behaves just as a periodic boundary.
By default, activateMaser() also turns on copying. And when a Maser is closed, the value of isCopying() is irrelevant, although it is set to false for housekeeping.
Add functionality which allows for opening the maser boundary after a certain time, being a normal periodic boundary until then
Consider writing a destructor that closes the gap again
Consider splitting it in 2 DPMBase instances, one for the periodic domain and one for the outflow domain
Consider re-using the PeriodicBoundary by adding it as a data member
The difference between SubcriticalMaserBoundary (formerly known as MaserBoundaryOldStyle) and ConstantMassFlowMaserBoundary (formerly known simply as MaserBoundary) is that in ConstantMassFlowMaserBoundary, the left hand side of the periodic box does not have any influence on the rest of the flow, but the right side of the periodic box and the left side of the outflow domain interact. The ConstantMassFlowMaserBoundary is most useful for fast (supercritical) flows, and for flows for which the flux across the boundary needs to be controlled. The SubcriticalMaserBoundary is more useful for slow flows, as the ConstantMassFlowMaserBoundary might generate "pulse-waves" in those cases.
For a compact overview of the behaviour of ConstantMassFlowMaserBoundary, please look at the output of ConstantMassFlowMaserSelfTest.
ConstantMassFlowMaserBoundary::ConstantMassFlowMaserBoundary | ( | ) |
MaserBoundary constructor.
MaserBoundary constructor, sets all scalars to non-sensible values.
References distanceLeft_, distanceRight_, gapSize_, logger, maserIsActivated_, and WARN.
Referenced by copy().
|
explicit |
Maserboundary constructor that takes a periodic boundary, and converts it to a maser boundary.
MaserBoundary constructor from a periodic boundary. It copies the properties of the periodic boundary, and then immediately opens the maser. Do not insert particles for the maser after this constructor.
[in] | periodicBoundary | The periodic boundary on which this maser boundary is based. |
References activateMaser(), distanceLeft_, distanceRight_, gapSize_, PeriodicBoundary::getDistanceLeft(), PeriodicBoundary::getDistanceRight(), PeriodicBoundary::getNormal(), PeriodicBoundary::getShift(), INFO, logger, maserIsActivated_, NO_FLUSH, normal_, and shift_.
|
overridevirtual |
Does everything that needs to be done for this boundary between setupInitialConditions and the time loop, in this case, it activates the maser.
The maser boundary should be activated before the time loop starts, but after all particles are added.
Reimplemented from BaseBoundary.
References activateMaser().
void ConstantMassFlowMaserBoundary::activateMaser | ( | ) |
Opens the gap, and transforms particles to maser particles. Also calls turnOnCopying().
Activate the maser by creating a gap betweeen the periodic domain and the outflow domain, and transforming all the particles in the domain to maser particles. For an explanation of the magic number 6, see the detailed documentation for gapSize_. Note that gapSize_ is set here and not in set, since it is possible that the user first adds boundaries to the domain before the particles. The maser boundary should only be activated after all particles are in.
References addParticleToMaser(), distanceLeft_, distanceRight_, gapSize_, getDistance(), BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), ParticleHandler::getLargestParticleLocal(), BaseParticle::getRadius(), INFO, logger, maserIsActivated_, NO_FLUSH, DPMBase::particleHandler, turnOnCopying(), and WARN.
Referenced by actionsBeforeTimeLoop(), and ConstantMassFlowMaserBoundary().
void ConstantMassFlowMaserBoundary::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. |
References BaseHandler< T >::copyAndAddObject(), BaseSpecies::copyInto(), DEBUG, gapSize_, BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), BaseObject::getId(), SpeciesHandler::getMixedObject(), BaseInteractable::getSpecies(), INFO, logger, BaseInteractable::move(), NO_FLUSH, normal_, BaseObject::setId(), BaseObject::setIndex(), BaseParticle::setSpecies(), speciesConversionMaserToNormal_, speciesConversionNormalToMaser_, DPMBase::speciesHandler, and VERBOSE.
Referenced by activateMaser().
bool ConstantMassFlowMaserBoundary::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 a given particle (a) is in the Maser and (b) has crossed the closest wall. If so, shifts its position so as to have it appear at the other wall, and creates a 'real' equivalent in the outflow domain.
[in] | p | The particle to be checked and possibly shifted and copied |
pH | The ParticleHandler, which is unused in this implementation |
References ParticleHandler::addObject(), BaseParticle::copy(), distanceRight_, Vec3D::dot(), gapSize_, getDistance(), BaseObject::getIndex(), BaseInteractable::getPosition(), BaseInteractable::getSpecies(), isClosestToRightBoundary(), isCopying(), isMaserParticle(), isNormalParticle(), BaseInteractable::move(), normal_, ParticleHandler::removeObject(), BaseParticle::setSpecies(), shiftPosition(), and speciesConversionMaserToNormal_.
Referenced by checkBoundaryAfterParticlesMove().
|
overridevirtual |
Evaluates what the particles have to do after they have changed position.
Reimplemented from BaseBoundary.
References BaseHandler< T >::begin(), checkBoundaryAfterParticleMoved(), and BaseHandler< T >::end().
void ConstantMassFlowMaserBoundary::closeMaser | ( | ) |
Stops copying particles (and act merely as a chute)
closing the maser: do exactly the opposite of activating the maser: close the gap by moving all particles, and assign the "normal" species to all maser particles again.
References distanceLeft_, distanceRight_, gapSize_, getDistance(), BaseBoundary::getHandler(), INFO, logger, maserIsActivated_, removeParticleFromMaser(), turnOffCopying(), and WARN.
|
overridevirtual |
Creates a copy of this maser on the heap.
Copy method, creates a copy of the object on the heap and returns a pointer to it.
Implements BaseBoundary.
References ConstantMassFlowMaserBoundary().
|
private |
Creates a copy of the input particle, that gets removed again in DPMBase::removeDuplicatePeriodicParticles.
Helper function for createPeriodicParticles. It makes a copy of the particle p, and labels the copy as a ghost particle.
[in] | p | Particle that needs to be copied |
References BaseParticle::copy(), BaseInteractable::copyInteractionsForPeriodicParticles(), BaseParticle::getPeriodicFromParticle(), and BaseParticle::setPeriodicFromParticle().
Referenced by createPeriodicParticle().
|
override |
Creates periodic particles 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). Note that this is the same function as in PeriodicBoundary, but with the extra check to make sure that only maser particles are periodic particles
[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 |
References ParticleHandler::addObject(), createGhostCopy(), gapSize_, getDistance(), ParticleHandler::getLargestParticleLocal(), BaseParticle::getMaxInteractionRadius(), isClosestToRightBoundary(), isMaserParticle(), maserIsActivated_, BaseInteractable::move(), normal_, and shiftPosition().
Referenced by createPeriodicParticles().
|
override |
References createPeriodicParticle(), BaseHandler< T >::getObject(), BaseHandler< T >::getSize(), and constants::i.
|
inlineprivate |
Returns the distance of the wall to the particle.
[in] | p | Pointer to the particle of which we want to know the distance to the wall to |
References distanceLeft_, distanceRight_, Vec3D::dot(), BaseInteractable::getPosition(), and normal_.
Referenced by activateMaser(), checkBoundaryAfterParticleMoved(), closeMaser(), and createPeriodicParticle().
Mdouble ConstantMassFlowMaserBoundary::getDistanceLeft | ( | ) | const |
References distanceLeft_.
Mdouble ConstantMassFlowMaserBoundary::getDistanceRight | ( | ) | const |
References distanceRight_.
Mdouble ConstantMassFlowMaserBoundary::getGapSize | ( | ) | const |
|
overridevirtual |
Returns the name of the object.
Returns the name of the object class
Implements BaseObject.
bool ConstantMassFlowMaserBoundary::isActivated | ( | ) | const |
Returns whether the Maser is activated or not.
References maserIsActivated_.
Referenced by isCopying().
|
inlineprivate |
Returns whether the given particle is closer to the right boundary of the periodic part.
[in] | p | Particle for which we would like to know whether it is closest to the right boundary |
References distanceLeft_, distanceRight_, Vec3D::dot(), BaseInteractable::getPosition(), and normal_.
Referenced by checkBoundaryAfterParticleMoved(), createPeriodicParticle(), and shiftPosition().
bool ConstantMassFlowMaserBoundary::isCopying | ( | ) | const |
Returns whether the Maser is copying particles or not.
References isActivated(), logger, maserIsCopying_, and WARN.
Referenced by checkBoundaryAfterParticleMoved().
bool ConstantMassFlowMaserBoundary::isMaserParticle | ( | BaseParticle * | p | ) | const |
Returns true if the particle is a Maser particle, and false otherwise.
One checks if the particle is in the Maser, by checking whether its species is found in the list of maser particle species
References BaseInteractable::getSpecies(), and speciesConversionMaserToNormal_.
Referenced by checkBoundaryAfterParticleMoved(), and createPeriodicParticle().
bool ConstantMassFlowMaserBoundary::isNormalParticle | ( | BaseParticle * | p | ) | const |
Returns true if the particle is a Normal particle, and false otherwise.
One checks if the particle is a normal particle, by checking whether the species changes when we do speciesConversionNormalToMaser_().
References BaseInteractable::getSpecies(), and speciesConversionNormalToMaser_.
Referenced by checkBoundaryAfterParticleMoved().
|
overridevirtual |
reads boundary properties from istream
Reads the boundary properties from an istream
[in,out] | is | the istream from which the boundary must be read |
Implements BaseBoundary.
References DEBUG, distanceLeft_, distanceRight_, gapSize_, BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), BaseHandler< T >::getObject(), constants::i, logger, maserIsActivated_, n, normal_, BaseBoundary::read(), shift_, speciesConversionMaserToNormal_, speciesConversionNormalToMaser_, and DPMBase::speciesHandler.
void ConstantMassFlowMaserBoundary::removeParticleFromMaser | ( | BaseParticle * | p | ) |
Convert a maser particle into a 'normal' particle.
References gapSize_, BaseInteractable::getSpecies(), BaseInteractable::move(), normal_, BaseParticle::setSpecies(), and speciesConversionMaserToNormal_.
Referenced by closeMaser().
void ConstantMassFlowMaserBoundary::set | ( | Vec3D | normal, |
Mdouble | distanceLeft, | ||
Mdouble | distanceRight | ||
) |
Sets the Maser's normal and positions, and sets the planewise shift to zero. This deactivates the Maser.
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 |
References distanceLeft_, distanceRight_, Vec3D::dot(), maserIsActivated_, normal_, and shift_.
void ConstantMassFlowMaserBoundary::set | ( | Vec3D | normal, |
Vec3D | planewiseShift, | ||
Mdouble | distanceLeft, | ||
Mdouble | distanceRight | ||
) |
Sets all boundary properties at once and adds particles of the handler to the maser. This deactivates the Maser.
References setPlanewiseShift().
Referenced by ConstantMassFlowMaserBoundaryMixedSpeciesSelfTest::setupInitialConditions(), and ConstantMassFlowMaserSelfTest::setupInitialConditions().
void ConstantMassFlowMaserBoundary::setPlanewiseShift | ( | Vec3D | planewiseShift | ) |
Sets a planewise direction to the shift. Doesn't change the normal or the positions.
Sets the shift_ vector through setting the planewise shift. We delete the component of planewiseShift that is parallel to normal_. Allows Lees–Edwards type Masers.
References distanceLeft_, distanceRight_, Vec3D::dot(), normal_, and shift_.
Referenced by set().
void ConstantMassFlowMaserBoundary::setShift | ( | Vec3D | shift | ) |
|
private |
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. |
References isClosestToRightBoundary(), BaseInteractable::move(), and shift_.
Referenced by checkBoundaryAfterParticleMoved(), and createPeriodicParticle().
void ConstantMassFlowMaserBoundary::turnOffCopying | ( | ) |
void ConstantMassFlowMaserBoundary::turnOnCopying | ( | ) |
|
overridevirtual |
writes boundary properties to ostream
Writes boundary's properties to an ostream
[in] | os | the ostream to which the boundary must be written |
Implements BaseBoundary.
References distanceLeft_, distanceRight_, gapSize_, maserIsActivated_, normal_, shift_, speciesConversionMaserToNormal_, speciesConversionNormalToMaser_, and BaseBoundary::write().
|
private |
position of left boundary wall, s.t. normal*x=position_left
Referenced by activateMaser(), closeMaser(), ConstantMassFlowMaserBoundary(), getDistance(), getDistanceLeft(), isClosestToRightBoundary(), read(), set(), setPlanewiseShift(), and write().
|
private |
position of right boundary wall, s.t. normal*x=position_right
Referenced by activateMaser(), checkBoundaryAfterParticleMoved(), closeMaser(), ConstantMassFlowMaserBoundary(), getDistance(), getDistanceRight(), isClosestToRightBoundary(), read(), set(), setPlanewiseShift(), and write().
|
private |
distance between the right side of the periodic domain and the start of the outflow domain.
I.e., each particle in the maser is moved -distanceToOutflowDomain_ * normal when it becomes part of the maser, and moved distanceToOutflowDomain_ * normal when it is inserted in the outflow domain. Generally this is 6 times the radius of the largest particle, so that the ghost particles do not touch each other: the centre of the ghostparticle is at most 1 diameter (2 radii) away from the boundary, so a ghost particle can extend at most 3 particle radii away from the domain. Do this on both sides, and it follows that the gap should be at least 6 diameters wide.
Referenced by activateMaser(), addParticleToMaser(), checkBoundaryAfterParticleMoved(), closeMaser(), ConstantMassFlowMaserBoundary(), createPeriodicParticle(), getGapSize(), read(), removeParticleFromMaser(), and write().
|
private |
Flag whether or not the gap is created and particles transformed already.
Referenced by activateMaser(), closeMaser(), ConstantMassFlowMaserBoundary(), createPeriodicParticle(), isActivated(), read(), set(), and write().
|
private |
Flag whether or not the Maser is copying particles.
Referenced by isCopying(), turnOffCopying(), and turnOnCopying().
|
private |
Normal unit vector of both maser walls. Points in the flowing direction.
Referenced by addParticleToMaser(), checkBoundaryAfterParticleMoved(), ConstantMassFlowMaserBoundary(), createPeriodicParticle(), getDistance(), isClosestToRightBoundary(), read(), removeParticleFromMaser(), set(), setPlanewiseShift(), and write().
|
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.
By default this is equal to normal_ * (distanceRight_ - distanceLeft_) but you can also set a planewise direction to the shift.
Referenced by ConstantMassFlowMaserBoundary(), read(), set(), setPlanewiseShift(), setShift(), shiftPosition(), and write().
|
private |
List of 'maser' particles' species, and their normal counterparts.
Referenced by addParticleToMaser(), checkBoundaryAfterParticleMoved(), isMaserParticle(), read(), removeParticleFromMaser(), and write().
|
private |
List of 'normal' particles' species, and their maser counterparts.
Referenced by addParticleToMaser(), isNormalParticle(), read(), and write().