ChuteWithPeriodicInflow Class Reference

Particles of a single Species. More...

#include <ChuteWithPeriodicInflow.h>

+ Inheritance diagram for ChuteWithPeriodicInflow:

Public Member Functions

 ChuteWithPeriodicInflow (std::string restart_file)
 
 ChuteWithPeriodicInflow (std::string restart_file, int numRepetitions)
 
 ChuteWithPeriodicInflow (std::string restart_file, int numRepetitions, int numRepetitionsInWidth)
 
double getInfo (const BaseParticle &P) const override
 A virtual function that returns some user-specified information about a particle. More...
 
void loadPeriodicBox (std::string const restart_file)
 loads periodic chute data from restart file More...
 
void AddContinuingBottom (int numRepetitions)
 
void ExtendInWidth (int numRepetitionsInWidth)
 
void actionsBeforeTimeStep () override
 Do not add, only remove particles. More...
 
void cleanChute ()
 Remove particles if they fall below a certain height (allows them to become supercritical) More...
 
void setupInitialConditions () override
 Do not add bottom. More...
 
void integrateBeforeForceComputation ()
 Update particles' and walls' positions and velocities before force computation. More...
 
void printTime () const override
 add some particular output More...
 
void computeInternalForces (BaseParticle *P1, BaseParticle *P2)
 
int Check_and_Duplicate_Periodic_Particle (BaseParticle *i, int nWallPeriodic)
 
void writeXBallsScript () const
 This writes a script which can be used to load the xballs problem to display the data just generated. More...
 
void outputXBallsDataParticlee (const unsigned int i, const unsigned int format, std::ostream &os) const
 
double get_PeriodicBoxLength ()
 
void set_PeriodicBoxLength (double new_)
 
int get_PeriodicBoxNSpecies ()
 
void set_PeriodicBoxNSpecies (int new_)
 
bool InPeriodicBox (BaseParticle *P)
 
- Public Member Functions inherited from Chute
 Chute ()
 This is the default constructor. All it does is set sensible defaults. More...
 
 Chute (const DPMBase &other)
 Copy constructor, converts an existing DPMBase problem into a Chute problem. More...
 
 Chute (const MercuryBase &other)
 Copy constructor, converts an existing MercuryBase problem into a Chute problem. More...
 
 Chute (const Mercury3D &other)
 Copy constructor, converts an existing Mercury3D problem into a Chute problem. More...
 
 Chute (const Chute &other)
 Default copy constructor. More...
 
void constructor ()
 This is the actual constructor METHOD; it is called by all constructors above (except the default copy constructor). More...
 
bool readNextArgument (int &i, int argc, char *argv[]) override
 This method can be used for reading object properties from a string. More...
 
void setupSideWalls ()
 Creates chute side walls (either solid or periodic) More...
 
void makeChutePeriodic ()
 This makes the chute periodic in Y. More...
 
bool getIsPeriodic () const
 Returns whether the chute is periodic in Y. More...
 
void setupInitialConditions () override
 Creates bottom, side walls and a particle insertion boundary. More...
 
void read (std::istream &is, ReadOptions opt=ReadOptions::ReadAll) override
 Reads all chute properties from an istream. More...
 
void write (std::ostream &os, bool writeAllParticles=true) const override
 This function writes the Chute properties to an ostream, and adds the properties of ALL chute particles as well. More...
 
void setFixedParticleRadius (Mdouble fixedParticleRadius)
 Sets the particle radius of the fixed particles which constitute the (rough) chute bottom. More...
 
Mdouble getFixedParticleRadius () const
 Returns the particle radius of the fixed particles which constitute the (rough) chute bottom. More...
 
void setFixedParticleSpacing (Mdouble fixedParticleSpacing)
 Sets the spacing of the fixed particles which constitute the (rough) chute bottom; used in triangular packing only. More...
 
Mdouble getFixedParticleSpacing () const
 Returns the particle radius of the fixed particles which constitute the (rough) chute bottom; used in triangular packing only. More...
 
void setRoughBottomType (RoughBottomType roughBottomType)
 Sets the type of rough bottom of the chute. More...
 
void setRoughBottomType (std::string roughBottomTypeString)
 Sets the type of rough bottom of the chute, using a string with the EXACT enum type as input. More...
 
RoughBottomType getRoughBottomType () const
 Returns the type of (rough) bottom of the chute. More...
 
void setChuteAngle (Mdouble chuteAngle)
 Sets gravity vector according to chute angle (in degrees) More...
 
void setChuteAngleAndMagnitudeOfGravity (Mdouble chuteAngle, Mdouble gravity)
 Sets gravity vector according to chute angle (in degrees) More...
 
Mdouble getChuteAngle () const
 Returns the chute angle (in radians) More...
 
Mdouble getChuteAngleDegrees () const
 Returns the chute angle (in degrees) More...
 
void setMaxFailed (unsigned int maxFailed)
 Sets the number of times a particle will be tried to be added to the insertion boundary. More...
 
unsigned int getMaxFailed () const
 Returns the number of times a particle will be tried to be added to the insertion boundary. More...
 
void setInflowParticleRadius (Mdouble inflowParticleRadius)
 Sets the radius of the inflow particles to a single one (i.e. ensures a monodisperse inflow). More...
 
void setInflowParticleRadius (Mdouble minInflowParticleRadius, Mdouble maxInflowParticleRadius)
 Sets the minimum and maximum radius of the inflow particles. More...
 
void setMinInflowParticleRadius (Mdouble minInflowParticleRadius)
 sets the minimum radius of inflow particles More...
 
void setMaxInflowParticleRadius (Mdouble maxInflowParticleRadius)
 Sets the maximum radius of inflow particles. More...
 
Mdouble getInflowParticleRadius () const
 Returns the average radius of inflow particles. More...
 
Mdouble getMinInflowParticleRadius () const
 returns the minimum radius of inflow particles More...
 
Mdouble getMaxInflowParticleRadius () const
 Returns the maximum radius of inflow particles. More...
 
void setInflowHeight (Mdouble inflowHeight)
 Sets maximum inflow height (Z-direction) More...
 
Mdouble getInflowHeight () const
 Returns the maximum inflow height (Z-direction) More...
 
void setInflowVelocity (Mdouble inflowVelocity)
 Sets the average inflow velocity. More...
 
Mdouble getInflowVelocity () const
 Returns the average inflow velocity. More...
 
void setInflowVelocityVariance (Mdouble inflowVelocityVariance)
 Sets the inflow velocity variance. More...
 
Mdouble getInflowVelocityVariance () const
 Returns the inflow velocity variance. More...
 
void setChuteWidth (Mdouble chuteWidth)
 Sets the chute width (Y-direction) More...
 
Mdouble getChuteWidth () const
 Returns the chute width (Y-direction) More...
 
virtual void setChuteLength (Mdouble chuteLength)
 Sets the chute length (X-direction) More...
 
Mdouble getChuteLength () const
 Returns the chute length (X-direction) More...
 
void setInsertionBoundary (InsertionBoundary *insertionBoundary)
 Sets the chute insertion boundary. More...
 
- Public Member Functions inherited from Mercury3D
 Mercury3D ()
 This is the default constructor. All it does is set sensible defaults. More...
 
 Mercury3D (const DPMBase &other)
 Copy-constructor for creates an Mercury3D problem from an existing MD problem. More...
 
 Mercury3D (const Mercury3D &other)
 Copy-constructor. More...
 
void constructor ()
 Function that sets the SystemDimension and ParticleDimension to 3. More...
 
std::vector< BaseParticle * > hGridFindParticleContacts (const BaseParticle *obj) override
 Returns all particles that have a contact with a given particle. More...
 
- Public Member Functions inherited from MercuryBase
 MercuryBase ()
 This is the default constructor. It sets sensible defaults. More...
 
 ~MercuryBase () override
 This is the default destructor. More...
 
 MercuryBase (const MercuryBase &mercuryBase)
 Copy-constructor. More...
 
void constructor ()
 This is the actual constructor, it is called do both constructors above. More...
 
void hGridActionsBeforeTimeLoop () override
 This sets up the broad phase information, has to be done at this stage because it requires the particle size. More...
 
void hGridActionsBeforeTimeStep () override
 Performs all necessary actions before a time-step, like updating the particles and resetting all the bucket information, etc. More...
 
void read (std::istream &is, ReadOptions opt=ReadOptions::ReadAll) override
 Reads the MercuryBase from an input stream, for example a restart file. More...
 
void write (std::ostream &os, bool writeAllParticles=true) const override
 Writes all data into a restart file. More...
 
Mdouble getHGridCurrentMaxRelativeDisplacement () const
 Returns hGridCurrentMaxRelativeDisplacement_. More...
 
Mdouble getHGridTotalCurrentMaxRelativeDisplacement () const
 Returns hGridTotalCurrentMaxRelativeDisplacement_. More...
 
void setHGridUpdateEachTimeStep (bool updateEachTimeStep)
 Sets whether or not the HGrid must be updated every time step. More...
 
bool getHGridUpdateEachTimeStep () const final
 Gets whether or not the HGrid is updated every time step. More...
 
void setHGridMaxLevels (unsigned int HGridMaxLevels)
 Sets the maximum number of levels of the HGrid in this MercuryBase. More...
 
unsigned int getHGridMaxLevels () const
 Gets the maximum number of levels of the HGrid in this MercuryBase. More...
 
HGridMethod getHGridMethod () const
 Gets whether the HGrid in this MercuryBase is BOTTOMUP or TOPDOWN. More...
 
void setHGridMethod (HGridMethod hGridMethod)
 Sets the HGridMethod to either BOTTOMUP or TOPDOWN. More...
 
HGridDistribution getHGridDistribution () const
 Gets how the sizes of the cells of different levels are distributed. More...
 
void setHGridDistribution (HGridDistribution hGridDistribution)
 Sets how the sizes of the cells of different levels are distributed. More...
 
Mdouble getHGridCellOverSizeRatio () const
 Gets the ratio of the smallest cell over the smallest particle. More...
 
void setHGridCellOverSizeRatio (Mdouble cellOverSizeRatio)
 Sets the ratio of the smallest cell over the smallest particle. More...
 
bool hGridNeedsRebuilding ()
 Gets if the HGrid needs rebuilding before anything else happens. More...
 
virtual unsigned int getHGridTargetNumberOfBuckets () const
 Gets the desired number of buckets, which is the maximum of the number of particles and 10. More...
 
virtual Mdouble getHGridTargetMinInteractionRadius () const
 Gets the desired size of the smallest cells of the HGrid. More...
 
virtual Mdouble getHGridTargetMaxInteractionRadius () const
 Gets the desired size of the largest cells of the HGrid. More...
 
bool checkParticleForInteraction (const BaseParticle &P) final
 Checks if given BaseParticle has an interaction with a BaseWall or other BaseParticle. More...
 
