TimeDependentPeriodicBoundary Class Reference

Class which creates a boundary with Lees-Edwards type periodic boundary conditions. More...

#include <TimeDependentPeriodicBoundary.h>

+ Inheritance diagram for TimeDependentPeriodicBoundary:

Public Member Functions

 TimeDependentPeriodicBoundary ()
 default constructor More...
 
 ~TimeDependentPeriodicBoundary ()
 destructor More...
 
TimeDependentPeriodicBoundarycopy () const override
 copy method More...
 
 TimeDependentPeriodicBoundary (const TimeDependentPeriodicBoundary &other)
 copy constructor More...
 
void set (Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight, std::function< Vec3D(Mdouble)> planewiseShift, std::function< Vec3D(Mdouble)> boost)
 Defines a TimeDependentPeriodicBoundary by its normal and positions, and by the shifting and boosting that it does (projected onto the planewise direction) More...
 
void set (Vec3D normal, Vec3D positionLeft, Vec3D positionRight, std::function< Vec3D(Mdouble)> shift, std::function< Vec3D(Mdouble)> boost)
 As above, but by specifying two positions that the boundaries go through instead of distanceLeft and distanceRight. More...
 
void setPlanewiseShiftAndBoost (std::function< Vec3D(Mdouble)> shift, std::function< Vec3D(Mdouble)> boost)
 Set the planewise shift and boost (projected onto the planewise direction) as functions of time. (Boost should be the derivative of shift) More...
 
void setMaxShift (Mdouble maxShift)
 Set the maximum shift (will take fmod w.r.t. this) More...
 
Vec3D getNormal () const
 returns the vector normal to the periodic boundary More...
 
Mdouble getDistanceLeft () const
 Returns the distance of the left wall to the origin, in normal direction. More...
 
Mdouble getDistanceRight () const
 Returns the distance of the right wall to the origin, in normal direction. More...
 
Vec3D getShift (Mdouble time) const
 Returns the vector going from the left to the right side of the periodic boundary. More...
 
Vec3D getPlanewiseShift (Mdouble time) const
 Returns the planewise shift as a function of time. More...
 
Vec3D getBoost (Mdouble time) const
 Returns the planewise boost as a function of time. More...
 
void moveLeft (Mdouble distanceLeft)
 Sets the distance from the origin of the 'left' periodic wall. More...
 
void moveRight (Mdouble distanceRight)
 Sets the distance from the origin of the 'right' periodic wall. More...
 
Mdouble getDistance (const BaseParticle &p) const override
 Returns the distance of the edge to the particle. More...
 
Mdouble getDistance (const Vec3D &position) const override
 Returns the distance of the edge to the position. More...
 
virtual void shiftPosition (BaseParticle *p) const override
 shifts and boosts the particle More...
 
virtual void shiftAndBoostParticle (BaseParticle *p, Mdouble time) const
 
virtual void shiftPositions (Vec3D &position1, Vec3D &position2) const
 shifts two positions (JMFT: Why, what is this for?) More...
 
virtual bool isClosestToLeftBoundary (const BaseParticle &p) const
 Returns true if particle checked is closer to the 'left' edge, and false if it is closer to the 'right' edge. More...
 
virtual bool isClosestToLeftBoundary (const Vec3D &p) const override
 Returns true if position checked is closer to the 'left' edge, and false if it is closer to the 'right' edge. More...
 
virtual void createPeriodicParticles (ParticleHandler &pH) override
 Checks distance of particle to closer edge and creates a periodic copy if necessary. More...
 
void createGhostParticle (BaseParticle *pReal)
 Creates and adds a ghost particle from a given real particle. More...
 
void createPeriodicParticle (BaseParticle *p, ParticleHandler &pH) override
 Creates a single periodic particle if required from a given particle. More...
 
virtual void checkBoundaryAfterParticlesMove (ParticleHandler &pH) override
 Loops over particles, checks if each particle has crossed either boundary edge, and applies a shift if that is the case. More...
 
virtual void read (std::istream &is) override
 reads boundary properties from istream More...
 
virtual void write (std::ostream &os) const override
 writes boundary properties to ostream More...
 
virtual std::string getName () const override
 Returns the name of the object. More...
 
