MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DPMBase Class Reference

The DPMBase header includes quite a few header files, defining all the handlers, which are essential. Moreover, it defines and solves a DPM problem. It is inherited from FilesAndRunNumber (public). More...

#include <DPMBase.h>

+ Inheritance diagram for DPMBase:

Public Types

enum  ReadOptions : int { ReadOptions::ReadAll, ReadOptions::ReadNoInteractions, ReadOptions::ReadNoParticlesAndInteractions }
 
enum  DomainSplit {
  DomainSplit::X, DomainSplit::Y, DomainSplit::Z, DomainSplit::XY,
  DomainSplit::XZ, DomainSplit::YZ, DomainSplit::XYZ
}
 

Public Member Functions

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...
 
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 setupInitialConditions ()
 This function allows to set the initial conditions for our problem to be solved, by default particle locations are randomly set. Remember particle properties must also be defined here. 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)
 Inserts particles in the whole domain. More...
 
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 void write (std::ostream &os, bool writeAllParticles=true) const
 Loads all MD data and plots statistics for all time steps in the .data file. More...
 
virtual void read (std::istream &is, ReadOptions opt=ReadOptions::ReadAll)
 Reads all data from a restart file, e.g. domain data and particle data. 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...
 
virtual bool readNextArgument (int &i, int argc, char *argv[])
 Interprets the i^th command-line argument. More...
 
virtual bool checkParticleForInteraction (const BaseParticle &P)
 Checks whether a particle P has any interaction with walls or other particles. More...
 
virtual bool checkParticleForInteractionLocal (const BaseParticle &P)
 Checks if a particle P has any interaction with walls or other particles in the local domain. 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...
 
MERCURY_DEPRECATED FilegetDataFile ()
 The non const version. Allows one to edit the File::dataFile. More...
 
MERCURY_DEPRECATED FilegetEneFile ()
 The non const version. Allows to edit the File::eneFile. More...
 
MERCURY_DEPRECATED FilegetFStatFile ()
 The non const version. Allows to edit the File::fStatFile. More...
 
MERCURY_DEPRECATED FilegetRestartFile ()
 The non const version. Allows to edit the File::restartFile. More...
 
MERCURY_DEPRECATED FilegetStatFile ()
 The non const version. Allows to edit the File::statFile. More...
 
FilegetInteractionFile ()
 Return a reference to the file InteractionsFile. More...
 
MERCURY_DEPRECATED const FilegetDataFile () const
 The const version. Does not allow for any editing of the File::dataFile. More...
 
MERCURY_DEPRECATED const FilegetEneFile () const
 The const version. Does not allow for any editing of the File::eneFile. More...
 
MERCURY_DEPRECATED const FilegetFStatFile () const
 The const version. Does not allow for any editing of the File::fStatFile. More...
 
MERCURY_DEPRECATED const FilegetRestartFile () const
 The const version. Does not allow for any editing of the File::restartFile. More...
 
MERCURY_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...
 
void setWallsWriteVTK (FileType writeWallsVTK)
 Sets whether walls are written into a VTK file. More...
 
void setWallsWriteVTK (bool)
 Sets whether walls are written into a VTK file. More...
 
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)
 
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...
 
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 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)
 
virtual void hGridUpdateMove (BaseParticle *, Mdouble)
 
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< unsignedgetNumberOfDomains ()
 returns the number of domains More...
 
DomaingetCurrentDomain ()
 Function that returns a pointer to the domain corresponding to the processor. More...
 
void removeOldFiles () const
 
virtual void hGridGetInteractingParticleList (BaseParticle *obj, std::vector< BaseParticle * > &list)
 Creates a list of neighbour particles obtained from the hgrid. More...
 
virtual void computeWallForces (BaseWall *w)
 
virtual bool getHGridUpdateEachTimeStep () 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
 

Static Public Member Functions

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

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

virtual void computeAllForces ()
 Computes all the forces acting on the particles using the BaseInteractable::setForce() and BaseInteractable::setTorque() More...
 
virtual void computeInternalForces (BaseParticle *)
 Computes the internal forces on particle i (internal in the sense that the sum over all these forces is zero i.e. fully modelled forces) 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...
 
void computeForcesDueToWalls (BaseParticle *, BaseWall *)
 Computes the forces on the particles due to the walls (normals are outward normals) More...
 
virtual void actionsOnRestart ()
 A virtual function where the users can add extra code which is executed only when the code is restarted. More...
 
virtual void actionsBeforeTimeLoop ()
 A virtual function. Allows one to carry out any operations before the start of the time loop. More...
 
virtual void hGridActionsBeforeTimeLoop ()
 A virtual function that allows one to carry out hGrid operations before the start of the time loop. More...
 
virtual void hGridActionsBeforeTimeStep ()
 A virtual function that allows one to set or execute hGrid parameters or operations before every simulation time step. 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...
 
virtual void actionsAfterSolve ()
 A virtual function which allows to define operations to be executed after the solve(). More...
 
virtual void actionsAfterTimeStep ()
 A virtual function which allows to define operations to be executed after time step. More...
 
void writeVTKFiles () const
 
virtual void outputXBallsData (std::ostream &os) const
 This function writes the location of the walls and particles in a format the XBalls program can read. For more information on the XBalls program, see Visualising data in xballs. More...
 
virtual void outputXBallsDataParticle (unsigned int i, unsigned int format, std::ostream &os) const
 This function writes out the particle locations into an output stream in a format the XBalls program can read. For more information on the XBalls program, see Visualising data in xballs. More...
 
virtual void writeEneHeader (std::ostream &os) const
 Writes a header with a certain format for ENE file. More...
 
virtual void writeFstatHeader (std::ostream &os) const
 Writes a header with a certain format for FStat file. More...
 
virtual void writeEneTimeStep (std::ostream &os) const
 Write the global kinetic, potential energy, etc. in the system. More...
 
virtual void initialiseStatistics ()
 
virtual void outputStatistics ()
 
void gatherContactStatistics ()
 
virtual void processStatistics (bool)
 
virtual void finishStatistics ()
 
virtual void 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...
 
virtual void hGridActionsBeforeIntegration ()
 This function has to be called before integrateBeforeForceComputation. More...
 
virtual void hGridActionsAfterIntegration ()
 This function has to be called after integrateBeforeForceComputation. More...
 
void setFixedParticles (unsigned int n)
 Sets a number, n, of particles in the particleHandler as "fixed particles". More...
 
virtual void printTime () const
 Displays the current simulation time and the maximum simulation duration. 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...
 

Private Attributes

int numberOfOMPThreads_
 
unsigned int systemDimensions_
 The dimensions of the simulation i.e. 2D or 3D. More...
 
unsigned int particleDimensions_
 determines if 2D or 3D particle volume is used for mass calculations More...
 
Vec3D gravity_
 Gravity vector. More...
 
std::vector< unsignednumberOfDomains_
 Vector containing the number of domains in x-,y- and z-direction, required for parallel computations. More...
 
Vec3D min_
 These vectors are used for the XBalls domain, and occasionally people use it to add walls. More...
 
Vec3D max_
 
Mdouble time_
 Stores the current simulation time. More...
 
unsigned int numberOfTimeSteps_
 Stores the number of time steps. More...
 
Mdouble timeStep_
 Stores the simulation time step. More...
 
Mdouble timeMax_
 Stores the duration of the simulation. More...
 
std::string restartVersion_
 Previous versions of MercuryDPM had a different restart file format, the below member variable allows one to specify the version in order to choose between the available version support. More...
 
bool restarted_
 A bool to check if the simulation was restarted or not, ie. if setupInitialConditionsShould be run and the fileCounters reset. More...
 
bool append_
 A flag to determine if the file has to be appended or not. See DPMBase::Solve() for example. More...
 
bool rotation_
 A flag to turn on/off particle rotation. true will enable particle rotation. false will disable particle rotation. More...
 
FileType writeWallsVTK_
 A flag to turn on/off the vtk writer for walls. More...
 
bool writeParticlesVTK_
 A flag to turn on/off the vtk writer for particles. More...
 
bool writeSuperquadricParticlesVTK_
 
ParticleVtkWritervtkWriter_
 
WallVTKWriter wallVTKWriter_
 
InteractionVTKWriter interactionVTKWriter_
 
BoundaryVTKWriter boundaryVTKWriter_
 
int xBallsColourMode_
 XBalls is a package to view the particle data. As an alternative MercuryDPM also supports ParaView. The below variable is used to set the argument cmode in xballs script (see XBalls/xballs.txt) More...
 
Mdouble xBallsVectorScale_
 sets the xballs argument vscale (see XBalls/xballs.txt) More...
 
Mdouble xBallsScale_
 sets the xballs argument scale (see XBalls/xballs.txt) More...
 
std::string xBallsAdditionalArguments_
 A string of additional arguments for xballs can be specified (see XBalls/xballs.txt). e.g. "-solidf -v0". More...
 
int runNumber_
 This stores the run number for saving. More...
 
std::string name_
 the name of the problem, used, e.g., for the output files More...
 
bool readSpeciesFromDataFile_
 Determines if the last column of the data file is interpreted as the info parameter during restart. More...
 
int nToWrite_
 number of elements to write to a screen More...
 

Detailed Description

The DPMBase header includes quite a few header files, defining all the handlers, which are essential. Moreover, it defines and solves a DPM problem. It is inherited from FilesAndRunNumber (public).

Bug:
When restarting the first time step is not saved, therefore there is a missing time step after a restart

Definition at line 73 of file DPMBase.h.

Member Enumeration Documentation

enum DPMBase::DomainSplit
strong
Enumerator
XY 
XZ 
YZ 
XYZ 

Definition at line 935 of file DPMBase.h.

enum DPMBase::ReadOptions : int
strong
Enumerator
ReadAll 
ReadNoInteractions 
ReadNoParticlesAndInteractions 

Definition at line 241 of file DPMBase.h.

241  : int {
242  ReadAll,
243  ReadNoInteractions,
244  ReadNoParticlesAndInteractions
245  };

Constructor & Destructor Documentation

DPMBase::DPMBase ( )

Constructor that calls the "void constructor()".

Constructor for the DPMBase class. Initialises a set of default parameters allowing a simulation to be created 'off the shelf'. For full details of the parameters initialised and their assigned values, see constructor()

Definition at line 188 of file DPMBase.cc.

References constructor().

189 {
190  constructor();
191 }
void constructor()
A function which initialises the member variables to default values, so that the problem can be solve...
Definition: DPMBase.cc:201
WallVTKWriter wallVTKWriter_
Definition: DPMBase.h:1308
InteractionVTKWriter interactionVTKWriter_
Definition: DPMBase.h:1310
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1391
BoundaryVTKWriter boundaryVTKWriter_
Definition: DPMBase.h:1312
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1406
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1386
DPMBase::DPMBase ( const DPMBase other)

Copy constructor type-2.

A copy constructor which takes a "DPMBase"-type object and creates a "copy" - i.e. creates a new instance of a class possessing the same properties as the original.
The argument "other" is the "original", i.e. the instance to be copied from.

The first set of actions performed, which follow the general form:
[variable] = other.[variable])
simply copy the relevant variables (i.e. information such as particle details, system details, simulation details...) from the original ("other").

The various handlers belonging to the original instance, however, are not directly copied, as this may cause problems (i.e. the handlers would still "point" to the original object, not the copy).
Rather, new handlers are created (e.g. boundaryHandler.setDPMBase(this);), and the contents of the handlers is then passed over (e.g. boundaryHandler = other.boundaryHandler;). For each handler class, the assignment operator = has been overrided to copy the contents, not just the pointer.

Parameters
[in]other

Definition at line 116 of file DPMBase.cc.

References append_, boundaryHandler, cgHandler, domainHandler, getName(), gravity_, DomainHandler::initialise(), PeriodicBoundaryHandler::initialise(), interactionHandler, max_, min_, numberOfDomains_, numberOfOMPThreads_, numberOfTimeSteps_, particleDimensions_, particleHandler, periodicBoundaryHandler, random, readSpeciesFromDataFile_, restarted_, restartVersion_, rotation_, runNumber_, BaseHandler< T >::setDPMBase(), setName(), speciesHandler, systemDimensions_, time_, timeMax_, timeStep_, vtkWriter_, wallHandler, writeParticlesVTK_, writeSuperquadricParticlesVTK_, writeWallsVTK_, xBallsAdditionalArguments_, xBallsColourMode_, xBallsScale_, and xBallsVectorScale_.

119 {
120  setName(other.getName());
121  runNumber_ = other.runNumber_;
124  gravity_ = other.gravity_;
125 /* xMin_ = other.xMin_;
126  xMax_ = other.xMax_;
127  yMin_ = other.yMin_;
128  yMax_ = other.yMax_;
129  zMin_ = other.zMin_;
130  zMax_ = other.zMax_;*/
131  min_ = other.min_;
132  max_ = other.max_;
134  time_ = other.time_;
135  timeStep_ = other.timeStep_;
137  timeMax_ = other.timeMax_;
138  restartVersion_ = other.restartVersion_; //to read new and old restart data
139  restarted_ = other.restarted_; //to see if it was restarted or not
140  append_ = other.append_;
141  rotation_ = other.rotation_;
142  xBallsColourMode_ = other.xBallsColourMode_; // sets the xballs argument cmode (see xballs.txt)
143  xBallsVectorScale_ = other.xBallsVectorScale_; // sets the xballs argument vscale (see xballs.txt)
144  xBallsScale_ = other.xBallsScale_; // sets the xballs argument scale (see xballs.txt)
145  xBallsAdditionalArguments_ = other.xBallsAdditionalArguments_; // std::string where additional xballs argument can be specified (see xballs.txt)
149 
150 //effectively saying "if there exists a CONTACT_LIST_HGRID, copy it, if not, ignore.
151 #ifdef CONTACT_LIST_HGRID
152  possibleContactList=other.possibleContactList;
153 #endif
154  random = other.random;
155 
160  wallHandler.setDPMBase(this);
163  //Initialise the handlers
166 
167  //setting contents equal to the other handlers!
170  cgHandler = other.cgHandler;
171  //cgHandler = other.cgHandler.copy(); //todo
172  //cgHandler.setDPMBase(this);
173  wallHandler = other.wallHandler;
176  vtkWriter_ = other.vtkWriter_;
181 }
Mdouble timeMax_
Stores the duration of the simulation.
Definition: DPMBase.h:1267
Vec3D max_
Definition: DPMBase.h:1247
unsigned int particleDimensions_
determines if 2D or 3D particle volume is used for mass calculations
Definition: DPMBase.h:1231
void setDPMBase(DPMBase *DPMBase)
Sets the problem that is solved using this handler.
Definition: BaseHandler.h:718
bool readSpeciesFromDataFile_
Determines if the last column of the data file is interpreted as the info parameter during restart...
Definition: DPMBase.h:1355
WallVTKWriter wallVTKWriter_
Definition: DPMBase.h:1308
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:390
InteractionVTKWriter interactionVTKWriter_
Definition: DPMBase.h:1310
int runNumber_
This stores the run number for saving.
Definition: DPMBase.h:1340
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1401
std::vector< unsigned > numberOfDomains_
Vector containing the number of domains in x-,y- and z-direction, required for parallel computations...
Definition: DPMBase.h:1241
bool rotation_
A flag to turn on/off particle rotation. true will enable particle rotation. false will disable parti...
Definition: DPMBase.h:1292
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1257
bool restarted_
A bool to check if the simulation was restarted or not, ie. if setupInitialConditionsShould be run an...
Definition: DPMBase.h:1279
void initialise()
Initialises the communication list vectors as they can not be determined on compile time...
unsigned int systemDimensions_
The dimensions of the simulation i.e. 2D or 3D.
Definition: DPMBase.h:1226
bool writeSuperquadricParticlesVTK_
Definition: DPMBase.h:1304
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1412
int xBallsColourMode_
XBalls is a package to view the particle data. As an alternative MercuryDPM also supports ParaView...
Definition: DPMBase.h:1320
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1391
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1396
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1306
BoundaryVTKWriter boundaryVTKWriter_
Definition: DPMBase.h:1312
Mdouble xBallsScale_
sets the xballs argument scale (see XBalls/xballs.txt)
Definition: DPMBase.h:1330
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
Mdouble time_
Stores the current simulation time.
Definition: DPMBase.h:1252
int numberOfOMPThreads_
Definition: DPMBase.h:1221
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1366
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1406
FileType writeWallsVTK_
A flag to turn on/off the vtk writer for walls.
Definition: DPMBase.h:1297
Mdouble xBallsVectorScale_
sets the xballs argument vscale (see XBalls/xballs.txt)
Definition: DPMBase.h:1325
Mdouble timeStep_
Stores the simulation time step.
Definition: DPMBase.h:1262
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1386
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:1371
bool writeParticlesVTK_
A flag to turn on/off the vtk writer for particles.
Definition: DPMBase.h:1302
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:413
std::string xBallsAdditionalArguments_
A string of additional arguments for xballs can be specified (see XBalls/xballs.txt). e.g. "-solidf -v0".
Definition: DPMBase.h:1335
std::string restartVersion_
Previous versions of MercuryDPM had a different restart file format, the below member variable allows...
Definition: DPMBase.h:1274
Vec3D min_
These vectors are used for the XBalls domain, and occasionally people use it to add walls...
Definition: DPMBase.h:1246
Vec3D gravity_
Gravity vector.
Definition: DPMBase.h:1236
bool append_
A flag to determine if the file has to be appended or not. See DPMBase::Solve() for example...
Definition: DPMBase.h:1285
DPMBase::~DPMBase ( )
virtual

virtual destructor

A simple destructor for "DPMBase"-type objects, used to free-up memory when an object is no longer necessary.

Definition at line 288 of file DPMBase.cc.

References vtkWriter_.

289 {
290  delete vtkWriter_;
291 }
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1306

Member Function Documentation

void DPMBase::actionsAfterSolve ( )
protectedvirtual

A virtual function which allows to define operations to be executed after the solve().

no implementation but can be overidden in its derived classes.

Reimplemented in BaseCluster.

Definition at line 1855 of file DPMBase.cc.

Referenced by solve(), and Mercury3DRestart::writeOutputFiles().

1856 {
1857 }
void DPMBase::actionsAfterTimeStep ( )
protectedvirtual

A virtual function which allows to define operations to be executed after time step.

no implementation but can be overidden in its derived classes.

Reimplemented in BaseCluster.

Definition at line 1862 of file DPMBase.cc.

Referenced by computeOneTimeStep().

1863 {
1864 }
void DPMBase::actionsBeforeTimeLoop ( )
protectedvirtual

A virtual function. Allows one to carry out any operations before the start of the time loop.

no implementation but can be overriden in its derived classes.

Definition at line 1653 of file DPMBase.cc.

Referenced by solve().

1654 {
1655 }
void DPMBase::actionsBeforeTimeStep ( )
protectedvirtual

A virtual function which allows to define operations to be executed before the new time step.

no implementation but can be overidden in its derived classes.

Reimplemented in Chute, and ChuteBottom.

Definition at line 1848 of file DPMBase.cc.

Referenced by computeOneTimeStep(), helpers::loadingTest(), helpers::normalAndTangentialLoadingTest(), and helpers::objectivenessTest().

1849 {
1850 }
void DPMBase::actionsOnRestart ( )
protectedvirtual

A virtual function where the users can add extra code which is executed only when the code is restarted.

no implementation but can be overidden in its derived classes.

Reimplemented in BaseCluster.

Definition at line 1667 of file DPMBase.cc.

Referenced by solve().

1668 {
1669 }
bool DPMBase::areInContact ( const BaseParticle pI,
const BaseParticle pJ 
)
static

Checks if two particle are in contact or is there any positive overlap.