bool checkParticleForInteractionLocal (const BaseParticle &P) final
 Checks if the given BaseParticle has an interaction with a BaseWall or other BaseParticles in a local domain. More...
 
virtual Mdouble userHGridCellSize (unsigned int level)
 Virtual function that enables inheriting classes to implement a function to let the user set the cell size of the HGrid. More...
 
void hGridInfo (std::ostream &os=std::cout) const
 Writes the info of the HGrid to the screen in a nice format. More...
 
- Public Member Functions inherited from DPMBase
void constructor ()
 A function which initialises the member variables to default values, so that the problem can be solved off the shelf; sets up a basic two dimensional problem which can be solved off the shelf. It is called in the constructor DPMBase(). More...
 
 DPMBase ()
 Constructor that calls the "void constructor()". More...
 
 DPMBase (const DPMBase &other)
 Copy constructor type-2. More...
 
virtual ~DPMBase ()
 virtual destructor More...
 
void autoNumber ()
 The autoNumber() function calls three functions: setRunNumber(), readRunNumberFromFile() and incrementRunNumberInFile(). More...
 
std::vector< int > get1DParametersFromRunNumber (int size_x) const
 This turns a counter into 1 index, which is a useful feature for performing 1D parameter study. The index run from 1:size_x, while the study number starts at 0 (initially the counter=1 in COUNTER_DONOTDEL) More...
 
std::vector< int > get2DParametersFromRunNumber (int size_x, int size_y) const
 This turns a counter into 2 indices which is a very useful feature for performing a 2D study. The indices run from 1:size_x and 1:size_y, while the study number starts at 0 ( initially the counter=1 in COUNTER_DONOTDEL) More...
 
std::vector< int > get3DParametersFromRunNumber (int size_x, int size_y, int size_z) const
 This turns a counter into 3 indices, which is a useful feature for performing a 3D parameter study. The indices run from 1:size_x, 1:size_y and 1:size_z, while the study number starts at 0 ( initially the counter=1 in COUNTER_DONOTDEL) More...
 
int launchNewRun (const char *name, bool quick=false)
 This launches a code from within this code. Please pass the name of the code to run. More...
 
void setRunNumber (int runNumber)
 This sets the counter/Run number, overriding the defaults. More...
 
int getRunNumber () const
 This returns the current value of the counter (runNumber_) More...
 
virtual void decompose ()
 Sends particles from processorId to the root processor. More...
 
void solve ()
 The work horse of the code. More...
 
void initialiseSolve ()
 Beginning of the solve routine, before time stepping. More...
 
void finaliseSolve ()
 End of the solve routine, after time stepping. More...
 
virtual void computeOneTimeStep ()
 Performs everything needed for one time step, used in the time-loop of solve(). More...
 
void checkSettings ()
 Checks if the essentials are set properly to go ahead with solving the problem. More...
 
void forceWriteOutputFiles ()
 Writes output files immediately, even if the current time step was not meant to be written. Also resets the last saved time step. More...
 
virtual void writeOutputFiles ()
 Writes simulation data to all the main Mercury files: .data, .ene, .fstat, .xballs and .restart (see the Mercury website for more details regarding these files). More...
 
void solve (int argc, char *argv[])
 The work horse of the code. Can handle flags from the command line. More...
 
ParticleVtkWritergetVtkWriter () const
 
virtual void writeRestartFile ()
 Stores all the particle data for current save time step to a "restart" file, which is a file simply intended to store all the information necessary to "restart" a simulation from a given time step (see also MercuryDPM.org for more information on restart files). More...
 
void writeDataFile ()
 
void writeEneFile ()
 
void writeFStatFile ()
 
void fillDomainWithParticles (unsigned N=50)
 
bool readRestartFile (ReadOptions opt=ReadOptions::ReadAll)
 Reads all the particle data corresponding to a given, existing . restart file (for more details regarding restart files, refer to the training materials on the MercuryDPM website).Returns true if it is successful, false otherwise. More...
 
int readRestartFile (std::string fileName, ReadOptions opt=ReadOptions::ReadAll)
 The same as readRestartFile(bool), but also reads all the particle data corresponding to the current saved time step. More...
 
virtual BaseWallreadUserDefinedWall (const std::string &type) const
 Allows you to read in a wall defined in a Driver directory; see USER/Luca/ScrewFiller. More...
 
virtual void readOld (std::istream &is)
 Reads all data from a restart file, e.g. domain data and particle data; old version. More...
 
bool readDataFile (std::string fileName="", unsigned int format=0)
 This allows particle data to be reloaded from data files. More...
 
bool readParAndIniFiles (std::string fileName)
 Allows the user to read par.ini files (useful to read files produced by the MDCLR simulation code - external to MercuryDPM) More...
 
bool readNextDataFile (unsigned int format=0)
 Reads the next data file with default format=0. However, one can modify the format based on whether the particle data corresponds to 3D or 2D data- see Visualising data in xballs. More...
 
void readNextFStatFile ()
 Reads the next fstat file. More...
 
bool findNextExistingDataFile (Mdouble tMin, bool verbose=true)
 Finds and opens the next data file, if such a file exists. More...
 
bool readArguments (int argc, char *argv[])
 Can interpret main function input arguments that are passed by the driver codes. More...
 
bool checkParticleForInteractionLocalPeriodic (const BaseParticle &P)
 
void readSpeciesFromDataFile (bool read=true)
 
void importParticlesAs (ParticleHandler &particleHandler, InteractionHandler &interactionHandler, const ParticleSpecies *species)
 Copies particles, interactions assigning species from a local simulation to a global one. Useful for the creation of a cluster. More...
 
MERCURYDPM_DEPRECATED FilegetDataFile ()
 The non const version. Allows one to edit the File::dataFile. More...
 
MERCURYDPM_DEPRECATED FilegetEneFile ()
 The non const version. Allows to edit the File::eneFile. More...
 
MERCURYDPM_DEPRECATED FilegetFStatFile ()
 The non const version. Allows to edit the File::fStatFile. More...
 
MERCURYDPM_DEPRECATED FilegetRestartFile ()
 The non const version. Allows to edit the File::restartFile. More...
 
MERCURYDPM_DEPRECATED FilegetStatFile ()
 The non const version. Allows to edit the File::statFile. More...
 
FilegetInteractionFile ()
 Return a reference to the file InteractionsFile. More...
 
MERCURYDPM_DEPRECATED const FilegetDataFile () const
 The const version. Does not allow for any editing of the File::dataFile. More...
 
MERCURYDPM_DEPRECATED const FilegetEneFile () const
 The const version. Does not allow for any editing of the File::eneFile. More...
 
MERCURYDPM_DEPRECATED const FilegetFStatFile () const
 The const version. Does not allow for any editing of the File::fStatFile. More...
 
MERCURYDPM_DEPRECATED const FilegetRestartFile () const
 The const version. Does not allow for any editing of the File::restartFile. More...
 
MERCURYDPM_DEPRECATED const FilegetStatFile () const
 The const version. Does not allow for any editing of the File::statFile. More...
 
const FilegetInteractionFile () const
 
const std::string & getName () const
 Returns the name of the file. Does not allow to change it though. More...
 
void setName (const std::string &name)
 Allows to set the name of all the files (ene, data, fstat, restart, stat) More...
 
void setName (const char *name)
 Calls setName(std::string) More...
 
void setSaveCount (unsigned int saveCount)
 Sets File::saveCount_ for all files (ene, data, fstat, restart, stat) More...
 
void setFileType (FileType fileType)
 Sets File::fileType_ for all files (ene, data, fstat, restart, stat) More...
 
void setOpenMode (std::fstream::openmode openMode)
 Sets File::openMode_ for all files (ene, data, fstat, restart, stat) More...
 
void resetFileCounter ()
 Resets the file counter for each file i.e. for ene, data, fstat, restart, stat) More...
 
void closeFiles ()
 Closes all files (ene, data, fstat, restart, stat) that were opened to read or write. More...
 
void setLastSavedTimeStep (unsigned int nextSavedTimeStep)
 Sets the next time step for all the files (ene, data, fstat, restart, stat) at which the data is to be written or saved. More...
 
Mdouble getTime () const
 Returns the current simulation time. More...
 
Mdouble getNextTime () const
 Returns the current simulation time. More...
 
unsigned int getNumberOfTimeSteps () const
 Returns the current counter of time-steps, i.e. the number of time-steps that the simulation has undergone so far. More...
 
void setTime (Mdouble time)
 Sets a new value for the current simulation time. More...
 
void setTimeMax (Mdouble newTMax)
 Sets a new value for the maximum simulation duration. More...
 
Mdouble getTimeMax () const
 Returns the maximum simulation duration. More...
 
void setLogarithmicSaveCount (Mdouble logarithmicSaveCountBase)
 Sets File::logarithmicSaveCount_ for all files (ene, data, fstat, restart, stat) More...
 
void setNToWrite (int nToWrite)
 set the number of elements to write to the screen More...
 
int getNToWrite () const
 get the number of elements to write to the More...
 
void setRotation (bool rotation)
 Sets whether particle rotation is enabled or disabled. More...
 
bool getRotation () const
 Indicates whether particle rotation is enabled or disabled. More...
 
MERCURYDPM_DEPRECATED void setWallsWriteVTK (FileType writeWallsVTK)
 Sets whether walls are written into a VTK file. More...
 
MERCURYDPM_DEPRECATED void setWallsWriteVTK (bool)
 Sets whether walls are written into a VTK file. More...
 
MERCURYDPM_DEPRECATED void setInteractionsWriteVTK (bool)
 Sets whether interactions are written into a VTK file. More...
 
void setParticlesWriteVTK (bool writeParticlesVTK)
 Sets whether particles are written in a VTK file. More...
 
void setSuperquadricParticlesWriteVTK (bool writeSuperquadricParticlesVTK)
 
MERCURYDPM_DEPRECATED FileType getWallsWriteVTK () const
 Returns whether walls are written in a VTK file. More...
 
bool getParticlesWriteVTK () const
 Returns whether particles are written in a VTK file. More...
 
bool getSuperquadricParticlesWriteVTK () const
 
Mdouble getXMin () const
 If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin. More...
 
Mdouble getXMax () const
 If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax. More...
 
Mdouble getYMin () const
 If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin. More...
 
Mdouble getYMax () const
 If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax. More...
 
Mdouble getZMin () const
 If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin. More...
 
Mdouble getZMax () const
 If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax. More...
 
Mdouble getXCenter () const
 
Mdouble getYCenter () const
 
Mdouble getZCenter () const
 
Vec3D getMin () const
 
Vec3D getMax () const
 
void setXMin (Mdouble newXMin)
 Sets the value of XMin, the lower bound of the problem domain in the x-direction. More...
 
void setYMin (Mdouble newYMin)
 Sets the value of YMin, the lower bound of the problem domain in the y-direction. More...
 
