MercuryDPM
Alpha
|
Classes | |
class | KAndDisp |
return type specifically for fuctions returning k and disp at once More... | |
class | KAndDispAndKtAndDispt |
return type specifically for fuctions returning k, disp, kt, dispt at once More... | |
Functions | |
MERCURY_DEPRECATED KAndDisp | computeKAndDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass (Mdouble tc, Mdouble r, Mdouble mass) |
Set disp and k such that is matches a given collision time tc and restitution coefficient r for a collision of effective/reduced mass m. More... | |
MERCURY_DEPRECATED Mdouble | computeCollisionTimeFromKAndDispAndEffectiveMass (Mdouble k, Mdouble disp, Mdouble mass) |
Calculates the collision time for a given stiffness, dissipation, and effective mass. More... | |
MERCURY_DEPRECATED Mdouble | computeRestitutionCoefficientFromKAndDispAndEffectiveMass (Mdouble k, Mdouble disp, Mdouble mass) |
Calculates the restitution coefficient time for a given stiffness, dissipation, and effective mass. More... | |
MERCURY_DEPRECATED Mdouble | computeDispFromKAndRestitutionCoefficientAndEffectiveMass (Mdouble k, Mdouble r, Mdouble mass) |
Calculates the dissipation for a given stiffness, restitution coefficient, and effective mass. More... | |
MERCURY_DEPRECATED Mdouble | computeCollisionTimeFromKAndRestitutionCoefficientAndEffectiveMass (Mdouble k, Mdouble r, Mdouble mass) |
Calculates the collision time for a given stiffness, restitution coefficient, and effective mass. More... | |
MERCURY_DEPRECATED Mdouble | computeDispFromKAndCollisionTimeAndEffectiveMass (Mdouble k, Mdouble tc, Mdouble mass) |
Calculates the dissipation for a given stiffness, collision time, and effective mass. More... | |
MERCURY_DEPRECATED Mdouble | computeRestitutionCoefficientFromKAndCollisionTimeAndEffectiveMass (Mdouble k, Mdouble tc, Mdouble mass) |
Calculates the restitution coefficient for a given stiffness, collision time, and effective mass. More... | |
MERCURY_DEPRECATED Mdouble | computeDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass (Mdouble tc, Mdouble r, Mdouble mass) |
Calculates the dissipation for a given collision time, restitution coefficient, and effective mass. More... | |
MERCURY_DEPRECATED Mdouble | computeKFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass (Mdouble tc, Mdouble r, Mdouble mass) |
Calculates the stiffness for a given collision time, restitution coefficient, and effective mass. More... | |
MERCURY_DEPRECATED Mdouble | computeKFromCollisionTimeAndDispAndEffectiveMass (Mdouble tc, Mdouble disp, Mdouble mass) |
Calculates the stiffness for a given collision time, dissipation, and effective mass. More... | |
MERCURY_DEPRECATED Mdouble | computeRestitutionCoefficientFromCollisionTimeAndDispAndEffectiveMass (Mdouble tc, Mdouble disp, Mdouble mass) |
Calculates the resitution coefficient for a given collision time, dissipation, and effective mass. More... | |
MERCURY_DEPRECATED Mdouble | computeKFromDispAndRestitutionCoefficientAndEffectiveMass (Mdouble disp, Mdouble r, Mdouble mass) |
Calculates the stiffness for a given dissipation, restitution coefficient, and effective mass. More... | |
MERCURY_DEPRECATED Mdouble | computeCollisionTimeFromDispAndRestitutionCoefficientAndEffectiveMass (Mdouble disp, Mdouble r, Mdouble mass) |
Calculates the collision time for a given dissipation, restitution coefficient, and effective mass. More... | |
MERCURY_DEPRECATED KAndDispAndKtAndDispt | computeDisptFromCollisionTimeAndRestitutionCoefficientAndTangentialRestitutionCoefficientAndEffectiveMass (Mdouble tc, Mdouble r, Mdouble beta, Mdouble mass) |
Set disp, k, dispt and kt such that is matches a given collision time tc and a normal andtangential restitution coefficient r, beta for a collision of effective/reduced mass m. From Deen...Kuipers2006, eq. 43 and 30. More... | |
MERCURY_DEPRECATED Mdouble | getMaximumVelocity (Mdouble k, Mdouble disp, Mdouble radius, Mdouble mass) |
Calculates the maximum relative velocity allowed for a normal collision of two particles of radius r and particle mass m (for higher velocities particles could pass through each other) More... | |
unsigned int | getSaveCountFromNumberOfSavesAndTimeMaxAndTimestep (unsigned int numberOfSaves, Mdouble timeMax, Mdouble timestep) |
Returns the correct saveCount if the total number of saves, the final time and the time step is known. More... | |
void | getLineFromStringStream (std::istream &in, std::stringstream &out) |
Reads a line from one stringstream into another, and prepares the latter for reading in. More... | |
bool | writeToFile (std::string filename, std::string filecontent) |
Writes a string to a file. More... | |
bool | addToFile (std::string filename, std::string filecontent) |
Adds a string to an existing file. More... | |
bool | fileExists (std::string strFilename) |
Function to check if a file exists, is used to check if a run has already need done. More... | |
bool | openFile (std::fstream &file, std::string filename, std::fstream::openmode mode) |
Provides a simple interface for opening a file. More... | |
Mdouble | getEffectiveMass (Mdouble mass0, Mdouble mass1) |
Calculates the effective mass of a particle pair, i.e. half the harmonic mean of two particle masses. More... | |
std::vector< double > | readArrayFromFile (std::string filename, int &n, int &m) |
template<typename T > | |
std::string | to_string (const T &n) |
template<typename T > | |
void | readOptionalVariable (std::istream &is, std::string name, T &variable) |
void | loadingTest (const ParticleSpecies *species, Mdouble displacement, Mdouble velocity, Mdouble radius, std::string name) |
Used to test the loading/unloading properties of a contact law. More... | |
void | normalAndTangentialLoadingTest (const ParticleSpecies *species, Mdouble displacement, Mdouble tangentialDisplacement, Mdouble velocity, Mdouble radius, std::string name) |
Used to test the tangential loading/unloading/reloading properties of a frictional contact law. More... | |
void | objectivenessTest (const ParticleSpecies *species, Mdouble displacement, Mdouble tangentialDisplacement, Mdouble velocity, Mdouble radius, std::string name) |
Used to test the tangential loading/unloading/reloading properties of a frictional contact law. More... | |
template<typename T > | |
T | readFromFile (std::string fileName, std::string varName, T value) |
Allows a quick read-in from a parameter file. More... | |
bool | compare (std::istream &is, std::string s) |
void | check (double real, double ideal, double error, std::string errorMessage) |
bool helpers::addToFile | ( | std::string | filename, |
std::string | filecontent | ||
) |
Adds a string to an existing file.
Definition at line 432 of file Helpers.cc.
void helpers::check | ( | double | real, |
double | ideal, | ||
double | error, | ||
std::string | errorMessage | ||
) |
Definition at line 770 of file Helpers.cc.
References mathsFunc::isEqual(), and logger.
bool helpers::compare | ( | std::istream & | is, |
std::string | s | ||
) |
Definition at line 754 of file Helpers.cc.
Referenced by File::open(), DPMBase::write(), and File::write().
Mdouble helpers::computeCollisionTimeFromDispAndRestitutionCoefficientAndEffectiveMass | ( | Mdouble | disp, |
Mdouble | r, | ||
Mdouble | mass | ||
) |
Calculates the collision time for a given dissipation, restitution coefficient, and effective mass.
Definition at line 288 of file Helpers.cc.
References mathsFunc::log().
Mdouble helpers::computeCollisionTimeFromKAndDispAndEffectiveMass | ( | Mdouble | k, |
Mdouble | disp, | ||
Mdouble | mass | ||
) |
Calculates the collision time for a given stiffness, dissipation, and effective mass.
Definition at line 48 of file Helpers.cc.
References constants::pi, and mathsFunc::square().
Mdouble helpers::computeCollisionTimeFromKAndRestitutionCoefficientAndEffectiveMass | ( | Mdouble | k, |
Mdouble | r, | ||
Mdouble | mass | ||
) |
Calculates the collision time for a given stiffness, restitution coefficient, and effective mass.
Definition at line 118 of file Helpers.cc.
References mathsFunc::log(), constants::sqr_pi, and mathsFunc::square().
Mdouble helpers::computeDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass | ( | Mdouble | tc, |
Mdouble | r, | ||
Mdouble | mass | ||
) |
Calculates the dissipation for a given collision time, restitution coefficient, and effective mass.
Definition at line 188 of file Helpers.cc.
References mathsFunc::log().
Referenced by computeKAndDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass().
Mdouble helpers::computeDispFromKAndCollisionTimeAndEffectiveMass | ( | Mdouble | k, |
Mdouble | tc, | ||
Mdouble | mass | ||
) |
Calculates the dissipation for a given stiffness, collision time, and effective mass.
Definition at line 138 of file Helpers.cc.
References constants::sqr_pi, and mathsFunc::square().
Mdouble helpers::computeDispFromKAndRestitutionCoefficientAndEffectiveMass | ( | Mdouble | k, |
Mdouble | r, | ||
Mdouble | mass | ||
) |
Calculates the dissipation for a given stiffness, restitution coefficient, and effective mass.
Definition at line 98 of file Helpers.cc.
References mathsFunc::log(), constants::sqr_pi, and mathsFunc::square().
helpers::KAndDispAndKtAndDispt helpers::computeDisptFromCollisionTimeAndRestitutionCoefficientAndTangentialRestitutionCoefficientAndEffectiveMass | ( | Mdouble | tc, |
Mdouble | r, | ||
Mdouble | beta, | ||
Mdouble | mass | ||
) |
Set disp, k, dispt and kt such that is matches a given collision time tc and a normal andtangential restitution coefficient r, beta for a collision of effective/reduced mass m. From Deen...Kuipers2006, eq. 43 and 30.
from Deen...Kuipers2006, eq. 43 and 30
Definition at line 309 of file Helpers.cc.
References helpers::KAndDispAndKtAndDispt::disp, helpers::KAndDispAndKtAndDispt::dispt, helpers::KAndDispAndKtAndDispt::k, helpers::KAndDispAndKtAndDispt::kt, mathsFunc::log(), constants::pi, and mathsFunc::square().
helpers::KAndDisp helpers::computeKAndDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass | ( | Mdouble | tc, |
Mdouble | r, | ||
Mdouble | mass | ||
) |
Set disp and k such that is matches a given collision time tc and restitution coefficient r for a collision of effective/reduced mass m.
Definition at line 40 of file Helpers.cc.
References computeDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(), computeKFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(), helpers::KAndDisp::disp, and helpers::KAndDisp::k.
Mdouble helpers::computeKFromCollisionTimeAndDispAndEffectiveMass | ( | Mdouble | tc, |
Mdouble | disp, | ||
Mdouble | mass | ||
) |
Calculates the stiffness for a given collision time, dissipation, and effective mass.
Definition at line 228 of file Helpers.cc.
References constants::sqr_pi, and mathsFunc::square().
Mdouble helpers::computeKFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass | ( | Mdouble | tc, |
Mdouble | r, | ||
Mdouble | mass | ||
) |
Calculates the stiffness for a given collision time, restitution coefficient, and effective mass.
Definition at line 208 of file Helpers.cc.
References mathsFunc::log(), constants::pi, and mathsFunc::square().
Referenced by computeKAndDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass().
Mdouble helpers::computeKFromDispAndRestitutionCoefficientAndEffectiveMass | ( | Mdouble | disp, |
Mdouble | r, | ||
Mdouble | mass | ||
) |
Calculates the stiffness for a given dissipation, restitution coefficient, and effective mass.
Definition at line 268 of file Helpers.cc.
References mathsFunc::log(), constants::sqr_pi, and mathsFunc::square().
Mdouble helpers::computeRestitutionCoefficientFromCollisionTimeAndDispAndEffectiveMass | ( | Mdouble | tc, |
Mdouble | disp, | ||
Mdouble | mass | ||
) |
Calculates the resitution coefficient for a given collision time, dissipation, and effective mass.
Definition at line 248 of file Helpers.cc.
References mathsFunc::exp().
Mdouble helpers::computeRestitutionCoefficientFromKAndCollisionTimeAndEffectiveMass | ( | Mdouble | k, |
Mdouble | tc, | ||
Mdouble | mass | ||
) |
Calculates the restitution coefficient for a given stiffness, collision time, and effective mass.
Definition at line 163 of file Helpers.cc.
References mathsFunc::exp(), constants::sqr_pi, and mathsFunc::square().
Mdouble helpers::computeRestitutionCoefficientFromKAndDispAndEffectiveMass | ( | Mdouble | k, |
Mdouble | disp, | ||
Mdouble | mass | ||
) |
Calculates the restitution coefficient time for a given stiffness, dissipation, and effective mass.
Definition at line 73 of file Helpers.cc.
References mathsFunc::exp(), constants::pi, and mathsFunc::square().
bool helpers::fileExists | ( | std::string | strFilename | ) |
Function to check if a file exists, is used to check if a run has already need done.
This is a FileExist routine, which is used to test if a run have already need preformed, allows me to plug holes in parm studies.
Definition at line 450 of file Helpers.cc.
Calculates the effective mass of a particle pair, i.e. half the harmonic mean of two particle masses.
The effective mass is an important parameter in a collision. E.g. the collision time and the restitution coefficient are functions of the effective mass.
[in] | mass0 | The mass of the first particle. |
[in] | mass1 | The mass of the second particle. |
Definition at line 503 of file Helpers.cc.
void helpers::getLineFromStringStream | ( | std::istream & | in, |
std::stringstream & | out | ||
) |
Reads a line from one stringstream into another, and prepares the latter for reading in.
This function is used to avoid errors from reading in old or manually modified restart files. Instead of reading variable by variable directly from the restart stringstream, a full line is read first, from which the variables are read. Thus, if a line has the wrong number of arguments, it might affect the reading of the current line, but correctly reads the next line.
Example of usage:
std::stringstream line(std::stringstream::in | std::stringstream::out); std::stringstream is = restartFile.getFStream(); helpers::getLineFromStringStream(is, line); std::string dummy; line >> dummy;
[in] | in | the stringstream from which a line is read out should be initialized as std::stringstream(std::stringstream::out) |
[out] | out | the stringstream into which the line is read; should be initialized as std::stringstream(std::stringstream::in | std::stringstream::out) |
Definition at line 396 of file Helpers.cc.
Referenced by BaseHandler< T >::read(), MercuryBase::read(), DPMBase::read(), DPMBase::readNextDataFile(), SpeciesHandler::readObject(), InteractionHandler::readObject(), SpeciesHandler::readOldObject(), BoundaryHandler::readOldObject(), WallHandler::readOldObject(), and ParticleHandler::readOldObject().
Calculates the maximum relative velocity allowed for a normal collision of two particles of radius r and particle mass m (for higher velocities particles could pass through each other)
Definition at line 322 of file Helpers.cc.
References mathsFunc::exp(), and mathsFunc::square().
unsigned int helpers::getSaveCountFromNumberOfSavesAndTimeMaxAndTimestep | ( | unsigned int | numberOfSaves, |
Mdouble | timeMax, | ||
Mdouble | timestep | ||
) |
Returns the correct saveCount if the total number of saves, the final time and the time step is known.
MercuryDPM uses the DPMBase::setSaveCount to determine how often output is written. However, if the user wants to set the total number of saves instead of the saveCount, he can use this function to calculate the correct saveCount, assuming that the final time and the mean time step is known.
Example of use:
setSaveCount(helpers::getSaveCountFromNumberOfSavesAndTimeMaxAndTimestep(numberOfSaves, getTimeMax(), getTimeStep()));
[in] | numberOfSaves | the total number of output files the user wants at the end of the simulation. |
[in] | timeMax | the final time of the simulation |
[in] | timestep | the mean time step used during the simulation |
Definition at line 350 of file Helpers.cc.
void helpers::loadingTest | ( | const ParticleSpecies * | species, |
Mdouble | displacement, | ||
Mdouble | velocity, | ||
Mdouble | radius, | ||
std::string | name | ||
) |
Used to test the loading/unloading properties of a contact law.
Creates a DPMBase with a particles of unit size and a flat wall and loads/unloads the particle-wall contact.
[in] | species | particle species specifying the contact law |
[in] | displacement | peak displacement before unloading |
[in] | velocity | loading/unloading velocity |
Definition at line 535 of file Helpers.cc.
References DPMBase::actionsBeforeTimeStep(), assert, DPMBase::getTime(), DPMBase::getTimeMax(), INFO, logger, NO_FILE, ONE_FILE, InfiniteWall::set(), BaseInteractable::setAngularVelocity(), Files::setFileType(), DPMBase::setMax(), DPMBase::setMin(), DPMBase::setParticleDimensions(), BaseInteractable::setPosition(), BaseParticle::setRadius(), Files::setSaveCount(), BaseWall::setSpecies(), BaseParticle::setSpecies(), DPMBase::setSystemDimensions(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), DPMBase::setupInitialConditions(), BaseInteractable::setVelocity(), and writeToFile().
void helpers::normalAndTangentialLoadingTest | ( | const ParticleSpecies * | species, |
Mdouble | displacement, | ||
Mdouble | tangentialDisplacement, | ||
Mdouble | velocity, | ||
Mdouble | radius, | ||
std::string | name | ||
) |
Used to test the tangential loading/unloading/reloading properties of a frictional contact law.
Creates a DPMBase with a particles of unit size and a flat wall and loads/unloads/reloads the particle-wall contact in tangential direction.
[in] | species | particle species specifying the contact law |
[in] | displacement | peak displacement before unloading |
[in] | velocity | loading/unloading velocity |
Definition at line 602 of file Helpers.cc.
References DPMBase::actionsBeforeTimeStep(), assert, DPMBase::getTime(), DPMBase::getTimeMax(), INFO, logger, NO_FILE, ONE_FILE, InfiniteWall::set(), BaseInteractable::setAngularVelocity(), Files::setFileType(), DPMBase::setMax(), DPMBase::setMin(), DPMBase::setParticleDimensions(), BaseInteractable::setPosition(), BaseParticle::setRadius(), Files::setSaveCount(), BaseWall::setSpecies(), BaseParticle::setSpecies(), DPMBase::setSystemDimensions(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), DPMBase::setupInitialConditions(), BaseInteractable::setVelocity(), and writeToFile().
void helpers::objectivenessTest | ( | const ParticleSpecies * | species, |
Mdouble | displacement, | ||
Mdouble | tangentialDisplacement, | ||
Mdouble | velocity, | ||
Mdouble | radius, | ||
std::string | name | ||
) |
Used to test the tangential loading/unloading/reloading properties of a frictional contact law.
Creates a DPMBase with a particles of unit size and a flat wall, loads the particle-wall contact in normal and tangential direction, then rotates.
[in] | species | particle species specifying the contact law |
[in] | displacement | peak displacement before unloading |
[in] | velocity | loading/unloading velocity |
Definition at line 677 of file Helpers.cc.
References DPMBase::actionsBeforeTimeStep(), assert, mathsFunc::cos(), BaseInteractable::getAngularVelocity(), BaseInteractable::getOrientation(), BaseInteractable::getPosition(), DPMBase::getTime(), DPMBase::getTimeMax(), BaseInteractable::getVelocity(), INFO, logger, NO_FILE, ONE_FILE, constants::pi, BaseInteractable::setAngularVelocity(), Files::setFileType(), DPMBase::setMax(), DPMBase::setMin(), BaseInteractable::setOrientation(), DPMBase::setParticleDimensions(), BaseInteractable::setPosition(), BaseParticle::setRadius(), Files::setSaveCount(), BaseParticle::setSpecies(), DPMBase::setSystemDimensions(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), DPMBase::setupInitialConditions(), BaseInteractable::setVelocity(), mathsFunc::sin(), and writeToFile().
bool helpers::openFile | ( | std::fstream & | file, |
std::string | filename, | ||
std::fstream::openmode | mode | ||
) |
Provides a simple interface for opening a file.
Provides a simple interface for opening a file, in order to avoid that the user has to learn the syntax for opening a file.
[out] | file | The std::fstream object that the user can write to. |
[in] | filename | The name of the file. |
[in] | mode | The openmode of the file, typically std::fstream::out or std::fstream::in. |
Definition at line 487 of file Helpers.cc.
std::vector< double > helpers::readArrayFromFile | ( | std::string | filename, |
int & | n, | ||
int & | m | ||
) |
Definition at line 508 of file Helpers.cc.
T helpers::readFromFile | ( | std::string | fileName, |
std::string | varName, | ||
T | value | ||
) |
Allows a quick read-in from a parameter file.
For example, the following code reads in the variable time from the file in:
The in file needs to contain the string time, followed by the value, e.g.
If the file cannot be opened, or the parameter is not found, the variable is set to the default value specified by the third argument.
fileName | name of input |
varName | variable name as it appears in the input file |
value | default value (used if the parameter could not be read) |
Definition at line 260 of file Helpers.h.
void helpers::readOptionalVariable | ( | std::istream & | is, |
std::string | name, | ||
T & | variable | ||
) |
std::string helpers::to_string | ( | const T & | n | ) |
Definition at line 203 of file Helpers.h.
Referenced by InteractionHandler::writeVTK(), ParticleHandler::writeVTK(), and WallHandler::writeVTKFile().
bool helpers::writeToFile | ( | std::string | filename, |
std::string | filecontent | ||
) |
Writes a string to a file.
Provides a simple interface for writing a string to a file. This function is mainly used to create ini or restart file that the code later reads back in.
Example of usage:
helpers::writeToFile("RestartUnitTest.ini", "1 0 0 0 0 1 1 1\n" "0.5 0.5 0 0 0 0.5 0 0 0 0 0 0 0 0\n");
[in] | filename | the name of the file |
[in] | filecontent | the content |
Definition at line 418 of file Helpers.cc.
Referenced by loadingTest(), main(), normalAndTangentialLoadingTest(), objectivenessTest(), Screw::writeVTK(), and DPMBase::writeVTK().