MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConstantMassFlowMaserBoundary Class Reference

Variation on the PeriodicBoundary which also has an outflow part. More...

#include <ConstantMassFlowMaserBoundary.h>

+ Inheritance diagram for ConstantMassFlowMaserBoundary:

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...
 
ConstantMassFlowMaserBoundarycopy () 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...
 
BoundaryHandlergetHandler () 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...
 
BaseParticlecreateGhostCopy (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...
 

Detailed Description

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.

Todo:

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.

Todo:
Which Maser is it used in Denissen2019? To cite the Maser: I. F. C. Denissen, T. Weinhart, A. Te Voortwis, S. Luding, J. M. N. T. Gray and A. R. Thornton, Bulbous head formation in bidisperse shallow granular flow over an inclined plane. Journal of Fluid Mechanics, 866:263–297, mar 2019.

Definition at line 92 of file ConstantMassFlowMaserBoundary.h.

Constructor & Destructor Documentation

ConstantMassFlowMaserBoundary::ConstantMassFlowMaserBoundary ( )

MaserBoundary constructor.

MaserBoundary constructor, sets all scalars to non-sensible values.

Definition at line 34 of file ConstantMassFlowMaserBoundary.cc.

References distanceLeft_, distanceRight_, gapSize_, logger, maserIsActivated_, and WARN.

Referenced by copy().

35 {
36 #ifdef MERCURY_USE_MPI
37  logger(WARN,"Make sure the whole maser boundary is on one processor when using parallel code");
38 #endif
39  distanceLeft_ = std::numeric_limits<double>::quiet_NaN();
40  distanceRight_ = std::numeric_limits<double>::quiet_NaN();
41  gapSize_ = std::numeric_limits<double>::quiet_NaN();
42  maserIsActivated_ = false;
43 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
bool maserIsActivated_
Flag whether or not the gap is created and particles transformed already.
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Mdouble gapSize_
distance between the right side of the periodic domain and the start of the outflow domain...
ConstantMassFlowMaserBoundary::ConstantMassFlowMaserBoundary ( const PeriodicBoundary periodicBoundary)
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.

Parameters
[in]periodicBoundaryThe periodic boundary on which this maser boundary is based.

Definition at line 50 of file ConstantMassFlowMaserBoundary.cc.

References activateMaser(), distanceLeft_, distanceRight_, gapSize_, PeriodicBoundary::getDistanceLeft(), PeriodicBoundary::getDistanceRight(), PeriodicBoundary::getNormal(), PeriodicBoundary::getShift(), INFO, logger, maserIsActivated_, NO_FLUSH, normal_, and shift_.

50  : BaseBoundary(
51  periodicBoundary)
52 {
53  logger(INFO, "Constructor ConstantMassFlowMaserBoundary(const PeriodicBoundary&) started\n", Flusher::NO_FLUSH);
54  distanceLeft_ = periodicBoundary.getDistanceLeft();
55  distanceRight_ = periodicBoundary.getDistanceRight();
56  normal_ = periodicBoundary.getNormal();
57  shift_ = periodicBoundary.getShift();
58  gapSize_ = std::numeric_limits<double>::quiet_NaN();
59  maserIsActivated_ = false;
60 
61  logger(INFO, "going to activate the maser");
62  //assume that the maser should be activated immediately when it gets constructed from a periodic boundary
63  activateMaser();
64 }
Mdouble getDistanceLeft() const
Returns the distance of the left wall to the origin, in normal direction.
void activateMaser()
Opens the gap, and transforms particles to maser particles. Also calls turnOnCopying().
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
Mdouble getDistanceRight() const
Returns the distance of the right wall to the origin, in normal direction.
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
Vec3D getNormal() const
returns the vector normal to the periodic boundary
Vec3D getShift() const
Returns the vector going from the left to the right side of the periodic boundary.
Vec3D shift_
Direction in which particles are to be shifted when they cross the boundary.
bool maserIsActivated_
Flag whether or not the gap is created and particles transformed already.
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
Mdouble gapSize_
distance between the right side of the periodic domain and the start of the outflow domain...
BaseBoundary()
default constructor.
Definition: BaseBoundary.cc:32

Member Function Documentation

void ConstantMassFlowMaserBoundary::actionsBeforeTimeLoop ( )
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.

Definition at line 412 of file ConstantMassFlowMaserBoundary.cc.

References activateMaser().

413 {
414  activateMaser();
415 }
void activateMaser()
Opens the gap, and transforms particles to maser particles. Also calls turnOnCopying().
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.

Todo:
JMFT: Would it be helpful to be able to set a custom gapSize ?

Definition at line 425 of file ConstantMassFlowMaserBoundary.cc.

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

426 {
427  if (!maserIsActivated_)
428  {
429  logger(INFO, "Going to add particles to the maser and shift the periodic maser boundaries\n",
433  logger(INFO, "just before particle loop");
434  for (BaseParticle* const p: pH)
435  {
436  if (getDistance(p) > 0)
437  {
439  }
440  }
441 
442 
445  maserIsActivated_ = true;
446 
447  turnOnCopying();
448 
449  logger(INFO, "The Maser has been activated, and is now copying particles.");
450  }
451  else
452  {
453  logger(WARN, "Cannot activate the maser boundary twice!");
454  }
455 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
void addParticleToMaser(BaseParticle *p)
Converts a 'normal' particle into a maser particle.
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1395
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:348
void turnOnCopying()
Start copying particles.
Container to store all BaseParticle.
bool maserIsActivated_
Flag whether or not the gap is created and particles transformed already.
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Mdouble gapSize_
distance between the right side of the periodic domain and the start of the outflow domain...
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
Mdouble getDistance(BaseParticle *p) const
Returns the distance of the wall to the particle.
BaseParticle * getLargestParticleLocal() const
Gets a pointer to the largest BaseParticle (by interactionRadius) in the ParticleHandler of the local...
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.

Parameters
[in,out]pThe particle which is added to the maser. Its species is 'changed' to the maser copy species.

Definition at line 328 of file ConstantMassFlowMaserBoundary.cc.

References BaseHandler< T >::copyAndAddObject(), BaseSpecies::copyInto(), DEBUG, gapSize_, BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), BaseObject::getId(), BaseInteractable::getSpecies(), INFO, logger, BaseInteractable::move(), NO_FLUSH, normal_, BaseObject::setId(), BaseObject::setIndex(), BaseParticle::setSpecies(), speciesConversionMaserToNormal_, speciesConversionNormalToMaser_, DPMBase::speciesHandler, and VERBOSE.

Referenced by activateMaser().

329 {
330  // check if particle species already known by the maser
331  auto conversion = speciesConversionNormalToMaser_.find(p->getSpecies());
332  if (conversion != speciesConversionNormalToMaser_.end())
333  {
334  //species known and flagged (i.e. 'converted')
335  logger(VERBOSE, "[ConstantMassFlowMaserBoundary::addParticleToMaser()] Species conversion already present");
336  p->setSpecies(conversion->second);
337  }
338  else
339  {
340  SpeciesHandler& speciesHandler = (getHandler()->getDPMBase()->speciesHandler);
341  // species is not yet known by the maser, it has to be added to both maps
342  ParticleSpecies* newSpecies = speciesHandler.copyAndAddObject(*(p->getSpecies()));
344  std::pair<const ParticleSpecies*, const ParticleSpecies*>(p->getSpecies(), newSpecies));
346  std::pair<const ParticleSpecies*, const ParticleSpecies*>(newSpecies, p->getSpecies()));
347  logger(INFO, "[ConstantMassFlowMaserBoundary::addParticleToMaser()] New species conversion created\n",
349  logger(INFO, "Original species ID: %, new species ID: %", p->getSpecies()->getId(), newSpecies->getId());
350 
351  //Copy over the mixed species. The delete is necessary here since it is overwritten with a copy of the old mixed
352  //species, and otherwise the properties are not copied over correctly.
353  //
354  //setId and setIndex refer to the two different species which are present in this mixed species.
355  //The highest species-index should appear first andis therefore the ID, while the second species-index is the
356  //"index" of the mixed species.
357  for (const BaseSpecies* const s: speciesHandler)
358  {
359  if (s->getId() != newSpecies->getId() && s->getId() != p->getSpecies()->getId())
360  {
361  BaseSpecies* newMixed = speciesHandler.getMixedObject(s->getId(), newSpecies->getId());
362  const BaseSpecies* const oldMixed = speciesHandler.getMixedObject(s->getId(), p->getSpecies()->getId());
363  oldMixed->copyInto(newMixed);
364  newMixed->setId(newSpecies->getId());
365  newMixed->setIndex(s->getId());
366  logger(DEBUG, "mixed species of % and % is now \n %, should be \n %", s->getId(), newSpecies->getId(),
367  *newMixed, *oldMixed);
368  }
369  }
370 
371  // now the species IS added, so flag (convert) it!
372  p->setSpecies(newSpecies);
373  }
374  p->move(-normal_ * gapSize_);
375 }
Container to store all ParticleSpecies.
void setIndex(unsigned int index)
Allows one to assign an index to an object in the handler/container.
Definition: BaseObject.cc:64
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:125
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:49
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
virtual void copyInto(BaseSpecies *s) const =0
void setSpecies(const ParticleSpecies *species)
std::enable_if<!std::is_pointer< U >::value, U * >::type copyAndAddObject(const U &object)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:379
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionMaserToNormal_
List of 'maser' particles' species, and their normal counterparts.
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1385
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionNormalToMaser_
List of 'normal' particles' species, and their maser counterparts.
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
Mdouble gapSize_
distance between the right side of the periodic domain and the start of the outflow domain...
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
void setId(unsigned long id)
Assigns a unique identifier to each object in the handler (container) which remains constant even aft...
Definition: BaseObject.cc:72
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.

Parameters
[in]pThe particle to be checked and possibly shifted and copied
pHThe ParticleHandler, which is unused in this implementation
Returns
Returns true if particle p has interacted with the boundary, false otherwise

Definition at line 274 of file ConstantMassFlowMaserBoundary.cc.

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

275 {
276  // check if particle passed either of the boundary walls
277  if (isMaserParticle(p) && getDistance(p) < 0)
278  {
279  // Checks if the particle is closest to the right boundary.
280  // If so, and if the Maser is turned on, then create a 'real'
281  // equivalent and move it over to the outflow domain
283  {
284  BaseParticle* pCopy = p->copy();
285  pCopy->setSpecies(speciesConversionMaserToNormal_.find(p->getSpecies())->second);
286  pCopy->move(gapSize_ * normal_);
287  pH.addObject(pCopy);
288  }
289 
290  // If the (original) particle has crossed a boundary wall (be it left or right),
291  // then shift that particle periodically.
292  shiftPosition(p);
293  }
294  else //remove normal particles trying to enter the gap between the maser and the outflow domain
295  {
296  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
297  if (distance < gapSize_ + distanceRight_ && isNormalParticle(p))
298  {
299  pH.removeObject(p->getIndex());
300  return true;
301  }
302  }
303  return false;
304 }
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
void removeObject(unsigned int index) override
Removes a BaseParticle from the ParticleHandler.
void addObject(BaseParticle *P) override
Adds a BaseParticle to the ParticleHandler.
double Mdouble
Definition: GeneralDefine.h:34
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
void setSpecies(const ParticleSpecies *species)
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
virtual BaseParticle * copy() const =0
Particle copy method. It calls to copy constructor of this Particle, useful for polymorphism.
bool isMaserParticle(BaseParticle *p) const
Returns true if the particle is a Maser particle, and false otherwise.
bool isNormalParticle(BaseParticle *p) const
Returns true if the particle is a Normal particle, and false otherwise.
bool isClosestToRightBoundary(const BaseParticle *const p) const
Returns whether the given particle is closer to the right boundary of the periodic part...
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionMaserToNormal_
List of 'maser' particles' species, and their normal counterparts.
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
void shiftPosition(BaseParticle *p) const
Shifts the particle to its 'periodic' position.
Mdouble gapSize_
distance between the right side of the periodic domain and the start of the outflow domain...
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
Mdouble getDistance(BaseParticle *p) const
Returns the distance of the wall to the particle.
bool isCopying() const
Returns whether the Maser is copying particles or not.
void ConstantMassFlowMaserBoundary::checkBoundaryAfterParticlesMove ( ParticleHandler pH)
overridevirtual

Evaluates what the particles have to do after they have changed position.

Reimplemented from BaseBoundary.

Definition at line 306 of file ConstantMassFlowMaserBoundary.cc.

References BaseHandler< T >::begin(), checkBoundaryAfterParticleMoved(), and BaseHandler< T >::end().

307 {
308  for (auto p = pH.begin(); p != pH.end(); ++p)
309  {
310  //If the particle has interacted with the boundary, change the iterator
312  {
313  p--;
314  }
315  }
316 }
bool checkBoundaryAfterParticleMoved(BaseParticle *p, ParticleHandler &pH)
Shifts the particle to its 'periodic' position if it is a maser particle and has crossed either of th...
const std::vector< T * >::const_iterator end() const
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
Definition: BaseHandler.h:704
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:690
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.

Definition at line 459 of file ConstantMassFlowMaserBoundary.cc.

References distanceLeft_, distanceRight_, gapSize_, getDistance(), BaseBoundary::getHandler(), INFO, logger, maserIsActivated_, removeParticleFromMaser(), turnOffCopying(), and WARN.

460 {
461  if (maserIsActivated_)
462  {
463  for (BaseParticle* const p : getHandler()->getDPMBase()->particleHandler)
464  {
465  if (getDistance(p) > 0)
466  {
468  }
469  }
472  maserIsActivated_ = false;
473 
474  turnOffCopying();
475 
476  logger(INFO, "The Maser has been deactivated.");
477  }
478  else
479  {
480  logger(WARN, "Cannot close the maser if it is not active");
481  }
482 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
void removeParticleFromMaser(BaseParticle *p)
Convert a maser particle into a 'normal' particle.
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
void turnOffCopying()
Stop copying particles.
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
bool maserIsActivated_
Flag whether or not the gap is created and particles transformed already.
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Mdouble gapSize_
distance between the right side of the periodic domain and the start of the outflow domain...
Mdouble getDistance(BaseParticle *p) const
Returns the distance of the wall to the particle.
ConstantMassFlowMaserBoundary * ConstantMassFlowMaserBoundary::copy ( ) const
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.

Returns
pointer to the copy

Implements BaseBoundary.

Definition at line 71 of file ConstantMassFlowMaserBoundary.cc.

References ConstantMassFlowMaserBoundary().

72 {
73  return new ConstantMassFlowMaserBoundary(*this);
74 }
ConstantMassFlowMaserBoundary()
MaserBoundary constructor.
BaseParticle * ConstantMassFlowMaserBoundary::createGhostCopy ( BaseParticle p) const
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.

Parameters
[in]pParticle that needs to be copied
Returns
Copy of particle p, labeled as a ghost particle

Definition at line 249 of file ConstantMassFlowMaserBoundary.cc.

References BaseParticle::copy(), BaseInteractable::copyInteractionsForPeriodicParticles(), BaseParticle::getPeriodicFromParticle(), and BaseParticle::setPeriodicFromParticle().

Referenced by createPeriodicParticle().

250 {
251  // Copy the particle and its interactions
252  BaseParticle* pGhost = p->copy();
254 
255  //Set the 'last' particle. If Particle is multiply shifted, get correct original particle
256  BaseParticle* last = p;
257  while (last->getPeriodicFromParticle() != nullptr)
258  {
259  last = last->getPeriodicFromParticle();
260  }
261  pGhost->setPeriodicFromParticle(last);
262  return pGhost;
263 }
void setPeriodicFromParticle(BaseParticle *p)
Assigns the pointer to the 'original' particle this one's a periodic copy of (used in periodic bounda...
Definition: BaseParticle.h:441
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Definition: BaseParticle.h:341
virtual BaseParticle * copy() const =0
Particle copy method. It calls to copy constructor of this Particle, useful for polymorphism.
void copyInteractionsForPeriodicParticles(const BaseInteractable &p)
Copies interactions to this BaseInteractable whenever a periodic copy made.
void ConstantMassFlowMaserBoundary::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.

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

Parameters
[in]pParticle to be checked and possibly periodically copied
[in,out]pHSystem'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 204 of file ConstantMassFlowMaserBoundary.cc.

References ParticleHandler::addObject(), createGhostCopy(), gapSize_, getDistance(), ParticleHandler::getLargestParticleLocal(), BaseParticle::getMaxInteractionRadius(), isClosestToRightBoundary(), isMaserParticle(), maserIsActivated_, BaseInteractable::move(), normal_, and shiftPosition().

Referenced by createPeriodicParticles().

205 {
206  if (isMaserParticle(p))
207  {
208  // check if particle is near the boundaries of the maser domain
210  {
211  BaseParticle* pGhost = createGhostCopy(p);
212 
213  // shift to the periodic location
214  shiftPosition(pGhost);
215 
216  // add the periodic particle to the handler
217  pH.addObject(pGhost);
218 
219  //furthermore, if the particle is on the right it has to be copied over to the outflow domain
221  {
222  // Copy the particle and its interactions if it is a maser particle
223  BaseParticle* pGhostOut = createGhostCopy(p);
224 
225  // shift to the outflow location
226  pGhostOut->move(gapSize_ * normal_);
227  // add the periodic particle to the handler
228  pH.addObject(pGhostOut);
229  }
230  }
231  }
232 }
void addObject(BaseParticle *P) override
Adds a BaseParticle to the ParticleHandler.
Mdouble getMaxInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
Definition: BaseParticle.h:362
BaseParticle * createGhostCopy(BaseParticle *p) const
Creates a copy of the input particle, that gets removed again in DPMBase::removeDuplicatePeriodicPart...
bool isMaserParticle(BaseParticle *p) const
Returns true if the particle is a Maser particle, and false otherwise.
bool isClosestToRightBoundary(const BaseParticle *const p) const
Returns whether the given particle is closer to the right boundary of the periodic part...
bool maserIsActivated_
Flag whether or not the gap is created and particles transformed already.
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
void shiftPosition(BaseParticle *p) const
Shifts the particle to its 'periodic' position.
Mdouble gapSize_
distance between the right side of the periodic domain and the start of the outflow domain...
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
Mdouble getDistance(BaseParticle *p) const
Returns the distance of the wall to the particle.
BaseParticle * getLargestParticleLocal() const
Gets a pointer to the largest BaseParticle (by interactionRadius) in the ParticleHandler of the local...
void ConstantMassFlowMaserBoundary::createPeriodicParticles ( ParticleHandler pH)
override

Definition at line 234 of file ConstantMassFlowMaserBoundary.cc.

References createPeriodicParticle(), BaseHandler< T >::getObject(), BaseHandler< T >::getSize(), and constants::i.

235 {
236  unsigned numberOfParticles = pH.getSize();
237  for (unsigned i = 0; i < numberOfParticles; i++)
238  {
240  }
241 }
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
void createPeriodicParticle(BaseParticle *p, ParticleHandler &pH) override
Creates periodic particles when the particle is a maser particle and is sufficiently close to one of ...
Mdouble ConstantMassFlowMaserBoundary::getDistance ( BaseParticle p) const
inlineprivate

Returns the distance of the wall to the particle.

Parameters
[in]pPointer to the particle of which we want to know the distance to the wall to
Returns
Distance of the particle to the boundary: positive means the particle is inside the periodic part of the boundary, negative means it's outside.

Definition at line 251 of file ConstantMassFlowMaserBoundary.h.

References distanceLeft_, distanceRight_, Vec3D::dot(), BaseInteractable::getPosition(), and normal_.

Referenced by activateMaser(), checkBoundaryAfterParticleMoved(), closeMaser(), and createPeriodicParticle().

252  {
253  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
254  return std::min(distance - distanceLeft_, distanceRight_ - distance);
255  }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
double Mdouble
Definition: GeneralDefine.h:34
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
Mdouble ConstantMassFlowMaserBoundary::getDistanceLeft ( ) const

Definition at line 508 of file ConstantMassFlowMaserBoundary.cc.

References distanceLeft_.

509 {
510  return distanceLeft_;
511 }
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
Mdouble ConstantMassFlowMaserBoundary::getDistanceRight ( ) const

Definition at line 513 of file ConstantMassFlowMaserBoundary.cc.

References distanceRight_.

514 {
515  return distanceRight_;
516 }
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Mdouble ConstantMassFlowMaserBoundary::getGapSize ( ) const

Definition at line 518 of file ConstantMassFlowMaserBoundary.cc.

References gapSize_.

519 {
520  return gapSize_;
521 }
Mdouble gapSize_
distance between the right side of the periodic domain and the start of the outflow domain...
std::string ConstantMassFlowMaserBoundary::getName ( ) const
overridevirtual

Returns the name of the object.

Returns the name of the object class

Returns
the object's class' name, i.e. 'MaserBoundary'

Implements BaseObject.

Definition at line 170 of file ConstantMassFlowMaserBoundary.cc.

171 {
172  return "ConstantMassFlowMaserBoundary";
173 }
bool ConstantMassFlowMaserBoundary::isActivated ( ) const

Returns whether the Maser is activated or not.

Definition at line 484 of file ConstantMassFlowMaserBoundary.cc.

References maserIsActivated_.

Referenced by isCopying().

485 {
486  return maserIsActivated_;
487 }
bool maserIsActivated_
Flag whether or not the gap is created and particles transformed already.
bool ConstantMassFlowMaserBoundary::isClosestToRightBoundary ( const BaseParticle *const  p) const
inlineprivate

Returns whether the given particle is closer to the right boundary of the periodic part.

Parameters
[in]pParticle for which we would like to know whether it is closest to the right boundary
Returns
True if p is closer to the right boundary, false otherwise

Definition at line 239 of file ConstantMassFlowMaserBoundary.h.

References distanceLeft_, distanceRight_, Vec3D::dot(), BaseInteractable::getPosition(), and normal_.

Referenced by checkBoundaryAfterParticleMoved(), createPeriodicParticle(), and shiftPosition().

240  {
241  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
242  return (distanceRight_ - distance < distance - distanceLeft_);
243  }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
double Mdouble
Definition: GeneralDefine.h:34
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
bool ConstantMassFlowMaserBoundary::isCopying ( ) const

Returns whether the Maser is copying particles or not.

Definition at line 500 of file ConstantMassFlowMaserBoundary.cc.

References isActivated(), logger, maserIsCopying_, and WARN.

Referenced by checkBoundaryAfterParticleMoved().

501 {
502  if (!isActivated())
503  logger(WARN, "The Maser is closed, so isCopying() is irrelevant.");
504 
505  return maserIsCopying_;
506 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
bool isActivated() const
Returns whether the Maser is activated or not.
bool maserIsCopying_
Flag whether or not the Maser is copying particles.
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

Definition at line 391 of file ConstantMassFlowMaserBoundary.cc.

References BaseInteractable::getSpecies(), and speciesConversionMaserToNormal_.

Referenced by checkBoundaryAfterParticleMoved(), and createPeriodicParticle().

392 {
393  // Check if the particle is in the Maser, by checking whether its
394  // species is found in the list of maser particle species
395  auto positionMaserSpeciesInMap = speciesConversionMaserToNormal_.find(p->getSpecies());
396  return (positionMaserSpeciesInMap != speciesConversionMaserToNormal_.end()); //Test if it is a maser particle
397 }
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionMaserToNormal_
List of 'maser' particles' species, and their normal counterparts.
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_().

Definition at line 403 of file ConstantMassFlowMaserBoundary.cc.

References BaseInteractable::getSpecies(), and speciesConversionNormalToMaser_.

Referenced by checkBoundaryAfterParticleMoved().

404 {
405  auto toFindOutflowSpecies = speciesConversionNormalToMaser_.find(p->getSpecies());
406  return (toFindOutflowSpecies != speciesConversionNormalToMaser_.end());
407 }
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionNormalToMaser_
List of 'normal' particles' species, and their maser counterparts.
void ConstantMassFlowMaserBoundary::read ( std::istream &  is)
overridevirtual

reads boundary properties from istream

Reads the boundary properties from an istream

Parameters
[in,out]isthe istream from which the boundary must be read

Implements BaseBoundary.

Definition at line 120 of file ConstantMassFlowMaserBoundary.cc.

References DEBUG, distanceLeft_, distanceRight_, gapSize_, BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), BaseHandler< T >::getObject(), constants::i, logger, maserIsActivated_, normal_, BaseBoundary::read(), shift_, speciesConversionMaserToNormal_, speciesConversionNormalToMaser_, and DPMBase::speciesHandler.

121 {
122  BaseBoundary::read(is);
123  std::string dummy;
124  is >> dummy >> normal_
125  >> dummy >> distanceLeft_
126  >> dummy >> distanceRight_
127  >> dummy >> shift_
128  >> dummy >> gapSize_
129  >> dummy >> maserIsActivated_;
130  unsigned int n;
131  is >> dummy >> n;
132  const SpeciesHandler& speciesHandler = getHandler()->getDPMBase()->speciesHandler;
133  for (unsigned int i = 0; i < n; ++i)
134  {
135  unsigned int key;
136  unsigned int value;
137  is >> dummy >> key >> dummy >> value;
138  speciesConversionNormalToMaser_[speciesHandler.getObject(key)] = speciesHandler.getObject(value);
139  speciesConversionMaserToNormal_[speciesHandler.getObject(value)] = speciesHandler.getObject(key);
140  }
141  logger(DEBUG, "Finished reading ConstantMassFlowMaserBoundary. \nNormal: % \nDistanceLeft: % \nDistanceRight: % "
142  "\nGapsize: % \nMaserIsActivated: %",
143  normal_, distanceLeft_, distanceRight_, gapSize_, maserIsActivated_);
144 }
Container to store all ParticleSpecies.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
void read(std::istream &is) override=0
Reads the object's id_ from given istream NB: purely virtual function, overriding the version of Base...
Definition: BaseBoundary.cc:61
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
Vec3D shift_
Direction in which particles are to be shifted when they cross the boundary.
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionMaserToNormal_
List of 'maser' particles' species, and their normal counterparts.
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1385
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionNormalToMaser_
List of 'normal' particles' species, and their maser counterparts.
bool maserIsActivated_
Flag whether or not the gap is created and particles transformed already.
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
Mdouble gapSize_
distance between the right side of the periodic domain and the start of the outflow domain...
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
void ConstantMassFlowMaserBoundary::removeParticleFromMaser ( BaseParticle p)

Convert a maser particle into a 'normal' particle.

Definition at line 377 of file ConstantMassFlowMaserBoundary.cc.

References gapSize_, BaseInteractable::getSpecies(), BaseInteractable::move(), normal_, BaseParticle::setSpecies(), and speciesConversionMaserToNormal_.

Referenced by closeMaser().

378 {
379  auto conversion = speciesConversionMaserToNormal_.find(p->getSpecies());
380  if (conversion != speciesConversionMaserToNormal_.end())
381  {
382  p->setSpecies(conversion->second);
383  p->move(normal_ * gapSize_);
384  }
385 }
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
void setSpecies(const ParticleSpecies *species)
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionMaserToNormal_
List of 'maser' particles' species, and their normal counterparts.
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
Mdouble gapSize_
distance between the right side of the periodic domain and the start of the outflow domain...
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
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.

Definition at line 76 of file ConstantMassFlowMaserBoundary.cc.

References setPlanewiseShift().

77 {
78  set(normal, distanceLeft, distanceRight);
79  setPlanewiseShift(planewiseShift);
80 }
void setPlanewiseShift(Vec3D planewiseShift)
Sets a planewise direction to the shift. Doesn't change the normal or the positions.
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.
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.

Parameters
[in]normalNormal unit vector of the (parallel) boundary walls
[in]distanceLeftThe distance of the left wall to the origin
[in]distanceRightThe distance of the right wall to the origin

Definition at line 89 of file ConstantMassFlowMaserBoundary.cc.

References distanceLeft_, distanceRight_, Vec3D::dot(), maserIsActivated_, normal_, and shift_.

90 {
91  // factor is used to set normal to unit length
92  Mdouble scaleFactor_ = 1. / std::sqrt(Vec3D::dot(normal, normal));
93  normal_ = normal * scaleFactor_;
94  distanceLeft_ = distanceLeft * scaleFactor_;
95  distanceRight_ = distanceRight * scaleFactor_;
97  maserIsActivated_ = false;
98 }
double Mdouble
Definition: GeneralDefine.h:34
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Vec3D shift_
Direction in which particles are to be shifted when they cross the boundary.
bool maserIsActivated_
Flag whether or not the gap is created and particles transformed already.
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
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.

Definition at line 105 of file ConstantMassFlowMaserBoundary.cc.

References distanceLeft_, distanceRight_, Vec3D::dot(), normal_, and shift_.

Referenced by set().

106 {
107  planewiseShift -= Vec3D::dot(planewiseShift, normal_) / Vec3D::dot(normal_, normal_) * normal_;
108  shift_ = normal_ * (distanceRight_ - distanceLeft_) + planewiseShift;
109 }
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Vec3D shift_
Direction in which particles are to be shifted when they cross the boundary.
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
void ConstantMassFlowMaserBoundary::setShift ( Vec3D  shift)

Sets the shift of the Maser. Usually don't use this directly, use set() or setPlanewiseShift() instead.

Definition at line 111 of file ConstantMassFlowMaserBoundary.cc.

References shift_.

112 {
113  shift_ = shift;
114 }
Vec3D shift_
Direction in which particles are to be shifted when they cross the boundary.
void ConstantMassFlowMaserBoundary::shiftPosition ( BaseParticle p) const
private

Shifts the particle to its 'periodic' position.

Shifts the particle (using the closestToLeftBoundary_ value)

Parameters
[in]pA pointer to the particle which will be shifted.

Definition at line 179 of file ConstantMassFlowMaserBoundary.cc.

References isClosestToRightBoundary(), BaseInteractable::move(), and shift_.

Referenced by checkBoundaryAfterParticleMoved(), and createPeriodicParticle().

180 {
182  {
183  p->move(-shift_);
184  }
185  else // if closest to right boundary
186  {
187  p->move(shift_);
188  }
189 }
Vec3D shift_
Direction in which particles are to be shifted when they cross the boundary.
bool isClosestToRightBoundary(const BaseParticle *const p) const
Returns whether the given particle is closer to the right boundary of the periodic part...
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
void ConstantMassFlowMaserBoundary::turnOffCopying ( )

Stop copying particles.

Definition at line 494 of file ConstantMassFlowMaserBoundary.cc.

References maserIsCopying_.

Referenced by closeMaser().

495 {
496  maserIsCopying_ = false;
497 }
bool maserIsCopying_
Flag whether or not the Maser is copying particles.
void ConstantMassFlowMaserBoundary::turnOnCopying ( )

Start copying particles.

Definition at line 489 of file ConstantMassFlowMaserBoundary.cc.

References maserIsCopying_.

Referenced by activateMaser().

490 {
491  maserIsCopying_ = true;
492 }
bool maserIsCopying_
Flag whether or not the Maser is copying particles.
void ConstantMassFlowMaserBoundary::write ( std::ostream &  os) const
overridevirtual

writes boundary properties to ostream

Writes boundary's properties to an ostream

Parameters
[in]osthe ostream to which the boundary must be written

Implements BaseBoundary.

Definition at line 150 of file ConstantMassFlowMaserBoundary.cc.

References distanceLeft_, distanceRight_, gapSize_, maserIsActivated_, normal_, shift_, speciesConversionMaserToNormal_, speciesConversionNormalToMaser_, and BaseBoundary::write().

151 {
153  os << " normal " << normal_
154  << " distanceLeft " << distanceLeft_
155  << " distanceRight " << distanceRight_
156  << " shift " << shift_
157  << " gapSize " << gapSize_
158  << " maserIsActivated " << maserIsActivated_
159  << " numberOfMaserSpecies " << speciesConversionMaserToNormal_.size();
160  for (auto p : speciesConversionNormalToMaser_)
161  {
162  os << " outflowSpeciesIndex " << p.first->getIndex() << " maserSpeciesIndex " << p.second->getIndex();
163  }
164 }
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
Vec3D shift_
Direction in which particles are to be shifted when they cross the boundary.
void write(std::ostream &os) const override=0
Adds object's id_ to given ostream NB: purely virtual function, overriding the version of BaseObject...
Definition: BaseBoundary.cc:70
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionMaserToNormal_
List of 'maser' particles' species, and their normal counterparts.
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionNormalToMaser_
List of 'normal' particles' species, and their maser counterparts.
bool maserIsActivated_
Flag whether or not the gap is created and particles transformed already.
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
Mdouble gapSize_
distance between the right side of the periodic domain and the start of the outflow domain...

Member Data Documentation

Mdouble ConstantMassFlowMaserBoundary::distanceLeft_
private

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

Definition at line 265 of file ConstantMassFlowMaserBoundary.h.

Referenced by activateMaser(), closeMaser(), ConstantMassFlowMaserBoundary(), getDistance(), getDistanceLeft(), isClosestToRightBoundary(), read(), set(), setPlanewiseShift(), and write().

Mdouble ConstantMassFlowMaserBoundary::distanceRight_
private
Mdouble ConstantMassFlowMaserBoundary::gapSize_
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.

Todo:
JMFT: Do you mean 6 radii?

Definition at line 285 of file ConstantMassFlowMaserBoundary.h.

Referenced by activateMaser(), addParticleToMaser(), checkBoundaryAfterParticleMoved(), closeMaser(), ConstantMassFlowMaserBoundary(), createPeriodicParticle(), getGapSize(), read(), removeParticleFromMaser(), and write().

bool ConstantMassFlowMaserBoundary::maserIsActivated_
private

Flag whether or not the gap is created and particles transformed already.

Definition at line 309 of file ConstantMassFlowMaserBoundary.h.

Referenced by activateMaser(), closeMaser(), ConstantMassFlowMaserBoundary(), createPeriodicParticle(), isActivated(), read(), set(), and write().

bool ConstantMassFlowMaserBoundary::maserIsCopying_
private

Flag whether or not the Maser is copying particles.

Definition at line 314 of file ConstantMassFlowMaserBoundary.h.

Referenced by isCopying(), turnOffCopying(), and turnOnCopying().

Vec3D ConstantMassFlowMaserBoundary::normal_
private
Vec3D ConstantMassFlowMaserBoundary::shift_
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.

Definition at line 294 of file ConstantMassFlowMaserBoundary.h.

Referenced by ConstantMassFlowMaserBoundary(), read(), set(), setPlanewiseShift(), setShift(), shiftPosition(), and write().

std::map<const ParticleSpecies*, const ParticleSpecies*> ConstantMassFlowMaserBoundary::speciesConversionMaserToNormal_
private

List of 'maser' particles' species, and their normal counterparts.

Definition at line 304 of file ConstantMassFlowMaserBoundary.h.

Referenced by addParticleToMaser(), checkBoundaryAfterParticleMoved(), isMaserParticle(), read(), removeParticleFromMaser(), and write().

std::map<const ParticleSpecies*, const ParticleSpecies*> ConstantMassFlowMaserBoundary::speciesConversionNormalToMaser_
private

List of 'normal' particles' species, and their maser counterparts.

Definition at line 299 of file ConstantMassFlowMaserBoundary.h.

Referenced by addParticleToMaser(), isNormalParticle(), read(), and write().


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