void setZMin (Mdouble newZMin)
 Sets the value of ZMin, the lower bound of the problem domain in the z-direction. More...
 
void setXMax (Mdouble newXMax)
 Sets the value of XMax, the upper bound of the problem domain in the x-direction. More...
 
void setYMax (Mdouble newYMax)
 Sets the value of YMax, the upper bound of the problem domain in the y-direction. More...
 
void setZMax (Mdouble newZMax)
 Sets the value of ZMax, the upper bound of the problem domain in the z-direction. More...
 
void setMax (const Vec3D &max)
 Sets the maximum coordinates of the problem domain. More...
 
void setMax (Mdouble, Mdouble, Mdouble)
 Sets the maximum coordinates of the problem domain. More...
 
void setDomain (const Vec3D &min, const Vec3D &max)
 Sets the minimum coordinates of the problem domain. More...
 
void setMin (const Vec3D &min)
 Sets the minimum coordinates of the problem domain. More...
 
void setMin (Mdouble, Mdouble, Mdouble)
 Sets the minimum coordinates of the problem domain. More...
 
void setTimeStep (Mdouble newDt)
 Sets a new value for the simulation time step. More...
 
Mdouble getTimeStep () const
 Returns the simulation time step. More...
 
void setNumberOfOMPThreads (int numberOfOMPThreads)
 
int getNumberOfOMPThreads () const
 
void setXBallsColourMode (int newCMode)
 Set the xballs output mode. More...
 
int getXBallsColourMode () const
 Get the xballs colour mode (CMode). More...
 
void setXBallsVectorScale (double newVScale)
 Set the scale of vectors in xballs. More...
 
double getXBallsVectorScale () const
 Returns the scale of vectors used in xballs. More...
 
void setXBallsAdditionalArguments (std::string newXBArgs)
 Set the additional arguments for xballs. More...
 
std::string getXBallsAdditionalArguments () const
 Returns the additional arguments for xballs. More...
 
void setXBallsScale (Mdouble newScale)
 Sets the scale of the view (either normal, zoom in or zoom out) to display in xballs. The default is fit to screen. More...
 
double getXBallsScale () const
 Returns the scale of the view in xballs. More...
 
void setGravity (Vec3D newGravity)
 Sets a new value for the gravitational acceleration. More...
 
Vec3D getGravity () const
 Returns the gravitational acceleration. More...
 
void setBackgroundDrag (Mdouble backgroundDrag)
 Simple access function to turn on a background drag. The force of particleVelocity*drag is applied (note, it allowd to be negaitve i.e. create energy) More...
 
const Mdouble getBackgroundDrag () const
 Return the background drag. More...
 
void setDimension (unsigned int newDim)
 Sets both the system dimensions and the particle dimensionality. More...
 
void setSystemDimensions (unsigned int newDim)
 Sets the system dimensionality. More...
 
unsigned int getSystemDimensions () const
 Returns the system dimensionality. More...
 
void setParticleDimensions (unsigned int particleDimensions)
 Sets the particle dimensionality. More...
 
unsigned int getParticleDimensions () const
 Returns the particle dimensionality. More...
 
std::string getRestartVersion () const
 This is to take into account for different Mercury versions. Returns the version of the restart file. More...
 
void setRestartVersion (std::string newRV)
 Sets restart_version. More...
 
bool getRestarted () const
 Returns the flag denoting if the simulation was restarted or not. More...
 
void setRestarted (bool newRestartedFlag)
 Allows to set the flag stating if the simulation is to be restarted or not. More...
 
bool getAppend () const
 Returns whether the "append" option is on or off. More...
 
void setAppend (bool newAppendFlag)
 Sets whether the "append" option is on or off. More...
 
Mdouble getElasticEnergy () const
 Returns the global elastic energy within the system. More...
 
Mdouble getKineticEnergy () const
 Returns the global kinetic energy stored in the system. More...
 
Mdouble getGravitationalEnergy () const
 Returns the global gravitational potential energy stored in the system. More...
 
Mdouble getRotationalEnergy () const
 JMFT Returns the global rotational energy stored in the system. More...
 
Mdouble getTotalEnergy () const
 
Mdouble getTotalMass () const
 JMFT: Return the total mass of the system, excluding fixed particles. More...
 
Vec3D getCentreOfMass () const
 JMFT: Return the centre of mass of the system, excluding fixed particles. More...
 
Vec3D getTotalMomentum () const
 JMFT: Return the total momentum of the system, excluding fixed particles. More...
 
double getCPUTime ()
 
double getWallTime ()
 
virtual void hGridInsertParticle (BaseParticle *obj UNUSED)
 
virtual void hGridUpdateParticle (BaseParticle *obj UNUSED)
 
virtual void hGridRemoveParticle (BaseParticle *obj UNUSED)
 
bool mpiIsInCommunicationZone (BaseParticle *particle)
 Checks if the position of the particle is in an mpi communication zone or not. More...
 
bool mpiInsertParticleCheck (BaseParticle *P)
 Function that checks if the mpi particle should really be inserted by the current domain. More...
 
void insertGhostParticle (BaseParticle *P)
 This function inserts a particle in the mpi communication boundaries. More...
 
void updateGhostGrid (BaseParticle *P)
 Checks if the Domain/periodic interaction distance needs to be updated and updates it accordingly. More...
 
virtual void gatherContactStatistics (unsigned int index1, int index2, Vec3D Contact, Mdouble delta, Mdouble ctheta, Mdouble fdotn, Mdouble fdott, Vec3D P1_P2_normal_, Vec3D P1_P2_tangential)
 //Not unsigned index because of possible wall collisions. More...
 
void setNumberOfDomains (std::vector< unsigned > direction)
 Sets the number of domains in x-,y- and z-direction. Required for parallel computations. More...
 
void splitDomain (DomainSplit domainSplit)
 
std::vector< unsigned > getNumberOfDomains ()
 returns the number of domains More...
 
DomaingetCurrentDomain ()
 Function that returns a pointer to the domain corresponding to the processor. More...
 
void removeOldFiles () const
 
void setMeanVelocity (Vec3D V_mean_goal)
 This function will help you set a fixed kinetic energy and mean velocity in your system. More...
 
void setMeanVelocityAndKineticEnergy (Vec3D V_mean_goal, Mdouble Ek_goal)
 This function will help you set a fixed kinetic energy and mean velocity in your system. More...
 
Mdouble getTotalVolume () const
 Get the total volume of the cuboid system. More...
 
Matrix3D getKineticStress () const
 Calculate the kinetic stress tensor in the system averaged over the whole volume. More...
 
Matrix3D getStaticStress () const
 Calculate the static stress tensor in the system averaged over the whole volume. More...
 
Matrix3D getTotalStress () const
 Calculate the total stress tensor in the system averaged over the whole volume. More...
 
virtual void handleParticleRemoval (unsigned int id)
 Handles the removal of particles from the particleHandler. More...
 
virtual void handleParticleAddition (unsigned int id, BaseParticle *p)
 
void writePythonFileForVTKVisualisation () const
 
void setWritePythonFileForVTKVisualisation (bool forceWritePythonFileForVTKVisualisation)
 
bool getWritePythonFileForVTKVisualisation () const
 
WallVTKWritergetWallVTKWriter ()
 

Public Attributes

SphericalParticle inflowParticle_
 
- Public Attributes inherited from DPMBase
SpeciesHandler speciesHandler
 A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc. More...
 
RNG random
 This is a random generator, often used for setting up the initial conditions etc... More...
 
ParticleHandler particleHandler
 An object of the class ParticleHandler, contains the pointers to all the particles created. More...
 
ParticleHandler paoloParticleHandler
 Fake particleHandler created by Paolo needed temporary by just Paolo. More...
 
WallHandler wallHandler
 An object of the class WallHandler. Contains pointers to all the walls created. More...
 
BoundaryHandler boundaryHandler
 An object of the class BoundaryHandler which concerns insertion and deletion of particles into or from regions. More...
 
PeriodicBoundaryHandler periodicBoundaryHandler
 Internal handler that deals with periodic boundaries, especially in a parallel build. More...
 
DomainHandler domainHandler
 An object of the class DomainHandler which deals with parallel code. More...
 
InteractionHandler interactionHandler
 An object of the class InteractionHandler. More...
 
CGHandler cgHandler
 Object of the class cgHandler. More...
 
File dataFile
 An instance of class File to handle in- and output into a .data file. More...
 
File fStatFile
 An instance of class File to handle in- and output into a .fstat file. More...
 
File eneFile
 An instance of class File to handle in- and output into a .ene file. More...
 
File restartFile
 An instance of class File to handle in- and output into a .restart file. More...
 
File statFile
 An instance of class File to handle in- and output into a .stat file. More...
 
File interactionFile
 File class to handle in- and output into .interactions file. This file hold information about interactions. More...
 
Time clock_
 record when the simulation started More...
 

Private Attributes

double PeriodicBoxLength
 stores the length of the periodic box More...
 
int PeriodicBoxNSpecies
 stores the number of species in the periodic box More...
 
bool FillChute
 

Additional Inherited Members

- Public Types inherited from DPMBase
enum class  ReadOptions : int { ReadAll , ReadNoInteractions , ReadNoParticlesAndInteractions }
 
enum class  DomainSplit {
  X , Y , Z , XY ,
  XZ , YZ , XYZ
}
 
- Static Public Member Functions inherited from DPMBase
static void incrementRunNumberInFile ()
 Increment the run Number (counter value) stored in the file_counter (COUNTER_DONOTDEL) by 1 and store the new value in the counter file. More...
 
static int readRunNumberFromFile ()
 Read the run number or the counter from the counter file (COUNTER_DONOTDEL) More...
 
static bool areInContact (const BaseParticle *pI, const BaseParticle *pJ)
 Checks if two particle are in contact or is there any positive overlap. More...
 
- Protected Member Functions inherited from Chute
void actionsBeforeTimeStep () override
 Calls Chute::cleanChute(). More...
 
void cleanChute ()
 Deletes all outflow particles once every 100 time steps. More...
 
virtual void createBottom ()
 Creates the chute bottom, which can be either flat or one of three flavours of rough. More...
 
virtual void addFlowParticlesCompactly ()
 Add initial flow particles in a dense packing. More...
 
virtual SphericalParticle createFlowParticle ()
 
void printTime () const override
 prints time, max time and number of particles More...
 
- Protected Member Functions inherited from Mercury3D
void hGridFindContactsWithinTargetCell (int x, int y, int z, unsigned int l)
 Finds contacts between particles in the target cell. More...
 
void hGridFindContactsWithTargetCell (int x, int y, int z, unsigned int l, BaseParticle *obj)
 Finds contacts between the BaseParticle and the target cell. More...
 
void computeWallForces (BaseWall *w) override
 Compute contacts with a wall. More...
 
void hGridFindParticlesWithTargetCell (int x, int y, int z, unsigned int l, BaseParticle *obj, std::vector< BaseParticle * > &list)
 Finds particles within target cell and stores them in a list. More...
 
