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

18 {
19  distanceLeft_ = std::numeric_limits<double>::quiet_NaN();
20  distanceRight_ = std::numeric_limits<double>::quiet_NaN();
21  maxShift_ = 0;
22 
23 
24 #ifdef MERCURYDPM_USE_MPI
25  MPIContainer& communicator = MPIContainer::Instance();
26  if (communicator.getNumberOfProcessors() > 1)
27  {
28  logger(WARN,"LeesEdwardsBoundaries are currently not implemented in parallel MercuryDPM");
29  }
30 #endif
31  logger(DEBUG, "TimeDependentPeriodicBoundary::TimeDependentPeriodicBoundary() finished");
32 }
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:14
This class contains all information and functions required for communication between processors.
Definition: MpiContainer.h:109
std::size_t getNumberOfProcessors() const
Get the total number of processors participating in this simulation.
Definition: MpiContainer.cc:83
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:113
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Definition: TimeDependentPeriodicBoundary.h:224
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Definition: TimeDependentPeriodicBoundary.h:219
Mdouble maxShift_
Maximum shifting (will take fmod(shift, maxshift) )
Definition: TimeDependentPeriodicBoundary.h:240

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

Referenced by copy().

◆ ~TimeDependentPeriodicBoundary()

TimeDependentPeriodicBoundary::~TimeDependentPeriodicBoundary ( )

destructor

destructor

38 {
39  logger(DEBUG, "TimeDependentPeriodicBoundary::~TimeDependentPeriodicBoundary() finished");
40 }

References DEBUG, and logger.

◆ TimeDependentPeriodicBoundary() [2/2]

TimeDependentPeriodicBoundary::TimeDependentPeriodicBoundary ( const TimeDependentPeriodicBoundary other)

copy constructor

Copy constructor

