BaseCluster Class Reference

#include <BaseCluster.h>

+ Inheritance diagram for BaseCluster:

Public Member Functions

 BaseCluster ()
 Default constructor. More...
 
 ~BaseCluster () final
 Default destructor. More...
 
Vec3D getPosition () const
 This returns the value of position_, which is the position in which the cluster will be inserted. More...
 
void setPosition (Vec3D p)
 This sets the value of position_, which is the position in which the cluster will be inserted. More...
 
Mdouble getCollisionTimeOverTimeStep () const
 This returns the value of the ratio between collision time and time step. More...
 
void setCollisionTimeOverTimeStep (Mdouble cTOTS)
 This sets the collisionTimeOverTimeStep number (which is the ratio between collision time and time step). More...
 
Mdouble getRadiusParticle () const
 This returns the value of particles' radius if there's no dispersity in size. In case of dispersity != 1, this is the radius from which all radii are computed (as a consequence in this case it is also the pseudo-averaged radius). More...
 
void setRadiusParticle (Mdouble rP)
 This sets the value of particles' radius if there's no dispersity in size. More...
 
Mdouble getSizeDispersityParticle () const
 This returns the value of particles' dispersity in size. More...
 
void setSizeDispersityParticle (Mdouble sDP)
 This sets the value of particles' dispersity in size. More...
 
int getNumberOfParticles () const
 This returns the value of the number of particles in the cluster. More...
 
void setNumberOfParticles (int nP)
 This sets the value of the number of particles in the cluster. More...
 
void setRadiusCluster (Mdouble rCR)
 This sets the desired value of the cluster radius (there is no getter of this value, but there is a getter of the actual mean cluster radius obtained, getMeanClusterRadius) More...
 
Mdouble getFinalMassFraction ()
 This gets the final value obtained for the mass fraction;. More...
 
unsigned int getClusterId () const
 This returns the value of the cluster ID. More...
 
void setClusterId (unsigned int iC)
 This sets the value of the cluster ID. More...
 
Mdouble getVelocityDampingModulus () const
 This returns the value of the velocity damping modulus. More...
 
void setVelocityDampingModulus (Mdouble vDM)
 This sets the value of the velocity damping modulus. More...
 
int getNumberOfInternalStructurePoints () const
 This returns the value of the number of particles used to compute internal structure. More...
 
void setNumberOfInternalStructurePoints (int gL)
 This sets the value of the number of particles used to compute the internal structure. More...
 
Mdouble getEnergyRatioTolerance () const
 This returns the value of the value of the energy ratio threshold under which the process can be considered static, and so over. More...
 
void setEnergyRatioTolerance (Mdouble eRT)
 This sets the value of the value of the energy ratio threshold under which the process can be considered static, and so over. More...
 
LinearPlasticViscoelasticFrictionSpeciesgetParticleSpecies () const
 This returns the species of the particle. More...
 
void setParticleSpecies (LinearPlasticViscoelasticFrictionSpecies *particleSpecies)
 This sets the species of the particle. More...
 
Vec3D getVelocity ()
 This gets the value of velocity after creation. More...
 
void setVelocity (Vec3D v)
 This sets the value of velocity after creation. More...
 
bool isCdatOutputOn () const
 This returns the bool variable that defines whether the cluster data output (which is NOT the mercury data output) is written or not. More...
 
void doCdatOutput (bool iCOO)
 This sets the bool variable that defines whether the cluster data output will be written or not. More...
 
bool isOverlOutputOn () const
 This returns the bool variable that defines whether the cluster overlap output is written or not. More...
 
void doOverlOutput (bool iOOO)
 This sets the bool variable that defines whether the cluster overlap output will be written or not. More...
 
bool isAmatOutputOn () const
 This returns the bool variable that defines whether the cluster adjacency matrix output is written or not. More...
 
void doAmatOutput (bool iAOO)
 This sets the bool variable that defines whether the cluster adjacency matrix output will be written or not. More...
 
bool isIntStrucOutputOn () const
 This returns the bool variable that defines whether the cluster internal structure output is written or not. More...
 
void doIntStrucOutput (bool iISOO)
 This sets the bool variable that defines whether the cluster internal structure output will be written or not. More...
 
bool isVtkOutputOn () const
 This returns the bool variable that defines whether the cluster vtk output is written or not. More...
 
void doVtkOutput (bool iVOO)
 This sets the bool variable that defines whether the cluster vtk output will be written or not. More...
 
bool isRestartOutputOn () const
 This returns the bool variable that defines whether the cluster restart output is written or not. More...
 
void doRestartOutput (bool isRestartOutputOn)
 This sets the bool variable that defines whether the cluster restart output will be written or not. More...
 
bool isFStatOutputOn () const
 This returns the bool variable that defines whether the cluster fStat output is written or not. More...
 
void doFStatOutput (bool isfStatOutputOn)
 This sets the bool variable that defines whether the cluster fStat output will be written or not. More...
 
bool isEneOutputOn () const
 This returns the bool variable that defines whether the cluster ene output is written or not. More...
 
void doEneOutput (bool isEneOutputOn)
 This sets the bool variable that defines whether the cluster ene output will be written or not. More...
 
