revision: v0.14
PeriodicBoundary.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #ifndef PeriodicBoundary_H
27 #define PeriodicBoundary_H
28 
29 #include "BasePeriodicBoundary.h"
30 #include "ParticleHandler.h"
31 #include "Math/Vector.h"
32 #include "MpiDataClass.h"
33 
41 {
42 public:
43 
48 
52  ~PeriodicBoundary() override;
53 
57  PeriodicBoundary* copy() const override;
58 
62  PeriodicBoundary(const PeriodicBoundary& other);
63 
67  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight);
68 
73  void set(Vec3D normal, Vec3D positionLeft, Vec3D positionRight);
74 
78  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight, Vec3D shiftDirection);
79 
84  void setPlanewiseShift(Vec3D planewiseShift);
85 
89  Vec3D getNormal() const;
90 
94  Mdouble getDistanceLeft() const;
95 
99  Mdouble getDistanceRight() const;
100 
104  Vec3D getShift() const;
105 
109  void moveLeft(Mdouble distanceLeft);
110 
114  void moveRight(Mdouble distanceRight);
115 
119  Mdouble getDistance(const BaseParticle& p) const override;
120 
124  Mdouble getDistance(const Vec3D& position) const override;
125 
130  virtual void shiftPosition(BaseParticle* p) const override;
131  void shiftPosition(Vec3D& p) const;
132 
136  virtual void shiftPositions(Vec3D& postition1, Vec3D& postion2) const;
137 
142  virtual bool isClosestToLeftBoundary(const BaseParticle& p) const;
143 
148  bool isClosestToLeftBoundary(const Vec3D& p) const override;
149 
154  virtual void createPeriodicParticles(ParticleHandler &pH) override;
155 
159  void createGhostParticle(BaseParticle *pReal);
160 
164  void createPeriodicParticle(BaseParticle* p, ParticleHandler &pH) override;
165 
170  virtual void checkBoundaryAfterParticlesMove(ParticleHandler& pH) override;
171 
175  virtual void read(std::istream& is) override;
180  void oldRead(std::istream& is);
181 
185  void write(std::ostream& os) const override;
186 
190  std::string getName() const override;
191 
192 
193 protected:
202 
207 
212 
217 
218 };
219 
220 #endif
DPMBase::setName
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:420
PeriodicBoundary::write
void write(std::ostream &os) const override
writes boundary properties to ostream
Definition: PeriodicBoundary.cc:426
DPMBase::setTimeStep
void setTimeStep(Mdouble newDt)
Sets a new value for the simulation time step.
Definition: DPMBase.cc:1225
my_problem::setupInitialConditions
void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: periodic.cpp:37
PeriodicBoundary::getShift
Vec3D getShift() const
Returns the vector going from the left to the right side of the periodic boundary.
Definition: PeriodicBoundary.cc:159
Vector.h
PeriodicBoundary.h
PeriodicBoundary::scaleFactor_
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
Definition: PeriodicBoundary.h:211
my_problem::N
unsigned int N
Definition: periodic.cpp:89
PeriodicBoundary::shiftPosition
virtual void shiftPosition(BaseParticle *p) const override
shifts the particle
Definition: PeriodicBoundary.cc:219
BaseParticle::getPeriodicFromParticle
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Definition: BaseParticle.h:341
DPMBase::getXMax
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax.
Definition: DPMBase.h:607
BaseInteractable::setPosition
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:239
logger
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
PeriodicBoundary::~PeriodicBoundary
~PeriodicBoundary() override
destructor
Definition: PeriodicBoundary.cc:50
BaseInteractable::copyInteractionsForPeriodicParticles
void copyInteractionsForPeriodicParticles(const BaseInteractable &p)
Copies interactions to this BaseInteractable whenever a periodic copy made.
Definition: BaseInteractable.cc:386
main
int main(int argc UNUSED, char *argv[] UNUSED)
Definition: periodic.cpp:111
Vec3D::dot
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
DPMBase::setYMax
void setYMax(Mdouble newYMax)
Sets the value of YMax, the upper bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1182
BaseHandler::getSize
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
ParticleHandler.h
MpiContainer.h
BaseInteractable::move
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
Definition: BaseInteractable.cc:215
Mercury2D.h
DPMBase::hGridUpdateMove
virtual void hGridUpdateMove(BaseParticle *, Mdouble)
Definition: DPMBase.cc:1924
BaseParticle::setRadius
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species)
Definition: BaseParticle.cc:542
Vec3D
Definition: Vector.h:50
DPMBase::solve
void solve()
The work horse of the code.
Definition: DPMBase.cc:4003
DPMBase::getYMin
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin.
Definition: DPMBase.h:613
DPMBase::setZMax
void setZMax(Mdouble newZMax)
Sets the value of ZMax, the upper bound of the problem domain in the z-direction.
Definition: DPMBase.cc:1208
DPMBase::boundaryHandler
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1410
BasePeriodicBoundary
Definition: BasePeriodicBoundary.h:41
NUMBER_OF_PROCESSORS
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:62
PeriodicBoundary::getDistanceRight
Mdouble getDistanceRight() const
Returns the distance of the right wall to the origin, in normal direction.
Definition: PeriodicBoundary.cc:151
PeriodicBoundary::copy
PeriodicBoundary * copy() const override
copy method
Definition: PeriodicBoundary.cc:58
ParticleHandler::getLargestParticle
BaseParticle * getLargestParticle() const
Returns the pointer of the largest particle in the particle handler. When mercury is running in paral...
Definition: ParticleHandler.cc:530
PeriodicBoundary::distanceRight_
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Definition: PeriodicBoundary.h:206
BaseInteractable::setVelocity
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Definition: BaseInteractable.cc:350
BasePeriodicBoundary::write
void write(std::ostream &os) const override
Adds object's id_ to given ostream.
Definition: BasePeriodicBoundary.cc:80
BaseParticle::copy
virtual BaseParticle * copy() const =0
Particle copy method. It calls to copy constructor of this Particle, useful for polymorphism.
my_problem
todo{This code is not working as is wanted}
Definition: elastic_gas.cpp:34
BaseParticle::setPeriodicFromParticle
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
double
PeriodicBoundary::normal_
Vec3D normal_
outward unit normal vector for right edge
Definition: PeriodicBoundary.h:197
PeriodicBoundary::read
virtual void read(std::istream &is) override
reads boundary properties from istream
Definition: PeriodicBoundary.cc:397
PeriodicBoundary::moveRight
void moveRight(Mdouble distanceRight)
Sets the distance from the origin of the 'right' periodic wall.
Definition: PeriodicBoundary.cc:182
PeriodicBoundary::PeriodicBoundary
PeriodicBoundary()
default constructor
Definition: PeriodicBoundary.cc:37
PeriodicBoundary::getDistanceLeft
Mdouble getDistanceLeft() const
Returns the distance of the left wall to the origin, in normal direction.
Definition: PeriodicBoundary.cc:143
mathsFunc::sin
Mdouble sin(Mdouble x)
Definition: ExtendedMath.cc:44
MERCURY_DEPRECATED
#define MERCURY_DEPRECATED
Definition: GeneralDefine.h:37
LinearViscoelasticSpecies
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Definition: LinearViscoelasticSpecies.h:33
LinearViscoelasticSpecies.h
DPMBase::getTime
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:805
DPMBase::setXMax
void setXMax(Mdouble newXMax)
Sets the value of XMax, the upper bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1156
InfiniteWall.h
Log::FATAL
@ FATAL
DPMBase::speciesHandler
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1385
PeriodicBoundary::getDistance
Mdouble getDistance(const BaseParticle &p) const override
Returns the distance of the edge to the particle.
Definition: PeriodicBoundary.cc:197
PeriodicBoundary::getNormal
Vec3D getNormal() const
returns the vector normal to the periodic boundary
Definition: PeriodicBoundary.cc:135
DPMBase.h
PeriodicBoundary::moveLeft
void moveLeft(Mdouble distanceLeft)
Sets the distance from the origin of the 'left' periodic wall.
Definition: PeriodicBoundary.cc:170
DPMBase::wallHandler
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1405
PeriodicBoundary::oldRead
MERCURY_DEPRECATED void oldRead(std::istream &is)
deprecated version of CubeInsertionBoundary::read().
Definition: PeriodicBoundary.cc:412
DPMBase::setTimeMax
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:870
DPMBase::setGravity
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1374
InfiniteWall
A infinite wall fills the half-space {point: (position_-point)*normal_<=0}.
Definition: InfiniteWall.h:48
BasePeriodicBoundary.h
constants::i
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
DPMBase::getZMin
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin.
Definition: DPMBase.h:625
PeriodicBoundary::createPeriodicParticle
void createPeriodicParticle(BaseParticle *p, ParticleHandler &pH) override
Creates a single periodic particle if required from a given particle.
Definition: PeriodicBoundary.cc:304
BaseInteractable::setPrescribedPosition
void setPrescribedPosition(const std::function< Vec3D(double)> &prescribedPosition)
Allows the position of an infinite mass interactable to be prescribed.
Definition: BaseInteractable.cc:413
BaseHandler::getObject
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
PeriodicBoundary::getName
std::string getName() const override
Returns the name of the object.
Definition: PeriodicBoundary.cc:440
BaseHandler::getDPMBase
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
PeriodicBoundary::distanceLeft_
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Definition: PeriodicBoundary.h:201
BaseParticle
Definition: BaseParticle.h:54
Vec3D::getLengthSquared
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.h:316
Mercury2D
This adds on the hierarchical grid code for 2D problems.
Definition: Mercury2D.h:36
ParticleHandler::addObject
void addObject(BaseParticle *P) override
Adds a BaseParticle to the ParticleHandler.
Definition: ParticleHandler.cc:170
UNUSED
#define UNUSED
Definition: GeneralDefine.h:39
DPMBase::getMin
Vec3D getMin() const
Definition: DPMBase.h:637
BaseHandler::copyAndAddObject
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
BaseParticle::getMaxInteractionRadius
Mdouble getMaxInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e....
Definition: BaseParticle.h:362
BaseHandler::begin
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
PeriodicBoundary::shiftPositions
virtual void shiftPositions(Vec3D &postition1, Vec3D &postion2) const
shifts two positions
Definition: PeriodicBoundary.cc:255
MpiDataClass.h
PeriodicBoundary
Defines a pair of periodic walls. Inherits from BaseBoundary.
Definition: PeriodicBoundary.h:41
DPMBase::getYMax
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax.
Definition: DPMBase.h:619
PeriodicBoundary::createGhostParticle
void createGhostParticle(BaseParticle *pReal)
Creates and adds a ghost particle from a given real particle.
Definition: PeriodicBoundary.cc:314
BaseBoundary::getHandler
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
Definition: BaseBoundary.cc:143
PeriodicBoundary::set
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
Definition: PeriodicBoundary.cc:84
ParticleHandler
Container to store all BaseParticle.
Definition: ParticleHandler.h:48
PeriodicBoundary::isClosestToLeftBoundary
virtual bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns TRUE if particle checked is closest to the 'left' edge, and FALSE if it is closest to the 'ri...
Definition: PeriodicBoundary.cc:275
MercuryBase.h
PeriodicBoundary::createPeriodicParticles
virtual void createPeriodicParticles(ParticleHandler &pH) override
Checks distance of particle to closer edge and creates a periodic copy if necessary.
Definition: PeriodicBoundary.cc:349
DPMBase::particleHandler
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1395
PeriodicBoundary::shift_
Vec3D shift_
shift from left to right boundary
Definition: PeriodicBoundary.h:216
PeriodicBoundary::checkBoundaryAfterParticlesMove
virtual void checkBoundaryAfterParticlesMove(ParticleHandler &pH) override
Loops over particles, checks if each particle has crossed either boundary edge, and applies a shift i...
Definition: PeriodicBoundary.cc:374
DPMBase::setSaveCount
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:406
PeriodicBoundary::setPlanewiseShift
void setPlanewiseShift(Vec3D planewiseShift)
Set the planewise shift (projected onto the planewise direction, and zero by default).
Definition: PeriodicBoundary.cc:126
InfiniteWall::set
void set(Vec3D normal, Vec3D point)
Defines a standard wall, given an outward normal vector s.t. normal*x=normal*point for all x of the w...
Definition: InfiniteWall.cc:118
BasePeriodicBoundary::read
void read(std::istream &is) override
Reads the object's id_ from given istream.
Definition: BasePeriodicBoundary.cc:71
BaseHandler::end
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
BaseParticle.h
BaseParticle::setPeriodicGhostParticle
void setPeriodicGhostParticle(bool flag)
Flags the status of the particle to be a ghost in periodic boundary or not.
Definition: BaseParticle.cc:296
DPMBase::getXMin
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin.
Definition: DPMBase.h:600
BaseInteractable::getPosition
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
DPMBase::setSystemDimensions
void setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1408