changed: add a parameter to suppress printing during RealFunc parsing

This commit is contained in:
Arne Morten Kvarving 2020-04-24 10:46:56 +02:00
parent f62f7d15bc
commit 2ccafc972e
3 changed files with 14 additions and 7 deletions

View File

@ -75,7 +75,7 @@ public:
//! \brief Saves point results to output file for a given time step.
//! \param[in] time Load/time step parameter
//! \param[in] Step Load/time step counter
//! \param[in] iStep Load/time step counter
//! \details By default it just forwards to the underlying model
virtual bool savePoints(double time, int iStep) const;

View File

@ -572,16 +572,19 @@ ScalarFunc* utl::parseTimeFunc (const char* func, const std::string& type,
}
RealFunc* utl::parseRealFunc (const std::string& func, const std::string& type)
RealFunc* utl::parseRealFunc (const std::string& func,
const std::string& type, bool print)
{
Real p = Real(0);
if (func.empty())
return new ConstFunc(p);
IFEM::cout <<": ";
if (print)
IFEM::cout <<": ";
if (type == "expression")
{
IFEM::cout << func;
if (print)
IFEM::cout << func;
EvalFunc::numError = 0;
RealFunc* rf = new EvalFunction(func.c_str());
if (EvalFunc::numError > 0)
@ -594,13 +597,15 @@ RealFunc* utl::parseRealFunc (const std::string& func, const std::string& type)
else if (type == "linear")
{
p = atof(func.c_str());
IFEM::cout << p <<"*t";
if (print)
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());
IFEM::cout << p;
if (print)
IFEM::cout << p;
return new ConstFunc(p);
}

View File

@ -558,8 +558,10 @@ namespace utl
//! \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 True to print function to terminal
RealFunc* parseRealFunc(const std::string& func,
const std::string& type = "expression");
const std::string& type = "expression",
bool print = true);
//! \brief Creates a vector-valued function by parsing a character string.
//! \param[in] func Character string to parse function definition from