- Public Member Functions inherited from BasePeriodicBoundary
 BasePeriodicBoundary ()
 default constructor. More...
 
 BasePeriodicBoundary (const BasePeriodicBoundary &b)
 copy constructor More...
 
 ~BasePeriodicBoundary () override
 destructor More...
 
void setPeriodicHandler (PeriodicBoundaryHandler *periodicHandler)
 Sets the periodicBoundaryHandler, required for parallel periodic boundaries. More...
 
PeriodicBoundaryHandlergetPeriodicHandler () const
 Returns the periodic boundary handler. More...
 
void createPeriodicParticles (ParticleHandler &pH) override
 Creates periodic ocpies of given particle in case of periodic boundaries in serial build. More...
 
virtual void modifyPeriodicComplexity (std::vector< int > &complexity, int &totalPeriodicComplexity, BaseParticle *particle, int i) const
 Modifies periodic complexity of a particle if necessary (i.e. maser boundary) More...
 
virtual void performActionsBeforeAddingParticles ()
 Actions that need to be performed before adding new ghost particles. More...
 
- 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 actionsBeforeTimeLoop ()
 Virtual function that does something after DPMBase::setupInitialConditions but before the first 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
 

Protected Attributes

Vec3D normal_
 outward unit normal vector for right edge More...
 
Mdouble distanceLeft_
 position of left edge, s.t. normal*x = distanceLeft_ More...
 
Mdouble distanceRight_
 position of right edge, s.t. normal*x = distanceRight_ More...
 
