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 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...
 
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...
 
void writePythonFileForVTKVisualisation () const
 record when the simulation started More...
 

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...
 

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 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...
 

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 72 of file DPMBase.h.

Member Enumeration Documentation

enum DPMBase::DomainSplit
strong
Enumerator
XY 
XZ 
YZ 
XYZ 

Definition at line 912 of file DPMBase.h.

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

Definition at line 240 of file DPMBase.h.

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

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 187 of file DPMBase.cc.

References constructor().

188 {
189  constructor();
190 }
void constructor()
A function which initialises the member variables to default values, so that the problem can be solve...
Definition: DPMBase.cc:200
WallVTKWriter wallVTKWriter_
Definition: DPMBase.h:1265
InteractionVTKWriter interactionVTKWriter_
Definition: DPMBase.h:1267
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1344
BoundaryVTKWriter boundaryVTKWriter_
Definition: DPMBase.h:1269
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1359
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1339
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 115 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_.

118 {
119  setName(other.getName());
120  runNumber_ = other.runNumber_;
123  gravity_ = other.gravity_;
124 /* xMin_ = other.xMin_;
125  xMax_ = other.xMax_;
126  yMin_ = other.yMin_;
127  yMax_ = other.yMax_;
128  zMin_ = other.zMin_;
129  zMax_ = other.zMax_;*/
130  min_ = other.min_;
131  max_ = other.max_;
133  time_ = other.time_;
134  timeStep_ = other.timeStep_;
136  timeMax_ = other.timeMax_;
137  restartVersion_ = other.restartVersion_; //to read new and old restart data
138  restarted_ = other.restarted_; //to see if it was restarted or not
139  append_ = other.append_;
140  rotation_ = other.rotation_;
141  xBallsColourMode_ = other.xBallsColourMode_; // sets the xballs argument cmode (see xballs.txt)
142  xBallsVectorScale_ = other.xBallsVectorScale_; // sets the xballs argument vscale (see xballs.txt)
143  xBallsScale_ = other.xBallsScale_; // sets the xballs argument scale (see xballs.txt)
144  xBallsAdditionalArguments_ = other.xBallsAdditionalArguments_; // std::string where additional xballs argument can be specified (see xballs.txt)
148 
149 //effectively saying "if there exists a CONTACT_LIST_HGRID, copy it, if not, ignore.
150 #ifdef CONTACT_LIST_HGRID
151  possibleContactList=other.possibleContactList;
152 #endif
153  random = other.random;
154 
159  wallHandler.setDPMBase(this);
162  //Initialise the handlers
165 
166  //setting contents equal to the other handlers!
169  cgHandler = other.cgHandler;
170  //cgHandler = other.cgHandler.copy(); //todo
171  //cgHandler.setDPMBase(this);
172  wallHandler = other.wallHandler;
175  vtkWriter_ = other.vtkWriter_;
180 }
Mdouble timeMax_
Stores the duration of the simulation.
Definition: DPMBase.h:1224
Vec3D max_
Definition: DPMBase.h:1204
unsigned int particleDimensions_
determines if 2D or 3D particle volume is used for mass calculations
Definition: DPMBase.h:1188
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:1312
WallVTKWriter wallVTKWriter_
Definition: DPMBase.h:1265
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:389
InteractionVTKWriter interactionVTKWriter_
Definition: DPMBase.h:1267
int runNumber_
This stores the run number for saving.
Definition: DPMBase.h:1297
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1354
std::vector< unsigned > numberOfDomains_
Vector containing the number of domains in x-,y- and z-direction, required for parallel computations...
Definition: DPMBase.h:1198
bool rotation_
A flag to turn on/off particle rotation. true will enable particle rotation. false will disable parti...
Definition: DPMBase.h:1249
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1214
bool restarted_
A bool to check if the simulation was restarted or not, ie. if setupInitialConditionsShould be run an...
Definition: DPMBase.h:1236
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:1183
bool writeSuperquadricParticlesVTK_
Definition: DPMBase.h:1261
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1365
int xBallsColourMode_
XBalls is a package to view the particle data. As an alternative MercuryDPM also supports ParaView...
Definition: DPMBase.h:1277
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1344
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1349
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1263
BoundaryVTKWriter boundaryVTKWriter_
Definition: DPMBase.h:1269
Mdouble xBallsScale_
sets the xballs argument scale (see XBalls/xballs.txt)
Definition: DPMBase.h:1287
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
Mdouble time_
Stores the current simulation time.
Definition: DPMBase.h:1209
int numberOfOMPThreads_
Definition: DPMBase.h:1178
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1319
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1359
FileType writeWallsVTK_
A flag to turn on/off the vtk writer for walls.
Definition: DPMBase.h:1254
Mdouble xBallsVectorScale_
sets the xballs argument vscale (see XBalls/xballs.txt)
Definition: DPMBase.h:1282
Mdouble timeStep_
Stores the simulation time step.
Definition: DPMBase.h:1219
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1339
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:1324
bool writeParticlesVTK_
A flag to turn on/off the vtk writer for particles.
Definition: DPMBase.h:1259
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:412
std::string xBallsAdditionalArguments_
A string of additional arguments for xballs can be specified (see XBalls/xballs.txt). e.g. "-solidf -v0".
Definition: DPMBase.h:1292
std::string restartVersion_
Previous versions of MercuryDPM had a different restart file format, the below member variable allows...
Definition: DPMBase.h:1231
Vec3D min_
These vectors are used for the XBalls domain, and occasionally people use it to add walls...
Definition: DPMBase.h:1203
Vec3D gravity_
Gravity vector.
Definition: DPMBase.h:1193
bool append_
A flag to determine if the file has to be appended or not. See DPMBase::Solve() for example...
Definition: DPMBase.h:1242
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 287 of file DPMBase.cc.

References vtkWriter_.

288 {
289  delete vtkWriter_;
290 }
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1263

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 1831 of file DPMBase.cc.

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

1832 {
1833 }
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 1838 of file DPMBase.cc.

Referenced by computeOneTimeStep().

1839 {
1840 }
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 1629 of file DPMBase.cc.

Referenced by solve().

1630 {
1631 }
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 1824 of file DPMBase.cc.

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

1825 {
1826 }
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 1643 of file DPMBase.cc.

Referenced by solve().

1644 {
1645 }
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 1621 of file DPMBase.cc.

References BaseParticle::isInContactWith().

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

1622 {
1623  return (pI != pJ && pI->isInContactWith(pJ));
1624 }
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 528 of file DPMBase.cc.

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

Referenced by readNextArgument().

529 {
531 
532  if (!getRestarted())
533  {
535  }
536 }
static void incrementRunNumberInFile()
Increment the run Number (counter value) stored in the file_counter (COUNTER_DONOTDEL) by 1 and store...
Definition: DPMBase.cc:617
bool getRestarted() const
Returns the flag denoting if the simulation was restarted or not.
Definition: DPMBase.cc:1453
static int readRunNumberFromFile()
Read the run number or the counter from the counter file (COUNTER_DONOTDEL)
Definition: DPMBase.cc:542
void setRunNumber(int runNumber)
This sets the counter/Run number, overriding the defaults.
Definition: DPMBase.cc:595
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 4814 of file DPMBase.cc.

References boundaryHandler, and particleHandler.

Referenced by computeOneTimeStep(), and solve().

4815 {
4816  //Looping over all boundaries in the boundaryHandler
4817  for (BaseBoundary* boundary : boundaryHandler)
4818  {
4819  //Calls the createPeriodicParticles() function which checks if a particle is adequately
4820  //close to a periodic particle that a periodic (ghost) particle should be created and,
4821  //if so, creates one and adds it to the system (hence the necessity to keep "N" variable).
4822  //
4823  // (The loop is over all boundaries, but if a boundary is not a PeriodicBoundary, then
4824  // this does nothing.)
4825  boundary->createPeriodicParticles(particleHandler);
4826  }
4827 
4828  // OMP parallelism
4829  /*#pragma omp parallel for num_threads(getNumberOfOMPThreads()) //schedule(dynamic)
4830  for (int k = 0; k < boundaryHandler.getNumberOfObjects(); k++)
4831  {
4832  //Calls the createPeriodicParticles() function which checks if a particle is adequately
4833  //close to a periodic particle that a periodic (ghost) particle should be created and,
4834  //if so, creates one and adds it to the system (hence the necessity to keep "N" variable).
4835  //
4836  // (The loop is over all boundaries, but if a boundary is not a PeriodicBoundary, then
4837  // this does nothing.)
4838 
4839  BaseBoundary* boundary = boundaryHandler.getObject(k);
4840  #pragma omp critical
4841  boundary->createPeriodicParticles(particleHandler);
4842  }*/
4843 }
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1344
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
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 3152 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().

3153 {
3154 
3155  //Cycling over all boundaries within the system...
3156  for (BaseBoundary* b : boundaryHandler)
3157  {
3158  //check all boundaries...
3159  b->checkBoundaryAfterParticlesMove(particleHandler);
3160 
3161 
3162 #ifdef MERCURY_USE_MPI
3163  //When ghost particles are deleted by deletion boundaries they need to be removed
3164  //from their communication lists to avoid segfaults
3165  if (NUMBER_OF_PROCESSORS > 1)
3166  {
3167  //Flush deleted particles from mpi communication zones
3168  getCurrentDomain()->flushParticles(b->getParticlesToBeDeleted());
3170  periodicBoundaryHandler.flushParticles(b->getParticlesToBeDeleted());
3172  }
3173 
3174  //Delete particles that were in communication zone
3175  for (auto p_it = b->getParticlesToBeDeleted().begin(); p_it != b->getParticlesToBeDeleted().end(); p_it++)
3176  {
3177  particleHandler.removeGhostObject((*p_it)->getIndex());
3178  }
3179 #endif
3180  }
3181 }
Domain * getCurrentDomain()
Function that returns a pointer to the domain corresponding to the processor.
Definition: DPMBase.cc:5034
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:1669
void flushParticles(std::set< BaseParticle * > &particlesToBeFlushed)
Removes particles from the periodiocParticleList_ and periociGhostList_.
void cleanCommunicationLists()
Removes nullptrs from boundaryParticleList_ and boundaryParticleListNeighbour_.
Definition: Domain.cc:1713
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1344
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1349
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
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 4588 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().

