40 std::string
lower(std::string s);
190 bool writeToFile(std::string filename, std::string filecontent);
200 void gnuplot(std::string command);
205 bool addToFile(std::string filename, std::string filecontent);
215 bool openFile(std::fstream& file, std::string filename, std::fstream::openmode mode);
229 std::ostringstream stm;
251 const auto pos = is.tellg();
286 bool compare(std::istream& is, std::string s);
314 std::ifstream is(fileName.c_str(), std::ios::in);
317 logger(
INFO,
"readFromFile: file % could not be opened, variable % set to default value %",
318 fileName, varName, value);
327 if (!s.compare(varName))
330 logger(
INFO,
"readFromFile: variable % set to % ", varName, value);
336 logger(
WARN,
"readFromFile: variable % not set in file %, using default value % ", varName, fileName, value);
354 for (
unsigned i=0;
i<argc-1; ++
i) {
355 if (varName == argv[
i]) {
356 value = atof(argv[i+1]);
357 logger(
INFO,
"readFromCommandLine: % set to % ", varName.substr(1), value);
362 logger(
INFO,
"readFromCommandLine: % set to default value % ", varName.substr(1), value);
366 template<
typename T,
size_t n>
369 for (
unsigned i=0;
i<argc-1; ++
i) {
370 if (varName == argv[
i]) {
372 std::stringstream out;
373 for (
auto& v : value) {
378 logger(
INFO,
"readFromCommandLine: % set to % ", varName.substr(1), out.str());
383 std::stringstream out;
384 for (
auto& v : value) out << v <<
' ';
385 logger(
INFO,
"readFromCommandLine: % set to default value % ", varName.substr(1), out.str());
392 for (
unsigned i=0;
i<argc-1; ++
i) {
393 if (varName == argv[
i]) {
396 std::stringstream out;
397 for (
int j = i+1; j<argc and argv[j][0]!=
'-'; ++j) {
398 values.push_back(atof(argv[j]));
399 out << values.back() <<
' ';
401 logger(
INFO,
"readFromCommandLine: % set to % ", varName.substr(1), out.str());
406 std::stringstream out;
407 for (
auto& v : values) out << v <<
' ';
408 logger(
INFO,
"readFromCommandLine: % set to default value % ", varName.substr(1), out.str());
413 std::string readFromCommandLine<std::string>(
int argc,
char *argv[], std::string varName, std::string value);
415 void check(
double real,
double ideal,
double error, std::string errorMessage);
417 void check(
Vec3D real,
Vec3D ideal,
double error, std::string errorMessage);
427 bool isNext(std::istream& is,
const std::string name);
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 and tangential ...
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
std::string lower(std::string s)
Mdouble getEffectiveMass(Mdouble mass0, Mdouble mass1)
Calculates the effective mass of a particle pair, i.e. half the harmonic mean of two particle masses...
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
return type specifically for fuctions returning k and disp at once
LL< Log::INFO > INFO
Info log level.
Mdouble getRayleighTime(Mdouble radius, Mdouble shearModulus, Mdouble poisson, Mdouble density)
Mdouble beta(Mdouble z, Mdouble w)
This is the beta function, returns the approximation based on cmath's implementation of ln(gamma) ...
void check(double real, double ideal, double error, std::string errorMessage)
const std::complex< Mdouble > i
T readFromFile(std::string fileName, std::string varName, T value)
Allows a quick read-in from a parameter file.
Set disp and k such that is matches a given collision time tc and restitution coefficient r for a col...
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...
#define MERCURY_DEPRECATED
const unsigned unsignedMax
LL< Log::WARN > WARN
Warning log level.
void getLineFromStringStream(std::istream &in, std::stringstream &out)
Reads a line from one stringstream into another, and prepares the latter for reading in...
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...
bool readOptionalVariable(std::istream &is, const std::string &name, T &variable)
Reads optional variables in the restart file.
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.
void gnuplot(std::string command)
Plots to a gnuplot window.
bool createDirectory(std::string)
bool isNext(std::istream &is, const std::string name)
reads next value in stream as a string and compares it with name.
std::string to_string(const T &n)
Mdouble round(const Mdouble value, unsigned precision)
bool readFromCommandLine(int argc, char *argv[], std::string varName)
Returns true if command line arguments contain varName, false else Usage example: if (readFromCommand...
bool compare(std::istream &is, std::string s)
Checks if the next argument in the input stream is a certain string.
void writeCommandLineToFile(const std::string filename, const int argc, char *const argv[])
Writes a string to a file.
std::vector< T > readVectorFromCommandLine(int argc, char *argv[], std::string varName, size_t n, std::vector< T > values)
bool fileExists(std::string strFilename)
Function to check if a file exists, is used to check if a run has already need done.
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 ...
Implementation of a 3D matrix.
bool openFile(std::fstream &file, std::string filename, std::fstream::openmode mode)
Provides a simple interface for opening a file.
std::array< T, n > readArrayFromCommandLine(int argc, char *argv[], std::string varName, std::array< T, n > value)
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...
bool addToFile(std::string filename, std::string filecontent)
Adds a string to an existing file.
Implementation of a 3D symmetric matrix.
void more(std::string filename, unsigned nLines=constants::unsignedMax)
std::vector< double > readArrayFromFile(std::string filename, int &n, int &m)