std::function< Vec3D(Mdouble)> planewiseShift_
 shift from left to right boundary in the planewise direction (Note: total shift = planewiseShift_(time) + normal * (distanceRight_ - distanceLeft_) More...
 
std::function< Vec3D(Mdouble)> boost_
 boost from the left to right boundary More...
 
Mdouble maxShift_
 Maximum shifting (will take fmod(shift, maxshift) ) More...
 

Detailed Description

Class which creates a boundary with Lees-Edwards type periodic boundary conditions.

A TimeDependentPeriodicBoundary is like a PeriodicBoundary, but, when a particle crosses an edge,

  • it is shifted as well as being copied
  • it is given a boost

In general, the shift and the boost may depend on time in an arbitrary way. They are to be specified as std::function<Mdouble (Mdouble)>.

This sort of boundary is useful for studying shear flows.

See also Lees and Edwards (J. Phys. C 1921, doi:1088/0022-3719/5/15/006). Inherits from BaseBoundary.

Todo:

Add link to paper by Lees-Edwards in the documentation of this class.

Is implemented for 2D only now. Needs extension to 3D.

Constructor & Destructor Documentation

◆ TimeDependentPeriodicBoundary() [1/2]

TimeDependentPeriodicBoundary::TimeDependentPeriodicBoundary ( )

default constructor

constructor

39 {
40  distanceLeft_ = std::numeric_limits<double>::quiet_NaN();
41  distanceRight_ = std::numeric_limits<double>::quiet_NaN();
42  maxShift_ = 0;
43 
44 
45 #ifdef MERCURYDPM_USE_MPI
46  MPIContainer& communicator = MPIContainer::Instance();
47  if (communicator.getNumberOfProcessors() > 1)
48  {
49  logger(WARN,"LeesEdwardsBoundaries are currently not implemented in parallel MercuryDPM");
50  }
51 #endif
52  logger(DEBUG, "TimeDependentPeriodicBoundary::TimeDependentPeriodicBoundary() finished");
53 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ WARN
@ DEBUG
BasePeriodicBoundary()
default constructor.
Definition: BasePeriodicBoundary.cc:35
This class contains all information and functions required for communication between processors.
Definition: MpiContainer.h:130
std::size_t getNumberOfProcessors() const
Get the total number of processors participating in this simulation.
Definition: MpiContainer.cc:104
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:134
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Definition: TimeDependentPeriodicBoundary.h:245
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Definition: TimeDependentPeriodicBoundary.h:240
Mdouble maxShift_
Maximum shifting (will take fmod(shift, maxshift) )
Definition: TimeDependentPeriodicBoundary.h:261

References DEBUG, distanceLeft_, distanceRight_, MPIContainer::getNumberOfProcessors(), MPIContainer::Instance(), logger, maxShift_, and WARN.

Referenced by copy().

◆ ~TimeDependentPeriodicBoundary()

TimeDependentPeriodicBoundary::~TimeDependentPeriodicBoundary ( )

destructor

destructor

59 {
60  logger(DEBUG, "TimeDependentPeriodicBoundary::~TimeDependentPeriodicBoundary() finished");
61 }

References DEBUG, and logger.

◆ TimeDependentPeriodicBoundary() [2/2]

TimeDependentPeriodicBoundary::TimeDependentPeriodicBoundary ( const TimeDependentPeriodicBoundary other)

copy constructor

Copy constructor

75 {
76  normal_ = other.normal_;
80  boost_ = other.boost_;
81  maxShift_ = other.maxShift_;
82 
83 }
Vec3D normal_
outward unit normal vector for right edge
Definition: TimeDependentPeriodicBoundary.h:235
std::function< Vec3D(Mdouble)> planewiseShift_
shift from left to right boundary in the planewise direction (Note: total shift = planewiseShift_(tim...
Definition: TimeDependentPeriodicBoundary.h:251
std::function< Vec3D(Mdouble)> boost_
boost from the left to right boundary
Definition: TimeDependentPeriodicBoundary.h:256

References boost_, distanceLeft_, distanceRight_, maxShift_, normal_, and planewiseShift_.

Member Function Documentation

◆ checkBoundaryAfterParticlesMove()

void TimeDependentPeriodicBoundary::checkBoundaryAfterParticlesMove ( ParticleHandler pH)
overridevirtual

Loops over particles, checks if each particle has crossed either boundary edge, and applies a shift if that is the case.

Loops through all particles to see if they have become ghosts. If that is the case their position is shifted. Note: This is only for a serial build - periodic particles work different in paralle

Parameters
[in]

Reimplemented from BasePeriodicBoundary.

321 {
322 #ifdef MERCURYDPM_USE_MPI
323  if (NUMBER_OF_PROCESSORS == 1)
324  {
325 #endif
326  for (auto p = pH.begin(); p != pH.end(); ++p)
327  {
328  if (getDistance((*p)->getPosition()) < 0)
329  {
331  }
332  }
333 #ifdef MERCURYDPM_USE_MPI
334  }
335 #endif
336 }
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:62
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
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
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:808
virtual void shiftAndBoostParticle(BaseParticle *p, Mdouble time) const
Definition: TimeDependentPeriodicBoundary.cc:213
Mdouble getDistance(const BaseParticle &p) const override
Returns the distance of the edge to the particle.
Definition: TimeDependentPeriodicBoundary.cc:188

References BaseHandler< T >::begin(), BaseHandler< T >::end(), getDistance(), BaseHandler< T >::getDPMBase(), DPMBase::getTime(), NUMBER_OF_PROCESSORS, and shiftAndBoostParticle().

◆ copy()

TimeDependentPeriodicBoundary * TimeDependentPeriodicBoundary::copy ( ) const
overridevirtual

copy method

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

Implements BasePeriodicBoundary.

67 {
68  return new TimeDependentPeriodicBoundary(*this);
69 }
TimeDependentPeriodicBoundary()
default constructor
Definition: TimeDependentPeriodicBoundary.cc:37

References TimeDependentPeriodicBoundary().

◆ createGhostParticle()

void TimeDependentPeriodicBoundary::createGhostParticle ( BaseParticle pReal)

Creates and adds a ghost particle from a given real particle.

Todo:
{JMFT: The time comes from p->getHandler()->getDPMBase()->getTime(), which will be undefined if p does not belong to a handler.}
282 {
284 
285  //Step 1: Copy the particle to new ghost particle.
286  BaseParticle* pGhost = pReal->copy();
287 
288  //Step 2: Copy the interactions of the ghost particle.
289  pGhost->copyInteractionsForPeriodicParticles(*pReal);
290 
291  //Step 3: Shift the ghost to the 'reflected' location.
292  shiftAndBoostParticle(pGhost, pH.getDPMBase()->getTime());
293 
294  //Step 4: If Particle is double shifted, get correct original particle
295  BaseParticle* from = pReal;
296  while (from->getPeriodicFromParticle() != nullptr)
297  from = from->getPeriodicFromParticle();
298  pGhost->setPeriodicFromParticle(from);
299 
300  pH.addObject(pGhost);
301 }
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
Definition: BaseBoundary.cc:143
void copyInteractionsForPeriodicParticles(const BaseInteractable &p)
Copies interactions to this BaseInteractable whenever a periodic copy made.
Definition: BaseInteractable.cc:386
Definition: BaseParticle.h:54
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
virtual BaseParticle * copy() const =0
Particle copy method. It calls to copy constructor of this Particle, useful for polymorphism.
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Definition: BaseParticle.h:341
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
Container to store all BaseParticle.
Definition: ParticleHandler.h:48
void addObject(BaseParticle *P) override
Adds a BaseParticle to the ParticleHandler.
Definition: ParticleHandler.cc:171

References ParticleHandler::addObject(), BaseParticle::copy(), BaseInteractable::copyInteractionsForPeriodicParticles(), BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), BaseParticle::getPeriodicFromParticle(), DPMBase::getTime(), DPMBase::particleHandler, BaseParticle::setPeriodicFromParticle(), and shiftAndBoostParticle().

Referenced by createPeriodicParticle().

◆ createPeriodicParticle()

void TimeDependentPeriodicBoundary::createPeriodicParticle ( BaseParticle p,
ParticleHandler pH 
)
override

Creates a single periodic particle if required from a given particle.

304 {
305  //note that getDistance sets closestToLeftBoundary_ to true or false depending on which side is closest
307  {
309  }
310 }
Mdouble getMaxInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e....
Definition: BaseParticle.h:362
BaseParticle * getLargestParticle() const
Returns the pointer of the largest particle in the particle handler. When mercury is running in paral...
Definition: ParticleHandler.cc:534
void createGhostParticle(BaseParticle *pReal)
Creates and adds a ghost particle from a given real particle.
Definition: TimeDependentPeriodicBoundary.cc:281

References createGhostParticle(), getDistance(), ParticleHandler::getLargestParticle(), and BaseParticle::getMaxInteractionRadius().

Referenced by createPeriodicParticles().

◆ createPeriodicParticles()

void TimeDependentPeriodicBoundary::createPeriodicParticles ( ParticleHandler pH)
overridevirtual

Checks distance of particle to closer edge and creates a periodic copy if necessary.

265 {
266 #ifdef MERCURYDPM_USE_MPI
267  if (NUMBER_OF_PROCESSORS == 1)
268  {
269 #endif
270  unsigned numberOfParticles = pH.getSize();
271 
272  for(unsigned i = 0; i < numberOfParticles; i++)
273  {
275  }
276 #ifdef MERCURYDPM_USE_MPI
277  }
278 #endif
279 }
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
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 a single periodic particle if required from a given particle.
Definition: TimeDependentPeriodicBoundary.cc:303
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

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

◆ getBoost()

Vec3D TimeDependentPeriodicBoundary::getBoost ( Mdouble  time) const

Returns the planewise boost as a function of time.

161 {
162  return boost_(time);
163 }

References boost_.

Referenced by shiftAndBoostParticle().

◆ getDistance() [1/2]

Mdouble TimeDependentPeriodicBoundary::getDistance ( const BaseParticle p) const
overridevirtual

Returns the distance of the edge to the particle.

Implements BasePeriodicBoundary.

189 {
190  return getDistance(p.getPosition());
191 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218

References BaseInteractable::getPosition().

Referenced by checkBoundaryAfterParticlesMove(), and createPeriodicParticle().

◆ getDistance() [2/2]

Mdouble TimeDependentPeriodicBoundary::getDistance ( const Vec3D position) const
overridevirtual

Returns the distance of the edge to the position.

Returns the distance to the edge closest to the position

Parameters
[in]positionA reference to the position which distance to the periodic boundary is to be calculated

Implements BasePeriodicBoundary.

199 {
200  Mdouble distanceFromPlaneThroughOrigin = Vec3D::dot(position, normal_);
201  return std::min(distanceFromPlaneThroughOrigin - distanceLeft_,
202  distanceRight_ - distanceFromPlaneThroughOrigin);
203 }
double Mdouble
Definition: GeneralDefine.h:34
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76

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

◆ getDistanceLeft()

Mdouble TimeDependentPeriodicBoundary::getDistanceLeft ( ) const

Returns the distance of the left wall to the origin, in normal direction.

Returns
The distance of the left wall to the origin, in normal direction
127 {
128  return distanceLeft_;
129 }

References distanceLeft_.

◆ getDistanceRight()

Mdouble TimeDependentPeriodicBoundary::getDistanceRight ( ) const

Returns the distance of the right wall to the origin, in normal direction.

Returns
The distance of the left wall to the origin, in normal direction
135 {
136  return distanceRight_;
137 }

References distanceRight_.

◆ getName()

std::string TimeDependentPeriodicBoundary::getName ( ) const
overridevirtual

Returns the name of the object.

Returns the name of the object class

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

Implements BaseObject.

374 {
375  return "TimeDependentPeriodicBoundary";
376 }

◆ getNormal()

Vec3D TimeDependentPeriodicBoundary::getNormal ( ) const

returns the vector normal to the periodic boundary

Returns
The vector perpendicular to the periodic boundary
119 {
120  return normal_;
121 }

References normal_.

◆ getPlanewiseShift()

Vec3D TimeDependentPeriodicBoundary::getPlanewiseShift ( Mdouble  time) const

Returns the planewise shift as a function of time.

145 {
146  if (maxShift_ == 0)
147  return planewiseShift_(time);
148  if (maxShift_ > 0)
149  {
150  Vec3D p = planewiseShift_(time);
151  Mdouble m = p.getLength();
152  Vec3D n = p / m;
153  return fmod(m, maxShift_) * n;
154  }
155  if (maxShift_ < 0)
156  logger(ERROR, "[TimeDependentPeriodicBoundary::getPlanewiseShift] maxShift_ = % is negative", maxShift_);
157  return {0,0,0};
158 }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
@ ERROR
Definition: Vector.h:51
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Definition: Vector.cc:331

References ERROR, Vec3D::getLength(), logger, maxShift_, n, and planewiseShift_.

Referenced by getShift().

◆ getShift()

Vec3D TimeDependentPeriodicBoundary::getShift ( Mdouble  time) const

Returns the vector going from the left to the right side of the periodic boundary.

140 {
142 }
Vec3D getPlanewiseShift(Mdouble time) const
Returns the planewise shift as a function of time.
Definition: TimeDependentPeriodicBoundary.cc:144

References distanceLeft_, distanceRight_, getPlanewiseShift(), and normal_.

Referenced by shiftAndBoostParticle(), and shiftPositions().

◆ isClosestToLeftBoundary() [1/2]

bool TimeDependentPeriodicBoundary::isClosestToLeftBoundary ( const BaseParticle p) const
virtual

Returns true if particle checked is closer to the 'left' edge, and false if it is closer to the 'right' edge.

248 {
250 }
virtual bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns true if particle checked is closer to the 'left' edge, and false if it is closer to the 'righ...
Definition: TimeDependentPeriodicBoundary.cc:247

References BaseInteractable::getPosition().

Referenced by shiftAndBoostParticle(), and shiftPositions().

◆ isClosestToLeftBoundary() [2/2]

bool TimeDependentPeriodicBoundary::isClosestToLeftBoundary ( const Vec3D p) const
overridevirtual

Returns true if position checked is closer to the 'left' edge, and false if it is closer to the 'right' edge.

Implements BasePeriodicBoundary.

259 {
260  const Mdouble distance = Vec3D::dot(p, normal_);
261  return (distanceRight_ - distance > distance - distanceLeft_);
262 }

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

◆ moveLeft()

void TimeDependentPeriodicBoundary::moveLeft ( Mdouble  distanceLeft)

Sets the distance from the origin of the 'left' periodic wall.

Allows the left periodic boundary to be moved to a new position and automatically changes its shift value

Parameters
[in]distanceLeftThe distance (from the origin) to which the left boundary is moved
173 {
174  distanceLeft_ = distanceLeft;
175 }

References distanceLeft_.

◆ moveRight()

void TimeDependentPeriodicBoundary::moveRight ( Mdouble  distanceRight)

Sets the distance from the origin of the 'right' periodic wall.

Allows the right periodic wall to be moved to a new position and automatically changes its shift value

Parameters
[in]distanceRightThe distance (from the origin) to which the right boundary is moved
184 {
185  distanceRight_ = distanceRight;
186 }

References distanceRight_.

◆ read()

void TimeDependentPeriodicBoundary::read ( std::istream &  is)
overridevirtual

reads boundary properties from istream

Reads the boundary properties from an istream

Parameters
[in]isthe istream

Reimplemented from BasePeriodicBoundary.

343 {
345  std::string dummy;
346  is >> dummy >> normal_
347  >> dummy >> distanceLeft_
348  >> dummy >> distanceRight_
349  // >> dummy >> planewiseShift_
350  // >> dummy >> boost_
351  ;
352 }
void read(std::istream &is) override
Reads the object's id_ from given istream.
Definition: BasePeriodicBoundary.cc:71

References distanceLeft_, distanceRight_, normal_, and BasePeriodicBoundary::read().

◆ set() [1/2]

void TimeDependentPeriodicBoundary::set ( Vec3D  normal,
Mdouble  distanceLeft,
Mdouble  distanceRight,
std::function< Vec3D(Mdouble)>  planewiseShift,
std::function< Vec3D(Mdouble)>  boost 
)

Defines a TimeDependentPeriodicBoundary by its normal and positions, and by the shifting and boosting that it does (projected onto the planewise direction)

Parameters
[in]normalVector specifying the normal direction of the edges
[in]distanceLeftPosition of the first edge
[in]distanceRightPosition of the second edge
[in]shiftVector (projected to remove normal component) by which particles crossing an edge are to be shifted, as a function of time.
[in]boostVector (projected to remove normal component) by which particles crossing an edge are to be boosted, as a function of time.
87 {
88  normal_ = normal;
89  distanceLeft_ = distanceLeft,
90  distanceRight_ = distanceRight,
91  planewiseShift_ = planewiseShift;
92  boost_ = boost;
94 }
const Mdouble inf
Definition: GeneralDefine.h:44

References boost_, distanceLeft_, distanceRight_, constants::inf, maxShift_, normal_, and planewiseShift_.

◆ set() [2/2]

void TimeDependentPeriodicBoundary::set ( Vec3D  normal,
Vec3D  positionLeft,
Vec3D  positionRight,
std::function< Vec3D(Mdouble)>  shift,
std::function< Vec3D(Mdouble)>  boost 
)

As above, but by specifying two positions that the boundaries go through instead of distanceLeft and distanceRight.

98 {
99  set(normal, Vec3D::dot(positionLeft,normal), Vec3D::dot(positionRight,normal),
100  planewiseShift, boost);
101 }
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight, std::function< Vec3D(Mdouble)> planewiseShift, std::function< Vec3D(Mdouble)> boost)
Defines a TimeDependentPeriodicBoundary by its normal and positions, and by the shifting and boosting...
Definition: TimeDependentPeriodicBoundary.cc:85

References Vec3D::dot(), and set().

Referenced by set().

◆ setMaxShift()

void TimeDependentPeriodicBoundary::setMaxShift ( Mdouble  maxShift)

Set the maximum shift (will take fmod w.r.t. this)

111 {
112  maxShift_ = maxShift;
113 }

References maxShift_.

◆ setPlanewiseShiftAndBoost()

void TimeDependentPeriodicBoundary::setPlanewiseShiftAndBoost ( std::function< Vec3D(Mdouble)>  shift,
std::function< Vec3D(Mdouble)>  boost 
)

Set the planewise shift and boost (projected onto the planewise direction) as functions of time. (Boost should be the derivative of shift)

105 {
106  planewiseShift_ = planewiseShift;
107  boost_ = boost;
108 }

References boost_, and planewiseShift_.

◆ shiftAndBoostParticle()

void TimeDependentPeriodicBoundary::shiftAndBoostParticle ( BaseParticle p,
Mdouble  time 
) const
virtual
214 {
215  if (isClosestToLeftBoundary(*p))
216  {
217  p->move(getShift(time));
218  p->addVelocity(getBoost(time));
219  }
220  else
221  {
222  p->move(-getShift(time));
223  p->addVelocity(-getBoost(time));
224  }
225 }
void addVelocity(const Vec3D &velocity)
adds an increment to the velocity.
Definition: BaseInteractable.h:312
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
Definition: BaseInteractable.cc:215
Vec3D getBoost(Mdouble time) const
Returns the planewise boost as a function of time.
Definition: TimeDependentPeriodicBoundary.cc:160
Vec3D getShift(Mdouble time) const
Returns the vector going from the left to the right side of the periodic boundary.
Definition: TimeDependentPeriodicBoundary.cc:139

References BaseInteractable::addVelocity(), getBoost(), getShift(), isClosestToLeftBoundary(), and BaseInteractable::move().

Referenced by checkBoundaryAfterParticlesMove(), and createGhostParticle().

◆ shiftPosition()

void TimeDependentPeriodicBoundary::shiftPosition ( BaseParticle p) const
overridevirtual

shifts and boosts the particle

Parameters
[in]pA pointer to the particle which will be shifted and boosted.
Todo:
{JMFT: The time comes from p->getHandler()->getDPMBase()->getTime(), which will be undefined if p does not belong to a handler.}

Shouldn't be used for TimeDependentPeriodicBoundary. Instead, use TimeDependentPeriodicBoundary::shiftandBoostParticle.

Implements BasePeriodicBoundary.

210 {
211 }

◆ shiftPositions()

void TimeDependentPeriodicBoundary::shiftPositions ( Vec3D position1,
Vec3D position2 
) const
virtual

shifts two positions (JMFT: Why, what is this for?)

228 {
229  if (isClosestToLeftBoundary(position1))
230  {
231  position1 += getShift(0); // TODO JMFT: ?!?!?!
232  position2 += getShift(0);
233  }
234  else
235  {
236  position1 -= getShift(0);
237  position2 -= getShift(0);
238  }
239 }

References getShift(), and isClosestToLeftBoundary().

◆ write()

void TimeDependentPeriodicBoundary::write ( std::ostream &  os) const
overridevirtual

writes boundary properties to ostream

Writes boundary's properties to an ostream

Parameters
[in]osthe ostream

Reimplemented from BasePeriodicBoundary.

359 {
361  os << " normal " << normal_
362  << " distanceLeft " << distanceLeft_
363  << " distanceRight " << distanceRight_
364  // << " planewiseShift " << planewiseShift_
365  // << " boost " << boost_
366  ;
367 }
void write(std::ostream &os) const override
Adds object's id_ to given ostream.
Definition: BasePeriodicBoundary.cc:80

References distanceLeft_, distanceRight_, normal_, and BasePeriodicBoundary::write().

Member Data Documentation

◆ boost_

std::function<Vec3D (Mdouble)> TimeDependentPeriodicBoundary::boost_
protected

boost from the left to right boundary

Referenced by getBoost(), set(), setPlanewiseShiftAndBoost(), and TimeDependentPeriodicBoundary().

◆ distanceLeft_

Mdouble TimeDependentPeriodicBoundary::distanceLeft_
protected

position of left edge, s.t. normal*x = distanceLeft_

Referenced by getDistance(), getDistanceLeft(), getShift(), isClosestToLeftBoundary(), moveLeft(), read(), set(), TimeDependentPeriodicBoundary(), and write().

◆ distanceRight_

Mdouble TimeDependentPeriodicBoundary::distanceRight_
protected

position of right edge, s.t. normal*x = distanceRight_

Referenced by getDistance(), getDistanceRight(), getShift(), isClosestToLeftBoundary(), moveRight(), read(), set(), TimeDependentPeriodicBoundary(), and write().

◆ maxShift_

Mdouble TimeDependentPeriodicBoundary::maxShift_
protected

Maximum shifting (will take fmod(shift, maxshift) )

Referenced by getPlanewiseShift(), set(), setMaxShift(), and TimeDependentPeriodicBoundary().

◆ normal_

Vec3D TimeDependentPeriodicBoundary::normal_
protected

outward unit normal vector for right edge

Referenced by getDistance(), getNormal(), getShift(), isClosestToLeftBoundary(), read(), set(), TimeDependentPeriodicBoundary(), and write().

◆ planewiseShift_

std::function<Vec3D (Mdouble)> TimeDependentPeriodicBoundary::planewiseShift_
protected

shift from left to right boundary in the planewise direction (Note: total shift = planewiseShift_(time) + normal * (distanceRight_ - distanceLeft_)

Referenced by getPlanewiseShift(), set(), setPlanewiseShiftAndBoost(), and TimeDependentPeriodicBoundary().


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