Determines whether two particles are distinct and in contact by comparing the separation of their centres to their (interaction) radii.

Firstly, checks if the two particles are different (if pI == pJ, the result is "false"). Secondly, if the two particles are distinct, finds the distance between the two particles' centres (getDistanceSquared(pI->getPosition(), pJ->getPosition()))) and tests whether the separation of the particles is less than the sum of their radii (pI->getInteractionRadius() + pJ->getInteractionRadius()). If so, the bool returns "true", i.e. the particles are in contact.

Parameters
[in]pIA pointer to a particle
[in]pJA pointer to a second particle
Returns
bool (True or False) - lets the user know whether two particles are in contact

Definition at line 1645 of file DPMBase.cc.

References BaseParticle::isInContactWith().

Referenced by Mercury2D::hGridFindParticleContacts(), Mercury3D::hGridFindParticleContacts(), and Mercury3D::hGridHasContactsInTargetCell().

1646 {
1647  return (pI != pJ && pI->isInContactWith(pJ));
1648 }
virtual bool isInContactWith(const BaseParticle *P) const
Get whether or not this particle is in contact with the given particle.
void DPMBase::autoNumber ( )

The autoNumber() function calls three functions: setRunNumber(), readRunNumberFromFile() and incrementRunNumberInFile().

Using the three functions named above, the autoNumber() function acts to:

1) Use the readRunNumberFromFile() function toead the current run number from the file COUNTER_DONOTDEL created by any script which utilises auto-numbering.

2) Set the runNumber_ counter to the value obtained from the above using the setRunNumber() function.

3) Increment the value stored in the COUNTER_DONOTDEL file by one once the current value has been read using the incrementRunNumberInFile() function.

Definition at line 529 of file DPMBase.cc.

References getRestarted(), incrementRunNumberInFile(), readRunNumberFromFile(), and setRunNumber().

Referenced by readNextArgument().

530 {
532 
533  if (!getRestarted())
534  {
536  }
537 }
static void incrementRunNumberInFile()
Increment the run Number (counter value) stored in the file_counter (COUNTER_DONOTDEL) by 1 and store...
Definition: DPMBase.cc:618
bool getRestarted() const
Returns the flag denoting if the simulation was restarted or not.
Definition: DPMBase.cc:1477
static int readRunNumberFromFile()
Read the run number or the counter from the counter file (COUNTER_DONOTDEL)
Definition: DPMBase.cc:543
void setRunNumber(int runNumber)
This sets the counter/Run number, overriding the defaults.
Definition: DPMBase.cc:596
void DPMBase::checkAndDuplicatePeriodicParticles ( )
protected

For simulations using periodic boundaries, checks and adds particles when necessary into the particle handler. See DPMBase.cc and PeriodicBoundary.cc for more details.

For all particles in the system, checks their proximity to all periodic boundaries. If a particle is found to be near a periodic boundary, creates and adds a periodic ("ghost") particle.

periodicBoundary.png

Definition at line 4857 of file DPMBase.cc.

References boundaryHandler, and particleHandler.

Referenced by computeOneTimeStep(), and solve().

4858 {
4859  //Looping over all boundaries in the boundaryHandler
4860  for (BaseBoundary* boundary : boundaryHandler)
4861  {
4862  //Calls the createPeriodicParticles() function which checks if a particle is adequately
4863  //close to a periodic particle that a periodic (ghost) particle should be created and,
4864  //if so, creates one and adds it to the system (hence the necessity to keep "N" variable).
4865  //
4866  // (The loop is over all boundaries, but if a boundary is not a PeriodicBoundary, then
4867  // this does nothing.)
4868  boundary->createPeriodicParticles(particleHandler);
4869  }
4870 
4871  // OMP parallelism
4872  /*#pragma omp parallel for num_threads(getNumberOfOMPThreads()) //schedule(dynamic)
4873  for (int k = 0; k < boundaryHandler.getNumberOfObjects(); k++)
4874  {
4875  //Calls the createPeriodicParticles() function which checks if a particle is adequately
4876  //close to a periodic particle that a periodic (ghost) particle should be created and,
4877  //if so, creates one and adds it to the system (hence the necessity to keep "N" variable).
4878  //
4879  // (The loop is over all boundaries, but if a boundary is not a PeriodicBoundary, then
4880  // this does nothing.)
4881 
4882  BaseBoundary* boundary = boundaryHandler.getObject(k);
4883  #pragma omp critical
4884  boundary->createPeriodicParticles(particleHandler);
4885  }*/
4886 }
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1391
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
void DPMBase::checkInteractionWithBoundaries ( )
protectedvirtual

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.

For each boundary, checks whether each particle in the system has "passed" it and performs an action according to the type of boundary involved.

For instance, if the boundary is a periodic boundary, the periodic boundary version of "checkBoundaryAfterParticleMoved" will be called ( PeriodicBoundary::checkBoundaryAfterParticleMoved()) and in turn apply the shiftPosition() function to the particle. If the boundary is a deletion boundary ( DeletionBoundary::checkBoundaryAfterParticleMoved ()), any particle passing the boundary will be deleted. Further details can be seen in the in-code comments below.

Definition at line 3170 of file DPMBase.cc.

References boundaryHandler, PeriodicBoundaryHandler::cleanCommunicationLists(), Domain::cleanCommunicationLists(), PeriodicBoundaryHandler::flushParticles(), Domain::flushParticles(), getCurrentDomain(), NUMBER_OF_PROCESSORS, particleHandler, periodicBoundaryHandler, and ParticleHandler::removeGhostObject().

Referenced by computeOneTimeStep().

3171 {
3172 
3173  //Cycling over all boundaries within the system...
3174  for (BaseBoundary* b : boundaryHandler)
3175  {
3176  //check all boundaries...
3177  b->checkBoundaryAfterParticlesMove(particleHandler);
3178 
3179 
3180 #ifdef MERCURY_USE_MPI
3181  //When ghost particles are deleted by deletion boundaries they need to be removed
3182  //from their communication lists to avoid segfaults
3183  if (NUMBER_OF_PROCESSORS > 1)
3184  {
3185  //Flush deleted particles from mpi communication zones
3186  getCurrentDomain()->flushParticles(b->getParticlesToBeDeleted());
3188  periodicBoundaryHandler.flushParticles(b->getParticlesToBeDeleted());
3190  }
3191 
3192  //Delete particles that were in communication zone
3193  for (auto p_it = b->getParticlesToBeDeleted().begin(); p_it != b->getParticlesToBeDeleted().end(); p_it++)
3194  {
3195  particleHandler.removeGhostObject((*p_it)->getIndex());
3196  }
3197 #endif
3198  }
3199 }
Domain * getCurrentDomain()
Function that returns a pointer to the domain corresponding to the processor.
Definition: DPMBase.cc:5076
void flushParticles(std::set< BaseParticle * > &toBeDeletedList)
Particles that are going to be deleted from the simulation are flushed out of the communication bound...
Definition: Domain.cc:1698
void flushParticles(std::set< BaseParticle * > &particlesToBeFlushed)
Removes particles from the periodiocParticleList_ and periociGhostList_.
void cleanCommunicationLists()
Removes nullptrs from boundaryParticleList_ and boundaryParticleListNeighbour_.
Definition: Domain.cc:1742
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1391
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1396
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
void removeGhostObject(unsigned int index)
Removes a BaseParticle from the ParticleHandler without a global check, this is only to be done for m...
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:62
bool DPMBase::checkParticleForInteraction ( const BaseParticle p)
virtual

Checks whether a particle P has any interaction with walls or other particles.

A very useful feature. For example, when one wants to have an initial condition with particles free of interactions with other particles or walls, one could use this to see if a particle about to be inserted would have interactions. If yes, then the particle would not be considered for insertion.

However can prove expensive if the number of particles is large.

Parameters
[in]pThe particle for which one wants to detect collisions (or the lack thereof).
Returns
true if and only if there are no interactions with other particles or walls.

Reimplemented in MercuryBase.

Definition at line 4631 of file DPMBase.cc.

References MPIContainer::broadcast(), checkParticleForInteractionLocal(), checkParticleForInteractionLocalPeriodic(), MPIContainer::gather(), constants::i, MPIContainer::Instance(), NUMBER_OF_PROCESSORS, and PROCESSOR_ID.

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

4632 {
4633 #ifdef MERCURY_USE_MPI
4634  if (NUMBER_OF_PROCESSORS == 1)
4635  {
4637  }
4638 
4639  int localInteraction = checkParticleForInteractionLocal(p);
4640  //The root gathers all values and computes the global value
4641  int *interactionList = nullptr;
4642  if (PROCESSOR_ID == 0)
4643  {
4644  interactionList = new int [NUMBER_OF_PROCESSORS];
4645  }
4646 
4647  //Gather all local values
4648  MPIContainer::Instance().gather(localInteraction,interactionList);
4649 
4650  //Compute the global value
4651  int globalInteraction = 1;
4652  if (PROCESSOR_ID == 0)
4653  {
4654  for (int i = 0; i < NUMBER_OF_PROCESSORS; i++)
4655  {
4656  if (interactionList[i] == 0)
4657  {
4658  globalInteraction = 0;
4659  break;
4660  }
4661  }
4662  }
4663  //The root now tells the other processors what the global value for the interaction is
4664  MPIContainer::Instance().broadcast(globalInteraction);
4665 
4666  //Convert the result back to bool
4667  bool interaction = globalInteraction;
4668 #else
4669  bool interaction = checkParticleForInteractionLocalPeriodic(p);
4670 #endif
4671  return interaction;
4672 }
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:134
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
void gather(T &send_t, T *receive_t)
Gathers a scaler from all processors to a vector of scalars on the root.
Definition: MpiContainer.h:428
#define PROCESSOR_ID
Definition: GeneralDefine.h:63
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:62
std::enable_if< std::is_scalar< T >::value, void >::type broadcast(T &t, int fromProcessor=0)
Broadcasts a scalar from the root to all other processors.
Definition: MpiContainer.h:441
bool checkParticleForInteractionLocalPeriodic(const BaseParticle &P)
Definition: DPMBase.cc:4680
virtual bool checkParticleForInteractionLocal(const BaseParticle &P)
Checks if a particle P has any interaction with walls or other particles in the local domain...
Definition: DPMBase.cc:4730
bool DPMBase::checkParticleForInteractionLocal ( const BaseParticle p)
virtual

Checks if a particle P has any interaction with walls or other particles in the local domain.

A very useful feature. For example, when one wants to have an initial condition with particles free of interactions with other particles or walls, one could use this method and whether particles are interacting. If yes, then it would not consider this particle for insertion and continue onto the next particle. However can prove expensive if the number of particles is large.

Returns true if and only if there are no interactions with other particles in the local domain or walls.

Parameters
[in]pThe particle for which one wants to detect collisions (or the lack thereof).
Returns
bool - true if particle P has no interactions, false if P has one or more interactions with other particles or walls.
Todo:
tw check against periodic copies (see ShearCell3DInitialConditions.cpp)

Reimplemented in MercuryBase.

Definition at line 4730 of file DPMBase.cc.

References Vec3D::getDistanceSquared(), BaseInteractable::getPosition(), BaseParticle::getSumOfInteractionRadii(), particleHandler, mathsFunc::square(), and wallHandler.

Referenced by checkParticleForInteraction(), and checkParticleForInteractionLocalPeriodic().