void hGridGetInteractingParticleList (BaseParticle *obj, std::vector< BaseParticle * > &list) override
 Obtains all neighbour particles of a given object, obtained from the hgrid. More...
 
void computeInternalForces (BaseParticle *obj) override
 Finds contacts with the BaseParticle; avoids multiple checks. More...
 
bool hGridHasContactsInTargetCell (int x, int y, int z, unsigned int l, const BaseParticle *obj) const
 Tests if the BaseParticle has contacts with other Particles in the target cell. More...
 
bool hGridHasParticleContacts (const BaseParticle *obj) override
 Tests if a BaseParticle has any contacts in the HGrid. More...
 
void hGridRemoveParticle (BaseParticle *obj) override
 Removes a BaseParticle from the HGrid. More...
 
void hGridUpdateParticle (BaseParticle *obj) override
 Updates the cell (not the level) of a BaseParticle. More...
 
- Protected Member Functions inherited from MercuryBase
void hGridRebuild ()
 This sets up the parameters required for the contact model. More...
 
void hGridInsertParticle (BaseParticle *obj) final
 Inserts a single Particle to current grid. More...
 
void hGridUpdateMove (BaseParticle *iP, Mdouble move) final
 Computes the relative displacement of the given BaseParticle and updates the currentMaxRelativeDisplacement_ accordingly. More...
 
void hGridActionsBeforeIntegration () override
 Resets the currentMaxRelativeDisplacement_ to 0. More...
 
void hGridActionsAfterIntegration () override
 This function has to be called before integrateBeforeForceComputation. More...
 
HGridgetHGrid ()
 Gets the HGrid used by this problem. More...
 
const HGridgetHGrid () const
 Gets the HGrid used by this problem, const version. More...
 
bool readNextArgument (int &i, int argc, char *argv[]) override
 Reads the next command line argument. More...
 
- Protected Member Functions inherited from DPMBase
virtual void computeAllForces ()
 Computes all the forces acting on the particles using the BaseInteractable::setForce() and BaseInteractable::setTorque() More...
 
virtual void computeInternalForce (BaseParticle *, BaseParticle *)
 Computes the forces between two particles (internal in the sense that the sum over all these forces is zero i.e. fully modelled forces) More...
 
virtual void computeExternalForces (BaseParticle *)
 Computes the external forces, such as gravity, acting on particles. More...
 
virtual void computeForcesDueToWalls (BaseParticle *, BaseWall *)
 Computes the forces on the particles due to the walls (normals are outward normals) More...
 
virtual void actionsOnRestart ()
 A virtual function where the users can add extra code which is executed only when the code is restarted. More...
 
virtual void actionsBeforeTimeLoop ()
 A virtual function. Allows one to carry out any operations before the start of the time loop. More...
 
virtual void computeAdditionalForces ()
 A virtual function which allows to define operations to be executed prior to the OMP force collect. More...
 
virtual void actionsAfterSolve ()
 A virtual function which allows to define operations to be executed after the solve(). More...
 
virtual void actionsAfterTimeStep ()
 A virtual function which allows to define operations to be executed after time step. More...
 
void writeVTKFiles () const
 
virtual void outputXBallsData (std::ostream &os) const
 This function writes the location of the walls and particles in a format the XBalls program can read. For more information on the XBalls program, see Visualising data in xballs. More...
 
virtual void outputXBallsDataParticle (unsigned int i, unsigned int format, std::ostream &os) const
 This function writes out the particle locations into an output stream in a format the XBalls program can read. For more information on the XBalls program, see Visualising data in xballs. More...
 
virtual void writeEneHeader (std::ostream &os) const
 Writes a header with a certain format for ENE file. More...
 
virtual void writeFstatHeader (std::ostream &os) const
 Writes a header with a certain format for FStat file. More...
 
virtual void writeEneTimeStep (std::ostream &os) const
 Write the global kinetic, potential energy, etc. in the system. More...
 
virtual void initialiseStatistics ()
 
virtual void outputStatistics ()
 
void gatherContactStatistics ()
 
virtual void processStatistics (bool)
 
virtual void finishStatistics ()
 
virtual void integrateAfterForceComputation ()
 Update particles' and walls' positions and velocities after force computation. More...
 
virtual void checkInteractionWithBoundaries ()
 There are a range of boundaries one could implement depending on ones' problem. This methods checks for interactions between particles and such range of boundaries. See BaseBoundary.h and all the boundaries in the Boundaries folder. More...
 
void setFixedParticles (unsigned int n)
 Sets a number, n, of particles in the particleHandler as "fixed particles". More...
 
virtual bool continueSolve () const
 A virtual function for deciding whether to continue the simulation, based on a user-specified criterion. More...
 
void outputInteractionDetails () const
 Displays the interaction details corresponding to the pointer objects in the interaction handler. More...
 
bool isTimeEqualTo (Mdouble time) const
 Checks whether the input variable "time" is the current time in the simulation. More...
 
void removeDuplicatePeriodicParticles ()
 Removes periodic duplicate Particles. More...
 
void checkAndDuplicatePeriodicParticles ()
 For simulations using periodic boundaries, checks and adds particles when necessary into the particle handler. See DPMBase.cc and PeriodicBoundary.cc for more details. More...
 
void performGhostParticleUpdate ()
 When the Verlet scheme updates the positions and velocities of particles, ghost particles will need an update as wel. Their status will also be updated accordingly. More...
 
void deleteGhostParticles (std::set< BaseParticle * > &particlesToBeDeleted)
 
void synchroniseParticle (BaseParticle *, unsigned fromProcessor=0)
 
void performGhostVelocityUpdate ()
 updates the final time-step velocity of the ghost particles More...
 
void setSoftStop ()
 function for setting sigaction constructor. More...
 
- Static Protected Member Functions inherited from DPMBase
static void signalHandler (int signal)
 signal handler function. More...
 

Detailed Description

Particles of a single Species.

Constructor & Destructor Documentation

◆ ChuteWithPeriodicInflow() [1/3]

ChuteWithPeriodicInflow::ChuteWithPeriodicInflow ( std::string  restart_file)
inline
41  {
42  loadPeriodicBox(restart_file);
43  }
void loadPeriodicBox(std::string const restart_file)
loads periodic chute data from restart file
Definition: ChuteWithPeriodicInflow.h:64

References loadPeriodicBox().

◆ ChuteWithPeriodicInflow() [2/3]

ChuteWithPeriodicInflow::ChuteWithPeriodicInflow ( std::string  restart_file,
int  numRepetitions 
)
inline
46  {
47  loadPeriodicBox(restart_file);
48  AddContinuingBottom(numRepetitions);
49  }
void AddContinuingBottom(int numRepetitions)
Definition: ChuteWithPeriodicInflow.h:91

References AddContinuingBottom(), and loadPeriodicBox().

◆ ChuteWithPeriodicInflow() [3/3]

ChuteWithPeriodicInflow::ChuteWithPeriodicInflow ( std::string  restart_file,
int  numRepetitions,
int  numRepetitionsInWidth 
)
inline
52  {
53  loadPeriodicBox(restart_file);
54  AddContinuingBottom(numRepetitions);
55  ExtendInWidth(numRepetitionsInWidth);
56  }
void ExtendInWidth(int numRepetitionsInWidth)
Definition: ChuteWithPeriodicInflow.h:117

References AddContinuingBottom(), ExtendInWidth(), and loadPeriodicBox().

Member Function Documentation

◆ actionsBeforeTimeStep()

void ChuteWithPeriodicInflow::actionsBeforeTimeStep ( )
inlineoverridevirtual

Do not add, only remove particles.

Reimplemented from DPMBase.

142  {
143  cleanChute();
144  }
void cleanChute()
Remove particles if they fall below a certain height (allows them to become supercritical)
Definition: ChuteWithPeriodicInflow.h:147

References cleanChute().

◆ AddContinuingBottom()

void ChuteWithPeriodicInflow::AddContinuingBottom ( int  numRepetitions)
inline
92  {
93  // creates bottom outside periodic chute of species 1
94  double lengthPeriodicChute = getXMax();
96  particleHandler.setStorageCapacity(N * (2. + numRepetitions));
97  //allows for a gap between the infow and flow regimes
98  double Gap = 0.;
99 
100  for (int j = 1; j < numRepetitions; j++)
101  {
102  for (int i = 0; i < N; i++)
103  {
105  {
108  particleHandler.getLastObject()->move(Vec3D(Gap + lengthPeriodicChute * j, 0., 0.));
109  }
110  }
111  }
112 
113  setXMax(numRepetitions * lengthPeriodicChute);
114  //setHGridNumberOfBucketsToPower(particleHandler.getStorageCapacity());
115  }
void setStorageCapacity(const unsigned int N)
Sets the storage capacity of this BaseHandler.
Definition: BaseHandler.h:669
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
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
Definition: BaseInteractable.cc:215
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
virtual BaseParticle * copy() const =0
Particle copy method. It calls to copy constructor of this Particle, useful for polymorphism.
void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:818
bool FillChute
Definition: ChuteWithPeriodicInflow.h:901
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax.
Definition: DPMBase.h:626
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1427
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
void addObject(BaseParticle *P) override
Adds a BaseParticle to the ParticleHandler.
Definition: ParticleHandler.cc:171
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
Definition: Vector.h:51
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References ParticleHandler::addObject(), BaseParticle::copy(), FillChute, BaseHandler< T >::getLastObject(), ParticleHandler::getNumberOfObjects(), BaseHandler< T >::getObject(), DPMBase::getXMax(), constants::i, BaseParticle::isFixed(), BaseInteractable::move(), DPMBase::particleHandler, BaseParticle::setSpecies(), BaseHandler< T >::setStorageCapacity(), DPMBase::setXMax(), and DPMBase::speciesHandler.

Referenced by ChuteWithPeriodicInflow().

◆ Check_and_Duplicate_Periodic_Particle()

int ChuteWithPeriodicInflow::Check_and_Duplicate_Periodic_Particle ( BaseParticle i,
int  nWallPeriodic 
)
inline

assumes first periodic wall is in x direction

749  {
750  int C = 0; //Number of particles created
751  for (int k = nWallPeriodic; k < getIsPeriodic(); k++)
752  { //Loop over all still posible walls
755  if ((k ? true : InPeriodicBox(i)) && (perw->getDistance(*i) < i->getRadius() + getMaxInflowParticleRadius()))
756  {
757  SphericalParticle F0 = *i;
758  perw->shiftPosition(i);
759 
760  //If Particle is Mdouble shifted, get correct original particle
761  BaseParticle* From = i;
762  while (From->getPeriodicFromParticle() != NULL)
763  From = From->getPeriodicFromParticle();
764  F0.setPeriodicFromParticle(From);
765 
767  C++;
768 
769  //Check for Mdouble shifted particles
771  }
772  }
773  return (C);
774  }
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
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
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Definition: BaseParticle.h:341
int Check_and_Duplicate_Periodic_Particle(BaseParticle *i, int nWallPeriodic)
Definition: ChuteWithPeriodicInflow.h:748
bool InPeriodicBox(BaseParticle *P)
Definition: ChuteWithPeriodicInflow.h:888
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
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1452
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
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:37

