From fccea559f13ef7342c46a0b77f372bf52f454ae4 Mon Sep 17 00:00:00 2001 From: Knut Morten Okstad Date: Sat, 6 Aug 2016 15:11:33 +0200 Subject: [PATCH] Changed: Removed option to suppress print during parsing (not needed). Added: type="expression" as default. --- src/Utility/Functions.C | 36 ++++++++++++++++++------------------ src/Utility/Functions.h | 26 +++++++++++++++----------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/Utility/Functions.C b/src/Utility/Functions.C index a8058b09..2c59ec2a 100644 --- a/src/Utility/Functions.C +++ b/src/Utility/Functions.C @@ -140,7 +140,8 @@ Interpolate1D::Interpolate1D (const char* file, int dir_, int col, Real ramp) : return; } - while (is.good() && !is.eof()) { + while (is.good() && !is.eof()) + { char temp[1024]; is.getline(temp,1024); if (is.eof()) return; @@ -269,7 +270,8 @@ const RealFunc* utl::parseRealFunc (char* cline, Real A) { double x1 = atof(strtok(nullptr," ")); double y1 = atof(strtok(nullptr," ")); - IFEM::cout <<"StepXY(["<< x0 <<","<< x1 <<"]x["<< y0 <<","< 0) @@ -457,15 +459,13 @@ RealFunc* utl::parseRealFunc (const std::string& func, const std::string& type, else if (type == "linear") { p = atof(func.c_str()); - if (print) - IFEM::cout << p <<"*t"; + IFEM::cout << p <<"*t"; return new ConstTimeFunc(new LinearFunc(p)); } else if (type == "constant" || func.find_first_of("\t ") == std::string::npos) { p = atof(func.c_str()); - if (print) - IFEM::cout << p; + IFEM::cout << p; return new ConstFunc(p); } diff --git a/src/Utility/Functions.h b/src/Utility/Functions.h index fde5549b..65e94044 100644 --- a/src/Utility/Functions.h +++ b/src/Utility/Functions.h @@ -502,35 +502,39 @@ protected: namespace utl { //! \brief Creates a time function by parsing a character string. - const ScalarFunc* parseTimeFunc(const char* type, char* cline = nullptr, - Real C = Real(1)); + const ScalarFunc* parseTimeFunction(const char* type, char* cline, + Real C = Real(1)); //! \brief Creates a scalar-valued function by parsing a character string. const RealFunc* parseRealFunc(char* cline, Real A = Real(1)); //! \brief Creates a time function by parsing a character string. - ScalarFunc* parseTimeFunc(const char* func, const std::string& type); + //! \param[in] func Character string to parse function definition from + //! \param[in] type Function definition type flag + ScalarFunc* parseTimeFunc(const char* func, + const std::string& type = "expression"); //! \brief Creates a scalar-valued function by parsing a character string. //! \param[in] func Character string to parse function definition from //! \param[in] type Function definition type flag - //! \param[in] print If \e false, do not print out function definition - RealFunc* parseRealFunc(const std::string& func, const std::string& type, - bool print = true); + RealFunc* parseRealFunc(const std::string& func, + const std::string& type = "expression"); //! \brief Creates a vector-valued function by parsing a character string. //! \param[in] func Character string to parse function definition from - //! \param[in] type Function defintion type flag - //! \param[in] variables Variable definition for expression functions - VecFunc* parseVecFunc(const std::string& func, const std::string& type, + //! \param[in] type Function definition type flag + //! \param[in] variables Optional variable definition for expression functions + VecFunc* parseVecFunc(const std::string& func, + const std::string& type = "expression", const std::string& variables = ""); //! \brief Creates a vector-valued function defining a surface traction. //! \param[in] func Character string to parse function definition from - //! \param[in] type Function defintion type flag + //! \param[in] type Function definition type flag //! \param[in] dir Coordinate direction of the traction (0=normal direction) TractionFunc* parseTracFunc(const std::string& func, - const std::string& type, int dir); + const std::string& type = "expression", + int dir = 0); } #endif