Mdouble getMeanClusterRadius ()
 this returns meanClusterRadius (radius of an ideal perfectly spherical cluster, there's no setter). More...
 
Mdouble getAverageOverlap ()
 this returns the average overlap. More...
 
void setupInitialConditions () override
 Overrides DPMBase setupInitialConditions(): in this initial conditions for the problem are set. More...
 
void actionsAfterTimeStep () override
 Overrides DPMBase actionsAfterTimeStep(): in this compression and decompression are computed, depending on the variable stage_. More...
 
void actionsAfterSolve () override
 Overrides DPMBase actionsAfterSolve(): in this cluster data file and cluster overlap file are closed and a few final actions are executed. Details in BaseCluster.cc. More...
 
void write (std::ostream &os, bool writeAllParticles) const override
 Overrides DPMBase write(): in this all variables needed by the program for restarting are written. More...
 
void read (std::istream &is, ReadOptions opt=ReadOptions::ReadAll) override
 Overrides DPMBase read(): in this all variables needed by the program for restarting are read. More...
 
void actionsOnRestart () override
 Overrides DPMBase actionsOnRestart(): in this all variables needed by the program for restarting are initialized. More...
 
void printTime () const override
 Overrides DPMBase printTime(): this way variables of interest are shown. 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...
 
virtual void writeXBallsScript () const
 This writes a script which can be used to load the xballs problem to display the data just generated. More...
 
virtual Mdouble getInfo (const BaseParticle &P) const
 A virtual function that returns some user-specified information about a particle. 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 ()
 

Private Member Functions

void setRadii ()
 Sets all radii according to particleRadius and sizeDispersityParticle. More...
 
void setSpecies ()
 Sets species of particles. More...
 
void setDomainLimits ()
 Sets domain limits. More...
 
void calculateTimeStep ()
 Calculates the time step. More...
 
void insertParticles ()
 Inserts particles inside the domain. More...
 
void makeCdatFile ()
 Creates the cluster data output file. More...
 
void makeOverlFile ()
 Creates the cluster overlap output file. More...
 
bool particleInsertionSuccessful (int n)
 This function tries to insert the n-th particle (returns true if it manage to do that). It is inside insertParticles(). More...
 
void makeDataAnalysis ()
 This functions computes some important cluster information needed by the program. More...
 
void writeToCdatFile ()
 This writes on the cluster data output file. More...
 
void writeToOverlFile ()
 This writes on the cluster overlap output file. More...
 
void applyCentralForce ()
 This applies force on each particle. More...
 
void increaseForce ()
 This linearly increases the value of forceModulus (stage = 1). More...
 
void dampVelocities ()
 This damps values of each particle velocity (stage = 1, stage = 2, stage = 3). More...
 
void decreaseForce ()
 This linearly decreases values of forceModulus (stage = 2). More...
 
void dampForce ()
 This damps values of forceModulus (stage = 3). More...
 
void createAdjacencyMatrix ()
 This calculates the adjacency matrix of the cluster. More...
 
void makeAmatFile ()
 This creates the adjacency matrix file. More...
 
void writeAmatFile ()
 This writes on the adjacency matrix file. More...
 
void computeInternalStructure ()
 This computes the internal structure of the cluster. More...
 
void makeGnuplotFile ()
 This creates the gnuplot file needed for printing force vs overlaps values. More...
 
void makeIntenalStructureFile ()
 This creates the file needed for writing down datas from computeInternalStructure(). More...
 

Private Attributes

Vec3D position_
 
Mdouble collisionTimeOverTimeStep_
 
Mdouble energyRatioTolerance_
 
Mdouble radiusParticle_
 
bool setRadiusParticle_ = false
 
Mdouble sizeDispersityParticle_
 
int nParticles_
 
bool setNumberOfParticles_ = false
 
unsigned int idCluster_
 
Mdouble radiusCluster_
 
bool setRadiusCluster_ = false
 
Vec3D clusterVelocity_
 
Mdouble meanClusterRadius_
 
Mdouble velocityDampingModulus_
 
int nInternalStructurePoints_
 
LinearPlasticViscoelasticFrictionSpeciesparticleSpecies_
 
bool isCdatOutputOn_
 
bool isOverlOutputOn_
 
bool isAmatOutputOn_
 
bool isIntStrucOutputOn_
 
bool isVtkOutputOn_
 
bool isRestartOutputOn_
 
bool isFStatOutputOn_
 
bool isEneOutputOn_
 
std::vector< Mdoubleradii_
 
Mdouble smallestRadius_
 
Mdouble massParticle_
 
Mdouble totalParticleVolume_
 
Mdouble boxSize_
 
Vec3D centerOfMass_
 
std::vector< std::vector< int > > adjacencyMatrix_
 
Mdouble meanCoordinationNumber_
 
Mdouble maxRelativeOverlap_
 
Mdouble meanRelativeOverlap_
 
Mdouble minRelativeOverlap_
 
int nIntraClusterBonds_
 
std::ofstream cdatFile_
 
std::ofstream overlFile_
 
std::ofstream gnuplotFile_
 
std::ofstream amatFile_
 
std::ofstream intStructFile_
 
Mdouble fileOutputTimeInterval_
 
Mdouble radiusForSolidFraction_
 
Mdouble solidFraction_
 
Mdouble solidFractionIntStruct_
 
int stage_
 
Mdouble t0_
 
Mdouble clusterTimeMax_
 
Mdouble maximumForceModulus_
 
Mdouble forceModulus_
 
Mdouble forceTuningInterval_
 
Mdouble velocityDampingInterval_
 
Mdouble forceTuningDuration_
 
Mdouble dissipationDuration_
 
Mdouble forceDampingModulus_
 

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...
 
- 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...
 
- 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 actionsBeforeTimeLoop ()
 A virtual function. Allows one to carry out any operations before the start of the time loop. More...
 
virtual void actionsBeforeTimeStep ()
 A virtual function which allows to define operations to be executed before the new time step. More...
 
virtual void computeAdditionalForces ()
 A virtual function which allows to define operations to be executed prior to the OMP force collect. 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 integrateBeforeForceComputation ()
 Update particles' and walls' positions and velocities before force computation. More...
 
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...
 

Constructor & Destructor Documentation

◆ BaseCluster()

BaseCluster::BaseCluster ( )

Default constructor.

Default constructor.

31  {
32  logger(DEBUG, "BaseCluster::BaseCluster() finished");
33 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ DEBUG

References DEBUG, and logger.

◆ ~BaseCluster()

BaseCluster::~BaseCluster ( )
final

Default destructor.

Default destructor.

38  {
39  logger(DEBUG, "BaseCluster::BaseClusterr() finished");
40 }

References DEBUG, and logger.

Member Function Documentation

◆ actionsAfterSolve()

void BaseCluster::actionsAfterSolve ( )
overridevirtual

Overrides DPMBase actionsAfterSolve(): in this cluster data file and cluster overlap file are closed and a few final actions are executed. Details in BaseCluster.cc.

In this: -data analysis is computed and cluster data and cluster overlap file are written for the last time. -if stage == 3 that means that the simulation is over but the energy ratio threshold is not reached: for this reason the user gets a warning. -adjacency matrix file is created and written (if needed), -internal structure file is created and written (if needed), -gnuplot file is created and written (if needed), -all particles are centred around the center of mass and their velocity is set, for this reason the user gets a warning, -finally cluster data file and cluster overlap file are closed.

Reimplemented from DPMBase.

735 {
736 
738 
739  if ( isCdatOutputOn() )
740  writeToCdatFile();
741 
742  if ( isOverlOutputOn() )
744 
745  if (stage_ == 3)
746  logger(WARN, "Dissipation process not completed: final energyRatioTollerance_ = %."
747  "Try to increase energyRatioTollerance_ or decreasing velocityDampingModulus.",
749 
750  if (isAmatOutputOn())
751  {
752  logger(VERBOSE, "CREATING ADJACENCY MATRIX FILE\n");
754  makeAmatFile();
755  writeAmatFile();
756  }
757 
758  if (isIntStrucOutputOn())
759  {
760  logger(VERBOSE, "COMPUTING INTERNAL STRUCTURE FILE\n");
762  }
763 
764  if(isOverlOutputOn())
765  {
766  logger(VERBOSE, "COMPUTING GNUPLOT FILE\n");
767  makeGnuplotFile();
768  }
769 
770 
771  /*
772  * \brief with this loop all particles are moved so that center of mass == position_ and their velocity is set.
773  */
774  for (auto i = particleHandler.begin(); i != particleHandler.end(); ++i){
775  (*i)->setPosition( (*i)->getPosition() + position_ - centerOfMass_ );
776  (*i)->setVelocity( clusterVelocity_ );
777  }
778 
779  logger(VERBOSE, "CLUSTER CREATED.\n");
780 
781  if (isCdatOutputOn())
782  cdatFile_.close();
783 
784  if (isOverlOutputOn())
785  overlFile_.close();
786 }
@ WARN
@ VERBOSE
std::ofstream overlFile_
Definition: BaseCluster.h:576
void createAdjacencyMatrix()
This calculates the adjacency matrix of the cluster.
Definition: BaseCluster.cc:1540
void makeDataAnalysis()
This functions computes some important cluster information needed by the program.
Definition: BaseCluster.cc:1256
Vec3D centerOfMass_
Definition: BaseCluster.h:556
void writeToCdatFile()
This writes on the cluster data output file.
Definition: BaseCluster.cc:1371
std::ofstream cdatFile_
Definition: BaseCluster.h:574
bool isAmatOutputOn() const
This returns the bool variable that defines whether the cluster adjacency matrix output is written or...
Definition: BaseCluster.cc:299
bool isIntStrucOutputOn() const
This returns the bool variable that defines whether the cluster internal structure output is written ...
Definition: BaseCluster.cc:313
bool isCdatOutputOn() const
This returns the bool variable that defines whether the cluster data output (which is NOT the mercury...
Definition: BaseCluster.cc:271
void writeAmatFile()
This writes on the adjacency matrix file.
Definition: BaseCluster.cc:1577
Vec3D clusterVelocity_
Definition: BaseCluster.h:499
int stage_
Definition: BaseCluster.h:596
void writeToOverlFile()
This writes on the cluster overlap output file.
Definition: BaseCluster.cc:1438
void makeGnuplotFile()
This creates the gnuplot file needed for printing force vs overlaps values.
Definition: BaseCluster.cc:1689
void computeInternalStructure()
This computes the internal structure of the cluster.
Definition: BaseCluster.cc:1603
void makeAmatFile()
This creates the adjacency matrix file.
Definition: BaseCluster.cc:1563
bool isOverlOutputOn() const
This returns the bool variable that defines whether the cluster overlap output is written or not.
Definition: BaseCluster.cc:285
Vec3D position_
Definition: BaseCluster.h:471
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:690
const std::vector< T * >::const_iterator end() const
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
Definition: BaseHandler.h:704
Mdouble getKineticEnergy() const
Returns the global kinetic energy stored in the system.
Definition: DPMBase.cc:1544
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
Mdouble getElasticEnergy() const
Returns the global elastic energy within the system.
Definition: DPMBase.cc:1530
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References BaseHandler< T >::begin(), cdatFile_, centerOfMass_, clusterVelocity_, computeInternalStructure(), createAdjacencyMatrix(), BaseHandler< T >::end(), DPMBase::getElasticEnergy(), DPMBase::getKineticEnergy(), constants::i, isAmatOutputOn(), isCdatOutputOn(), isIntStrucOutputOn(), isOverlOutputOn(), logger, makeAmatFile(), makeDataAnalysis(), makeGnuplotFile(), overlFile_, DPMBase::particleHandler, position_, stage_, VERBOSE, WARN, writeAmatFile(), writeToCdatFile(), and writeToOverlFile().

◆ actionsAfterTimeStep()

void BaseCluster::actionsAfterTimeStep ( )
overridevirtual

Overrides DPMBase actionsAfterTimeStep(): in this compression and decompression are computed, depending on the variable stage_.

In this the process takes place: in particular after each time step the following tasks are computed (in order): -data analysis: calculating values of interest, -writing to cluster data file, -writing to overlap file, -increasing central force and damping velocity (stage == 1), decreasing central force and damp velocity (stage == 2), damp central force and damp velocity until the system is static (stage == 3).

Reimplemented from DPMBase.

623 {
625 
627  writeToCdatFile();
628 
631 
632  /*
633  * \brief If stage == 1 force is linearly increased and velocities are damped for a time T = forceTuningDuration.
634  * If t > T, stage is set to 2.
635  */
636  if (stage_ == 1)
637  {
638  if (getTime() - t0_ < forceTuningDuration_)
639  {
640  if (fmod(getTime() - t0_, forceTuningInterval_) < getTimeStep())
641  increaseForce();
642 
643  if (fmod(getTime() - t0_, velocityDampingInterval_) < getTimeStep())
644  dampVelocities();
645 
647  }
648  else
649  {
650  logger(VERBOSE, "DECREASING CENTRAL FORCE");
651 
652  t0_ = getTime();
653  stage_++;
654  }
655  }
656 
657  /*
658  * \brief If stage == 2 force is linearly decreased and velocities are damped for a time duration of T = forceTuningDuration.
659  * If t > T, stage is set to 3.
660  */
661  if (stage_ == 2)
662  {
663  if (getTime() - t0_ < forceTuningDuration_)
664  {
665  if (fmod(getTime() - t0_, forceTuningInterval_) < getTimeStep())
666  decreaseForce();
667 
668  if (fmod(getTime() - t0_, velocityDampingInterval_) < getTimeStep())
669  dampVelocities();
670 
672  }
673  else
674  {
675  logger(VERBOSE, "DISSIPATING ENERGY");
676 
677  t0_ = getTime();
680  stage_++;
681  }
682  }
683 
684  /*
685  * \details If stage == 3 force is exponentially decreased and velocities are damped for a time duration of T = dissipationDuration_.
686  * If t>T or if the energy ratio is below the minimum threshold calculation is concluded and a few last operation are computed.
687  * They are:
688  * -timeMax is set to getTime(), in order to stop the calculation,
689  * -stage is set to 4 (if the energy threshold is not reached stage will remain 3 (because the simulation is stopped by the previous
690  * definition of timeMax): if this happens the user gets a warning, see actionsAfterSolve()).
691  * If MERCURYDPM_USE_MPI this process lasts for a time T = dissipationDuration_ - getTimeStep().
692  */
693  if (stage_ == 3)
694  {
695  // \brief Now force is damped and not decreased.
696  if (fmod(getTime() - t0_, forceTuningInterval_) < getTimeStep())
697  dampForce();
698 
699  if (fmod(getTime() - t0_, velocityDampingInterval_) < getTimeStep())
700  dampVelocities();
701 
703 #ifdef MERCURYDPM_USE_MPI
705 #else
708 #endif
709  {
710  printTime();
711  logger(VERBOSE, "ENERGY DISSIPATED\n");
712 
713  // stage++ now is a flag used to understand if the dissipation procedure has been completed.
714  stage_++;
715 
716  setTimeMax(getTime());
717  }
718  }
719 
720 }
Mdouble energyRatioTolerance_
Definition: BaseCluster.h:477
void decreaseForce()
This linearly decreases values of forceModulus (stage = 2).
Definition: BaseCluster.cc:1522
void applyCentralForce()
This applies force on each particle.
Definition: BaseCluster.cc:1481
Mdouble forceTuningDuration_
Definition: BaseCluster.h:612
Mdouble forceTuningInterval_
Definition: BaseCluster.h:608
void increaseForce()
This linearly increases the value of forceModulus (stage = 1).
Definition: BaseCluster.cc:1500
Mdouble t0_
Definition: BaseCluster.h:598
void dampVelocities()
This damps values of each particle velocity (stage = 1, stage = 2, stage = 3).
Definition: BaseCluster.cc:1509
void printTime() const override
Overrides DPMBase printTime(): this way variables of interest are shown.
Definition: BaseCluster.cc:945
Mdouble dissipationDuration_
Definition: BaseCluster.h:615
Mdouble velocityDampingInterval_
Definition: BaseCluster.h:610
Mdouble fileOutputTimeInterval_
Definition: BaseCluster.h:584
void dampForce()
This damps values of forceModulus (stage = 3).
Definition: BaseCluster.cc:1530
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:408
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 setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:873

References applyCentralForce(), dampForce(), dampVelocities(), decreaseForce(), dissipationDuration_, energyRatioTolerance_, fileOutputTimeInterval_, forceTuningDuration_, forceTuningInterval_, DPMBase::getElasticEnergy(), DPMBase::getKineticEnergy(), DPMBase::getTime(), DPMBase::getTimeStep(), increaseForce(), isCdatOutputOn(), isOverlOutputOn(), logger, makeDataAnalysis(), printTime(), DPMBase::setSaveCount(), DPMBase::setTimeMax(), stage_, t0_, velocityDampingInterval_, VERBOSE, writeToCdatFile(), and writeToOverlFile().

◆ actionsOnRestart()

void BaseCluster::actionsOnRestart ( )
overridevirtual

Overrides DPMBase actionsOnRestart(): in this all variables needed by the program for restarting are initialized.

In this all variables needed by the program for restarting are initialized. DPMBase::readRestartFile() is included.

Reimplemented from DPMBase.

886 {
887  readRestartFile();
888 
890 
892 
894 
896 
898 
899  setXBallsAdditionalArguments("-v0 -p 10");
900 
902 
904 
906 
908 
910 
911  if (isCdatOutputOn())
912  {
913  std::ostringstream cdatName;
914  cdatName << getName() << ".cdat";
915  cdatFile_.open(cdatName.str(), std::ios::app);
916  }
917 
918  if (isOverlOutputOn())
919  {
920  std::ostringstream overlName;
921  overlName << getName() << ".overl";
922  overlFile_.open(overlName.str(), std::ios::app);
923  }
924 
925  logger(VERBOSE, "CALCULATION RESTARTED\n");
926 }
@ NO_FILE
file will not be created/read
@ ONE_FILE
all data will be written into/ read from a single file called name_
bool isVtkOutputOn() const
This returns the bool variable that defines whether the cluster vtk output is written or not.
Definition: BaseCluster.cc:327
bool isFStatOutputOn() const
This returns the bool variable that defines whether the cluster fStat output is written or not.
Definition: BaseCluster.cc:355
bool isEneOutputOn() const
This returns the bool variable that defines whether the cluster ene output is written or not.
Definition: BaseCluster.cc:369
bool isRestartOutputOn() const
This returns the bool variable that defines whether the cluster restart output is written or not.
Definition: BaseCluster.cc:341
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
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:399
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1478
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1493
void setXBallsAdditionalArguments(std::string newXBArgs)
Set the additional arguments for xballs.
Definition: DPMBase.cc:1347
void setParticlesWriteVTK(bool writeParticlesVTK)
Sets whether particles are written in a VTK file.
Definition: DPMBase.cc:942
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
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:215

References cdatFile_, DPMBase::dataFile, dissipationDuration_, DPMBase::eneFile, fileOutputTimeInterval_, forceTuningDuration_, forceTuningInterval_, DPMBase::fStatFile, DPMBase::getName(), DPMBase::getTimeStep(), isCdatOutputOn(), isEneOutputOn(), isFStatOutputOn(), isOverlOutputOn(), isRestartOutputOn(), isVtkOutputOn(), logger, NO_FILE, ONE_FILE, overlFile_, DPMBase::readRestartFile(), DPMBase::restartFile, File::setFileType(), DPMBase::setParticlesWriteVTK(), DPMBase::setSaveCount(), DPMBase::setXBallsAdditionalArguments(), velocityDampingInterval_, and VERBOSE.

◆ applyCentralForce()

void BaseCluster::applyCentralForce ( )
private

This applies force on each particle.

This applies force on each particle. The force applied is proportional to the distance from force center (which is position_) and normalized by a ( 1/(2r) + 1/norm ) factor: this way even if a particle is very close to the force center (so -forceModulus * distanceFromForceCenter / (2 * r) ~ 0 ) a force F = -forceModulus * distanceFromForceCenter / norm is applied, which is the minimum guaranteed. (r is radiusParticle and norm is the 2-norm of distanceFromForceCenter vector).

1482 {
1483  for (auto p = particleHandler.begin(); p != particleHandler.end(); ++p)
1484  {
1485  //\brief distance from the center of forces (which is position_).
1486  Vec3D distanceFromForceCenter = (*p) -> getPosition() - position_;
1487 
1488  //\brief norm of distanceFromForceCenter vector
1489  Mdouble norm = distanceFromForceCenter.getLength();
1490 
1491  (*p) -> addForce( -forceModulus_ * distanceFromForceCenter * (2*radiusParticle_ + norm) / (2*radiusParticle_*norm) );
1492 
1493  }
1494 }
double Mdouble
Definition: GeneralDefine.h:34
Mdouble forceModulus_
Definition: BaseCluster.h:606
Vec3D getPosition() const
This returns the value of position_, which is the position in which the cluster will be inserted.
Definition: BaseCluster.cc:52
Mdouble radiusParticle_
Definition: BaseCluster.h:481
Definition: Vector.h:51
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Definition: Vector.cc:331

References BaseHandler< T >::begin(), BaseHandler< T >::end(), forceModulus_, Vec3D::getLength(), getPosition(), DPMBase::particleHandler, position_, and radiusParticle_.

Referenced by actionsAfterTimeStep().

◆ calculateTimeStep()

void BaseCluster::calculateTimeStep ( )
private

Calculates the time step.

Calculates the time step over the smallest particle. After this the time step and the ratio between collision time and time step are printed.

1061 {
1062  // if constantRestitution(true) mass for collision time will be automatically set to 1, otherwise the smallest particle's mass will be used
1064 
1065  // printing values of timeStep and ratio between collisionTime and timeStep
1066  std::ostringstream printTimeStep;
1067  printTimeStep << "timeStep: " << std::setprecision(4) << getTimeStep() << std::endl
1068  << "cT/tS, at least: " << std::fixed << std::setprecision(1)
1070  << std::endl;
1071  logger(VERBOSE, printTimeStep.str());
1072 }
Mdouble collisionTimeOverTimeStep_
Definition: BaseCluster.h:475
Mdouble smallestRadius_
Definition: BaseCluster.h:546
LinearPlasticViscoelasticFrictionSpecies * particleSpecies_
Definition: BaseCluster.h:513
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1427
void setTimeStep(Mdouble newDt)
Sets a new value for the simulation time step.
Definition: DPMBase.cc:1234
Mdouble getMassFromRadius(Mdouble radius) const
Definition: ParticleSpecies.cc:123

References collisionTimeOverTimeStep_, ParticleSpecies::getMassFromRadius(), BaseHandler< T >::getObject(), DPMBase::getTimeStep(), logger, particleSpecies_, DPMBase::setTimeStep(), smallestRadius_, DPMBase::speciesHandler, and VERBOSE.

Referenced by setupInitialConditions().

◆ computeInternalStructure()

void BaseCluster::computeInternalStructure ( )
private

This computes the internal structure of the cluster.

This computes the internal structure and solid fraction of the cluster. A total number of particles (equal to nInternalStructurePoints_) is tried to be inserted (with spherical coordinates identical to the ones used for inserting the actual particles) inside a sphere having radius radiusForSolidFraction_. If no interaction is found, nothing happens, otherwise the counuter nPointsInsideComponentsForMCTest is incremented and the corresponding position is written down in the internal structure file.

1604 {
1605 
1606 
1607 
1608  Vec3D mcPoint;
1609  SphericalParticle p0;
1610  Mdouble fictitiousGridPointRadiusRatio = 1.0e-5;
1612  p0.setRadius(radiusParticle_*fictitiousGridPointRadiusRatio);
1613  p0.setVelocity(Vec3D(0.0, 0.0, 0.0));
1614  int nMonteCarloSamplingPoints = nInternalStructurePoints_;
1615  Mdouble nPointsInsideComponentsForMCTest = 0;
1616 
1618 
1619  for (int i = 0; i < nMonteCarloSamplingPoints; ++i)
1620  {
1621 
1622  Mdouble theta = constants::pi * random.getRandomNumber(0, 2.0);
1623  Mdouble phi = acos(random.getRandomNumber(-1.0, 1.0));
1624  Mdouble rad = radiusForSolidFraction_*cbrt( random.getRandomNumber( 0, 1 ) );
1625 
1626  mcPoint.X = rad * sin(phi) * cos(theta);
1627  mcPoint.Y = rad * sin(phi) * sin(theta);
1628  mcPoint.Z = rad * cos(phi);
1629  mcPoint += centerOfMass_;
1630 
1631  p0.setPosition(mcPoint);
1632 
1633  if (!checkParticleForInteraction(p0)) // collision -> the counter goes to the mass fraction
1634  {
1635  nPointsInsideComponentsForMCTest++;
1636  intStructFile_ << std::scientific << std::setprecision(5) << std::setw(12) << mcPoint.X
1637  << std::setw(13) << mcPoint.Y << std::setw(13) << mcPoint.Z << std::setw(6) << 0 << std::endl;
1638  }
1639 
1640  }
1641 
1642  // Solid fraction (accordance between theoretical values and penetration depth max).
1643  // It is very important to notice that this value is accurate only if sliding friction is set to 0.5 and relative
1644  // tangential stiffness is set to 0.3 while creating the cluster. Different values do not guarantee accuracy.
1645  solidFractionIntStruct_ = nPointsInsideComponentsForMCTest/nMonteCarloSamplingPoints;
1646  Mdouble theoVal = 0.58 + 3*pow(0.58,2)*particleSpecies_->getPenetrationDepthMax();
1647  Mdouble diff = fabs(theoVal-solidFractionIntStruct_);
1648  Mdouble accordance = (theoVal - diff)/theoVal;
1649  // Solid fraction (accordance between theoretical values and average overlap).
1650  // It is very important to notice that this value is accurate only if sliding friction is set to 0.5 and relative
1651  // tangential stiffness is set to 0.3 while creating the cluster. Different values do not guarantee accuracy.
1652  solidFractionIntStruct_ = nPointsInsideComponentsForMCTest/nMonteCarloSamplingPoints;
1653  Mdouble theoValAvOverl = 0.58 + 3*pow(0.58,2)*meanRelativeOverlap_;
1654  Mdouble diffAvOverl = fabs(theoValAvOverl-solidFractionIntStruct_);
1655  Mdouble accordanceAvOverl = (theoValAvOverl - diffAvOverl)/theoValAvOverl;
1656 
1657  intStructFile_ << "n_points_inside_boundary: " << std::scientific << nMonteCarloSamplingPoints << std::endl;
1658  intStructFile_ << "n_points_inside_components: " << nPointsInsideComponentsForMCTest << std::endl;
1659  intStructFile_ << "solidFractionIntStruct_: " << std::fixed << std::setprecision(6) << solidFractionIntStruct_
1660  << ", accordance with theoretical values: " << 100*accordance << "%." << std::endl
1661  << "Accordance with average overlap: " << 100*accordanceAvOverl << "%." << std::endl
1662  << "It is very important to notice that this formula is accurate only if sliding friction" << std::endl
1663  << "is set to 0.5 and relative tangential stiffness is set to 0.3 while creating the cluster." << std::endl
1664  << "Different values do not guarantee accuracy." << std::endl << std::endl;
1665 
1666  /*
1667  * computeInternalStructure output is set to VERBOSE in order not to have too much output. If the user needs it,
1668  * it is enough to set it to INFO.
1669  */
1670 
1671  std::ostringstream printResults;
1672  printResults << "n_points_inside_boundary: " << std::scientific << nMonteCarloSamplingPoints << std::endl;
1673  printResults << "n_points_inside_components: " << nPointsInsideComponentsForMCTest << std::endl;
1674  printResults << "solidFractionIntStruct_: " << std::fixed << std::setprecision(6) << solidFractionIntStruct_
1675  << ", accordance with theoretical values: " << 100*accordance << "%." << std::endl
1676  << "Accordance with average overlap: " << 100*accordanceAvOverl << "%." << std::endl
1677  << "It is very important to notice that this formula is accurate only if sliding friction" << std::endl
1678  << "is set to 0.5 and relative tangential stiffness is set to 0.3 while creating the cluster." << std::endl
1679  << "Different values do not guarantee accuracy." << std::endl << std::endl;
1680  logger(VERBOSE, printResults.str());
1681 }
Mdouble meanRelativeOverlap_
Definition: BaseCluster.h:566
int nInternalStructurePoints_
Definition: BaseCluster.h:509
Mdouble solidFractionIntStruct_
Definition: BaseCluster.h:592
std::ofstream intStructFile_
Definition: BaseCluster.h:582
void makeIntenalStructureFile()
This creates the file needed for writing down datas from computeInternalStructure().
Definition: BaseCluster.cc:1720
Mdouble radiusForSolidFraction_
Definition: BaseCluster.h:588
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Definition: BaseInteractable.cc:350
virtual void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:239
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species)
Definition: BaseParticle.cc:553
void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:818
RNG random
This is a random generator, often used for setting up the initial conditions etc.....
Definition: DPMBase.h:1432
bool checkParticleForInteraction(const BaseParticle &P) final
Checks if given BaseParticle has an interaction with a BaseWall or other BaseParticle.
Definition: MercuryBase.cc:594
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
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
Mdouble X
the vector components
Definition: Vector.h:66
const Mdouble pi
Definition: ExtendedMath.h:45
Mdouble cos(Mdouble x)
Definition: ExtendedMath.cc:64
Mdouble sin(Mdouble x)
Definition: ExtendedMath.cc:44

References centerOfMass_, MercuryBase::checkParticleForInteraction(), mathsFunc::cos(), BaseHandler< T >::getObject(), RNG::getRandomNumber(), constants::i, intStructFile_, logger, makeIntenalStructureFile(), meanRelativeOverlap_, nInternalStructurePoints_, particleSpecies_, constants::pi, radiusForSolidFraction_, radiusParticle_, DPMBase::random, BaseInteractable::setPosition(), BaseParticle::setRadius(), BaseParticle::setSpecies(), BaseInteractable::setVelocity(), mathsFunc::sin(), solidFractionIntStruct_, DPMBase::speciesHandler, VERBOSE, Vec3D::X, Vec3D::Y, and Vec3D::Z.

Referenced by actionsAfterSolve().

◆ createAdjacencyMatrix()

void BaseCluster::createAdjacencyMatrix ( )
private

This calculates the adjacency matrix of the cluster.

This calculates the adjacency matrix of the cluster. Firstly a NxN matrix is created and filled with zeros. with a for cycle on the interactions then, if there's a contact between particle i and j adjacencyMatrix(i,j) = adjacencyMatrix(j,i) = 1. (N is the number of particles).

1541 {
1542  for (int i = 0; i < particleHandler.getSize(); i++)
1543  {
1544  std::vector<int> temporaryRowVector;
1545  temporaryRowVector.reserve(particleHandler.getSize());
1546 
1547  for (int j = 0; j < particleHandler.getSize(); j++)
1548  temporaryRowVector.push_back(0);
1549 
1550  adjacencyMatrix_.push_back(temporaryRowVector);
1551  }
1552 
1553  for (auto i = interactionHandler.begin(); i != interactionHandler.end(); ++i)
1554  {
1555  adjacencyMatrix_[(*i) -> getP() -> getIndex()][(*i) -> getI() -> getIndex()] = 1;
1556  adjacencyMatrix_[(*i) -> getI() -> getIndex()][(*i) -> getP() -> getIndex()] = 1;
1557  }
1558 }
std::vector< std::vector< int > > adjacencyMatrix_
Definition: BaseCluster.h:560
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1467

References adjacencyMatrix_, BaseHandler< T >::begin(), BaseHandler< T >::end(), BaseHandler< T >::getSize(), constants::i, DPMBase::interactionHandler, and DPMBase::particleHandler.

Referenced by actionsAfterSolve().

◆ dampForce()

void BaseCluster::dampForce ( )
private

This damps values of forceModulus (stage = 3).

This damps values of forceModulus (stage = 3). Damping is done by a factor forceDampingModulus_.

1531 {
1533 }
Mdouble forceDampingModulus_
Definition: BaseCluster.h:617

References forceDampingModulus_, and forceModulus_.

Referenced by actionsAfterTimeStep().

◆ dampVelocities()

void BaseCluster::dampVelocities ( )
private

This damps values of each particle velocity (stage = 1, stage = 2, stage = 3).

This damps values of each particle velocity (stage = 1, stage = 2, stage = 3). Damping is done by a factor velocityDampingModulus.

1510 {
1511  for (auto p = particleHandler.begin(); p != particleHandler.end(); ++p)
1512  {
1513  (*p) -> setVelocity(velocityDampingModulus_*( (*p) -> getVelocity() ));
1514  }
1515 }
void setVelocity(Vec3D v)
This sets the value of velocity after creation.
Definition: BaseCluster.cc:264
Vec3D getVelocity()
This gets the value of velocity after creation.
Definition: BaseCluster.cc:257
Mdouble velocityDampingModulus_
Definition: BaseCluster.h:505

References BaseHandler< T >::begin(), BaseHandler< T >::end(), getVelocity(), DPMBase::particleHandler, setVelocity(), and velocityDampingModulus_.

Referenced by actionsAfterTimeStep().

◆ decreaseForce()

void BaseCluster::decreaseForce ( )
private

This linearly decreases values of forceModulus (stage = 2).

This linearly decreases values of forceModulus (stage = 2). forceModulus varies from maximumForceModulus to 0 linearly with time. Actually last value reached of forceModulus with this is maximumForceModulus * timeStep / forceTuningDuration because this process is discrete: starting from this value forceModulus will then be damped in stage = 3.

1523 {
1525 }
Mdouble maximumForceModulus_
Definition: BaseCluster.h:604

References forceModulus_, forceTuningDuration_, DPMBase::getTime(), maximumForceModulus_, and t0_.

Referenced by actionsAfterTimeStep().

◆ doAmatOutput()

void BaseCluster::doAmatOutput ( bool  iAOO)

This sets the bool variable that defines whether the cluster adjacency matrix output will be written or not.

This sets the bool variable that defines whether the cluster adjacency matrix output will be written or not.

306  {
307  isAmatOutputOn_ = iAOO;
308 }
bool isAmatOutputOn_
Definition: BaseCluster.h:522

References isAmatOutputOn_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and ClusterGenerator::ClusterGenerator().

◆ doCdatOutput()

void BaseCluster::doCdatOutput ( bool  iCOO)

This sets the bool variable that defines whether the cluster data output will be written or not.

This sets the bool variable that defines whether the cluster data output will be written or not.

278  {
279  isCdatOutputOn_ = iCOO;
280 }
bool isCdatOutputOn_
Definition: BaseCluster.h:518

References isCdatOutputOn_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and ClusterGenerator::ClusterGenerator().

◆ doEneOutput()

void BaseCluster::doEneOutput ( bool  e)

This sets the bool variable that defines whether the cluster ene output will be written or not.

This sets the bool variable that defines whether the cluster ene output will be written or not.

376  {
377  isEneOutputOn_ = e;
378 }
bool isEneOutputOn_
Definition: BaseCluster.h:532

References isEneOutputOn_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and ClusterGenerator::ClusterGenerator().

◆ doFStatOutput()

void BaseCluster::doFStatOutput ( bool  fS)

This sets the bool variable that defines whether the cluster fStat output will be written or not.

This sets the bool variable that defines whether the cluster fStat output will be written or not.

362  {
363  isFStatOutputOn_ = fS;
364 }
bool isFStatOutputOn_
Definition: BaseCluster.h:530

References isFStatOutputOn_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and ClusterGenerator::ClusterGenerator().

◆ doIntStrucOutput()

void BaseCluster::doIntStrucOutput ( bool  iISOO)

This sets the bool variable that defines whether the cluster internal structure output will be written or not.

This sets the bool variable that defines whether the cluster internal structure output will be written or not.

320  {
321  isIntStrucOutputOn_ = iISOO;
322 }
bool isIntStrucOutputOn_
Definition: BaseCluster.h:524

References isIntStrucOutputOn_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and ClusterGenerator::ClusterGenerator().

◆ doOverlOutput()

void BaseCluster::doOverlOutput ( bool  iOOO)

This sets the bool variable that defines whether the cluster overlap output will be written or not.

This sets the bool variable that defines whether the cluster overlap output will be written or not.

292  {
293  isOverlOutputOn_ = iOOO;
294 }
bool isOverlOutputOn_
Definition: BaseCluster.h:520

References isOverlOutputOn_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and ClusterGenerator::ClusterGenerator().

◆ doRestartOutput()

void BaseCluster::doRestartOutput ( bool  r)

This sets the bool variable that defines whether the cluster restart output will be written or not.

This sets the bool variable that defines whether the cluster restart output will be written or not.

348  {
349  isRestartOutputOn_ = r;
350 }
bool isRestartOutputOn_
Definition: BaseCluster.h:528

References isRestartOutputOn_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and ClusterGenerator::ClusterGenerator().

◆ doVtkOutput()

void BaseCluster::doVtkOutput ( bool  iVOO)

This sets the bool variable that defines whether the cluster vtk output will be written or not.

This sets the bool variable that defines whether the cluster vtk output will be written or not.

334  {
335  isVtkOutputOn_ = iVOO;
336 }
bool isVtkOutputOn_
Definition: BaseCluster.h:526

References isVtkOutputOn_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and ClusterGenerator::ClusterGenerator().

◆ getAverageOverlap()

Mdouble BaseCluster::getAverageOverlap ( )

this returns the average overlap.

this returns the average overlap.

390  {
391  return meanRelativeOverlap_;
392 }

References meanRelativeOverlap_.

◆ getClusterId()

unsigned int BaseCluster::getClusterId ( ) const

This returns the value of the cluster ID.

This returns the value of the cluster ID.

175  {
176  return idCluster_;
177 }
unsigned int idCluster_
Definition: BaseCluster.h:493

References idCluster_.

Referenced by makeCdatFile().

◆ getCollisionTimeOverTimeStep()

Mdouble BaseCluster::getCollisionTimeOverTimeStep ( ) const

This returns the value of the ratio between collision time and time step.

This returns the value of the ratio between collision time and time step

68  {
70 }

References collisionTimeOverTimeStep_.

Referenced by makeCdatFile().

◆ getEnergyRatioTolerance()

Mdouble BaseCluster::getEnergyRatioTolerance ( ) const

This returns the value of the value of the energy ratio threshold under which the process can be considered static, and so over.

This returns the value of the value of the energy ratio threshold under which the process can be considered static, and so over.

226  {
227  return energyRatioTolerance_;
228 }

References energyRatioTolerance_.

Referenced by makeCdatFile().

◆ getFinalMassFraction()

Mdouble BaseCluster::getFinalMassFraction ( )

This gets the final value obtained for the mass fraction;.

This return the value of the obtained mass fraction (could be a little different than the desired). In particular, if the internal structure output is computed, the value for the mass fraction will be solidFractionIntStruct_ (computed within the internal structure and more precise), otherwise it will be solidFraction_.

165  {
168  else
169  return solidFraction_;
170 }
Mdouble solidFraction_
Definition: BaseCluster.h:590

References isIntStrucOutputOn_, solidFraction_, and solidFractionIntStruct_.

◆ getMeanClusterRadius()

Mdouble BaseCluster::getMeanClusterRadius ( )

this returns meanClusterRadius (radius of an ideal perfectly spherical cluster, there's no setter).

this returns meanClusterRadius (radius of an ideal perfectly spherical cluster, there's no setter).

383  {
384  return meanClusterRadius_;
385 }
Mdouble meanClusterRadius_
Definition: BaseCluster.h:501

References meanClusterRadius_.

◆ getNumberOfInternalStructurePoints()

int BaseCluster::getNumberOfInternalStructurePoints ( ) const

This returns the value of the number of particles used to compute internal structure.

This returns the value of the length of the number of particles used to compute the internal structure.

209  {
211 }

References nInternalStructurePoints_.

Referenced by makeCdatFile().

◆ getNumberOfParticles()

int BaseCluster::getNumberOfParticles ( ) const

This returns the value of the number of particles in the cluster.

This returns the value of the number of particles in the cluster.

126  {
127  return nParticles_;
128 }
int nParticles_
Definition: BaseCluster.h:487

References nParticles_.

Referenced by makeCdatFile().

◆ getParticleSpecies()

LinearPlasticViscoelasticFrictionSpecies * BaseCluster::getParticleSpecies ( ) const

This returns the species of the particle.

This returns the species of the particle.

243  {
244  return particleSpecies_;
245 }

References particleSpecies_.

◆ getPosition()

Vec3D BaseCluster::getPosition ( ) const

This returns the value of position_, which is the position in which the cluster will be inserted.

This returns the value of position_, which is the position in which the cluster will be inserted (it is also the centre of mass of the cluster).

52  {
53  return position_;
54 }

References position_.

Referenced by applyCentralForce(), and makeDataAnalysis().

◆ getRadiusParticle()

Mdouble BaseCluster::getRadiusParticle ( ) const

This returns the value of particles' radius if there's no dispersity in size. In case of dispersity != 1, this is the radius from which all radii are computed (as a consequence in this case it is also the pseudo-averaged radius).

This returns the value of particles' radius if there's no dispersity in size. If the dispersity is not 1, this is the value on which all radii will be computed.

88  {
89  return radiusParticle_;
90 }

References radiusParticle_.

Referenced by makeCdatFile().

◆ getSizeDispersityParticle()

Mdouble BaseCluster::getSizeDispersityParticle ( ) const

This returns the value of particles' dispersity in size.

This returns the value of particles' dispersity in size.

109  {
111 }
Mdouble sizeDispersityParticle_
Definition: BaseCluster.h:485

References sizeDispersityParticle_.

Referenced by makeCdatFile().

◆ getVelocity()

Vec3D BaseCluster::getVelocity ( )

This gets the value of velocity after creation.

This returns the velocity of the cluster after creation.

257  {
258  return clusterVelocity_;
259 }

References clusterVelocity_.

Referenced by dampVelocities().

◆ getVelocityDampingModulus()

Mdouble BaseCluster::getVelocityDampingModulus ( ) const

This returns the value of the velocity damping modulus.

This returns the value of the velocity damping modulus.

192  {
194 }

References velocityDampingModulus_.

Referenced by makeCdatFile().

◆ increaseForce()

void BaseCluster::increaseForce ( )
private

This linearly increases the value of forceModulus (stage = 1).

This increases the value of forceModulus (stage = 1). ForceModulus varies from 0 to maximumForceModulus linearly with time.

References forceModulus_, forceTuningDuration_, DPMBase::getTime(), maximumForceModulus_, and t0_.

Referenced by actionsAfterTimeStep().

◆ insertParticles()

void BaseCluster::insertParticles ( )
private

Inserts particles inside the domain.

Inserts particles inside the domain with a while cycle.

1079 {
1080  int nParticlesInserted = 0;
1081 
1082  while (nParticlesInserted < nParticles_)
1083  {
1084  /* nParticleInserted corresponds to the index of the particle which is being inserted:
1085  * for example if no particle has been inserted yet nParticlesInserted=0 which is the
1086  * index of the first particle, and so on. For this reason this variable is the input
1087  * for particleInsertionSuccessful.
1088  */
1089  if (particleInsertionSuccessful(nParticlesInserted))
1090  {
1091  nParticlesInserted++;
1092  }
1093  else
1094  {
1095  logger(ERROR, "Cannot insert all particles, try to decrase the value of initialSolidFraction in "
1096  "BaseCluster::setDomainLimits();\n"
1097  "Inserted %/% particles.", nParticlesInserted, nParticles_);
1098  }
1099  }
1100  logger(VERBOSE, "PARTICLE INSERTION TERMINATED SUCCESSFULLY\n");
1101 }
@ ERROR
bool particleInsertionSuccessful(int n)
This function tries to insert the n-th particle (returns true if it manage to do that)....
Definition: BaseCluster.cc:1199

References ERROR, logger, nParticles_, particleInsertionSuccessful(), and VERBOSE.

Referenced by setupInitialConditions().

◆ isAmatOutputOn()

bool BaseCluster::isAmatOutputOn ( ) const

This returns the bool variable that defines whether the cluster adjacency matrix output is written or not.

This returns the bool variable that defines whether the cluster adjacency matrix output is written or not.

299  {
300  return isAmatOutputOn_;
301 }

References isAmatOutputOn_.

Referenced by actionsAfterSolve().

◆ isCdatOutputOn()

bool BaseCluster::isCdatOutputOn ( ) const

This returns the bool variable that defines whether the cluster data output (which is NOT the mercury data output) is written or not.

This returns the bool variable that defines whether the cluster data output is written or not.

271  {
272  return isCdatOutputOn_;
273 }

References isCdatOutputOn_.

Referenced by actionsAfterSolve(), actionsAfterTimeStep(), actionsOnRestart(), and setupInitialConditions().

◆ isEneOutputOn()

bool BaseCluster::isEneOutputOn ( ) const

This returns the bool variable that defines whether the cluster ene output is written or not.

This returns the bool variable that defines whether the cluster ene output is written or not.

369  {
370  return isEneOutputOn_;
371 }

References isEneOutputOn_.

Referenced by actionsOnRestart(), and setupInitialConditions().

◆ isFStatOutputOn()

bool BaseCluster::isFStatOutputOn ( ) const

This returns the bool variable that defines whether the cluster fStat output is written or not.

This returns the bool variable that defines whether the cluster fStat output is written or not.

355  {
356  return isFStatOutputOn_;
357 }

References isFStatOutputOn_.

Referenced by actionsOnRestart(), and setupInitialConditions().

◆ isIntStrucOutputOn()

bool BaseCluster::isIntStrucOutputOn ( ) const

This returns the bool variable that defines whether the cluster internal structure output is written or not.

This returns the bool variable that defines whether the cluster internal structure output is written or not.

313  {
314  return isIntStrucOutputOn_;
315 }

References isIntStrucOutputOn_.

Referenced by actionsAfterSolve(), read(), and write().

◆ isOverlOutputOn()

bool BaseCluster::isOverlOutputOn ( ) const

This returns the bool variable that defines whether the cluster overlap output is written or not.

This returns the bool variable that defines whether the cluster overlap output is written or not.

285  {
286  return isOverlOutputOn_;
287 }

References isOverlOutputOn_.

Referenced by actionsAfterSolve(), actionsAfterTimeStep(), actionsOnRestart(), and setupInitialConditions().

◆ isRestartOutputOn()

bool BaseCluster::isRestartOutputOn ( ) const

This returns the bool variable that defines whether the cluster restart output is written or not.

This returns the bool variable that defines whether the cluster restart output is written or not.

341  {
342  return isRestartOutputOn_;
343 }

References isRestartOutputOn_.

Referenced by actionsOnRestart(), and setupInitialConditions().

◆ isVtkOutputOn()

bool BaseCluster::isVtkOutputOn ( ) const

This returns the bool variable that defines whether the cluster vtk output is written or not.

This returns the bool variable that defines whether the cluster vtk output is written or not.

327  {
328  return isVtkOutputOn_;
329 }

References isVtkOutputOn_.

Referenced by actionsOnRestart(), and setupInitialConditions().

◆ makeAmatFile()

void BaseCluster::makeAmatFile ( )
private

This creates the adjacency matrix file.

This creates the adjacency matrix file.

1564 {
1565  std::ostringstream amatName;
1566  amatName << getName() << ".amat";
1567 
1568  amatFile_.open(amatName.str(), std::ios::out);
1569  amatFile_ << "ADJACENCY MATRIX" << std::endl << std::endl;
1570 }
std::ofstream amatFile_
Definition: BaseCluster.h:580

References amatFile_, and DPMBase::getName().

Referenced by actionsAfterSolve().

◆ makeCdatFile()

void BaseCluster::makeCdatFile ( )
private

Creates the cluster data output file.

Creates the cluster data output file. In the first lines of the file some important infos about the cluster are written. They are (in order): -Ratio between collision time and time step, -radiusParticle, -size dispersity of particles, -density of the particles -number of particles, -cluster ID (group ID), -safety factor of the cluster radius, -sliding friction coefficient, -rolling friction coefficient, -torsion friction coefficient, -loading stiffness, -unloading stiffness, -cohesion stiffness, -number of particles for computing internal structure (if needed), -energy ratio threshold, -velocity damping modulus, -restitution cohefficient.

After this the indentation of the file is written. The values that will be written are (in order): -elastic energy, -energy ratio threshold, -mean coordination number, -mean cluster radius, -solid fraction, -force modulus, -mean force on interaction, -minimum relative overlap, -mean relative overlap, -maximum realative overlap, -center of mass.

1138 {
1139  std::ostringstream cdatName;
1140  cdatName << getName() << ".cdat";
1141 
1142  cdatFile_.open(cdatName.str(), std::ios::out);
1143 
1144  cdatFile_ << "CLUSTER DATA AND INFORMATION" << std::endl << std::endl;
1145  cdatFile_ << "position: " << position_ << std::endl;
1146  cdatFile_ << "collisionTimeOverTimeStep: " << getCollisionTimeOverTimeStep() << std::endl;
1147  cdatFile_ << "radiusParticle: " << std:: scientific << std::setprecision(2) << getRadiusParticle() << std::endl;
1148  cdatFile_ << "sizeDispersityParticle: " << std::defaultfloat << getSizeDispersityParticle() << std::endl;
1149  cdatFile_ << "densityParticle: " << std:: scientific << particleSpecies_ -> getDensity() << std::endl;
1150  cdatFile_ << "nParticles: " << std::defaultfloat << getNumberOfParticles() << std::endl;
1151  cdatFile_ << "idCluster: " << getClusterId() << std::endl;
1152  cdatFile_ << "slidingFrictionCoeff: " << particleSpecies_ -> getSlidingFrictionCoefficient() << std::endl;
1153  cdatFile_ << "rollingFrictionCoeff: " << particleSpecies_ -> getRollingFrictionCoefficient() << std::endl;
1154  cdatFile_ << "torsionFrictionCoeff: " << particleSpecies_ -> getTorsionFrictionCoefficient() << std::endl;
1155  // If constantRestitution(true) loading, unloading, and cohesion stiffness are multiplied by the mass of a particle (massParticle_) whose radius is radiusParticle_*2/(1+sizeDispersityParticle_),
1156  // which is the mass that should be used to compute collision time.
1157  cdatFile_ << "loadingStiffness: " << std::scientific << particleSpecies_ -> getLoadingStiffness()
1158  * (particleSpecies_->getConstantRestitution()?massParticle_:1) << std::endl;
1159  cdatFile_ << "unloadingStiffnessMax: " << particleSpecies_ -> getUnloadingStiffnessMax()
1160  * (particleSpecies_->getConstantRestitution()?massParticle_:1) << std::endl;
1161  cdatFile_ << "cohesionStiffness: " << particleSpecies_ -> getCohesionStiffness()
1162  * (particleSpecies_->getConstantRestitution()?massParticle_:1) << std::endl;
1163  cdatFile_ << "restitutionCoefficient: " << particleSpecies_ -> getRestitutionCoefficient(massParticle_) << std::endl;
1164  cdatFile_ << "collisionTime: " << std::scientific << std::setprecision(3) << particleSpecies_ -> getCollisionTime(massParticle_) << std::endl;
1166  cdatFile_ << "nInternalStructurePoints: " << getNumberOfInternalStructurePoints() << std::endl;
1167  cdatFile_ << "energyRatioTolerance: " << getEnergyRatioTolerance() << std::endl;
1168  cdatFile_ << "velocityDampingModulus: " << std::defaultfloat << getVelocityDampingModulus() << std::endl << std::endl;
1169 
1170  cdatFile_ << "progress" << std::setw(16) << "ElastEne" << std::setw(23) << "Ekin/ElastEne" << std::setw(18) << "coord_number" << std::setw(14) << "meanRadius"
1171  << std::setw(19) << "solidFraction" << std::setw(16) << "forceModulus" << std::setw(22) << "AveFOnOverl" << std::setw(15) << "dMin" << std::setw(17) << "dMean"
1172  << std::setw(14) << "dMax" << std::setw(24) << "Mass Centre" << std::endl;
1173 }
Mdouble getRadiusParticle() const
This returns the value of particles' radius if there's no dispersity in size. In case of dispersity !...
Definition: BaseCluster.cc:88
Mdouble massParticle_
Definition: BaseCluster.h:548
int getNumberOfParticles() const
This returns the value of the number of particles in the cluster.
Definition: BaseCluster.cc:126
Mdouble getEnergyRatioTolerance() const
This returns the value of the value of the energy ratio threshold under which the process can be cons...
Definition: BaseCluster.cc:226
Mdouble getVelocityDampingModulus() const
This returns the value of the velocity damping modulus.
Definition: BaseCluster.cc:192
Mdouble getSizeDispersityParticle() const
This returns the value of particles' dispersity in size.
Definition: BaseCluster.cc:109
unsigned int getClusterId() const
This returns the value of the cluster ID.
Definition: BaseCluster.cc:175
Mdouble getCollisionTimeOverTimeStep() const
This returns the value of the ratio between collision time and time step.
Definition: BaseCluster.cc:68
int getNumberOfInternalStructurePoints() const
This returns the value of the number of particles used to compute internal structure.
Definition: BaseCluster.cc:209

References cdatFile_, getClusterId(), getCollisionTimeOverTimeStep(), getEnergyRatioTolerance(), DPMBase::getName(), getNumberOfInternalStructurePoints(), getNumberOfParticles(), getRadiusParticle(), getSizeDispersityParticle(), getVelocityDampingModulus(), massParticle_, particleSpecies_, and position_.

Referenced by setupInitialConditions().

◆ makeDataAnalysis()

void BaseCluster::makeDataAnalysis ( )
private

This functions computes some important cluster information needed by the program.

This functions computes some important cluster information needed by the program. They are (in order): -mean coordination number, -center of mass, -mean cluster radius, -cluster radius used to compute solid fraction (different from mean cluster radius, see

below), -solid fraction, -mean force acting on interaction, -maximum overlap, -mean overlap, -minimum overlap.

1257 {
1258  // resetting counters and variables
1259  Mdouble solidVolumeInsideRadius = 0;
1260  Vec3D localMin;
1261  Vec3D localMax;
1262  localMin.setZero();
1263  localMax.setZero();
1265  //\brief vector in which it is saved the relative position of a particle from the center of mass
1266  Vec3D distanceFromCenterOfMass;
1267  //\brief distance from the center of mass of the furthest particle
1268  Mdouble furthestParticleDistance = 0;
1269  // number of particles whose distance d from the center of mass is d > furthestParticleDistance - radiusParticle_
1270  int counter = 0;
1271  Mdouble relativeOverlap = 0;
1272 
1273  meanClusterRadius_ = 0.0;
1275  maxRelativeOverlap_ = 0.0;
1276  meanRelativeOverlap_ = 0.0;
1278 
1279  // loops over each particle to compute mean coordination number and center of mass.
1280  for (auto p = particleHandler.begin(); p != particleHandler.end(); ++p) {
1281 
1282  meanCoordinationNumber_ += ((*p)->getInteractions()).size();
1283 
1284  centerOfMass_ += ((*p)->getVolume()) * ((*p)->getPosition());
1285  }
1286 
1289 
1290 
1291  // loops over each particle to compute the furthest particle from the center of mass.
1292  for (auto p = particleHandler.begin(); p != particleHandler.end(); ++p) {
1293 
1294  distanceFromCenterOfMass = (*p)->getPosition() - centerOfMass_;
1295 
1296  if (distanceFromCenterOfMass.getLength() > furthestParticleDistance)
1297  furthestParticleDistance = distanceFromCenterOfMass.getLength();
1298 
1299  }
1300 
1301  for (auto p = particleHandler.begin(); p != particleHandler.end(); ++p) {
1302 
1303  distanceFromCenterOfMass = (*p)->getPosition() - centerOfMass_;
1304 
1305  if (distanceFromCenterOfMass.getLength() > furthestParticleDistance - radiusParticle_) {
1306  meanClusterRadius_ += distanceFromCenterOfMass.getLength();
1307  counter++;
1308  }
1309 
1310  }
1311 
1312  meanClusterRadius_ /= counter;
1314 
1315 
1316  /*
1317  * \details This is the radius used to compute solid fraction: it is smaller than the meanClusterRadius.
1318  */
1320 
1321  /*
1322  * \details With a for cycle the volume of the particles inside radiusForSolidFraction is computed and after this the value of solid
1323  * fraction is calculated. This value is less precise as the maximum penetration depth increases and more precise as the
1324  * number of particle increases.
1325  */
1326  for (auto p = particleHandler.begin(); p != particleHandler.end(); ++p)
1327  {
1328  distanceFromCenterOfMass = (*p) -> getPosition() - centerOfMass_;
1329 
1330  if( distanceFromCenterOfMass.getLength() < radiusForSolidFraction_ )
1331  solidVolumeInsideRadius += (*p) -> getVolume();
1332  }
1333 
1334  solidFraction_ = 3 * solidVolumeInsideRadius / ( 4 * constants::pi * pow(radiusForSolidFraction_, 3) );
1335 
1336  // loops over every interaction to compute mean force acting on interaction, maximum, mean and minimum relative particle overlap.
1337  for (std::vector<BaseInteraction*>::const_iterator i = interactionHandler.begin(); i != interactionHandler.end(); ++i)
1338  {
1339 
1340  /*
1341  * \details the relative overlap is computed as an average of the relative overlap on the two particles.
1342  * rO = ( O/R1 + O/R2 ) / 2.
1343  */
1344  relativeOverlap = ((*i) -> getOverlap())/(particleHandler.getObject((*i) -> getP() -> getIndex()) -> getRadius()) +
1345  ((*i) -> getOverlap())/(particleHandler.getObject((*i) -> getI() -> getIndex()) -> getRadius());
1346  relativeOverlap /= 2;
1347  meanRelativeOverlap_ += relativeOverlap;
1348  if (relativeOverlap > maxRelativeOverlap_)
1349  maxRelativeOverlap_ = relativeOverlap;
1350 
1351  if (relativeOverlap < minRelativeOverlap_)
1352  minRelativeOverlap_ = relativeOverlap;
1353  }
1355 }
Mdouble minRelativeOverlap_
Definition: BaseCluster.h:568
Mdouble meanCoordinationNumber_
Definition: BaseCluster.h:562
Mdouble maxRelativeOverlap_
Definition: BaseCluster.h:564
Mdouble totalParticleVolume_
Definition: BaseCluster.h:550
void setZero()
Sets all elements to zero.
Definition: Vector.cc:43

References BaseHandler< T >::begin(), centerOfMass_, BaseHandler< T >::end(), Vec3D::getLength(), BaseHandler< T >::getObject(), getPosition(), BaseHandler< T >::getSize(), constants::i, DPMBase::interactionHandler, maxRelativeOverlap_, meanClusterRadius_, meanCoordinationNumber_, meanRelativeOverlap_, minRelativeOverlap_, DPMBase::particleHandler, constants::pi, radiusForSolidFraction_, radiusParticle_, Vec3D::setZero(), sizeDispersityParticle_, solidFraction_, and totalParticleVolume_.

Referenced by actionsAfterSolve(), and actionsAfterTimeStep().

◆ makeGnuplotFile()

void BaseCluster::makeGnuplotFile ( )
private

This creates the gnuplot file needed for printing force vs overlaps values.

This creates the gnuplot file needed for printing force vs overlaps values. After setting output tipe, title, labels and grid, all columns needed for overlap printing are written after the plot command. Only overlaps present at the end of the process will be printed. Loading this file with gnuplot a jpeg image is obtained showing all forces vs overlaps.

1690 {
1691  std::ostringstream gnuplotname;
1692  gnuplotname << getName() << ".gnuplot";
1693 
1694  gnuplotFile_.open(gnuplotname.str(), std::ios::out);
1695  gnuplotFile_ << "set terminal jpeg" << std::endl;
1696  gnuplotFile_ << "set output \"" << getName() << "_overlaps" << ".jpeg\"" << std::endl;
1697  std::string titleLine=R"(set title "Overlap Vs Force")";// font ",14"
1698  std::string xLabel=R"(set xlabel "Overlap")";
1699  std::string yLabel=R"(set ylabel "Force")";
1700  gnuplotFile_ << titleLine << std::endl;
1701  gnuplotFile_ << xLabel << std::endl;
1702  gnuplotFile_ << yLabel << std::endl;
1703  gnuplotFile_ << "set grid" << std::endl;
1704  gnuplotFile_ << "plot ";
1705  for (int i = 0; i < interactionHandler.getSize(); ++i)
1706  {
1707  gnuplotFile_ << "\"" << getName() << ".overl" << "\"" << " using " << 2*i+4 << ":" << 2*i+3 << " title \"\" with lines lt 1 dashtype 2, ";
1708  }
1709 
1710  gnuplotFile_.close();
1711 
1712 }
std::ofstream gnuplotFile_
Definition: BaseCluster.h:578

References DPMBase::getName(), BaseHandler< T >::getSize(), gnuplotFile_, constants::i, and DPMBase::interactionHandler.

Referenced by actionsAfterSolve().

◆ makeIntenalStructureFile()

void BaseCluster::makeIntenalStructureFile ( )
private

This creates the file needed for writing down datas from computeInternalStructure().

This creates the file needed for writing down datas from computeInternalStructure(). In the first row nInternalStructurePoints is printed: this number is the total number of points tried to be inserted (and so is grater than the number of lines of the file, which corresponds to the number of points that gave interaction).

1721 {
1722  std::ostringstream intStructName;
1723  intStructName << getName() << ".struct";
1724 
1725  intStructFile_.open(intStructName.str(), std::ios::out);
1726  intStructFile_ << "Number of Montecarlo points: " << nInternalStructurePoints_ << std::endl;
1727 }

References DPMBase::getName(), intStructFile_, and nInternalStructurePoints_.

Referenced by computeInternalStructure().

◆ makeOverlFile()

void BaseCluster::makeOverlFile ( )
private

Creates the cluster overlap output file.

\detail Creates the cluster overlap output file. In this file forces vs overlaps will be written. Together with this a ".gnuplot" file is created, which reads from this, ready to be loaded (see BaseCluster::makeGnuplotFile() ).

1181 {
1182  std::ostringstream overlName;
1183  overlName << getName() << ".overl";
1184 
1185  overlFile_.open(overlName.str(), std::ios::out);
1186  overlFile_ << "Overlap Vs Normal Force" << std::endl;
1187 }

References DPMBase::getName(), and overlFile_.

Referenced by setupInitialConditions().

◆ particleInsertionSuccessful()

bool BaseCluster::particleInsertionSuccessful ( int  n)
private

This function tries to insert the n-th particle (returns true if it manage to do that). It is inside insertParticles().

Tries to insert a particle in a spherical area centered around the initial site of the cluster; With an insertion fail counter and a while cycle this function tries to insert a particle in the domain: in order to do this, after computing random spherical coordinates, checks for interaction. If no interaction is detected the particle is inserted and returns true, if it fails 1000 times returns false and the computation is over. The spherical coordinates are rescaled over the radius by a factor cbrt(rand(0,1) ) and also over vertical angle thanks to acos(rand (-1, 1) ): this has been done in order to ensure the most possible spherical shape to the cluster, which with classic spherical coordinates was not achieved.

Parameters
nindex of the particle being inserted.
Returns
bool: true if particle inserted, false if not.
1199  {
1200 
1201  int insertionFailCounter = 0;
1202  Mdouble rad, theta, phi;
1203  Vec3D particlePosition;
1204  SphericalParticle p0;
1205 
1206  // setup of particle properties and initial conditions (besides position)
1207  p0.setVelocity(Vec3D(0.0, 0.0, 0.0));
1208  p0.setRadius(radii_[n]);
1210  p0.setGroupId(idCluster_);
1211 
1212  while (insertionFailCounter < 1000)
1213  {
1214  theta = constants::pi * random.getRandomNumber(0, 2.0);
1215  phi = acos(random.getRandomNumber(-1.0, 1.0));
1216  rad = p0.getRadius() + cbrt( random.getRandomNumber( 0, 1 ) ) * ( 0.5 * boxSize_ - 2.01 * p0.getRadius() );
1217 
1218  particlePosition.X = position_.X + rad * sin(phi) * cos(theta);
1219  particlePosition.Y = position_.Y + rad * sin(phi) * sin(theta);
1220  particlePosition.Z = position_.Z + rad * cos(phi);
1221 
1222  p0.setPosition(particlePosition);
1223 
1225  {
1227  return true;
1228  }
1229 
1230  insertionFailCounter++;
1231  }
1232 
1233  return false;
1234 }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
Mdouble boxSize_
Definition: BaseCluster.h:554
std::vector< Mdouble > radii_
Definition: BaseCluster.h:544
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
void setGroupId(unsigned groupId)
Definition: BaseObject.h:131
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:348

References boxSize_, MercuryBase::checkParticleForInteraction(), BaseHandler< T >::copyAndAddObject(), mathsFunc::cos(), BaseHandler< T >::getObject(), BaseParticle::getRadius(), RNG::getRandomNumber(), idCluster_, n, DPMBase::particleHandler, constants::pi, position_, radii_, DPMBase::random, BaseObject::setGroupId(), BaseInteractable::setPosition(), BaseParticle::setRadius(), BaseParticle::setSpecies(), BaseInteractable::setVelocity(), mathsFunc::sin(), DPMBase::speciesHandler, Vec3D::X, Vec3D::Y, and Vec3D::Z.

Referenced by insertParticles().

◆ printTime()

void BaseCluster::printTime ( ) const
overridevirtual

Overrides DPMBase printTime(): this way variables of interest are shown.

Overrides DPMBase printTime(): this way stage and variables of interest are shown. They are (in order): -computation progress, -energy ratio, -mean coordination number, -mean cluster radius, -mass fraction, -force modulus, -minimum relative overlap, -mean relative overlap, -maximum realative overlap, -center of mass, -number of particles.

printTime output is set to VERBOSE in order not to have too much output. If the user needs it, it is enough to set it to INFO.

Reimplemented from DPMBase.

946 {
947  std::ostringstream printTime;
948  switch (stage_)
949  {
950  case 1: printTime << "Compression progress: " << std::setw(3) << int( ceil( 100 * (getTime() - t0_) / forceTuningDuration_ ) ) << "%, ";
951  break;
952 
953  case 2: printTime << "Decompression progress: " << std::setw(3) << int( ceil( 100 * (getTime() - t0_) / forceTuningDuration_ ) )<< "%, ";
954  break;
955 
956  case 3: printTime << "Dissipating energy: ";
957  break;
958 
959  default: printTime << "Final values: ";
960  break;
961  }
962  printTime <<
963  "E_ratio = " << std::scientific << std::setprecision(2) << std::setw(8) << getKineticEnergy()/getElasticEnergy() <<
964  ", cN = " << std::fixed << std::setw(5) << meanCoordinationNumber_ << ", rMean = " << std::scientific << meanClusterRadius_ <<
965  ", mF = " << std::fixed << std::setprecision(3) << solidFraction_ << ", Force Modulus = " << std::scientific << forceModulus_ <<
966  ", dMin = " << std::fixed << std::setw(7) << std::setprecision(5) << minRelativeOverlap_ << ", dMean = " << std::setw(7) << meanRelativeOverlap_ <<
967  ", dMax = " << maxRelativeOverlap_ << ", centerOfMass = " << std::scientific << std::setprecision(5) << std::setw(13) << centerOfMass_.X
968  << std::setw(14) << centerOfMass_.Y << std::setw(14) << centerOfMass_.Z <<
969  " nParticles: " << particleHandler.getSize();
970  logger(VERBOSE, printTime.str());
971 }

References centerOfMass_, forceModulus_, forceTuningDuration_, DPMBase::getElasticEnergy(), DPMBase::getKineticEnergy(), BaseHandler< T >::getSize(), DPMBase::getTime(), logger, maxRelativeOverlap_, meanClusterRadius_, meanCoordinationNumber_, meanRelativeOverlap_, minRelativeOverlap_, DPMBase::particleHandler, solidFraction_, stage_, t0_, VERBOSE, Vec3D::X, Vec3D::Y, and Vec3D::Z.

Referenced by actionsAfterTimeStep().

◆ read()

void BaseCluster::read ( std::istream &  is,
ReadOptions  opt = ReadOptions::ReadAll 
)
overridevirtual

Overrides DPMBase read(): in this all variables needed by the program for restarting are read.

In this all variables needed by the program for restarting are read from a .restart file. As MercuryBase::write was included in ClusterDPM::write, here MercuryBase::read is included.

Reimplemented from DPMBase.

840 {
841  MercuryBase::read(is);
842 
843  std::stringstream line;
844  std::string dummy;
845 
847  line >> dummy >> position_
848  >> dummy >> stage_
849  >> dummy >> t0_;
851  line >> dummy >> idCluster_
852  >> dummy >> nParticles_
853  >> dummy >> radiusParticle_
854  >> dummy >> massParticle_
855  >> dummy >> sizeDispersityParticle_
856  >> dummy >> totalParticleVolume_;
858  line >> dummy >> maximumForceModulus_
859  >> dummy >> forceTuningInterval_
860  >> dummy >> forceTuningDuration_
861  >> dummy >> velocityDampingInterval_
862  >> dummy >> velocityDampingModulus_
863  >> dummy >> energyRatioTolerance_
864  >> dummy >> forceDampingModulus_
865  >> dummy >> forceModulus_;
867  line >> dummy >> isCdatOutputOn_
868  >> dummy >> isOverlOutputOn_
869  >> dummy >> isAmatOutputOn_
870  >> dummy >> isIntStrucOutputOn_;
871  if(isIntStrucOutputOn() )
872  {
874  line >> dummy >> nInternalStructurePoints_;
875  }
876  line >> dummy >> isRestartOutputOn_
877  >> dummy >> isFStatOutputOn_
878  >> dummy >> isEneOutputOn_;
879 }
void read(std::istream &is, ReadOptions opt=ReadOptions::ReadAll) override
Reads the MercuryBase from an input stream, for example a restart file.
Definition: MercuryBase.cc:104
void getLineFromStringStream(std::istream &in, std::stringstream &out)
Reads a line from one stringstream into another, and prepares the latter for reading in.
Definition: StringHelpers.cc:62

References energyRatioTolerance_, forceDampingModulus_, forceModulus_, forceTuningDuration_, forceTuningInterval_, helpers::getLineFromStringStream(), idCluster_, isAmatOutputOn_, isCdatOutputOn_, isEneOutputOn_, isFStatOutputOn_, isIntStrucOutputOn(), isIntStrucOutputOn_, isOverlOutputOn_, isRestartOutputOn_, massParticle_, maximumForceModulus_, nInternalStructurePoints_, nParticles_, position_, radiusParticle_, MercuryBase::read(), sizeDispersityParticle_, stage_, t0_, totalParticleVolume_, velocityDampingInterval_, and velocityDampingModulus_.

◆ setClusterId()

void BaseCluster::setClusterId ( unsigned int  iC)

This sets the value of the cluster ID.

This sets the value of the cluster ID. In addition to that, it checks if the value is acceptable.

183  {
184  if (iC < 0)
185  logger(WARN, "idCluster = % is less than zero.", iC);
186  idCluster_ = iC;
187 }

References idCluster_, logger, and WARN.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and ClusterGenerator::ClusterGenerator().

◆ setCollisionTimeOverTimeStep()

void BaseCluster::setCollisionTimeOverTimeStep ( Mdouble  cTOTS)

This sets the collisionTimeOverTimeStep number (which is the ratio between collision time and time step).

This sets the collisionTimeOverTimeStep_ number. In addition to that, it checks if the value is acceptable.

76  {
77  if (cTOTS < 45 && cTOTS > 0)
78  logger(WARN, "collisionTimeOverTimeStep = % is too small: consider setting it greater or equal than 50.", cTOTS);
79  else if (cTOTS <= 0)
80  logger(ERROR, "collisionTimeOverTimeStep = % must be grater than zero.", cTOTS);
82 }

References collisionTimeOverTimeStep_, ERROR, logger, and WARN.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and ClusterGenerator::ClusterGenerator().

◆ setDomainLimits()

void BaseCluster::setDomainLimits ( )
private

Sets domain limits.

Sets domain limits of the simulation. Using spherical coordinates and the insertion process defined in particleInsertionSuccessful the final solid fraction obtained varies from 0.11 to 0.14 (empirically calculated, even for high size dispersity, which anyway shouldn't be contemplated in this field). For this reason the domain size (here called boxSize_) is computed as the cubic root of the total particle volume over 0.1.

1046 {
1047  Mdouble initialSolidFraction = 0.1;
1048  boxSize_ = cbrt(totalParticleVolume_/initialSolidFraction);
1049  std::ostringstream printDomainLimits;
1050  printDomainLimits << "Cubic size " << boxSize_ << std::endl;
1051  logger(VERBOSE, printDomainLimits.str());
1052 
1053  setDomain(-0.5*boxSize_*Vec3D(1,1,1) + position_, 0.5*boxSize_*Vec3D(1,1,1) + position_);
1054 }
void setDomain(const Vec3D &min, const Vec3D &max)
Sets the minimum coordinates of the problem domain.
Definition: DPMBase.cc:1098

References boxSize_, logger, position_, DPMBase::setDomain(), totalParticleVolume_, and VERBOSE.

Referenced by setupInitialConditions().

◆ setEnergyRatioTolerance()

void BaseCluster::setEnergyRatioTolerance ( Mdouble  eRT)

This sets the value of the value of the energy ratio threshold under which the process can be considered static, and so over.

This sets the value of the value of the energy ratio threshold under which the process can be considered static, and so over. In addition to that, it checks if the value is acceptable.

234  {
235  if (eRT <= 0)
236  logger(ERROR, "energyRatioTolerance must be grater than zero. energyRatioTolerance = %", eRT);
237  energyRatioTolerance_ = eRT;
238 }

References energyRatioTolerance_, ERROR, and logger.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and ClusterGenerator::ClusterGenerator().

◆ setNumberOfInternalStructurePoints()

void BaseCluster::setNumberOfInternalStructurePoints ( int  gL)

This sets the value of the number of particles used to compute the internal structure.

This sets the value of the length of the number of particles used to compute the internal structure. In addition to that, it checks if the value is acceptable.

217  {
218  if (gL <= 0)
219  logger(ERROR, "nInternalStructurePoints_ must be grater than zero. nInternalStructurePoints_ = %", gL);
221 }

References ERROR, logger, and nInternalStructurePoints_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep().

◆ setNumberOfParticles()

void BaseCluster::setNumberOfParticles ( int  nP)

This sets the value of the number of particles in the cluster.

This sets the value of the number of particles in the cluster. In addition to that, it checks if the value is acceptable.

134  {
135  if (nP < 0)
136  logger(ERROR, "nParticles must be grater than zero. nParticles = %", nP);
137  else {
138  nParticles_ = nP;
139  setNumberOfParticles_ = true;
140  }
141 }
bool setNumberOfParticles_
Definition: BaseCluster.h:489

References ERROR, logger, nParticles_, and setNumberOfParticles_.

Referenced by RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and ClusterGenerator::ClusterGenerator().

◆ setParticleSpecies()

void BaseCluster::setParticleSpecies ( LinearPlasticViscoelasticFrictionSpecies pS)

This sets the species of the particle.

This sets the species of the particle.

250  {
251  particleSpecies_ = pS;
252 }

References particleSpecies_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep().

◆ setPosition()

void BaseCluster::setPosition ( Vec3D  p)

This sets the value of position_, which is the position in which the cluster will be inserted.

This sets the value of position_, which is the position in which the cluster will be inserted (it is also the centre of mass of the cluster).

60  {
61  position_ = p;
62 }

References position_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep().

◆ setRadii()

void BaseCluster::setRadii ( )
private

Sets all radii according to particleRadius and sizeDispersityParticle.

Sets all radii according to particleRadius and sizeDispersityParticle_.

985 {
988  for (int i = 0; i < nParticles_; ++i)
989  {
990  // This is the actual radius of the i-th particle
992  // Computing totalParticleVolume (this is done because this value is needed before particle insertion).
993  totalParticleVolume_ += 4.0*constants::pi*pow(radii_[i],3.0)/3.0;
994  //computing the smallest radius (needed in computeTimeStep(), which is needed before particle insertion)
996  }
997 }
const Mdouble inf
Definition: GeneralDefine.h:44

References RNG::getRandomNumber(), constants::i, constants::inf, nParticles_, constants::pi, radii_, radiusParticle_, DPMBase::random, sizeDispersityParticle_, smallestRadius_, and totalParticleVolume_.

Referenced by setupInitialConditions().

◆ setRadiusCluster()

void BaseCluster::setRadiusCluster ( Mdouble  rCR)

This sets the desired value of the cluster radius (there is no getter of this value, but there is a getter of the actual mean cluster radius obtained, getMeanClusterRadius)

This sets the value of the Radius of the cluster. A boolean (setRadiusCluster_) is also set to true: this is done because the user has to set exactly two among radiusCluster_, radiusCluster_ and radiusParticle_. In addition to that, it checks if the value is acceptable.

149  {
150  if (rCR <= 0)
151  logger(ERROR,
152  "relativeClusterRadius is smaller than 0. relativeClusterRadius = %",
153  rCR);
154  else
155  radiusCluster_ = rCR;
156 
157  setRadiusCluster_ = true;
158 }
bool setRadiusCluster_
Definition: BaseCluster.h:497
Mdouble radiusCluster_
Definition: BaseCluster.h:495

References ERROR, logger, radiusCluster_, and setRadiusCluster_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep().

◆ setRadiusParticle()

void BaseCluster::setRadiusParticle ( Mdouble  rP)

This sets the value of particles' radius if there's no dispersity in size.

This sets the value of particles' radius if there's no dispersity in size. If the dispersity is not 1, this is the value on which all radii will be computed. In addition to that, it checks if the value is acceptable.

97  {
98  if (rP <= 0)
99  logger(ERROR, "radiusParticle must be greater than zero. radiusParticle = %", rP);
100  else {
101  radiusParticle_ = rP;
102  setRadiusParticle_ = true;
103  }
104 }
bool setRadiusParticle_
Definition: BaseCluster.h:483

References ERROR, logger, radiusParticle_, and setRadiusParticle_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep().

◆ setSizeDispersityParticle()

void BaseCluster::setSizeDispersityParticle ( Mdouble  sDP)

This sets the value of particles' dispersity in size.

This sets the value of particles' dispersity in size. In addition to that, it checks if the value is acceptable.

117  {
118  if (sDP < 1)
119  logger(ERROR, "sizeDispersityParticle must be greater or equal than 1. sizeDispersityParticle = %", sDP);
120  else sizeDispersityParticle_ = sDP;
121 }

References ERROR, logger, and sizeDispersityParticle_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and ClusterGenerator::ClusterGenerator().

◆ setSpecies()

void BaseCluster::setSpecies ( )
private

Sets species of particles.

adds particlePureSpaces (set by the user or by default) to the species handler. After this, values of stiffnesses, restitution coefficient and collision time are printed.

1004 {
1005  if (particleSpecies_ == nullptr)
1006  {
1007  logger(ERROR, "Species not set.");
1008  }
1010  /*
1011  * \brief mass of the particle which has radius radiusParticle if constantRestitution(false) or
1012  * radiusParticle_*2/(1+sizeDispersityParticle_) otherwise.
1013  * It is set now and used various time in the code (for example for stiffnesses, collision time
1014  * and restitution coefficient below).
1015  */
1016  massParticle_ = particleSpecies_ -> getConstantRestitution()?
1017  speciesHandler.getObject(0) -> getMassFromRadius(radiusParticle_*2/(1+sizeDispersityParticle_))
1018  :
1019  speciesHandler.getObject(0) -> getMassFromRadius(radiusParticle_);
1020 
1021  std::ostringstream printSpecies;
1022  /*
1023  * If constantRestitution(true) loading, unloading, and cohesion stiffness are multiplied by the mass of a particle
1024  * whose radius is radiusParticle_*2/(1+sizeDispersityParticle_),
1025  * which is the mass that should be used to compute collision time.
1026  */
1027  printSpecies << "loadingStiffness: " << std::scientific << particleSpecies_ -> getLoadingStiffness()
1028  * (particleSpecies_->getConstantRestitution()?massParticle_:1) << std::endl
1029  << "unloadingStiffnessMax: " << particleSpecies_ -> getUnloadingStiffnessMax()
1030  * (particleSpecies_->getConstantRestitution()?massParticle_:1) << std::endl
1031  << "cohesionStiffness: " << particleSpecies_ -> getCohesionStiffness()
1032  * (particleSpecies_->getConstantRestitution()?massParticle_:1) << std::endl
1033  << "restitutionCoefficient: " << std::fixed << particleSpecies_ -> getRestitutionCoefficient(massParticle_) << std::endl
1034  << "collisionTime: " << std::scientific << std::setprecision(3) << particleSpecies_ -> getCollisionTime(massParticle_) << std::endl;
1035  logger(VERBOSE, printSpecies.str());
1036 }

References BaseHandler< T >::copyAndAddObject(), ERROR, BaseHandler< T >::getObject(), logger, massParticle_, particleSpecies_, radiusParticle_, sizeDispersityParticle_, DPMBase::speciesHandler, and VERBOSE.

Referenced by setupInitialConditions().

◆ setupInitialConditions()

void BaseCluster::setupInitialConditions ( )
overridevirtual

Overrides DPMBase setupInitialConditions(): in this initial conditions for the problem are set.

Overrides DPMBase function setupInitialConditions(): in this initial conditions for the problem are set, and they are (in order): -checking that particleHandler and speciesHandler are empty, -defining cluster parameters starting from the user input, -all particles radii, -particle species, -domain limits, -time step, -particles initial positions (insertParticles), -initial time (t0), -maximum force applied on particles (maximumForceModulus), -time duration of applying (and releasing) force (forceTuningDuration) and dissipation time (dissipationDuration_), -time max, -output time for files and print time function (fileOutputTimeInterval), -time interval on which force is increased or decreased (forceTuningInterval), -value of forceDampingModulus_, -time interval on which velocity is damped (velocityTuningInterval), -xballs settings, -vtk settings, -standard mercury output data settings (dataFile, restartFile, fStatFile and eneFile), -name settings, -creation of cluster data file (if needed), -creation of overlap file (if needed), -stage of computation.

Reimplemented from DPMBase.

426 {
427  logger(VERBOSE, "CREATING CLUSTER");
428 
429  if (particleHandler.getSize()>0){
430  logger(WARN, "ParticleHandler was not empty");
432  }
433 
434  if (speciesHandler.getSize()>0){
435  logger(WARN, "speciesHandler was not empty");
437  }
438  // Defining cluster parameters starting from the user input.
439  // In order to use this class the user has to set exactly 2 values among radiusParticle,
440  // radiusCluster and numberOfParticles.
442  logger(ERROR, "Please set exactly two values among radiusParticle, radiusCluster and numberOfParticles."
443  " radiusParticle = %, radiusCluster = %, numberOfParticles = %.",
445 
446  // If the user sets the cluster radius and the radius of a single particle,
447  // the number of particles has to be computed:
450  logger(VERBOSE, "clusterRadius is small compared to the radius of a single particle:"
451  " consider setting clusterRadius >= 2 * radiusParticle."
452  "clusterRadius = %, radiusParticle = %.", radiusCluster_, radiusParticle_);
453  // relative cluster radius
455  // mass fraction of the cluster in the limit of phi = 0.
456  Mdouble eps0 = 0.58;
457  // The number of particles (N) per cluster given the relative cluster radius (hatR) and penetration depth max (phi)
458  // can be computed as: N = ( hatR / (1 - eps0*phi) )^3 * eps0.
459  // It is very important to notice that this formula is accurate only if sliding friction is set to 0.5 and relative
460  // tangential stiffness is set to 0.3 while creating the cluster. Different values do not guarantee accuracy.
461 
462  nParticles_ =
463  round (std::pow( hatR / (1.0 - eps0 * particleSpecies_->getPenetrationDepthMax() ), 3) * eps0);
464  logger(VERBOSE, "Number of particles: %.\n", nParticles_);
465  }
466 
467  // If the user sets the cluster radius and the number of particles,
468  // the radius of a single particle has to be computed:
470  // mass fraction of the cluster in the limit of phi = 0.
471  Mdouble eps0 = 0.58;
472  // The radius of a single particle (r) composig the cluster given the cluster radius (R), penetration depth max (phi)
473  // and the number of particles (N) can be obtained as: r = R / ( cbrt(N/eps0) * (1-eps0*phi) ).
474  // It is very important to notice that this formula is accurate only if sliding friction is set to 0.5 and relative
475  // tangential stiffness is set to 0.3 while creating the cluster. Different values do not guarantee accuracy.
476  radiusParticle_ = radiusCluster_ / (cbrt(nParticles_/eps0) * (1-eps0*particleSpecies_->getPenetrationDepthMax()));
477 
478  logger(VERBOSE, "radius particle: %.\n", radiusParticle_);
479  }
480 
481  logger(VERBOSE, "SETTING RADII");
482  setRadii();
483 
484  logger(VERBOSE, "SETTING SPECIES");
485  setSpecies();
486 
487  logger(VERBOSE, "SETTING DOMAIN LIMITS");
488  setDomainLimits();
489 
490  logger(VERBOSE, "COMPUTING TIME STEP");
492 
493  logger(VERBOSE, "PARTICLE INSERTION");
494  insertParticles();
495 
496  logger(VERBOSE, "Number of particles: %.", particleHandler.getSize());
497 
498  t0_ = getTime();
499 
500  // \details deltaStar
501  Mdouble deltaStar = particleSpecies_->getPenetrationDepthMax() * particleSpecies_->getUnloadingStiffnessMax()
502  / (particleSpecies_->getUnloadingStiffnessMax() - particleSpecies_->getLoadingStiffness());
503 
504  /*
505  * \brief maximum force modulus applied on particles (this value is then multiplied by the relative distance from
506  * force center d, which is d = D/r).
507  * It is the force necessary to get a overlap of deltaStar (computed above this description).
508  * If constant restitution is true then it is also multiplied by the mass of the biggest particle,
509  * or if MERCURYDPM_USE_MPI it is the biggest possible mass computed taking into account particle
510  * dispersity,
511  * i.e. the mass of a particle having radius
512  * r = radiusParticle_ * 2 * sizeDispersityParticle_ / (1 + sizeDispersityParticle_).
513  * (In order to get the right value of loading stiffness it should be multiplied by the mass of the smallest
514  * particle; multiplying it for the biggest mass here, instead, is for safety).
515  */
516 
517 #ifdef MERCURYDPM_USE_MPI
519  particleSpecies_->getLoadingStiffness()
520  * (particleSpecies_->getConstantRestitution() ?
522  :
523  1);
524 #else
526  particleSpecies_->getLoadingStiffness()
527  * (particleSpecies_->getConstantRestitution() ?
529  :
530  1);
531 #endif
532 
533  /*
534  * \details
535  * The time needed for a particle to cover a distance of x is sqrt(2 * x * m / F), when a constant force F is applied.
536  * In order to hit another particle, a single particle has to travel a distance of about boxSize/4 (boxSize is the domain length).
537  * As a value for x it is used boxSize_ (instead of boxSize_/4 as a safety factor).
538  * As a value for F it is used maximumForceModulus/50 which is half of maximumForceModulus/25 (in this way it is calculated
539  * a measure of the time needed with a force which linearly increases from 0 to maximumForceModulus/25, again dividing for 25
540  * is done for safety). As a value for m it is used the mass of the biggest particle, or if MERCURYDPM_USE_MPI it is
541  * the mass computed taking into account size dispersity, so the mass
542  * of a particle having radius r = radiusParticle_ * 2 * sizeDispersityParticle_ / (1 + sizeDispersityParticle_), for safety.
543  * The factor 5* outside the sqrt is another safety factor empirically determined: with this values the computation is fast
544  * and the obtained results are very similar to the ones obtained if longer times would be set.
545  * All this safety factors are needed because this is not the exact value of time needed but a measure of it: the problem
546  * indeed is quite complicated given that particles can also rearrange during compression and so they will eventually
547  * move in a non radial direction and for this reason they will need more time to settle.
548  */
549 #ifdef MERCURYDPM_USE_MPI
553 #else
556 #endif
557 
558  //\details Maximum possible time duration of dissipation (i.e. duration of dissipation if energy ration tollerance not reached).
560 
561  // Compression + Decompression + Dissipation = 2 * Compression + Dissipation
564 
566 
568 
570 
571  forceDampingModulus_ = 0.95;
572 
574 
575  setXBallsAdditionalArguments("-v0 -p 10");
576 
578 
580 
582 
584 
586 
587  // Name setting
588  std::ostringstream name;
589  name << "Cluster_ID_" << idCluster_;
590  setName(name.str());
591 
592  if (isCdatOutputOn()) {
593  logger(VERBOSE, "CREATING .cdat FILE\n");
594  makeCdatFile();
595  }
596 
597  if (isOverlOutputOn()) {
598  logger(VERBOSE, "CREATING .overl FILE\n");
599  makeOverlFile();
600  }
601 
602  logger(VERBOSE, "ACTIVATING CENTRAL FORCES\n");
603 
604  /*
605  * \details
606  * Stage defines in which phase of the calculation the program is:
607  * stage = 1: compressing particles and increasing force
608  * stage = 2: releasing force
609  * stage = 3: waiting for the system to be static.
610  */
611  stage_ = 1;
612 }
void makeCdatFile()
Creates the cluster data output file.
Definition: BaseCluster.cc:1137
void setSpecies()
Sets species of particles.
Definition: BaseCluster.cc:1003
void setRadii()
Sets all radii according to particleRadius and sizeDispersityParticle.
Definition: BaseCluster.cc:984
Mdouble clusterTimeMax_
Definition: BaseCluster.h:600
void setDomainLimits()
Sets domain limits.
Definition: BaseCluster.cc:1045
void makeOverlFile()
Creates the cluster overlap output file.
Definition: BaseCluster.cc:1180
void calculateTimeStep()
Calculates the time step.
Definition: BaseCluster.cc:1060
void insertParticles()
Inserts particles inside the domain.
Definition: BaseCluster.cc:1078
Mdouble getMass() const
Returns the particle's mass.
Definition: BaseParticle.h:322
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 clear() override
Empties the whole ParticleHandler by removing all BaseParticle.
Definition: ParticleHandler.cc:977
BaseParticle * getLargestParticle() const
Returns the pointer of the largest particle in the particle handler. When mercury is running in paral...
Definition: ParticleHandler.cc:534
void clear() override
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0.
Definition: SpeciesHandler.h:54
Mdouble round(Mdouble value, unsigned int precision)
rounds a floating point number with a given precision
Definition: MathHelpers.cc:28
std::string name
Definition: MercuryProb.h:48

References boxSize_, calculateTimeStep(), ParticleHandler::clear(), SpeciesHandler::clear(), clusterTimeMax_, DPMBase::dataFile, dissipationDuration_, DPMBase::eneFile, ERROR, fileOutputTimeInterval_, forceDampingModulus_, forceTuningDuration_, forceTuningInterval_, DPMBase::fStatFile, ParticleHandler::getLargestParticle(), BaseParticle::getMass(), ParticleSpecies::getMassFromRadius(), BaseHandler< T >::getSize(), DPMBase::getTime(), DPMBase::getTimeStep(), idCluster_, insertParticles(), isCdatOutputOn(), isEneOutputOn(), isFStatOutputOn(), isOverlOutputOn(), isRestartOutputOn(), isVtkOutputOn(), logger, makeCdatFile(), makeOverlFile(), maximumForceModulus_, units::name, NO_FILE, nParticles_, ONE_FILE, DPMBase::particleHandler, particleSpecies_, radiusCluster_, radiusParticle_, DPMBase::restartFile, helpers::round(), setDomainLimits(), File::setFileType(), DPMBase::setName(), setNumberOfParticles_, DPMBase::setParticlesWriteVTK(), setRadii(), setRadiusCluster_, setRadiusParticle_, DPMBase::setSaveCount(), setSpecies(), DPMBase::setTimeMax(), DPMBase::setXBallsAdditionalArguments(), sizeDispersityParticle_, DPMBase::speciesHandler, stage_, t0_, velocityDampingInterval_, VERBOSE, and WARN.

◆ setVelocity()

void BaseCluster::setVelocity ( Vec3D  v)

This sets the value of velocity after creation.

This sets the velocity of the cluster after creation.

264  {
265  clusterVelocity_ = v;
266 }

References clusterVelocity_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and dampVelocities().

◆ setVelocityDampingModulus()

void BaseCluster::setVelocityDampingModulus ( Mdouble  vDM)

This sets the value of the velocity damping modulus.

This sets the value of the velocity damping modulus. In addition to that, it checks if the value is acceptable.

200  {
201  if (vDM < 0 || vDM > 1)
202  logger(ERROR, "velocityDampingModulus must be grater than zero and less than 1. velocityDampingModulus = %", vDM);
204 }

References ERROR, logger, and velocityDampingModulus_.

Referenced by FixedClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), and ClusterGenerator::ClusterGenerator().

◆ write()

void BaseCluster::write ( std::ostream &  os,
bool  writeAllParticles 
) const
overridevirtual

Overrides DPMBase write(): in this all variables needed by the program for restarting are written.

In this all variables needed by the program for restarting are written on a .restart file Most of the needed variables are already saved by MercuryBase::write, which for this reason is included.

Reimplemented from DPMBase.

793 {
794  writeAllParticles = true;
795  MercuryBase::write(os, writeAllParticles);
796 
797  os <<
798  "position " << position_ << " " <<
799  "stage " << stage_ << " " <<
800  "t0 " << t0_
801  << "\n" <<
802  "idCluster " << idCluster_ << " " <<
803  "nParticles " << nParticles_ << " " <<
804  "radiusParticle " << radiusParticle_ << " " <<
805  "massParticle " << massParticle_ << " " <<
806  "sizeDispersityParticle " << sizeDispersityParticle_ << " " <<
807  "totalParticleVolume " << totalParticleVolume_
808  << "\n" <<
809  "maximumForceModulus " << maximumForceModulus_ << " " <<
810  "forceTuningInterval " << forceTuningInterval_ << " " <<
811  "forceTuningDuration " << forceTuningDuration_ << " " <<
812  "velocityDampingInterval " << velocityDampingInterval_ << " " <<
813  "velocityDampingModulus " << velocityDampingModulus_ << " " <<
814  "energyRatioTolerance " << energyRatioTolerance_ << " " <<
815  "forceDampingModulus " << forceDampingModulus_ << " " <<
816  "forceModulus " << forceModulus_
817  << "\n" <<
818  "isCdatOutputON " << isCdatOutputOn_ << " " <<
819  "isOverlOutputOn " << isOverlOutputOn_ << " " <<
820  "isAmatOutputOn " << isAmatOutputOn_ << " " <<
821  "isIntStrucOutputOn " << isIntStrucOutputOn_
822  << "\n";
823  if (isIntStrucOutputOn())
824  {
825  os << "nInternalStructurePoints " << nInternalStructurePoints_ << "\n";
826  }
827 
828  os << "isRestartOutputOn " << isRestartOutputOn_ << " " << //This is obviously on because otherwise restart
829  // process would not take place.
830  //For now it is saved but could eventually be removed.
831  "isFStatOutputOn " << isFStatOutputOn_ << " " <<
832  "isEneOutputOn " << isEneOutputOn_ << std::endl;
833 }
void write(std::ostream &os, bool writeAllParticles=true) const override
Writes all data into a restart file.
Definition: MercuryBase.cc:147

References energyRatioTolerance_, forceDampingModulus_, forceModulus_, forceTuningDuration_, forceTuningInterval_, idCluster_, isAmatOutputOn_, isCdatOutputOn_, isEneOutputOn_, isFStatOutputOn_, isIntStrucOutputOn(), isIntStrucOutputOn_, isOverlOutputOn_, isRestartOutputOn_, massParticle_, maximumForceModulus_, nInternalStructurePoints_, nParticles_, position_, radiusParticle_, sizeDispersityParticle_, stage_, t0_, totalParticleVolume_, velocityDampingInterval_, velocityDampingModulus_, and MercuryBase::write().

◆ writeAmatFile()

void BaseCluster::writeAmatFile ( )
private

This writes on the adjacency matrix file.

This writes on the adjacency matrix file. With two nested for cycles adjacencyMatrix is written down. Finally number of intra-cluster bonds and mean coordination number are also written. After this the file is closed.

1578 {
1579  for(int i=0; i < particleHandler.getSize(); i++)
1580  {
1581  for(int j=0; j < particleHandler.getSize(); j++)
1582  {
1583  amatFile_ << adjacencyMatrix_[i][j] << " ";
1584  }
1585  amatFile_ << std::endl;
1586  }
1588  amatFile_ << std::endl;
1589  amatFile_ << "THE TOTAL NUMBER OF INTRACLUSTER BONDS IS: " << nIntraClusterBonds_ << std::endl;
1590  amatFile_ << "THE MEAN COORDINATION NUMBER IS: " << meanCoordinationNumber_ << std::endl;
1591 
1592  amatFile_.close();
1593 }
int nIntraClusterBonds_
Definition: BaseCluster.h:570

References adjacencyMatrix_, amatFile_, BaseHandler< T >::getSize(), constants::i, DPMBase::interactionHandler, meanCoordinationNumber_, nIntraClusterBonds_, and DPMBase::particleHandler.

Referenced by actionsAfterSolve().

◆ writeToCdatFile()

void BaseCluster::writeToCdatFile ( )
private

This writes on the cluster data output file.

This writes on the cluster data output file. Written values are (in order): -elastic energy, -energy ratio threshold, -mean coordination number, -mean cluster radius, -solid fraction, -force modulus, -mean force on interaction, -minimum relative overlap, -mean relative overlap, -maximum realative overlap, -center of mass.

1372 {
1373  switch (stage_)
1374  {
1375  case 1:
1376  cdatFile_ << "C, " << std::fixed << std::setprecision(0) << std::setw(4) << 100 * (getTime() - t0_) / forceTuningDuration_ << "%: ";
1377  break;
1378 
1379  case 2:
1380  cdatFile_ << "D, " << std::fixed << std::setprecision(0) << std::setw(4) << 100 * (getTime() - t0_) / forceTuningDuration_ << "%: ";
1381  break;
1382 
1383  case 3:
1384  cdatFile_ << "D-energy: ";
1385  break;
1386 
1387  default:
1388  cdatFile_ << "Final v: ";
1389  }
1390 
1391  cdatFile_ <<
1392  std::scientific <<
1393  std::setprecision(2)<<
1394  std::setw(14) <<
1395  getElasticEnergy() <<
1396  std::setw(18) <<
1398  std::fixed <<
1399  std::setprecision(2) <<
1400  std::setw(15) <<
1402  std::scientific <<
1403  std::setw(20) <<
1405  std::fixed <<
1406  std::setprecision(2) <<
1407  std::setw(13) <<
1408  solidFraction_ <<
1409  std::scientific <<
1410  std::setprecision(3) <<
1411  std::setw(24) <<
1412  forceModulus_ <<
1413  std::setw(22) <<
1414  std::fixed <<
1415  std::setprecision(5) <<
1416  std::setw(18) <<
1418  std::setw(16) <<
1420  std::setw(15) <<
1422  std::scientific <<
1423  std::setprecision(2) <<
1424  std::setw(19) <<
1425  centerOfMass_.X <<
1426  std::setw(12) <<
1427  centerOfMass_.Y <<
1428  std::setw(12) <<
1429  centerOfMass_.Z <<
1430  " " <<
1431  std::endl;
1432 }

References cdatFile_, centerOfMass_, forceModulus_, forceTuningDuration_, DPMBase::getElasticEnergy(), DPMBase::getKineticEnergy(), DPMBase::getTime(), maxRelativeOverlap_, meanClusterRadius_, meanCoordinationNumber_, meanRelativeOverlap_, minRelativeOverlap_, solidFraction_, stage_, t0_, Vec3D::X, Vec3D::Y, and Vec3D::Z.

Referenced by actionsAfterSolve(), and actionsAfterTimeStep().

◆ writeToOverlFile()

void BaseCluster::writeToOverlFile ( )
private

This writes on the cluster overlap output file.

This writes on the cluster overlap output file. At each output time and for each interaction force vs overlap is written down.

1439 {
1440  //\brief force acting on overlap.
1441  Mdouble forceOnOverlap = 0;
1442  Mdouble relativeOverlap = 0;
1443  switch (stage_)
1444  {
1445  case 1:
1446  overlFile_ << "C, " << std::fixed << std::setprecision(0) << std::setw(4) << 100 * (getTime() - t0_) / forceTuningDuration_ << "%: ";
1447  break;
1448 
1449  case 2:
1450  overlFile_ << "D, " << std::fixed << std::setprecision(0) << std::setw(4) << 100 * (getTime() - t0_) / forceTuningDuration_ << "%: ";
1451  break;
1452 
1453  case 3:
1454  overlFile_ << "D energy: ";
1455  break;
1456 
1457  default:
1458  overlFile_ << "Final v: ";
1459  }
1460 
1461  for (std::vector<BaseInteraction*>::const_iterator i = interactionHandler.begin(); i != interactionHandler.end(); ++i)
1462  {
1463  forceOnOverlap = ((*i) -> getForce()).getLength();
1464  relativeOverlap = ((*i) -> getOverlap())/(particleHandler.getObject((*i) -> getP() -> getIndex()) -> getRadius()) +
1465  ((*i) -> getOverlap())/(particleHandler.getObject((*i) -> getI() -> getIndex()) -> getRadius());
1466  relativeOverlap = relativeOverlap / 2;
1467  overlFile_ << std::setprecision(2) << std::scientific << std::setw(18) << forceOnOverlap
1468  << std::defaultfloat << std::fixed << std::setprecision(4) << std::setw(9) << relativeOverlap;
1469  }
1470 
1471  overlFile_ << " " << std::endl;
1472 }

References BaseHandler< T >::begin(), BaseHandler< T >::end(), forceTuningDuration_, BaseHandler< T >::getObject(), DPMBase::getTime(), constants::i, DPMBase::interactionHandler, overlFile_, DPMBase::particleHandler, stage_, and t0_.

Referenced by actionsAfterSolve(), and actionsAfterTimeStep().

Member Data Documentation

◆ adjacencyMatrix_

std::vector< std::vector<int> > BaseCluster::adjacencyMatrix_
private

◆ amatFile_

std::ofstream BaseCluster::amatFile_
private

Referenced by makeAmatFile(), and writeAmatFile().

◆ boxSize_

Mdouble BaseCluster::boxSize_
private

◆ cdatFile_

std::ofstream BaseCluster::cdatFile_
private

◆ centerOfMass_

Vec3D BaseCluster::centerOfMass_
private

◆ clusterTimeMax_

Mdouble BaseCluster::clusterTimeMax_
private

Referenced by setupInitialConditions().

◆ clusterVelocity_

Vec3D BaseCluster::clusterVelocity_
private

◆ collisionTimeOverTimeStep_

Mdouble BaseCluster::collisionTimeOverTimeStep_
private

◆ dissipationDuration_

Mdouble BaseCluster::dissipationDuration_
private

◆ energyRatioTolerance_

Mdouble BaseCluster::energyRatioTolerance_
private

◆ fileOutputTimeInterval_

Mdouble BaseCluster::fileOutputTimeInterval_
private

◆ forceDampingModulus_

Mdouble BaseCluster::forceDampingModulus_
private

◆ forceModulus_

◆ forceTuningDuration_

◆ forceTuningInterval_

Mdouble BaseCluster::forceTuningInterval_
private

◆ gnuplotFile_

std::ofstream BaseCluster::gnuplotFile_
private

Referenced by makeGnuplotFile().

◆ idCluster_

unsigned int BaseCluster::idCluster_
private

◆ intStructFile_

std::ofstream BaseCluster::intStructFile_
private

◆ isAmatOutputOn_

bool BaseCluster::isAmatOutputOn_
private

◆ isCdatOutputOn_

bool BaseCluster::isCdatOutputOn_
private

◆ isEneOutputOn_

bool BaseCluster::isEneOutputOn_
private

◆ isFStatOutputOn_

bool BaseCluster::isFStatOutputOn_
private

◆ isIntStrucOutputOn_

bool BaseCluster::isIntStrucOutputOn_
private

◆ isOverlOutputOn_

bool BaseCluster::isOverlOutputOn_
private

◆ isRestartOutputOn_

bool BaseCluster::isRestartOutputOn_
private

◆ isVtkOutputOn_

bool BaseCluster::isVtkOutputOn_
private

Referenced by doVtkOutput(), and isVtkOutputOn().

◆ massParticle_

Mdouble BaseCluster::massParticle_
private

Referenced by makeCdatFile(), read(), setSpecies(), and write().

◆ maximumForceModulus_

Mdouble BaseCluster::maximumForceModulus_
private

◆ maxRelativeOverlap_

Mdouble BaseCluster::maxRelativeOverlap_
private

◆ meanClusterRadius_

Mdouble BaseCluster::meanClusterRadius_
private

◆ meanCoordinationNumber_

Mdouble BaseCluster::meanCoordinationNumber_
private

◆ meanRelativeOverlap_

Mdouble BaseCluster::meanRelativeOverlap_
private

◆ minRelativeOverlap_

Mdouble BaseCluster::minRelativeOverlap_
private

◆ nInternalStructurePoints_

◆ nIntraClusterBonds_

int BaseCluster::nIntraClusterBonds_
private

Referenced by writeAmatFile().

◆ nParticles_

◆ overlFile_

std::ofstream BaseCluster::overlFile_
private

◆ particleSpecies_

◆ position_

◆ radii_

std::vector<Mdouble> BaseCluster::radii_
private

◆ radiusCluster_

Mdouble BaseCluster::radiusCluster_
private

◆ radiusForSolidFraction_

Mdouble BaseCluster::radiusForSolidFraction_
private

◆ radiusParticle_

◆ setNumberOfParticles_

bool BaseCluster::setNumberOfParticles_ = false
private

◆ setRadiusCluster_

bool BaseCluster::setRadiusCluster_ = false
private

◆ setRadiusParticle_

bool BaseCluster::setRadiusParticle_ = false
private

◆ sizeDispersityParticle_

◆ smallestRadius_

Mdouble BaseCluster::smallestRadius_
private

Referenced by calculateTimeStep(), and setRadii().

◆ solidFraction_

Mdouble BaseCluster::solidFraction_
private

◆ solidFractionIntStruct_

Mdouble BaseCluster::solidFractionIntStruct_
private

◆ stage_

◆ t0_

◆ totalParticleVolume_

Mdouble BaseCluster::totalParticleVolume_
private

◆ velocityDampingInterval_

Mdouble BaseCluster::velocityDampingInterval_
private

◆ velocityDampingModulus_

Mdouble BaseCluster::velocityDampingModulus_
private

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