References DPMBase::boundaryHandler, BaseHandler< T >::copyAndAddObject(), PeriodicBoundary::getDistance(), Chute::getIsPeriodic(), BaseHandler< T >::getLastObject(), Chute::getMaxInflowParticleRadius(), BaseHandler< T >::getObject(), BaseParticle::getPeriodicFromParticle(), constants::i, InPeriodicBox(), DPMBase::particleHandler, BaseParticle::setPeriodicFromParticle(), and PeriodicBoundary::shiftPosition().

◆ cleanChute()

void ChuteWithPeriodicInflow::cleanChute ( )
inline

Remove particles if they fall below a certain height (allows them to become supercritical)

148  {
149  //clean outflow every 100 time steps
150  static int count = 0, maxcount = 100;
151  if (count > maxcount)
152  {
153  count = 0;
154  // delete all outflowing particles
155  for (unsigned int i = 0; i < particleHandler.getNumberOfObjects();)
156  {
157  //~ if (particleHandler.getObject(i)->getPosition().Z<getZMin()-10*getInflowParticleRadius()){
159  {
160  //~ cout << "Remove particle" << endl;
162  }
163  else
164  i++;
165  }
166  }
167  else
168  count++;
169  }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
void removeObject(unsigned int index) override
Removes a BaseParticle from the ParticleHandler.
Definition: ParticleHandler.cc:394
Mdouble X
the vector components
Definition: Vector.h:66

References ParticleHandler::getNumberOfObjects(), BaseHandler< T >::getObject(), BaseInteractable::getPosition(), DPMBase::getXMax(), constants::i, DPMBase::particleHandler, ParticleHandler::removeObject(), and Vec3D::X.

Referenced by actionsBeforeTimeStep().

◆ computeInternalForces()

void ChuteWithPeriodicInflow::computeInternalForces ( BaseParticle P1,
BaseParticle P2 
)
inline

Tangential spring information is always store in the real particle with highest index When a Periodic contact is encountered it is always encoutered twice (for normal periodic walls), but the force is only applied to the real particle The tangential spring information for periodic particles is stored in the normal particle (and thus twice for normal periodic interactions) When a Particle is removed the tangential spring information has to be moved

Both options are up to first order the same (the first one is nicer becaus it always keeps the spring tangential, whereas the second one is in a nicer intergration form)

Todo:
{The spring should be cut back such that fdott=mu*fdotn. This is simple for getSlidingDissipation()=0; we have to think about what happens in the sliding case with tang. dissipation; same for walls; Update Dec-2-2011: fixed}
Todo:
TW: the following 13 lines concern only the sliding spring and could be moved into the if statement above
Todo:
Define the center this way or are radii involved? Or maybe just use middle of overlap region? Thomas: Yes, we should correct that for polydispersed problems; however, then we also have to correct it in StatisticsVector::gatherContactStatistics.

The second particle (i.e. the particle the force acts on) is always a flow particle

