60 return P.getIndSpecies();
68 std::cout <<
"constructor" << std::endl;
81 size_t found = restart_file.find_last_of(
"/\\");
82 setName(restart_file.substr(found + 1).c_str());
88 setName(
"ChuteWithPeriodicInflow");
94 double lengthPeriodicChute =
getXMax();
100 for (
int j = 1; j < numRepetitions; j++)
102 for (
int i = 0;
i < N;
i++)
113 setXMax(numRepetitions * lengthPeriodicChute);
121 double widthPeriodicChute =
getYMax();
124 for (
int j = 1; j < numRepetitionsInWidth; j++)
126 for (
int i = 0;
i < N;
i++)
135 setYMax(numRepetitionsInWidth * widthPeriodicChute);
150 static int count = 0, maxcount = 100;
151 if (count > maxcount)
180 (*it)->integrateBeforeForceComputation(
getTimeStep());
185 if ((*it)->getIndSpecies() == 0 && perw->
getDistance(**it) < 0)
204 static int count = -1;
208 std::cout <<
"Warning: Particle " << (*it)->getIndex() <<
" is left of xmin: x="
209 << (*it)->getPosition().X <<
", v_x=" << (*it)->getVelocity().X << std::endl;
255 std::cout <<
"t=" << std::setprecision(5) << std::left << std::setw(6) <<
getTime()
256 <<
", n=" << n1 <<
"(inflow:" << n0 <<
")"
257 <<
", speed= " << speed1 <<
"(" << speed0 <<
")"
358 std::cerr <<
"In computing internal forces between particle "<<PI->
getPosition()<<
" and "<<PJ->
getPosition()<<std::endl;
363 Mdouble interactionRadii_sum = PI->getInteractionRadius() + PJ->getInteractionRadius();
365 #ifdef DEBUG_OUTPUT_FULL
366 std::cerr <<
"Square of distance between " << dist_squared <<
" square sum of radii " << radii_sum*radii_sum <<std::endl;
370 if (dist_squared < (interactionRadii_sum * interactionRadii_sum))
377 Mdouble dist = sqrt(dist_squared);
385 Mdouble deltan = std::max(0.0, radii_sum - dist);
396 CTangentialSpring* TangentialSpring = NULL;
399 if (pSpecies->getAdhesionForceType() != AdhesionForceType::NONE)
400 fdotn += computeShortRangeForceWithParticle(PI, PJ, PJreal, pSpecies, dist);
407 if (!pSpecies->getSlidingFrictionCoefficient())
420 if (pSpecies->getIsRestitutionCoefficientConstant())
425 if (pSpecies->getForceType() == ForceType::HERTZ_MINDLIN || pSpecies->getForceType() == ForceType::HERTZ_MINDLIN_DERESIEWICZ)
429 a = sqrt(
R * deltan);
431 Mdouble kn = 4. / 3. * pSpecies->getStiffness() * a;
432 fdotn += kn * deltan + pSpecies->getDissipation() * vdotn;
436 fdotn += pSpecies->getStiffness() * deltan + pSpecies->getDissipation() * vdotn;
438 force += normal * fdotn;
441 if (pSpecies->getSlidingFrictionCoefficient() || pSpecies->getRollingFrictionCoefficient() || pSpecies->getTorsionFrictionCoefficient())
444 if (pSpecies->getSlidingStiffness() || pSpecies->getRollingStiffness() || pSpecies->getTorsionStiffness())
445 TangentialSpring = getTangentialSpring(PI, PJ, PJreal);
451 if (pSpecies->getSlidingFrictionCoefficient())
454 Vec3D vrelt = vrel + normal * vdotn;
458 if (pSpecies->getSlidingStiffness())
460 Vec3D* delta = &(TangentialSpring->delta);
469 if (pSpecies->getForceType() == ForceType::HERTZ_MINDLIN)
472 Mdouble kt = 8. * pSpecies->getSlidingStiffness() * a;
473 TangentialSpring->SlidingForce += -kt * ddelta;
474 forcet = TangentialSpring->SlidingForce - pSpecies->getSlidingDissipation() * vrelt;
476 else if (pSpecies->getForceType() == ForceType::HERTZ_MINDLIN_DERESIEWICZ)
479 forcet = TangentialSpring->SlidingForce - pSpecies->getSlidingDissipation() * vrelt;
480 Mdouble kt = 8. * pSpecies->getSlidingStiffness() * a * std::pow(1 -
Vec3D::getLength(forcet) / pSpecies->getSlidingFrictionCoefficient() / fdotn, 0.33);
481 TangentialSpring->SlidingForce += -kt * ddelta;
482 forcet = TangentialSpring->SlidingForce - pSpecies->getSlidingDissipation() * vrelt;
486 forcet = (-pSpecies->getSlidingDissipation()) * vrelt - pSpecies->getSlidingStiffness() * (*delta);
493 double muact = (TangentialSpring->sliding) ? (pSpecies->getSlidingFrictionCoefficient()) : (pSpecies->getSlidingFrictionCoefficientStatic());
497 TangentialSpring->sliding =
false;
502 TangentialSpring->sliding =
true;
504 Mdouble norm_forcet = sqrt(forcet2);
505 forcet *= pSpecies->getSlidingFrictionCoefficient() * norm_fn / norm_forcet;
506 TangentialSpring->SlidingForce = forcet + pSpecies->getSlidingDissipation() * vrelt;
507 (*delta) = TangentialSpring->SlidingForce / (-pSpecies->getSlidingStiffness());
519 if (vdott * pSpecies->getSlidingDissipation() <= pSpecies->getSlidingFrictionCoefficientStatic() * norm_fn)
521 forcet = -pSpecies->getSlidingDissipation() * vrelt;
526 forcet = -(pSpecies->getSlidingFrictionCoefficient() * norm_fn / vdott) * vrelt;
534 if (pSpecies->getRollingFrictionCoefficient())
539 Mdouble reducedRadiusIJ = 2.0 * reducedRadiusI * reducedRadiusJ / (reducedRadiusI + reducedRadiusJ);
541 if (pSpecies->getRollingStiffness())
543 Vec3D* RollingSpring = &(TangentialSpring->RollingSpring);
549 forcerolling = (-pSpecies->getRollingDissipation()) * vrolling - pSpecies->getRollingStiffness() * (*RollingSpring);
555 double muact = (TangentialSpring->slidingRolling) ? (pSpecies->getRollingFrictionCoefficient()) : (pSpecies->getRollingFrictionCoefficientStatic());
559 TangentialSpring->slidingRolling =
false;
564 TangentialSpring->slidingRolling =
true;
565 forcerolling *= pSpecies->getRollingFrictionCoefficient() * norm_fn / sqrt(forcerolling2);
566 (*RollingSpring) = (forcerolling + pSpecies->getRollingDissipation() * vrolling) / (-pSpecies->getRollingStiffness());
577 if (pSpecies->getTorsionFrictionCoefficient())
582 if (pSpecies->getTorsionStiffness())
586 Vec3D* TorsionSpring = &(TangentialSpring->TorsionSpring);
592 forcetorsion = (-pSpecies->getTorsionDissipation()) * vtorsion - pSpecies->getTorsionStiffness() * (*TorsionSpring);
598 double muact = (TangentialSpring->slidingTorsion) ? (pSpecies->getTorsionFrictionCoefficient()) : (pSpecies->getTorsionFrictionCoefficientStatic());
602 TangentialSpring->slidingTorsion =
false;
607 TangentialSpring->slidingTorsion =
true;
609 forcetorsion *= pSpecies->getTorsionFrictionCoefficient() * norm_fn / sqrt(forcetorsion2);
610 (*TorsionSpring) = (forcetorsion + pSpecies->getTorsionDissipation() * vtorsion) / (-pSpecies->getTorsionStiffness());
614 Vec3D torque = RadiusIJ * forcetorsion;
624 if (pSpecies->getForceType() == ForceType::HERTZ)
630 force += fdotn * normal;
680 if (pSpecies->getSlidingFrictionCoefficient())
709 if (
eneFile.getSaveCurrentTimeStep())
712 addElasticEnergy(0.5 * (pSpecies->getStiffness() *
mathsFunc::square(deltan) + (TangentialSpring ? (pSpecies->getSlidingStiffness() * TangentialSpring->delta.getLengthSquared() + pSpecies->getRollingStiffness() * TangentialSpring->RollingSpring.getLengthSquared() + pSpecies->getTorsionStiffness() * TangentialSpring->TorsionSpring.getLengthSquared()) : 0.0)));
714 addElasticEnergy(0.25 * (pSpecies->getStiffness() *
mathsFunc::square(deltan) + (TangentialSpring ? (pSpecies->getSlidingStiffness() * TangentialSpring->delta.getLengthSquared() + pSpecies->getRollingStiffness() * TangentialSpring->RollingSpring.getLengthSquared() + pSpecies->getTorsionStiffness() * TangentialSpring->TorsionSpring.getLengthSquared()) : 0.0)));
716 if (
fStatFile.getSaveCurrentTimeStep() ||
statFile.getSaveCurrentTimeStep() || getDoCGAlways())
720 Mdouble deltat_norm = TangentialSpring ? (-TangentialSpring->delta.getLength()) : 0.0;
732 if (
statFile.getSaveCurrentTimeStep() || getDoCGAlways())
735 fStatFile.
getFstream() <<
getTime() <<
" " << PJreal->
getIndex() <<
" " << PI->
getIndex() <<
" " << centre <<
" " << radii_sum - dist <<
" " << deltat_norm <<
" " << fdotn <<
" " << fdott <<
" " << -normal <<
" " << -(fdott ? forcet / fdott : forcet) << std::endl;
737 if (!PJreal->
isFixed() && !isPeriodic)
739 if (
statFile.getSaveCurrentTimeStep() || getDoCGAlways())
742 fStatFile.
getFstream() <<
getTime() <<
" " << PI->
getIndex() <<
" " << PJreal->
getIndex() <<
" " << centre <<
" " << radii_sum - dist <<
" " << deltat_norm <<
" " << fdotn <<
" " << fdott <<
" " << normal <<
" " << (fdott ? forcet / fdott : forcet) << std::endl;
779 std::stringstream file_name;
780 std::ofstream script_file;
781 file_name <<
getName() <<
".disp";
782 script_file.open((file_name.str()).c_str());
785 script_file <<
"#!/bin/bash" << std::endl;
786 script_file <<
"x=$(echo $0 | cut -c2-)" << std::endl;
787 script_file <<
"file=$PWD$x" << std::endl;
788 script_file <<
"dirname=`dirname \"$file\"`" << std::endl;
789 script_file <<
"cd $dirname" << std::endl;
794 int width = 1570, height = 860;
796 if (ratio > width / height)
797 height = width / ratio;
799 width = height * ratio;
828 script_file <<
"../xballs -format " << format
831 <<
" -w " << width + 140
832 <<
" -h " << height + 140
834 <<
" -cmax -scala 4 -sort -oh 50 "
845 chmod((file_name.str().c_str()),S_IRWXU);
@ R
Definition: StatisticsVector.h:42
virtual unsigned int getNumberOfObjects() const
Gets the number of real Object in this BaseHandler. (i.e. no mpi or periodic particles)
Definition: BaseHandler.h:648
void setStorageCapacity(const unsigned int N)
Sets the storage capacity of this BaseHandler.
Definition: BaseHandler.h:669
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
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
unsigned int getStorageCapacity() const
Gets the storage capacity of this BaseHandler.
Definition: BaseHandler.h:662
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
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Definition: BaseInteractable.h:230
virtual const Vec3D & getAngularVelocity() const
Returns the angular velocity of this interactable.
Definition: BaseInteractable.cc:341
void addTorque(const Vec3D &addTorque)
Adds an amount to the torque on this BaseInteractable.
Definition: BaseInteractable.cc:132
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
Definition: BaseInteractable.cc:329
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
Definition: BaseInteractable.cc:215
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
void addForce(const Vec3D &addForce)
Adds an amount to the force on this BaseInteractable.
Definition: BaseInteractable.cc:116
unsigned int getIndSpecies() const
Returns the index of the species associated with the interactable object.
Definition: BaseInteractable.h:88
unsigned int getIndex() const
Returns the index of the object in the handler.
Definition: BaseObject.h:118
Definition: BaseParticle.h:54
bool isFixed() const override
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...
Definition: BaseParticle.h:93
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
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:348
Mdouble getMass() const
Returns the particle's mass.
Definition: BaseParticle.h:322
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
void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:818
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:50
Particles of a single Species.
Definition: ChuteWithPeriodicInflow.h:38
void set_PeriodicBoxNSpecies(int new_)
Definition: ChuteWithPeriodicInflow.h:883
void set_PeriodicBoxLength(double new_)
Definition: ChuteWithPeriodicInflow.h:875
void integrateBeforeForceComputation()
Update particles' and walls' positions and velocities before force computation.
Definition: ChuteWithPeriodicInflow.h:176
int Check_and_Duplicate_Periodic_Particle(BaseParticle *i, int nWallPeriodic)
Definition: ChuteWithPeriodicInflow.h:748
void ExtendInWidth(int numRepetitionsInWidth)
Definition: ChuteWithPeriodicInflow.h:117
void computeInternalForces(BaseParticle *P1, BaseParticle *P2)
Definition: ChuteWithPeriodicInflow.h:265
void setupInitialConditions() override
Do not add bottom.
Definition: ChuteWithPeriodicInflow.h:172
double getInfo(const BaseParticle &P) const override
A virtual function that returns some user-specified information about a particle.
Definition: ChuteWithPeriodicInflow.h:58
void actionsBeforeTimeStep() override
Do not add, only remove particles.
Definition: ChuteWithPeriodicInflow.h:141
void writeXBallsScript() const
This writes a script which can be used to load the xballs problem to display the data just generated.
Definition: ChuteWithPeriodicInflow.h:776
bool FillChute
Definition: ChuteWithPeriodicInflow.h:901
void outputXBallsDataParticlee(const unsigned int i, const unsigned int format, std::ostream &os) const
Definition: ChuteWithPeriodicInflow.h:849
double PeriodicBoxLength
stores the length of the periodic box
Definition: ChuteWithPeriodicInflow.h:897
SphericalParticle inflowParticle_
Definition: ChuteWithPeriodicInflow.h:893
ChuteWithPeriodicInflow(std::string restart_file, int numRepetitions, int numRepetitionsInWidth)
Definition: ChuteWithPeriodicInflow.h:51
void printTime() const override
add some particular output
Definition: ChuteWithPeriodicInflow.h:226
void AddContinuingBottom(int numRepetitions)
Definition: ChuteWithPeriodicInflow.h:91
bool InPeriodicBox(BaseParticle *P)
Definition: ChuteWithPeriodicInflow.h:888
ChuteWithPeriodicInflow(std::string restart_file, int numRepetitions)
Definition: ChuteWithPeriodicInflow.h:45
double get_PeriodicBoxLength()
Definition: ChuteWithPeriodicInflow.h:871
int PeriodicBoxNSpecies
stores the number of species in the periodic box
Definition: ChuteWithPeriodicInflow.h:899
ChuteWithPeriodicInflow(std::string restart_file)
Definition: ChuteWithPeriodicInflow.h:40
void cleanChute()
Remove particles if they fall below a certain height (allows them to become supercritical)
Definition: ChuteWithPeriodicInflow.h:147
int get_PeriodicBoxNSpecies()
Definition: ChuteWithPeriodicInflow.h:879
void loadPeriodicBox(std::string const restart_file)
loads periodic chute data from restart file
Definition: ChuteWithPeriodicInflow.h:64
Creates chutes with different bottoms. Inherits from Mercury3D (-> MercuryBase -> DPMBase).
Definition: Chute.h:65
Mdouble getMaxInflowParticleRadius() const
Returns the maximum radius of inflow particles.
Definition: Chute.cc:947
bool getIsPeriodic() const
Returns whether the chute is periodic in Y.
Definition: Chute.cc:642
int getXBallsColourMode() const
Get the xballs colour mode (CMode).
Definition: DPMBase.cc:1310
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin.
Definition: DPMBase.h:619
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax.
Definition: DPMBase.h:626
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1488
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1427
double getXBallsVectorScale() const
Returns the scale of vectors used in xballs.
Definition: DPMBase.cc:1330
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1483
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin.
Definition: DPMBase.h:632
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1250
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:399
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:808
std::string getXBallsAdditionalArguments() const
Returns the additional arguments for xballs.
Definition: DPMBase.cc:1355
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1478
void setYMax(Mdouble newYMax)
Sets the value of YMax, the upper bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1191
void setRestarted(bool newRestartedFlag)
Allows to set the flag stating if the simulation is to be restarted or not.
Definition: DPMBase.cc:1501
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1452
void gatherContactStatistics()
Definition: DPMBase.cc:1898
void setXMax(Mdouble newXMax)
Sets the value of XMax, the upper bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1165
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
double getXBallsScale() const
Returns the scale of the view in xballs.
Definition: DPMBase.cc:1372
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax.
Definition: DPMBase.h:638
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: DPMBase.h:1498
unsigned int getSystemDimensions() const
Returns the system dimensionality.
Definition: DPMBase.cc:1430
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax.
Definition: DPMBase.h:650
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin.
Definition: DPMBase.h:644
bool readRestartFile(ReadOptions opt=ReadOptions::ReadAll)
Reads all the particle data corresponding to a given, existing . restart file (for more details regar...
Definition: DPMBase.cc:3006
std::fstream & getFstream()
Allows to access the member variable File::fstream_.
Definition: File.cc:153
const std::string getFullName() const
Also allows to access the file name, however with additional information which is the file counter,...
Definition: File.cc:170
unsigned int getSaveCount() const
Gets File::saveCount_.
Definition: File.cc:255
void hGridUpdateParticle(BaseParticle *obj) override
Updates the cell (not the level) of a BaseParticle.
Definition: Mercury3D.cc:361
void hGridRemoveParticle(BaseParticle *obj) override
Removes a BaseParticle from the HGrid.
Definition: Mercury3D.cc:422
bool getHGridUpdateEachTimeStep() const final
Gets whether or not the HGrid is updated every time step.
Definition: MercuryBase.cc:184
void addObject(BaseParticle *P) override
Adds a BaseParticle to the ParticleHandler.
Definition: ParticleHandler.cc:171
void removeObject(unsigned int index) override
Removes a BaseParticle from the ParticleHandler.
Definition: ParticleHandler.cc:394
unsigned int getNumberOfObjects() const override
Returns the number of objects in the container. In parallel code this practice is forbidden to avoid ...
Definition: ParticleHandler.cc:1325
BaseParticle * getLargestParticle() const
Returns the pointer of the largest particle in the particle handler. When mercury is running in paral...
Definition: ParticleHandler.cc:534
Definition: ParticleSpecies.h:37
Defines a pair of periodic walls. Inherits from BaseBoundary.
Definition: PeriodicBoundary.h:41
Mdouble getDistance(const BaseParticle &p) const override
Returns the distance of the edge to the particle.
Definition: PeriodicBoundary.cc:197
virtual void shiftPosition(BaseParticle *p) const override
shifts the particle
Definition: PeriodicBoundary.cc:219
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
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
Definition: PeriodicBoundary.cc:84
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
Definition: SpeciesHandler.h:74
Contains material and contact force properties.
Definition: Species.h:35
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:37
Mdouble Y
Definition: Vector.h:66
Mdouble Z
Definition: Vector.h:66
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.h:332
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
Mdouble X
the vector components
Definition: Vector.h:66
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Definition: Vector.cc:331
static Mdouble getDistanceSquared(const Vec3D &a, const Vec3D &b)
Calculates the squared distance between two Vec3D: .
Definition: Vector.h:311
void setZero()
Sets all elements to zero.
Definition: Vector.cc:43
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Mdouble getLength() const
Calculates the length of this Vec3D: .
Definition: Vector.cc:320
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:73
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
T square(const T val)
squares a number
Definition: ExtendedMath.h:106