diff --git a/src/Utility/Functions.C b/src/Utility/Functions.C index eeadbcfd..b1e29128 100644 --- a/src/Utility/Functions.C +++ b/src/Utility/Functions.C @@ -239,7 +239,7 @@ Real LinearRotZFunc::deriv (const Vec3& X, int dir) const Real StepXFunc::evaluate (const Vec3& X) const { - return X.x < x0 || X.x > x1 ? Real(0) : fv; + return X[d-'X'] < x0 || X[d-'X'] > x1 ? Real(0) : fv; } @@ -320,6 +320,7 @@ const RealFunc* utl::parseRealFunc (char* cline, Real A) // Check for spatial variation int linear = 0; int quadratic = 0; + char stepDir = 'X'; if (!cline) linear = -1; else if (strcasecmp(cline,"X") == 0) @@ -332,8 +333,13 @@ const RealFunc* utl::parseRealFunc (char* cline, Real A) linear = 4; else if (strcasecmp(cline,"YrotZ") == 0) linear = 5; - else if (strcasecmp(cline,"StepX") == 0) + else if (strcasecmp(cline,"StepX") == 0 || + strcasecmp(cline,"StepY") == 0 || + strcasecmp(cline,"StepZ") == 0) + { linear = 6; + stepDir = toupper(cline[4]); + } else if (strcasecmp(cline,"StepXY") == 0) linear = 7; else if (strcasecmp(cline,"Interpolate1D") == 0) @@ -377,8 +383,8 @@ const RealFunc* utl::parseRealFunc (char* cline, Real A) { double x0 = atof(cline); double x1 = atof(strtok(nullptr," ")); - IFEM::cout <<"StepX("<< x0 <<","<< x1 <<"))"; - f = new StepXFunc(A,x0,x1); + IFEM::cout <<"Step"<< stepDir <<"("<< x0 <<","<< x1 <<"))"; + f = new StepXFunc(A,x0,x1,stepDir); } break; case 7: diff --git a/src/Utility/Functions.h b/src/Utility/Functions.h index 3c437674..9723f655 100644 --- a/src/Utility/Functions.h +++ b/src/Utility/Functions.h @@ -443,11 +443,12 @@ class StepXFunc : public RealFunc Real fv; //!< The non-zero function value Real x0; //!< Function is zero for \a x < \a x0 Real x1; //!< Function is zero for \a x > \a x1 + char d; //!< Coordinate to step in (default X). public: //! \brief Constructor initializing the function parameters. - StepXFunc(Real v, Real X0 = Real(0), Real X1 = Real(1)) - : fv(v), x0(X0), x1(X1) {} + StepXFunc(Real v, Real X0 = Real(0), Real X1 = Real(1), char dir = 'X') + : fv(v), x0(X0), x1(X1), d(dir) {} //! \brief Returns whether the function is identically zero or not. virtual bool isZero() const { return fv == Real(0); }