![]() |
|
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 | |
std::size_t | countLeadingDashes (const std::string &s) |
Counts the leading dash ('-') characters in a string. More... | |
bool | removeFromCommandline (int &argc, char *argv[], const std::string &varName, int nArgs) |
May be used to hide arguments from argc and argv. More... | |
bool | readFromCommandLine (int argc, char *argv[], const std::string &varName) |
Returns true if command line arguments contain varName, false else. More... | |
template<typename T > | |
T | readFromCommandLine (int argc, char *argv[], const std::string &varName, T value) |
template<typename T , size_t n> | |
std::array< T, n > | readArrayFromCommandLine (int argc, char *argv[], const std::string &varName, std::array< T, n > value) |
template<typename T > | |
std::vector< T > | readVectorFromCommandLine (int argc, char *argv[], const std::string &varName, size_t n, std::vector< T > values) |
template<> | |
std::string | readFromCommandLine< std::string > (int argc, char *argv[], const std::string &varName, std::string value) |
bool | writeToFile (const std::string &filename, const 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 (const std::string &filename, const std::string &filecontent) |
Adds a string to an existing file. More... | |
bool | fileExists (const 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, const std::string &filename, std::fstream::openmode mode) |
Provides a simple interface for opening a file. More... | |
std::vector< double > | readArrayFromFile (const std::string &filename, int &n, int &m) |
void | more (const std::string &filename, unsigned nLines=constants::unsignedMax) |
bool | createDirectory (const std::string &directory, bool allowExists=false) |
Creates a directory. More... | |
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 | getShearModulus (Mdouble youngsModulus, Mdouble poisson) |
Returns the shear modulus calculated from Young's modulus and Poisson's ratio. 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) |
Checks if the next argument in the input stream equals a certain string. When true, the current position is that of the next argument. When false, the current position remains unchanged. More... | |
MERCURYDPM_DEPRECATED bool | compare (std::istream &is, const std::string &s) |
Checks if the next argument in the input stream is a certain string. More... | |
bool | lookAhead (std::istream &is, const std::string &name, int number) |
Checks if the nth argument from the current position in the input stream equals a certain string. The current position remains unchanged. 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) |
template<typename... Args> | |
std::string | stringFormat (const std::string &format, Args... args) |
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 | ( | const std::string & | filename, |
const std::string & | filecontent | ||
) |
Adds a string to an existing file.
References MergeRestartFiles::filename, INFO, and logger.
References checkTemplate(), and calibrate::error.
Referenced by ForceLawsMPI2Test::actionsAfterSolve(), ScaleCoupledBeam::actionsAfterSolve(), DPM::actionsBeforeTimeStep(), Beam::checkBeamDeflection(), CoupledBeam::CoupledBeam(), main(), ExtremeOverlapVolumeUnitTest::setupInitialConditions(), PSDSelfTest::setupInitialConditions(), InertiaTensorTester::test(), and MortaringValidationProblem< ELEMENT, NON_MORTAR_ELEMENT >::verify_mortared_nodes_coincide().
References checkTemplate(), and calibrate::error.
void helpers::check | ( | MatrixSymmetric3D | real, |
MatrixSymmetric3D | ideal, | ||
double | error, | ||
std::string | errorMessage | ||
) |
References checkTemplate(), and calibrate::error.
References checkTemplate(), and calibrate::error.
bool helpers::compare | ( | std::istream & | is, |
const std::string & | s | ||
) |
Checks if the next argument in the input stream is a certain string.
References logger, s, oomph::Global_string_for_annotation::string(), VERBOSE, and WARN.
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 beta, helpers::KAndDispAndKtAndDispt::disp, helpers::KAndDispAndKtAndDispt::dispt, helpers::KAndDispAndKtAndDispt::k, helpers::KAndDispAndKtAndDispt::kt, Eigen::bfloat16_impl::log(), constants::pi, UniformPSDSelfTest::r, sqrt(), and mathsFunc::square().
std::size_t helpers::countLeadingDashes | ( | const std::string & | s | ) |
Counts the leading dash ('-') characters in a string.
[in] | s | String constaining dash ('-') characters. |
References calibrate::c, and s.
Referenced by helpers::readFromCommandLine< std::string >(), readArrayFromCommandLine(), readFromCommandLine(), and readVectorFromCommandLine().
Creates a directory.
directory | Absoulte/relative path of the directory |
allowExists | Won't fail if directory exists |
directory | Absoulte/relative path of the directory |
allowExists | Won't fail if directory exists |
References ERROR, logger, and PROCESSOR_ID.
Referenced by DPMBase::initialiseVTK().
bool helpers::fileExists | ( | const 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) |
References out(), and oomph::Global_string_for_annotation::string().
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 Eigen::bfloat16_impl::asin(), Eigen::bfloat16_impl::exp(), k, UniformPSDSelfTest::radius, sqrt(), mathsFunc::square(), and w.
Referenced by ChutePeriodic::setupInitialConditions(), Vreman::setupInitialConditions(), and SilbertPeriodic::setupInitialConditions().
std::string helpers::getPath | ( | ) |
References logger, oomph::Global_string_for_annotation::string(), 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.
References Eigen::bfloat16_impl::ceil(), Eigen::bfloat16_impl::floor(), and lambda.
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 UniformPSDSelfTest::density, constants::pi, UniformPSDSelfTest::radius, and sqrt().
Referenced by main(), NozzleDemo::setupInitialConditions(), and NozzleSelfTest::setupInitialConditions().
Mdouble helpers::getRealTime | ( | ) |
References Eigen::placeholders::end, and oomph::CumulativeTimings::start().
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 |
References Eigen::bfloat16_impl::ceil(), ERROR, and logger.
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 | ||
) |
Checks if the next argument in the input stream equals a certain string. When true, the current position is that of the next argument. When false, the current position remains unchanged.
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 plotDoE::name, and oomph::Global_string_for_annotation::string().
Referenced by DropletBoundary::read(), BaseWall::read(), and DPMBase::read().
creates a 1D linear space partition
References calibrate::val, and plotDoE::x.
Referenced by PSD::convertPdfPhiToPdfMeter(), PSD::setDistributionLogNormal(), PSD::setDistributionNormal(), and PSD::setDistributionUniform().
Checks if the nth argument from the current position in the input stream equals a certain string. The current position remains unchanged.
References i, logger, plotDoE::name, and oomph::Global_string_for_annotation::string().
Referenced by DropletBoundary::read().
std::string helpers::lower | ( | std::string | s | ) |
returns the input string after converting upper-case characters to lower case
References s, and transform().
Referenced by HistogramHelper< Scalar, std::enable_if_t< Eigen::NumTraits< Scalar >::IsInteger > >::bin_width(), oomph::HypreHelpers::create_HYPRE_Matrix(), oomph::HypreHelpers::create_HYPRE_Vector(), fpdiff::fpdiff_helper(), oomph::Gauss_Rescaled< DIM, NPTS_1D >::Gauss_Rescaled(), PolarNSProblem< ELEMENT >::get_shear_stress(), HistogramHelper< Scalar, EnableIf >::HistogramHelper(), oomph::PiecewiseGauss< DIM, NPTS_1D >::knot(), oomph::DenseComplexMatrix::ludecompose(), main(), oomph::PiecewiseGauss< DIM, NPTS_1D >::PiecewiseGauss(), and WallHandler::readTriangleWall().
void helpers::more | ( | const std::string & | filename, |
unsigned | nLines = constants::unsignedMax |
||
) |
References ERROR, MergeRestartFiles::filename, i, INFO, calibrate::line, logger, NO_FLUSH, oomph::Global_string_for_annotation::string(), and constants::unsignedMax.
Referenced by commandLineCG(), and main().
bool helpers::openFile | ( | std::fstream & | file, |
const 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. |
References MergeRestartFiles::filename.
Referenced by main().
int helpers::qSortCompare | ( | const void * | x, |
const void * | y | ||
) |
std::array<T,n> helpers::readArrayFromCommandLine | ( | int | argc, |
char * | argv[], | ||
const std::string & | varName, | ||
std::array< T, n > | value | ||
) |
References countLeadingDashes(), i, INFO, j, logger, out(), v, and Eigen::value.
References ERROR, MergeRestartFiles::filename, i, logger, m, n, v, and calibrate::val.
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 countLeadingDashes(), i, INFO, and logger.
Referenced by Calibration::Calibration(), GranuDrum::GranuDrum(), GranuHeap::GranuHeap(), main(), RotatingDrumBidisperse::RotatingDrumBidisperse(), Calibration::setSpecies(), Material::setSpecies(), RotatingDrumWet::setupInitialConditions(), and ThermalConductionSelfTest::ThermalConductionSelfTest().
T helpers::readFromCommandLine | ( | int | argc, |
char * | argv[], | ||
const std::string & | varName, | ||
T | value | ||
) |
References countLeadingDashes(), i, INFO, logger, and Eigen::value.
std::string helpers::readFromCommandLine< std::string > | ( | int | argc, |
char * | argv[], | ||
const 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 UniformPSDSelfTest::fileName, INFO, logger, s, oomph::Global_string_for_annotation::string(), Eigen::value, 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 plotDoE::name, and oomph::Global_string_for_annotation::string().
Referenced by LiquidMigrationLSSpecies::read(), LiquidMigrationWilletSpecies::read(), AxisymmetricIntersectionOfWalls::read(), InsertionBoundary::read(), BaseInteraction::read(), BaseParticle::read(), BaseSpecies::read(), InfiniteWall::read(), and BaseObject::read().
std::vector<T> helpers::readVectorFromCommandLine | ( | int | argc, |
char * | argv[], | ||
const std::string & | varName, | ||
size_t | n, | ||
std::vector< T > | values | ||
) |
bool helpers::removeFromCommandline | ( | int & | argc, |
char * | argv[], | ||
const std::string & | varName, | ||
int | nArgs | ||
) |
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.
Referenced by main().
rounds a floating point number with a given precision
References n, Eigen::bfloat16_impl::pow(), Eigen::bfloat16_impl::round(), and Eigen::value.
std::string helpers::stringFormat | ( | const std::string & | format, |
Args... | args | ||
) |
References compute_granudrum_aor::args, ERROR, format(), logger, size, and oomph::Global_string_for_annotation::string().
std::string helpers::toString | ( | const std::vector< T > & | vec | ) |
References calibrate::val.
std::string helpers::toString | ( | const T & | n | ) |
converts a floating point number into a string with a given precision
References Eigen::bfloat16_impl::round(), and Eigen::value.
Referenced by ShearStage::actionsAfterSolve(), DeletionBoundary::checkBoundaryAfterParticleMoved(), computeFFc(), computeSimpleFFc(), Contact::Contact(), Indenter::Indenter(), main(), MeltableForceLaw2SelfTest::setupInitialConditions(), MeltableForceLawSelfTest::setupInitialConditions(), SingleParticle< SpeciesType >::setupInitialConditions(), SinterPair::SinterPair(), GranuDrum::writeResults(), and RotatingDrumBidisperse::writeResults().
void helpers::writeCommandLineToFile | ( | const std::string & | filename, |
const int | argc, | ||
char *const | argv[] | ||
) |
Writes a string to a file.
References MergeRestartFiles::filename, i, and writeToFile().
bool helpers::writeToFile | ( | const std::string & | filename, |
const 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 |
References MergeRestartFiles::filename, logger, out(), and WARN.
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(), RotatingDrumBidisperse::writeResults(), HorizontalMixer::writeScript(), LevelSetWall::writeToFile(), and Screw::writeVTK().