4589 {
4590 #ifdef MERCURY_USE_MPI
4591  if (NUMBER_OF_PROCESSORS == 1)
4592  {
4594  }
4595 
4596  int localInteraction = checkParticleForInteractionLocal(p);
4597  //The root gathers all values and computes the global value
4598  int *interactionList = nullptr;
4599  if (PROCESSOR_ID == 0)
4600  {
4601  interactionList = new int [NUMBER_OF_PROCESSORS];
4602  }
4603 
4604  //Gather all local values
4605  MPIContainer::Instance().gather(localInteraction,interactionList);
4606 
4607  //Compute the global value
4608  int globalInteraction = 1;
4609  if (PROCESSOR_ID == 0)
4610  {
4611  for (int i = 0; i < NUMBER_OF_PROCESSORS; i++)
4612  {
4613  if (interactionList[i] == 0)
4614  {
4615  globalInteraction = 0;
4616  break;
4617  }
4618  }
4619  }
4620  //The root now tells the other processors what the global value for the interaction is
4621  MPIContainer::Instance().broadcast(globalInteraction);
4622 
4623  //Convert the result back to bool
4624  bool interaction = globalInteraction;
4625 #else
4626  bool interaction = checkParticleForInteractionLocalPeriodic(p);
4627 #endif
4628  return interaction;
4629 }
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
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:416
#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:429
bool checkParticleForInteractionLocalPeriodic(const BaseParticle &P)
Definition: DPMBase.cc:4637
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:4687
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 4687 of file DPMBase.cc.

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

Referenced by checkParticleForInteraction(), and checkParticleForInteractionLocalPeriodic().

4688 {
4689  Mdouble distance;
4690  Vec3D normal;
4691 
4692  //Check if it has no collision with walls
4693  for (BaseWall* w : wallHandler)
4694  {
4695  //returns false if the function getDistanceAndNormal returns true,
4696  //i.e. if there exists an interaction between wall and particle
4697  //\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.)
4698  if (w->getDistanceAndNormal(p, distance, normal))
4699  {
4700  //std::cout<<"failure: Collision with wall: "<<**it<<std::endl;
4701  return false;
4702  }
4703  else
4704  {
4705  //std::cout<<"No collision with wall: "<<**it<<std::endl;
4706  }
4707  }
4708 
4709  //Check if it has no collision with other particles
4710  for (BaseParticle* q : particleHandler)
4711  {
4712  //returns false if the particle separation is less than the relevant sum of interaction radii
4713  //(i.e. another particle is in contact with P)
4714  if (Vec3D::getDistanceSquared(q->getPosition(), p.getPosition())
4716  {
4717  //std::cout<<"failure: Collision with particle "<<**it<<std::endl;
4718  return false;
4719  }
4720  else
4721  {
4722  //std::cout<<"No collision with particle "<<**it<<std::endl;
4723  }
4724  }
4725  return true;
4727 }
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:1329
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:1339
Definition: Vector.h:49
T square(const T val)
squares a number
Definition: ExtendedMath.h:104
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 4637 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().

4638 {
4639  //A vector of ghost particles of the particle that is to be inserted (empty if no periodic boundaries are present)
4640  std::vector<Vec3D> pPeriodic;
4641  for (BaseBoundary* b : boundaryHandler)
4642  {
4643  PeriodicBoundary* pb = dynamic_cast<PeriodicBoundary*>(b);
4644  if (pb && particleHandler.getNumberOfObjects() > 0 )
4645  {
4647  for (int i = pPeriodic.size() - 1; i >= 0; --i)
4648  {
4649  if (pb->getDistance(pPeriodic[i]) < maxDistance)
4650  {
4651  pPeriodic.push_back(pPeriodic[i]);
4652  pb->shiftPosition(pPeriodic.back());
4653  }
4654  }
4655  if (pb->getDistance(p) < maxDistance)
4656  {
4657  pPeriodic.push_back(p.getPosition());
4658  pb->shiftPosition(pPeriodic.back());
4659  }
4660  }
4661  }
4662  //check the particle AND the ghost particles for intersection problems
4663  bool insertable = checkParticleForInteractionLocal(p);
4664  if (!pPeriodic.empty()) {
4665  BaseParticle* q = p.copy();
4666  for (const Vec3D& pos : pPeriodic) {
4667  q->setPosition(pos);
4668  insertable &= checkParticleForInteractionLocal(*q);
4669  }
4670  delete q;
4671  }
4672  return insertable;
4673 }
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:1344
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
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:4687
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 3796 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().

3797 {
3798  //check if name is set
3799  logger.assert_always(getName() != "",
3800  "File name not set: use setName()");
3801  //check if time step is set
3802  logger.assert_always(getTimeStep() != 0,
3803  "Time step undefined: use setTimeStep()");
3804  //check if domain is set
3805  logger.assert_always(getXMax() > getXMin(),
3806  "Domain size not set: use setXMin() and setXMax()");
3807  logger.assert_always(getYMax() > getYMin(),
3808  "Domain size not set: use setYMin() and setYMax()");
3809  logger.assert_always(systemDimensions_ == 3 ? (getZMax() > getZMin()) : (getZMax() >= getZMin()),
3810  "Domain size not set: use setZMin() and setZMax()", systemDimensions_);
3811 
3812  //check for species parameters
3813  logger.assert_always(speciesHandler.getNumberOfObjects() > 0,
3814  "No species defined: use speciesHandler.copyAndAddObject()");
3815  for (BaseParticle* p : particleHandler)
3816  {
3817  logger.assert_always(p->getSpecies() != nullptr, "particle % has no species", p->getId());
3818  }
3819  for (BaseWall* w : wallHandler)
3820  {
3821  logger.assert_always(w->getSpecies() != nullptr, "% with index % has no species", w->getName(), w->getId());
3822  }
3823 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.h:617
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.h:586
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.h:599
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:389
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.h:593
unsigned int systemDimensions_
The dimensions of the simulation i.e. 2D or 3D.
Definition: DPMBase.h:1183
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
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:1319
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.h:605
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1339
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.h:611
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1211
void DPMBase::closeFiles ( )

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

Definition at line 492 of file DPMBase.cc.

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

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

493 {
494  dataFile.close();
495  fStatFile.close();
496  restartFile.close();
497  statFile.close();
498  eneFile.close();
500 }
File interactionFile
File class to handle in- and output into .interactions file. This file hold information about interac...
Definition: DPMBase.h:1396
void close()
Closes the file by calling fstream_.close()
Definition: File.cc:408
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1370
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1375
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: DPMBase.h:1390
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1380
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1385
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 3277 of file DPMBase.cc.

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

Referenced by computeOneTimeStep(), and solve().

3278 {
3279  //Resetting all forces on both particles and walls to zero
3280  #pragma omp parallel num_threads(getNumberOfOMPThreads())
3281  {
3282  #pragma omp for
3283  for (int k = 0; k < particleHandler.getNumberOfObjects(); ++k) {
3285  }
3286  #pragma omp for
3287  for (int k = 0; k < wallHandler.getNumberOfObjects(); k++) {
3289  }
3290  }
3291  logger(DEBUG,"All forces set to zero");
3292 
3293  // for omp simulations, reset the newObjects_ variable (used for reduction)
3295 
3296  // compute all internal and external forces; for omp simulations, this can be done in parallel
3297  #pragma omp parallel num_threads(getNumberOfOMPThreads())
3298  {
3299  //logger(INFO, "Number of omp threads = %", getNumberOfOMPThreads());
3301  #pragma omp for schedule(dynamic)
3302  for (int k = 0; k < particleHandler.getNumberOfObjects(); ++k) {
3304  //computing both internal forces (e.g. due to collisions)
3305  //and external forces (e.g. gravity)
3306  //(compute internal forces compares the current particle p
3307  //with all others in the handler!)
3309  // body forces
3311  }
3312 
3313  // wall-forces
3314  #pragma omp for schedule(dynamic)
3315  for (int k = 0; k < wallHandler.getNumberOfObjects(); k++) {
3316  BaseWall *w = wallHandler.getObject(k);
3317  computeWallForces(w);
3318  }
3319 
3320  }
3321 
3322 #ifdef CONTACT_LIST_HGRID
3323  PossibleContact* Curr=possibleContactList.getFirstPossibleContact();
3324  while(Curr)
3325  {
3326  computeInternalForces(Curr->getP1(),Curr->getP2());
3327  Curr=Curr->getNext();
3328  }
3329 #endif
3330 
3331  // for omp simulations, sum up all forces and add all newObjects_ (needed since both are using reduction)
3332  #ifdef MERCURY_USE_OMP
3333  if (getNumberOfOMPThreads()>1) {
3335  }
3336  //Resetting all forces on both particles and walls to zero
3337  #pragma omp parallel num_threads(getNumberOfOMPThreads())
3338  {
3339  #pragma omp for
3340  for (int k = 0; k < particleHandler.getNumberOfObjects(); k++) {
3342  }
3343  #pragma omp for
3344  for (int k = 0; k < wallHandler.getNumberOfObjects(); k++) {
3346  } //end reset forces loop
3347  }
3348  #endif
3349 
3350  //end outer loop over contacts.
3351 }
virtual void computeExternalForces(BaseParticle *)
Computes the external forces, such as gravity, acting on particles.
Definition: DPMBase.cc:3049
BaseParticle * getP1()
Gets a pointer to the first BaseParticle in this PossibleContact.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
unsigned int getNumberOfObjects() const override
Returns the number of objects in the container. In parallel code this practice is forbidden to avoid ...
void resetForceTorque(int numberOfOMPthreads)
virtual void computeWallForces(BaseWall *w)
Definition: DPMBase.cc:5172
BaseParticle * getP2()
Gets a pointer to the second BaseParticle in this PossibleContact.
int getNumberOfOMPThreads() const
Definition: DPMBase.cc:1246
PossibleContact * getNext()
Gets the next PossibleContact in the general linked list of PossibleContact.
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
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:1359
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1339
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:3359
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 3049 of file DPMBase.cc.

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

Referenced by computeAllForces().

3050 {
3051  //Checks that the current particle is not "fixed"
3052  //and hence infinitely massive!
3053  if (!CI->isFixed())
3054  {
3055  // Applying the force due to gravity (F = m.g)
3056  CI->addForce(getGravity() * CI->getMass());
3057  // Still calls this in compute External Forces.
3058  // computeForcesDueToWalls(CI);
3059  }
3060 }
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:1351
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 3069 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().

3070 {
3071  //No need to compute interactions between periodic particle images and walls
3072  if (pI->getPeriodicFromParticle() != nullptr)
3073  return;
3074 
3075  //Checks if the particle is interacting with the current wall
3078  if (i!=nullptr) {
3079  //...calculates the forces between the two objects...
3080  i->computeForce();
3081 
3082  //...and applies them to each of the two objects (wall and particle).
3083  pI->addForce(i->getForce());
3084  w->addForce(-i->getForce());
3085 
3086  //If the rotation flag is on, also applies the relevant torques
3087  //(getRotation() returns a boolean).
3088  if (getRotation()) // getRotation() returns a boolean.
3089  {
3090  pI->addTorque(i->getTorque() - Vec3D::cross(pI->getPosition() - i->getContactPoint(), i->getForce()));
3092  w->addTorque(-i->getTorque() + Vec3D::cross(w->getPosition() - i->getContactPoint(), i->getForce()));
3093  }
3094  }
3095 }
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:813
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:1359
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:545
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 2994 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().

2995 {
2996  //Does not compute forces if particles are fixed
2997  //this is necessary because the rough bottom allows overlapping fixed particles
2998  if (P1->isFixed() && P2->isFixed())
2999  {
3000  return;
3001  }
3002 //Ensures that interactions between the "ghost" particles used to implement periodic behaviour
3003  //are not included in calculations
3004  //i.e. ends the function if both particles are "ghosts".
3005  if ((P1->getPeriodicFromParticle() != nullptr) && (P2->getPeriodicFromParticle() != nullptr))
3006  {
3007  return;
3008  }
3009 //if statement below ensures that the PI has the lower id than PJ
3010  BaseParticle* PI, * PJ;
3011  if (P1->getId() > P2->getId())
3012  {
3013  PI = P2;
3014  PJ = P1;
3015  }
3016  else
3017  {
3018  PI = P1;
3019  PJ = P2;
3020  }
3021  //checks if the two particles are interacting
3022  //("getInteractionWith" returns the relevant pointer if PI and PJ are interacting,
3023  //zero if not)
3024  //if statement above ensures that the PI has the lower id than PJ
3027  if (i!= nullptr) {
3028  //calculates the force corresponding to the interaction
3029  i->computeForce();
3030 
3031  //Applies the relevant calculated forces to PI and PJ
3032  PI->addForce(i->getForce());
3033  PJ->addForce(-i->getForce());
3034 
3035  //checks if particle rotation is turned on...
3036  if (getRotation()) {
3037  //...and, if so, performs equivalent calculations for the torque as were
3038  //performed for the force.
3039  PI->addTorque(i->getTorque() - Vec3D::cross(PI->getPosition() - i->getContactPoint(), i->getForce()));
3040  PJ->addTorque(-i->getTorque() + Vec3D::cross(PJ->getPosition() - i->getContactPoint(), i->getForce()));
3041  }
3042  }
3043 }
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:813
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:1359
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:545
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 3359 of file DPMBase.cc.

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

Referenced by computeAllForces().

3360 {
3361  for (auto it = particleHandler.begin(); (*it) != i; ++it)
3362  {
3363  computeInternalForce(i, *it);
3364  }
3365 }
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:1329
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:2994
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 4090 of file DPMBase.cc.

References 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_, and writeOutputFiles().

Referenced by solve().

4091 {
4092  logger(DEBUG, "starting computeOneTimeStep()");
4093 
4094  logger(DEBUG, "about to call writeOutputFiles()");
4095  writeOutputFiles(); //everything is written at the beginning of the time step!
4096 
4097  logger(DEBUG, "about to call hGridActionsBeforeIntegration()");
4099 
4100  //Computes the half-time step velocity and full time step position and updates the particles accordingly
4101  logger(DEBUG, "about to call integrateBeforeForceComputation()");
4102 
4104  //New positions require the MPI and parallel periodic boundaries to do things
4105  logger(DEBUG, "about to call performGhostParticleUpdate()");
4107 
4111 
4112  logger(DEBUG, "about to call checkInteractionWithBoundaries()");
4113  checkInteractionWithBoundaries(); // INSERTION boundaries handled
4114 
4115  logger(DEBUG, "about to call hGridActionsAfterIntegration()");
4117 
4118  // Compute forces
4120  // INSERTION/DELETION boundary flag change
4121  for (BaseBoundary* b : boundaryHandler)
4122  {
4123  b->checkBoundaryBeforeTimeStep(this);
4124  }
4125 
4126  logger(DEBUG, "about to call actionsBeforeTimeStep()");
4128 
4129  logger(DEBUG, "about to call checkAndDuplicatePeriodicParticles()");
4131 
4132  logger(DEBUG, "about to call hGridActionsBeforeTimeStep()");
4134 
4135  //Creates and updates interactions and computes forces based on these
4136  logger(DEBUG, "about to call computeAllForces()");
4137  computeAllForces();
4138 
4139  logger(DEBUG, "about to call removeDuplicatePeriodicParticles()");
4141 
4142  logger(DEBUG, "about to call actionsAfterTimeStep()");
4144 
4145  //Computes new velocities and updates the particles accordingly
4146  logger(DEBUG, "about to call integrateAfterForceComputation()");
4148 
4149  //erase interactions that have not been used during the last time step
4150  //logger(DEBUG, "about to call interactionHandler.eraseOldInteractions(getNumberOfTimeSteps())");
4152  logger(DEBUG, "about to call interactionHandler.actionsAfterTimeStep()");
4155 
4156  time_ += timeStep_;
4158 
4159  logger(DEBUG, "finished computeOneTimeStep()");
4160 }
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:3194
void checkAndDuplicatePeriodicParticles()
For simulations using periodic boundaries, checks and adds particles when necessary into the particle...
Definition: DPMBase.cc:4814
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
virtual void actionsAfterTimeStep()
A virtual function which allows to define operations to be executed after time step.
Definition: DPMBase.cc:1838
virtual void writeOutputFiles()
Writes simulation data to all the main Mercury files: .data, .ene, .fstat, .xballs and ...
Definition: DPMBase.cc:3846
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1214
virtual void hGridActionsBeforeIntegration()
This function has to be called before integrateBeforeForceComputation.
Definition: DPMBase.cc:1900
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:813
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1344
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
Mdouble time_
Stores the current simulation time.
Definition: DPMBase.h:1209
virtual void computeAllForces()
Computes all the forces acting on the particles using the BaseInteractable::setForce() and BaseIntera...
Definition: DPMBase.cc:3277
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1359
virtual void actionsBeforeTimeStep()
A virtual function which allows to define operations to be executed before the new time step...
Definition: DPMBase.cc:1824
Mdouble timeStep_
Stores the simulation time step.
Definition: DPMBase.h:1219
void removeDuplicatePeriodicParticles()
Removes periodic duplicate Particles.
Definition: DPMBase.cc:4771
virtual void integrateBeforeForceComputation()
Update particles' and walls' positions and velocities before force computation.
Definition: DPMBase.cc:3108
virtual void hGridActionsAfterIntegration()
This function has to be called after integrateBeforeForceComputation.
Definition: DPMBase.cc:1907
virtual void hGridActionsBeforeTimeStep()
A virtual function that allows one to set or execute hGrid parameters or operations before every simu...
Definition: DPMBase.cc:1650
virtual void checkInteractionWithBoundaries()
There are a range of boundaries one could implement depending on ones' problem. This methods checks f...
Definition: DPMBase.cc:3152
void performGhostParticleUpdate()
When the Verlet scheme updates the positions and velocities of particles, ghost particles will need a...
Definition: DPMBase.cc:4848
void DPMBase::computeWallForces ( BaseWall w)
virtual

Reimplemented in Mercury3D.

Definition at line 5172 of file DPMBase.cc.

References computeForcesDueToWalls(), and particleHandler.

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

5173 {
5174  //compute forces for all particles that are neither fixed or ghosts
5175  for (auto p : particleHandler)
5176  {
5177  if (!p->isFixed() && p->getPeriodicFromParticle() == nullptr)
5178  {
5179  //w->computeForces(p);
5181  }
5182  }
5183 }
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
void computeForcesDueToWalls(BaseParticle *, BaseWall *)
Computes the forces on the particles due to the walls (normals are outward normals) ...
Definition: DPMBase.cc:3069
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 200 of file DPMBase.cc.

References boundaryHandler, cgHandler, dataFile, DEBUG, domainHandler, eneFile, fStatFile, File::getFstream(), DomainHandler::initialise(), PeriodicBoundaryHandler::initialise(), initialiseMPI(), interactionFile, interactionHandler, logger, loggerOutput, logWriteAndDie(), max_, min_, name_, NO_FILE, numberOfDomains_, numberOfOMPThreads_, numberOfTimeSteps_, LoggerOutput::onFatal, 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().

201 {
202  //constructor();
203  dataFile.getFstream().precision(10);
204  fStatFile.getFstream().precision(10);
205  eneFile.getFstream().precision(10);
206  restartFile.getFstream().precision(
207  std::numeric_limits<double>::digits10); //highly accurate, so the overlap is accurate
208  statFile.getFstream().precision(10);
209  statFile.getFstream().setf(std::ios::left);
210  interactionFile.getFstream().precision(10);
211  name_ = ""; // needs to be user-specified, otherwise checkSettings throws error
212  //by default, the fileType of all files is ONE_FILE. However, by default we don't want an interaction file since it
213  // is very large.
215 
216  runNumber_ = 0;
217 
218  //Decomposition direction for MPI
219  numberOfDomains_ = {1, 1, 1};
220 
221  //Check if MPI is already initialised
222  initialiseMPI();
223 
224  //This sets the maximum number of particles
229  cgHandler.setDPMBase(this);
231  wallHandler.setDPMBase(this);
237 
238  //set defaults for DPMBase parameters
241  setRestarted(false);
242  setGravity(Vec3D(0, 0, 0));
243 
244  //This is the parameter of the numerical part
245  setTime(0);
246  numberOfTimeSteps_ = 0;
247  setTimeMax(0);
248  timeStep_ = 0; // needs to be user-specified, otherwise checkSettings throws error
249  setSaveCount(20);
250 
251  //This sets the default xballs domain
252  min_ = Vec3D(0, 0, 0);
253  max_ = Vec3D(0, 0, 0); // needs to be user-specified, otherwise checkSettings throws error
254 
255  //sets the default write particles data in VTK format flag to false
256  writeParticlesVTK_ = false;
259  vtkWriter_ = nullptr;
260 
261  //defines logger behaviour
263 
264  setName(""); // needs to be user-specified, otherwise checkSettings throws error
265 
266  //Default mode is energy with no scale of the vectors
267  xBallsColourMode_ = 0;
268  xBallsVectorScale_ = -1;
269  xBallsScale_ = -1;
271  setAppend(false);
272 
273  //The default random seed is 0
275 
276  logger(DEBUG, "DPMBase problem constructor finished");
277 
278  readSpeciesFromDataFile_ = false;
279 
281 }
void setTime(Mdouble time)
Sets a new value for the current simulation time.
Definition: DPMBase.cc:825
std::string name_
the name of the problem, used, e.g., for the output files
Definition: DPMBase.h:1302
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:840
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Vec3D max_
Definition: DPMBase.h:1204
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:1312
File interactionFile
File class to handle in- and output into .interactions file. This file hold information about interac...
Definition: DPMBase.h:1396
int runNumber_
This stores the run number for saving.
Definition: DPMBase.h:1297
void setParticleDimensions(unsigned int particleDimensions)
Sets the particle dimensionality.
Definition: DPMBase.cc:1408
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1354
std::vector< unsigned > numberOfDomains_
Vector containing the number of domains in x-,y- and z-direction, required for parallel computations...
Definition: DPMBase.h:1198
void setAppend(bool newAppendFlag)
Sets whether the "append" option is on or off.
Definition: DPMBase.cc:1482
void setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1377
std::function< void(std::string, std::string)> onFatal
Definition: Logger.h:195
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1343
void initialiseMPI()
Inialises the MPI library.
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1214
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:1370
file will not be created/read
std::fstream & getFstream()
Allows to access the member variable File::fstream_.
Definition: File.cc:154
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1375
bool writeSuperquadricParticlesVTK_
Definition: DPMBase.h:1261
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1365
int xBallsColourMode_
XBalls is a package to view the particle data. As an alternative MercuryDPM also supports ParaView...
Definition: DPMBase.h:1277
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1344
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1349
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1263
Mdouble xBallsScale_
sets the xballs argument scale (see XBalls/xballs.txt)
Definition: DPMBase.h:1287
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:398
int numberOfOMPThreads_
Definition: DPMBase.h:1178
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1319
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1359
FileType writeWallsVTK_
A flag to turn on/off the vtk writer for walls.
Definition: DPMBase.h:1254
Mdouble xBallsVectorScale_
sets the xballs argument vscale (see XBalls/xballs.txt)
Definition: DPMBase.h:1282
LoggerOutput * loggerOutput
Declaration of the output functions. If the output needs to be redirected, please swap the loggerOutp...
Definition: Logger.cc:168
Mdouble timeStep_
Stores the simulation time step.
Definition: DPMBase.h:1219
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:216
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:1339
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:1324
bool writeParticlesVTK_
A flag to turn on/off the vtk writer for particles.
Definition: DPMBase.h:1259
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:412
void logWriteAndDie(const std::string &module, std::string message)
todo strcmp relies on this, should be changed to more modern version
Definition: DPMBase.cc:73
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: DPMBase.h:1390
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1380
std::string xBallsAdditionalArguments_
A string of additional arguments for xballs can be specified (see XBalls/xballs.txt). e.g. "-solidf -v0".
Definition: DPMBase.h:1292
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1385
void setRestarted(bool newRestartedFlag)
Allows to set the flag stating if the simulation is to be restarted or not.
Definition: DPMBase.cc:1461
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:1203
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 1953 of file DPMBase.cc.

Referenced by solve().

1954 {
1955  return true;
1956 }
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 3885 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().

3886 {
3887 #ifdef MERCURY_USE_MPI
3888 
3889  //If running in parallel build, but just running with one core - no domain decomposition required
3890  int numberOfRequiredProcessors = numberOfDomains_[Direction::XAXIS]*
3893  if (NUMBER_OF_PROCESSORS != numberOfRequiredProcessors)
3894  {
3895  logger(ERROR,"The domain decompositions expects % processors, but only % are requested.\n"
3896  "Either run your process using \"mpirun -np % [executable]\", "
3897  "or change the domain decomposition to e.g. setNumberOfDomains({%,1,1}).", numberOfRequiredProcessors, NUMBER_OF_PROCESSORS, numberOfRequiredProcessors, NUMBER_OF_PROCESSORS);
3898  }
3899 
3900  if (NUMBER_OF_PROCESSORS == 1) {return;}
3901 
3902  //Check if the simulation domain has been set
3903  logger.assert_always(getXMax() - getXMin() > 0,"Please set your simulation domain (setXMax(),setXmin()) before calling solve()");
3904  logger.assert_always(getYMax() - getYMin() > 0,"Please set your simulation domain (setYMax(),setYmin()) before calling solve()");
3905  logger.assert_always(getZMax() - getZMin() > 0,"Please set your simulation domain (setZMax(),setZmin()) before calling solve()");
3906 
3907  //Grab simulation domains
3908  std::vector<Mdouble> simulationMin{getXMin(), getYMin(), getZMin()};
3909  std::vector<Mdouble> simulationMax{getXMax(), getYMax(), getZMax()};
3910 
3911  //Check if the user input decomposition is correct
3912  logger.assert_always(numberOfDomains_[Direction::XAXIS] > 0,"Number of domain in x-direction incorrect: %",numberOfDomains_[Direction::XAXIS]);
3913  logger.assert_always(numberOfDomains_[Direction::YAXIS] > 0,"Number of domain in y-direction incorrect: %",numberOfDomains_[Direction::YAXIS]);
3914  logger.assert_always(numberOfDomains_[Direction::ZAXIS] > 0,"Number of domain in z-direction incorrect: %",numberOfDomains_[Direction::ZAXIS]);
3915 
3916  //Open domain decomposition, closed is not implemented
3917  bool open = true;
3918 
3919  //Check if the number of domains is equal to the number of processors
3920  logger.assert_always(numberOfDomains_[Direction::XAXIS]*numberOfDomains_[Direction::YAXIS]*numberOfDomains_[Direction::ZAXIS] == NUMBER_OF_PROCESSORS,
3921  "Number of Processors is not equal to number of domains. Processors %, domains, %",
3923  numberOfDomains_[Direction::XAXIS]*numberOfDomains_[Direction::YAXIS]*numberOfDomains_[Direction::ZAXIS]);
3924 
3925  //Create all processor domains
3926 
3927  domainHandler.setDPMBase(this);
3928  domainHandler.createMesh(simulationMin, simulationMax, numberOfDomains_, open);
3929  logger(VERBOSE,"Number of domains: % | Number of processors: %",domainHandler.getNumberOfObjects(), NUMBER_OF_PROCESSORS);
3930  //logger.assert_always(domainHandler.getNumberOfObjects() == numberOfProcessors, "Invalid decomposition: Number of domains and processors are different");
3931 
3932  //Tell the current processor to which domain it belongs
3933  for (Domain* domain : domainHandler)
3934  {
3935  if (domain->getRank() == PROCESSOR_ID)
3936  {
3937  logger(VERBOSE,"processor: %, domain index: %",PROCESSOR_ID, domain->getIndex());
3938  domainHandler.setCurrentDomainIndex(domain->getIndex());
3939  }
3940  }
3941 
3942  //Define the mpi transfer types, which requires a definition of the species already
3944  logger.assert_always(speciesHandler.getNumberOfObjects() > 0, "Please create a particle species before calling solve()");
3946 
3947  //Make sure all processors are done with decomposition before proceeding
3948  logger(VERBOSE,"processor %: #real particles: %, #total particles: %", PROCESSOR_ID, particleHandler.getNumberOfRealObjects(), particleHandler.getSize());
3950 #endif
3951 }
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
void initialiseMercuryMPITypes(const SpeciesHandler &speciesHandler)
Creates the MPI types required for communication of Mercury data through the MPI interface.
Definition: MpiContainer.cc:70
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
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:617
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.h:586
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.h:599
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1354
std::vector< unsigned > numberOfDomains_
Vector containing the number of domains in x-,y- and z-direction, required for parallel computations...
Definition: DPMBase.h:1198
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.h:593
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:1329
#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:1319
#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:605
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:148
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.h:611
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 4871 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().

4872 {
4873  //Flush mixed particles from lists (MP particles are located in both structures)
4874  if (periodicBoundaryHandler.getSize() > 0)
4875  {
4876  //Flush particles from boundaries
4877  domainHandler.getCurrentDomain()->flushParticles(particlesToBeDeleted);
4878  periodicBoundaryHandler.flushParticles(particlesToBeDeleted);
4879  }
4880 
4881  //Clean communication lists
4884 
4885  //Delete the particles
4886  for (auto particle_it : particlesToBeDeleted)
4887  {
4888  particleHandler.removeGhostObject(particle_it->getIndex());
4889  }
4890 }
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:1669
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1354
void flushParticles(std::set< BaseParticle * > &particlesToBeFlushed)
Removes particles from the periodiocParticleList_ and periociGhostList_.
void cleanCommunicationLists()
Removes nullptrs from boundaryParticleList_ and boundaryParticleListNeighbour_.
Definition: Domain.cc:1713
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1349
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
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 2874 of file DPMBase.cc.

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

2874  {
2875  logger.assert_always(speciesHandler.getSize()>0,"There needs to be at least one species");
2877  SphericalParticle p(s);
2879  Mdouble r = cbrt(getTotalVolume())/N;
2880  b.set(p,100,getMin(),getMax(),{0,0,0},{0,0,0},r,r);
2881  b.insertParticles(this);
2882  logger(INFO,"Inserted % particles",particleHandler.getSize());
2883  //setTimeMax(0);
2884  //solve();
2885 }
A basic particle.
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
Vec3D getMin() const
Definition: DPMBase.h:623
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:1329
Mdouble getTotalVolume() const
Get the total volume of the cuboid system.
Definition: DPMBase.cc:5115
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1319
Vec3D getMax() const
Definition: DPMBase.h:629
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 2538 of file DPMBase.cc.

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

2539 {
2541  {
2542  while (true)// This true corresponds to the if s
2543  {
2544  dataFile.open();
2545  //check if file exists and contains data
2546  int N;
2547  dataFile.getFstream() >> N;
2548  if (dataFile.getFstream().eof() || dataFile.getFstream().peek() == -1)
2549  {
2550  std::cout << "file " << dataFile.getName() << " not found" << std::endl;
2551  return false;
2552  }
2553  //check if tmin condition is satisfied
2554  Mdouble t;
2555  dataFile.getFstream() >> t;
2556  if (t > tMin)
2557  {
2558  //set_file_counter(get_file_counter()-1);
2559  return true;
2560  }
2561  if (verbose)
2562  std::cout << "Jumping file counter: " << dataFile.getCounter() << std::endl;
2563  }
2564  }
2565  return true;
2566 }
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:208
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:224
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1370
std::fstream & getFstream()
Allows to access the member variable File::fstream_.
Definition: File.cc:154
bool open()
Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the ne...
Definition: File.cc:348
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:166
void DPMBase::finishStatistics ( )
protectedvirtual

This function is overridden by StatisticsVector

Reimplemented in StatisticsVector< T >.

Definition at line 1885 of file DPMBase.cc.

References cgHandler, and CGHandler::finish().

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

1886 {
1887  cgHandler.finish();
1888 }
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:1365
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 3825 of file DPMBase.cc.

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

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

3826 {
3828  writeOutputFiles();
3829 }
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:508
virtual void writeOutputFiles()
Writes simulation data to all the main Mercury files: .data, .ene, .fstat, .xballs and ...
Definition: DPMBase.cc:3846
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 1869 of file DPMBase.cc.

Referenced by BaseInteraction::gatherContactStatistics().

1872 {
1873 }
void DPMBase::gatherContactStatistics ( )
protected

Definition at line 1858 of file DPMBase.cc.

References interactionHandler.

1859 {
1861  {
1862  c->gatherContactStatistics();
1863  }
1864 }
Stores information about interactions between two interactable objects; often particles but could be ...
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1359
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 659 of file DPMBase.cc.

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

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

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

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

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

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

References append_.

Referenced by solve(), and writeEneHeader().

1471 {
1472  return append_;
1473 }
bool append_
A flag to determine if the file has to be appended or not. See DPMBase::Solve() for example...
Definition: DPMBase.h:1242
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 1574 of file DPMBase.cc.

References ParticleHandler::getCentreOfMass(), and particleHandler.

1575 {
1577 }
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
Vec3D getCentreOfMass() const
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 5034 of file DPMBase.cc.

References domainHandler, and DomainHandler::getCurrentDomain().

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

5035 {
5037 }
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1354
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 295 of file DPMBase.cc.

References dataFile.

296 {
297  return dataFile;
298 }
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1370
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 344 of file DPMBase.cc.

References dataFile.

345 {
346  return dataFile;
347 }
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1370
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 1490 of file DPMBase.cc.

References interactionHandler.

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

1491 {
1492  Mdouble elasticEnergy = 0.0;
1493  // JMFT: Note that we do count the elastic energy of fixed particles here.
1494  for (const BaseInteraction* c : interactionHandler)
1495  {
1496  elasticEnergy += c->getElasticEnergy();
1497  }
1498  return elasticEnergy;
1499 }
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:1359
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 303 of file DPMBase.cc.

References eneFile.

304 {
305  return eneFile;
306 }
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1380
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 352 of file DPMBase.cc.

References eneFile.

353 {
354  return eneFile;
355 }
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1380
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 311 of file DPMBase.cc.

References fStatFile.

312 {
313  return fStatFile;
314 }
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1375
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 360 of file DPMBase.cc.

References fStatFile.

361 {
362  return fStatFile;
363 }
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1375
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 1521 of file DPMBase.cc.

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

Referenced by getTotalEnergy().

1522 {
1523  Mdouble gravitationalEnergy = 0;
1524  for (const BaseParticle* const p : particleHandler)
1525  {
1526  // Don't consider fixed particles. 'Fixed' particles aren't necessarily
1527  // stationary; it just means their position is prescribed.
1528  if (!(p->isFixed()))
1529  {
1530  gravitationalEnergy += p->getMass() * Vec3D::dot((-getGravity()), p->getPosition());
1531  }
1532  }
1533  return gravitationalEnergy;
1534 }
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:1329
Vec3D getGravity() const
Returns the gravitational acceleration.
Definition: DPMBase.cc:1351
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 1351 of file DPMBase.cc.

References gravity_.

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

1352 {
1353  return gravity_;
1354 }
Vec3D gravity_
Gravity vector.
Definition: DPMBase.h:1193
bool DPMBase::getHGridUpdateEachTimeStep ( ) const
virtual
Returns
bool (True or False)

Reimplemented in MercuryBase.

Definition at line 1678 of file DPMBase.cc.

Referenced by BaseParticle::integrateBeforeForceComputation().

1679 {
1680  return true;
1681 }
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 1602 of file DPMBase.cc.

References BaseParticle::getInfo().

1603 {
1604 // return p.getSpecies()->getId(); // was getIndex()
1605  return p.getInfo();
1606 }
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 335 of file DPMBase.cc.

References interactionFile.

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

336 {
337  return interactionFile;
338 }
File interactionFile
File class to handle in- and output into .interactions file. This file hold information about interac...
Definition: DPMBase.h:1396
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 384 of file DPMBase.cc.

385 {
386  return interactionFile;
387 }
File interactionFile
File class to handle in- and output into .interactions file. This file hold information about interac...
Definition: DPMBase.h:1396
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 1504 of file DPMBase.cc.

References particleHandler.

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

1505 {
1506  Mdouble kineticEnergy = 0;
1507  for (const BaseParticle* const p : particleHandler)
1508  {
1509  if (!(p->isFixed()))
1510  {
1511  kineticEnergy += .5 * p->getMass() * p->getVelocity().getLengthSquared();
1512  }
1513  }
1514  return kineticEnergy;
1515 }
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:1329
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 5124 of file DPMBase.cc.

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

Referenced by getTotalStress().

5125 {
5126  Matrix3D F; //set the kinetic energy tensor, this is in terms of Sum(m*v^2)
5127  Vec3D J; //set the momentum tensor
5128 
5129  //calculate stress for kinetic part
5130  for (const auto& p : particleHandler)
5131  {
5132  F += Matrix3D::dyadic(p->getVelocity(), p->getVelocity()) * p->getMass();
5133  J += p->getVelocity() * p->getMass();
5134  }
5135 
5136  Matrix3D stressKinetic = F - Matrix3D::dyadic(J, J) / getTotalMass();
5137  stressKinetic /= getTotalVolume();
5138  return stressKinetic;
5139 }
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:1329
Mdouble getTotalVolume() const
Get the total volume of the cuboid system.
Definition: DPMBase.cc:5115
Mdouble getTotalMass() const
JMFT: Return the total mass of the system, excluding fixed particles.
Definition: DPMBase.cc:1558
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 805 of file DPMBase.cc.

References time_, and timeStep_.

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

806 {
807  return time_ + timeStep_;
808 }
Mdouble time_
Stores the current simulation time.
Definition: DPMBase.h:1209
Mdouble timeStep_
Stores the simulation time step.
Definition: DPMBase.h:1219
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 5025 of file DPMBase.cc.

References numberOfDomains_.

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

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

Definition at line 1246 of file DPMBase.cc.

References numberOfOMPThreads_.

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

1247 {
1248  //logger.assert(numberOfOMPThreads_,"You need to set the number of OMP threads");
1249  return numberOfOMPThreads_;
1250 }
int numberOfOMPThreads_
Definition: DPMBase.h:1178
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 813 of file DPMBase.cc.

References numberOfTimeSteps_.

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

814 {
815  return numberOfTimeSteps_;
816 }
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1214
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 1427 of file DPMBase.cc.

References particleDimensions_.

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

1428 {
1429  return particleDimensions_;
1430 }
unsigned int particleDimensions_
determines if 2D or 3D particle volume is used for mass calculations
Definition: DPMBase.h:1188
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 946 of file DPMBase.cc.

References writeParticlesVTK_.

Referenced by writePythonFileForVTKVisualisation(), and writeVTKFiles().

947 {
948  return writeParticlesVTK_;
949 }
bool writeParticlesVTK_
A flag to turn on/off the vtk writer for particles.
Definition: DPMBase.h:1259
bool DPMBase::getRestarted ( ) const

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

Returns
restarted_

Definition at line 1453 of file DPMBase.cc.

References restarted_.

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

1454 {
1455  return restarted_;
1456 }
bool restarted_
A bool to check if the simulation was restarted or not, ie. if setupInitialConditionsShould be run an...
Definition: DPMBase.h:1236
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 319 of file DPMBase.cc.

References restartFile.

320 {
321  return restartFile;
322 }
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1385
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 368 of file DPMBase.cc.

References restartFile.

369 {
370  return restartFile;
371 }
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1385
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 1435 of file DPMBase.cc.

References restartVersion_.

Referenced by Chute::read().

1436 {
1437  return restartVersion_;
1438 }
std::string restartVersion_
Previous versions of MercuryDPM had a different restart file format, the below member variable allows...
Definition: DPMBase.h:1231
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 545 of file DPMBase.h.

References rotation_.

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

546  { return rotation_; }
bool rotation_
A flag to turn on/off particle rotation. true will enable particle rotation. false will disable parti...
Definition: DPMBase.h:1249
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 1537 of file DPMBase.cc.

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

Referenced by getTotalEnergy().

1538 {
1539  Mdouble ene_rot = 0;
1540  for (std::vector<BaseParticle*>::const_iterator it = particleHandler.begin(); it != particleHandler.end(); ++it)
1541  {
1542  // See above.
1543  if (!(*it)->isFixed())
1544  {
1545  // ene_rot += .5 * (*it)->getInertia() * (*it)->getAngularVelocity().getLengthSquared();
1546  }
1547  }
1548  return ene_rot;
1549 }
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:1329
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 606 of file DPMBase.cc.

References runNumber_.

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

607 {
608  return runNumber_;
609 }
int runNumber_
This stores the run number for saving.
Definition: DPMBase.h:1297
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 327 of file DPMBase.cc.

References statFile.

328 {
329  return statFile;
330 }
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: DPMBase.h:1390
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 376 of file DPMBase.cc.

References statFile.

377 {
378  return statFile;
379 }
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: DPMBase.h:1390
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 5146 of file DPMBase.cc.

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

Referenced by getTotalStress().

5147 {
5148  //stress components calculation variables
5149  Matrix3D stressStatic;
5150 
5151  //calculate the static stress tensor based on all the interactions
5152  for (const auto i : interactionHandler)
5153  {
5154  stressStatic += Matrix3D::dyadic(i->getForce(), i->getNormal()) * i->getDistance();
5155  }
5156 
5157  stressStatic /= getTotalVolume();
5158  return stressStatic;
5159 }
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:5115
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1359
Implementation of a 3D matrix.
Definition: Matrix.h:37
bool DPMBase::getSuperquadricParticlesWriteVTK ( ) const
Returns
bool

Definition at line 954 of file DPMBase.cc.

References writeSuperquadricParticlesVTK_.

Referenced by writeVTKFiles().

955 {
957 }
bool writeSuperquadricParticlesVTK_
Definition: DPMBase.h:1261
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 1390 of file DPMBase.cc.

References systemDimensions_.

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

1391 {
1392  return systemDimensions_;
1393 }
unsigned int systemDimensions_
The dimensions of the simulation i.e. 2D or 3D.
Definition: DPMBase.h:1183
Mdouble DPMBase::getTimeMax ( ) const

Returns the maximum simulation duration.

Returns
timeMax_

Definition at line 855 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().

856 {
857  return timeMax_;
858 }
Mdouble timeMax_
Stores the duration of the simulation.
Definition: DPMBase.h:1224
Mdouble DPMBase::getTotalEnergy ( ) const

Definition at line 1551 of file DPMBase.cc.

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

1551  {
1553 }
Mdouble getRotationalEnergy() const
JMFT Returns the global rotational energy stored in the system.
Definition: DPMBase.cc:1537
Mdouble getElasticEnergy() const
Returns the global elastic energy within the system.
Definition: DPMBase.cc:1490
Mdouble getGravitationalEnergy() const
Returns the global gravitational potential energy stored in the system.
Definition: DPMBase.cc:1521
Mdouble getKineticEnergy() const
Returns the global kinetic energy stored in the system.
Definition: DPMBase.cc:1504
Mdouble DPMBase::getTotalMass ( ) const

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

Returns
double

Definition at line 1558 of file DPMBase.cc.

References ParticleHandler::getMass(), and particleHandler.

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

1559 {
1560  /*
1561  double mass_sum = 0;
1562  for (std::vector<BaseParticle*>::const_iterator it = particleHandler.begin(); it != particleHandler.end(); ++it)
1563  if (!(*it)->isFixed())
1564  mass_sum += (*it)->getMass();
1565  return mass_sum;
1566  */
1567  return particleHandler.getMass();
1568 }
Mdouble getMass() const
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
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 1584 of file DPMBase.cc.

References ParticleHandler::getMomentum(), and particleHandler.

Referenced by setMeanVelocity(), and setMeanVelocityAndKineticEnergy().

1585 {
1586  return particleHandler.getMomentum();
1587  /*
1588  Vec3D total_momentum = Vec3D(0,0,0);
1589  for (std::vector<BaseParticle*>::const_iterator it = particleHandler.begin(); it != particleHandler.end(); ++it)
1590  if (!(*it)->isFixed())
1591  total_momentum += (*it)->getMass() * (*it)->getVelocity();
1592  return total_momentum;
1593  */
1594 }
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
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 5166 of file DPMBase.cc.

References getKineticStress(), and getStaticStress().

Referenced by StressStrainControlBoundary::computeStrainRate().

5167 {
5168  return getKineticStress() + getStaticStress();
5169 }
Matrix3D getStaticStress() const
Calculate the static stress tensor in the system averaged over the whole volume.
Definition: DPMBase.cc:5146
Matrix3D getKineticStress() const
Calculate the kinetic stress tensor in the system averaged over the whole volume. ...
Definition: DPMBase.cc:5124
Mdouble DPMBase::getTotalVolume ( ) const

Get the total volume of the cuboid system.

Returns
The total volume of the domain.

Definition at line 5115 of file DPMBase.cc.

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

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

5116 {
5117  return (getXMax() - getXMin()) * (getYMax() - getYMin()) * (getZMax() - getZMin());
5118 }
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.h:617
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.h:586
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.h:599
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.h:593
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.h:605
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.h:611
ParticleVtkWriter * DPMBase::getVtkWriter ( ) const

Definition at line 5039 of file DPMBase.cc.

References vtkWriter_.

5040 {
5041  return vtkWriter_;
5042 }
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1263
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 935 of file DPMBase.cc.

References writeWallsVTK_.

Referenced by writePythonFileForVTKVisualisation(), and writeVTKFiles().

936 {
937  return writeWallsVTK_;
938 }
FileType writeWallsVTK_
A flag to turn on/off the vtk writer for walls.
Definition: DPMBase.h:1254
std::string DPMBase::getXBallsAdditionalArguments ( ) const

Returns the additional arguments for xballs.

Returns
xBallsAdditionalArguments_

Definition at line 1315 of file DPMBase.cc.

References xBallsAdditionalArguments_.

Referenced by write().

1316 {
1318 }
std::string xBallsAdditionalArguments_
A string of additional arguments for xballs can be specified (see XBalls/xballs.txt). e.g. "-solidf -v0".
Definition: DPMBase.h:1292
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 1270 of file DPMBase.cc.

References xBallsColourMode_.

1271 {
1272  return xBallsColourMode_;
1273 }
int xBallsColourMode_
XBalls is a package to view the particle data. As an alternative MercuryDPM also supports ParaView...
Definition: DPMBase.h:1277
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 1332 of file DPMBase.cc.

References xBallsScale_.

1333 {
1334  return xBallsScale_;
1335 }
Mdouble xBallsScale_
sets the xballs argument scale (see XBalls/xballs.txt)
Definition: DPMBase.h:1287
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 1290 of file DPMBase.cc.

References xBallsVectorScale_.

1291 {
1292  return xBallsVectorScale_;
1293 }
Mdouble xBallsVectorScale_
sets the xballs argument vscale (see XBalls/xballs.txt)
Definition: DPMBase.h:1282
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 1907 of file DPMBase.cc.

Referenced by computeOneTimeStep().

1908 {
1909 }
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 1900 of file DPMBase.cc.

Referenced by computeOneTimeStep().

1901 {
1902 }
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 1636 of file DPMBase.cc.

Referenced by solve().

1637 {
1638 }
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 1650 of file DPMBase.cc.

Referenced by computeOneTimeStep(), and solve().

1651 {
1652 }
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 936 of file DPMBase.h.

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

937  {};
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 1657 of file DPMBase.cc.

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

1658 {
1659 }
void DPMBase::hGridRemoveParticle ( BaseParticle *obj  UNUSED)
virtual

no implementation but can be overidden in its derived classes.

Definition at line 1671 of file DPMBase.cc.

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

1672 {
1673 }
void DPMBase::hGridUpdateMove ( BaseParticle ,
Mdouble   
)
virtual

no implementation but can be overidden in its derived classes.

Reimplemented in MercuryBase.

Definition at line 1893 of file DPMBase.cc.

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

1894 {
1895 }
void DPMBase::hGridUpdateParticle ( BaseParticle *obj  UNUSED)
virtual

no implementation but can be overidden in its derived classes.

Definition at line 1664 of file DPMBase.cc.

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

1665 {
1666 }
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 4737 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().

4738 {
4739  size_t nParticlesPreviouslyIn = particleHandler.getSize();
4740  int l = 0;
4741  for (auto k = particleH.begin(); k != particleH.end(); ++k) {
4742  auto p = particleHandler.copyAndAddObject( *k );
4743  p->setSpecies(species);
4744  l++;
4745  }
4746 
4747  for (std::vector<BaseInteraction*>::const_iterator i = interactionH.begin(); i != interactionH.end(); ++i) {
4748  if ( (*i)->getP()->getInvMass() != 0.0 && (*i)->getI()->getInvMass() != 0.0 ) {
4750  j->importP(particleHandler.getObject(nParticlesPreviouslyIn + j->getP()->getIndex()));
4751  j->importI(particleHandler.getObject(nParticlesPreviouslyIn + j->getI()->getIndex()));
4752  j->setTimeStamp(getNumberOfTimeSteps());
4753  }
4754  }
4755 }
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:813
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
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:1359
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 617 of file DPMBase.cc.

Referenced by autoNumber().

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

This function is overridden by StatisticsVector

Reimplemented in StatisticsVector< T >.

Definition at line 1845 of file DPMBase.cc.

References cgHandler, and CGHandler::initialise().

Referenced by solve().

1846 {
1848 }
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:1365
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 1771 of file DPMBase.cc.

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

Referenced by ParticleHandler::addObject().

1772 {
1773 #ifdef MERCURY_USE_MPI
1774  //mpi particles only exist when there is more than one domain
1775  if (domainHandler.getSize() > 0)
1776  {
1777  //Add the particle to the mpi domain
1779  }
1780 
1781  //If periodic boundaries are present..
1782  if (periodicBoundaryHandler.getSize() > 0)
1783  {
1785  }
1786 #endif
1787 }
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:1581
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:1354
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1349
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 3194 of file DPMBase.cc.

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

Referenced by computeOneTimeStep().

3195 {
3196  //cycling through all particles, p, in the particleHandler
3197  //for_each(particleHandler.begin(), particleHandler.end(), [this](BaseParticle* p){
3198  #pragma omp parallel for num_threads(getNumberOfOMPThreads()) //schedule(dynamic)
3199  for (int k = 0; k < particleHandler.getNumberOfObjects(); ++k) {
3201 #ifdef MERCURY_USE_MPI
3202  //MPI particles do not require integration - they are updated by the communication step
3203  if (!(p->isMPIParticle() || p->isPeriodicGhostParticle()))
3204  {
3206  }
3207 #else
3208  //using the particle p's internal "integrateAfterForceComputation" function
3209  //to update the relevant parameters concerning the particle's position and motion
3211 #endif
3212  }
3213  //});
3214  //cycling through all walls, w, in the wallHandler
3215  //for_each(wallHandler.begin(), wallHandler.end(), [this](BaseWall* w){
3216  #pragma omp parallel for num_threads(getNumberOfOMPThreads()) //schedule(dynamic)
3217  for (int k = 0; k < wallHandler.getNumberOfObjects(); k++) {
3218  BaseWall *w = wallHandler.getObject(k);
3219  //using the wall's internal "integrateAfterForceComputation" function
3220  //to update the relevant parameters concerning its position and motion
3222  }
3223  //});
3224 }
unsigned int getNumberOfObjects() const override
Returns the number of objects in the container. In parallel code this practice is forbidden to avoid ...
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
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
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:1339
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:1211
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:797
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 3108 of file DPMBase.cc.

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

Referenced by computeOneTimeStep().

3109 {
3110  //cycling through all particles, p, in the particleHandler
3111  //for_each(particleHandler.begin(), particleHandler.end(), [this](BaseParticle* p)
3112  //for (BaseParticle* p : particleHandler) {
3113 
3114  #pragma omp parallel for num_threads(getNumberOfOMPThreads()) //schedule(dynamic)
3115  for (int k = 0; k < particleHandler.getNumberOfObjects(); ++k) {
3117 #ifdef MERCURY_USE_MPI
3118  //MPI particles are not integrated, they are purely ghost particles and get their new velocity and position from an MPI update
3119  if (!(p->isMPIParticle() || p->isPeriodicGhostParticle()))
3120  {
3122  }
3123 #else
3124  //using the particle p's internal "integrateBeforeForceComputation" function
3125  //to update the relevant parameters concerning the particle's position and motion
3127 #endif
3128  }
3129  //});
3130  //cycling through all walls, w, in the wallHandler
3131  //for_each(wallHandler.begin(), wallHandler.end(), [this](BaseWall* w)
3132  //for (BaseWall* w : wallHandler) {
3133  #pragma omp parallel for num_threads(getNumberOfOMPThreads()) //schedule(dynamic)
3134  for (int k = 0; k < wallHandler.getNumberOfObjects(); k++) {
3135  BaseWall *w = wallHandler.getObject(k);
3136  //using the wall's internal "integrateBeforeForceComputation" function
3137  //to update the relevant parameters concerning its position and motion
3139  }
3140  //});
3141 }
unsigned int getNumberOfObjects() const override
Returns the number of objects in the container. In parallel code this practice is forbidden to avoid ...
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:1329
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
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:1339
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:1211
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:797
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 4948 of file DPMBase.cc.

References getTime(), and getTimeStep().

4949 {
4950  return getTime() <= time && getTime() + getTimeStep() > time;
4951 }
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1211
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:797
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 764 of file DPMBase.cc.

765 {
766  //defines an (empty) stringstream named "com"
767  std::stringstream com("");
768  //adds the name of the code to run (fed in as an argument)
769  //to the "com" string and appends the string with " &"
770  com << name << " &";
771  //converts the stringstream "com" to a standard string, and then
772  //converts this string to a C string
773  //the string is then fed to the "system" function, which will run the named command
774  return system(com.str().c_str());
775 }
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 1692 of file DPMBase.cc.

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

Referenced by ParticleHandler::addObject().

1693 {
1694 #ifdef MERCURY_USE_MPI
1695  //If only one core is used (i.e. domainHandler is empty) then the result is always true
1696  if (domainHandler.getSize() == 0)
1697  {
1698  return true;
1699  }
1700  //Get the current domain
1702 
1703  //Check if the particle is in the current domain
1704  if(domain->containsParticle(P))
1705  {
1706  //When adding a particle inside the domain, this should always be true
1707  return true;
1708  }
1709  else
1710  {
1711  //MPI particles that are inserted in the communication zone should still be inserted
1712  return (P->isMPIParticle());
1713  }
1714 #else
1715  return false;
1716 #endif
1717 }
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:1354
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 1724 of file DPMBase.cc.

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

1725 {
1726 
1727  bool insideCommunicationZone = false;
1728 #ifdef MERCURY_USE_MPI
1729  MPIContainer& communicator = MPIContainer::Instance();
1730 
1731  //Check for the current domain if the particle is within the communication domain
1732  int val = domainHandler.getCurrentDomain()->isInCommunicationZone(particle);
1733 
1734  //The root gathers all results
1735  int *list = nullptr;
1736  if (PROCESSOR_ID == 0)
1737  {
1738  list = new int [NUMBER_OF_PROCESSORS];
1739  }
1740  communicator.gather(val,list);
1741 
1742  //Compute the global value
1743  //if on any processor the val is true, we have to do the communcation step
1745  int result = 0;
1746  if (PROCESSOR_ID == 0)
1747  {
1748  for (int i = 0; i< NUMBER_OF_PROCESSORS; i++)
1749  {
1750  if (list[i] == 1)
1751  {
1752  result = 1;
1753  break;
1754  }
1755  }
1756  }
1757 
1758  //The root now tells the other processors what the global value for the interaction is
1759  communicator.broadcast(result);
1760 
1761  //Convert the result back to bool
1762  insideCommunicationZone = result;
1763 #endif
1764  return insideCommunicationZone;
1765 }
This class contains all information and functions required for communication between processors...
Definition: MpiContainer.h:125
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
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:1354
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:416
#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:429
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 4927 of file DPMBase.cc.

References interactionHandler.

4928 {
4929  std::cout << "Interactions currently in the handler:" << std::endl;
4930  //looping over all individual objects in the interactionHandler
4932  {
4933  p->write(std::cout);
4934  std::cout << std::endl;
4935  std::cout << "Interaction " << p->getName() << " " << p->getId() << " between " << p->getP()->getId() << " and "
4936  << p->getI()->getId() << std::endl;
4937  }
4938 }
Stores information about interactions between two interactable objects; often particles but could be ...
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1359
void DPMBase::outputStatistics ( )
protectedvirtual

This function is overridden by StatisticsVector

Reimplemented in StatisticsVector< T >.

Definition at line 1853 of file DPMBase.cc.

1854 {
1855  //cgHandler.evaluate();
1856 }
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 2240 of file DPMBase.cc.

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

Referenced by writeDataFile().

2241 {
2242 
2243 
2244  //Set the correct formation based of dimension if the formation is not specified by the user
2245 
2246  unsigned int format;
2247  switch (getSystemDimensions())
2248  {
2249  case 2:
2250  format = 8;
2251  break;
2252  case 3:
2253  format = 14;
2254  break;
2255  default:
2256  std::cerr << "Unknown system dimension" << std::endl;
2257  exit(-1);
2258  }
2259 
2260  unsigned int numberOfParticles = particleHandler.getNumberOfRealObjectsLocal();
2261 
2262  // This outputs the location of walls and how many particles there are to file this is required by the xballs plotting
2263  if (format != 14) // dim = 1 or 2
2264  {
2265  os << numberOfParticles
2266  << " " << getTime()
2267  << " " << getXMin()
2268  << " " << getYMin()
2269  << " " << getXMax()
2270  << " " << getYMax()
2271  << " " << std::endl;
2272  }
2273  else
2274  {
2275  //dim==3
2276  os << numberOfParticles
2277  << " " << getTime()
2278  << " " << getXMin()
2279  << " " << getYMin()
2280  << " " << getZMin()
2281  << " " << getXMax()
2282  << " " << getYMax()
2283  << " " << getZMax()
2284  << " " << std::endl;
2285  }
2286 
2287  // This outputs the particle data
2288  for (unsigned int i = 0; i < particleHandler.getSize(); i++)
2289  {
2290 #ifdef MERCURY_USE_MPI
2292  {
2293  outputXBallsDataParticle(i, format, os);
2294  }
2295 #else
2296  outputXBallsDataParticle(i, format, os);
2297 #endif
2298  }
2299 #ifdef DEBUG_OUTPUT
2300  std::cerr << "Have output the properties of the problem to disk " << std::endl;
2301 #endif
2302 }
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:1390
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.h:617
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.h:586
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:599
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:593
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
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:605
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.h:611
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:797
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 4848 of file DPMBase.cc.

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

Referenced by computeOneTimeStep().

4849 {
4850 #ifdef MERCURY_USE_MPI
4851  //MPIContainer& communicator = MPIContainer::Instance();
4852  if (NUMBER_OF_PROCESSORS == 1) {return;}
4853 
4854  //Update the postion and velocity data of ghosts and perform some bookkeeping
4855  std::set<BaseParticle*> particlesToBeDeleted;
4856  domainHandler.updateStatus(particlesToBeDeleted);
4857  periodicBoundaryHandler.updateStatus(particlesToBeDeleted);
4858 
4859  //Delete particles
4860  deleteGhostParticles(particlesToBeDeleted);
4861 
4862  //Add new particles
4865 #endif
4866 }
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1354
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:1349
#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:4871
void DPMBase::performGhostVelocityUpdate ( )
protected

updates the final time-step velocity of the ghost particles

Definition at line 4913 of file DPMBase.cc.

References NUMBER_OF_PROCESSORS.

4914 {
4915 #ifdef MERCURY_USE_MPI
4916  if (NUMBER_OF_PROCESSORS == 1) {return;}
4917  //TODO If required, I can implement this for periodic particles, first discuss with Thomas if it is actually requiredf
4918  //periodicDomainHandler.updateVelocity()
4919  //domainHandler.updateVelocity();
4920 #endif
4921 }
#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 1930 of file DPMBase.cc.

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

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

1931 {
1932 #ifdef MERCURY_USE_MPI
1933  MPIContainer& communicator = MPIContainer::Instance();
1934  if (communicator.getProcessorID() == 0)
1935  {
1936 #endif
1937  std::cout << "t=" << std::setprecision(3) << std::left << std::setw(6) << getTime()
1938  << ", tmax=" << std::setprecision(3) << std::left << std::setw(6) << getTimeMax()
1939  << std::endl;
1940  std::cout.flush();
1941 #ifdef MERCURY_USE_MPI
1942  }
1943 #endif
1944 }
This class contains all information and functions required for communication between processors...
Definition: MpiContainer.h:125
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
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:797
Mdouble getTimeMax() const
Returns the maximum simulation duration.
Definition: DPMBase.cc:855
void DPMBase::processStatistics ( bool  )
protectedvirtual

This function is overridden by StatisticsVector

Reimplemented in StatisticsVector< T >.

Definition at line 1878 of file DPMBase.cc.

1879 {
1880 }
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 3496 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().

3497 {
3498 #ifdef MERCURY_USE_MPI
3499  int previousNumberOfProcessors;
3500 #endif
3501  //Declares...
3502  std::string dummy;
3503  //...and reads in a dummy variable from the start of the stream "is"
3504  is >> dummy;
3505  //compare the string read in to the phrase "restart_version" to see if the stream corresponds
3506  //to a restart file (all restart files begin with this phrase)
3507  //if both strings match, strcmp(dummy.c_str(), "restart_version") returns 0 (here read as "false")
3508  if (dummy != "restart_version" && dummy != "MercuryDPM")
3509  {
3510  //If the strings do not match, if statement is fulfilled and the error logged
3511  //Note: only very old files did not have a restart_version
3512  logger(FATAL, "Error in DPMBase::read(is): this is not a valid restart file");
3513  }
3514  else
3515  {
3516  //reads in the restart version (earlier versions of Mercury possess different file formats!)
3517  is >> restartVersion_;
3518  //checking which version the current data file corresponds to, and reads the data in
3519  //accordingly
3520  if (restartVersion_ == "1.0" || restartVersion_ == "0.14")
3521  {
3522  //reads in and saves the relevant values from the data file to the current instance of DPMBase
3523  std::stringstream line;
3524 
3525  // Store path (if restart file is nonlocal)
3526  auto slash = restartFile.getName().rfind('/');
3527  std::string path;
3528  if (slash != std::string::npos)
3529  {
3530  path = restartFile.getName().substr(0, slash + 1);
3531  }
3532  if (!path.empty())
3533  {
3534  logger(INFO, "Adding path information (%) to file names", path);
3535  }
3536 
3537  //line 1
3539  //discards the whitespace (ws) at the start of the stream
3540  line >> std::ws;
3541  //uses the "peek" function to access the stream's first
3542  //non-whitespace character, and check if it is an "r"
3543  if (line.peek() == 'r')
3544  //if so, reads in the current run number
3545  line >> dummy >> runNumber_;
3546  //In either case, then uses the "Files" version of the read function
3547  //to read in the rest of the relevant information.
3548  line >> dummy >> name_;
3549  setName(name_);
3550 
3551  //Read line 2-7 (definition of i/o files)
3553  line >> dummy >> dataFile;
3555  line >> dummy >> fStatFile;
3557  line >> dummy >> eneFile;
3559  line >> dummy >> restartFile;
3561  line >> dummy >> statFile;
3562 
3563  // Add the file path from the restart file to the file names
3564  dataFile.setName(path + dataFile.getName());
3565  fStatFile.setName(path + fStatFile.getName());
3566  eneFile.setName(path + eneFile.getName());
3567  restartFile.setName(path + restartFile.getName());
3568  statFile.setName(path + statFile.getName());
3569 
3570  // Get current position
3571  //check if the next line starts with 'interactionFile'; otherwise, skip interaction
3572  if (helpers::compare(is, "interactionFile"))
3573  {
3575  line >> interactionFile;
3576  interactionFile.setName(path + interactionFile.getName());
3577  }
3578 
3580  line >> dummy >> min_.x()
3581  >> dummy >> max_.x()
3582  >> dummy >> min_.y()
3583  >> dummy >> max_.y()
3584  >> dummy >> min_.z()
3585  >> dummy >> max_.z();
3586 
3588  line >> dummy >> timeStep_
3589  >> dummy >> time_
3590  >> dummy >> numberOfTimeSteps_
3591  >> dummy >> timeMax_;
3592 
3594  line >> dummy >> systemDimensions_
3595  >> dummy >> particleDimensions_
3596  >> dummy >> gravity_;
3597 
3598  line >> dummy;
3599  if (!dummy.compare("writeVTK"))
3600  {
3601  FileType writeInteractionsVTK = FileType::NO_FILE;
3602  unsigned particlesCounter, wallCounter, interactionCounter;
3603  bool writeBoundaryVTK;
3604  line >> writeParticlesVTK_ >> writeWallsVTK_ >> writeInteractionsVTK >> writeBoundaryVTK >> particlesCounter >> wallCounter >> interactionCounter;
3605  line.clear();//because the number of arguments in writeVTK has changed
3606  line >> dummy;
3609  interactionHandler.setWriteVTK(writeInteractionsVTK);
3610  boundaryHandler.setWriteVTK(writeBoundaryVTK);
3611  vtkWriter_->setFileCounter(particlesCounter);
3612  wallVTKWriter_.setFileCounter(particlesCounter);
3613  interactionVTKWriter_.setFileCounter(particlesCounter);
3614  boundaryVTKWriter_.setFileCounter(particlesCounter);
3615  }
3616  if (!dummy.compare("random"))
3617  {
3618  random.read(line);
3619  line >> dummy;
3620  }
3621 
3622 #ifdef MERCURY_USE_OMP
3623  //Read the number of OMP threads
3624  if (!dummy.compare("numberOfOMPThreads")) {
3625  int numberOfOMPThreads;
3626  line >> numberOfOMPThreads;
3627  setNumberOfOMPThreads(numberOfOMPThreads);
3628  //logger(INFO," Check the number of OMP threads = % ", getNumberOfOMPThreads());
3629  }
3630 #endif
3631 #ifdef MERCURY_USE_MPI
3632  if (!dummy.compare("numberOfProcessors"))
3633  {
3634  line >> previousNumberOfProcessors
3635  >> dummy >> numberOfDomains_[Direction::XAXIS]
3638  }
3639  else
3640  {
3641  logger(INFO,"Reading a serial restart file");
3642  //numberOfDomains_ = {1,1,1};
3643  }
3644 #endif
3645  if (!dummy.compare("xBallsArguments")) {
3647  setXBallsAdditionalArguments(line.str());
3648  }
3649 
3650  speciesHandler.read(is);
3651 
3652 #ifdef MERCURY_USE_MPI
3653  //Initialise MPI structures and perform domain decomposition
3654  decompose();
3655 #endif
3656 
3657  //reading in the various relevant handlers
3658  unsigned int N;
3659  is >> dummy >> N;
3660  if (dummy.compare("Walls"))
3661  logger(ERROR, "DPMBase::read(is): Error during restart: 'Walls' argument could not be found.");
3662  wallHandler.clear();
3665  for (unsigned int i = 0; i < N; i++)
3666  {
3669  }
3670 
3671  is >> dummy >> N;
3674  if (dummy.compare("Boundaries"))
3675  logger(ERROR, "DPMBase::read(is): Error during restart: 'Boundaries' argument could not be found.");
3677  for (unsigned int i = 0; i < N; i++)
3678  {
3681  }
3682 
3684 
3685  is >> dummy >> N;
3686  is.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
3687  //display a message if a large amount o fparticles is read
3688  if (N>2.5e5) logger(INFO, "Reading % particles (may take a while)",N);
3689  logger.assert_always(dummy.compare("Particles")==0, "DPMBase::read(is): Error during restart: 'Particles' argument could not be found. %",dummy);
3692  for (unsigned int i = 0; i < N; i++)
3693  {
3694  //ParticleHandler::readAndCreateObject reads line-by-line
3696  //skip the remaining data in line
3697  is.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
3699  //particleHandler.getLastObject()->computeMass();
3700  }
3701 #ifdef MERCURY_USE_MPI
3702  //Interaction distances of the domainHandler and periodicBoundaryHandler need to be set
3703  Mdouble interactionRadius = particleHandler.getLargestInteractionRadius();
3704  domainHandler.setInteractionDistance(2.0*interactionRadius);
3705  periodicBoundaryHandler.setInteractionDistance(2.0*interactionRadius);
3706 
3707  if (NUMBER_OF_PROCESSORS > 1)
3708  {
3709  //Create ghost particles
3712  }
3713 #endif
3714  //Add interactions to particles and ghost particles
3715  if (opt==ReadOptions::ReadNoInteractions) return;
3717  }
3718  //reading in for older versions of the Mercury restart file.
3719  else if (!restartVersion_.compare("3"))
3720  {
3721  logger(INFO, "DPMBase::read(is): restarting from an old restart file (restart_version %).",
3722  restartVersion_);
3723  readOld(is);
3724  }
3725  //returning an error if there is no restart file to read in due to the use of outdated files.
3726  else
3727  {
3728  //only very old files did not have a restart_version
3729  logger(FATAL,
3730  "Error in DPMBase::read(is): restart_version % cannot be read; use an older version of Mercury to upgrade the file",
3731  restartVersion_);
3732  }
3733  }
3734 }
Mdouble timeMax_
Stores the duration of the simulation.
Definition: DPMBase.h:1224
void setFileCounter(unsigned fileCounter)
Definition: BaseVTKWriter.h:61
void setWallsWriteVTK(FileType writeWallsVTK)
Sets whether walls are written into a VTK file.
Definition: DPMBase.cc:878
void read(std::istream &is)
Definition: RNG.cc:59
std::string name_
the name of the problem, used, e.g., for the output files
Definition: DPMBase.h:1302
void readAndAddObject(std::istream &is) final
Create a new wall in the WallHandler, based on the information provided in a restart file...
Definition: WallHandler.cc:276
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Vec3D max_
Definition: DPMBase.h:1204
double Mdouble
Definition: GeneralDefine.h:34
unsigned int particleDimensions_
determines if 2D or 3D particle volume is used for mass calculations
Definition: DPMBase.h:1188
void read(std::istream &is)
void setStorageCapacity(const unsigned int N)
Sets the storage capacity of this BaseHandler.
Definition: BaseHandler.h:669
virtual void decompose()
Sends particles from processorId to the root processor.
Definition: DPMBase.cc:3885
void setParticlesWriteVTK(bool writeParticlesVTK)
Sets whether particles are written in a VTK file.
Definition: DPMBase.cc:904
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
WallVTKWriter wallVTKWriter_
Definition: DPMBase.h:1265
File interactionFile
File class to handle in- and output into .interactions file. This file hold information about interac...
Definition: DPMBase.h:1396
virtual void readOld(std::istream &is)
Reads all data from a restart file, e.g. domain data and particle data; old version.
Definition: DPMBase.cc:3739
InteractionVTKWriter interactionVTKWriter_
Definition: DPMBase.h:1267
int runNumber_
This stores the run number for saving.
Definition: DPMBase.h:1297
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1354
std::vector< unsigned > numberOfDomains_
Vector containing the number of domains in x-,y- and z-direction, required for parallel computations...
Definition: DPMBase.h:1198
void clear() override
Empties the whole ParticleHandler by removing all BaseParticle.
void read(std::istream &is)
Reads all objects from restart data.
Definition: BaseHandler.h:543
Mdouble & z()
RW reference to Z.
Definition: Vector.h:368
void addNewParticles()
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1214
FileType
With FileType options, one is able to choose if data is to be read/written from/into no or single or ...
Definition: File.h:40
unsigned int systemDimensions_
The dimensions of the simulation i.e. 2D or 3D.
Definition: DPMBase.h:1183
void readAndAddObject(std::istream &is) final
Reads BaseBoundary into the BoundaryHandler from restart data.
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1370
file will not be created/read
void setWriteVTK(bool writeVTK)
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1375
void getLineFromStringStream(std::istream &in, std::stringstream &out)
Reads a line from one stringstream into another, and prepares the latter for reading in...
Definition: Helpers.cc:424
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1344
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:1349
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1263
BoundaryVTKWriter boundaryVTKWriter_
Definition: DPMBase.h:1269
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
void readAndAddObject(std::istream &is) override
Create a new particle, based on the information from old-style restart data.
Mdouble & x()
RW reference to X.
Definition: Vector.h:344
Mdouble time_
Stores the current simulation time.
Definition: DPMBase.h:1209
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1319
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1359
FileType writeWallsVTK_
A flag to turn on/off the vtk writer for walls.
Definition: DPMBase.h:1254
void setNumberOfOMPThreads(int numberOfOMPThreads)
Definition: DPMBase.cc:1218