41 #include <sys/types.h>
52 #include "DPMBaseXBalls.icc"
65 std::cerr <<
"A fatal error has occured"
66 <<
"\n Module :" << module
67 <<
"\n Message :" << message << std::endl;
115 #ifdef CONTACT_LIST_HGRID
116 possibleContactList=other.possibleContactList;
187 std::cerr <<
"Error in setTimeMax, newTMax=" << newTMax << std::endl;
201 #ifdef CONTACT_LIST_HGRID
204 return possibleContactList;
274 std::cerr <<
"Warning in setXMin(" << newXMin <<
"): xMax=" <<
getXMax() << std::endl;
288 std::cerr <<
"Error in setYMin(" << newYMin <<
"): yMax=" <<
getYMax() << std::endl;
303 std::cerr <<
"Warning in setZMin(" << newZMin <<
"): zMax=" <<
getZMax() << std::endl;
317 std::cerr <<
"Error in setXMax(" << newXMax <<
"): xMin=" <<
getXMin() << std::endl;
332 std::cerr <<
"Warning in setYMax(" << newYMax <<
"): yMin=" <<
getYMin() << std::endl;
346 std::cerr <<
"Error in setZMax(" << newZMax <<
"): zMin=" <<
getZMin() << std::endl;
361 std::cerr <<
"Error in setTimeStep" << std::endl;
455 if (newDim >= 1 && newDim <= 3)
459 std::cerr <<
"Error in setSystemDimensions" << std::endl;
476 if (particleDimensions >= 1 && particleDimensions <= 3)
483 std::cerr <<
"Error in setParticleDimensions" << std::endl;
556 elasticEnergy += (*it)->getElasticEnergy();
557 return elasticEnergy;
568 if (!(*it)->isFixed())
570 kineticEnergy += .5 * (*it)->getMass() * (*it)->getVelocity().getLengthSquared();
573 return kineticEnergy;
690 (*it)->gatherContactStatistics();
760 std::cout <<
"t=" << std::setprecision(3) << std::left << std::setw(6) <<
getTime()
761 <<
", tmax=" << std::setprecision(3) << std::left << std::setw(6) <<
getTimeMax()
826 std::cerr <<
"MD problem constructor finished " << std::endl;
847 long width = os.precision() + 6;
848 os << std::setw(width) <<
"t" <<
" " << std::setw(width)
849 <<
"ene_gra" <<
" " << std::setw(width)
850 <<
"ene_kin" <<
" " << std::setw(width)
851 <<
"ene_rot" <<
" " << std::setw(width)
852 <<
"ene_ela" <<
" " << std::setw(width)
853 <<
"X_COM" <<
" " << std::setw(width)
854 <<
"Y_COM" <<
" " << std::setw(width)
855 <<
"Z_COM" << std::endl;
886 os << std::numeric_limits<double>::quiet_NaN();
895 os << std::numeric_limits<double>::quiet_NaN();
905 (*it)->writeToFStat(os);
914 Mdouble ene_kin = 0, ene_elastic = 0, ene_rot = 0, ene_gra = 0, mass_sum = 0, x_masslength = 0, y_masslength = 0, z_masslength = 0;
917 if (!(*it)->isFixed())
919 ene_kin += .5 * (*it)->getMass() * (*it)->getVelocity().getLengthSquared();
920 ene_rot += .5 * (*it)->getInertia() * (*it)->getAngularVelocity().getLengthSquared();
922 mass_sum += (*it)->getMass();
923 x_masslength += (*it)->getMass() * (*it)->getPosition().X;
924 y_masslength += (*it)->getMass() * (*it)->getPosition().Y;
925 z_masslength += (*it)->getMass() * (*it)->getPosition().Z;
931 long width = os.precision() + 6;
932 os << std::setw(width) <<
getTime()
933 <<
" " << std::setw(width) << ene_gra
934 <<
" " << std::setw(width) << ene_kin
935 <<
" " << std::setw(width) << ene_rot
936 <<
" " << std::setw(width) << ene_elastic
937 <<
" " << std::setw(width) << (mass_sum != 0.0 ? x_masslength / mass_sum : std::numeric_limits<double>::quiet_NaN())
938 <<
" " << std::setw(width) << (mass_sum != 0.0 ? y_masslength / mass_sum : std::numeric_limits<double>::quiet_NaN())
939 <<
" " << std::setw(width) << (mass_sum != 0.0 ? z_masslength / mass_sum : std::numeric_limits<double>::quiet_NaN()) << std::endl;
960 std::cerr <<
"Unknown systemdimension" << std::endl;
980 std::cerr <<
"Have output the properties of the problem to disk " << std::endl;
997 std::cout <<
"Loading data file " << fileName <<
" failed" << std::endl;
1022 file.open(fileName, std::fstream::in);
1023 if (!file.is_open() || file.bad())
1039 file >> integerValue;
1041 if (integerValue == 0)
1057 else if (integerValue == 1)
1067 else if (integerValue == 5)
1080 else if (integerValue == 6)
1092 std::cerr <<
"Error in par.ini: line 1, value 1 is " << integerValue << std::endl;
1097 file >> integerValue;
1100 file >> doubleValue;
1107 file >> doubleValue;
1108 if (doubleValue < 0)
1113 file >> doubleValue;
1118 file >> doubleValue;
1119 if (doubleValue >= 0)
1122 unsigned int savecount =
static_cast<unsigned int>(round(doubleValue /
getTimeStep()));
1127 file >> doubleValue;
1128 savecount =
static_cast<unsigned int>(round(doubleValue /
getTimeStep()));
1139 std::cerr <<
"Error in par.ini: line 3, value 1 is " << doubleValue << std::endl;
1146 file >> doubleValue;
1154 S->setDensity(doubleValue);
1157 file >> doubleValue;
1158 S->setStiffness(doubleValue);
1161 file >> doubleValue;
1162 S->setDissipation(doubleValue);
1165 file >> doubleValue;
1166 if (doubleValue != 0.0)
1167 std::cerr <<
"Warning in par.ini: ignored background damping " << doubleValue << std::endl;
1172 file >> doubleValue;
1173 if (doubleValue != 0.0)
1174 std::cerr <<
"Warning in par.ini: ignored growth rate " << doubleValue << std::endl;
1177 file >> doubleValue;
1178 if (doubleValue != 0.0)
1179 std::cerr <<
"Warning in par.ini: ignored target volume_fraction " << doubleValue << std::endl;
1203 std::cout <<
"file " <<
dataFile.
getName() <<
" not found" << std::endl;
1264 std::cout <<
"Number of particles read from file "<<N << std::endl;
1289 Vec3D position, velocity;
1292 dataFile.
getFstream() >> position.
X >> position.
Z >> position.
Y >> velocity.
X >> velocity.
Z >> velocity.
Y >> radius >> dummy;
1293 (*it)->setPosition(position);
1294 (*it)->setVelocity(velocity);
1295 (*it)->setOrientation(
Vec3D(0.0, 0.0, 0.0));
1296 (*it)->setAngularVelocity(
Vec3D(0.0, 0.0, 0.0));
1297 (*it)->setRadius(radius);
1309 Vec3D position, velocity, angle, angularVelocity;
1312 dataFile.
getFstream() >> position.
X >> position.
Y >> velocity.
X >> velocity.
Y >> radius >> angle.
Z >> angularVelocity.
Z >> dummy;
1313 (*it)->setPosition(position);
1314 (*it)->setVelocity(velocity);
1315 (*it)->setOrientation(-angle);
1316 (*it)->setAngularVelocity(-angularVelocity);
1317 (*it)->setRadius(radius);
1326 Vec3D position, velocity, angle, angularVelocity;
1329 dataFile.
getFstream() >> position >> velocity >> radius >> angle >> angularVelocity >> dummy;
1330 (*it)->setPosition(position);
1331 (*it)->setVelocity(velocity);
1332 (*it)->setOrientation(angle);
1333 (*it)->setAngularVelocity(angularVelocity);
1334 (*it)->setRadius(radius);
1343 Vec3D position, velocity, angle, angularVelocity;
1346 dataFile.
getFstream() >> position >> velocity >> radius >> angle >> angularVelocity >> dummy >> dummy;
1347 (*it)->setPosition(position);
1348 (*it)->setVelocity(velocity);
1349 (*it)->setOrientation(angle);
1350 (*it)->setAngularVelocity(angularVelocity);
1351 (*it)->setRadius(radius);
1591 (*it)->setForce(
Vec3D(0.0, 0.0, 0.0));
1592 (*it)->setTorque(
Vec3D(0.0, 0.0, 0.0));
1596 (*it)->setForce(
Vec3D(0.0, 0.0, 0.0));
1597 (*it)->setTorque(
Vec3D(0.0, 0.0, 0.0));
1601 std::cerr <<
"Have all forces set to zero " << std::endl;
1617 #ifdef CONTACT_LIST_HGRID
1644 os <<
"restart_version " <<
"1.0";
1651 <<
" zMax " <<
getZMax() << std::endl
1662 os << (**it) << std::endl;
1665 os << (**it) << std::endl;
1673 for (
unsigned int i = 0; i < 2; i++)
1675 os <<
"..." << std::endl;
1684 for (
unsigned int i = 0; i < 2; i++)
1686 os <<
"..." << std::endl;
1699 if (strcmp(dummy.c_str(),
"restart_version"))
1702 logger.log(
Log::FATAL,
"Error in DPMBase::read(is): this is not a valid restart file");
1707 if (!restartVersion_.compare(
"1.0"))
1710 is >> dummy >>
xMin_
1726 std::stringstream line(std::stringstream::in | std::stringstream::out);
1730 for (
unsigned int i = 0; i < N; i++)
1739 for (
unsigned int i = 0; i < N; i++)
1748 for (
unsigned int i = 0; i < N; i++)
1757 else if (!restartVersion_.compare(
"3"))
1759 logger.log(
Log::INFO,
"DPMBase::read(is): restarting from an old restart file (restart_version %).", restartVersion_);
1765 logger.log(
Log::FATAL,
"Error in DPMBase::read(is): restart_version % cannot be read; use an older version of Mercury to upgrade the file", restartVersion_);
1775 is >> dummy >> dummy;
1778 unsigned int saveCountData, saveCountEne, saveCountStat, saveCountFStat;
1779 unsigned int fileTypeFstat, fileTypeData, fileTypeEne, fileTypeRestart;
1780 is >> dummy >>
xMin_
1789 >> dummy >> saveCountData
1790 >> dummy >> saveCountEne
1791 >> dummy >> saveCountStat
1792 >> dummy >> saveCountFStat
1795 >> dummy >> fileTypeFstat
1796 >> dummy >> fileTypeData
1797 >> dummy >> fileTypeEne;
1809 if (!strcmp(dummy.c_str(),
"options_restart"))
1811 is >> fileTypeRestart;
1828 std::cerr <<
"Error in solve(): at least one species has to be defined" << std::endl;
1833 std::cerr <<
"Error in solve(): particleDimensions not specified" << std::endl;
1838 std::cerr <<
"Error in solve(): systemDimensions not specified" << std::endl;
1843 std::cerr <<
"Error in solve(): timeStep not specified" << std::endl;
1898 std::cerr <<
"Entered solve" << std::endl;
1900 #ifdef CONTACT_LIST_HGRID
1901 std::cout <<
"Using CONTACT_LIST_HGRID"<<std::endl;
1919 std::cerr <<
"Have created the particles initial conditions " << std::endl;
1931 std::stringstream name;
1939 setOpenMode(std::fstream::out | std::fstream::app);
1963 std::cerr <<
"Have computed the initial values for the forces " << std::endl;
1983 (*it)->checkBoundaryBeforeTimeStep(
this);
2018 std::cout << std::endl;
2032 for (
int i = 1; i < argc; i += 2)
2034 std::cout <<
"interpreting input argument " << argv[i];
2035 for (
int j = i + 1; j < argc; j++)
2037 if (argv[j][0] ==
'-')
2039 std::cout <<
" " << argv[j];
2041 std::cout << std::endl;
2045 std::cerr <<
"Warning: not all arguments read correctly!" << std::endl;
2060 if (!strcmp(argv[i],
"-name"))
2064 else if (!strcmp(argv[i],
"-xmin"))
2068 else if (!strcmp(argv[i],
"-ymin"))
2072 else if (!strcmp(argv[i],
"-zmin"))
2076 else if (!strcmp(argv[i],
"-xmax"))
2080 else if (!strcmp(argv[i],
"-ymax"))
2084 else if (!strcmp(argv[i],
"-zmax"))
2091 else if (!strcmp(argv[i],
"-dt"))
2095 std::cout <<
" reset dt from " << old <<
" to " <<
getTimeStep() << std::endl;
2102 else if (!strcmp(argv[i],
"-tmax"))
2106 std::cout <<
" reset timeMax from " << old <<
" to " <<
getTimeMax() << std::endl;
2108 else if (!strcmp(argv[i],
"-saveCount"))
2110 setSaveCount(static_cast<unsigned int>(atoi(argv[i + 1])));
2112 else if (!strcmp(argv[i],
"-saveCountData"))
2116 else if (!strcmp(argv[i],
"-saveCountFStat"))
2120 else if (!strcmp(argv[i],
"-saveCountStat"))
2124 else if (!strcmp(argv[i],
"-saveCountEne"))
2128 else if (!strcmp(argv[i],
"-saveCountRestart"))
2132 else if (!strcmp(argv[i],
"-dim"))
2136 else if (!strcmp(argv[i],
"-gravity"))
2139 setGravity(
Vec3D(atof(argv[i + 1]), atof(argv[i + 2]), atof(argv[i + 3])));
2142 else if (!strcmp(argv[i],
"-fileType"))
2144 setFileType(static_cast<FileType>(atoi(argv[i + 1])));
2146 else if (!strcmp(argv[i],
"-fileTypeFStat"))
2150 else if (!strcmp(argv[i],
"-fileTypeRestart"))
2154 else if (!strcmp(argv[i],
"-fileTypeData"))
2158 else if (!strcmp(argv[i],
"-fileTypeStat"))
2162 else if (!strcmp(argv[i],
"-fileTypeEne"))
2166 else if (!strcmp(argv[i],
"-auto_number"))
2175 else if (!strcmp(argv[i],
"-restart") || !strcmp(argv[i],
"-r"))
2180 std::string filename;
2183 if (i + 1 >= argc || argv[i + 1][0] ==
'-')
2187 std::cout <<
getName() << std::endl;
2190 filename = argv[i + 1];
2193 if (filename.find(
".restart") == std::string::npos)
2195 filename = filename +
".restart";
2198 std::cout <<
"restart from " << filename << std::endl;
2201 else if (!strcmp(argv[i],
"-clean") || !strcmp(argv[i],
"-c"))
2203 std::cout<<
"Remove old " <<
getName() <<
".* files" << std::endl;
2206 std::ostringstream filename;
2207 std::vector<std::string> ext {
".restart",
".stat",
".fstat",
".data",
".ene",
".xballs"};
2208 for (
unsigned int j=0; j<ext.size(); j++)
2212 filename <<
getName() <<ext[j];
2213 if( !
remove( filename.str().c_str() ) )
2215 std::cout<<
" File " << filename.str() <<
" successfully deleted" << std::endl;
2219 filename.clear(); filename <<
getName() << ext[j] <<
'.' << k;
2220 while( !
remove( filename.str().c_str() ) )
2222 std::cout<<
" File " << filename.str() <<
" successfully deleted" << std::endl;
2224 filename <<
getName() << ext[j] <<
'.' << ++k;
2229 while( !
remove( filename.str().c_str() ) )
2231 std::cout<<
" File " << filename.str() <<
" successfully deleted" << std::endl;
2238 else if (!strcmp(argv[i],
"-data"))
2240 std::string filename = argv[i + 1];
2291 else if (!strcmp(argv[i],
"-randomise") || !strcmp(argv[i],
"-randomize"))
2316 else if (!strcmp(argv[i],
"-append"))
2321 else if (!strcmp(argv[i],
"-fixedParticles"))
2335 else if (!strcmp(argv[i],
"-counter"))
2361 if ((*it)->getDistanceAndNormal(p, distance, normal))
2414 for (
unsigned int i = 0; i < N; i++)
2426 std::cout <<
"Interactions currently in the handler:" << std::endl;
2429 (*it)->write(std::cout);
2430 std::cout << std::endl;
2431 std::cout <<
"Interaction " << (*it)->getName() <<
" " << (*it)->getId() <<
" between " << (*it)->getP()->getId() <<
" and " << (*it)->getI()->getId() << std::endl;
const Vec3D & getForce() const
Gets the current force (vector) between the two interacting objects.
Mdouble timeMax_
Stores the duration of the simulation.
void setTime(Mdouble time)
Access function for the time.
BaseParticle * getLargestParticle() const
Gets a pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.
virtual void actionsBeforeTimeLoop()
A virtual function. Allows one to carry out any operations before the start of the time loop...
unsigned int getId() const
Returns the unique identifier of any particular object.
void setXBallsVectorScale(double newVScale)
Set the scale of vectors in xballs.
virtual void write(std::ostream &os, bool writeAllParticles=true) const
Loads all MD data and plots statistics for all timesteps in the .data file.
virtual void hGridUpdateParticle(BaseParticle *obj UNUSED)
no implementation but can be overidden in its derived classes.
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a periodic wall.
void setXMax(Mdouble newXMax)
If the length of the problem domain in x-direction is XMax - XMin, this method sets XMax...
void write(std::ostream &os) const
void solve()
The work horse of the code.
Mdouble yMax_
If the length of the problem domain in y-direction is YMax - XMin, the above variable stores YMax...
virtual void hGridInsertParticle(BaseParticle *obj UNUSED)
no implementation but can be overidden in its derived classes.
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Mdouble X
the vector components
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, ..
virtual void integrateAfterForceComputation()
Integration is done after force computations. We apply the Velocity verlet scheme. See http://en.wikipedia.org/wiki/Verlet_integration#Velocity_Verlet.
void checkAndDuplicatePeriodicParticles()
In case of periodic boundaries, the below methods checks and adds particles when necessary into the p...
int getXBallsColourMode() const
Get the xball colour mode (CMode)
void setNextSavedTimeStep(unsigned int nextSavedTimeStep)
Sets the next time step for all the files (ene, data, fstat, restart, stat) at which the data is to b...
void setTimeMax(Mdouble newTMax)
Allows the upper time limit to be changed.
bool areInContact(const BaseParticle *pI, const BaseParticle *pJ) const
Checks if two particle are in contact or is there any positive overlap.
void constructor()
A function which initialises the member variables to default values, so that the problem can be solve...
void write(std::ostream &os) const
Writes the InteractionHandler to an output stream, for example a restart file.
unsigned int getSystemDimensions() const
Returns the dimension of the simulation. Note there is also a particle dimension. ...
bool readArguments(int argc, char *argv[])
Can interpret main function input arguments that are passed by the driver codes.
FileType getFileType() const
Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
unsigned int particleDimensions_
determines if 2D or 3D particle volume is used for mass calculations
Mdouble yMin_
If the length of the problem domain in y-direction is YMax - YMin, the above variable stores YMin...
void setDPMBase(DPMBase *DPMBase)
Sets the problem that is solved using this handler.
void setYMin(Mdouble newYMin)
If the length of the problem domain in y-direction is YMax - YMin, this method sets YMin...
virtual void computeInternalForces(BaseParticle *i)
Computes the forces between particles (internal in the sense that the sum over all these forces is ze...
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
void setStorageCapacity(const unsigned int N)
Sets the storage capacity of this BaseHandler.
unsigned int getParticleDimensions() const
Returns the particle dimensions.
bool readDataFile(const std::string fileName, unsigned int format=0)
This allows particle data to be reloaded from data files.
void computeAllMasses(unsigned int indSpecies)
Computes the mass for all BaseParticle of the given species in this ParticleHandler.
virtual void initialiseStatistics()
no implementation but can be overidden in its derived classes.
File restartFile
An instance of class File to handle in- and output into a .restart file.
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
void setXBallsColourMode(int newCMode)
Set the xball output mode.
const std::vector< T * >::const_iterator end() const
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
virtual void readOld(std::istream &is)
Reads all particle data into a restart file; old version.
void closeFiles()
Closes all files (ene, data, fstat, restart, stat) that were opened to read or write.
void setParticleDimensions(unsigned int particleDimensions)
Allows the dimension of the particle (f.e. for mass) to be changed. e.g. discs or spheres...
virtual ~DPMBase()
virtual destructor
virtual void actionsAfterTimeStep()
A virtual function which allows to define operations to be executed after time step.
void readObject(std::istream &is)
Reads BaseParticle into the ParticleHandler from restart data.
void setZMax(Mdouble newZMax)
If the length of the problem domain in z-direction is XMax - XMin, this method sets ZMax...
void write(std::ostream &os) const
Accepts an output stream read function, which accepts an input stream std::ostream.
bool openNextFile()
This function should be called before a data corresponding to the new time step is written or read...
void setDimension(unsigned int newDim)
Sets the system and particle dimension.
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
void setAppend(bool newAppendFlag)
Allows to set the append option.
virtual void writeOutputFiles()
Writes the simulation data onto all the files i.e. .data, .ene, .fstat ...
void setSystemDimensions(unsigned int newDim)
Allows for the dimension of the simulation to be changed.
Species< LinearViscoelasticNormalSpecies, SlidingFrictionSpecies > LinearViscoelasticSlidingFrictionSpecies
void setFileType(FileType fileType)
Sets File::fileType_ for all files (ene, data, fstat, restart, stat)
void read(std::istream &is)
Reads all objects from restart data.
virtual void write(std::ostream &os) const
Write all the species and mixed species to an output stream.
void setGravity(Vec3D newGravity)
Allows to modify the gravity vector.
T square(T val)
squares a number
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...
void logWriteAndDie(std::string module, std::string message)
todo strcmp relies on this, should be changed to more modern version
virtual bool getHGridUpdateEachTimeStep() const
bool rotation_
A flag to turn on/off particle rotation.
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Stores information about interactions between two interactable objects; often particles but could be ...
void randomise()
sets the random variables such that they differ for each run
void eraseOldInteractions(Mdouble lastTimeStep)
erases interactions which have an old timestamp.
void setRunNumber(int runNumber)
This sets the counter/Run number, overriding the defaults.
Mdouble zMax_
If the length of the problem domain in z-direction is ZMax - ZMin, the above variable stores ZMax...
FileType
With FileType options, one is able to choose if data is to be read/written from/into no or single or ...
bool restarted_
A bool to check if the simulation was restarted or not.
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Defines a pair of periodic walls. Inherits from BaseBoundary.
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
void clear()
Empties the whole ParticleHandler by removing all BaseParticle.
void setRotation(bool newRotFlag)
Allows to set the flag for enabling or disabling particle rotation in the simulations.
void readObject(std::istream &is)
Reads BaseWall into the WallHandler from restart data.
void setOpenMode(std::fstream::openmode openMode)
Sets File::openMode_ for all files (ene, data, fstat, restart, stat)
virtual void processStatistics(bool usethese UNUSED)
no implementation but can be overidden in its derived classes.
void close()
Closes the file by calling fstream_.close()
bool findNextExistingDataFile(Mdouble tMin, bool verbose=true)
Useful when fileType is chosen as Multiple Files or Multiple files with padded.
void setYMax(Mdouble newYMax)
If the length of the problem domain in y-direction is YMax - YMin, this method sets YMax...
unsigned int systemDimensions_
The dimensions of the simulation i.e. 2D or 3D.
void readObject(std::istream &is)
Reads BaseBoundary into the BoundaryHandler from restart data.
const Vec3D & getContactPoint() const
Gets constant reference to contact point (vector).
File eneFile
An instance of class File to handle in- and output into a .ene file.
Mdouble zMin_
If the length of the problem domain in z-direction is ZMax - ZMin, the above variable stores ZMin...
Mdouble getElasticEnergy() const
Returns the global elastic energy within the system.
Mdouble xMax_
If the length of the problem domain in x-direction is XMax - XMin, the above variable stores XMax...
unsigned int getCounter() const
In case of multiple files, File::getCounter() returns the the number (FILE::Counter_) of the next fil...
void removeObjectKeepingPeriodics(unsigned const int id)
Removes interactions of periodic particles when the periodic particles get deleted (see DPMBase::remo...
file will not be created/read
unsigned int ntimeSteps_
Stores the number of time steps.
virtual void writeEneTimestep(std::ostream &os) const
This function enables one to write the global energy available in the system after each time step...
int readRestartFile()
Reads all the particle data corresponding to the current saved time step. Which is what the restart f...
std::fstream & getFstream()
Allows to access the member variable File::fstream_.
virtual void hGridActionsBeforeIntegration()
no implementation but can be overidden in its derived classes.
BaseParticle * getSmallestParticle() const
Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler.
bool getAppend() const
Returns the flag denoting if the append option is on or off.
virtual bool readNextArgument(int &i, int argc, char *argv[])
virtual bool checkParticleForInteraction(const BaseParticle &P)
Checks if the particle having any interaction with walls or other particles.
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
U * copyAndAddObject(const U &O)
Creates a copy of a Object and adds it to the BaseHandler.
void resetFileCounter()
Resets the file counter for each file i.e. for ene, data, fstat, restart, stat)
bool getRestarted() const
Returns the flag denoting if the simulation was restarted or not.
Mdouble getMass() const
Returns the particle's mass_.
void getLineFromStringStream(std::istream &in, std::stringstream &out)
Reads a line from one stringstream into another, and prepares the latter for reading in...
virtual void addObject(ParticleSpecies *const S)
Adds a new ParticleSpecies to the SpeciesHandler.
int xBallsColourMode_
XBalls is a package to view the particle data. As an alternative MercuryDPM also supports Paraview...
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Mdouble xBallsScale_
sets the xballs argument scale (see XBalls/xballs.txt)
void setXMin(Mdouble newXMin)
If the length of the problem domain in x-direction is XMax - XMin, this method sets XMin...
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
void removeLastObject()
Removes the last BaseParticle from the ParticleHandler.
all data will be written into/ read from a single file called name_
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
unsigned int getNtimeSteps() const
Returns the current counter of time steps.
Mdouble getKineticEnergy() const
Returns the global kinetic energy stored in the system.
virtual void outputXBallsDataParticle(const unsigned int i, const 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 time_
Stores the current simulation time.
void setRestartVersion(std::string newRV)
Sets restart_version.
Vec3D getGravity() const
Returns the gravity vector.
void checkSettings()
Checks if the essentials are set properly to go ahead with solving the problem.
virtual void hGridActionsBeforeTimeLoop()
A virtual function that allows one to carry out hGrid operations before the start of the time loop...
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
void read(std::istream &is)
Accepts an input stream std::istream.
bool readParAndIniFiles(const std::string fileName)
Allows the user to read par.ini files (useful to read MDCLR files)
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
virtual void computeAllForces()
Computes all the forces acting on the particles by using the setTorque and setForce methods...
File dataFile
An instance of class File to handle in- and output into a .data file.
Mdouble getRadius() const
Returns the particle's radius_.
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...
void setZMin(Mdouble newZMin)
If the length of the problem domain in z-direction is ZMax - ZMin, this method sets ZMin...
virtual void actionsAfterSolve()
A virtual function which allows to define operations to be executed after the solve().
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_.
void addTorque(Vec3D addTorque)
Adds an amount to the torque on this BaseInteractable.
virtual void printTime() const
Displays the current simulation time onto your screen for example.
unsigned int getNumberOfObjects() const
Gets the number of Object in this BaseHandler.
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. elastic, linear visco-elastic... et cetera...
InteractionHandler interactionHandler
An object of the class InteractionHandler.
virtual void writeXBallsScript() const
This writes a script which can be used to load the xballs problem to display the data just generated...
void outputInteractionDetails() const
Displays the interaction details corresponding to the pointer objects in the interaction handler...
void setXBallsAdditionalArguments(std::string newXBArgs)
Set the additional arguments for xballs.
BaseInteraction * getInteractionWith(BaseParticle *P, Mdouble timeStamp, InteractionHandler *interactionHandler)
Checks if particle is in interaction with given particle P, and if so, returns pointer to the associa...
void setFixedParticles(unsigned int n)
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Mdouble xBallsVectorScale_
sets the xballs argument vscale (see XBalls/xballs.txt)
Mdouble xMin_
If the length of the problem domain in x-direction is XMax - XMin, the above variable stores XMin...
virtual void actionsBeforeTimeStep()
A virtual function which allows to define operations to be executed before the new time step...
LoggerOutput * loggerOutput
Declaration of the output functions. If the output needs to be redirected, please swap the loggerOutp...
Mdouble timeStep_
Stores the simulation time step.
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
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 ...
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
RNG random
This is a random generator, often used for setting up the initial conditions etc...
std::string to_string_padded(unsigned int value)
Pads the number This function tries to pad the number to 4 digits, which is used when you create mult...
virtual void hGridRemoveParticle(BaseParticle *obj UNUSED)
no implementation but can be overidden in its derived classes.
virtual double getInfo(const BaseParticle &P) const
A virtual method that allows the user to overrride and set what is written into the info column in th...
virtual void actionsOnRestart()
A virtual function where the users can add extra code which is executed only when the code is restart...
void autoNumber()
The autoNumber() function is the trigger. It calls three functions. setRunNumber(), readRunNumberFromFile() and incrementRunNumberInFile().
virtual void writeEneHeader(std::ostream &os) const
Writes a header with a certain format for ENE file.
bool open()
Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the ne...
void set(Vec3D normal, Vec3D point)
Defines a standard wall, given an outward normal vector s.t. normal*x=normal*point for all x of the w...
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
bool saveCurrentTimestep(unsigned int ntimeSteps)
void gatherContactStatistics()
virtual void outputStatistics()
no implementation but can be overidden in its derived classes.
void setTimeStep(Mdouble newDt)
Allows the time step dt to be changed.
void removeDuplicatePeriodicParticles()
Removes periodic duplicate Particles.
const Vec3D & getTorque() const
Gets the current torque (vector) between the two interacting objects.
virtual void integrateBeforeForceComputation()
This is were the integration is done, at the moment it is velocity Verlet integration and is done bef...
virtual void writeRestartFile()
Stores all the particle data for current save time step. Calls the write function.
std::string xBallsAdditionalArguments_
A string of additional arguments for xballs can be specified (see XBalls/xballs.txt). e.g. "-solidf -v0".
double getXBallsVectorScale() const
Returns the scale of vectors used in xballs.
This is a class defining walls.
virtual bool continueSolve() const
each time-step will be written into/read from separate files numbered consecutively: name_...
It is publicly inherited from class Files. It defines an awesome feature that is ideal when doing a p...
static Mdouble getDistanceSquared(const Vec3D &a, const Vec3D &b)
Calculates the squared distance between two Vec3D: .
std::ostream & operator<<(std::ostream &os, DPMBase &md)
virtual void hGridUpdateMove(BaseParticle *, Mdouble)
no implementation but can be overidden in its derived classes.
virtual void computeForcesDueToWalls(BaseParticle *PI)
Computes the forces on the particles due to the walls (normals are outward normals) ...
std::string restartVersion_
Previous versions of MercuryDPM had a different restart file format, the below member variable allows...
const std::list< BaseInteraction * > & getInteractions() const
Returns a reference to the list of interactions in this BaseInteractable.
virtual void computeForce()
Virtual function that contains the force law between the two objects interacting. ...
void setRestarted(bool newRestartedFlag)
Allows to set the flag stating if the simulation is to be restarted or not.
Implementation of a 3D vector (by Vitaliy).
void setName(const std::string &name)
Sets the file name, e.g. "Name.data".
std::string getXBallsAdditionalArguments() const
virtual void hGridActionsAfterIntegration()
no implementation but can be overidden in its derived classes.
void addForce(Vec3D addForce)
Adds an amount to the force on this BaseInteractable.
Mdouble getTimeStep() const
Allows the time step dt to be accessed.
File statFile
An instance of class File to handle in- and output into a .stat file.
double getXBallsScale() const
Returns the scale of the view in xballs.
bool isFixed() const
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...
virtual void hGridActionsBeforeTimeStep()
A virtual function that allows one to set or execute hGrid parameters or operations before every simu...
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.
Mdouble getInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
bool getRotation() const
Returns a flag indicating if particle rotation is enabled or disabled.
virtual void finishStatistics()
no implementation but can be overidden in its derived classes.
virtual void broadPhase(BaseParticle *i)
By broad one means to screen and determine an approximate number of particles that a given particle c...
Mdouble getTime() const
Access function for the time.
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
virtual void checkInteractionWithBoundaries()
There are a range of boundaries one could implement depending on ones' problem. This methods checks f...
virtual void removeObject(unsigned const int id)
Removes a BaseParticle from the ParticleHandler.
virtual void writeFstatHeader(std::ostream &os) const
Writes a header with a certain format for FStat file.
virtual void read(std::istream &is)
Reads all particle data into a restart file.
Mdouble getTimeMax() const
Allows the user to access the total simulation time during the simulation. Cannot change it though...
int getRunNumber() const
This returns the current value of the counter (runNumber_)
const std::string & getName() const
Allows to access the file name, e.g., "problem.data".
DPMBase()
Constructor that calls the "void constructor()".
void setOpenMode(std::fstream::openmode openMode)
Allows the user to Sets File::openMode_.
Vec3D gravity_
Gravity vector.
std::function< void(std::string, std::string)> onFatal
void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
virtual void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
void fixParticle()
Fix Particle function. It fixes a Particle by setting its inverse mass and inertia and velocities to ...
bool append_
A flag to determine if the file has to be appended or not. See DPMBase::Solve() for example...
virtual void computeExternalForces(BaseParticle *PI)
Computes the external forces acting on particles (e.g. gravitational)
std::string getRestartVersion() const
This is to take into account for different Mercury versions. Returns the version of the restart file...
bool isTimeEqualTo(Mdouble time) const
Checks if the input variable "time" is the current time in the simulation.