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  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 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...
 
int readRunNumberFromFile ()
 Read the run number or the counter from the counter file (COUNTER_DONOTDEL) More...
 
void autoNumber ()
 The autoNumber() function calls three functions: setRunNumber(), readRunNumberFromFile() and incrementRunNumberInFile(). More...
 
std::vector< int > get2DParametersFromRunNumber (int size_x, int size_y)
 This turns a counter into two indices which is a very useful feature for performing two-dimensional parameter studies. 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...
 
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 ()
 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)
 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)
 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...
 
bool readNextDataFileMPI (unsigned int format=0)
 
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 (const 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 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...
 
bool areInContact (const BaseParticle *pI, const BaseParticle *pJ) const
 Checks if two particle are in contact or is there any positive overlap. 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...
 
void setReadInteractions (const bool readInteractions)
 
bool getReadInteractions () const
 

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

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_
 
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...
 
bool readInteractions_ = true
 

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

Member Enumeration Documentation

enum DPMBase::DomainSplit
strong
Enumerator
XY 
XZ 
YZ 
XYZ 

Definition at line 883 of file DPMBase.h.

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

References constructor().

192 {
193  constructor();
194 }
void constructor()
A function which initialises the member variables to default values, so that the problem can be solve...
Definition: DPMBase.cc:204
WallVTKWriter wallVTKWriter_
Definition: DPMBase.h:1234
InteractionVTKWriter interactionVTKWriter_
Definition: DPMBase.h:1236
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1326
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1306
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 122 of file DPMBase.cc.

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

124 {
125  setName(other.getName());
126  runNumber_ = other.runNumber_;
129  gravity_ = other.gravity_;
130 /* xMin_ = other.xMin_;
131  xMax_ = other.xMax_;
132  yMin_ = other.yMin_;
133  yMax_ = other.yMax_;
134  zMin_ = other.zMin_;
135  zMax_ = other.zMax_;*/
136  min_ = other.min_;
137  max_ = other.max_;
139  time_ = other.time_;
140  timeStep_ = other.timeStep_;
142  timeMax_ = other.timeMax_;
143  restartVersion_ = other.restartVersion_; //to read new and old restart data
144  restarted_ = other.restarted_; //to see if it was restarted or not
145  append_ = other.append_;
146  rotation_ = other.rotation_;
147  xBallsColourMode_ = other.xBallsColourMode_; // sets the xballs argument cmode (see xballs.txt)
148  xBallsVectorScale_ = other.xBallsVectorScale_; // sets the xballs argument vscale (see xballs.txt)
149  xBallsScale_ = other.xBallsScale_; // sets the xballs argument scale (see xballs.txt)
150  xBallsAdditionalArguments_ = other.xBallsAdditionalArguments_; // std::string where additional xballs argument can be specified (see xballs.txt)
153 
154 //effectively saying "if there exists a CONTACT_LIST_HGRID, copy it, if not, ignore.
155 #ifdef CONTACT_LIST_HGRID
156  possibleContactList=other.possibleContactList;
157 #endif
158  random = other.random;
159 
164  wallHandler.setDPMBase(this);
167  //Initialise the handlers
170 
171  //setting contents equal to the other handlers!
174  cgHandler = other.cgHandler;
175  //cgHandler = other.cgHandler.copy(); //todo
176  //cgHandler.setDPMBase(this);
177  wallHandler = other.wallHandler;
180  vtkWriter_ = other.vtkWriter_;
184 }
Mdouble timeMax_
Stores the duration of the simulation.
Definition: DPMBase.h:1193
Vec3D max_
Definition: DPMBase.h:1173
unsigned int particleDimensions_
determines if 2D or 3D particle volume is used for mass calculations
Definition: DPMBase.h:1157
void setDPMBase(DPMBase *DPMBase)
Sets the problem that is solved using this handler.
Definition: BaseHandler.h:718
WallVTKWriter wallVTKWriter_
Definition: DPMBase.h:1234
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:391
InteractionVTKWriter interactionVTKWriter_
Definition: DPMBase.h:1236
int runNumber_
This stores the run number for saving.
Definition: DPMBase.h:1264
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1321
std::vector< unsigned > numberOfDomains_
Vector containing the number of domains in x-,y- and z-direction, required for parallel computations...
Definition: DPMBase.h:1167
bool rotation_
A flag to turn on/off particle rotation. true will enable particle rotation. false will disable parti...
Definition: DPMBase.h:1218
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1183
bool restarted_
A bool to check if the simulation was restarted or not, ie. if setupInitialConditionsShould be run an...
Definition: DPMBase.h:1205
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:1152
bool writeSuperquadricParticlesVTK_
Definition: DPMBase.h:1230
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1332
int xBallsColourMode_
XBalls is a package to view the particle data. As an alternative MercuryDPM also supports ParaView...
Definition: DPMBase.h:1244
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1311
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1316
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1232
Mdouble xBallsScale_
sets the xballs argument scale (see XBalls/xballs.txt)
Definition: DPMBase.h:1254
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
Mdouble time_
Stores the current simulation time.
Definition: DPMBase.h:1178
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1286
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1326
FileType writeWallsVTK_
A flag to turn on/off the vtk writer for walls.
Definition: DPMBase.h:1223
Mdouble xBallsVectorScale_
sets the xballs argument vscale (see XBalls/xballs.txt)
Definition: DPMBase.h:1249
Mdouble timeStep_
Stores the simulation time step.
Definition: DPMBase.h:1188
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1306
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:1291
bool writeParticlesVTK_
A flag to turn on/off the vtk writer for particles.
Definition: DPMBase.h:1228
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:414
std::string xBallsAdditionalArguments_
A string of additional arguments for xballs can be specified (see XBalls/xballs.txt). e.g. "-solidf -v0".
Definition: DPMBase.h:1259
std::string restartVersion_
Previous versions of MercuryDPM had a different restart file format, the below member variable allows...
Definition: DPMBase.h:1200
Vec3D min_
These vectors are used for the XBalls domain, and occasionally people use it to add walls...
Definition: DPMBase.h:1172
Vec3D gravity_
Gravity vector.
Definition: DPMBase.h:1162
bool append_
A flag to determine if the file has to be appended or not. See DPMBase::Solve() for example...
Definition: DPMBase.h:1211
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 289 of file DPMBase.cc.

References vtkWriter_.

290 {
291  delete vtkWriter_;
292 }
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1232

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

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

1726 {
1727 }
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 1732 of file DPMBase.cc.

Referenced by computeOneTimeStep().

1733 {
1734 }
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 1523 of file DPMBase.cc.

Referenced by solve().

1524 {
1525 }
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 1718 of file DPMBase.cc.

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

1719 {
1720 }
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 1537 of file DPMBase.cc.

Referenced by solve().

1538 {
1539 }
bool DPMBase::areInContact ( const BaseParticle pI,
const BaseParticle pJ 
) const

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

References BaseParticle::isInContactWith().

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

1516 {
1517  return (pI != pJ && pI->isInContactWith(pJ));
1518 }
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 526 of file DPMBase.cc.

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

Referenced by readNextArgument().

527 {
530 }
void incrementRunNumberInFile()
Increment the run Number (counter value) stored in the file_counter (COUNTER_DONOTDEL) by 1 and store...
Definition: DPMBase.cc:611
int readRunNumberFromFile()
Read the run number or the counter from the counter file (COUNTER_DONOTDEL)
Definition: DPMBase.cc:536
void setRunNumber(int runNumber)
This sets the counter/Run number, overriding the defaults.
Definition: DPMBase.cc:589
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 4638 of file DPMBase.cc.

References boundaryHandler, and particleHandler.

Referenced by computeOneTimeStep(), and solve().

4639 {
4640  //Looping over all boundaries in the boundaryHandler
4641  for (BaseBoundary* boundary : boundaryHandler)
4642  {
4643  //Calls the createPeriodicParticles() function which checks if a particle is adequately
4644  //close to a periodic particle that a periodic (ghost) particle should be created and,
4645  //if so, creates one and adds it to the system (hence the necessity to keep "N" variable).
4646  //
4647  // (The loop is over all boundaries, but if a boundary is not a PeriodicBoundary, then
4648  // this does nothing.)
4649  boundary->createPeriodicParticles(particleHandler);
4650  }
4651 }
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1311
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
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 3057 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().

3058 {
3059 
3060  //Cycling over all boundaries within the system...
3061  for (BaseBoundary* b : boundaryHandler)
3062  {
3063  //check all boundaries...
3064  b->checkBoundaryAfterParticlesMove(particleHandler);
3065 
3066 
3067 #ifdef MERCURY_USE_MPI
3068  //When ghost particles are deleted by deletion boundaries they need to be removed
3069  //from their communication lists to avoid segfaults
3070  if (NUMBER_OF_PROCESSORS > 1)
3071  {
3072  //Flush deleted particles from mpi communication zones
3073  getCurrentDomain()->flushParticles(b->getParticlesToBeDeleted());
3075  periodicBoundaryHandler.flushParticles(b->getParticlesToBeDeleted());
3077  }
3078 
3079  //Delete particles that were in communication zone
3080  for (auto p_it = b->getParticlesToBeDeleted().begin(); p_it != b->getParticlesToBeDeleted().end(); p_it++)
3081  {
3082  particleHandler.removeGhostObject((*p_it)->getIndex());
3083  }
3084 #endif
3085  }
3086 }
Domain * getCurrentDomain()
Function that returns a pointer to the domain corresponding to the processor.
Definition: DPMBase.cc:4842
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:1311
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1316
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
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:59
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 4425 of file DPMBase.cc.

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

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

4426 {
4427 #ifdef MERCURY_USE_MPI
4428  if (NUMBER_OF_PROCESSORS == 1)
4429  {
4431  }
4432 
4433  int localInteraction = checkParticleForInteractionLocal(p);
4434 
4435  //The root gathers all values and computes the global value
4436  int *interactionList = nullptr;
4437  if (PROCESSOR_ID == 0)
4438  {
4439  interactionList = new int [NUMBER_OF_PROCESSORS];
4440  }
4441 
4442  //Gather all local values
4443  MPIContainer::Instance().gather(localInteraction,interactionList);
4444 
4445  //Compute the global value
4446  int globalInteraction = 1;
4447  if (PROCESSOR_ID == 0)
4448  {
4449  for (int i = 0; i < NUMBER_OF_PROCESSORS; i++)
4450  {
4451  if (interactionList[i] == 0)
4452  {
4453  globalInteraction = 0;
4454  break;
4455  }
4456  }
4457  }
4458  //The root now tells the other processors what the global value for the interaction is
4459  MPIContainer::Instance().broadcast(globalInteraction);
4460 
4461  //Convert the result back to bool
4462  bool interaction = globalInteraction;
4463 #else
4464  bool interaction = checkParticleForInteractionLocalPeriodic(p);
4465 #endif
4466  return interaction;
4467 }
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:60
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:59
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:4475
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:4525
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 4525 of file DPMBase.cc.

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

Referenced by checkParticleForInteraction(), and checkParticleForInteractionLocalPeriodic().

4526 {
4527  Mdouble distance;
4528  Vec3D normal;
4529 
4530  //Check if it has no collision with walls
4531  for (BaseWall* w : wallHandler)
4532  {
4533  //returns false if the function getDistanceAndNormal returns true,
4534  //i.e. if there exists an interaction between wall and particle
4535  //\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.)
4536  if (w->getDistanceAndNormal(p, distance, normal))
4537  {
4538  //std::cout<<"failure: Collision with wall: "<<**it<<std::endl;
4539  return false;
4540  }
4541  else
4542  {
4543  //std::cout<<"No collision with wall: "<<**it<<std::endl;
4544  }
4545  }
4546 
4547  //Check if it has no collision with other particles
4548  for (BaseParticle* q : particleHandler)
4549  {
4550  //returns false if the particle separation is less than the relevant sum of interaction radii
4551  //(i.e. another particle is in contact with P)
4552  if (Vec3D::getDistanceSquared(q->getPosition(), p.getPosition())
4554  {
4555  //std::cout<<"failure: Collision with particle "<<**it<<std::endl;
4556  return false;
4557  }
4558  else
4559  {
4560  //std::cout<<"No collision with particle "<<**it<<std::endl;
4561  }
4562  }
4563  return true;
4565 }
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:1296
Basic class for walls.
Definition: BaseWall.h:47
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1306
static Mdouble getDistanceSquared(const Vec3D &a, const Vec3D &b)
Calculates the squared distance between two Vec3D: .
Definition: Vector.cc:237
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 4475 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().

4476 {
4477  //A vector of ghost particles of the particle that is to be inserted (empty if no periodic boundaries are present)
4478  std::vector<Vec3D> pPeriodic;
4479  for (BaseBoundary* b : boundaryHandler)
4480  {
4481  PeriodicBoundary* pb = dynamic_cast<PeriodicBoundary*>(b);
4482  if (pb && particleHandler.getNumberOfObjects() > 0 )
4483  {
4485  for (int i = pPeriodic.size() - 1; i >= 0; --i)
4486  {
4487  if (pb->getDistance(pPeriodic[i]) < maxDistance)
4488  {
4489  pPeriodic.push_back(pPeriodic[i]);
4490  pb->shiftPosition(pPeriodic.back());
4491  }
4492  }
4493  if (pb->getDistance(p) < maxDistance)
4494  {
4495  pPeriodic.push_back(p.getPosition());
4496  pb->shiftPosition(pPeriodic.back());
4497  }
4498  }
4499  }
4500  //check the particle AND the ghost particles for intersection problems
4501  bool insertable = checkParticleForInteractionLocal(p);
4502  if (!pPeriodic.empty()) {
4503  BaseParticle* q = p.copy();
4504  for (const Vec3D& pos : pPeriodic) {
4505  q->setPosition(pos);
4506  insertable &= checkParticleForInteractionLocal(*q);
4507  }
4508  delete q;
4509  }
4510  return insertable;
4511 }
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:1311
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
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:4525
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 3634 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().

3635 {
3636  //check if name is set
3637  logger.assert_always(getName() != "",
3638  "File name not set: use setName()");
3639  //check if time step is set
3640  logger.assert_always(getTimeStep() != 0,
3641  "Time step undefined: use setTimeStep()");
3642  //check if domain is set
3643  logger.assert_always(getXMax() > getXMin(),
3644  "Domain size not set: use setXMin() and setXMax()");
3645  logger.assert_always(getYMax() > getYMin(),
3646  "Domain size not set: use setYMin() and setYMax()");
3647  logger.assert_always(systemDimensions_ == 3 ? (getZMax() > getZMin()) : (getZMax() >= getZMin()),
3648  "Domain size not set: use setZMin() and setZMax()", systemDimensions_);
3649 
3650  //check for species parameters
3651  logger.assert_always(speciesHandler.getNumberOfObjects() > 0,
3652  "No species defined: use speciesHandler.copyAndAddObject()");
3653  for (BaseParticle* p : particleHandler)
3654  {
3655  logger.assert_always(p->getSpecies() != nullptr, "particle % has no species", p->getId());
3656  }
3657  for (BaseWall* w : wallHandler)
3658  {
3659  logger.assert_always(w->getSpecies() != nullptr, "% with index % has no species", w->getName(), w->getId());
3660  }
3661 }
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:594
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.h:563
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.h:576
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:391
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.h:570
unsigned int systemDimensions_
The dimensions of the simulation i.e. 2D or 3D.
Definition: DPMBase.h:1152
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
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:1286
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.h:582
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1306
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.h:588
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1141
void DPMBase::closeFiles ( )

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

Definition at line 490 of file DPMBase.cc.

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

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

491 {
492  dataFile.close();
493  fStatFile.close();
494  restartFile.close();
495  statFile.close();
496  eneFile.close();
498 }
File interactionFile
File class to handle in- and output into .interactions file. This file hold information about interac...
Definition: DPMBase.h:1363
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:1337
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1342
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: DPMBase.h:1357
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1347
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1352
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 3176 of file DPMBase.cc.

References computeExternalForces(), computeInternalForces(), computeWallForces(), PossibleContact::getNext(), PossibleContact::getP1(), PossibleContact::getP2(), particleHandler, and wallHandler.

Referenced by computeOneTimeStep(), and solve().

3177 {
3178  //Resetting all forces on both particles and walls to zero
3179  for (BaseParticle* const p : particleHandler)
3180  {
3181  p->setForce(Vec3D(0.0, 0.0, 0.0));
3182  p->setTorque(Vec3D(0.0, 0.0, 0.0));
3183  }
3184  for (BaseWall* const w : wallHandler)
3185  {
3186  w->setForce(Vec3D(0.0, 0.0, 0.0));
3187  w->setTorque(Vec3D(0.0, 0.0, 0.0));
3188  } //end reset forces loop
3189 
3190 #ifdef DEBUG_OUTPUT
3191  std::cerr << "Have all forces set to zero " << std::endl;
3192 #endif
3193 
3194 
3196 
3197  for (BaseParticle* p : particleHandler)
3198  {
3199  //computing both internal forces (e.g. due to collisions)
3200  //and external forces (e.g. gravity)
3201  //(compute internal forces compares the current particle p
3202  //with all others in the handler!)
3204  // body forces
3206  }
3207 
3208  // wall-forces
3209  for (BaseWall* w : wallHandler)
3210  {
3211  computeWallForces(w);
3212  }
3213 
3214 #ifdef CONTACT_LIST_HGRID
3215  PossibleContact* Curr=possibleContactList.getFirstPossibleContact();
3216  while(Curr)
3217  {
3218  computeInternalForces(Curr->getP1(),Curr->getP2());
3219  Curr=Curr->getNext();
3220  }
3221 #endif
3222  //end outer loop over contacts.
3223 }
virtual void computeExternalForces(BaseParticle *)
Computes the external forces, such as gravity, acting on particles.
Definition: DPMBase.cc:2963
BaseParticle * getP1()
Gets a pointer to the first BaseParticle in this PossibleContact.
virtual void computeWallForces(BaseWall *w)
Definition: DPMBase.cc:4980
BaseParticle * getP2()
Gets a pointer to the second BaseParticle in this PossibleContact.
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:1296
Basic class for walls.
Definition: BaseWall.h:47
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1306
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:3231
Class that describes a possible contact between two BaseParticle.
Definition: Vector.h:49
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 2963 of file DPMBase.cc.

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

Referenced by computeAllForces().

2964 {
2965  //Checks that the current particle is not "fixed"
2966  //and hence infinitely massive!
2967  if (!CI->isFixed())
2968  {
2969  // Applying the force due to gravity (F = m.g)
2970  CI->addForce(getGravity() * CI->getMass());
2971  // Still calls this in compute External Forces.
2972  // computeForcesDueToWalls(CI);
2973  }
2974 }
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:1245
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 2983 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().

2984 {
2985  //No need to compute interactions between periodic particle images and walls
2986  if (pI->getPeriodicFromParticle() != nullptr)
2987  return;
2988 
2989  //Checks if the particle is interacting with the current wall
2992  if (i!=nullptr) {
2993  //...calculates the forces between the two objects...
2994  i->computeForce();
2995 
2996  //...and applies them to each of the two objects (wall and particle).
2997  pI->addForce(i->getForce());
2998  w->addForce(-i->getForce());
2999 
3000  //If the rotation flag is on, also applies the relevant torques
3001  //(getRotation() returns a boolean).
3002  if (getRotation()) // getRotation() returns a boolean.
3003  {
3004  pI->addTorque(i->getTorque() - Vec3D::cross(pI->getPosition() - i->getContactPoint(), i->getForce()));
3006  w->addTorque(-i->getTorque() + Vec3D::cross(w->getPosition() - i->getContactPoint(), i->getForce()));
3007  }
3008  }
3009 }
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:741
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:212
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1326
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:522
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 2908 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().

2909 {
2910  //Does not compute forces if particles are fixed
2911  //this is necessary because the rough bottom allows overlapping fixed particles
2912  if (P1->isFixed() && P2->isFixed())
2913  {
2914  return;
2915  }
2916 //Ensures that interactions between the "ghost" particles used to implement periodic behaviour
2917  //are not included in calculations
2918  //i.e. ends the function if both particles are "ghosts".
2919  if ((P1->getPeriodicFromParticle() != nullptr) && (P2->getPeriodicFromParticle() != nullptr))
2920  {
2921  return;
2922  }
2923 //if statement below ensures that the PI has the lower id than PJ
2924  BaseParticle* PI, * PJ;
2925  if (P1->getId() > P2->getId())
2926  {
2927  PI = P2;
2928  PJ = P1;
2929  }
2930  else
2931  {
2932  PI = P1;
2933  PJ = P2;
2934  }
2935  //checks if the two particles are interacting
2936  //("getInteractionWith" returns the relevant pointer if PI and PJ are interacting,
2937  //zero if not)
2938  //if statement above ensures that the PI has the lower id than PJ
2941  if (i!= nullptr) {
2942  //calculates the force corresponding to the interaction
2943  i->computeForce();
2944 
2945  //Applies the relevant calculated forces to PI and PJ
2946  PI->addForce(i->getForce());
2947  PJ->addForce(-i->getForce());
2948 
2949  //checks if particle rotation is turned on...
2950  if (getRotation()) {
2951  //...and, if so, performs equivalent calculations for the torque as were
2952  //performed for the force.
2953  PI->addTorque(i->getTorque() - Vec3D::cross(PI->getPosition() - i->getContactPoint(), i->getForce()));
2954  PJ->addTorque(-i->getTorque() + Vec3D::cross(PJ->getPosition() - i->getContactPoint(), i->getForce()));
2955  }
2956  }
2957 }
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:741
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:212
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:1326
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:522
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 3231 of file DPMBase.cc.

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

Referenced by computeAllForces().

3232 {
3233  for (auto it = particleHandler.begin(); (*it) != i; ++it)
3234  {
3235  computeInternalForce(i, *it);
3236  }
3237 }
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:1296
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:2908
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 3928 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().

3929 {
3930  logger(DEBUG, "starting computeOneTimeStep()");
3931 
3932  logger(DEBUG, "about to call writeOutputFiles()");
3933  writeOutputFiles(); //everything is written at the beginning of the time step!
3934 
3935  logger(DEBUG, "about to call hGridActionsBeforeIntegration()");
3937 
3938  //Computes the half-time step velocity and full time step position and updates the particles accordingly
3939  logger(DEBUG, "about to call integrateBeforeForceComputation()");
3941  //New positions require the MPI and parallel periodic boundaries to do things
3942  logger(DEBUG, "about to call performGhostParticleUpdate()");
3944 
3948 
3949  logger(DEBUG, "about to call checkInteractionWithBoundaries()");
3950  checkInteractionWithBoundaries(); // INSERTION boundaries handled
3951 
3952  logger(DEBUG, "about to call hGridActionsAfterIntegration()");
3954 
3955  // Compute forces
3957  // INSERTION/DELETION boundary flag change
3958  for (BaseBoundary* b : boundaryHandler)
3959  {
3960  b->checkBoundaryBeforeTimeStep(this);
3961  }
3962 
3963  logger(DEBUG, "about to call actionsBeforeTimeStep()");
3965 
3966  logger(DEBUG, "about to call checkAndDuplicatePeriodicParticles()");
3968 
3969  logger(DEBUG, "about to call hGridActionsBeforeTimeStep()");
3971 
3972  //Creates and updates interactions and computes forces based on these
3973  logger(DEBUG, "about to call computeAllForces()");
3974  computeAllForces();
3975 
3976  logger(DEBUG, "about to call removeDuplicatePeriodicParticles()");
3978 
3979  logger(DEBUG, "about to call actionsAfterTimeStep()");
3981 
3982  //Computes new velocities and updates the particles accordingly
3983  logger(DEBUG, "about to call integrateAfterForceComputation()");
3985 
3986  //erase interactions that have not been used during the last time step
3987  logger(DEBUG, "about to call interactionHandler.eraseOldInteractions(getNumberOfTimeSteps())");
3989  logger(DEBUG, "about to call interactionHandler.actionsAfterTimeStep()");
3992 
3993  time_ += timeStep_;
3995 
3996  logger(DEBUG, "finished computeOneTimeStep()");
3997 }
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:3099
void checkAndDuplicatePeriodicParticles()
For simulations using periodic boundaries, checks and adds particles when necessary into the particle...
Definition: DPMBase.cc:4638
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:1732
virtual void writeOutputFiles()
Writes simulation data to all the main Mercury files: .data, .ene, .fstat, .xballs and ...
Definition: DPMBase.cc:3684
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1183
virtual void hGridActionsBeforeIntegration()
This function has to be called before integrateBeforeForceComputation.
Definition: DPMBase.cc:1794
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:741
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1311
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
Mdouble time_
Stores the current simulation time.
Definition: DPMBase.h:1178
virtual void computeAllForces()
Computes all the forces acting on the particles using the BaseInteractable::setForce() and BaseIntera...
Definition: DPMBase.cc:3176
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1326
virtual void actionsBeforeTimeStep()
A virtual function which allows to define operations to be executed before the new time step...
Definition: DPMBase.cc:1718
Mdouble timeStep_
Stores the simulation time step.
Definition: DPMBase.h:1188
void removeDuplicatePeriodicParticles()
Removes periodic duplicate Particles.
Definition: DPMBase.cc:4609
virtual void integrateBeforeForceComputation()
Update particles' and walls' positions and velocities before force computation.
Definition: DPMBase.cc:3022
virtual void hGridActionsAfterIntegration()
This function has to be called after integrateBeforeForceComputation.
Definition: DPMBase.cc:1801
virtual void hGridActionsBeforeTimeStep()
A virtual function that allows one to set or execute hGrid parameters or operations before every simu...
Definition: DPMBase.cc:1544
virtual void checkInteractionWithBoundaries()
There are a range of boundaries one could implement depending on ones' problem. This methods checks f...
Definition: DPMBase.cc:3057
void performGhostParticleUpdate()
When the Verlet scheme updates the positions and velocities of particles, ghost particles will need a...
Definition: DPMBase.cc:4656
void DPMBase::computeWallForces ( BaseWall w)
virtual

Reimplemented in Mercury3D.

Definition at line 4980 of file DPMBase.cc.

References computeForcesDueToWalls(), and particleHandler.

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

4981 {
4982  //compute forces for all particles that are neither fixed or ghosts
4983  for (auto p : particleHandler)
4984  {
4985  if (!p->isFixed() && p->getPeriodicFromParticle() == nullptr)
4986  {
4987  //w->computeForces(p);
4989  }
4990  }
4991 }
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
void computeForcesDueToWalls(BaseParticle *, BaseWall *)
Computes the forces on the particles due to the walls (normals are outward normals) ...
Definition: DPMBase.cc:2983
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().

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 204 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_, 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().

205 {
206  //constructor();
207  dataFile.getFstream().precision(10);
208  fStatFile.getFstream().precision(10);
209  eneFile.getFstream().precision(10);
210  restartFile.getFstream().precision(
211  std::numeric_limits<double>::digits10); //highly accurate, so the overlap is accurate
212  statFile.getFstream().precision(10);
213  statFile.getFstream().setf(std::ios::left);
214  interactionFile.getFstream().precision(10);
215  name_ = ""; // needs to be user-specified, otherwise checkSettings throws error
216  //by default, the fileType of all files is ONE_FILE. However, by default we don't want an interaction file since it
217  // is very large.
219 
220  runNumber_ = 0;
221 
222  //Decomposition direction for MPI
223  numberOfDomains_ = {1, 1, 1};
224 
225  //Check if MPI is already initialised
226  initialiseMPI();
227 
228  //This sets the maximum number of particles
233  cgHandler.setDPMBase(this);
235  wallHandler.setDPMBase(this);
241 
242  //set defaults for DPMBase parameters
245  setRestarted(false);
246  setGravity(Vec3D(0, 0, 0));
247 
248  //This is the parameter of the numerical part
249  setTime(0);
250  numberOfTimeSteps_ = 0;
251  setTimeMax(0);
252  timeStep_ = 0; // needs to be user-specified, otherwise checkSettings throws error
253  setSaveCount(20);
254 
255  //This sets the default xballs domain
256  min_ = Vec3D(0, 0, 0);
257  max_ = Vec3D(0, 0, 0); // needs to be user-specified, otherwise checkSettings throws error
258 
259  //sets the default write particles data in VTK format flag to false
260  writeParticlesVTK_ = false;
263  vtkWriter_ = nullptr;
264 
265  //defines logger behaviour
267 
268  setName(""); // needs to be user-specified, otherwise checkSettings throws error
269 
270  //Default mode is energy with no scale of the vectors
271  xBallsColourMode_ = 0;
272  xBallsVectorScale_ = -1;
273  xBallsScale_ = -1;
275  setAppend(false);
276 
277  //The default random seed is 0
279 
280  logger(DEBUG, "DPMBase problem constructor finished");
281 
282  readSpeciesFromDataFile_ = false;
283 }
void setTime(Mdouble time)
Sets a new value for the current simulation time.
Definition: DPMBase.cc:753
std::string name_
the name of the problem, used, e.g., for the output files
Definition: DPMBase.h:1269
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:768
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Vec3D max_
Definition: DPMBase.h:1173
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:1279
File interactionFile
File class to handle in- and output into .interactions file. This file hold information about interac...
Definition: DPMBase.h:1363
int runNumber_
This stores the run number for saving.
Definition: DPMBase.h:1264
void setParticleDimensions(unsigned int particleDimensions)
Sets the particle dimensionality.
Definition: DPMBase.cc:1302
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1321
std::vector< unsigned > numberOfDomains_
Vector containing the number of domains in x-,y- and z-direction, required for parallel computations...
Definition: DPMBase.h:1167
void setAppend(bool newAppendFlag)
Sets whether the "append" option is on or off.
Definition: DPMBase.cc:1376
void setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1271
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:1237
void initialiseMPI()
Inialises the MPI library.
void logWriteAndDie(std::string module, std::string message)
todo strcmp relies on this, should be changed to more modern version
Definition: DPMBase.cc:80
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1183
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:1337
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:1342
bool writeSuperquadricParticlesVTK_
Definition: DPMBase.h:1230
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1332
int xBallsColourMode_
XBalls is a package to view the particle data. As an alternative MercuryDPM also supports ParaView...
Definition: DPMBase.h:1244
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1311
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1316
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1232
Mdouble xBallsScale_
sets the xballs argument scale (see XBalls/xballs.txt)
Definition: DPMBase.h:1254
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:400
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1286
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1326
FileType writeWallsVTK_
A flag to turn on/off the vtk writer for walls.
Definition: DPMBase.h:1223
Mdouble xBallsVectorScale_
sets the xballs argument vscale (see XBalls/xballs.txt)
Definition: DPMBase.h:1249
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:1188
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:1306
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:1291
bool writeParticlesVTK_
A flag to turn on/off the vtk writer for particles.
Definition: DPMBase.h:1228
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:414
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: DPMBase.h:1357
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1347
std::string xBallsAdditionalArguments_
A string of additional arguments for xballs can be specified (see XBalls/xballs.txt). e.g. "-solidf -v0".
Definition: DPMBase.h:1259
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1352
void setRestarted(bool newRestartedFlag)
Allows to set the flag stating if the simulation is to be restarted or not.
Definition: DPMBase.cc:1355
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:1172
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 1847 of file DPMBase.cc.

Referenced by solve().

1848 {
1849  return true;
1850 }
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 3723 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().

3724 {
3725 #ifdef MERCURY_USE_MPI
3726 
3727  //If running in parallel build, but just running with one core - no domain decomposition required
3728  int numberOfRequiredProcessors = numberOfDomains_[Direction::XAXIS]*
3731  if (NUMBER_OF_PROCESSORS != numberOfRequiredProcessors)
3732  {
3733  logger(ERROR,"The domain decompositions expects % processors, but only % are requested.\n"
3734  "Either run your process using \"mpirun -np % [executable]\", "
3735  "or change the domain decomposition to e.g. setNumberOfDomains({%,1,1}).", numberOfRequiredProcessors, NUMBER_OF_PROCESSORS, numberOfRequiredProcessors, NUMBER_OF_PROCESSORS);
3736  }
3737 
3738  if (NUMBER_OF_PROCESSORS == 1) {return;}
3739 
3740  //Check if the simulation domain has been set
3741  logger.assert_always(getXMax() - getXMin() > 0,"Please set your simulation domain (setXMax(),setXmin()) before calling solve()");
3742  logger.assert_always(getYMax() - getYMin() > 0,"Please set your simulation domain (setYMax(),setYmin()) before calling solve()");
3743  logger.assert_always(getZMax() - getZMin() > 0,"Please set your simulation domain (setZMax(),setZmin()) before calling solve()");
3744 
3745  //Grab simulation domains
3746  std::vector<Mdouble> simulationMin{getXMin(), getYMin(), getZMin()};
3747  std::vector<Mdouble> simulationMax{getXMax(), getYMax(), getZMax()};
3748 
3749  //Check if the user input decomposition is correct
3750  logger.assert_always(numberOfDomains_[Direction::XAXIS] > 0,"Number of domain in x-direction incorrect: %",numberOfDomains_[Direction::XAXIS]);
3751  logger.assert_always(numberOfDomains_[Direction::YAXIS] > 0,"Number of domain in y-direction incorrect: %",numberOfDomains_[Direction::YAXIS]);
3752  logger.assert_always(numberOfDomains_[Direction::ZAXIS] > 0,"Number of domain in z-direction incorrect: %",numberOfDomains_[Direction::ZAXIS]);
3753 
3754  //Open domain decomposition, closed is not implemented
3755  bool open = true;
3756 
3757  //Check if the number of domains is equal to the number of processors
3758  logger.assert_always(numberOfDomains_[Direction::XAXIS]*numberOfDomains_[Direction::YAXIS]*numberOfDomains_[Direction::ZAXIS] == NUMBER_OF_PROCESSORS,
3759  "Number of Processors is not equal to number of domains. Processors %, domains, %",
3761  numberOfDomains_[Direction::XAXIS]*numberOfDomains_[Direction::YAXIS]*numberOfDomains_[Direction::ZAXIS]);
3762 
3763  //Create all processor domains
3764 
3765  domainHandler.setDPMBase(this);
3766  domainHandler.createMesh(simulationMin, simulationMax, numberOfDomains_, open);
3767  logger(VERBOSE,"Number of domains: % | Number of processors: %",domainHandler.getNumberOfObjects(), NUMBER_OF_PROCESSORS);
3768  //logger.assert_always(domainHandler.getNumberOfObjects() == numberOfProcessors, "Invalid decomposition: Number of domains and processors are different");
3769 
3770  //Tell the current processor to which domain it belongs
3771  for (Domain* domain : domainHandler)
3772  {
3773  if (domain->getRank() == PROCESSOR_ID)
3774  {
3775  logger(VERBOSE,"processor: %, domain index: %",PROCESSOR_ID, domain->getIndex());
3776  domainHandler.setCurrentDomainIndex(domain->getIndex());
3777  }
3778  }
3779 
3780  //Define the mpi transfer types, which requires a definition of the species already
3782  logger.assert_always(speciesHandler.getNumberOfObjects() > 0, "Please create a particle species before calling solve()");
3784 
3785  //Make sure all processors are done with decomposition before proceeding
3786  logger(VERBOSE,"processor %: #real particles: %, #total particles: %", PROCESSOR_ID, particleHandler.getNumberOfRealObjects(), particleHandler.getSize());
3788 #endif
3789 }
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:594
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.h:563
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.h:576
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1321
std::vector< unsigned > numberOfDomains_
Vector containing the number of domains in x-,y- and z-direction, required for parallel computations...
Definition: DPMBase.h:1167
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.h:570
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:1296
#define PROCESSOR_ID
Definition: GeneralDefine.h:60
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:1286
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:59
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.h:582
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:588
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 4679 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().

4680 {
4681  //Flush mixed particles from lists (MP particles are located in both structures)
4682  if (periodicBoundaryHandler.getSize() > 0)
4683  {
4684  //Flush particles from boundaries
4685  domainHandler.getCurrentDomain()->flushParticles(particlesToBeDeleted);
4686  periodicBoundaryHandler.flushParticles(particlesToBeDeleted);
4687  }
4688 
4689  //Clean communication lists
4692 
4693  //Delete the particles
4694  for (auto particle_it : particlesToBeDeleted)
4695  {
4696  particleHandler.removeGhostObject(particle_it->getIndex());
4697  }
4698 }
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:1321
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:1316
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
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 2788 of file DPMBase.cc.

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

2788  {
2789  logger.assert_always(speciesHandler.getSize()>0,"There needs to be at least one species");
2791  SphericalParticle p(s);
2793  Mdouble r = cbrt(getTotalVolume())/N;
2794  b.set(p,100,getMin(),getMax(),{0,0,0},{0,0,0},r,r);
2795  b.insertParticles(this);
2796  logger(INFO,"Inserted % particles",particleHandler.getSize());
2797  //setTimeMax(0);
2798  //solve();
2799 }
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:600
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:1296
Mdouble getTotalVolume() const
Get the total volume of the cuboid system.
Definition: DPMBase.cc:4923
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1286
Vec3D getMax() const
Definition: DPMBase.h:606
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 2425 of file DPMBase.cc.

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

2426 {
2428  {
2429  while (true)// This true corresponds to the if s
2430  {
2431  dataFile.open();
2432  //check if file exists and contains data
2433  int N;
2434  dataFile.getFstream() >> N;
2435  if (dataFile.getFstream().eof() || dataFile.getFstream().peek() == -1)
2436  {
2437  std::cout << "file " << dataFile.getName() << " not found" << std::endl;
2438  return false;
2439  }
2440  //check if tmin condition is satisfied
2441  Mdouble t;
2442  dataFile.getFstream() >> t;
2443  if (t > tMin)
2444  {
2445  //set_file_counter(get_file_counter()-1);
2446  return true;
2447  }
2448  if (verbose)
2449  std::cout << "Jumping file counter: " << dataFile.getCounter() << std::endl;
2450  }
2451  }
2452  return true;
2453 }
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:1337
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 1779 of file DPMBase.cc.

References cgHandler, and CGHandler::finish().

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

1780 {
1781  cgHandler.finish();
1782 }
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:1332
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 3663 of file DPMBase.cc.

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

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

3664 {
3666  writeOutputFiles();
3667 }
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:506
virtual void writeOutputFiles()
Writes simulation data to all the main Mercury files: .data, .ene, .fstat, .xballs and ...
Definition: DPMBase.cc:3684
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 1763 of file DPMBase.cc.

Referenced by BaseInteraction::gatherContactStatistics().

1766 {
1767 }
void DPMBase::gatherContactStatistics ( )
protected

Definition at line 1752 of file DPMBase.cc.

References interactionHandler.

1753 {
1755  {
1756  c->gatherContactStatistics();
1757  }
1758 }
Stores information about interactions between two interactable objects; often particles but could be ...
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1326
std::vector< int > DPMBase::get2DParametersFromRunNumber ( int  size_x,
int  size_y 
)

This turns a counter into two indices which is a very useful feature for performing two-dimensional parameter studies. 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 size_x = 2 and size_y = 5, counter stored in COUNTER_DONOTDEL =1. The study_size = 10. Substituting these values into the below algorithm implies that study_num = 0 or 1, everytime the code is executed the counter gets incremented and hence determined the values of study_num, i and j which is returned as a std::vector<int>

Parameters
[in]size_xThe (integer) number of values to be tested for one of the 2 parameters forming the 2D parameter space.
[in]size_yThe (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 654 of file DPMBase.cc.

References getRunNumber(), and constants::i.

655 {
656  //declares a vector of integers capable of storing 3 values,
657  std::vector<int> temp(3);
658  //declares and initialises an integer variable named "counter"
659  //with the current counter number, runNumber_
660  int counter = getRunNumber();
661  //calculates the total size of the study, i.e. the number of points
662  //in the 2D parameter space explored
663  int study_size = size_x * size_y;
664  //(counter - 1) / study_size gives a fraction comparing the number of runs conducted so far
665  //to the total size of the study, i.e. the total number of runs that need to be performed.
666  //since study_num is an integer, will declare zero until an adequate number of runs has been performed,
667  //at which point it will equal 1
668  int study_num = (counter - 1) / study_size;
669 
670  counter = counter - study_size * study_num;
671  int i = ((counter - 1) % size_x) + 1;
672  int j = (counter - i) / size_x + 1;
673  std::cout << "Counter: " << counter << " i: " << i << " j: " << j << std::endl;
674 
675  temp[0] = study_num;
676  temp[1] = i;
677  temp[2] = j;
678 
679  return (temp);
680 }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
int getRunNumber() const
This returns the current value of the counter (runNumber_)
Definition: DPMBase.cc:600
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 1364 of file DPMBase.cc.

References append_.

Referenced by solve(), and writeEneHeader().

1365 {
1366  return append_;
1367 }
bool append_
A flag to determine if the file has to be appended or not. See DPMBase::Solve() for example...
Definition: DPMBase.h:1211
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 1468 of file DPMBase.cc.

References ParticleHandler::getCentreOfMass(), and particleHandler.

1469 {
1471 }
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
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 4842 of file DPMBase.cc.

References domainHandler, and DomainHandler::getCurrentDomain().

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

4843 {
4845 }
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1321
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 297 of file DPMBase.cc.

References dataFile.

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

References dataFile.

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

References interactionHandler.

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

1385 {
1386  Mdouble elasticEnergy = 0.0;
1387  // JMFT: Note that we do count the elastic energy of fixed particles here.
1388  for (const BaseInteraction* c : interactionHandler)
1389  {
1390  elasticEnergy += c->getElasticEnergy();
1391  }
1392  return elasticEnergy;
1393 }
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:1326
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 305 of file DPMBase.cc.

References eneFile.

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

References eneFile.

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

References fStatFile.

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

References fStatFile.

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

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

Referenced by getTotalEnergy().

1416 {
1417  Mdouble gravitationalEnergy = 0;
1418  for (const BaseParticle* const p : particleHandler)
1419  {
1420  // Don't consider fixed particles. 'Fixed' particles aren't necessarily
1421  // stationary; it just means their position is prescribed.
1422  if (!(p->isFixed()))
1423  {
1424  gravitationalEnergy += p->getMass() * Vec3D::dot((-getGravity()), p->getPosition());
1425  }
1426  }
1427  return gravitationalEnergy;
1428 }
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:125
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
Vec3D getGravity() const
Returns the gravitational acceleration.
Definition: DPMBase.cc:1245
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 1245 of file DPMBase.cc.

References gravity_.

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

1246 {
1247  return gravity_;
1248 }
Vec3D gravity_
Gravity vector.
Definition: DPMBase.h:1162
bool DPMBase::getHGridUpdateEachTimeStep ( ) const
virtual
Returns
bool (True or False)

Reimplemented in MercuryBase.

Definition at line 1572 of file DPMBase.cc.

Referenced by BaseParticle::integrateBeforeForceComputation().

1573 {
1574  return true;
1575 }
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 1496 of file DPMBase.cc.

References BaseParticle::getInfo().

1497 {
1498 // return p.getSpecies()->getId(); // was getIndex()
1499  return p.getInfo();
1500 }
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 337 of file DPMBase.cc.

References interactionFile.

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

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

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

References particleHandler.

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

1399 {
1400  Mdouble kineticEnergy = 0;
1401  for (const BaseParticle* const p : particleHandler)
1402  {
1403  if (!(p->isFixed()))
1404  {
1405  kineticEnergy += .5 * p->getMass() * p->getVelocity().getLengthSquared();
1406  }
1407  }
1408  return kineticEnergy;
1409 }
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:1296
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 4932 of file DPMBase.cc.

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

Referenced by getTotalStress().

4933 {
4934  Matrix3D F; //set the kinetic energy tensor, this is in terms of Sum(m*v^2)
4935  Vec3D J; //set the momentum tensor
4936 
4937  //calculate stress for kinetic part
4938  for (const auto& p : particleHandler)
4939  {
4940  F += Matrix3D::dyadic(p->getVelocity(), p->getVelocity()) * p->getMass();
4941  J += p->getVelocity() * p->getMass();
4942  }
4943 
4944  Matrix3D stressKinetic = F - Matrix3D::dyadic(J, J) / getTotalMass();
4945  stressKinetic /= getTotalVolume();
4946  return stressKinetic;
4947 }
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:1296
Mdouble getTotalVolume() const
Get the total volume of the cuboid system.
Definition: DPMBase.cc:4923
Mdouble getTotalMass() const
JMFT: Return the total mass of the system, excluding fixed particles.
Definition: DPMBase.cc:1452
Implementation of a 3D matrix.
Definition: Matrix.h:37
Definition: Vector.h:49
Mdouble DPMBase::getNextTime ( ) const

Returns the current simulation time.

Returns
time_

Definition at line 733 of file DPMBase.cc.

References time_, and timeStep_.

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

734 {
735  return time_ + timeStep_;
736 }
Mdouble time_
Stores the current simulation time.
Definition: DPMBase.h:1178
Mdouble timeStep_
Stores the simulation time step.
Definition: DPMBase.h:1188
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 4833 of file DPMBase.cc.

References numberOfDomains_.

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

4834 {
4835  return numberOfDomains_;
4836 }
std::vector< unsigned > numberOfDomains_
Vector containing the number of domains in x-,y- and z-direction, required for parallel computations...
Definition: DPMBase.h:1167
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 741 of file DPMBase.cc.

References numberOfTimeSteps_.

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

742 {
743  return numberOfTimeSteps_;
744 }
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1183
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 1321 of file DPMBase.cc.

References particleDimensions_.

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

1322 {
1323  return particleDimensions_;
1324 }
unsigned int particleDimensions_
determines if 2D or 3D particle volume is used for mass calculations
Definition: DPMBase.h:1157
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 876 of file DPMBase.cc.

References writeParticlesVTK_.

Referenced by writePythonFileForVTKVisualisation(), and writeVTKFiles().

877 {
878  return writeParticlesVTK_;
879 }
bool writeParticlesVTK_
A flag to turn on/off the vtk writer for particles.
Definition: DPMBase.h:1228
bool DPMBase::getReadInteractions ( ) const
inline

Definition at line 1373 of file DPMBase.h.

References readInteractions_.

Referenced by read().

1373 {return readInteractions_;}
bool readInteractions_
Definition: DPMBase.h:1376
bool DPMBase::getRestarted ( ) const

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

Returns
restarted_

Definition at line 1347 of file DPMBase.cc.

References restarted_.

Referenced by solve(), and writeOutputFiles().

1348 {
1349  return restarted_;
1350 }
bool restarted_
A bool to check if the simulation was restarted or not, ie. if setupInitialConditionsShould be run an...
Definition: DPMBase.h:1205
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 321 of file DPMBase.cc.

References restartFile.

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

References restartFile.

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

References restartVersion_.

Referenced by Chute::read().

1330 {
1331  return restartVersion_;
1332 }
std::string restartVersion_
Previous versions of MercuryDPM had a different restart file format, the below member variable allows...
Definition: DPMBase.h:1200
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 522 of file DPMBase.h.

References rotation_.

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

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

JMFT Returns the global rotational energy stored in the system.

Definition at line 1431 of file DPMBase.cc.

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

Referenced by getTotalEnergy().

1432 {
1433  Mdouble ene_rot = 0;
1434  for (std::vector<BaseParticle*>::const_iterator it = particleHandler.begin(); it != particleHandler.end(); ++it)
1435  {
1436  // See above.
1437  if (!(*it)->isFixed())
1438  {
1439  // ene_rot += .5 * (*it)->getInertia() * (*it)->getAngularVelocity().getLengthSquared();
1440  }
1441  }
1442  return ene_rot;
1443 }
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:1296
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 600 of file DPMBase.cc.

References runNumber_.

Referenced by get2DParametersFromRunNumber(), and solve().

601 {
602  return runNumber_;
603 }
int runNumber_
This stores the run number for saving.
Definition: DPMBase.h:1264
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 329 of file DPMBase.cc.

References statFile.

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

References statFile.

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

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

Referenced by getTotalStress().

4955 {
4956  //stress components calculation variables
4957  Matrix3D stressStatic;
4958 
4959  //calculate the static stress tensor based on all the interactions
4960  for (const auto i : interactionHandler)
4961  {
4962  stressStatic += Matrix3D::dyadic(i->getForce(), i->getNormal()) * i->getDistance();
4963  }
4964 
4965  stressStatic /= getTotalVolume();
4966  return stressStatic;
4967 }
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:4923
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1326
Implementation of a 3D matrix.
Definition: Matrix.h:37
bool DPMBase::getSuperquadricParticlesWriteVTK ( ) const
Returns
bool

Definition at line 884 of file DPMBase.cc.

References writeSuperquadricParticlesVTK_.

Referenced by writeVTKFiles().

885 {
887 }
bool writeSuperquadricParticlesVTK_
Definition: DPMBase.h:1230
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 1284 of file DPMBase.cc.

References systemDimensions_.

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

1285 {
1286  return systemDimensions_;
1287 }
unsigned int systemDimensions_
The dimensions of the simulation i.e. 2D or 3D.
Definition: DPMBase.h:1152
Mdouble DPMBase::getTimeMax ( ) const

Returns the maximum simulation duration.

Returns
timeMax_

Definition at line 783 of file DPMBase.cc.

References timeMax_.

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

784 {
785  return timeMax_;
786 }
Mdouble timeMax_
Stores the duration of the simulation.
Definition: DPMBase.h:1193
Mdouble DPMBase::getTotalEnergy ( ) const

Definition at line 1445 of file DPMBase.cc.

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

1445  {
1447 }
Mdouble getRotationalEnergy() const
JMFT Returns the global rotational energy stored in the system.
Definition: DPMBase.cc:1431
Mdouble getElasticEnergy() const
Returns the global elastic energy within the system.
Definition: DPMBase.cc:1384
Mdouble getGravitationalEnergy() const
Returns the global gravitational potential energy stored in the system.
Definition: DPMBase.cc:1415
Mdouble getKineticEnergy() const
Returns the global kinetic energy stored in the system.
Definition: DPMBase.cc:1398
Mdouble DPMBase::getTotalMass ( ) const

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

Returns
double

Definition at line 1452 of file DPMBase.cc.

References ParticleHandler::getMass(), and particleHandler.

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

1453 {
1454  /*
1455  double mass_sum = 0;
1456  for (std::vector<BaseParticle*>::const_iterator it = particleHandler.begin(); it != particleHandler.end(); ++it)
1457  if (!(*it)->isFixed())
1458  mass_sum += (*it)->getMass();
1459  return mass_sum;
1460  */
1461  return particleHandler.getMass();
1462 }
Mdouble getMass() const
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
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 1478 of file DPMBase.cc.

References ParticleHandler::getMomentum(), and particleHandler.

Referenced by setMeanVelocity(), and setMeanVelocityAndKineticEnergy().

1479 {
1480  return particleHandler.getMomentum();
1481  /*
1482  Vec3D total_momentum = Vec3D(0,0,0);
1483  for (std::vector<BaseParticle*>::const_iterator it = particleHandler.begin(); it != particleHandler.end(); ++it)
1484  if (!(*it)->isFixed())
1485  total_momentum += (*it)->getMass() * (*it)->getVelocity();
1486  return total_momentum;
1487  */
1488 }
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
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 4974 of file DPMBase.cc.

References getKineticStress(), and getStaticStress().

Referenced by StressStrainControlBoundary::computeStrainRate().

4975 {
4976  return getKineticStress() + getStaticStress();
4977 }
Matrix3D getStaticStress() const
Calculate the static stress tensor in the system averaged over the whole volume.
Definition: DPMBase.cc:4954
Matrix3D getKineticStress() const
Calculate the kinetic stress tensor in the system averaged over the whole volume. ...
Definition: DPMBase.cc:4932
Mdouble DPMBase::getTotalVolume ( ) const

Get the total volume of the cuboid system.

Returns
The total volume of the domain.

Definition at line 4923 of file DPMBase.cc.

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

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

4924 {
4925  return (getXMax() - getXMin()) * (getYMax() - getYMin()) * (getZMax() - getZMin());
4926 }
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.h:594
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.h:563
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.h:576
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.h:570
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.h:582
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.h:588
ParticleVtkWriter * DPMBase::getVtkWriter ( ) const

Definition at line 4847 of file DPMBase.cc.

References vtkWriter_.

4848 {
4849  return vtkWriter_;
4850 }
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1232
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 865 of file DPMBase.cc.

References writeWallsVTK_.

Referenced by writePythonFileForVTKVisualisation(), and writeVTKFiles().

866 {
867  return writeWallsVTK_;
868 }
FileType writeWallsVTK_
A flag to turn on/off the vtk writer for walls.
Definition: DPMBase.h:1223
std::string DPMBase::getXBallsAdditionalArguments ( ) const

Returns the additional arguments for xballs.

Returns
xBallsAdditionalArguments_

Definition at line 1209 of file DPMBase.cc.

References xBallsAdditionalArguments_.

Referenced by write().

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

References xBallsColourMode_.

1165 {
1166  return xBallsColourMode_;
1167 }
int xBallsColourMode_
XBalls is a package to view the particle data. As an alternative MercuryDPM also supports ParaView...
Definition: DPMBase.h:1244
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 1226 of file DPMBase.cc.

References xBallsScale_.

1227 {
1228  return xBallsScale_;
1229 }
Mdouble xBallsScale_
sets the xballs argument scale (see XBalls/xballs.txt)
Definition: DPMBase.h:1254
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 1184 of file DPMBase.cc.

References xBallsVectorScale_.

1185 {
1186  return xBallsVectorScale_;
1187 }
Mdouble xBallsVectorScale_
sets the xballs argument vscale (see XBalls/xballs.txt)
Definition: DPMBase.h:1249
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 1801 of file DPMBase.cc.

Referenced by computeOneTimeStep().

1802 {
1803 }
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 1794 of file DPMBase.cc.

Referenced by computeOneTimeStep().

1795 {
1796 }
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 1530 of file DPMBase.cc.

Referenced by solve().

1531 {
1532 }
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 1544 of file DPMBase.cc.

Referenced by computeOneTimeStep(), and solve().

1545 {
1546 }
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 907 of file DPMBase.h.

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

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

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

1552 {
1553 }
void DPMBase::hGridRemoveParticle ( BaseParticle *obj  UNUSED)
virtual

no implementation but can be overidden in its derived classes.

Definition at line 1565 of file DPMBase.cc.

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

1566 {
1567 }
void DPMBase::hGridUpdateMove ( BaseParticle ,
Mdouble   
)
virtual

no implementation but can be overidden in its derived classes.

Reimplemented in MercuryBase.

Definition at line 1787 of file DPMBase.cc.

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

1788 {
1789 }
void DPMBase::hGridUpdateParticle ( BaseParticle *obj  UNUSED)
virtual

no implementation but can be overidden in its derived classes.

Definition at line 1558 of file DPMBase.cc.

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

1559 {
1560 }
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 4575 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().

4576 {
4577  int nParticlesPreviouslyIn = particleHandler.getSize();
4578  int l = 0;
4579  for (auto k = particleH.begin(); k != particleH.end(); ++k) {
4580  auto p = particleHandler.copyAndAddObject( *k );
4581  p->setSpecies(species);
4582  l++;
4583  }
4584 
4585  for (std::vector<BaseInteraction*>::const_iterator i = interactionH.begin(); i != interactionH.end(); ++i) {
4586  if ( (*i)->getP()->getInvMass() != 0.0 && (*i)->getI()->getInvMass() != 0.0 ) {
4588  j->importP(particleHandler.getObject(nParticlesPreviouslyIn + j->getP()->getIndex()));
4589  j->importI(particleHandler.getObject(nParticlesPreviouslyIn + j->getI()->getIndex()));
4590  j->setTimeStamp(getNumberOfTimeSteps());
4591  }
4592  }
4593 }
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:741
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
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:1326
void DPMBase::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.

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

Referenced by autoNumber().

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

This function is overridden by StatisticsVector

Reimplemented in StatisticsVector< T >.

Definition at line 1739 of file DPMBase.cc.

References cgHandler, and CGHandler::initialise().

Referenced by solve().

1740 {
1742 }
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:1332
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 1665 of file DPMBase.cc.

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

Referenced by ParticleHandler::addObject().

1666 {
1667 #ifdef MERCURY_USE_MPI
1668  //mpi particles only exist when there is more than one domain
1669  if (domainHandler.getSize() > 0)
1670  {
1671  //Add the particle to the mpi domain
1673  }
1674 
1675  //If periodic boundaries are present..
1676  if (periodicBoundaryHandler.getSize() > 0)
1677  {
1679  }
1680 #endif
1681 }
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:1321
PeriodicBoundaryHandler periodicBoundaryHandler
Internal handler that deals with periodic boundaries, especially in a parallel build.
Definition: DPMBase.h:1316
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 3099 of file DPMBase.cc.

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

Referenced by computeOneTimeStep().

3100 {
3101  //cycling through all particles, p, in the particleHandler
3102  for_each(particleHandler.begin(), particleHandler.end(), [this](BaseParticle* p)
3103  {
3104 #ifdef MERCURY_USE_MPI
3105  //MPI particles do not require integration - they are updated by the communication step
3106  if (!(p->isMPIParticle() || p->isPeriodicGhostParticle()))
3107  {
3108  p->integrateAfterForceComputation(getTime(), getTimeStep());
3109  }
3110 #else
3111  //using the particle p's internal "integrateAfterForceComputation" function
3112  //to update the relevant parameters concerning the particle's position and motion
3113  p->integrateAfterForceComputation(getTime(), getTimeStep());
3114 #endif
3115  });
3116  //cycling through all walls, w, in the wallHandler
3117  for_each(wallHandler.begin(), wallHandler.end(), [this](BaseWall* w)
3118  {
3119  //using the wall's internal "integrateAfterForceComputation" function
3120  //to update the relevant parameters concerning its position and motion
3121  w->integrateAfterForceComputation(getTime(), getTimeStep());
3122  });
3123 }
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:1296
Basic class for walls.
Definition: BaseWall.h:47
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1306
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1141
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:725
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 3022 of file DPMBase.cc.

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

Referenced by computeOneTimeStep().

3023 {
3024  //cycling through all particles, p, in the particleHandler
3025  for_each(particleHandler.begin(), particleHandler.end(), [this](BaseParticle* p)
3026  {
3027 #ifdef MERCURY_USE_MPI
3028  //MPI particles are not integrated, they are purely ghost particles and get their new velocity and position from an MPI update
3029  if (!(p->isMPIParticle() || p->isPeriodicGhostParticle()))
3030  {
3031  p->integrateBeforeForceComputation(getTime(), getTimeStep());
3032  }
3033 #else
3034  //using the particle p's internal "integrateBeforeForceComputation" function
3035  //to update the relevant parameters concerning the particle's position and motion
3036  p->integrateBeforeForceComputation(getTime(), getTimeStep());
3037 #endif
3038  });
3039  //cycling through all walls, w, in the wallHandler
3040  for_each(wallHandler.begin(), wallHandler.end(), [this](BaseWall* w)
3041  {
3042  //using the wall's internal "integrateBeforeForceComputation" function
3043  //to update the relevant parameters concerning its position and motion
3044  w->integrateBeforeForceComputation(getTime(), getTimeStep());
3045  });
3046 }
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:1296
Basic class for walls.
Definition: BaseWall.h:47
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1306
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1141
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:725
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 4756 of file DPMBase.cc.

References getTime(), and getTimeStep().

4757 {
4758  return getTime() <= time && getTime() + getTimeStep() > time;
4759 }
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1141
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:725
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 692 of file DPMBase.cc.

693 {
694  //defines an (empty) stringstream named "com"
695  std::stringstream com("");
696  //adds the name of the code to run (fed in as an argument)
697  //to the "com" string and appends the string with " &"
698  com << name << " &";
699  //converts the stringstream "com" to a standard string, and then
700  //converts this string to a C string
701  //the string is then fed to the "system" function, which will run the named command
702  return system(com.str().c_str());
703 }
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 1586 of file DPMBase.cc.

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

Referenced by ParticleHandler::addObject().

1587 {
1588 #ifdef MERCURY_USE_MPI
1589  //If only one core is used (i.e. domainHandler is empty) then the result is always true
1590  if (domainHandler.getSize() == 0)
1591  {
1592  return true;
1593  }
1594  //Get the current domain
1596 
1597  //Check if the particle is in the current domain
1598  if(domain->containsParticle(P))
1599  {
1600  //When adding a particle inside the domain, this should always be true
1601  return true;
1602  }
1603  else
1604  {
1605  //MPI particles that are inserted in the communication zone should still be inserted
1606  return (P->isMPIParticle());
1607  }
1608 #else
1609  return false;
1610 #endif
1611 }
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:1321
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 1618 of file DPMBase.cc.

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

1619 {
1620 
1621  bool insideCommunicationZone = false;
1622 #ifdef MERCURY_USE_MPI
1623  MPIContainer& communicator = MPIContainer::Instance();
1624 
1625  //Check for the current domain if the particle is within the communication domain
1626  int val = domainHandler.getCurrentDomain()->isInCommunicationZone(particle);
1627 
1628  //The root gathers all results
1629  int *list = nullptr;
1630  if (PROCESSOR_ID == 0)
1631  {
1632  list = new int [NUMBER_OF_PROCESSORS];
1633  }
1634  communicator.gather(val,list);
1635 
1636  //Compute the global value
1637  //if on any processor the val is true, we have to do the communcation step
1639  int result = 0;
1640  if (PROCESSOR_ID == 0)
1641  {
1642  for (int i = 0; i< NUMBER_OF_PROCESSORS; i++)
1643  {
1644  if (list[i] == 1)
1645  {
1646  result = 1;
1647  break;
1648  }
1649  }
1650  }
1651 
1652  //The root now tells the other processors what the global value for the interaction is
1653  communicator.broadcast(result);
1654 
1655  //Convert the result back to bool
1656  insideCommunicationZone = result;
1657 #endif
1658  return insideCommunicationZone;
1659 }
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:1321
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:60
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:59
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 4735 of file DPMBase.cc.

References interactionHandler.

4736 {
4737  std::cout << "Interactions currently in the handler:" << std::endl;
4738  //looping over all individual objects in the interactionHandler
4740  {
4741  p->write(std::cout);
4742  std::cout << std::endl;
4743  std::cout << "Interaction " << p->getName() << " " << p->getId() << " between " << p->getP()->getId() << " and "
4744  << p->getI()->getId() << std::endl;
4745  }
4746 }
Stores information about interactions between two interactable objects; often particles but could be ...
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1326
void DPMBase::outputStatistics ( )
protectedvirtual

This function is overridden by StatisticsVector

Reimplemented in StatisticsVector< T >.

Definition at line 1747 of file DPMBase.cc.

1748 {
1749  //cgHandler.evaluate();
1750 }
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 2127 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().

2128 {
2129 
2130 
2131  //Set the correct formation based of dimension if the formation is not specified by the user
2132 
2133  unsigned int format;
2134  switch (getSystemDimensions())
2135  {
2136  case 2:
2137  format = 8;
2138  break;
2139  case 3:
2140  format = 14;
2141  break;
2142  default:
2143  std::cerr << "Unknown system dimension" << std::endl;
2144  exit(-1);
2145  }
2146 
2147  unsigned int numberOfParticles = particleHandler.getNumberOfRealObjectsLocal();
2148 
2149  // This outputs the location of walls and how many particles there are to file this is required by the xballs plotting
2150  if (format != 14) // dim = 1 or 2
2151  {
2152  os << numberOfParticles
2153  << " " << getTime()
2154  << " " << getXMin()
2155  << " " << getYMin()
2156  << " " << getXMax()
2157  << " " << getYMax()
2158  << " " << std::endl;
2159  }
2160  else
2161  {
2162  //dim==3
2163  os << numberOfParticles
2164  << " " << getTime()
2165  << " " << getXMin()
2166  << " " << getYMin()
2167  << " " << getZMin()
2168  << " " << getXMax()
2169  << " " << getYMax()
2170  << " " << getZMax()
2171  << " " << std::endl;
2172  }
2173 
2174  // This outputs the particle data
2175  for (unsigned int i = 0; i < particleHandler.getSize(); i++)
2176  {
2177 #ifdef MERCURY_USE_MPI
2179  {
2180  outputXBallsDataParticle(i, format, os);
2181  }
2182 #else
2183  outputXBallsDataParticle(i, format, os);
2184 #endif
2185  }
2186 #ifdef DEBUG_OUTPUT
2187  std::cerr << "Have output the properties of the problem to disk " << std::endl;
2188 #endif
2189 }
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:1284
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.h:594
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.h:563
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:576
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:570
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
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:582
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.h:588
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:725
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 4656 of file DPMBase.cc.

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

Referenced by computeOneTimeStep().

4657 {
4658 #ifdef MERCURY_USE_MPI
4659  //MPIContainer& communicator = MPIContainer::Instance();
4660  if (NUMBER_OF_PROCESSORS == 1) {return;}
4661 
4662  //Update the postion and velocity data of ghosts and perform some bookkeeping
4663  std::set<BaseParticle*> particlesToBeDeleted;
4664  domainHandler.updateStatus(particlesToBeDeleted);
4665  periodicBoundaryHandler.updateStatus(particlesToBeDeleted);
4666 
4667  //Delete particles
4668  deleteGhostParticles(particlesToBeDeleted);
4669 
4670  //Add new particles
4673 #endif
4674 }
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1321
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:1316
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:59
void updateStatus(std::set< BaseParticle * > &particlesToBeDeleted)
void deleteGhostParticles(std::set< BaseParticle * > &particlesToBeDeleted)
Definition: DPMBase.cc:4679
void DPMBase::performGhostVelocityUpdate ( )
protected

updates the final time-step velocity of the ghost particles

Definition at line 4721 of file DPMBase.cc.

References NUMBER_OF_PROCESSORS.

4722 {
4723 #ifdef MERCURY_USE_MPI
4724  if (NUMBER_OF_PROCESSORS == 1) {return;}
4725  //TODO If required, I can implement this for periodic particles, first discuss with Thomas if it is actually requiredf
4726  //periodicDomainHandler.updateVelocity()
4727  //domainHandler.updateVelocity();
4728 #endif
4729 }
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:59
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 1824 of file DPMBase.cc.

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

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

1825 {
1826 #ifdef MERCURY_USE_MPI
1827  MPIContainer& communicator = MPIContainer::Instance();
1828  if (communicator.getProcessorID() == 0)
1829  {
1830 #endif
1831  std::cout << "t=" << std::setprecision(3) << std::left << std::setw(6) << getTime()
1832  << ", tmax=" << std::setprecision(3) << std::left << std::setw(6) << getTimeMax()
1833  << std::endl;
1834  std::cout.flush();
1835 #ifdef MERCURY_USE_MPI
1836  }
1837 #endif
1838 }
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:725
Mdouble getTimeMax() const
Returns the maximum simulation duration.
Definition: DPMBase.cc:783
void DPMBase::processStatistics ( bool  )
protectedvirtual

This function is overridden by StatisticsVector

Reimplemented in StatisticsVector< T >.

Definition at line 1772 of file DPMBase.cc.

1773 {
1774 }
void DPMBase::read ( std::istream &  is)
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 3356 of file DPMBase.cc.

References PeriodicBoundaryHandler::addNewParticles(), DomainHandler::addNewParticles(), boundaryHandler, BaseHandler< T >::clear(), ParticleHandler::clear(), helpers::compare(), dataFile, decompose(), domainHandler, eneFile, ERROR, FATAL, fStatFile, ParticleHandler::getLargestInteractionRadius(), helpers::getLineFromStringStream(), File::getName(), getReadInteractions(), gravity_, constants::i, INFO, interactionFile, interactionHandler, interactionVTKWriter_, logger, max_, min_, name_, NO_FILE, NUMBER_OF_PROCESSORS, numberOfDomains_, numberOfTimeSteps_, particleDimensions_, particleHandler, periodicBoundaryHandler, random, RNG::read(), BaseHandler< T >::read(), BoundaryHandler::readAndAddObject(), WallHandler::readAndAddObject(), ParticleHandler::readAndAddObject(), readOld(), restartFile, restartVersion_, runNumber_, BaseVTKWriter< H >::setFileCounter(), PeriodicBoundaryHandler::setInteractionDistance(), DomainHandler::setInteractionDistance(), File::setName(), setName(), setParticlesWriteVTK(), BaseHandler< T >::setStorageCapacity(), setWallsWriteVTK(), 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().

3357 {
3358 #ifdef MERCURY_USE_MPI
3359  int previousNumberOfProcessors;
3360 #endif
3361  //Declares...
3362  std::string dummy;
3363  //...and reads in a dummy variable from the start of the stream "is"
3364  is >> dummy;
3365  //compare the string read in to the phrase "restart_version" to see if the stream corresponds
3366  //to a restart file (all restart files begin with this phrase)
3367  //if both strings match, strcmp(dummy.c_str(), "restart_version") returns 0 (here read as "false")
3368  if (dummy != "restart_version" && dummy != "MercuryDPM")
3369  {
3370  //If the strings do not match, if statement is fulfilled and the error logged
3371  //Note: only very old files did not have a restart_version
3372  logger(FATAL, "Error in DPMBase::read(is): this is not a valid restart file");
3373  }
3374  else
3375  {
3376  //reads in the restart version (earlier versions of Mercury possess different file formats!)
3377  is >> restartVersion_;
3378  //checking which version the current data file corresponds to, and reads the data in
3379  //accordingly
3380  if (restartVersion_ == "1.0" || restartVersion_ == "0.14")
3381  {
3382  //reads in and saves the relevant values from the data file to the current instance of DPMBase
3383  std::stringstream line;
3384 
3385  // Store path (if restart file is nonlocal)
3386  auto slash = restartFile.getName().rfind('/');
3387  std::string path;
3388  if (slash != std::string::npos)
3389  {
3390  path = restartFile.getName().substr(0, slash + 1);
3391  }
3392  if (!path.empty())
3393  {
3394  logger(INFO, "Adding path information (%) to file names", path);
3395  }
3396 
3397  //line 1
3399  //discards the whitespace (ws) at the start of the stream
3400  line >> std::ws;
3401  //uses the "peek" function to access the stream's first
3402  //non-whitespace character, and check if it is an "r"
3403  if (line.peek() == 'r')
3404  //if so, reads in the current run number
3405  line >> dummy >> runNumber_;
3406  //In either case, then uses the "Files" version of the read function
3407  //to read in the rest of the relevant information.
3408  line >> dummy >> name_;
3409  setName(name_);
3410 
3411  //Read line 2-7 (definition of i/o files)
3413  line >> dummy >> dataFile;
3415  line >> dummy >> fStatFile;
3417  line >> dummy >> eneFile;
3419  line >> dummy >> restartFile;
3421  line >> dummy >> statFile;
3422 
3423  // Add the file path from the restart file to the file names
3424  dataFile.setName(path + dataFile.getName());
3425  fStatFile.setName(path + fStatFile.getName());
3426  eneFile.setName(path + eneFile.getName());
3427  restartFile.setName(path + restartFile.getName());
3428  statFile.setName(path + statFile.getName());
3429 
3430  // Get current position
3431  //check if the next line starts with 'interactionFile'; otherwise, skip interaction
3432  if (helpers::compare(is, "interactionFile"))
3433  {
3435  line >> interactionFile;
3436  interactionFile.setName(path + interactionFile.getName());
3437  }
3438 
3440  line >> dummy >> min_.x()
3441  >> dummy >> max_.x()
3442  >> dummy >> min_.y()
3443  >> dummy >> max_.y()
3444  >> dummy >> min_.z()
3445  >> dummy >> max_.z();
3446 
3448  line >> dummy >> timeStep_
3449  >> dummy >> time_
3450  >> dummy >> numberOfTimeSteps_
3451  >> dummy >> timeMax_;
3452 
3454  line >> dummy >> systemDimensions_
3455  >> dummy >> particleDimensions_
3456  >> dummy >> gravity_;
3457 
3458  line >> dummy;
3459  if (!dummy.compare("writeVTK"))
3460  {
3461  FileType writeInteractionsVTK = FileType::NO_FILE;
3462  unsigned particlesCounter, wallCounter, interactionCounter;
3463  line >> writeParticlesVTK_ >> writeWallsVTK_ >> writeInteractionsVTK >> particlesCounter >> wallCounter >> interactionCounter >> dummy;
3466  interactionHandler.setWriteVTK(writeInteractionsVTK);
3467  vtkWriter_->setFileCounter(particlesCounter);
3468  wallVTKWriter_.setFileCounter(particlesCounter);
3469  interactionVTKWriter_.setFileCounter(particlesCounter);
3470  }
3471  if (!dummy.compare("random"))
3472  {
3473  random.read(line);
3474  line >> dummy;
3476  setXBallsAdditionalArguments(line.str());
3477  }
3478 #ifdef MERCURY_USE_MPI
3479  if (!dummy.compare("numberOfProcessors"))
3480  {
3481  line >> previousNumberOfProcessors
3482  >> dummy >> numberOfDomains_[Direction::XAXIS]
3485  }
3486  else
3487  {
3488  logger(INFO,"Reading a serial restart file");
3489  //numberOfDomains_ = {1,1,1};
3490  }
3491 #endif
3492 
3493  speciesHandler.read(is);
3494 
3495 #ifdef MERCURY_USE_MPI
3496  //Initialise MPI structures and perform domain decomposition
3497  decompose();
3498 #endif
3499 
3500  //reading in the various relevant handlers
3501  unsigned int N;
3502  is >> dummy >> N;
3503  if (dummy.compare("Walls"))
3504  logger(ERROR, "DPMBase::read(is): Error during restart: 'Walls' argument could not be found.");
3505  wallHandler.clear();
3508  for (unsigned int i = 0; i < N; i++)
3509  {
3512  }
3513 
3514  is >> dummy >> N;
3517  if (dummy.compare("Boundaries"))
3518  logger(ERROR, "DPMBase::read(is): Error during restart: 'Boundaries' argument could not be found.");
3520  for (unsigned int i = 0; i < N; i++)
3521  {
3524  }
3525 
3526  is >> dummy >> N;
3527  if (dummy.compare("Particles"))
3528  logger(ERROR, "DPMBase::read(is): Error during restart: 'Particles' argument could not be found. %",dummy);
3532  for (unsigned int i = 0; i < N; i++)
3533  {
3537  //particleHandler.getLastObject()->computeMass();
3538  }
3539 #ifdef MERCURY_USE_MPI
3540  //Interaction distances of the domainHandler and periodicBoundaryHandler need to be set
3541  Mdouble interactionRadius = particleHandler.getLargestInteractionRadius();
3542  domainHandler.setInteractionDistance(2.0*interactionRadius);
3543  periodicBoundaryHandler.setInteractionDistance(2.0*interactionRadius);
3544 
3545  if (NUMBER_OF_PROCESSORS > 1)
3546  {
3547  //Create ghost particles
3550  }
3551 #endif
3552  //Add interactions to particles and ghost particles
3553 
3555  }
3556  //reading in for older versions of the Mercury restart file.
3557  else if (!restartVersion_.compare("3"))
3558  {
3559  logger(INFO, "DPMBase::read(is): restarting from an old restart file (restart_version %).",
3560  restartVersion_);
3561  readOld(is);
3562  }
3563  //returning an error if there is no restart file to read in due to the use of outdated files.
3564  else
3565  {
3566  //only very old files did not have a restart_version
3567  logger(FATAL,
3568  "Error in DPMBase::read(is): restart_version % cannot be read; use an older version of Mercury to upgrade the file",
3569  restartVersion_);
3570  }
3571  }
3572 }
Mdouble timeMax_
Stores the duration of the simulation.
Definition: DPMBase.h:1193
void setFileCounter(unsigned fileCounter)
Definition: BaseVTKWriter.h:61
void setWallsWriteVTK(FileType writeWallsVTK)
Sets whether walls are written into a VTK file.
Definition: DPMBase.cc:806
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:1269
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:1173
double Mdouble
Definition: GeneralDefine.h:34
unsigned int particleDimensions_
determines if 2D or 3D particle volume is used for mass calculations
Definition: DPMBase.h:1157
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:3723
void setParticlesWriteVTK(bool writeParticlesVTK)
Sets whether particles are written in a VTK file.
Definition: DPMBase.cc:832
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
WallVTKWriter wallVTKWriter_
Definition: DPMBase.h:1234
File interactionFile
File class to handle in- and output into .interactions file. This file hold information about interac...
Definition: DPMBase.h:1363
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:3577
InteractionVTKWriter interactionVTKWriter_
Definition: DPMBase.h:1236
int runNumber_
This stores the run number for saving.
Definition: DPMBase.h:1264
DomainHandler domainHandler
An object of the class DomainHandler which deals with parallel code.
Definition: DPMBase.h:1321
std::vector< unsigned > numberOfDomains_
Vector containing the number of domains in x-,y- and z-direction, required for parallel computations...
Definition: DPMBase.h:1167
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:309
void addNewParticles()
unsigned int numberOfTimeSteps_
Stores the number of time steps.
Definition: DPMBase.h:1183
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:1152
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:1337
file will not be created/read
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1342
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:1311
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:1316
ParticleVtkWriter * vtkWriter_
Definition: DPMBase.h:1232
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1296
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:285
Mdouble time_
Stores the current simulation time.
Definition: DPMBase.h:1178
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1286
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1326
FileType writeWallsVTK_
A flag to turn on/off the vtk writer for walls.
Definition: DPMBase.h:1223
Mdouble & y()
RW reference to Y.
Definition: Vector.h:297
void setXBallsAdditionalArguments(std::string newXBArgs)
Set the additional arguments for xballs.
Definition: DPMBase.cc:1201
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:59
Mdouble timeStep_
Stores the simulation time step.
Definition: DPMBase.h:1188
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1306
void setWriteVTK(FileType f)
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:1291
bool writeParticlesVTK_
A flag to turn on/off the vtk writer for particles.
Definition: DPMBase.h:1228
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:414
File statFile
An instance of class File to handle in- and output into a .stat file.
Definition: DPMBase.h:1357
bool compare(std::istream &is, std::string s)
Checks if the next argument in the input stream is a certain string.
Definition: Helpers.cc:872
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1347
void setInteractionDistance(Mdouble interactionDistance)
Sets the interaction distance of the domain handler.
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1352
std::string restartVersion_
Previous versions of MercuryDPM had a different restart file format, the below member variable allows...
Definition: DPMBase.h:1200
void setName(const std::string &name)
Sets the file name, e.g. "Name.data".
Definition: File.cc:199
bool getReadInteractions() const
Definition: DPMBase.h:1373
Vec3D min_
These vectors are used for the XBalls domain, and occasionally people use it to add walls...
Definition: DPMBase.h:1172
Mdouble getLargestInteractionRadius() const
Returns the largest interaction radius.
const std::string & getName() const
Allows to access the file name, e.g., "problem.data".
Definition: File.cc:166
Vec3D gravity_
Gravity vector.
Definition: DPMBase.h:1162
virtual void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
Definition: BaseHandler.h:528
void setInteractionDistance(Mdouble interactionDistance)
Sets the interaction distance.
bool DPMBase::readArguments ( int  argc,
char *  argv[] 
)

Can interpret main function input arguments that are passed by the driver codes.

Interprets commands passed in the command line (e.g. -tmin 0 -tmax 100 ...).

argc gives the number of commands passed, while argv stores the commands themselves (as strings).

Outputs the name and value of each flag passed, then calls the readNextArgument() function to actually interpret and implement the relevant arguments. Will raise an error if an unknown flag is passed.

Parameters
[in]argc"Argument count" - number of individual elements that argv will possess
[in]*argv[]An array of length argc - specifically an array of strings (or, in C terminology, a character array)

Definition at line 4011 of file DPMBase.cc.

References ERROR, constants::i, logger, and readNextArgument().

Referenced by solve().

4012 {
4013  bool isRead = true;
4014  // Cycles over every second element. (Most flags will contain both name labels and actual data.
4015  // Those that don't will have to do i--; some examples in readNextArgument.)
4016  for (int i = 1; i < argc; i += 2)
4017  {
4018  std::cout << "interpreting input argument " << argv[i];
4019  for (int j = i + 1; j < argc; j++)
4020  {
4021  //looks for the next string that starts with a minus sign
4022  //i.e. the next flag, as each flag may take 0, 1 , 2, 3... arguments
4023  //and we need to make sure all are read in!
4024  if (argv[j][0] == '-')
4025  break;
4026  std::cout << " " << argv[j];
4027  }
4028  std::cout << std::endl;
4029  //if "isRead"is true and "readNextArgument" is also true...
4030  //(i.e. checking if any argument is false)
4031  isRead &= readNextArgument(i, argc, argv);
4032 
4033  // If the read was unsuccessful, raise an error and quit. (JMFT: Used to just be a warning.)
4034  if (!isRead)
4035  {
4036  logger(ERROR, "Warning: not all arguments read correctly!");
4037  }
4038  }
4039  return isRead;
4040 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
virtual bool readNextArgument(int &i, int argc, char *argv[])
Interprets the i^th command-line argument.
Definition: DPMBase.cc:4136
bool DPMBase::readDataFile ( std::string  fileName = "",
unsigned int  format = 0 
)

This allows particle data to be reloaded from data files.

This function reads a .data file, which contains info about each particle's position, velocity, angular velocity, radius ...info. See also MD::readRestartFile For XBalls: Can read in format_ 14 - 8 or format_ 7 data format. This code saves in format_ 8 for 2D and format_ 14 for 3D. So if no extra parameters are specified it will assume many parameters, like density cannot be set using the data file. use of string instead of string& b/c this function is often used with a string literal

Parameters
[in]fileName
[in]format(format for specifying if its for 2D or 3D data)
Returns
bool (True or False)

Definition at line 2206 of file DPMBase.cc.

References File::close(), dataFile, File::getCounter(), File::getFileType(), File::getFstream(), File::getFullName(), File::getName(), logger, ONE_FILE, File::open(), readNextDataFile(), File::setCounter(), File::setFileType(), File::setName(), and WARN.

Referenced by readNextArgument().

2207 {
2208  //default value: dataFile.getFullName()
2209  if (!fileName.compare(""))
2210  fileName = dataFile.getFullName();
2211 
2212  std::string oldFileName = dataFile.getName();
2213  unsigned oldCounter = dataFile.getCounter();
2214  //Updates the name of the data file to the user-input from the argument.
2215  dataFile.setName(fileName);
2216  //opens a filestream of the input type
2217  dataFile.open(std::fstream::in);
2218  //Checks if the file has been successfully opened...
2219  if (!dataFile.getFstream().is_open() || dataFile.getFstream().bad())
2220  {
2221  //...and if not, ends the function and returns "false"
2222  logger(WARN, "Loading data file % failed.", fileName);
2223  return false;
2224  }
2225 
2226  //retrieves and saves the "FileType" of the file
2227  FileType fileTypeData = dataFile.getFileType();
2229  readNextDataFile(format);
2230  dataFile.setFileType(fileTypeData);
2231  dataFile.close();
2232  dataFile.setName(oldFileName);
2233  dataFile.setCounter(oldCounter);
2234  return true;
2235 }
FileType getFileType() const
Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_.
Definition: File.cc:208
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void setCounter(unsigned int counter)
Allows the user to set the file counter according to his need. Sets File::counter_.
Definition: File.cc:232
const std::string getFullName() const
Also allows to access the file name, however with additional information which is the file counter...
Definition: File.cc:171
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
void close()
Closes the file by calling fstream_.close()
Definition: File.cc:408
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:1337
std::fstream & getFstream()
Allows to access the member variable File::fstream_.
Definition: File.cc:154
all data will be written into/ read from a single file called name_
bool readNextDataFile(unsigned int format=0)
Reads the next data file with default format=0. However, one can modify the format based on whether t...
Definition: DPMBase.cc:2462
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:216
bool open()
Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the ne...
Definition: File.cc:348
void setName(const std::string &name)
Sets the file name, e.g. "Name.data".
Definition: File.cc:199
const std::string & getName() const
Allows to access the file name, e.g., "problem.data".
Definition: File.cc:166
bool DPMBase::readNextArgument ( int &  i,
int  argc,
char *  argv[] 
)
virtual

Interprets the i^th command-line argument.

Reads, recognises and applies all valid flags passed when starting or restarting a Mercury simulation.

For all of the N = argc (argument count) command line arguments passed when starting/restarting a code (e.g. -tmax, -tmin ...), compares them to the "known" arguments understood by Mercury (note that further recognised arguments can be added in derived classes). If a match is found, the relevant parameter is set to the corresponding value(s) following the flag and true is returned. Otherwise, false is returned.

For instance, if the flag -xmin 0 is passed, the code's second if statement will recognise the flag, convert the subsequent string in argv to a double, and then call the setXMin() function to implement the new value (0) of XMin.

For developers: note the use of strcmp here. This cannot be replaced with a simpler ==, as we are comparing c-style strings (char*), instead of std::string. Thus, == would return equality of the pointers instead of the contents of the string. strcmp returns 0 if the strings are the same, and another number if they are different. This is then implicitly cast to a bool, where 0->false and other numbers will give true. Finally, the !-operator makes sure that the expression in the if-statements are true if the strings are the same, and false otherwise.

Parameters
[in]ithe position of the element that will be read, note that the count starts at 1, as element 0 is the name of the executable
[in]argcnumber of arguments the user has given
[in]*argv[]the command-line arguments the user has given when calling the executable
Returns
true if the argument is successfully read, and false otherwise.

-gravity_ requires three arguments

-restart or -r loads a restart file. By default, it loads <name>.restart. If an argument "arg" is given it loads the file "arg", or "arg".restart (if the ending is not given).

Reimplemented in MercuryBase, ChuteWithHopper, Chute, and Mercury3DRestart.

Definition at line 4136 of file DPMBase.cc.

References autoNumber(), dataFile, eneFile, fStatFile, getName(), File::getSaveCount(), getTimeMax(), getTimeStep(), INFO, logger, random, RNG::randomise(), readDataFile(), readRestartFile(), readSpeciesFromDataFile_, removeOldFiles(), restartFile, setAppend(), File::setFileType(), setFileType(), setFixedParticles(), setGravity(), setName(), setRunNumber(), File::setSaveCount(), setSaveCount(), setSystemDimensions(), setTimeMax(), setTimeStep(), setXMax(), setXMin(), setYMax(), setYMin(), setZMax(), setZMin(), and statFile.

Referenced by readArguments(), and MercuryBase::readNextArgument().

4137 {
4138  // The argument argv[i] identifies the label of the flag, and subsequent arguments (usually 1)
4139  // contain the content.
4140  //
4141  // For example...
4142  // Checks if the "-name" flag has been passed
4143  // The strcmp returns 0 if "argv[i]" is "-name" (i.e. !strcmp(argv[i], "-name") --> 1)
4144  // In this case, the setName function is run with the relevant input (i.e. the value which
4145  // immediately follows the "-name" flag
4146  if (!strcmp(argv[i], "-name"))
4147  {
4148  setName(argv[i + 1]);
4149  }
4150  // The above process is repeated for all viable flags.
4151  else if (!strcmp(argv[i], "-xmin"))
4152  {
4153  setXMin(atof(argv[i + 1]));
4154  }
4155  else if (!strcmp(argv[i], "-ymin"))
4156  {
4157  setYMin(atof(argv[i + 1]));
4158  }
4159  else if (!strcmp(argv[i], "-zmin"))
4160  {
4161  setZMin(atof(argv[i + 1]));
4162  }
4163  else if (!strcmp(argv[i], "-xmax"))
4164  {
4165  setXMax(atof(argv[i + 1]));
4166  }
4167  else if (!strcmp(argv[i], "-ymax"))
4168  {
4169  setYMax(atof(argv[i + 1]));
4170  }
4171  else if (!strcmp(argv[i], "-zmax"))
4172  {
4173  setZMax(atof(argv[i + 1]));
4174  //} else if (!strcmp(argv[i],"-svn")) {
4175  // std::cout << "svn version " << SVN_VERSION << std::endl;
4176  // i--;
4177  }
4178  else if (!strcmp(argv[i], "-dt"))
4179  {
4180  Mdouble old = getTimeStep();
4181  setTimeStep(atof(argv[i + 1]));
4182  std::cout << " reset dt from " << old << " to " << getTimeStep() << std::endl;
4183  }
4184 // else if (!strcmp(argv[i], "-Hertz"))
4185 // {
4186 // speciesHandler.getObject(0)->setForceType(ForceType::HERTZ);
4187 // i--;
4188 // }
4189  else if (!strcmp(argv[i], "-tmax"))
4190  {
4191  Mdouble old = getTimeMax();
4192  setTimeMax(atof(argv[i + 1]));
4193  std::cout << " reset timeMax from " << old << " to " << getTimeMax() << std::endl;
4194  }
4195  else if (!strcmp(argv[i], "-saveCount"))
4196  {
4197  Mdouble old = dataFile.getSaveCount();
4198  setSaveCount(static_cast<unsigned int>(atoi(argv[i + 1])));
4199  std::cout << " reset saveCount from " << old << " to " << dataFile.getSaveCount() << std::endl;
4200  }
4201  else if (!strcmp(argv[i], "-saveCountData"))
4202  {
4203  dataFile.setSaveCount(static_cast<unsigned int>(atoi(argv[i + 1])));
4204  }
4205  else if (!strcmp(argv[i], "-saveCountFStat"))
4206  {
4207  fStatFile.setSaveCount(static_cast<unsigned int>(atoi(argv[i + 1])));
4208  }
4209  else if (!strcmp(argv[i], "-saveCountStat"))
4210  {
4211  statFile.setSaveCount(static_cast<unsigned int>(atoi(argv[i + 1])));
4212  }
4213  else if (!strcmp(argv[i], "-saveCountEne"))
4214  {
4215  eneFile.setSaveCount(static_cast<unsigned int>(atoi(argv[i + 1])));
4216  }
4217  else if (!strcmp(argv[i], "-saveCountRestart"))
4218  {
4219  restartFile.setSaveCount(static_cast<unsigned int>(atoi(argv[i + 1])));
4220  }
4221  else if (!strcmp(argv[i], "-dim"))
4222  {
4223  setSystemDimensions(static_cast<unsigned int>(atoi(argv[i + 1])));
4224  }
4225  else if (!strcmp(argv[i], "-gravity"))
4226  {
4228  setGravity(Vec3D(atof(argv[i + 1]), atof(argv[i + 2]), atof(argv[i + 3])));
4229  i += 2;
4230  }
4231  else if (!strcmp(argv[i], "-fileType"))