54 {
55  normal_ = other.normal_;
59  boost_ = other.boost_;
60  maxShift_ = other.maxShift_;
61 
62 }
Vec3D normal_
outward unit normal vector for right edge
Definition: TimeDependentPeriodicBoundary.h:214
std::function< Vec3D(Mdouble)> planewiseShift_
shift from left to right boundary in the planewise direction (Note: total shift = planewiseShift_(tim...
Definition: TimeDependentPeriodicBoundary.h:230
std::function< Vec3D(Mdouble)> boost_
boost from the left to right boundary
Definition: TimeDependentPeriodicBoundary.h:235

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.

300 {
301 #ifdef MERCURYDPM_USE_MPI
302  if (NUMBER_OF_PROCESSORS == 1)
303  {
304 #endif
305  for (auto p = pH.begin(); p != pH.end(); ++p)
306  {
307  if (getDistance((*p)->getPosition()) < 0)
308  {
310  }
311  }
312 #ifdef MERCURYDPM_USE_MPI
313  }
314 #endif
315 }
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:41
float * p
Definition: Tutorial_Map_using.cpp:9
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:698
const std::vector< T * >::const_iterator end() const
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
Definition: BaseHandler.h:712
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:733
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:799
virtual void shiftAndBoostParticle(BaseParticle *p, Mdouble time) const
Definition: TimeDependentPeriodicBoundary.cc:192
Mdouble getDistance(const BaseParticle &p) const override
Returns the distance of the edge to the particle.
Definition: TimeDependentPeriodicBoundary.cc:167

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

◆ copy()

TimeDependentPeriodicBoundary * TimeDependentPeriodicBoundary::copy ( ) const
overridevirtual

copy method

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

Implements BasePeriodicBoundary.

46 {
47  return new TimeDependentPeriodicBoundary(*this);
48 }
TimeDependentPeriodicBoundary()
default constructor
Definition: TimeDependentPeriodicBoundary.cc:16

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.}
261 {
263 
264  //Step 1: Copy the particle to new ghost particle.
265  BaseParticle* pGhost = pReal->copy();
266 
267  //Step 2: Copy the interactions of the ghost particle.
268  pGhost->copyInteractionsForPeriodicParticles(*pReal);
269 
270  //Step 3: Shift the ghost to the 'reflected' location.
271  shiftAndBoostParticle(pGhost, pH.getDPMBase()->getTime());
272 
273  //Step 4: If Particle is double shifted, get correct original particle
274  BaseParticle* from = pReal;
275  while (from->getPeriodicFromParticle() != nullptr)
276  from = from->getPeriodicFromParticle();
277  pGhost->setPeriodicFromParticle(from);
278 
279  pH.addObject(pGhost);
280 }
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
Definition: BaseBoundary.cc:122
void copyInteractionsForPeriodicParticles(const BaseInteractable &p)
Copies interactions to this BaseInteractable whenever a periodic copy made.
Definition: BaseInteractable.cc:364
Definition: BaseParticle.h:33
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:416
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:324
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1443
Container to store pointers to all particles.
Definition: ParticleHandler.h:28
void addObject(BaseParticle *P) override
Adds a BaseParticle to the ParticleHandler.
Definition: ParticleHandler.cc:150

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.

283 {
284  //note that getDistance sets closestToLeftBoundary_ to true or false depending on which side is closest
285  if (getDistance(*p) < p->getMaxInteractionRadius() + pH.getLargestParticle()->getMaxInteractionRadius())
286  {
288  }
289 }
Mdouble getMaxInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e....
Definition: BaseParticle.h:345
BaseParticle * getLargestParticle() const
Returns the pointer of the largest particle in the particle handler. When mercury is running in paral...
Definition: ParticleHandler.cc:528
void createGhostParticle(BaseParticle *pReal)
Creates and adds a ghost particle from a given real particle.
Definition: TimeDependentPeriodicBoundary.cc:260

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

Referenced by createPeriodicParticles().

◆ createPeriodicParticles()

void TimeDependentPeriodicBoundary::createPeriodicParticles ( ParticleHandler pH)
overridevirtual

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

244 {
245 #ifdef MERCURYDPM_USE_MPI
246  if (NUMBER_OF_PROCESSORS == 1)
247  {
248 #endif
249  unsigned numberOfParticles = pH.getSize();
250 
251  for(unsigned i = 0; i < numberOfParticles; i++)
252  {
254  }
255 #ifdef MERCURYDPM_USE_MPI
256  }
257 #endif
258 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:663
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:621
void createPeriodicParticle(BaseParticle *p, ParticleHandler &pH) override
Creates a single periodic particle if required from a given particle.
Definition: TimeDependentPeriodicBoundary.cc:282

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

◆ getBoost()

Vec3D TimeDependentPeriodicBoundary::getBoost ( Mdouble  time) const

Returns the planewise boost as a function of time.

140 {
141  return boost_(time);
142 }

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.

168 {
169  return getDistance(p.getPosition());
170 }

References p.

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.

178 {
179  Mdouble distanceFromPlaneThroughOrigin = Vec3D::dot(position, normal_);
180  return std::min(distanceFromPlaneThroughOrigin - distanceLeft_,
181  distanceRight_ - distanceFromPlaneThroughOrigin);
182 }
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:56
#define min(a, b)
Definition: datatypes.h:22

References distanceLeft_, distanceRight_, Vec3D::dot(), min, 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
106 {
107  return distanceLeft_;
108 }

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
114 {
115  return distanceRight_;
116 }

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.

353 {
354  return "TimeDependentPeriodicBoundary";
355 }

◆ getNormal()

Vec3D TimeDependentPeriodicBoundary::getNormal ( ) const

returns the vector normal to the periodic boundary

Returns
The vector perpendicular to the periodic boundary
98 {
99  return normal_;
100 }

References normal_.

◆ getPlanewiseShift()

Vec3D TimeDependentPeriodicBoundary::getPlanewiseShift ( Mdouble  time) const

Returns the planewise shift as a function of time.

124 {
125  if (maxShift_ == 0)
126  return planewiseShift_(time);
127  if (maxShift_ > 0)
128  {
129  Vec3D p = planewiseShift_(time);
130  Mdouble m = p.getLength();
131  Vec3D n = p / m;
132  return fmod(m, maxShift_) * n;
133  }
134  if (maxShift_ < 0)
135  logger(ERROR, "[TimeDependentPeriodicBoundary::getPlanewiseShift] maxShift_ = % is negative", maxShift_);
136  return {0,0,0};
137 }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
@ ERROR
Definition: Kernel/Math/Vector.h:30
int * m
Definition: level2_cplx_impl.h:294
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 fmod(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:648

References ERROR, Eigen::bfloat16_impl::fmod(), logger, m, maxShift_, n, p, 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.

119 {
121 }
Vec3D getPlanewiseShift(Mdouble time) const
Returns the planewise shift as a function of time.
Definition: TimeDependentPeriodicBoundary.cc:123

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.

227 {
228  return isClosestToLeftBoundary(p.getPosition());
229 }
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:226

References p.

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.

238 {
239  const Mdouble distance = Vec3D::dot(p, normal_);
240  return (distanceRight_ - distance > distance - distanceLeft_);
241 }

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

◆ 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
152 {
153  distanceLeft_ = distanceLeft;
154 }

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
163 {
164  distanceRight_ = distanceRight;
165 }

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.

322 {
324  std::string dummy;
325  is >> dummy >> normal_
326  >> dummy >> distanceLeft_
327  >> dummy >> distanceRight_
328  // >> dummy >> planewiseShift_
329  // >> dummy >> boost_
330  ;
331 }
void read(std::istream &is) override
Reads the object's id_ from given istream.
Definition: BasePeriodicBoundary.cc:50
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

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

◆ 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.
66 {
67  normal_ = normal;
68  distanceLeft_ = distanceLeft,
69  distanceRight_ = distanceRight,
70  planewiseShift_ = planewiseShift;
71  boost_ = boost;
73 }
void normal(const Vector< double > &x, Vector< double > &normal)
Definition: free_surface_rotation.cc:65
Definition: boostmultiprec.cpp:107
const Mdouble inf
Definition: GeneralDefine.h:23

References boost_, distanceLeft_, distanceRight_, constants::inf, maxShift_, WallFunction::normal(), 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.

77 {
78  set(normal, Vec3D::dot(positionLeft,normal), Vec3D::dot(positionRight,normal),
79  planewiseShift, boost);
80 }
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:64

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

Referenced by set().

◆ setMaxShift()

void TimeDependentPeriodicBoundary::setMaxShift ( Mdouble  maxShift)

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

90 {
91  maxShift_ = maxShift;
92 }

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)

84 {
85  planewiseShift_ = planewiseShift;
86  boost_ = boost;
87 }

References boost_, and planewiseShift_.

◆ shiftAndBoostParticle()

void TimeDependentPeriodicBoundary::shiftAndBoostParticle ( BaseParticle p,
Mdouble  time 
) const
virtual
193 {
195  {
196  p->move(getShift(time));
197  p->addVelocity(getBoost(time));
198  }
199  else
200  {
201  p->move(-getShift(time));
202  p->addVelocity(-getBoost(time));
203  }
204 }
Vec3D getBoost(Mdouble time) const
Returns the planewise boost as a function of time.
Definition: TimeDependentPeriodicBoundary.cc:139
Vec3D getShift(Mdouble time) const
Returns the vector going from the left to the right side of the periodic boundary.
Definition: TimeDependentPeriodicBoundary.cc:118

References getBoost(), getShift(), isClosestToLeftBoundary(), and p.

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.

189 {
190 }

◆ shiftPositions()

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

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

207 {
208  if (isClosestToLeftBoundary(position1))
209  {
210  position1 += getShift(0); // TODO JMFT: ?!?!?!
211  position2 += getShift(0);
212  }
213  else
214  {
215  position1 -= getShift(0);
216  position2 -= getShift(0);
217  }
218 }

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.

338 {
340  os << " normal " << normal_
341  << " distanceLeft " << distanceLeft_
342  << " distanceRight " << distanceRight_
343  // << " planewiseShift " << planewiseShift_
344  // << " boost " << boost_
345  ;
346 }
void write(std::ostream &os) const override
Adds object's id_ to given ostream.
Definition: BasePeriodicBoundary.cc:59

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: