|
Classes | |
struct | KAndDisp |
return type specifically for fuctions returning k and disp at once More... | |
struct | KAndDispAndKtAndDispt |
return type specifically for fuctions returning k, disp, kt, dispt at once More... | |
Functions | |
bool | removeFromCommandline (int &argc, char *argv[], std::string varName, int nArgs) |
May be used to hide arguments from argc and argv. More... | |
bool | readFromCommandLine (int argc, char *argv[], std::string varName) |
Returns true if command line arguments contain varName, false else. More... | |
template<typename T > | |
T | readFromCommandLine (int argc, char *argv[], std::string varName, T value) |
template<typename T , size_t n> | |
std::array< T, n > | readArrayFromCommandLine (int argc, char *argv[], std::string varName, std::array< T, n > value) |
template<typename T > | |
std::vector< T > | readVectorFromCommandLine (int argc, char *argv[], std::string varName, size_t n, std::vector< T > values) |
template<> | |
std::string | readFromCommandLine< std::string > (int argc, char *argv[], std::string varName, std::string value) |
bool | writeToFile (std::string filename, std::string filecontent) |
Writes a string to a file. More... | |
void | writeCommandLineToFile (const std::string filename, const int argc, char *const argv[]) |
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... | |
std::vector< double > | readArrayFromFile (std::string filename, int &n, int &m) |
void | more (std::string filename, unsigned nLines=constants::unsignedMax) |
bool | createDirectory (std::string) |
std::string | getPath () |
template<typename T > | |
bool | readOptionalVariable (std::istream &is, const std::string &name, T &variable) |
Reads optional variables in the restart file. More... | |
template<typename T > | |
T | readFromFile (const std::string fileName, const std::string varName, const T defaultValue) |
MERCURYDPM_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 and tangential restitution coefficient r, beta for a collision of effective/reduced mass m. From Deen...Kuipers2006, eq. 43 and 30. More... | |
MERCURYDPM_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... | |
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... | |
Mdouble | getRayleighTime (Mdouble radius, Mdouble shearModulus, Mdouble poisson, Mdouble density) |
Returns the Rayleigh time step for a Hertz contact law. 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... | |
Mdouble | round (Mdouble value, unsigned int precision) |
rounds a floating point number with a given precision More... | |
std::vector< Mdouble > | linspace (Mdouble a, Mdouble b, int N) |
creates a 1D linear space partition More... | |
void | gnuplot (std::string command) |
Plots to a gnuplot window. More... | |
Mdouble | getRealTime () |
int | qSortCompare (const void *x, const void *y) |
For use with qsort. More... | |
double | getPercentile (const double *array, size_t nel, double perc) |
Returns the 100*perc-th percentile of array. More... | |
int | getMaximumNumberOfOMPThreads () |
Gets the maximum number of OpenMP threads. More... | |
std::string | lower (std::string s) |
returns the input string after converting upper-case characters to lower case 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 | isNext (std::istream &is, const std::string name) |
bool | compare (std::istream &is, std::string s) |
Checks if the next argument in the input stream is a certain string. More... | |
std::string | toString (Mdouble value, unsigned precision) |
converts a floating point number into a string with a given precision More... | |
template<typename T > | |
std::string | toString (const T &n) |
template<typename T > | |
std::string | toString (const std::vector< T > &vec) |
void | check (double real, double ideal, double error, std::string errorMessage) |
void | check (Vec3D real, Vec3D ideal, double error, std::string errorMessage) |
void | check (Matrix3D real, Matrix3D ideal, double error, std::string errorMessage) |
void | check (MatrixSymmetric3D real, MatrixSymmetric3D ideal, double error, std::string errorMessage) |
bool helpers::addToFile | ( | std::string | filename, |
std::string | filecontent | ||
) |
Adds a string to an existing file.
References checkTemplate().
Referenced by ForceLawsMPI2Test::actionsAfterSolve(), ScaleCoupledBeam::actionsAfterSolve(), DPM::actionsBeforeTimeStep(), Beam::checkBeamDeflection(), CoupledBeam::CoupledBeam(), InsertionBoundary::generateParticle(), BidisperseCubeInsertionBoundary::generateParticle(), PolydisperseInsertionBoundary::generateParticle(), main(), ExtremeOverlapVolumeUnitTest::setupInitialConditions(), and InertiaTensorTester::test().
References checkTemplate().
void helpers::check | ( | MatrixSymmetric3D | real, |
MatrixSymmetric3D | ideal, | ||
double | error, | ||
std::string | errorMessage | ||
) |
References checkTemplate().
References checkTemplate().
bool helpers::compare | ( | std::istream & | is, |
std::string | s | ||
) |
Checks if the next argument in the input stream is a certain string.
Referenced by DPMBase::read(), File::write(), and DPMBase::write().
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 and tangential restitution coefficient r, beta for a collision of effective/reduced mass m. From Deen...Kuipers2006, eq. 43 and 30.
References mathsFunc::beta(), helpers::KAndDispAndKtAndDispt::disp, helpers::KAndDispAndKtAndDispt::dispt, helpers::KAndDispAndKtAndDispt::k, helpers::KAndDispAndKtAndDispt::kt, mathsFunc::log(), constants::pi, and mathsFunc::square().
bool helpers::createDirectory | ( | std::string | path | ) |
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.
Referenced by ParameterStudy1DDemo::actionsBeforeTimeLoop(), ParameterStudy2DDemo::actionsBeforeTimeLoop(), ParameterStudy3DDemo::actionsBeforeTimeLoop(), main(), DPMBase::readRestartFile(), FlowRule::run(), AngleOfRepose::run(), and SegregationPeriodic::setupInitialConditions().
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. |
Referenced by main().
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 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) |
Referenced by main(), BaseHandler< T >::read(), InteractionHandler::read(), DPMBase::read(), BaseCluster::read(), MercuryBase::read(), SpeciesHandler::readAndAddObject(), WallHandler::readAndCreateOldObject(), DPMBase::readNextDataFile(), BoundaryHandler::readOldObject(), and SpeciesHandler::readOldObject().
int helpers::getMaximumNumberOfOMPThreads | ( | ) |
Gets the maximum number of OpenMP threads.
Gets the maximum number of OpenMP threads if MERCURYDPM_USE_OMP is enabled.
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)
References mathsFunc::exp(), and mathsFunc::square().
Referenced by ChutePeriodic::setupInitialConditions(), Vreman::setupInitialConditions(), and SilbertPeriodic::setupInitialConditions().
std::string helpers::getPath | ( | ) |
References GetCurrentDir, logger, and WARN.
Referenced by DPMBase::writePythonFileForVTKVisualisation(), and HorizontalMixer::writeScript().
Returns the 100*perc-th percentile of array.
array should be sorted, e.g. qsort(xs, n, sizeof(double), qSortCompare); and perc should be a number between 0 and 1.
Mdouble helpers::getRayleighTime | ( | Mdouble | radius, |
Mdouble | shearModulus, | ||
Mdouble | poisson, | ||
Mdouble | density | ||
) |
Returns the Rayleigh time step for a Hertz contact law.
An accepted time step for Hertz is 10-20% of the Rayleigh time step. See [Marigo2015]
References constants::pi.
Referenced by NozzleDemo::setupInitialConditions(), and NozzleSelfTest::setupInitialConditions().
Mdouble helpers::getRealTime | ( | ) |
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 |
Referenced by ChutePeriodicDemo::ChutePeriodicDemo(), ChuteWithWedge::ChuteWithWedge(), main(), ChutePeriodic::setup(), AxisymmetricHopper::setupInitialConditions(), MovingIntersectionOfWallsUnitTest_Basic::setupInitialConditions(), MovingWall::setupInitialConditions(), SeparateFilesSelfTest::setupInitialConditions(), Slide::Slide(), and statistics_while_running< T >::statistics_while_running().
void helpers::gnuplot | ( | std::string | command | ) |
Plots to a gnuplot window.
bool helpers::isNext | ( | std::istream & | is, |
const std::string | name | ||
) |
reads next value in stream as a string and compares it with name. If name is equal to string, the function outputs true. If name is not equal to string, the function undoes the read by setting seekg, and outputs false.
is | |
name |
References units::name.
Referenced by BaseWall::read().
creates a 1D linear space partition
std::string helpers::lower | ( | std::string | s | ) |
returns the input string after converting upper-case characters to lower case
Referenced by WallHandler::readTriangleWall().
void helpers::more | ( | std::string | filename, |
unsigned | nLines = constants::unsignedMax |
||
) |
References ERROR, constants::i, INFO, logger, NO_FLUSH, and constants::unsignedMax.
Referenced by commandLineCG(), and main().
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. |
Referenced by main().
int helpers::qSortCompare | ( | const void * | x, |
const void * | y | ||
) |
std::array<T,n> helpers::readArrayFromCommandLine | ( | int | argc, |
char * | argv[], | ||
std::string | varName, | ||
std::array< T, n > | value | ||
) |
References constants::i, INFO, and logger.
std::vector< double > helpers::readArrayFromFile | ( | std::string | filename, |
int & | n, | ||
int & | m | ||
) |
References ERROR, constants::i, logger, and n.
Returns true if command line arguments contain varName, false else.
Returns true if command line arguments contain varName, false else Usage example: if (readFromCommandLine(argc, argv, '-verbose')) ...
argc | pass through number of command line arguments |
argv | pass through values of command line arguments |
varName | name of command line arguments that is required to return true |
References constants::i, INFO, and logger.
Referenced by Calibration::Calibration(), GranuDrum::GranuDrum(), GranuHeap::GranuHeap(), main(), Calibration::setSpecies(), Material::setSpecies(), and RotatingDrumWet::setupInitialConditions().
T helpers::readFromCommandLine | ( | int | argc, |
char * | argv[], | ||
std::string | varName, | ||
T | value | ||
) |
References constants::i, INFO, and logger.
std::string helpers::readFromCommandLine< std::string > | ( | int | argc, |
char * | argv[], | ||
std::string | varName, | ||
std::string | value | ||
) |
T helpers::readFromFile | ( | const std::string | fileName, |
const std::string | varName, | ||
const T | defaultValue | ||
) |
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 |
defaultValue | default value (used if the parameter could not be read) |
References INFO, logger, and WARN.
Referenced by main().
bool helpers::readOptionalVariable | ( | std::istream & | is, |
const std::string & | name, | ||
T & | variable | ||
) |
Reads optional variables in the restart file.
A variable is stored in the restart file by storing the variables name and value, e.g. " name value" If a variable is always written to the restart file, it can be read-in like this: is >> dummy >> variable; If a variable is optional, the variable name has to be checked, and should be read in like this: readOptionalVariable(is,"name",variable);
References units::name.
Referenced by LiquidMigrationLSSpecies::read(), LiquidMigrationWilletSpecies::read(), InsertionBoundary::read(), BaseInteraction::read(), BaseSpecies::read(), InfiniteWall::read(), and BaseObject::read().
std::vector<T> helpers::readVectorFromCommandLine | ( | int | argc, |
char * | argv[], | ||
std::string | varName, | ||
size_t | n, | ||
std::vector< T > | values | ||
) |
References constants::i, INFO, and logger.
May be used to hide arguments from argc and argv.
[in] | argc | |
[in] | argv | |
[in] | varName | The name of the commandline argument to be removed |
[in] | nArgs | The number of additional command line arguments to remove |
This function does hide the desired argument from the supplied argv argc combination. It does it by moving the specified arguent to the end of the supplied argv and reducing argc by the coorect number. Other pieces of code that rely on argc should therefor no longer see the hidden argument.
If used in comination with readFromCommandLine(...), this function allows handling of arguments that are not seen by solve(), even if commandline arguments are passed.
References constants::i.
Referenced by main().
rounds a floating point number with a given precision
References n.
Referenced by SpeciesTest::actionsAfterSolve(), Vreman::add_particles(), ChuteWithContraction::ChuteWithContraction(), ChuteWithPeriodicInflowAndContraction::ChuteWithPeriodicInflowAndContraction(), VariableBottom::createBottom(), HorizontalScrew::getDistanceAndNormal(), Coil::getDistanceAndNormal(), Screw::getDistanceAndNormalLabCoordinates(), GranuHeap::GranuHeap(), PointIsAboveCurve(), FileReader::read(), DPMBase::readParAndIniFiles(), AngleOfRepose::run(), VariableBottom::set_chute_parameters(), AngleOfRepose::set_study(), SilbertPeriodic::set_study(), ClosedCSCStats::setupInitialConditions(), CSCStats::setupInitialConditions(), BaseCluster::setupInitialConditions(), ScaleCoupledBeam::setupOomph(), WearableNurbsWall::storeDebris(), and toString().
std::string helpers::toString | ( | const std::vector< T > & | vec | ) |
std::string helpers::toString | ( | const T & | n | ) |
std::string helpers::toString | ( | Mdouble | value, |
unsigned | precision | ||
) |
converts a floating point number into a string with a given precision
References round().
Referenced by ShearStage::actionsAfterSolve(), DeletionBoundary::checkBoundaryAfterParticleMoved(), computeFFc(), computeSimpleFFc(), Contact::Contact(), Indenter::Indenter(), main(), SingleParticle< SpeciesType >::setupInitialConditions(), SinterPair::SinterPair(), and GranuDrum::writeResults().
void helpers::writeCommandLineToFile | ( | const std::string | filename, |
const int | argc, | ||
char *const | argv[] | ||
) |
Writes a string to a file.
References constants::i, and writeToFile().
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 |
Referenced by ShearStage::actionsAfterSolve(), ScaleCoupledBeam::actionsBeforeSolve(), Beam::actionsBeforeSolve(), CoupledBeam::actionsBeforeSolve(), CoupledProblem::CoupledProblem(), statistics_while_running< T >::finishStatistics(), loadingTest(), main(), normalAndTangentialLoadingTest(), objectivenessTest(), LevelSetWall::setShapeFourSided(), GetDistanceAndNormalForIntersectionOfWalls::setupInitialConditions(), GetDistanceAndNormalForScrew::setupInitialConditions(), GetDistanceAndNormalForTriangleWall::setupInitialConditions(), GetDistanceAndNormalForTriangleWalls::setupInitialConditions(), SingleParticle< SpeciesType >::setupInitialConditions(), ShearStage::ShearStage(), SinterPair::SinterPair(), writeCommandLineToFile(), writeHelpers(), Calibration::writePSDToFile(), DPMBase::writePythonFileForVTKVisualisation(), GranuDrum::writeResults(), GranuHeap::writeResults(), HorizontalMixer::writeScript(), LevelSetWall::writeToFile(), and Screw::writeVTK().