Todo:
{Is it the first particle the force acts on?}
266  {
267 <<<<<<< .mine
268  // For particles of the same species, set species vector to Species(PI);
269  // for particles of different species, set species vector to MixedSpecies(PI,PJ)
270  BaseSpecies* pSpecies = (PI->getIndSpecies() == PJ->getIndSpecies()) ? &Species[PI->getIndSpecies()] : speciesHandler.getMixedObject(PI->getIndSpecies(), PJ->getIndSpecies());
271 =======
272  //this is because the rough bottom allows overlapping fixed particles
273  if (P1->isFixed() && P2->isFixed())
274  return;
275 >>>>>>> .r824
276 
281 
282  //Dificult cases for tangential springs in comination with periodic walls are:
283  //
284  // A new contact over a periodic wall:
285  // Starting situation: There are no tangential springs stored at all
286  // Creating periodic particles: There are no tangential springs so nothing happens
287  // Contact detection: There are two contacts detected, one (CA) for P1 with P2per and one (CB) for P2 with P1per
288  // Switch to the 4 cases:
289  // CA: PI=P1, PJ=P2per PJreal=P2
290  // CB: PI=P2, PJ=P1per PJreal=P1
291  // Reconnecting springs:
292  // CA: PI=P1 and PJ=P2per do not have a spring, so a new spring is created in either PI or PJ (could be in periodic particle)
293  // CB: PI=P2 and PJ=P1Per do not have a spring, so a new spring is created in either PI or PJ (could be in periodic particle)
294  // Removing periodic particles: One of the springs will be stored in a periodic particle and thus removed, the other spring is kept and used (this is the real particle with the kighest index)
295 
296  // Reconnect to a contact over a periodic wall:
297  // Starting situation: There is a tangential spring stored in the particle with the highest index, lets assume this is P1
298  // Creating periodic particles: P1 has a tangential spring, so P1per has a reversed copy of this spring
299  // Contact detection: There are two contacts detected, one (CA) for P1 with P2per and one (CB) for P2 with P1per
300  // Switch to the 4 cases:
301  // CA: PI=P1, PJ=P2per PJreal=P2
302  // CB: PI=P2, PJ=P1per PJreal=P1
303  // Reconnecting springs:
304  // CA: PI=P1 and PJ=P2per have a spring in P1, so we reconnect to this spring in the normal way and integrate it.
305  // CB: PI=P2 and PJ=P1Per have a spring in P1per, however this spring has to be a reversed spring since it is in PJ.
306  // Removing periodic particles: The spring in P1per is removed
307 
308  //Cases (start from P1 and P2 and go to PI and PJ
309  //1 Normal-Normal ->PI=max(P1,P2), PJ=min(P1,P2)
310  //2 Periodic-Normal ->(PI=P2 PJ=real(P1))
311  //3 Normal-Periodic ->(PI=P1 PJ=real(P2))
312  //4 Periodic-Periodic ->do nothing
313 
314  //Just some statements to handle the 4 cases
315  BaseParticle *PI, *PJ, *PJreal;
316  bool isPeriodic;
317  BaseParticle *P1Per = P1->getPeriodicFromParticle();
318  BaseParticle *P2Per = P2->getPeriodicFromParticle();
319  if (P1Per == NULL)
320  {
321  if (P2Per == NULL) //N-N
322  if (P1->getIndex() < P2->getIndex())
323  {
324  PI = P2;
325  PJ = P1;
326  PJreal = P1;
327  isPeriodic = false;
328  }
329  else
330  {
331  PI = P1;
332  PJ = P2;
333  PJreal = P2;
334  isPeriodic = false;
335  }
336  else //N-P
337  {
338  PI = P1;
339  PJ = P2;
340  PJreal = P2Per;
341  isPeriodic = true;
342  }
343  }
344  else
345  {
346  if (P2Per == NULL) //P-N
347  {
348  PI = P2;
349  PJ = P1;
350  PJreal = P1Per;
351  isPeriodic = true;
352  }
353  else
354  return;
355  }
356 
357 #ifdef DEBUG_OUTPUT
358  std::cerr << "In computing internal forces between particle "<<PI->getPosition()<<" and "<<PJ->getPosition()<<std::endl;
359 #endif
360 
361  //Get the square of the distance between particle i and particle j
362  Mdouble dist_squared = Vec3D::getDistanceSquared(PI->getPosition(), PJ->getPosition());
363  Mdouble interactionRadii_sum = PI->getInteractionRadius() + PJ->getInteractionRadius();
364 
365 #ifdef DEBUG_OUTPUT_FULL
366  std::cerr << "Square of distance between " << dist_squared << " square sum of radii " << radii_sum*radii_sum <<std::endl;
367 #endif
368 
369  // True if the particles are in contact
370  if (dist_squared < (interactionRadii_sum * interactionRadii_sum))
371  {
372  // For particles of the same species, set species vector to Species(PI);
373  // for particles of different species, set species vector to MixedSpecies(PI,PJ)
374  CSpecies* pSpecies = (PI->getIndSpecies() == PJ->getIndSpecies()) ? &Species[PI->getIndSpecies()] : getMixedSpecies(PI->getIndSpecies(), PJ->getIndSpecies());
375 
376  // Calculate distance between the particles
377  Mdouble dist = sqrt(dist_squared);
378 
379  // Compute normal vector
380 
381  Vec3D normal = (PI->getPosition() - PJ->getPosition()) / dist;
382 
383  // Compute the overlap between the particles
384  Mdouble radii_sum = PI->getRadius() + PJ->getRadius();
385  Mdouble deltan = std::max(0.0, radii_sum - dist);
386 
387  Vec3D force = Vec3D(0, 0, 0);
388  ;
389  Vec3D forcet;
390  forcet.setZero();
391  Vec3D forcerolling;
392  forcerolling.setZero();
393  Vec3D forcetorsion;
394  forcetorsion.setZero();
395  Mdouble fdotn = 0;
396  CTangentialSpring* TangentialSpring = NULL;
397 
398  //evaluate shortrange non-contact forces
399  if (pSpecies->getAdhesionForceType() != AdhesionForceType::NONE)
400  fdotn += computeShortRangeForceWithParticle(PI, PJ, PJreal, pSpecies, dist);
401 
402  if (deltan > 0) //if contact forces
403  {
404 
405  // Compute the relative velocity vector v_ij
406  Vec3D vrel;
407  if (!pSpecies->getSlidingFrictionCoefficient())
408  {
409  vrel = (PI->getVelocity() - PJ->getVelocity());
410  }
411  else
412  {
413  vrel = (PI->getVelocity() - PJ->getVelocity()) + Vec3D::cross(normal, PI->getAngularVelocity() * (PI->getRadius() - .5 * deltan) + PJ->getAngularVelocity() * (PJ->getRadius() - .5 * deltan));
414  }
415 
416  // Compute the projection of vrel onto the normal (can be negative)
417  Mdouble vdotn = -Vec3D::dot(vrel, normal);
418 
419  //update restitution coeff
420  if (pSpecies->getIsRestitutionCoefficientConstant())
421  pSpecies->updateDissipation(PI->getMass(), PJ->getMass());
422  Mdouble a = 0, R = 0;
423 
424  // Compute normal force on particle i due to contact
425  if (pSpecies->getForceType() == ForceType::HERTZ_MINDLIN || pSpecies->getForceType() == ForceType::HERTZ_MINDLIN_DERESIEWICZ)
426  {
427  //R is twice the effective radius
428  R = 2.0 * PI->getRadius() * PJ->getRadius() / (PI->getRadius() + PJ->getRadius());
429  a = sqrt(R * deltan);
430  //pSpecies->getStiffness() stores the elastic modulus
431  Mdouble kn = 4. / 3. * pSpecies->getStiffness() * a;
432  fdotn += kn * deltan + pSpecies->getDissipation() * vdotn;
433  }
434  else
435  {
436  fdotn += pSpecies->getStiffness() * deltan + pSpecies->getDissipation() * vdotn;
437  }
438  force += normal * fdotn;
439 
440  //If tangential forces are present
441  if (pSpecies->getSlidingFrictionCoefficient() || pSpecies->getRollingFrictionCoefficient() || pSpecies->getTorsionFrictionCoefficient())
442  {
443  //call tangential spring
444  if (pSpecies->getSlidingStiffness() || pSpecies->getRollingStiffness() || pSpecies->getTorsionStiffness())
445  TangentialSpring = getTangentialSpring(PI, PJ, PJreal);
446 
447  //Compute norm of normal force
448  Mdouble norm_fn = fabs(fdotn);
449 
450  //calculate sliding friction
451  if (pSpecies->getSlidingFrictionCoefficient())
452  {
453  //Compute the tangential component of vrel
454  Vec3D vrelt = vrel + normal * vdotn;
455  //Compute norm of vrelt
456  Mdouble vdott = vrelt.getLength();
457 
458  if (pSpecies->getSlidingStiffness())
459  {
460  Vec3D* delta = &(TangentialSpring->delta);
461 
462  //Integrate the spring
464  //(*delta) += vrelt * dt - Vec3D::Dot(*delta,normal)*normal;
465  Vec3D ddelta = (vrelt - Vec3D::dot(*delta, PI->getVelocity() - PJ->getVelocity()) * normal / dist) * getTimeStep();
466  (*delta) += ddelta;
467 
468  //Calculate test force including viscous force
469  if (pSpecies->getForceType() == ForceType::HERTZ_MINDLIN)
470  {
471  //pSpecies->getSlidingStiffness() stores the elastic shear modulus
472  Mdouble kt = 8. * pSpecies->getSlidingStiffness() * a;
473  TangentialSpring->SlidingForce += -kt * ddelta;
474  forcet = TangentialSpring->SlidingForce - pSpecies->getSlidingDissipation() * vrelt;
475  }
476  else if (pSpecies->getForceType() == ForceType::HERTZ_MINDLIN_DERESIEWICZ)
477  {
478  //pSpecies->getSlidingStiffness() stores the elastic shear modulus
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;
483  }
484  else
485  {
486  forcet = (-pSpecies->getSlidingDissipation()) * vrelt - pSpecies->getSlidingStiffness() * (*delta);
487  }
488  Mdouble forcet2 = forcet.getLengthSquared();
489 
490  //tangential forces are modelled by a spring-damper of elastisity kt and viscosity getSlidingDissipation() (sticking),
491  //but the force is limited by Coulomb friction (sliding):
492  //f_t = -getSlidingDissipation()*vrelt, if getSlidingDissipation()*vrelt<=mu_s*fdotn, f_t=mu+s*fdotn*t, else
493  double muact = (TangentialSpring->sliding) ? (pSpecies->getSlidingFrictionCoefficient()) : (pSpecies->getSlidingFrictionCoefficientStatic()); // select mu from previous sliding mode
494  if (forcet2 <= mathsFunc::square(muact * norm_fn))
495  {
496  //sticking++;
497  TangentialSpring->sliding = false;
498  }
499  else
500  {
501  //sliding++;
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());
508  }
509 
510  //Add tangential force to total force
511  force += forcet;
512 
513  }
514  else
515  { //if no tangential spring
516  //tangential forces are modelled by a damper of viscosity getSlidingDissipation() (sticking),
517  //but the force is limited by Coulomb friction (sliding):
518  //f_t = -getSlidingDissipation()*vrelt, if getSlidingDissipation()*vrelt<=mu_s*fdotn, f_t=mu+s*fdotn*t, else
519  if (vdott * pSpecies->getSlidingDissipation() <= pSpecies->getSlidingFrictionCoefficientStatic() * norm_fn)
520  { //sticking++;
521  forcet = -pSpecies->getSlidingDissipation() * vrelt;
522  }
523  else
524  { //sliding++;
525  //set force to Coulomb limit
526  forcet = -(pSpecies->getSlidingFrictionCoefficient() * norm_fn / vdott) * vrelt;
527  }
528  //Add tangential force to total force
529  force += forcet;
530  }
531  }
532 
533  //calculate rolling friction
534  if (pSpecies->getRollingFrictionCoefficient())
535  {
536  //From Luding2008, objective rolling velocity (eq 15) w/o 2.0!
537  Mdouble reducedRadiusI = PI->getRadius() - .5 * deltan;
538  Mdouble reducedRadiusJ = PJ->getRadius() - .5 * deltan;
539  Mdouble reducedRadiusIJ = 2.0 * reducedRadiusI * reducedRadiusJ / (reducedRadiusI + reducedRadiusJ);
540  Vec3D vrolling = -reducedRadiusIJ * Vec3D::cross(normal, PI->getAngularVelocity() - PJ->getAngularVelocity());
541  if (pSpecies->getRollingStiffness())
542  {
543  Vec3D* RollingSpring = &(TangentialSpring->RollingSpring);
544 
545  //Integrate the spring
546  (*RollingSpring) += vrolling * getTimeStep(); // - Vec3D::Dot(*RollingSpring,normal)*normal;
547 
548  //Calculate test force including viscous force
549  forcerolling = (-pSpecies->getRollingDissipation()) * vrolling - pSpecies->getRollingStiffness() * (*RollingSpring);
550  Mdouble forcerolling2 = forcerolling.getLengthSquared();
551 
552  //tangential forces are modelled by a spring-damper of elastisity kt and viscosity getSlidingDissipation() (sticking),
553  //but the force is limited by Coulomb friction (sliding):
554  //f_t = -getSlidingDissipation()*vrelt, if getSlidingDissipation()*vrelt<=mu_s*fdotn, f_t=mu+s*fdotn*t, else
555  double muact = (TangentialSpring->slidingRolling) ? (pSpecies->getRollingFrictionCoefficient()) : (pSpecies->getRollingFrictionCoefficientStatic()); // select mu from previous sliding mode
556  if (forcerolling2 <= mathsFunc::square(muact * norm_fn))
557  {
558  //sticking++;
559  TangentialSpring->slidingRolling = false;
560  }
561  else
562  {
563  //sliding++;
564  TangentialSpring->slidingRolling = true;
565  forcerolling *= pSpecies->getRollingFrictionCoefficient() * norm_fn / sqrt(forcerolling2);
566  (*RollingSpring) = (forcerolling + pSpecies->getRollingDissipation() * vrolling) / (-pSpecies->getRollingStiffness());
567  }
568 
569  //Add tangential force to torque
570  Vec3D Torque = reducedRadiusIJ * Vec3D::cross(normal, forcerolling);
571  PI->addTorque(Torque);
572  PJreal->addTorque(-Torque);
573  }
574  }
575 
576  //calculate torsive friction
577  if (pSpecies->getTorsionFrictionCoefficient())
578  {
579  //From Luding2008, spin velocity (eq 16) w/o 2.0!
580  Mdouble RadiusIJ = 2.0 * PI->getRadius() * PJ->getRadius() / (PI->getRadius() + PJ->getRadius());
581  Vec3D vtorsion = RadiusIJ * Vec3D::dot(normal, PI->getAngularVelocity() - PJ->getAngularVelocity()) * normal;
582  if (pSpecies->getTorsionStiffness())
583  {
584  //~ std::cout << "Error; not yet implemented" << std::endl;
585  //~ exit(-1);
586  Vec3D* TorsionSpring = &(TangentialSpring->TorsionSpring);
587 
588  //Integrate the spring
589  (*TorsionSpring) = Vec3D::dot((*TorsionSpring) + vtorsion * getTimeStep(), normal) * normal;
590 
591  //Calculate test force including viscous force
592  forcetorsion = (-pSpecies->getTorsionDissipation()) * vtorsion - pSpecies->getTorsionStiffness() * (*TorsionSpring);
593  Mdouble forcetorsion2 = forcetorsion.getLengthSquared();
594 
595  //tangential forces are modelled by a spring-damper of elastisity kt and viscosity getSlidingDissipation() (sticking),
596  //but the force is limited by Coulomb friction (sliding):
597  //f_t = -getSlidingDissipation()*vrelt, if getSlidingDissipation()*vrelt<=mu_s*fdotn, f_t=mu+s*fdotn*t, else
598  double muact = (TangentialSpring->slidingTorsion) ? (pSpecies->getTorsionFrictionCoefficient()) : (pSpecies->getTorsionFrictionCoefficientStatic()); // select mu from previous sliding mode
599  if (forcetorsion2 <= mathsFunc::square(muact * norm_fn))
600  {
601  //sticking++;
602  TangentialSpring->slidingTorsion = false;
603  }
604  else
605  {
606  //sliding++;
607  TangentialSpring->slidingTorsion = true;
608  //~ std::cout << "sliding " << std::endl;
609  forcetorsion *= pSpecies->getTorsionFrictionCoefficient() * norm_fn / sqrt(forcetorsion2);
610  (*TorsionSpring) = (forcetorsion + pSpecies->getTorsionDissipation() * vtorsion) / (-pSpecies->getTorsionStiffness());
611  }
612 
613  //Add tangential force to torque
614  Vec3D torque = RadiusIJ * forcetorsion;
615  PI->addTorque(torque);
616  PJreal->addTorque(-torque);
617 
618  }
619  }
620  } //end if tangential forces
621 
623  //Make force Hertzian (note: deltan is normalized by the normal distanct of two particles in contact, as in Silbert)
624  if (pSpecies->getForceType() == ForceType::HERTZ)
625  force *= sqrt(deltan / (PI->getRadius() + PJ->getRadius()));
626 
627  }
628  else
629  { //end if contact forces
630  force += fdotn * normal;
631  }
632 
633  //Add forces to total force
634  //PI->addForce(force);
635  //if (!isPeriodic)
636  // PJreal->addForce(-force);
637 
638  // Add torque due to tangential forces: t = Vec3D::Cross(l,f), l=dist*Wall.normal
639  //if (pSpecies->getSlidingFrictionCoefficient())
640  //{
641  // Vec3D Vec3D::Cross = Vec3D::Cross(normal, force);
642  // PI->addTorque(-Vec3D::Cross * (PI->getRadius() - .5 * deltan));
643  // if (!isPeriodic)
644  // PJreal->addTorque(-Vec3D::Cross * (PJ->getRadius() - .5 * deltan));
645  //}
646  //BEGIN: CHANGE
647  if (InPeriodicBox(PI) != InPeriodicBox(PJreal))
648  {
649  if (InPeriodicBox(PI))
650  {
652  {
653  //~ if (PJreal->isFixed()) cout << "PJreal" << endl;
654  PJreal->addForce(-force);
655  }
656  }
657  else
658  {
660  {
661  //~ if (Particles[PI].isFixed()) cout << "PI" << endl;
662  PI->addForce(force);
663  }
664  }
665  }
666  else
667  {
668  PI->addForce(force);
669  PJreal->addForce(-force);
670  }
671  //END: CHANGE
672 
673  // Add torque due to tangential forces: t = Vec3D::Cross(l,f), l=dist*Wall.normal
674  //if (pSpecies->getSlidingFrictionCoefficient()) {
675  // Vec3D Vec3D::Cross = Vec3D::Cross(normal, force);
676  // PI ->add_Torque(-Vec3D::Cross * (PI->getRadius() - .5 * deltan));
677  // PJreal->add_Torque(-Vec3D::Cross * (PJ->getRadius() - .5 * deltan));
678  //}
679  //BEGIN: CHANGE
680  if (pSpecies->getSlidingFrictionCoefficient())
681  {
682  Vec3D cross = Vec3D::cross(normal, force);
683  if (InPeriodicBox(PI) != InPeriodicBox(PJreal))
684  {
685  if (InPeriodicBox(PI))
686  {
688  {
689  PJreal->addTorque(-cross * (PJreal->getRadius() - .5 * deltan));
690  }
691  }
692  else
693  {
695  {
696  PI->addTorque(-cross * (PI->getRadius() - .5 * deltan));
697  }
698  }
699  }
700  else
701  {
702  PI->addTorque(-cross * (PI->getRadius() - .5 * deltan));
703  PJreal->addTorque(-cross * (PJreal->getRadius() - .5 * deltan));
704  }
705  }
706  //END:CHANGE
707 
708  // output for ene and stat files:
709  if (eneFile.getSaveCurrentTimeStep())
710  {
711  if (!isPeriodic)
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)));
713  else
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)));
715  }
716  if (fStatFile.getSaveCurrentTimeStep() || statFile.getSaveCurrentTimeStep() || getDoCGAlways())
717  {
718 
719  Mdouble fdott = forcet.getLength();
720  Mdouble deltat_norm = TangentialSpring ? (-TangentialSpring->delta.getLength()) : 0.0;
721 
724  Vec3D centre = 0.5 * (PI->getPosition() + PJ->getPosition());
725 
729 
730  if (!PI->isFixed())
731  {
732  if (statFile.getSaveCurrentTimeStep() || getDoCGAlways())
733  gatherContactStatistics(PJreal->getIndex(), PI->getIndex(), centre, deltan, deltat_norm, fdotn, fdott, -normal, -(fdott ? forcet / fdott : forcet));
734  if (fStatFile.getSaveCurrentTimeStep())
735  fStatFile.getFstream() << getTime() << " " << PJreal->getIndex() << " " << PI->getIndex() << " " << centre << " " << radii_sum - dist << " " << deltat_norm << " " << fdotn << " " << fdott << " " << -normal << " " << -(fdott ? forcet / fdott : forcet) << std::endl;
736  }
737  if (!PJreal->isFixed() && !isPeriodic)
738  {
739  if (statFile.getSaveCurrentTimeStep() || getDoCGAlways())
740  gatherContactStatistics(PI->getIndex(), PJreal->getIndex(), centre, deltan, deltat_norm, fdotn, fdott, normal, (fdott ? forcet / fdott : forcet));
741  if (fStatFile.getSaveCurrentTimeStep())
742  fStatFile.getFstream() << getTime() << " " << PI->getIndex() << " " << PJreal->getIndex() << " " << centre << " " << radii_sum - dist << " " << deltat_norm << " " << fdotn << " " << fdott << " " << normal << " " << (fdott ? forcet / fdott : forcet) << std::endl;
743  }
744  }
745  } // end if particle i and j are overlapping
746  }
double Mdouble
Definition: GeneralDefine.h:34
@ R
Definition: StatisticsVector.h:42
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
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
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:348
Mdouble getMass() const
Returns the particle's mass.
Definition: BaseParticle.h:322
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:50
double get_PeriodicBoxLength()
Definition: ChuteWithPeriodicInflow.h:871
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1488
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1483
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1250
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:808
void gatherContactStatistics()
Definition: DPMBase.cc:1898
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: DPMBase.h:1498
std::fstream & getFstream()
Allows to access the member variable File::fstream_.
Definition: File.cc:153
BaseParticle * getLargestParticle() const
Returns the pointer of the largest particle in the particle handler. When mercury is running in paral...
Definition: ParticleHandler.cc:534
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
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
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
T square(const T val)
squares a number
Definition: ExtendedMath.h:106