4731 {
4732  Mdouble distance;
4733  Vec3D normal;
4734 
4735  //Check if it has no collision with walls
4736  for (BaseWall* w : wallHandler)
4737  {
4738  //returns false if the function getDistanceAndNormal returns true,
4739  //i.e. if there exists an interaction between wall and particle
4740  //\todo TW getDistanceAndNormal(p,distance,normal) should ideally be replaced by a inContact(p) function, as it doesn't require distance and normal for anything (and walls now can have multiple contacts, soon particles can have it too.)
4741  if (w->getDistanceAndNormal(p, distance, normal))
4742  {
4743  //std::cout<<"failure: Collision with wall: "<<**it<<std::endl;
4744  return false;
4745  }
4746  else
4747  {
4748  //std::cout<<"No collision with wall: "<<**it<<std::endl;
4749  }
4750  }
4751 
4752  //Check if it has no collision with other particles
4753  for (BaseParticle* q : particleHandler)
4754  {
4755  //returns false if the particle separation is less than the relevant sum of interaction radii
4756  //(i.e. another particle is in contact with P)
4757  if (Vec3D::getDistanceSquared(q->getPosition(), p.getPosition())
4759  {
4760  //std::cout<<"failure: Collision with particle "<<**it<<std::endl;
4761  return false;
4762  }
4763  else
4764  {
4765  //std::cout<<"No collision with particle "<<**it<<std::endl;
4766  }
4767  }
4768  return true;
4770 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
double Mdouble
Definition: GeneralDefine.h:34
Mdouble getSumOfInteractionRadii(const BaseParticle *particle) const
returns the sum of the radii plus the interactionDistance
Definition: BaseParticle.h:376
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
Basic class for walls.
Definition: BaseWall.h:47
static Mdouble getDistanceSquared(const Vec3D &a, const Vec3D &b)
Calculates the squared distance between two Vec3D: .
Definition: Vector.h:295
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1386
Definition: Vector.h:49
T square(const T val)
squares a number
Definition: ExtendedMath.h:105
bool DPMBase::checkParticleForInteractionLocalPeriodic ( const BaseParticle p)

Extends the capability of detecting intersecting particles to periodic systems

Todo:
TW the implementation of this function is not very efficient and should be improved
Parameters
p
Returns

Definition at line 4680 of file DPMBase.cc.

References boundaryHandler, checkParticleForInteractionLocal(), BaseParticle::copy(), PeriodicBoundary::getDistance(), ParticleHandler::getLargestParticle(), BaseParticle::getMaxInteractionRadius(), ParticleHandler::getNumberOfObjects(), BaseInteractable::getPosition(), constants::i, particleHandler, BaseInteractable::setPosition(), and PeriodicBoundary::shiftPosition().

Referenced by checkParticleForInteraction().

4681 {
4682  //A vector of ghost particles of the particle that is to be inserted (empty if no periodic boundaries are present)
4683  std::vector<Vec3D> pPeriodic;
4684  for (BaseBoundary* b : boundaryHandler)
4685  {
4686  PeriodicBoundary* pb = dynamic_cast<PeriodicBoundary*>(b);
4687  if (pb && particleHandler.getNumberOfObjects() > 0 )
4688  {
4690  for (int i = pPeriodic.size() - 1; i >= 0; --i)
4691  {
4692  if (pb->getDistance(pPeriodic[i]) < maxDistance)
4693  {
4694  pPeriodic.push_back(pPeriodic[i]);
4695  pb->shiftPosition(pPeriodic.back());
4696  }
4697  }
4698  if (pb->getDistance(p) < maxDistance)
4699  {
4700  pPeriodic.push_back(p.getPosition());
4701  pb->shiftPosition(pPeriodic.back());
4702  }
4703  }
4704  }
4705  //check the particle AND the ghost particles for intersection problems
4706  bool insertable = checkParticleForInteractionLocal(p);
4707  if (!pPeriodic.empty()) {
4708  BaseParticle* q = p.copy();
4709  for (const Vec3D& pos : pPeriodic) {
4710  q->setPosition(pos);
4711  insertable &= checkParticleForInteractionLocal(*q);
4712  }
4713  delete q;
4714  }
4715  return insertable;
4716 }
void shiftPosition(BaseParticle *p) const override
shifts the particle
BaseParticle * getLargestParticle() const
Returns the pointer of the largest particle in the particle handler. When mercury is running in paral...
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
double Mdouble
Definition: GeneralDefine.h:34
unsigned int getNumberOfObjects() const override
Returns the number of objects in the container. In parallel code this practice is forbidden to avoid ...
Mdouble getMaxInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
Definition: BaseParticle.h:359
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
virtual BaseParticle * copy() const =0
Particle copy method. It calls to copy constructor of this Particle, useful for polymorfism.
Mdouble getDistance(const BaseParticle &p) const override
Returns the distance of the edge to the particle.
Defines a pair of periodic walls. Inherits from BaseBoundary.
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1391
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: Vector.h:49
virtual bool checkParticleForInteractionLocal(const BaseParticle &P)
Checks if a particle P has any interaction with walls or other particles in the local domain...
Definition: DPMBase.cc:4730
void DPMBase::checkSettings ( )

Checks if the essentials are set properly to go ahead with solving the problem.

  1. Checks if at least one species exists in the SpeciesHandler.
  2. Checks if the time step is set or not.

    If any of the above checks fail, gives an error message to the user and terminates the program.

Definition at line 3823 of file DPMBase.cc.

References getName(), BaseHandler< T >::getNumberOfObjects(), getTimeStep(), getXMax(), getXMin(), getYMax(), getYMin(), getZMax(), getZMin(), logger, particleHandler, speciesHandler, systemDimensions_, and wallHandler.

Referenced by solve().

3824 {
3825  //check if name is set
3826  logger.assert_always(getName() != "",
3827  "File name not set: use setName()");
3828  //check if time step is set
3829  logger.assert_always(getTimeStep() != 0,
3830  "Time step undefined: use setTimeStep()");
3831  //check if domain is set
3832  logger.assert_always(getXMax() > getXMin(),
3833  "Domain size not set: use setXMin() and setXMax()");
3834  logger.assert_always(getYMax() > getYMin(),
3835  "Domain size not set: use setYMin() and setYMax()");
3836  logger.assert_always(systemDimensions_ == 3 ? (getZMax() > getZMin()) : (getZMax() >= getZMin()),
3837  "Domain size not set: use setZMin() and setZMax()", systemDimensions_);
3838 
3839  //check for species parameters
3840  logger.assert_always(speciesHandler.getNumberOfObjects() > 0,
3841  "No species defined: use speciesHandler.copyAndAddObject()");
3842  for (BaseParticle* p : particleHandler)
3843  {
3844  logger.assert_always(p->getSpecies() != nullptr, "particle % has no species", p->getId());
3845  }
3846  for (BaseWall* w : wallHandler)
3847  {
3848  logger.assert_always(w->getSpecies() != nullptr, "% with index % has no species", w->getName(), w->getId());
3849  }
3850 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.h:629
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.h:598
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.h:611
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:390
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.h:605
unsigned int systemDimensions_
The dimensions of the simulation i.e. 2D or 3D.
Definition: DPMBase.h:1226
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
Basic class for walls.
Definition: BaseWall.h:47
virtual unsigned int getNumberOfObjects() const
Gets the number of real Object in this BaseHandler. (i.e. no mpi or periodic particles) ...
Definition: BaseHandler.h:648
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1366
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.h:617
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1386
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.h:623
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1234
void DPMBase::closeFiles ( )

Closes all files (ene, data, fstat, restart, stat) that were opened to read or write.

Definition at line 493 of file DPMBase.cc.

References File::close(), dataFile, eneFile, fStatFile, interactionFile, restartFile, and statFile.

Referenced by solve(), and Mercury3DRestart::writeOutputFiles().

494 {
495  dataFile.close();
496  fStatFile.close();
497  restartFile.close();
498  statFile.close();
499  eneFile.close();
501 }
File interactionFile
File class to handle in- and output into .interactions file. This file hold information about interac...
Definition: DPMBase.h:1443
void close()
Closes the file by calling fstream_.close()
Definition: File.cc:407
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1417
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1422
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: DPMBase.h:1437
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1427
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1432
virtual void DPMBase::computeAdditionalForces ( )
inlineprotectedvirtual

A virtual function which allows to define operations to be executed prior to the OMP force collect.

no implementation but can be overidden in its derived classes. This function is called by DPMBase::computeAllForces. It may be used to add additional user defined forces to any MercuryObject. Within this function, OMP parallelization may be used, as it is called prior to sumForceTorqueOMP.

Definition at line 1066 of file DPMBase.h.

Referenced by computeAllForces().

1066 {}
void DPMBase::computeAllForces ( )
protectedvirtual

Computes all the forces acting on the particles using the BaseInteractable::setForce() and BaseInteractable::setTorque()

Initially, resets all forces to zero for all particles and all walls. For each particle in turn, the function searches for particle interactions, and computes the relevant internal forces, followed by the relevant external forces (e.g. gravity).

Now loop over all particles contacts computing force contributions

Definition at line 3295 of file DPMBase.cc.

References InteractionHandler::addNewObjectsOMP(), BaseWall::checkInteractions(), computeAdditionalForces(), computeExternalForces(), computeInternalForces(), computeWallForces(), DEBUG, PossibleContact::getNext(), BaseHandler< T >::getNumberOfObjects(), getNumberOfOMPThreads(), getNumberOfTimeSteps(), BaseHandler< T >::getObject(), PossibleContact::getP1(), PossibleContact::getP2(), BaseHandler< T >::getSize(), interactionHandler, logger, particleHandler, BaseInteractable::resetForceTorque(), InteractionHandler::resetNewObjectsOMP(), BaseInteractable::sumForceTorqueOMP(), and wallHandler.

Referenced by computeOneTimeStep(), and solve().

3296 {
3297  //Resetting all forces on both particles and walls to zero
3298  #pragma omp parallel num_threads(getNumberOfOMPThreads())
3299  {
3300  #pragma omp for
3301  for (int k = 0; k < particleHandler.getSize(); ++k) {
3303  }
3304  #pragma omp for
3305  for (int k = 0; k < wallHandler.getSize(); k++) {
3307  }
3308  }
3309  logger(DEBUG,"All forces set to zero");
3310 
3311  // for omp simulations, reset the newObjects_ variable (used for reduction)
3313 
3314  // compute all internal and external forces; for omp simulations, this can be done in parallel
3315  #pragma omp parallel num_threads(getNumberOfOMPThreads())
3316  {
3317  //logger(INFO, "Number of omp threads = %", getNumberOfOMPThreads());
3319  #pragma omp for schedule(dynamic)
3320  for (int k = 0; k < particleHandler.getSize(); ++k) {
3322  //computing both internal forces (e.g. due to collisions)
3323  //and external forces (e.g. gravity)
3324  //(compute internal forces compares the current particle p
3325  //with all others in the handler!)
3327  // body forces
3329  }
3330 
3331  // wall-forces
3332  #pragma omp for schedule(dynamic)
3333  for (int k = 0; k < wallHandler.getSize(); k++) {
3334  BaseWall *w = wallHandler.getObject(k);
3335  computeWallForces(w);
3336  }
3337 
3338  }
3339 
3340 #ifdef CONTACT_LIST_HGRID
3341  PossibleContact* Curr=possibleContactList.getFirstPossibleContact();
3342  while(Curr)
3343  {
3344  computeInternalForces(Curr->getP1(),Curr->getP2());
3345  Curr=Curr->getNext();
3346  }
3347 #endif
3348 
3349  // Check wall forces
3350  #pragma omp for schedule(dynamic)
3351  for (int k = 0; k < wallHandler.getNumberOfObjects(); k++) {
3352  BaseWall *w = wallHandler.getObject(k);
3354  }
3355 
3357 
3358  // for omp simulations, sum up all forces and add all newObjects_ (needed since both are using reduction)
3359  #ifdef MERCURY_USE_OMP
3360  if (getNumberOfOMPThreads()>1) {
3362  }
3363  //Resetting all forces on both particles and walls to zero
3364  #pragma omp parallel num_threads(getNumberOfOMPThreads())
3365  {
3366  #pragma omp for
3367  for (int k = 0; k < particleHandler.getSize(); k++) {
3369  }
3370  #pragma omp for
3371  for (int k = 0; k < wallHandler.getSize(); k++) {
3373  } //end reset forces loop
3374  }
3375  #endif
3376 
3377  //end outer loop over contacts.
3378 }
virtual void computeExternalForces(BaseParticle *)
Computes the external forces, such as gravity, acting on particles.
Definition: DPMBase.cc:3067
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
BaseParticle * getP1()
Gets a pointer to the first BaseParticle in this PossibleContact.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
void resetForceTorque(int numberOfOMPthreads)
virtual void computeWallForces(BaseWall *w)
Definition: DPMBase.cc:5214
BaseParticle * getP2()
Gets a pointer to the second BaseParticle in this PossibleContact.
int getNumberOfOMPThreads() const
Definition: DPMBase.cc:1270
PossibleContact * getNext()
Gets the next PossibleContact in the general linked list of PossibleContact.
unsigned int getNumberOfTimeSteps() const
Returns the current counter of time-steps, i.e. the number of time-steps that the simulation has unde...
Definition: DPMBase.cc:814
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
Basic class for walls.
Definition: BaseWall.h:47
virtual unsigned int getNumberOfObjects() const
Gets the number of real Object in this BaseHandler. (i.e. no mpi or periodic particles) ...
Definition: BaseHandler.h:648
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1406
virtual void checkInteractions(InteractionHandler *interactionHandler, unsigned int timeStamp)
Check if all interactions are valid.
Definition: BaseWall.h:219
virtual void computeAdditionalForces()
A virtual function which allows to define operations to be executed prior to the OMP force collect...
Definition: DPMBase.h:1066
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1386
virtual void computeInternalForces(BaseParticle *)
Computes the internal forces on particle i (internal in the sense that the sum over all these forces ...
Definition: DPMBase.cc:3386
Class that describes a possible contact between two BaseParticle.
void DPMBase::computeExternalForces ( BaseParticle CI)
protectedvirtual

Computes the external forces, such as gravity, acting on particles.

Todo:
take out computeWalls() from compute External Forces method.
Parameters
[in]CIThe BaseParticle object to which the relevant external forces are applied.

Definition at line 3067 of file DPMBase.cc.

References BaseInteractable::addForce(), getGravity(), BaseParticle::getMass(), and BaseParticle::isFixed().

Referenced by computeAllForces().

3068 {
3069  //Checks that the current particle is not "fixed"
3070  //and hence infinitely massive!
3071  if (!CI->isFixed())
3072  {
3073  // Applying the force due to gravity (F = m.g)
3074  CI->addForce(getGravity() * CI->getMass());
3075  // Still calls this in compute External Forces.
3076  // computeForcesDueToWalls(CI);
3077  }
3078 }
void addForce(const Vec3D &addForce)
Adds an amount to the force on this BaseInteractable.
Mdouble getMass() const
Returns the particle's mass.
Definition: BaseParticle.h:322
Vec3D getGravity() const
Returns the gravitational acceleration.
Definition: DPMBase.cc:1375
bool isFixed() const override
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...
Definition: BaseParticle.h:93
void DPMBase::computeForcesDueToWalls ( BaseParticle pI,
BaseWall w 
)
protected

Computes the forces on the particles due to the walls (normals are outward normals)

Checks if a particle pI is currently in contact - i.e. interacting - with any of the walls within the system using the BaseParticle::getInteractionWith() function. If an interaction is detected, computes the force acting between particle and wall and applies the relevant torques and forces to both particle and wall(s).

Parameters
[in]pIThe BaseParticle object to which the wall forces are applied.
Todo:
TW: I think this torque has the wrong sign

Definition at line 3087 of file DPMBase.cc.

References BaseInteractable::addForce(), BaseInteractable::addTorque(), BaseInteraction::computeForce(), Vec3D::cross(), BaseInteraction::getContactPoint(), BaseInteraction::getForce(), BaseWall::getInteractionWith(), getNumberOfTimeSteps(), BaseParticle::getPeriodicFromParticle(), BaseInteractable::getPosition(), getRotation(), BaseInteraction::getTorque(), constants::i, and interactionHandler.

Referenced by Mercury3D::computeWallForces(), and computeWallForces().

3088 {
3089  //No need to compute interactions between periodic particle images and walls
3090  if (pI->getPeriodicFromParticle() != nullptr)
3091  return;
3092 
3093  //Checks if the particle is interacting with the current wall
3096  if (i!=nullptr) {
3097  //...calculates the forces between the two objects...
3098  i->computeForce();
3099 
3100  //...and applies them to each of the two objects (wall and particle).
3101  pI->addForce(i->getForce());
3102  w->addForce(-i->getForce());
3103 
3104  //If the rotation flag is on, also applies the relevant torques
3105  //(getRotation() returns a boolean).
3106  if (getRotation()) // getRotation() returns a boolean.
3107  {
3108  pI->addTorque(i->getTorque() - Vec3D::cross(pI->getPosition() - i->getContactPoint(), i->getForce()));
3110  w->addTorque(-i->getTorque() + Vec3D::cross(w->getPosition() - i->getContactPoint(), i->getForce()));
3111  }
3112  }
3113 }
const Vec3D & getTorque() const
Gets the current torque (vector) between the two interacting objects.
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
void addForce(const Vec3D &addForce)
Adds an amount to the force on this BaseInteractable.
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Definition: BaseParticle.h:338
const Vec3D & getContactPoint() const
Gets constant reference to contact point (vector).
BaseInteraction * getInteractionWith(BaseParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler) override
Returns the interaction between this wall and a given particle, nullptr if there is no interaction...
Definition: BaseWall.cc:369
Stores information about interactions between two interactable objects; often particles but could be ...
unsigned int getNumberOfTimeSteps() const
Returns the current counter of time-steps, i.e. the number of time-steps that the simulation has unde...
Definition: DPMBase.cc:814
const Vec3D & getForce() const
Gets the current force (vector) between the two interacting objects.
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1406
void addTorque(const Vec3D &addTorque)
Adds an amount to the torque on this BaseInteractable.
virtual void computeForce()
Virtual function that contains the force law between the two objects interacting. ...
bool getRotation() const
Indicates whether particle rotation is enabled or disabled.
Definition: DPMBase.h:557
void DPMBase::computeInternalForce ( BaseParticle P1,
BaseParticle P2 
)
protectedvirtual

Computes the forces between two particles (internal in the sense that the sum over all these forces is zero i.e. fully modelled forces)

Firstly, checks the types of particles involved in order to ensure that only viable interactions are counted.

Secondly, if the particle combination is viable, checks if the particles are interacting.

Finally, if the particles are found to be interacting, calculates the relevant forces (as well as torques, if the "rotation" flag is turned "on") acting between the particles, and applies them to each particle.

Parameters
[in]P1
[in]P2

Definition at line 3012 of file DPMBase.cc.

References BaseInteractable::addForce(), BaseInteractable::addTorque(), BaseInteraction::computeForce(), Vec3D::cross(), BaseInteraction::getContactPoint(), BaseInteraction::getForce(), BaseObject::getId(), BaseParticle::getInteractionWith(), getNumberOfTimeSteps(), BaseParticle::getPeriodicFromParticle(), BaseInteractable::getPosition(), getRotation(), BaseInteraction::getTorque(), constants::i, interactionHandler, and BaseParticle::isFixed().

Referenced by computeInternalForces(), Mercury2D::hGridFindContactsWithinTargetCell(), Mercury3D::hGridFindContactsWithinTargetCell(), Mercury2D::hGridFindContactsWithTargetCell(), and Mercury3D::hGridFindContactsWithTargetCell().

3013 {
3014  //Does not compute forces if particles are fixed
3015  //this is necessary because the rough bottom allows overlapping fixed particles
3016  if (P1->isFixed() && P2->isFixed())
3017  {
3018  return;
3019  }
3020 //Ensures that interactions between the "ghost" particles used to implement periodic behaviour
3021  //are not included in calculations
3022  //i.e. ends the function if both particles are "ghosts".
3023  if ((P1->getPeriodicFromParticle() != nullptr) && (P2->getPeriodicFromParticle() != nullptr))
3024  {
3025  return;
3026  }
3027 //if statement below ensures that the PI has the lower id than PJ
3028  BaseParticle* PI, * PJ;
3029  if (P1->getId() > P2->getId())
3030  {
3031  PI = P2;
3032  PJ = P1;
3033  }
3034  else
3035  {
3036  PI = P1;
3037  PJ = P2;
3038  }
3039  //checks if the two particles are interacting
3040  //("getInteractionWith" returns the relevant pointer if PI and PJ are interacting,
3041  //zero if not)
3042  //if statement above ensures that the PI has the lower id than PJ
3045  if (i!= nullptr) {
3046  //calculates the force corresponding to the interaction
3047  i->computeForce();
3048 
3049  //Applies the relevant calculated forces to PI and PJ
3050  PI->addForce(i->getForce());
3051  PJ->addForce(-i->getForce());
3052 
3053  //checks if particle rotation is turned on...
3054  if (getRotation()) {
3055  //...and, if so, performs equivalent calculations for the torque as were
3056  //performed for the force.
3057  PI->addTorque(i->getTorque() - Vec3D::cross(PI->getPosition() - i->getContactPoint(), i->getForce()));
3058  PJ->addTorque(-i->getTorque() + Vec3D::cross(PJ->getPosition() - i->getContactPoint(), i->getForce()));
3059  }
3060  }
3061 }
unsigned int getId() const
Returns the unique identifier of any particular object.
Definition: BaseObject.h:125
const Vec3D & getTorque() const
Gets the current torque (vector) between the two interacting objects.
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
void addForce(const Vec3D &addForce)
Adds an amount to the force on this BaseInteractable.
BaseInteraction * getInteractionWith(BaseParticle *P, unsigned timeStamp, InteractionHandler *interactionHandler) override
Checks if particle is in interaction with given particle P, and if so, returns vector of pointer to t...
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Definition: BaseParticle.h:338
const Vec3D & getContactPoint() const
Gets constant reference to contact point (vector).
Stores information about interactions between two interactable objects; often particles but could be ...
unsigned int getNumberOfTimeSteps() const
Returns the current counter of time-steps, i.e. the number of time-steps that the simulation has unde...
Definition: DPMBase.cc:814
const Vec3D & getForce() const
Gets the current force (vector) between the two interacting objects.
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
bool isFixed() const override
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...
Definition: BaseParticle.h:93
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1406
void addTorque(const Vec3D &addTorque)
Adds an amount to the torque on this BaseInteractable.
virtual void computeForce()
Virtual function that contains the force law between the two objects interacting. ...
bool getRotation() const
Indicates whether particle rotation is enabled or disabled.
Definition: DPMBase.h:557
void DPMBase::computeInternalForces ( BaseParticle i)
protectedvirtual

Computes the internal forces on particle i (internal in the sense that the sum over all these forces is zero i.e. fully modelled forces)

Taking a single BaseParticle object as an argument, passes it to the broadPhase() function which then loops over all other particles in the particleHandler and computes the relevant forces for any particle pairing found to be in contact.

Parameters
[in]iA BaseParticle object for which we want to calculate the internal forces.

Reimplemented in Mercury3D, and Mercury2D.

Definition at line 3386 of file DPMBase.cc.

References BaseHandler< T >::begin(), computeInternalForce(), constants::i, and particleHandler.

Referenced by computeAllForces().

3387 {
3388  for (auto it = particleHandler.begin(); (*it) != i; ++it)
3389  {
3390  computeInternalForce(i, *it);
3391  }
3392 }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
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
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
virtual void computeInternalForce(BaseParticle *, BaseParticle *)
Computes the forces between two particles (internal in the sense that the sum over all these forces i...
Definition: DPMBase.cc:3012
void DPMBase::computeOneTimeStep ( )
virtual

Performs everything needed for one time step, used in the time-loop of solve().

Todo:
IFCD , TW: please check what should be in here, and whether it should be virtual or not.

Performs one time step in the time loop, including updating the time. It is made public, since this makes coupling multiple DPM simulations easier in the future.

Todo:
MX: this is not true anymore. all boundaries are handled here. particles have received a position update, so here the deletion boundary deletes particles add particles need a periodic check
Bug:
{In chute particles are added in actions_before_time_set(), however they are not written to the xballs data yet, but can have a collision and be written to the fstat data}

Definition at line 4131 of file DPMBase.cc.

References WallHandler::actionsAfterParticleGhostUpdate(), InteractionHandler::actionsAfterTimeStep(), ParticleHandler::actionsAfterTimeStep(), actionsAfterTimeStep(), actionsBeforeTimeStep(), boundaryHandler, checkAndDuplicatePeriodicParticles(), checkInteractionWithBoundaries(), computeAllForces(), DEBUG, InteractionHandler::eraseOldInteractions(), getNumberOfTimeSteps(), hGridActionsAfterIntegration(), hGridActionsBeforeIntegration(), hGridActionsBeforeTimeStep(), integrateAfterForceComputation(), integrateBeforeForceComputation(), interactionHandler, logger, numberOfTimeSteps_, particleHandler, performGhostParticleUpdate(), removeDuplicatePeriodicParticles(), time_, timeStep_, wallHandler, and writeOutputFiles().

Referenced by solve().

4132 {
4133  logger(DEBUG, "starting computeOneTimeStep()");
4134 
4135  logger(DEBUG, "about to call writeOutputFiles()");
4136  writeOutputFiles(); //everything is written at the beginning of the time step!
4137 
4138  logger(DEBUG, "about to call hGridActionsBeforeIntegration()");
4140 
4141  //Computes the half-time step velocity and full time step position and updates the particles accordingly
4142  logger(DEBUG, "about to call integrateBeforeForceComputation()");
4143 
4145  //New positions require the MPI and parallel periodic boundaries to do things
4146  logger(DEBUG, "about to call performGhostParticleUpdate()");
4148  // Some walls need to be aware of the new positions
4150 
4154 
4155  logger(DEBUG, "about to call checkInteractionWithBoundaries()");
4156  checkInteractionWithBoundaries(); // INSERTION boundaries handled
4157 
4158  logger(DEBUG, "about to call hGridActionsAfterIntegration()");
4160 
4161  // Compute forces
4163  // INSERTION/DELETION boundary flag change
4164  for (BaseBoundary* b : boundaryHandler)
4165  {
4166  b->checkBoundaryBeforeTimeStep(this);
4167  }
4168 
4169  logger(DEBUG, "about to call actionsBeforeTimeStep()");
4171 
4172  logger(DEBUG, "about to call checkAndDuplicatePeriodicParticles()");
4174 
4175  logger(DEBUG, "about to call hGridActionsBeforeTimeStep()");
4177 
4178  //Creates and updates interactions and computes forces based on these
4179  logger(DEBUG, "about to call computeAllForces()");
4180  computeAllForces();
4181 
4182  logger(DEBUG, "about to call removeDuplicatePeriodicParticles()");
4184 
4185  logger(DEBUG, "about to call actionsAfterTimeStep()");
4187 
4188  //Computes new velocities and updates the particles accordingly
4189  logger(DEBUG, "about to call integrateAfterForceComputation()");
4191 
4192  //erase interactions that have not been used during the last time step
4193  //logger(DEBUG, "about to call interactionHandler.eraseOldInteractions(getNumberOfTimeSteps())");
4195  logger(DEBUG, "about to call interactionHandler.actionsAfterTimeStep()");
4198 
4199  time_ += timeStep_;
4201 
4202  logger(DEBUG, "finished computeOneTimeStep()");
4203 }
void eraseOldInteractions(unsigned)
erases interactions which have an old timestamp.
virtual void integrateAfterForceComputation()
Update particles' and walls' positions and velocities after force computation.
Definition: DPMBase.cc:3212
void checkAndDuplicatePeriodicParticles()
For simulations using periodic boundaries, checks and adds particles when necessary into the particle...
Definition: DPMBase.cc:4857
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
virtual void actionsAfterTimeStep()
A virtual function which allows to define operations to be executed after time step.
Definition: DPMBase.cc:1862
virtual void writeOutputFiles()
Writes simulation data to all the main Mercury files: .data, .ene, .fstat, .xballs and ...
Definition: DPMBase.cc:3873
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1257
void actionsAfterParticleGhostUpdate()
Calls the method actionsAfterParticleGhostUpdate of every wall in the handler.
Definition: WallHandler.cc:479
virtual void hGridActionsBeforeIntegration()
This function has to be called before integrateBeforeForceComputation.
Definition: DPMBase.cc:1924
unsigned int getNumberOfTimeSteps() const
Returns the current counter of time-steps, i.e. the number of time-steps that the simulation has unde...
Definition: DPMBase.cc:814
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1391
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
Mdouble time_
Stores the current simulation time.
Definition: DPMBase.h:1252
virtual void computeAllForces()
Computes all the forces acting on the particles using the BaseInteractable::setForce() and BaseIntera...
Definition: DPMBase.cc:3295
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1406
virtual void actionsBeforeTimeStep()
A virtual function which allows to define operations to be executed before the new time step...
Definition: DPMBase.cc:1848
Mdouble timeStep_
Stores the simulation time step.
Definition: DPMBase.h:1262
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1386
void removeDuplicatePeriodicParticles()
Removes periodic duplicate Particles.
Definition: DPMBase.cc:4814
virtual void integrateBeforeForceComputation()
Update particles' and walls' positions and velocities before force computation.
Definition: DPMBase.cc:3126
virtual void hGridActionsAfterIntegration()
This function has to be called after integrateBeforeForceComputation.
Definition: DPMBase.cc:1931
virtual void hGridActionsBeforeTimeStep()
A virtual function that allows one to set or execute hGrid parameters or operations before every simu...
Definition: DPMBase.cc:1674
virtual void checkInteractionWithBoundaries()
There are a range of boundaries one could implement depending on ones' problem. This methods checks f...
Definition: DPMBase.cc:3170
void performGhostParticleUpdate()
When the Verlet scheme updates the positions and velocities of particles, ghost particles will need a...
Definition: DPMBase.cc:4891
void DPMBase::computeWallForces ( BaseWall w)
virtual

Reimplemented in Mercury3D.

Definition at line 5214 of file DPMBase.cc.

References computeForcesDueToWalls(), and particleHandler.

Referenced by computeAllForces(), and Mercury3D::computeWallForces().

5215 {
5216  //compute forces for all particles that are neither fixed or ghosts
5217  for (auto p : particleHandler)
5218  {
5219  if (!p->isFixed() && p->getPeriodicFromParticle() == nullptr)
5220  {
5221  //w->computeForces(p);
5223  }
5224  }
5225 }
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
void computeForcesDueToWalls(BaseParticle *, BaseWall *)
Computes the forces on the particles due to the walls (normals are outward normals) ...
Definition: DPMBase.cc:3087
void DPMBase::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().

A simple vector of vectors for collecting and ordering interactions in the OpenMP parallel environment

Provides all the necessary default values for the DPMBase() constructor. When called, will initialise a two-dimensional simulation (setSystemDimensions(2), setParticleDimensions(2)) with "normal" vertical gravity (gravity_ = Vec3D(0.0, -9.8, 0.0);) as well as defining an arbitrary length (1s) and XBalls viewing domain (0.01 x 0.01) and other relevant viewing parameters (e.g. colourscheme, scale...). The first block of text creates the necessary handlers and sets their content according to the current ("this") instance of the DPMBase superclass.

Definition at line 201 of file DPMBase.cc.

References boundaryHandler, cgHandler, dataFile, DEBUG, domainHandler, eneFile, fStatFile, File::getFstream(), DomainHandler::initialise(), PeriodicBoundaryHandler::initialise(), initialiseMPI(), interactionFile, interactionHandler, logger, max_, min_, name_, NO_FILE, nToWrite_, numberOfDomains_, numberOfOMPThreads_, numberOfTimeSteps_, particleHandler, periodicBoundaryHandler, random, readSpeciesFromDataFile_, restartFile, runNumber_, setAppend(), BaseHandler< T >::setDPMBase(), File::setFileType(), setGravity(), setName(), setParticleDimensions(), RNG::setRandomSeed(), setRestarted(), setSaveCount(), setSystemDimensions(), setTime(), setTimeMax(), speciesHandler, statFile, timeStep_, vtkWriter_, wallHandler, writeParticlesVTK_, writeSuperquadricParticlesVTK_, writeWallsVTK_, xBallsAdditionalArguments_, xBallsColourMode_, xBallsScale_, and xBallsVectorScale_.

Referenced by DPMBase().

202 {
203  //constructor();
204  dataFile.getFstream().precision(10);
205  fStatFile.getFstream().precision(10);
206  eneFile.getFstream().precision(10);
207  restartFile.getFstream().precision(
208  std::numeric_limits<double>::digits10); //highly accurate, so the overlap is accurate
209  statFile.getFstream().precision(10);
210  statFile.getFstream().setf(std::ios::left);
211  interactionFile.getFstream().precision(10);
212  name_ = ""; // needs to be user-specified, otherwise checkSettings throws error
213  //by default, the fileType of all files is ONE_FILE. However, by default we don't want an interaction file since it
214  // is very large.
216 
217  runNumber_ = 0;
218 
219  //Decomposition direction for MPI
220  numberOfDomains_ = {1, 1, 1};
221 
222  //Check if MPI is already initialised
223  initialiseMPI();
224 
225  //This sets the maximum number of particles
230  cgHandler.setDPMBase(this);
232  wallHandler.setDPMBase(this);
238 
239  //set defaults for DPMBase parameters
242  setRestarted(false);
243  setGravity(Vec3D(0, 0, 0));
244 
245  //This is the parameter of the numerical part
246  setTime(0);
247  numberOfTimeSteps_ = 0;
248  setTimeMax(0);
249  timeStep_ = 0; // needs to be user-specified, otherwise checkSettings throws error
250  setSaveCount(20);
251 
252  //This sets the default xballs domain
253  min_ = Vec3D(0, 0, 0);
254  max_ = Vec3D(0, 0, 0); // needs to be user-specified, otherwise checkSettings throws error
255 
256  //sets the default write particles data in VTK format flag to false
257  writeParticlesVTK_ = false;
260  vtkWriter_ = nullptr;
261 
262  setName(""); // needs to be user-specified, otherwise checkSettings throws error
263 
264  //Default mode is energy with no scale of the vectors
265  xBallsColourMode_ = 0;
266  xBallsVectorScale_ = -1;
267  xBallsScale_ = -1;
269  setAppend(false);
270 
271  //The default random seed is 0
273 
274  logger(DEBUG, "DPMBase problem constructor finished");
275 
276  readSpeciesFromDataFile_ = false;
277 
279 
280  //Set number of elements to write to the screen if a user wants to output write information to the terminal
281  nToWrite_ = 4;
282 }
void setTime(Mdouble time)
Sets a new value for the current simulation time.
Definition: DPMBase.cc:826
std::string name_
the name of the problem, used, e.g., for the output files
Definition: DPMBase.h:1345
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:863
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
Vec3D max_
Definition: DPMBase.h:1247
void setDPMBase(DPMBase *DPMBase)
Sets the problem that is solved using this handler.
Definition: BaseHandler.h:718
bool readSpeciesFromDataFile_
Determines if the last column of the data file is interpreted as the info parameter during restart...
Definition: DPMBase.h:1355
File interactionFile
File class to handle in- and output into .interactions file. This file hold information about interac...
Definition: DPMBase.h:1443
int runNumber_
This stores the run number for saving.
Definition: DPMBase.h:1340
void setParticleDimensions(unsigned int particleDimensions)
Sets the particle dimensionality.
Definition: DPMBase.cc:1432
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1401
std::vector< unsigned > numberOfDomains_
Vector containing the number of domains in x-,y- and z-direction, required for parallel computations...
Definition: DPMBase.h:1241
void setAppend(bool newAppendFlag)
Sets whether the "append" option is on or off.
Definition: DPMBase.cc:1506
void setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1401
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1367
void initialiseMPI()
Inialises the MPI library.
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1257
void initialise()
Initialises the communication list vectors as they can not be determined on compile time...
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1417
file will not be created/read
std::fstream & getFstream()
Allows to access the member variable File::fstream_.
Definition: File.cc:153
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1422
bool writeSuperquadricParticlesVTK_
Definition: DPMBase.h:1304
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1412
int xBallsColourMode_
XBalls is a package to view the particle data. As an alternative MercuryDPM also supports ParaView...
Definition: DPMBase.h:1320
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1391
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1396
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1306
Mdouble xBallsScale_
sets the xballs argument scale (see XBalls/xballs.txt)
Definition: DPMBase.h:1330
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
int nToWrite_
number of elements to write to a screen
Definition: DPMBase.h:1360
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:399
int numberOfOMPThreads_
Definition: DPMBase.h:1221
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1366
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1406
FileType writeWallsVTK_
A flag to turn on/off the vtk writer for walls.
Definition: DPMBase.h:1297
Mdouble xBallsVectorScale_
sets the xballs argument vscale (see XBalls/xballs.txt)
Definition: DPMBase.h:1325
Mdouble timeStep_
Stores the simulation time step.
Definition: DPMBase.h:1262
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:215
void setRandomSeed(unsigned long int new_seed)
This is the seed for the random number generator (note the call to seed_LFG is only required really i...
Definition: RNG.cc:53
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1386
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:1371
bool writeParticlesVTK_
A flag to turn on/off the vtk writer for particles.
Definition: DPMBase.h:1302
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:413
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: DPMBase.h:1437
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1427
std::string xBallsAdditionalArguments_
A string of additional arguments for xballs can be specified (see XBalls/xballs.txt). e.g. "-solidf -v0".
Definition: DPMBase.h:1335
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1432
void setRestarted(bool newRestartedFlag)
Allows to set the flag stating if the simulation is to be restarted or not.
Definition: DPMBase.cc:1485
Definition: Vector.h:49
Vec3D min_
These vectors are used for the XBalls domain, and occasionally people use it to add walls...
Definition: DPMBase.h:1246
bool DPMBase::continueSolve ( ) const
protectedvirtual

A virtual function for deciding whether to continue the simulation, based on a user-specified criterion.

Used within the main loop of the 'solve()' routine to let the code know whether or not the time step should continue to be advanced, i.e. whether the simulation should be continued. By default this is always true but the user may redefine it to return false under certain desired circumstances.

Returns
bool (True or False)

Definition at line 1974 of file DPMBase.cc.

Referenced by solve().

1975 {
1976  return true;
1977 }
void DPMBase::decompose ( )
virtual

Sends particles from processorId to the root processor.

Decomposes the simulation domain in a structured cube mesh of domains for parallel processing

This function takes the simulation domain boundaries and decomposes it into sub domains ready for parallel computations

Definition at line 3912 of file DPMBase.cc.

References DomainHandler::createMesh(), domainHandler, ERROR, BaseHandler< T >::getNumberOfObjects(), ParticleHandler::getNumberOfRealObjects(), BaseHandler< T >::getSize(), getXMax(), getXMin(), getYMax(), getYMin(), getZMax(), getZMin(), MPIContainer::initialiseMercuryMPITypes(), MPIContainer::Instance(), logger, NUMBER_OF_PROCESSORS, numberOfDomains_, particleHandler, PROCESSOR_ID, BaseHandler< T >::setDPMBase(), speciesHandler, MPIContainer::sync(), VERBOSE, XAXIS, YAXIS, and ZAXIS.

Referenced by read(), and solve().

3913 {
3914 #ifdef MERCURY_USE_MPI
3915 
3916  //If running in parallel build, but just running with one core - no domain decomposition required
3917  int numberOfRequiredProcessors = numberOfDomains_[Direction::XAXIS]*
3920  if (NUMBER_OF_PROCESSORS != numberOfRequiredProcessors)
3921  {
3922  logger(ERROR,"The domain decompositions expects % processors, but only % are requested.\n"
3923  "Either run your process using \"mpirun -np % [executable]\", "
3924  "or change the domain decomposition to e.g. setNumberOfDomains({%,1,1}).", numberOfRequiredProcessors, NUMBER_OF_PROCESSORS, numberOfRequiredProcessors, NUMBER_OF_PROCESSORS);
3925  }
3926 
3927  if (NUMBER_OF_PROCESSORS == 1) {return;}
3928 
3929  //Check if the simulation domain has been set
3930  logger.assert_always(getXMax() - getXMin() > 0,"Please set your simulation domain (setXMax(),setXmin()) before calling solve()");
3931  logger.assert_always(getYMax() - getYMin() > 0,"Please set your simulation domain (setYMax(),setYmin()) before calling solve()");
3932  logger.assert_always(getZMax() - getZMin() > 0,"Please set your simulation domain (setZMax(),setZmin()) before calling solve()");
3933 
3934  //Grab simulation domains
3935  std::vector<Mdouble> simulationMin{getXMin(), getYMin(), getZMin()};
3936  std::vector<Mdouble> simulationMax{getXMax(), getYMax(), getZMax()};
3937 
3938  //Check if the user input decomposition is correct
3939  logger.assert_always(numberOfDomains_[Direction::XAXIS] > 0,"Number of domain in x-direction incorrect: %",numberOfDomains_[Direction::XAXIS]);
3940  logger.assert_always(numberOfDomains_[Direction::YAXIS] > 0,"Number of domain in y-direction incorrect: %",numberOfDomains_[Direction::YAXIS]);
3941  logger.assert_always(numberOfDomains_[Direction::ZAXIS] > 0,"Number of domain in z-direction incorrect: %",numberOfDomains_[Direction::ZAXIS]);
3942 
3943  //Open domain decomposition, closed is not implemented
3944  bool open = true;
3945 
3946  //Check if the number of domains is equal to the number of processors
3947  logger.assert_always(numberOfDomains_[Direction::XAXIS]*numberOfDomains_[Direction::YAXIS]*numberOfDomains_[Direction::ZAXIS] == NUMBER_OF_PROCESSORS,
3948  "Number of Processors is not equal to number of domains. Processors %, domains, %",
3950  numberOfDomains_[Direction::XAXIS]*numberOfDomains_[Direction::YAXIS]*numberOfDomains_[Direction::ZAXIS]);
3951 
3952  //Create all processor domains
3953 
3954  domainHandler.setDPMBase(this);
3955  domainHandler.createMesh(simulationMin, simulationMax, numberOfDomains_, open);
3956  logger(VERBOSE,"Number of domains: % | Number of processors: %",domainHandler.getNumberOfObjects(), NUMBER_OF_PROCESSORS);
3957  //logger.assert_always(domainHandler.getNumberOfObjects() == numberOfProcessors, "Invalid decomposition: Number of domains and processors are different");
3958 
3959  //Tell the current processor to which domain it belongs
3960  for (Domain* domain : domainHandler)
3961  {
3962  if (domain->getRank() == PROCESSOR_ID)
3963  {
3964  logger(VERBOSE,"processor: %, domain index: %",PROCESSOR_ID, domain->getIndex());
3965  domainHandler.setCurrentDomainIndex(domain->getIndex());
3966  }
3967  }
3968 
3969  //Define the mpi transfer types, which requires a definition of the species already
3971  logger.assert_always(speciesHandler.getNumberOfObjects() > 0, "Please create a particle species before calling solve()");
3973 
3974  //Make sure all processors are done with decomposition before proceeding
3975  logger(VERBOSE,"processor %: #real particles: %, #total particles: %", PROCESSOR_ID, particleHandler.getNumberOfRealObjects(), particleHandler.getSize());
3977 #endif
3978 }
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:134
void initialiseMercuryMPITypes(const SpeciesHandler &speciesHandler)
Creates the MPI types required for communication of Mercury data through the MPI interface.
Definition: MpiContainer.cc:74
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
void setDPMBase(DPMBase *DPMBase)
Sets the problem that is solved using this handler.
Definition: BaseHandler.h:718
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.h:629
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.h:598
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.h:611
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1401
std::vector< unsigned > numberOfDomains_
Vector containing the number of domains in x-,y- and z-direction, required for parallel computations...
Definition: DPMBase.h:1241
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.h:605
unsigned int getNumberOfRealObjects() const
Returns the number of real objects (on all processors)
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
#define PROCESSOR_ID
Definition: GeneralDefine.h:63
virtual unsigned int getNumberOfObjects() const
Gets the number of real Object in this BaseHandler. (i.e. no mpi or periodic particles) ...
Definition: BaseHandler.h:648
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1366
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:62
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.h:617
The simulation can be subdivided into Domain's used in parallel code.
Definition: Domain.h:63
void sync()
Process all pending asynchronous communication requests before continuing.
Definition: MpiContainer.h:152
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.h:623
void createMesh(std::vector< Mdouble > &simulationMin, std::vector< Mdouble > &simulationMax, std::vector< unsigned > &numberOfDomains, bool open)
Creates a Cartesian square mesh in 3D.
void DPMBase::deleteGhostParticles ( std::set< BaseParticle * > &  particlesToBeDeleted)
protected
Todo:
: doc

Definition at line 4914 of file DPMBase.cc.

References PeriodicBoundaryHandler::cleanCommunicationLists(), Domain::cleanCommunicationLists(), domainHandler, PeriodicBoundaryHandler::flushParticles(), Domain::flushParticles(), DomainHandler::getCurrentDomain(), BaseHandler< T >::getSize(), particleHandler, periodicBoundaryHandler, and ParticleHandler::removeGhostObject().

Referenced by performGhostParticleUpdate().

4915 {
4916  //Flush mixed particles from lists (MP particles are located in both structures)
4917  if (periodicBoundaryHandler.getSize() > 0)
4918  {
4919  //Flush particles from boundaries
4920  domainHandler.getCurrentDomain()->flushParticles(particlesToBeDeleted);
4921  periodicBoundaryHandler.flushParticles(particlesToBeDeleted);
4922  }
4923 
4924  //Clean communication lists
4927 
4928  //Delete the particles
4929  for (auto particle_it : particlesToBeDeleted)
4930  {
4931  particleHandler.removeGhostObject(particle_it->getIndex());
4932  }
4933 }
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
void flushParticles(std::set< BaseParticle * > &toBeDeletedList)
Particles that are going to be deleted from the simulation are flushed out of the communication bound...
Definition: Domain.cc:1698
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1401
void flushParticles(std::set< BaseParticle * > &particlesToBeFlushed)
Removes particles from the periodiocParticleList_ and periociGhostList_.
void cleanCommunicationLists()
Removes nullptrs from boundaryParticleList_ and boundaryParticleListNeighbour_.
Definition: Domain.cc:1742
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1396
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
void removeGhostObject(unsigned int index)
Removes a BaseParticle from the ParticleHandler without a global check, this is only to be done for m...
Domain * getCurrentDomain()
Gets the domain assigned to the processor.
void DPMBase::fillDomainWithParticles ( unsigned  N = 50)

Inserts particles in the whole domain.

THis is useful if you want to check whether the wall visualisation or wall computation is correct: First insert the walls, then the particles, then check in paraview if the walls and particles overlap

Parameters
N

Definition at line 2892 of file DPMBase.cc.

References BaseHandler< T >::getLastObject(), getMax(), getMin(), BaseHandler< T >::getSize(), getTotalVolume(), INFO, InsertionBoundary::insertParticles(), logger, particleHandler, CubeInsertionBoundary::set(), and speciesHandler.

2892  {
2893  logger.assert_always(speciesHandler.getSize()>0,"There needs to be at least one species");
2895  SphericalParticle p(s);
2897  Mdouble r = cbrt(getTotalVolume())/N;
2898  b.set(p,100,getMin(),getMax(),{0,0,0},{0,0,0},r,r);
2899  b.insertParticles(this);
2900  logger(INFO,"Inserted % particles",particleHandler.getSize());
2901  //setTimeMax(0);
2902  //solve();
2903 }
A spherical particle is the most simple particle used in MercuryDPM.
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
double Mdouble
Definition: GeneralDefine.h:34
Vec3D getMin() const
Definition: DPMBase.h:635
void insertParticles(DPMBase *md)
void set(BaseParticle *particleToCopy, unsigned int maxFailed, Vec3D posMin, Vec3D posMax, Vec3D velMin, Vec3D velMax, double radMin, double radMax)
Sets the properties of the CubeInsertionBoundary.
It's an insertion boundary which has cuboidal shape (yes, 'CuboidalInsertionBoundary' would have been...
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
Mdouble getTotalVolume() const
Get the total volume of the cuboid system.
Definition: DPMBase.cc:5157
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1366
Vec3D getMax() const
Definition: DPMBase.h:641
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
bool DPMBase::findNextExistingDataFile ( Mdouble  tMin,
bool  verbose = true 
)

Finds and opens the next data file, if such a file exists.

First, checks to see if the file type is MULTIPLE_FILES or MULTIPLE_FILES_PADDED and, if so, whether the file contains data (ending the function if not). Then, checks if the time corresponding to the current file exceeds the minimum value entered (tMin). If not, keeps looking through subsequent data files. When a data file that satisfies t > tMin is found and successfully opened, the function returns true.

Useful when fileType is chosen as MULTIPLE_FILES or MULTIPLE_FILES_PADDED, which write data corresponding to each time step as a separate, consecutively numbered file (see FileType).

Parameters
[in]tMinCompared with the t value belonging to the file being checked to see if it is viable.
[in]verboseAllows the function to give output to the screen if desired.
Returns
bool - true if the next file is found, false if not.

Definition at line 2556 of file DPMBase.cc.

References dataFile, File::getCounter(), File::getFileType(), File::getFstream(), File::getName(), logger, MULTIPLE_FILES, MULTIPLE_FILES_PADDED, File::open(), VERBOSE, and WARN.

2557 {
2559  {
2560  while (true)// This true corresponds to the if s
2561  {
2562  dataFile.open();
2563  //check if file exists and contains data
2564  int N;
2565  dataFile.getFstream() >> N;
2566  if (dataFile.getFstream().eof() || dataFile.getFstream().peek() == -1)
2567  {
2568  logger(WARN, "file % not found", dataFile.getName());
2569  return false;
2570  }
2571  //check if tmin condition is satisfied
2572  Mdouble t;
2573  dataFile.getFstream() >> t;
2574  if (t > tMin)
2575  {
2576  //set_file_counter(get_file_counter()-1);
2577  return true;
2578  }
2579  if (verbose)
2580  logger(VERBOSE, "Jumping file counter: %", dataFile.getCounter());
2581  }
2582  }
2583  return true;
2584 }
each time-step will be written into/read from separate files numbered consecutively, with numbers padded by zeros to a minimum of four digits: name_.0000, name_.0001, ..
FileType getFileType() const
Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_.
Definition: File.cc:207
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
double Mdouble
Definition: GeneralDefine.h:34
unsigned int getCounter() const
In case of multiple files, File::getCounter() returns the the number (FILE::Counter_) of the next fil...
Definition: File.cc:223
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1417
std::fstream & getFstream()
Allows to access the member variable File::fstream_.
Definition: File.cc:153
bool open()
Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the ne...
Definition: File.cc:347
each time-step will be written into/read from separate files numbered consecutively: name_...
const std::string & getName() const
Allows to access the file name, e.g., "problem.data".
Definition: File.cc:165
void DPMBase::finishStatistics ( )
protectedvirtual

This function is overridden by StatisticsVector

Reimplemented in StatisticsVector< T >.

Definition at line 1909 of file DPMBase.cc.

References cgHandler, and CGHandler::finish().

Referenced by solve(), and Mercury3DRestart::writeOutputFiles().

1910 {
1911  cgHandler.finish();
1912 }
void finish()
Contains the code executed after the last time step.
Definition: CGHandler.cc:113
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1412
void DPMBase::forceWriteOutputFiles ( )

Writes output files immediately, even if the current time step was not meant to be written. Also resets the last saved time step.

Definition at line 3852 of file DPMBase.cc.

References NEVER, setLastSavedTimeStep(), and writeOutputFiles().

Referenced by FileReader::read(), and solve().

3853 {
3855  writeOutputFiles();
3856 }
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 b...
Definition: DPMBase.cc:509
virtual void writeOutputFiles()
Writes simulation data to all the main Mercury files: .data, .ene, .fstat, .xballs and ...
Definition: DPMBase.cc:3873
const unsigned NEVER
Definition: File.h:35
void DPMBase::gatherContactStatistics ( unsigned int index1  UNUSED,
int index2  UNUSED,
Vec3D Contact  UNUSED,
Mdouble delta  UNUSED,
Mdouble ctheta  UNUSED,
Mdouble fdotn  UNUSED,
Mdouble fdott  UNUSED,
Vec3D P1_P2_normal_  UNUSED,
Vec3D P1_P2_tangential  UNUSED 
)
virtual

//Not unsigned index because of possible wall collisions.

no implementation but can be overidden in its derived classes.

Reimplemented in StatisticsVector< T >.

Definition at line 1893 of file DPMBase.cc.

Referenced by BaseInteraction::gatherContactStatistics().

1896 {
1897 }
void DPMBase::gatherContactStatistics ( )
protected

Definition at line 1882 of file DPMBase.cc.

References interactionHandler.

1883 {
1885  {
1886  c->gatherContactStatistics();
1887  }
1888 }
Stores information about interactions between two interactable objects; often particles but could be ...
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1406
std::vector< int > DPMBase::get1DParametersFromRunNumber ( int  sizeX) 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)

Let's say sizeX = 5, counter stored in COUNTER_DONOTDEL = 1. Substituting these values into the algorithm below implies that studyNum = 0 or 1. Everytime the code is executed the counter gets incremented and the values of studyNum and i are updated, which is returned as std::vector<int>

Parameters
[in]sizeXThe (integer) number of values to be tested in 1D parameter space.
Returns
std::vector<int> The current study numbers.

Definition at line 660 of file DPMBase.cc.

References getRunNumber(), constants::i, INFO, and logger.

661 {
662  // Declare a vector of integers capable of storing 2 values
663  std::vector<int> temp(2);
664 
665  // Declare and initialise for the current simulation run number
666  int counter = getRunNumber();
667 
668  // Give studyNum value 0 if study is incomplete, otherwise value > 0
669  int studyNum = (counter-1)/sizeX;
670  counter = counter - sizeX*studyNum;
671 
672  int i = ((counter - 1) % sizeX) + 1;
673  logger(INFO,"StudyNum: % \t Counter: % \t i: %", studyNum, counter, i);
674  temp[0] = studyNum;
675  temp[1] = i;
676 
677  return temp;
678 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
int getRunNumber() const
This returns the current value of the counter (runNumber_)
Definition: DPMBase.cc:607
std::vector< int > DPMBase::get2DParametersFromRunNumber ( int  sizeX,
int  sizeY 
) 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)

Let's say sizeX = 2 and sizeY = 5, counter stored in COUNTER_DONOTDEL =1. The studySize = 10. Substituting these values into the below algorithm implies that studyNum = 0 or 1, everytime the code is executed the counter gets incremented and hence determined the values of studyNum, i and j which is returned as a std::vector<int>

Parameters
[in]sizeXThe (integer) number of values to be tested for one of the 2 parameters forming the 2D parameter space.
[in]sizeYThe (integer) number of values to be tested for the other of the 2 parameters forming the 2D parameter space.
Returns
std::vector<int>

Definition at line 688 of file DPMBase.cc.

References getRunNumber(), constants::i, INFO, and logger.

689 {
690  //declares a vector of integers capable of storing 3 values,
691  std::vector<int> temp(3);
692  //declares and initialises an integer variable named "counter"
693  //with the current counter number, runNumber_
694  int counter = getRunNumber();
695  //calculates the total size of the study, i.e. the number of points
696  //in the 2D parameter space explored
697  int studySize = sizeX * sizeY;
698  //(counter - 1) / studySize gives a fraction comparing the number of runs conducted so far
699  //to the total size of the study, i.e. the total number of runs that need to be performed.
700  //since studyNum is an integer, will declare zero until an adequate number of runs has been performed,
701  //at which point it will equal 1
702  int studyNum = (counter - 1) / studySize;
703 
704  counter = counter - studySize * studyNum;
705  int i = ((counter - 1) % sizeX) + 1;
706  int j = ((counter - i) / sizeX) + 1;
707  logger(INFO,"StudyNum: % \t Counter: % \t i: % \t j: %", studyNum, counter, i, j);
708 
709  temp[0] = studyNum;
710  temp[1] = i;
711  temp[2] = j;
712 
713  return (temp);
714 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
int getRunNumber() const
This returns the current value of the counter (runNumber_)
Definition: DPMBase.cc:607
std::vector< int > DPMBase::get3DParametersFromRunNumber ( int  sizeX,
int  sizeY,
int  sizeZ 
) 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)

Let's say sizeX = 2, sizeY = 5 and sizeZ = 3, counter stored in COUNTER_DONOTDEL =1. The studySize = 30. Substituting these values into the below algorithm implies that studyNum = 0 or 1, everytime the code is executed the counter gets incremented and hence determined the values of studyNum, i,j and k which is returned as a std::vector<int>

Parameters
[in]sizeXThe (integer) number of values to be tested for one of the 3 parameters forming the 3D parameter space.
[in]sizeYThe (integer) number of values to be tested for one of the 3 parameters forming the 3D parameter space.
[in]sizeZThe (integer) number of values to be tested for one of the 3 parameters forming the 3D parameter space.
Returns
std::vector<int>

Definition at line 725 of file DPMBase.cc.

References getRunNumber(), constants::i, INFO, and logger.

726 {
727  //declares a vector of integers capable of storing 4 values,
728  std::vector<int> temp(4);
729  //declares and initialises an integer variable named "counter"
730  //with the current counter number, runNumber_
731  int counter = getRunNumber();
732  //calculates the total size of the study, i.e. the number of points
733  //in the 3D parameter space explored
734  int studySize = sizeX * sizeY * sizeZ;
735  //(counter - 1) / studySize gives a fraction comparing the number of runs conducted so far
736  //to the total size of the study, i.e. the total number of runs that need to be performed.
737  //since studyNum is an integer, will declare zero until an adequate number of runs has been performed,
738  //at which point it will equal 1
739  int studyNum = (counter - 1) / studySize;
740 
741  counter = counter - studySize * studyNum;
742  int i = ((counter-1) % sizeX) + 1;
743  int j = static_cast<int>(std::floor((counter-1)/sizeX)) % sizeY + 1;
744  int k = static_cast<int>(std::floor((counter-1)/(sizeX*sizeY))) % sizeZ + 1;
745  logger(INFO,"StudyNum: % \t Counter: % \t i: % \t j: % \t k: %", studyNum, counter, i, j, k);
746 
747  temp[0] = studyNum;
748  temp[1] = i;
749  temp[2] = j;
750  temp[3] = k;
751 
752  return (temp);
753 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
int getRunNumber() const
This returns the current value of the counter (runNumber_)
Definition: DPMBase.cc:607
bool DPMBase::getAppend ( ) const

Returns whether the "append" option is on or off.

Returns
true if the "append" option is on; false if the "append" option is off.

Definition at line 1494 of file DPMBase.cc.

References append_.

Referenced by solve(), and writeEneHeader().

1495 {
1496  return append_;
1497 }
bool append_
A flag to determine if the file has to be appended or not. See DPMBase::Solve() for example...
Definition: DPMBase.h:1285
Vec3D DPMBase::getCentreOfMass ( ) const

JMFT: Return the centre of mass of the system, excluding fixed particles.

Returns the centre of mass of particles, excluding fixed particles.

Definition at line 1598 of file DPMBase.cc.

References ParticleHandler::getCentreOfMass(), and particleHandler.

1599 {
1601 }
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
Vec3D getCentreOfMass() const
double DPMBase::getCPUTime ( )
inline

Definition at line 869 of file DPMBase.h.

References clock_, and Time::getCPUTime().

869 { return clock_.getCPUTime(); }
Mdouble getCPUTime()
Definition: MercuryTime.h:76
Time clock_
record when the simulation started
Definition: DPMBase.h:1448
Domain * DPMBase::getCurrentDomain ( )

Function that returns a pointer to the domain corresponding to the processor.

Function that returns a pointer to the domain correseponding to the processor.

Returns
Pointer to a domain corresponding to the processor

Definition at line 5076 of file DPMBase.cc.

References domainHandler, and DomainHandler::getCurrentDomain().

Referenced by checkInteractionWithBoundaries(), and PeriodicBoundaryHandler::clearCommunicationLists().

5077 {
5079 }
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1401
Domain * getCurrentDomain()
Gets the domain assigned to the processor.
File & DPMBase::getDataFile ( )

The non const version. Allows one to edit the File::dataFile.

Deprecated:
dataFile is now protected, so it can be used by all applications. Please don't use getDataFile() anymore.
Returns
File& (A reference of object type File i.e. File& dataFile)

Definition at line 296 of file DPMBase.cc.

References dataFile.

297 {
298  return dataFile;
299 }
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1417
const File & DPMBase::getDataFile ( ) const

The const version. Does not allow for any editing of the File::dataFile.

Deprecated:
dataFile is now protected, so it can be used by all applications. Please don't use getDataFile() anymore.
Returns
const File& (A const reference of object type File i.e. const File& dataFile)

Definition at line 345 of file DPMBase.cc.

References dataFile.

346 {
347  return dataFile;
348 }
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1417
Mdouble DPMBase::getElasticEnergy ( ) const

Returns the global elastic energy within the system.

Returns
elasticEnergy The total elastic energy of all current particle interactions.

Definition at line 1514 of file DPMBase.cc.

References interactionHandler.

Referenced by BaseCluster::actionsAfterSolve(), BaseCluster::actionsAfterTimeStep(), getTotalEnergy(), BaseCluster::printTime(), writeEneTimeStep(), and BaseCluster::writeToCdatFile().

1515 {
1516  Mdouble elasticEnergy = 0.0;
1517  // JMFT: Note that we do count the elastic energy of fixed particles here.
1518  for (const BaseInteraction* c : interactionHandler)
1519  {
1520  elasticEnergy += c->getElasticEnergy();
1521  }
1522  return elasticEnergy;
1523 }
double Mdouble
Definition: GeneralDefine.h:34
Stores information about interactions between two interactable objects; often particles but could be ...
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1406
File & DPMBase::getEneFile ( )

The non const version. Allows to edit the File::eneFile.

Deprecated:
eneFile is now protected, so it can be used by all applications. Please don't use getEneFile() anymore.
Returns
File& (A reference of object type File i.e. File& eneFile)

Definition at line 304 of file DPMBase.cc.

References eneFile.

305 {
306  return eneFile;
307 }
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1427
const File & DPMBase::getEneFile ( ) const

The const version. Does not allow for any editing of the File::eneFile.

Deprecated:
eneFile is now protected, so it can be used by all applications. Please don't use getEneFile() anymore.
Returns
const File& (A const reference of object type File i.e. const File& eneFile)

Definition at line 353 of file DPMBase.cc.

References eneFile.

354 {
355  return eneFile;
356 }
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1427
File & DPMBase::getFStatFile ( )

The non const version. Allows to edit the File::fStatFile.

Deprecated:
fStatFile is now protected, so it can be used by all applications. Please don't use getFStatFile() anymore.
Returns
File& (A reference of object type File i.e. File& fStatFile)

Definition at line 312 of file DPMBase.cc.

References fStatFile.

313 {
314  return fStatFile;
315 }
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1422
const File & DPMBase::getFStatFile ( ) const

The const version. Does not allow for any editing of the File::fStatFile.

Deprecated:
fStatFile is now protected, so it can be used by all applications. Please don't use getFStatFile() anymore.
Returns
const File& (A const reference of object type File i.e. const File& fStatFile)

Definition at line 361 of file DPMBase.cc.

References fStatFile.

362 {
363  return fStatFile;
364 }
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1422
Mdouble DPMBase::getGravitationalEnergy ( ) const

Returns the global gravitational potential energy stored in the system.

Returns
gravitationalEnergy The total gravitational potential energy of all particles (relative to the origin).

Definition at line 1545 of file DPMBase.cc.

References Vec3D::dot(), getGravity(), and particleHandler.

Referenced by getTotalEnergy().

1546 {
1547  Mdouble gravitationalEnergy = 0;
1548  for (const BaseParticle* const p : particleHandler)
1549  {
1550  // Don't consider fixed particles. 'Fixed' particles aren't necessarily
1551  // stationary; it just means their position is prescribed.
1552  if (!(p->isFixed()))
1553  {
1554  gravitationalEnergy += p->getMass() * Vec3D::dot((-getGravity()), p->getPosition());
1555  }
1556  }
1557  return gravitationalEnergy;
1558 }
double Mdouble
Definition: GeneralDefine.h:34
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
Vec3D getGravity() const
Returns the gravitational acceleration.
Definition: DPMBase.cc:1375
Vec3D DPMBase::getGravity ( ) const

Returns the gravitational acceleration.

Returns
Vec3D gravity_ The desired new value of the gravitational acceleration as a Vec3D vector.

Definition at line 1375 of file DPMBase.cc.

References gravity_.

Referenced by DropletBoundary::checkBoundaryAfterParticlesMove(), computeExternalForces(), getGravitationalEnergy(), ChuteWithHopper::getMaximumVelocityInducedByGravity(), Chute::setChuteAngle(), write(), and writeEneTimeStep().

1376 {
1377  return gravity_;
1378 }
Vec3D gravity_
Gravity vector.
Definition: DPMBase.h:1236
bool DPMBase::getHGridUpdateEachTimeStep ( ) const
virtual
Returns
bool (True or False)

Reimplemented in MercuryBase.

Definition at line 1702 of file DPMBase.cc.

Referenced by BaseParticle::integrateBeforeForceComputation().

1703 {
1704  return true;
1705 }
Mdouble DPMBase::getInfo ( const BaseParticle p) const
virtual

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

Returns
double

Definition at line 1626 of file DPMBase.cc.

References BaseParticle::getInfo().

1627 {
1628 // return p.getSpecies()->getId(); // was getIndex()
1629  return p.getInfo();
1630 }
virtual Mdouble getInfo() const
Returns some user-defined information about this object (by default, species ID). ...
File & DPMBase::getInteractionFile ( )

Return a reference to the file InteractionsFile.

Returns
A reference of object type File i.e. File* interactionFile_

Definition at line 336 of file DPMBase.cc.

References interactionFile.

Referenced by BaseInteraction::BaseInteraction(), setName(), solve(), and BaseInteraction::~BaseInteraction().

337 {
338  return interactionFile;
339 }
File interactionFile
File class to handle in- and output into .interactions file. This file hold information about interac...
Definition: DPMBase.h:1443
const File & DPMBase::getInteractionFile ( ) const

Returns a constant reference to an Interactions file

Returns
const File& (A const reference of object type std::string i.e. const std::string& name_)
Bug:
The InteractionFile does not work across multifiles.

Definition at line 385 of file DPMBase.cc.

386 {
387  return interactionFile;
388 }
File interactionFile
File class to handle in- and output into .interactions file. This file hold information about interac...
Definition: DPMBase.h:1443
Mdouble DPMBase::getKineticEnergy ( ) const

Returns the global kinetic energy stored in the system.

Returns
kineticEnergy The total kinetic energy of all particles.

Definition at line 1528 of file DPMBase.cc.

References particleHandler.

Referenced by BaseCluster::actionsAfterSolve(), BaseCluster::actionsAfterTimeStep(), getTotalEnergy(), BaseCluster::printTime(), setMeanVelocityAndKineticEnergy(), and BaseCluster::writeToCdatFile().

1529 {
1530  Mdouble kineticEnergy = 0;
1531  for (const BaseParticle* const p : particleHandler)
1532  {
1533  if (!(p->isFixed()))
1534  {
1535  kineticEnergy += .5 * p->getMass() * p->getVelocity().getLengthSquared();
1536  }
1537  }
1538  return kineticEnergy;
1539 }
double Mdouble
Definition: GeneralDefine.h:34
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
Matrix3D DPMBase::getKineticStress ( ) const

Calculate the kinetic stress tensor in the system averaged over the whole volume.

The function calculate the kinetic stress tensor based on particle fluctuation velocity.

Returns
The kinetic stress of the whole system (all particles).

Definition at line 5166 of file DPMBase.cc.

References Matrix3D::dyadic(), getTotalMass(), getTotalVolume(), and particleHandler.

Referenced by getTotalStress().

5167 {
5168  Matrix3D F; //set the kinetic energy tensor, this is in terms of Sum(m*v^2)
5169  Vec3D J; //set the momentum tensor
5170 
5171  //calculate stress for kinetic part
5172  for (const auto& p : particleHandler)
5173  {
5174  F += Matrix3D::dyadic(p->getVelocity(), p->getVelocity()) * p->getMass();
5175  J += p->getVelocity() * p->getMass();
5176  }
5177 
5178  Matrix3D stressKinetic = F - Matrix3D::dyadic(J, J) / getTotalMass();
5179  stressKinetic /= getTotalVolume();
5180  return stressKinetic;
5181 }
static Matrix3D dyadic(const Vec3D &a, const Vec3D &b)
Calculates the dyadic product of a two Vec3D: .
Definition: Matrix.cc:323
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
Mdouble getTotalVolume() const
Get the total volume of the cuboid system.
Definition: DPMBase.cc:5157
Mdouble getTotalMass() const
JMFT: Return the total mass of the system, excluding fixed particles.
Definition: DPMBase.cc:1582
Implementation of a 3D matrix.
Definition: Matrix.h:37
Definition: Vector.h:49
const std::string & DPMBase::getName ( ) const
Mdouble DPMBase::getNextTime ( ) const

Returns the current simulation time.

Returns
time_

Definition at line 806 of file DPMBase.cc.

References time_, and timeStep_.

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

807 {
808  return time_ + timeStep_;
809 }
Mdouble time_
Stores the current simulation time.
Definition: DPMBase.h:1252
Mdouble timeStep_
Stores the simulation time step.
Definition: DPMBase.h:1262
int DPMBase::getNToWrite ( ) const

get the number of elements to write to the

Gets nToWrite. If a user wants to output e.g. particle information to the screen we limit the number of outputs to nToWrite elements to not get an overflow of information in the terminal.

Parameters
[out]nToWrite_Number of elements to write to the screen

Definition at line 854 of file DPMBase.cc.

References nToWrite_.

Referenced by write().

855 {
856  return nToWrite_;
857 }
int nToWrite_
number of elements to write to a screen
Definition: DPMBase.h:1360
std::vector< unsigned > DPMBase::getNumberOfDomains ( )

returns the number of domains

number of domains in parallel code in terms of domains in x,y,z direction

Returns
Returns the number of domains in cartesian cooridates of the parallel mesh

Definition at line 5067 of file DPMBase.cc.

References numberOfDomains_.

Referenced by RandomClusterInsertionBoundary::checkBoundaryBeforeTimeStep(), CGHandler::evaluateDataFiles(), CGHandler::evaluateRestartFiles(), and DomainHandler::getParticleDomainGlobalIndex().

5068 {
5069  return numberOfDomains_;
5070 }
std::vector< unsigned > numberOfDomains_
Vector containing the number of domains in x-,y- and z-direction, required for parallel computations...
Definition: DPMBase.h:1241
int DPMBase::getNumberOfOMPThreads ( ) const

Definition at line 1270 of file DPMBase.cc.

References numberOfOMPThreads_.

Referenced by computeAllForces(), setNumberOfOMPThreads(), and write().

1271 {
1272  //logger.assert_debug(numberOfOMPThreads_,"You need to set the number of OMP threads");
1273  return numberOfOMPThreads_;
1274 }
int numberOfOMPThreads_
Definition: DPMBase.h:1221
unsigned int DPMBase::getNumberOfTimeSteps ( ) const

Returns the current counter of time-steps, i.e. the number of time-steps that the simulation has undergone so far.

Returns
numberOfTimeSteps_

Definition at line 814 of file DPMBase.cc.

References numberOfTimeSteps_.

Referenced by DropletBoundary::checkBoundaryAfterParticlesMove(), computeAllForces(), computeForcesDueToWalls(), computeInternalForce(), computeOneTimeStep(), importParticlesAs(), readNextFStatFile(), writeDataFile(), writeEneFile(), writeFStatFile(), and writeRestartFile().

815 {
816  return numberOfTimeSteps_;
817 }
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1257
unsigned int DPMBase::getParticleDimensions ( ) const

Returns the particle dimensionality.

Returns
particleDimensions_ The dimensionality of the particles. (Note that the system may possess a different dimensionality).

Definition at line 1451 of file DPMBase.cc.

References particleDimensions_.

Referenced by BaseParticle::getParticleDimensions(), ParticleSpecies::getVolumeFromRadius(), and write().

1452 {
1453  return particleDimensions_;
1454 }
unsigned int particleDimensions_
determines if 2D or 3D particle volume is used for mass calculations
Definition: DPMBase.h:1231
bool DPMBase::getParticlesWriteVTK ( ) const

Returns whether particles are written in a VTK file.

The VTK format is used for visualisation in Paraview.

Todo:
Move this (and the set) to ParticleHandler.
Returns
bool

Definition at line 969 of file DPMBase.cc.

References writeParticlesVTK_.

Referenced by writePythonFileForVTKVisualisation(), and writeVTKFiles().

970 {
971  return writeParticlesVTK_;
972 }
bool writeParticlesVTK_
A flag to turn on/off the vtk writer for particles.
Definition: DPMBase.h:1302
bool DPMBase::getRestarted ( ) const

Returns the flag denoting if the simulation was restarted or not.

Returns
restarted_

Definition at line 1477 of file DPMBase.cc.

References restarted_.

Referenced by autoNumber(), solve(), and writeOutputFiles().

1478 {
1479  return restarted_;
1480 }
bool restarted_
A bool to check if the simulation was restarted or not, ie. if setupInitialConditionsShould be run an...
Definition: DPMBase.h:1279
File & DPMBase::getRestartFile ( )

The non const version. Allows to edit the File::restartFile.

Deprecated:
restartFile is now protected, so it can be used by all applications. Please don't use getRestartFile() anymore.
Returns
File& (A reference of object type File i.e. File& restartFile)

Definition at line 320 of file DPMBase.cc.

References restartFile.

321 {
322  return restartFile;
323 }
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1432
const File & DPMBase::getRestartFile ( ) const

The const version. Does not allow for any editing of the File::restartFile.

Deprecated:
restartFile is now protected, so it can be used by all applications. Please don't use getRestartFile() anymore.
Returns
const File& (A const reference of object type File i.e. const File& restartFile)

Definition at line 369 of file DPMBase.cc.

References restartFile.

370 {
371  return restartFile;
372 }
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1432
std::string DPMBase::getRestartVersion ( ) const

This is to take into account for different Mercury versions. Returns the version of the restart file.

Returns
restartVersion_

Definition at line 1459 of file DPMBase.cc.

References restartVersion_.

Referenced by Chute::read().

1460 {
1461  return restartVersion_;
1462 }
std::string restartVersion_
Previous versions of MercuryDPM had a different restart file format, the below member variable allows...
Definition: DPMBase.h:1274
bool DPMBase::getRotation ( ) const
inline

Indicates whether particle rotation is enabled or disabled.

Returns
true if particle rotation is enabled; false if particle rotation is disabled.

Definition at line 557 of file DPMBase.h.

References rotation_.

Referenced by MeshTriangle::checkInteractions(), computeForcesDueToWalls(), computeInternalForce(), BaseWall::getInteractionWith(), and BaseParticle::integrateBeforeForceComputation().

558  { return rotation_; }
bool rotation_
A flag to turn on/off particle rotation. true will enable particle rotation. false will disable parti...
Definition: DPMBase.h:1292
Mdouble DPMBase::getRotationalEnergy ( ) const

JMFT Returns the global rotational energy stored in the system.

Todo:
TW why is the ene_rot commented out

Definition at line 1561 of file DPMBase.cc.

References BaseHandler< T >::begin(), BaseHandler< T >::end(), and particleHandler.

Referenced by getTotalEnergy().

1562 {
1563  Mdouble ene_rot = 0;
1564  for (std::vector<BaseParticle*>::const_iterator it = particleHandler.begin(); it != particleHandler.end(); ++it)
1565  {
1566  // See above.
1567  if (!(*it)->isFixed())
1568  {
1569  // ene_rot += .5 * (*it)->getInertia() * (*it)->getAngularVelocity().getLengthSquared();
1570  }
1571  }
1572  return ene_rot;
1573 }
double Mdouble
Definition: GeneralDefine.h:34
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
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
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
int DPMBase::getRunNumber ( ) const

This returns the current value of the counter (runNumber_)

A simple "get function" which allows the user to retrieve the current value corresponding to the run number counter, runNumber_

Returns
runNumber_ - the stored value of the current run number, i.e. the number of files corresponding to a given Mercury script that have been produced in a given directory.

Definition at line 607 of file DPMBase.cc.

References runNumber_.

Referenced by get1DParametersFromRunNumber(), get2DParametersFromRunNumber(), get3DParametersFromRunNumber(), and solve().

608 {
609  return runNumber_;
610 }
int runNumber_
This stores the run number for saving.
Definition: DPMBase.h:1340
File & DPMBase::getStatFile ( )

The non const version. Allows to edit the File::statFile.

Deprecated:
statFile is now protected, so it can be used by all applications. Please don't use getStatFile() anymore.
Returns
File& (A reference of object type File i.e. File& statFile)

Definition at line 328 of file DPMBase.cc.

References statFile.

329 {
330  return statFile;
331 }
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: DPMBase.h:1437
const File & DPMBase::getStatFile ( ) const

The const version. Does not allow for any editing of the File::statFile.

Deprecated:
statFile is now protected, so it can be used by all applications. Please don't use getStatFile() anymore.
Returns
const File& (A const reference of object type File i.e. const File& statFile)

Definition at line 377 of file DPMBase.cc.

References statFile.

378 {
379  return statFile;
380 }
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: DPMBase.h:1437
Matrix3D DPMBase::getStaticStress ( ) const

Calculate the static stress tensor in the system averaged over the whole volume.

The function calculate the static stress tensor based on particle contact force and contact normal branch vector.

Returns
The static stress of the whole system (all interactions).

Definition at line 5188 of file DPMBase.cc.

References Matrix3D::dyadic(), getTotalVolume(), constants::i, and interactionHandler.

Referenced by getTotalStress().

5189 {
5190  //stress components calculation variables
5191  Matrix3D stressStatic;
5192 
5193  //calculate the static stress tensor based on all the interactions
5194  for (const auto i : interactionHandler)
5195  {
5196  stressStatic += Matrix3D::dyadic(i->getForce(), i->getNormal()) * i->getDistance();
5197  }
5198 
5199  stressStatic /= getTotalVolume();
5200  return stressStatic;
5201 }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
static Matrix3D dyadic(const Vec3D &a, const Vec3D &b)
Calculates the dyadic product of a two Vec3D: .
Definition: Matrix.cc:323
Mdouble getTotalVolume() const
Get the total volume of the cuboid system.
Definition: DPMBase.cc:5157
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1406
Implementation of a 3D matrix.
Definition: Matrix.h:37
bool DPMBase::getSuperquadricParticlesWriteVTK ( ) const
Returns
bool

Definition at line 977 of file DPMBase.cc.

References writeSuperquadricParticlesVTK_.

Referenced by writeVTKFiles().

978 {
980 }
bool writeSuperquadricParticlesVTK_
Definition: DPMBase.h:1304
unsigned int DPMBase::getSystemDimensions ( ) const

Returns the system dimensionality.

Returns
systemDimensions_ The dimensionality of the system. (Note that particles may possess a different dimensionality.)

Definition at line 1414 of file DPMBase.cc.

References systemDimensions_.

Referenced by HGridOptimiser::initialise(), outputXBallsData(), readNextDataFile(), StatisticsVector< T >::setNZ(), and write().

1415 {
1416  return systemDimensions_;
1417 }
unsigned int systemDimensions_
The dimensions of the simulation i.e. 2D or 3D.
Definition: DPMBase.h:1226
Mdouble DPMBase::getTimeMax ( ) const

Returns the maximum simulation duration.

Returns
timeMax_

Definition at line 878 of file DPMBase.cc.

References timeMax_.

Referenced by StatisticsVector< T >::getTimeMaxStat(), helpers::loadingTest(), helpers::normalAndTangentialLoadingTest(), helpers::objectivenessTest(), Chute::printTime(), printTime(), Mercury3DRestart::readNextArgument(), readNextArgument(), solve(), and write().

879 {
880  return timeMax_;
881 }
Mdouble timeMax_
Stores the duration of the simulation.
Definition: DPMBase.h:1267
Mdouble DPMBase::getTotalEnergy ( ) const

Definition at line 1575 of file DPMBase.cc.

References getElasticEnergy(), getGravitationalEnergy(), getKineticEnergy(), and getRotationalEnergy().

1575  {
1577 }
Mdouble getRotationalEnergy() const
JMFT Returns the global rotational energy stored in the system.
Definition: DPMBase.cc:1561
Mdouble getElasticEnergy() const
Returns the global elastic energy within the system.
Definition: DPMBase.cc:1514
Mdouble getGravitationalEnergy() const
Returns the global gravitational potential energy stored in the system.
Definition: DPMBase.cc:1545
Mdouble getKineticEnergy() const
Returns the global kinetic energy stored in the system.
Definition: DPMBase.cc:1528
Mdouble DPMBase::getTotalMass ( ) const

JMFT: Return the total mass of the system, excluding fixed particles.

Returns
double

Definition at line 1582 of file DPMBase.cc.

References ParticleHandler::getMass(), and particleHandler.

Referenced by getKineticStress(), setMeanVelocity(), and setMeanVelocityAndKineticEnergy().

1583 {
1584  /*
1585  double mass_sum = 0;
1586  for (std::vector<BaseParticle*>::const_iterator it = particleHandler.begin(); it != particleHandler.end(); ++it)
1587  if (!(*it)->isFixed())
1588  mass_sum += (*it)->getMass();
1589  return mass_sum;
1590  */
1591  return particleHandler.getMass();
1592 }
Mdouble getMass() const
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
Vec3D DPMBase::getTotalMomentum ( ) const

JMFT: Return the total momentum of the system, excluding fixed particles.

Returns the total momentum in the system, excluding fixed particles (which will usually, but not always, have velocity 0)

Returns
Vec3D

Definition at line 1608 of file DPMBase.cc.

References ParticleHandler::getMomentum(), and particleHandler.

Referenced by setMeanVelocity(), and setMeanVelocityAndKineticEnergy().

1609 {
1610  return particleHandler.getMomentum();
1611  /*
1612  Vec3D total_momentum = Vec3D(0,0,0);
1613  for (std::vector<BaseParticle*>::const_iterator it = particleHandler.begin(); it != particleHandler.end(); ++it)
1614  if (!(*it)->isFixed())
1615  total_momentum += (*it)->getMass() * (*it)->getVelocity();
1616  return total_momentum;
1617  */
1618 }
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
Vec3D getMomentum() const
Matrix3D DPMBase::getTotalStress ( ) const

Calculate the total stress tensor in the system averaged over the whole volume.

The function calculate the total stress tensor which is the sum of kinetic and static stress tensors.

Returns
The total stress of the whole system (all particles and all interactions).

Definition at line 5208 of file DPMBase.cc.

References getKineticStress(), and getStaticStress().

Referenced by StressStrainControlBoundary::computeStrainRate().

5209 {
5210  return getKineticStress() + getStaticStress();
5211 }
Matrix3D getStaticStress() const
Calculate the static stress tensor in the system averaged over the whole volume.
Definition: DPMBase.cc:5188
Matrix3D getKineticStress() const
Calculate the kinetic stress tensor in the system averaged over the whole volume. ...
Definition: DPMBase.cc:5166
Mdouble DPMBase::getTotalVolume ( ) const

Get the total volume of the cuboid system.

Returns
The total volume of the domain.

Definition at line 5157 of file DPMBase.cc.

References getXMax(), getXMin(), getYMax(), getYMin(), getZMax(), and getZMin().

Referenced by fillDomainWithParticles(), getKineticStress(), and getStaticStress().

5158 {
5159  return (getXMax() - getXMin()) * (getYMax() - getYMin()) * (getZMax() - getZMin());
5160 }
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.h:629
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.h:598
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.h:611
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.h:605
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.h:617
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.h:623
ParticleVtkWriter * DPMBase::getVtkWriter ( ) const

Definition at line 5081 of file DPMBase.cc.

References vtkWriter_.

5082 {
5083  return vtkWriter_;
5084 }
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1306
FileType DPMBase::getWallsWriteVTK ( ) const

Returns whether walls are written in a VTK file.

The VTK file is used for visualisation in Paraview.

Todo:
Move this (and the set) to WallHandler.
Returns
bool

Definition at line 958 of file DPMBase.cc.

References writeWallsVTK_.

Referenced by writePythonFileForVTKVisualisation(), and writeVTKFiles().

959 {
960  return writeWallsVTK_;
961 }
FileType writeWallsVTK_
A flag to turn on/off the vtk writer for walls.
Definition: DPMBase.h:1297
double DPMBase::getWallTime ( )
inline

Definition at line 874 of file DPMBase.h.

References clock_, and Time::getWallTime().

874 { return clock_.getWallTime(); }
Mdouble getWallTime()
Definition: MercuryTime.h:84
Time clock_
record when the simulation started
Definition: DPMBase.h:1448
std::string DPMBase::getXBallsAdditionalArguments ( ) const

Returns the additional arguments for xballs.

Returns
xBallsAdditionalArguments_

Definition at line 1339 of file DPMBase.cc.

References xBallsAdditionalArguments_.

Referenced by write().

1340 {
1342 }
std::string xBallsAdditionalArguments_
A string of additional arguments for xballs can be specified (see XBalls/xballs.txt). e.g. "-solidf -v0".
Definition: DPMBase.h:1335
int DPMBase::getXBallsColourMode ( ) const

Get the xballs colour mode (CMode).

Returns the integer value corresponding to the colour scheme used by the XBalls visualisation software. See also setXBallsColourMode and the Visualising data in xballs

Returns
int xBallsColourMode_ The integer value corresponding to the colour scheme used by the XBalls visualisation software.

Definition at line 1294 of file DPMBase.cc.

References xBallsColourMode_.

1295 {
1296  return xBallsColourMode_;
1297 }
int xBallsColourMode_
XBalls is a package to view the particle data. As an alternative MercuryDPM also supports ParaView...
Definition: DPMBase.h:1320
double DPMBase::getXBallsScale ( ) const

Returns the scale of the view in xballs.

Returns
double xBallsScale_ The scaling or "zoom" - corresponds tol the XBalls "-s" flag. Values > 1 mean a "zoomed out" view, values < 1 give a "zoomed in" view.

Definition at line 1356 of file DPMBase.cc.

References xBallsScale_.

1357 {
1358  return xBallsScale_;
1359 }
Mdouble xBallsScale_
sets the xballs argument scale (see XBalls/xballs.txt)
Definition: DPMBase.h:1330
double DPMBase::getXBallsVectorScale ( ) const

Returns the scale of vectors used in xballs.

Returns the length of the vectors which represent particle velocities in XBalls visualisations (see also setXBallsVectorScale and the Visualising data in xballs).

Returns
double xBallsVectorScale_ The value of the vector length used in XBalls visualisations. A value of 100 sets the length to 1 particle radius, 1000 sets it to 10 particle radii etc.

Definition at line 1314 of file DPMBase.cc.

References xBallsVectorScale_.

1315 {
1316  return xBallsVectorScale_;
1317 }
Mdouble xBallsVectorScale_
sets the xballs argument vscale (see XBalls/xballs.txt)
Definition: DPMBase.h:1325
void DPMBase::handleParticleAddition ( unsigned int  id,
BaseParticle p 
)
virtual

the addition of particles to the particleHandler

This function is called by ParticleHandler::addObject and ParticleHandler::addGhostObject to broadcast the addition of a particle from the handler. It passes the information on to the walls in the wallHandler.

Parameters
[in]idThe id of the removed particle.
[in]pA pointer to the particle.

Definition at line 5264 of file DPMBase.cc.

References wallHandler.

Referenced by ParticleHandler::addGhostObject(), and ParticleHandler::addObject().

5265 {
5266  for (auto w: wallHandler)
5267  {
5268  w->handleParticleAddition(id, p);
5269  }
5270 }
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1386
void DPMBase::handleParticleRemoval ( unsigned int  id)
virtual

Handles the removal of particles from the particleHandler.

This function is called by ParticleHandler::removeObject and ParticleHandler::removeGhostObject to broadcast the removal of a particle from the handler. It passes the information on to the walls in the wallHandler.

Parameters
[in]idThe id of the removed particle.

Definition at line 5249 of file DPMBase.cc.

References wallHandler.

Referenced by ParticleHandler::removeGhostObject(), and ParticleHandler::removeObject().

5250 {
5251  for (auto w: wallHandler)
5252  {
5253  w->handleParticleRemoval(id);
5254  }
5255 }
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1386
void DPMBase::hGridActionsAfterIntegration ( )
protectedvirtual

This function has to be called after integrateBeforeForceComputation.

no implementation but can be overidden in its derived classes.

Reimplemented in MercuryBase.

Definition at line 1931 of file DPMBase.cc.

Referenced by computeOneTimeStep().

1932 {
1933 }
void DPMBase::hGridActionsBeforeIntegration ( )
protectedvirtual

This function has to be called before integrateBeforeForceComputation.

no implementation but can be overidden in its derived classes.

Reimplemented in MercuryBase.

Definition at line 1924 of file DPMBase.cc.

Referenced by computeOneTimeStep().

1925 {
1926 }
void DPMBase::hGridActionsBeforeTimeLoop ( )
protectedvirtual

A virtual function that allows one to carry out hGrid operations before the start of the time loop.

no implementation but can be overidden in its derived classes.

Reimplemented in MercuryBase.

Definition at line 1660 of file DPMBase.cc.

Referenced by solve().

1661 {
1662 }
void DPMBase::hGridActionsBeforeTimeStep ( )
protectedvirtual

A virtual function that allows one to set or execute hGrid parameters or operations before every simulation time step.

no implementation but can be overidden in its derived classes.

Reimplemented in MercuryBase.

Definition at line 1674 of file DPMBase.cc.

Referenced by computeOneTimeStep(), and solve().

1675 {
1676 }
virtual void DPMBase::hGridGetInteractingParticleList ( BaseParticle obj,
std::vector< BaseParticle * > &  list 
)
inlinevirtual

Creates a list of neighbour particles obtained from the hgrid.

Reimplemented in Mercury3D, and Mercury2D.

Definition at line 959 of file DPMBase.h.

Referenced by PeriodicBoundaryHandler::processLocalInteractionData(), PeriodicBoundaryHandler::processReceivedInteractionData(), and Domain::processReceivedInteractionData().

960  {};
void DPMBase::hGridInsertParticle ( BaseParticle *obj  UNUSED)
virtual
Bug:
Why are the hGRID actions public, this seems wrong. Someone please comment [Ant].

no implementation but can be overidden in its derived classes.

Definition at line 1681 of file DPMBase.cc.

Referenced by ParticleHandler::addExistingObject(), ParticleHandler::addGhostObject(), and ParticleHandler::addObject().

1682 {
1683 }
void DPMBase::hGridRemoveParticle ( BaseParticle *obj  UNUSED)
virtual

no implementation but can be overidden in its derived classes.

Definition at line 1695 of file DPMBase.cc.

Referenced by ParticleHandler::removeGhostObject(), ParticleHandler::removeLastObject(), and ParticleHandler::removeObject().

1696 {
1697 }
void DPMBase::hGridUpdateMove ( BaseParticle ,
Mdouble   
)
virtual

no implementation but can be overidden in its derived classes.

Reimplemented in MercuryBase.

Definition at line 1917 of file DPMBase.cc.

Referenced by PeriodicBoundary::checkBoundaryAfterParticlesMove(), BaseParticle::integrateBeforeForceComputation(), Domain::updateParticlePosition(), and PeriodicBoundaryHandler::updateParticles().

1918 {
1919 }
void DPMBase::hGridUpdateParticle ( BaseParticle *obj  UNUSED)
virtual

no implementation but can be overidden in its derived classes.

Definition at line 1688 of file DPMBase.cc.

Referenced by ParticleHandler::addExistingObject(), ParticleHandler::addGhostObject(), ParticleHandler::addObject(), MercuryBase::hGridActionsBeforeTimeStep(), and MercuryBase::hGridRebuild().

1689 {
1690 }
void DPMBase::importParticlesAs ( ParticleHandler particleH,
InteractionHandler interactionH,
const ParticleSpecies species 
)

Copies particles, interactions assigning species from a local simulation to a global one. Useful for the creation of a cluster.

Copies particles, interactions assigning species from a local simulation to a global one; useful for the creation of a cluster.

Parameters
[in]particleHthe particle handler from wich particles are copied,
[in]particleHthe interaction handler from wich interactions are copied,
[in]speciesthe species that will be assigned to the particle.

Definition at line 4780 of file DPMBase.cc.

References BaseHandler< T >::begin(), BaseHandler< T >::copyAndAddObject(), BaseHandler< T >::end(), getNumberOfTimeSteps(), BaseHandler< T >::getObject(), BaseHandler< T >::getSize(), constants::i, interactionHandler, and particleHandler.

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

4781 {
4782  size_t nParticlesPreviouslyIn = particleHandler.getSize();
4783  int l = 0;
4784  for (auto k = particleH.begin(); k != particleH.end(); ++k) {
4785  auto p = particleHandler.copyAndAddObject( *k );
4786  p->setSpecies(species);
4787  l++;
4788  }
4789 
4790  for (std::vector<BaseInteraction*>::const_iterator i = interactionH.begin(); i != interactionH.end(); ++i) {
4791  if ( (*i)->getP()->getInvMass() != 0.0 && (*i)->getI()->getInvMass() != 0.0 ) {
4793  j->importP(particleHandler.getObject(nParticlesPreviouslyIn + j->getP()->getIndex()));
4794  j->importI(particleHandler.getObject(nParticlesPreviouslyIn + j->getI()->getIndex()));
4795  j->setTimeStamp(getNumberOfTimeSteps());
4796  }
4797  }
4798 }
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
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
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:690
unsigned int getNumberOfTimeSteps() const
Returns the current counter of time-steps, i.e. the number of time-steps that the simulation has unde...
Definition: DPMBase.cc:814
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
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
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1406
void DPMBase::incrementRunNumberInFile ( )
static

Increment the run Number (counter value) stored in the file_counter (COUNTER_DONOTDEL) by 1 and store the new value in the counter file.

In order to increment the counter stored in COUNTER_DONOTDEL, we initialise two fstream objects counter_file, counter_file2 and an integer type temp_counter. First we open the file COUNTER_DONOTDEL, check if everything went fine with the opening. If yes, we extract the runNumber (counter) into the temp_counter. Increment the temp_counter and then write it into COUNTER_DONOTDEL. This is how we increment the counter in the file.

Definition at line 618 of file DPMBase.cc.

Referenced by autoNumber().

619 {
620  //opening two filestreams - counter_file and counter_file2
621  std::fstream counter_file, counter_file2;
622  //declares an integer, temp_counter
623  int temp_counter;
624  //attempts to open the COUNTER_DONOTDEL text file
625  counter_file.open("COUNTER_DONOTDEL", std::ios::in);
626  //gives error message if file could not be successfully opened and ends the program
627  if (counter_file.fail())
628  {
629  fprintf(stderr, "\n\n\tERROR :: Counter File NOT found, please re-create\n\n");
630  counter_file.close();
631  exit(0);
632  }
633  // if opened successfully, reads in the counter corresponding to the current run number
634  //and stored it in the "temp_counter" variable
635  counter_file >> temp_counter;
636  counter_file.close();
637  //Increments the temp_counter
638  temp_counter++;
639  //opens an output stream to the COUNTER_DONOTDEL file
640  counter_file2.open("COUNTER_DONOTDEL", std::ios::out);
641  if (counter_file2.fail())
642  {
643  fprintf(stderr, "\n\n\tERROR :: Counter File NOT found, please re-create2\n\n");
644  counter_file2.close();
645  exit(0);
646  }
647  //writes the new valuer of the counter to COUNTER_DONOTDEL
648  counter_file2 << temp_counter;
649 
650  counter_file2.close();
651 }
void DPMBase::initialiseStatistics ( )
protectedvirtual

This function is overridden by StatisticsVector

Reimplemented in StatisticsVector< T >.

Definition at line 1869 of file DPMBase.cc.

References cgHandler, and CGHandler::initialise().

Referenced by solve().

1870 {
1872 }
void initialise()
Contains the code executed before the first time step.
Definition: CGHandler.cc:90
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1412
void DPMBase::insertGhostParticle ( BaseParticle particle)

This function inserts a particle in the mpi communication boundaries.

Parameters
[in]particlePointer to a base particle that needs to be inserted in the communication boundaries

Definition at line 1795 of file DPMBase.cc.

References PeriodicBoundaryHandler::addNewParticle(), Domain::addParticle(), domainHandler, DomainHandler::getCurrentDomain(), BaseHandler< T >::getSize(), and periodicBoundaryHandler.

Referenced by ParticleHandler::addObject().

1796 {
1797 #ifdef MERCURY_USE_MPI
1798  //mpi particles only exist when there is more than one domain
1799  if (domainHandler.getSize() > 0)
1800  {
1801  //Add the particle to the mpi domain
1803  }
1804 
1805  //If periodic boundaries are present..
1806  if (periodicBoundaryHandler.getSize() > 0)
1807  {
1809  }
1810 #endif
1811 }
void addNewParticle(BaseParticle *particle)
Adds a new particle to the periodic list.
void addParticle(BaseParticle *particle)
Initialises a single particle which is added during the simulation.
Definition: Domain.cc:1610
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1401
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1396
Domain * getCurrentDomain()
Gets the domain assigned to the processor.
void DPMBase::integrateAfterForceComputation ( )
protectedvirtual

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

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

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

Definition at line 3212 of file DPMBase.cc.

References BaseHandler< T >::getObject(), BaseHandler< T >::getSize(), getTime(), getTimeStep(), BaseInteractable::integrateAfterForceComputation(), BaseParticle::integrateAfterForceComputation(), BaseParticle::isMPIParticle(), BaseParticle::isPeriodicGhostParticle(), particleHandler, and wallHandler.

Referenced by computeOneTimeStep().

3213 {
3214  //cycling through all particles, p, in the particleHandler
3215  //for_each(particleHandler.begin(), particleHandler.end(), [this](BaseParticle* p){
3216  #pragma omp parallel for num_threads(getNumberOfOMPThreads()) //schedule(dynamic)
3217  for (int k = 0; k < particleHandler.getSize(); ++k) {
3219 #ifdef MERCURY_USE_MPI
3220  //MPI particles do not require integration - they are updated by the communication step
3221  if (!(p->isMPIParticle() || p->isPeriodicGhostParticle()))
3222  {
3224  }
3225 #else
3226  //using the particle p's internal "integrateAfterForceComputation" function
3227  //to update the relevant parameters concerning the particle's position and motion
3229 #endif
3230  }
3231  //});
3232  //cycling through all walls, w, in the wallHandler
3233  //for_each(wallHandler.begin(), wallHandler.end(), [this](BaseWall* w){
3234  #pragma omp parallel for num_threads(getNumberOfOMPThreads()) //schedule(dynamic)
3235  for (int k = 0; k < wallHandler.getSize(); k++) {
3236  BaseWall *w = wallHandler.getObject(k);
3237  //using the wall's internal "integrateAfterForceComputation" function
3238  //to update the relevant parameters concerning its position and motion
3240  }
3241  //});
3242 }
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
Basic class for walls.
Definition: BaseWall.h:47
bool isPeriodicGhostParticle() const
Indicates if this particle is a ghost in the periodic boundary.
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1386
bool isMPIParticle() const
Indicates if this particle is a ghost in the MPI domain.
void integrateAfterForceComputation(double time, double timeStep)
Second step of Velocity Verlet integration.
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1234
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:798
void integrateAfterForceComputation(double time, double timeStep)
This is part of the integration routine for objects with infinite mass.
void DPMBase::integrateBeforeForceComputation ( )
protectedvirtual

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

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

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

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

Definition at line 3126 of file DPMBase.cc.

References BaseHandler< T >::getObject(), BaseHandler< T >::getSize(), getTime(), getTimeStep(), BaseInteractable::integrateBeforeForceComputation(), BaseParticle::integrateBeforeForceComputation(), BaseParticle::isMPIParticle(), BaseParticle::isPeriodicGhostParticle(), particleHandler, and wallHandler.

Referenced by computeOneTimeStep().

3127 {
3128  //cycling through all particles, p, in the particleHandler
3129  //for_each(particleHandler.begin(), particleHandler.end(), [this](BaseParticle* p)
3130  //for (BaseParticle* p : particleHandler) {
3131 
3132  #pragma omp parallel for num_threads(getNumberOfOMPThreads()) //schedule(dynamic)
3133  for (int k = 0; k < particleHandler.getSize(); ++k) {
3135 #ifdef MERCURY_USE_MPI
3136  //MPI particles are not integrated, they are purely ghost particles and get their new velocity and position from an MPI update
3137  if (!(p->isMPIParticle() || p->isPeriodicGhostParticle()))
3138  {
3140  }
3141 #else
3142  //using the particle p's internal "integrateBeforeForceComputation" function
3143  //to update the relevant parameters concerning the particle's position and motion
3145 #endif
3146  }
3147  //});
3148  //cycling through all walls, w, in the wallHandler
3149  //for_each(wallHandler.begin(), wallHandler.end(), [this](BaseWall* w)
3150  //for (BaseWall* w : wallHandler) {
3151  #pragma omp parallel for num_threads(getNumberOfOMPThreads()) //schedule(dynamic)
3152  for (int k = 0; k < wallHandler.getSize(); k++) {
3153  BaseWall *w = wallHandler.getObject(k);
3154  //using the wall's internal "integrateBeforeForceComputation" function
3155  //to update the relevant parameters concerning its position and motion
3157  }
3158  //});
3159 }
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
void integrateBeforeForceComputation(double time, double timeStep)
This is part of integrate routine for objects with infinite mass.
void integrateBeforeForceComputation(double time, double timeStep)
First step of Velocity Verlet integration.
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
Basic class for walls.
Definition: BaseWall.h:47
bool isPeriodicGhostParticle() const
Indicates if this particle is a ghost in the periodic boundary.
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1386
bool isMPIParticle() const
Indicates if this particle is a ghost in the MPI domain.
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1234
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:798
bool DPMBase::isTimeEqualTo ( Mdouble  time) const
protected

Checks whether the input variable "time" is the current time in the simulation.

Returns true if and only if the "time" argument passed to the function is equal to the current simulation time i.e. if "time" is either exactly equal to the current simulation time (getTime() ) or at least lies between this time step and the next increment (this nicely avoids rounding errors!)

Returns
true if "time" and getTime() are equal, otherwise false.

Definition at line 4990 of file DPMBase.cc.

References getTime(), and getTimeStep().

4991 {
4992  return getTime() <= time && getTime() + getTimeStep() > time;
4993 }
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1234
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:798
int DPMBase::launchNewRun ( const char *  name,
bool quick  UNUSED = false 
)

This launches a code from within this code. Please pass the name of the code to run.

Reads in the name of the command (code) to be launched. This name is then converted to a string stream and appended with " &" (such that command is run in the background), before being converted back to a C string and then fed to the system() command which will execute the named code from within the running Mercury program.

Parameters
[in]nameThe name of the code to be launched
[in]quick
Returns
int

Definition at line 765 of file DPMBase.cc.

766 {
767  //defines an (empty) stringstream named "com"
768  std::stringstream com("");
769  //adds the name of the code to run (fed in as an argument)
770  //to the "com" string and appends the string with " &"
771  com << name << " &";
772  //converts the stringstream "com" to a standard string, and then
773  //converts this string to a C string
774  //the string is then fed to the "system" function, which will run the named command
775  return system(com.str().c_str());
776 }
bool DPMBase::mpiInsertParticleCheck ( BaseParticle P)

Function that checks if the mpi particle should really be inserted by the current domain.

When adding a particle, all domains "add" the particle to enable communication between processors However not very domain should add the particle, only the domain that actually contains the particle There is one exception, if an MPI Particle is added (which is not physically in the current domain), this has already been approved by the domain and hence it should return true.

Parameters
[in]PPointer to a baseParticle that requires an insertion check
Returns
Returns if the baseParticle should be inserted or not

Definition at line 1716 of file DPMBase.cc.

References Domain::containsParticle(), domainHandler, DomainHandler::getCurrentDomain(), BaseHandler< T >::getSize(), and BaseParticle::isMPIParticle().

Referenced by ParticleHandler::addObject().

1717 {
1718 #ifdef MERCURY_USE_MPI
1719  //If only one core is used (i.e. domainHandler is empty) then the result is always true
1720  if (domainHandler.getSize() == 0)
1721  {
1722  return true;
1723  }
1724  //Get the current domain
1726 
1727  //Check if the particle is in the current domain
1728  if(domain->containsParticle(P))
1729  {
1730  //When adding a particle inside the domain, this should always be true
1731  return true;
1732  }
1733  else
1734  {
1735  //MPI particles that are inserted in the communication zone should still be inserted
1736  return (P->isMPIParticle());
1737  }
1738 #else
1739  return false;
1740 #endif
1741 }
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
bool containsParticle(BaseParticle *particle, Mdouble offset=0.0)
Check to see if a given particle is within the current domain.
Definition: Domain.cc:400
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1401
The simulation can be subdivided into Domain's used in parallel code.
Definition: Domain.h:63
Domain * getCurrentDomain()
Gets the domain assigned to the processor.
bool isMPIParticle() const
Indicates if this particle is a ghost in the MPI domain.
bool DPMBase::mpiIsInCommunicationZone ( BaseParticle particle)

Checks if the position of the particle is in an mpi communication zone or not.

Parameters
[in]particlePointer to a base particle
Returns
Returns if the particle is in the communication zone (true) or not (false)

Definition at line 1748 of file DPMBase.cc.

References MPIContainer::broadcast(), domainHandler, MPIContainer::gather(), DomainHandler::getCurrentDomain(), constants::i, MPIContainer::Instance(), Domain::isInCommunicationZone(), NUMBER_OF_PROCESSORS, and PROCESSOR_ID.

1749 {
1750 
1751  bool insideCommunicationZone = false;
1752 #ifdef MERCURY_USE_MPI
1753  MPIContainer& communicator = MPIContainer::Instance();
1754 
1755  //Check for the current domain if the particle is within the communication domain
1756  int val = domainHandler.getCurrentDomain()->isInCommunicationZone(particle);
1757 
1758  //The root gathers all results
1759  int *list = nullptr;
1760  if (PROCESSOR_ID == 0)
1761  {
1762  list = new int [NUMBER_OF_PROCESSORS];
1763  }
1764  communicator.gather(val,list);
1765 
1766  //Compute the global value
1767  //if on any processor the val is true, we have to do the communcation step
1769  int result = 0;
1770  if (PROCESSOR_ID == 0)
1771  {
1772  for (int i = 0; i< NUMBER_OF_PROCESSORS; i++)
1773  {
1774  if (list[i] == 1)
1775  {
1776  result = 1;
1777  break;
1778  }
1779  }
1780  }
1781 
1782  //The root now tells the other processors what the global value for the interaction is
1783  communicator.broadcast(result);
1784 
1785  //Convert the result back to bool
1786  insideCommunicationZone = result;
1787 #endif
1788  return insideCommunicationZone;
1789 }
This class contains all information and functions required for communication between processors...
Definition: MpiContainer.h:129
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:134
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1401
void gather(T &send_t, T *receive_t)
Gathers a scaler from all processors to a vector of scalars on the root.
Definition: MpiContainer.h:428
#define PROCESSOR_ID
Definition: GeneralDefine.h:63
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:62
std::enable_if< std::is_scalar< T >::value, void >::type broadcast(T &t, int fromProcessor=0)
Broadcasts a scalar from the root to all other processors.
Definition: MpiContainer.h:441
bool isInCommunicationZone(BaseParticle *particle)
Check if the particle is in the communication zone of the current domain.
Definition: Domain.cc:441
Domain * getCurrentDomain()
Gets the domain assigned to the processor.
void DPMBase::outputInteractionDetails ( ) const
protected

Displays the interaction details corresponding to the pointer objects in the interaction handler.

Skims through all the object pointers of type BaseInteraction in the interaction handler. Outputs the type of interaction between two particles P and I.

Definition at line 4970 of file DPMBase.cc.

References INFO, interactionHandler, logger, and NO_FLUSH.

4971 {
4972  logger(INFO, "Interactions currently in the handler:\n", Flusher::NO_FLUSH);
4973  //looping over all individual objects in the interactionHandler
4975  {
4976  p->write(std::cout);
4977  logger(INFO, "\nInteraction % % between % and %",
4978  p->getName(), p->getId(), p->getP()->getId(), p->getI()->getId());
4979  }
4980 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
Stores information about interactions between two interactable objects; often particles but could be ...
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1406
void DPMBase::outputStatistics ( )
protectedvirtual

This function is overridden by StatisticsVector

Reimplemented in StatisticsVector< T >.

Definition at line 1877 of file DPMBase.cc.

1878 {
1879  //cgHandler.evaluate();
1880 }
void DPMBase::outputXBallsData ( std::ostream &  os) const
protectedvirtual

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.

Parameters
[in]os

Definition at line 2261 of file DPMBase.cc.

References DEBUG, ERROR, ParticleHandler::getNumberOfRealObjectsLocal(), BaseHandler< T >::getObject(), BaseHandler< T >::getSize(), getSystemDimensions(), getTime(), getXMax(), getXMin(), getYMax(), getYMin(), getZMax(), getZMin(), constants::i, BaseParticle::isMPIParticle(), BaseParticle::isPeriodicGhostParticle(), logger, outputXBallsDataParticle(), and particleHandler.

Referenced by writeDataFile().

2262 {
2263 
2264 
2265  //Set the correct formation based of dimension if the formation is not specified by the user
2266 
2267  unsigned int format;
2268  switch (getSystemDimensions())
2269  {
2270  case 2:
2271  format = 8;
2272  break;
2273  case 3:
2274  format = 14;
2275  break;
2276  default:
2277  logger(ERROR, "Unknown system dimension");
2278  }
2279 
2280  unsigned int numberOfParticles = particleHandler.getNumberOfRealObjectsLocal();
2281 
2282  // This outputs the location of walls and how many particles there are to file this is required by the xballs plotting
2283  if (format != 14) // dim = 1 or 2
2284  {
2285  os << numberOfParticles
2286  << " " << getTime()
2287  << " " << getXMin()
2288  << " " << getYMin()
2289  << " " << getXMax()
2290  << " " << getYMax()
2291  << " " << std::endl;
2292  }
2293  else
2294  {
2295  //dim==3
2296  os << numberOfParticles
2297  << " " << getTime()
2298  << " " << getXMin()
2299  << " " << getYMin()
2300  << " " << getZMin()
2301  << " " << getXMax()
2302  << " " << getYMax()
2303  << " " << getZMax()
2304  << " " << std::endl;
2305  }
2306 
2307  // This outputs the particle data
2308  for (unsigned int i = 0; i < particleHandler.getSize(); i++)
2309  {
2310 #ifdef MERCURY_USE_MPI
2312  {
2313  outputXBallsDataParticle(i, format, os);
2314  }
2315 #else
2316  outputXBallsDataParticle(i, format, os);
2317 #endif
2318  }
2319 #ifdef DEBUG_OUTPUT
2320  logger(DEBUG, "Have output the properties of the problem to disk ");
2321 #endif
2322 }
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
unsigned int getSystemDimensions() const
Returns the system dimensionality.
Definition: DPMBase.cc:1414
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.h:629
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.h:598
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.h:611
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 ...
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.h:605
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1376
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
unsigned int getNumberOfRealObjectsLocal() const
Returns the number of real objects on a local domain. MPI particles and periodic particles are neglec...
bool isPeriodicGhostParticle() const
Indicates if this particle is a ghost in the periodic boundary.
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.h:617
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.h:623
bool isMPIParticle() const
Indicates if this particle is a ghost in the MPI domain.
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:798
virtual void DPMBase::outputXBallsDataParticle ( unsigned int  i,
unsigned int  format,
std::ostream &  os 
) const
protectedvirtual

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.

Referenced by outputXBallsData().

void DPMBase::performGhostParticleUpdate ( )
protected

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.

Todo:
MX: Under construction

Definition at line 4891 of file DPMBase.cc.

References PeriodicBoundaryHandler::addNewParticles(), DomainHandler::addNewParticles(), deleteGhostParticles(), domainHandler, NUMBER_OF_PROCESSORS, periodicBoundaryHandler, PeriodicBoundaryHandler::updateStatus(), and DomainHandler::updateStatus().

Referenced by computeOneTimeStep().

4892 {
4893 #ifdef MERCURY_USE_MPI
4894  //MPIContainer& communicator = MPIContainer::Instance();
4895  if (NUMBER_OF_PROCESSORS == 1) {return;}
4896 
4897  //Update the postion and velocity data of ghosts and perform some bookkeeping
4898  std::set<BaseParticle*> particlesToBeDeleted;
4899  domainHandler.updateStatus(particlesToBeDeleted);
4900  periodicBoundaryHandler.updateStatus(particlesToBeDeleted);
4901 
4902  //Delete particles
4903  deleteGhostParticles(particlesToBeDeleted);
4904 
4905  //Add new particles
4908 #endif
4909 }
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1401
void addNewParticles()
void updateStatus(std::set< BaseParticle * > &ghostParticlesToBeDeleted)
Updates the positions/velocity of ghost particles and accordingly the status of these particles...
void addNewParticles()
Adds new particles to the periodic particle lists.
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1396
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:62
void updateStatus(std::set< BaseParticle * > &particlesToBeDeleted)
void deleteGhostParticles(std::set< BaseParticle * > &particlesToBeDeleted)
Definition: DPMBase.cc:4914
void DPMBase::performGhostVelocityUpdate ( )
protected

updates the final time-step velocity of the ghost particles

Definition at line 4956 of file DPMBase.cc.

References NUMBER_OF_PROCESSORS.

4957 {
4958 #ifdef MERCURY_USE_MPI
4959  if (NUMBER_OF_PROCESSORS == 1) {return;}
4960  //TODO If required, I can implement this for periodic particles, first discuss with Thomas if it is actually requiredf
4961  //periodicDomainHandler.updateVelocity()
4962  //domainHandler.updateVelocity();
4963 #endif
4964 }
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:62
void DPMBase::printTime ( ) const
protectedvirtual

Displays the current simulation time and the maximum simulation duration.

Gets and prints the current simulation time (getTime()) and the currently set maximum simulation time (getTimeMax()) .

Reimplemented in BaseCluster, and Chute.

Definition at line 1954 of file DPMBase.cc.

References MPIContainer::getProcessorID(), getTime(), getTimeMax(), INFO, MPIContainer::Instance(), and logger.

Referenced by Mercury3DRestart::readNextArgument(), and writeOutputFiles().

1955 {
1956 #ifdef MERCURY_USE_MPI
1957  MPIContainer& communicator = MPIContainer::Instance();
1958  if (communicator.getProcessorID() == 0)
1959  {
1960 #endif
1961  logger(INFO, "t=%3.6, tmax=%3.6", getTime(), getTimeMax());
1962 #ifdef MERCURY_USE_MPI
1963  }
1964 #endif
1965 }
This class contains all information and functions required for communication between processors...
Definition: MpiContainer.h:129
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:134
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
std::size_t getProcessorID()
Reduces a scalar on all processors to one scalar on a target processor.
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:798
Mdouble getTimeMax() const
Returns the maximum simulation duration.
Definition: DPMBase.cc:878
void DPMBase::processStatistics ( bool  )
protectedvirtual

This function is overridden by StatisticsVector

Reimplemented in StatisticsVector< T >.

Definition at line 1902 of file DPMBase.cc.

1903 {
1904 }
void DPMBase::read ( std::istream &  is,
ReadOptions  opt = ReadOptions::ReadAll 
)
virtual

Reads all data from a restart file, e.g. domain data and particle data.

Todo:
warning: hides non-virtual function from the class 'Files'.

Reads in an existing .restart file line-by-line and passes all relevant parameters to the current instance of DPMBase. The data stream corresponding to the desired input file is passed as an argument.

Parameters
[in]isThe data stream from which the particle data will be read.

: Bound checking

: Same order as other file format, please?

todo{Do we want to calculate the mass?}

Reimplemented in BaseCluster, ChuteWithHopper, MercuryBase, and Chute.

Definition at line 3523 of file DPMBase.cc.

References PeriodicBoundaryHandler::addNewParticles(), DomainHandler::addNewParticles(), boundaryHandler, boundaryVTKWriter_, BaseHandler< T >::clear(), ParticleHandler::clear(), helpers::compare(), dataFile, decompose(), domainHandler, eneFile, ERROR, FATAL, fStatFile, ParticleHandler::getLargestInteractionRadius(), helpers::getLineFromStringStream(), File::getName(), gravity_, constants::i, INFO, interactionFile, interactionHandler, interactionVTKWriter_, logger, max_, min_, name_, NO_FILE, NUMBER_OF_PROCESSORS, numberOfDomains_, numberOfTimeSteps_, particleDimensions_, particleHandler, periodicBoundaryHandler, random, RNG::read(), InteractionHandler::read(), BaseHandler< T >::read(), BoundaryHandler::readAndAddObject(), WallHandler::readAndAddObject(), ParticleHandler::readAndAddObject(), ReadNoInteractions, ReadNoParticlesAndInteractions, readOld(), restartFile, restartVersion_, runNumber_, BaseVTKWriter< H >::setFileCounter(), PeriodicBoundaryHandler::setInteractionDistance(), DomainHandler::setInteractionDistance(), File::setName(), setName(), setNumberOfOMPThreads(), setParticlesWriteVTK(), BaseHandler< T >::setStorageCapacity(), setWallsWriteVTK(), BoundaryHandler::setWriteVTK(), InteractionHandler::setWriteVTK(), setXBallsAdditionalArguments(), speciesHandler, statFile, systemDimensions_, time_, timeMax_, timeStep_, vtkWriter_, wallHandler, wallVTKWriter_, writeParticlesVTK_, writeWallsVTK_, Vec3D::x(), XAXIS, Vec3D::y(), YAXIS, Vec3D::z(), and ZAXIS.

Referenced by MercuryBase::read(), readRestartFile(), and readSpeciesFromDataFile().

3524 {
3525 #ifdef MERCURY_USE_MPI
3526  int previousNumberOfProcessors;
3527 #endif
3528  //Declares...
3529  std::string dummy;
3530  //...and reads in a dummy variable from the start of the stream "is"
3531  is >> dummy;
3532  //compare the string read in to the phrase "restart_version" to see if the stream corresponds
3533  //to a restart file (all restart files begin with this phrase)
3534  //if both strings match, strcmp(dummy.c_str(), "restart_version") returns 0 (here read as "false")
3535  if (dummy != "restart_version" && dummy != "MercuryDPM")
3536  {
3537  //If the strings do not match, if statement is fulfilled and the error logged
3538  //Note: only very old files did not have a restart_version
3539  logger(FATAL, "Error in DPMBase::read(is): this is not a valid restart file");
3540  }
3541  else
3542  {
3543  //reads in the restart version (earlier versions of Mercury possess different file formats!)
3544  is >> restartVersion_;
3545  //checking which version the current data file corresponds to, and reads the data in
3546  //accordingly
3547  if (restartVersion_ == "1.0" || restartVersion_ == "0.14")
3548  {
3549  //reads in and saves the relevant values from the data file to the current instance of DPMBase
3550  std::stringstream line;
3551 
3552  // Store path (if restart file is nonlocal)
3553  auto slash = restartFile.getName().rfind('/');
3554  std::string path;
3555  if (slash != std::string::npos)
3556  {
3557  path = restartFile.getName().substr(0, slash + 1);
3558  }
3559  if (!path.empty())
3560  {
3561  logger(INFO, "Adding path information (%) to file names", path);
3562  }
3563 
3564  //line 1
3566  //discards the whitespace (ws) at the start of the stream
3567  line >> std::ws;
3568  //uses the "peek" function to access the stream's first
3569  //non-whitespace character, and check if it is an "r"
3570  if (line.peek() == 'r')
3571  //if so, reads in the current run number
3572  line >> dummy >> runNumber_;
3573  //In either case, then uses the "Files" version of the read function
3574  //to read in the rest of the relevant information.
3575  line >> dummy >> name_;
3576  setName(name_);
3577 
3578  //Read line 2-7 (definition of i/o files)
3580  line >> dummy >> dataFile;
3582  line >> dummy >> fStatFile;
3584  line >> dummy >> eneFile;
3586  line >> dummy >> restartFile;
3588  line >> dummy >> statFile;
3589 
3590  // Add the file path from the restart file to the file names
3591  dataFile.setName(path + dataFile.getName());
3592  fStatFile.setName(path + fStatFile.getName());
3593  eneFile.setName(path + eneFile.getName());
3594  restartFile.setName(path + restartFile.getName());
3595  statFile.setName(path + statFile.getName());
3596 
3597  // Get current position
3598  //check if the next line starts with 'interactionFile'; otherwise, skip interaction
3599  if (helpers::compare(is, "interactionFile"))
3600  {
3602  line >> interactionFile;
3603  interactionFile.setName(path + interactionFile.getName());
3604  }
3605 
3607  line >> dummy >> min_.x()
3608  >> dummy >> max_.x()
3609  >> dummy >> min_.y()
3610  >> dummy >> max_.y()
3611  >> dummy >> min_.z()
3612  >> dummy >> max_.z();
3613 
3615  line >> dummy >> timeStep_
3616  >> dummy >> time_
3617  >> dummy >> numberOfTimeSteps_
3618  >> dummy >> timeMax_;
3619 
3621  line >> dummy >> systemDimensions_
3622  >> dummy >> particleDimensions_
3623  >> dummy >> gravity_;
3624 
3625  line >> dummy;
3626  if (!dummy.compare("writeVTK"))
3627  {
3628  FileType writeInteractionsVTK = FileType::NO_FILE;
3629  unsigned particlesCounter, wallCounter, interactionCounter;
3630  bool writeBoundaryVTK;
3631  line >> writeParticlesVTK_ >> writeWallsVTK_ >> writeInteractionsVTK >> writeBoundaryVTK >> particlesCounter >> wallCounter >> interactionCounter;
3632  line.clear();//because the number of arguments in writeVTK has changed
3633  line >> dummy;
3636  interactionHandler.setWriteVTK(writeInteractionsVTK);
3637  boundaryHandler.setWriteVTK(writeBoundaryVTK);
3638  vtkWriter_->setFileCounter(particlesCounter);
3639  wallVTKWriter_.setFileCounter(particlesCounter);
3640  interactionVTKWriter_.setFileCounter(particlesCounter);
3641  boundaryVTKWriter_.setFileCounter(particlesCounter);
3642  }
3643  if (!dummy.compare("random"))
3644  {
3645  random.read(line);
3646  line >> dummy;
3647  }
3648 
3649 #ifdef MERCURY_USE_OMP
3650  //Read the number of OMP threads
3651  if (!dummy.compare("numberOfOMPThreads")) {
3652  int numberOfOMPThreads;
3653  line >> numberOfOMPThreads;
3654  setNumberOfOMPThreads(numberOfOMPThreads);
3655  //logger(INFO," Check the number of OMP threads = % ", getNumberOfOMPThreads());
3656  }
3657 #endif
3658 #ifdef MERCURY_USE_MPI
3659  if (!dummy.compare("numberOfProcessors"))
3660  {
3661  line >> previousNumberOfProcessors
3662  >> dummy >> numberOfDomains_[Direction::XAXIS]
3665  }
3666  else
3667  {
3668  logger(INFO,"Reading a serial restart file");
3669  //numberOfDomains_ = {1,1,1};
3670  }
3671 #endif
3672  if (!dummy.compare("xBallsArguments")) {
3674  setXBallsAdditionalArguments(line.str());
3675  }
3676 
3677  speciesHandler.read(is);
3678 
3679 #ifdef MERCURY_USE_MPI
3680  //Initialise MPI structures and perform domain decomposition
3681  decompose();
3682 #endif
3683 
3684  //reading in the various relevant handlers
3685  unsigned int N;
3686  is >> dummy >> N;
3687  if (dummy.compare("Walls"))
3688  logger(ERROR, "DPMBase::read(is): Error during restart: 'Walls' argument could not be found.");
3689  wallHandler.clear();
3692  for (unsigned int i = 0; i < N; i++)
3693  {
3696  }
3697 
3698  is >> dummy >> N;
3701  if (dummy.compare("Boundaries"))
3702  logger(ERROR, "DPMBase::read(is): Error during restart: 'Boundaries' argument could not be found.");
3704  for (unsigned int i = 0; i < N; i++)
3705  {
3708  }
3709 
3711 
3712  is >> dummy >> N;
3713  is.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
3714  //display a message if a large amount o fparticles is read
3715  if (N>2.5e5) logger(INFO, "Reading % particles (may take a while)",N);
3716  logger.assert_always(dummy.compare("Particles")==0, "DPMBase::read(is): Error during restart: 'Particles' argument could not be found. %",dummy);
3719  for (unsigned int i = 0; i < N; i++)
3720  {
3721  //ParticleHandler::readAndCreateObject reads line-by-line
3723  //skip the remaining data in line
3724  is.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
3726  //particleHandler.getLastObject()->computeMass();
3727  }
3728 #ifdef MERCURY_USE_MPI
3729  //Interaction distances of the domainHandler and periodicBoundaryHandler need to be set
3730  Mdouble interactionRadius = particleHandler.getLargestInteractionRadius();
3731  domainHandler.setInteractionDistance(2.0*interactionRadius);
3732  periodicBoundaryHandler.setInteractionDistance(2.0*interactionRadius);
3733