MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Helpers.cc File Reference
#include "Helpers.h"
#include <cmath>
#include <sys/stat.h>
#include <cstdio>
#include <sstream>
#include <string>
#include <Logger.h>
#include <DPMBase.h>
#include <Walls/InfiniteWall.h>
#include <Particles/BaseParticle.h>
#include <Species/BaseSpecies.h>
#include "Math/ExtendedMath.h"
#include <numeric>
#include <chrono>
#include <sys/types.h>
#include <unistd.h>
#include "Particles/SphericalParticle.h"

Go to the source code of this file.

Macros

#define GetCurrentDir   getcwd
 

Functions

template<class T >
void checkTemplate (T real, T ideal, double error, std::string whatIsChecked)
 
template<>
std::string helpers::readFromCommandLine< std::string > (int argc, char *argv[], std::string varName, std::string value)
 

Macro Definition Documentation

#define GetCurrentDir   getcwd

Definition at line 51 of file Helpers.cc.

Referenced by helpers::getPath().

Function Documentation

template<class T >
void checkTemplate ( real,
ideal,
double  error,
std::string  whatIsChecked 
)

Definition at line 891 of file Helpers.cc.

References INFO, mathsFunc::isEqual(), and logger.

Referenced by helpers::check().

892 {
893  logger.assert_always(mathsFunc::isEqual(real, ideal, error),
894  whatIsChecked + ": % (should be %) ", real, ideal);
895  logger(INFO, whatIsChecked + ": % (correct)", real);
896 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
bool isEqual(Mdouble v1, Mdouble v2, Mdouble absError)
Compares the difference of two Mdouble with an absolute error, useful in UnitTests.
template<>
std::string helpers::readFromCommandLine< std::string > ( int  argc,
char *  argv[],
std::string  varName,
std::string  value 
)

Definition at line 957 of file Helpers.cc.

References constants::i, INFO, and logger.

958 {
959  for (unsigned i=0; i<argc-1; ++i) {
960  if (varName == argv[i]) {
961  value = argv[i+1];
962  logger(INFO, "readFromCommandLine: % set to % ", varName.substr(1), value);
963  return value;
964  }
965  }
966  //if the variable is not found
967  logger(INFO, "readFromCommandLine: % set to default value % ", varName.substr(1), value);
968  return value;
969 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50