References BaseInteractable::addForce(), BaseInteractable::addTorque(), Vec3D::cross(), Vec3D::dot(), DPMBase::eneFile, DPMBase::fStatFile, DPMBase::gatherContactStatistics(), get_PeriodicBoxLength(), BaseInteractable::getAngularVelocity(), Vec3D::getDistanceSquared(), File::getFstream(), BaseObject::getIndex(), BaseInteractable::getIndSpecies(), ParticleHandler::getLargestParticle(), Vec3D::getLength(), Vec3D::getLengthSquared(), BaseParticle::getMass(), SpeciesHandler::getMixedObject(), BaseParticle::getPeriodicFromParticle(), BaseInteractable::getPosition(), BaseParticle::getRadius(), DPMBase::getTime(), DPMBase::getTimeStep(), BaseInteractable::getVelocity(), InPeriodicBox(), BaseParticle::isFixed(), DPMBase::particleHandler, R, Vec3D::setZero(), DPMBase::speciesHandler, mathsFunc::square(), DPMBase::statFile, and Vec3D::X.

◆ ExtendInWidth()

void ChuteWithPeriodicInflow::ExtendInWidth ( int  numRepetitionsInWidth)
inline
118  {
120  // creates bottom outside periodic chute of species 1
121  double widthPeriodicChute = getYMax();
123  particleHandler.setStorageCapacity(N * numRepetitionsInWidth);
124  for (int j = 1; j < numRepetitionsInWidth; j++)
125  {
126  for (int i = 0; i < N; i++)
127  {
128  //if (particleHandler.getObject(i)->isFixed()) {
130  //Particles.back()->get_IndSpecies()=1;
131  particleHandler.getLastObject()->move(Vec3D(0.0, widthPeriodicChute * j, 0.0));
132  //}
133  }
134  }
135  setYMax(numRepetitionsInWidth * widthPeriodicChute);
136  perw->set(Vec3D(0, 1, 0), getYMin(), getYMax());
137  //setHGridNumberOfBucketsToPower(particleHandler.getNumberOfObjects());
138  }
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 setYMax(Mdouble newYMax)
Sets the value of YMax, the upper bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1191
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax.
Definition: DPMBase.h:638
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
Definition: PeriodicBoundary.cc:84

References ParticleHandler::addObject(), DPMBase::boundaryHandler, BaseParticle::copy(), BaseHandler< T >::getLastObject(), ParticleHandler::getNumberOfObjects(), BaseHandler< T >::getObject(), DPMBase::getYMax(), DPMBase::getYMin(), constants::i, BaseInteractable::move(), DPMBase::particleHandler, PeriodicBoundary::set(), BaseHandler< T >::setStorageCapacity(), and DPMBase::setYMax().

Referenced by ChuteWithPeriodicInflow().

◆ get_PeriodicBoxLength()

double ChuteWithPeriodicInflow::get_PeriodicBoxLength ( )
inline
872  {
873  return PeriodicBoxLength;
874  }
double PeriodicBoxLength
stores the length of the periodic box
Definition: ChuteWithPeriodicInflow.h:897

References PeriodicBoxLength.

Referenced by computeInternalForces().

◆ get_PeriodicBoxNSpecies()

int ChuteWithPeriodicInflow::get_PeriodicBoxNSpecies ( )
inline
880  {
881  return PeriodicBoxNSpecies;
882  }
int PeriodicBoxNSpecies
stores the number of species in the periodic box
Definition: ChuteWithPeriodicInflow.h:899

References PeriodicBoxNSpecies.

Referenced by integrateBeforeForceComputation(), and loadPeriodicBox().

◆ getInfo()

double ChuteWithPeriodicInflow::getInfo ( const BaseParticle p) const
inlineoverridevirtual

A virtual function that returns some user-specified information about a particle.

Returns
double

Reimplemented from DPMBase.

59  {
60  return P.getIndSpecies();
61  }
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:73

References Global_Physical_Variables::P.

◆ InPeriodicBox()

bool ChuteWithPeriodicInflow::InPeriodicBox ( BaseParticle P)
inline
889  {
890  return P->getIndSpecies() < PeriodicBoxNSpecies;
891  }

References Global_Physical_Variables::P, and PeriodicBoxNSpecies.

Referenced by Check_and_Duplicate_Periodic_Particle(), and computeInternalForces().

◆ integrateBeforeForceComputation()

void ChuteWithPeriodicInflow::integrateBeforeForceComputation ( )
inlinevirtual

Update particles' and walls' positions and velocities before force computation.

This is where the integration is done, at the moment it is velocity Verlet integration and is done before the forces are computed. See http://en.wikipedia.org/wiki/Verlet_integration#Velocity_Verlet

Performs integration - i.e. updating particle's positions, velocities and accelerations - for all particles and walls within the system (i.e. in the particleHandler and wallHandler). Integration is performed using the BaseParticle::integrateBeforeForceComputation() function.

The velocity Verlet algorithm requires us to integrate twice each time step: both before and after the force computation. This method is therefore used in conjunction with DPMBase::integrateAfterForceComputation(). See http://en.wikipedia.org/wiki/Verlet_integration#Velocity_Verlet for details.

Reimplemented from DPMBase.

177  {
178  for (std::vector<BaseParticle*>::iterator it = particleHandler.begin(); it != particleHandler.end(); ++it)
179  {
180  (*it)->integrateBeforeForceComputation(getTimeStep());
181 
182  // This shifts particles that moved through periodic walls
184  PeriodicBoundary* perw1 = static_cast<PeriodicBoundary*>(boundaryHandler.getObject(1));
185  if ((*it)->getIndSpecies() == 0 && perw->getDistance(**it) < 0)
186  {
187  //if (iP->getIndSpecies()==0 && static_cast<PeriodicWall*>(boundaryHandler.getObject(0))->getDistance(*iP)<0) {
188  if (!perw->isClosestToLeftBoundary())
189  {
192  particleHandler.addObject((*it)->copy());
195  perw->shiftPosition((*it));
197  {
198  hGridRemoveParticle((*it));
199  hGridUpdateParticle((*it));
200  }
201  }
202  else
203  {
204  static int count = -1;
205  count++;
206  if (!(count % dataFile.getSaveCount()))
207 
208  std::cout << "Warning: Particle " << (*it)->getIndex() << " is left of xmin: x="
209  << (*it)->getPosition().X << ", v_x=" << (*it)->getVelocity().X << std::endl;
210  }
211  }
212  if (getIsPeriodic() > 1 && perw1->getDistance(**it) < 0)
213  {
214  perw1->shiftPosition(*it);
216  {
217  hGridRemoveParticle(*it);
218  hGridUpdateParticle(*it);
219  }
220  }
221  }
222 
223  }
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
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
int get_PeriodicBoxNSpecies()
Definition: ChuteWithPeriodicInflow.h:879
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1478
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
Definition: ParticleSpecies.h:37
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

References ParticleHandler::addObject(), BaseHandler< T >::begin(), DPMBase::boundaryHandler, DPMBase::dataFile, BaseHandler< T >::end(), get_PeriodicBoxNSpecies(), PeriodicBoundary::getDistance(), MercuryBase::getHGridUpdateEachTimeStep(), BaseInteractable::getIndSpecies(), Chute::getIsPeriodic(), BaseHandler< T >::getLastObject(), ParticleHandler::getNumberOfObjects(), BaseHandler< T >::getObject(), File::getSaveCount(), BaseHandler< T >::getStorageCapacity(), DPMBase::getTimeStep(), Mercury3D::hGridRemoveParticle(), Mercury3D::hGridUpdateParticle(), PeriodicBoundary::isClosestToLeftBoundary(), DPMBase::particleHandler, BaseParticle::setSpecies(), BaseHandler< T >::setStorageCapacity(), PeriodicBoundary::shiftPosition(), and DPMBase::speciesHandler.

◆ loadPeriodicBox()

void ChuteWithPeriodicInflow::loadPeriodicBox ( std::string const  restart_file)
inline

loads periodic chute data from restart file

65  {
66  FillChute = false;
67 
68  std::cout << "constructor" << std::endl;
69 
70  //load particles and chute setup into periodic chute
71  setName(restart_file.c_str());
73 
76 
77  //we don't want to treat the data as restarted, i.e. we start the program at time=0 and create new output files
78  setRestarted(false);
79 
80  //keep file name but create files in the local directory, i.e. remove folder
81  size_t found = restart_file.find_last_of("/\\");
82  setName(restart_file.substr(found + 1).c_str());
83 
84  // adds new species for the flow particles (0 for the periodic inflow particles)
85  for (int i = 0; i < get_PeriodicBoxNSpecies(); i++)
86  addSpecies(Species[i]);
87 
88  setName("ChuteWithPeriodicInflow");
89  }
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 set_PeriodicBoxNSpecies(int new_)
Definition: ChuteWithPeriodicInflow.h:883
void set_PeriodicBoxLength(double new_)
Definition: ChuteWithPeriodicInflow.h:875
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
void setRestarted(bool newRestartedFlag)
Allows to set the flag stating if the simulation is to be restarted or not.
Definition: DPMBase.cc:1501
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

References FillChute, get_PeriodicBoxNSpecies(), BaseHandler< T >::getNumberOfObjects(), DPMBase::getXMax(), constants::i, DPMBase::readRestartFile(), set_PeriodicBoxLength(), set_PeriodicBoxNSpecies(), DPMBase::setName(), DPMBase::setRestarted(), and DPMBase::speciesHandler.

Referenced by ChuteWithPeriodicInflow().

◆ outputXBallsDataParticlee()

void ChuteWithPeriodicInflow::outputXBallsDataParticlee ( const unsigned int  i,
const unsigned int  format,
std::ostream &  os 
) const
inline
850  {
851  os
852  << particleHandler.getObject(i)->getPosition().X << " "
853  << particleHandler.getObject(i)->getPosition().Y << " "
854  << particleHandler.getObject(i)->getPosition().Z << " "
855  << particleHandler.getObject(i)->getVelocity().X << " "
856  << particleHandler.getObject(i)->getVelocity().Y << " "
857  << particleHandler.getObject(i)->getVelocity().Z << " "
858  //~ << (particleHandler.getObject(i)->isFixed()?0.0:particleHandler.getObject(i)->Force.X) << " "
859  //~ << (particleHandler.getObject(i)->isFixed()?0.0:particleHandler.getObject(i)->Force.Y) << " "
860  //~ << (particleHandler.getObject(i)->isFixed()?0.0:particleHandler.getObject(i)->Force.Z) << " "
861  << particleHandler.getObject(i)->getRadius() << " "
863  << particleHandler.getObject(i)->getOrientation().Y << " "
864  << particleHandler.getObject(i)->getOrientation().Z << " "
868  << particleHandler.getObject(i)->getIndSpecies() << std::endl;
869  }
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Definition: BaseInteractable.h:230
Mdouble Y
Definition: Vector.h:66
Mdouble Z
Definition: Vector.h:66

References BaseInteractable::getAngularVelocity(), BaseInteractable::getIndSpecies(), BaseHandler< T >::getObject(), BaseInteractable::getOrientation(), BaseInteractable::getPosition(), BaseParticle::getRadius(), BaseInteractable::getVelocity(), constants::i, DPMBase::particleHandler, Vec3D::X, Vec3D::Y, and Vec3D::Z.

◆ printTime()

void ChuteWithPeriodicInflow::printTime ( ) const
inlineoverridevirtual

add some particular output

Reimplemented from DPMBase.

227  {
228  int counter = 0;
229 
230  double speed1 = 0;
231  double speed0 = 0;
232  double n1 = 0;
233  double n0 = 0;
234  for (int i = 0; i < particleHandler.getNumberOfObjects(); i++)
235  {
237  counter++;
239  {
241  {
242  speed0 += particleHandler.getObject(i)->getVelocity().X;
243  n0++;
244  }
245  else
246  {
247  speed1 += particleHandler.getObject(i)->getVelocity().X;
248  n1++;
249  }
250  }
251  }
252  speed0 /= n0;
253  speed1 /= n1;
254 
255  std::cout << "t=" << std::setprecision(5) << std::left << std::setw(6) << getTime()
256  << ", n=" << n1 << "(inflow:" << n0 << ")"
257  << ", speed= " << speed1 << "(" << speed0 << ")"
258  << std::endl;
259  //~ cout
260  //~ << " A " << PeriodicBoxLength
261  //~ << " A " << PeriodicBoxNSpecies
262  //~ << " A " << FillChute << endl;
263  }

References BaseInteractable::getIndSpecies(), ParticleHandler::getNumberOfObjects(), BaseHandler< T >::getObject(), DPMBase::getTime(), BaseInteractable::getVelocity(), constants::i, BaseParticle::isFixed(), DPMBase::particleHandler, and Vec3D::X.

◆ set_PeriodicBoxLength()

void ChuteWithPeriodicInflow::set_PeriodicBoxLength ( double  new_)
inline
876  {
877  PeriodicBoxLength = new_;
878  }

References PeriodicBoxLength.

Referenced by loadPeriodicBox().

◆ set_PeriodicBoxNSpecies()

void ChuteWithPeriodicInflow::set_PeriodicBoxNSpecies ( int  new_)
inline
884  {
885  PeriodicBoxNSpecies = new_;
886  }

References PeriodicBoxNSpecies.

Referenced by loadPeriodicBox().

◆ setupInitialConditions()

void ChuteWithPeriodicInflow::setupInitialConditions ( )
inlineoverridevirtual

Do not add bottom.

Reimplemented from DPMBase.

173  {
174  }

◆ writeXBallsScript()

void ChuteWithPeriodicInflow::writeXBallsScript ( ) const
inlinevirtual

This writes a script which can be used to load the xballs problem to display the data just generated.

Todo:
Implement or make pure virtual

First put in all the script lines. All these lines do is move you to the correct directory from any location

Reimplemented from DPMBase.

777  {
778 
779  std::stringstream file_name;
780  std::ofstream script_file;
781  file_name << getName() << ".disp";
782  script_file.open((file_name.str()).c_str());
783 
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;
790 
791  double scale;
792  int format;
793 
794  int width = 1570, height = 860;
795  double ratio = getSystemDimensions() < 3 ? (getXMax() - getXMin()) / (getYMax() - getYMin()) : (getXMax() - getXMin()) / (getZMax() - getZMin());
796  if (ratio > width / height)
797  height = width / ratio;
798  else
799  width = height * ratio;
800  //~ cout << ratio << "r" << endl;
801  if (getSystemDimensions() < 3)
802  { // dim = 1 or 2
803  format = 8;
804  if (getXBallsScale() < 0)
805  {
806  scale = 1.0 / std::max(getYMax() - getYMin(), getXMax() - getXMin());
807  }
808  else
809  {
810  scale = getXBallsScale();
811  }
812  }
813  else
814  { //dim==3
815  format = 14;
816  if (getXBallsScale() < 0)
817  {
818  scale = width / 480 / (getXMax() - getXMin());
819  }
820 
821  else
822  {
823  scale = getXBallsScale();
824  }
825 
826  }
827 
828  script_file << "../xballs -format " << format
829  << " -f " << dataFile.getFullName()
830  << " -s " << scale
831  << " -w " << width + 140
832  << " -h " << height + 140
833  << " -cmode " << getXBallsColourMode()
834  << " -cmax -scala 4 -sort -oh 50 "
836  << " $*";
837  if (getXBallsVectorScale() > -1)
838  {
839  script_file << " -vscale " << getXBallsVectorScale();
840  }
841  script_file.close();
842 
843  //This line changes the file permision and gives the owner (i.e. you) read, write and execute permission to the file
844 #ifdef UNIX
845  chmod((file_name.str().c_str()),S_IRWXU);
846 #endif
847  }
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
double getXBallsVectorScale() const
Returns the scale of vectors used in xballs.
Definition: DPMBase.cc:1330
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:399
std::string getXBallsAdditionalArguments() const
Returns the additional arguments for xballs.
Definition: DPMBase.cc:1355
double getXBallsScale() const
Returns the scale of the view in xballs.
Definition: DPMBase.cc:1372
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
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

References DPMBase::dataFile, File::getFullName(), DPMBase::getName(), DPMBase::getSystemDimensions(), DPMBase::getXBallsAdditionalArguments(), DPMBase::getXBallsColourMode(), DPMBase::getXBallsScale(), DPMBase::getXBallsVectorScale(), DPMBase::getXMax(), DPMBase::getXMin(), DPMBase::getYMax(), DPMBase::getYMin(), DPMBase::getZMax(), and DPMBase::getZMin().

Member Data Documentation

◆ FillChute

bool ChuteWithPeriodicInflow::FillChute
private

◆ inflowParticle_

◆ PeriodicBoxLength

double ChuteWithPeriodicInflow::PeriodicBoxLength
private

stores the length of the periodic box

Referenced by get_PeriodicBoxLength(), and set_PeriodicBoxLength().

◆ PeriodicBoxNSpecies

int ChuteWithPeriodicInflow::PeriodicBoxNSpecies
private

stores the number of species in the periodic box

Referenced by get_PeriodicBoxNSpecies(), InPeriodicBox(), and set_PeriodicBoxNSpecies().


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