IFEM  90A354
Functions.h
Go to the documentation of this file.
1 // $Id$
2 //==============================================================================
12 //==============================================================================
13 
14 #ifndef _FUNCTIONS_H
15 #define _FUNCTIONS_H
16 
17 #include "Function.h"
18 
19 class TensorFunc;
20 namespace tinyxml2 { class XMLElement; }
21 
24 
25 
30 class ConstantFunc : public ScalarFunc
31 {
33 
34 public:
36  explicit ConstantFunc(Real v) : fval(v) {}
37 
39  bool isZero() const override { return fval == Real(0); }
40 
41 protected:
43  Real evaluate(const Real&) const override { return fval; }
44 };
45 
46 
51 class LinearFunc : public ScalarFunc
52 {
53  using Point = std::pair<Real,Real>;
54 
55  std::vector<Point> fvals;
57 
58 public:
60  explicit LinearFunc(Real s = Real(1)) : scale(s) {}
61 
66  explicit LinearFunc(const char* file, int c = 2, Real s = Real(1));
67 
71  LinearFunc(const std::vector<Real>& x, const std::vector<Real>& y);
72 
74  bool isZero() const override;
76  bool isConstant() const override { return fvals.size() == 1; }
77 
79  Real deriv(Real x) const override;
80 
81 protected:
83  Real evaluate(const Real& x) const override;
84 
85 private:
87  size_t locate(Real x) const;
88 };
89 
90 
95 class LinVecFunc : public VecTimeFunc
96 {
97  using Point = std::pair<Real,Vec3>;
98 
99  std::vector<Point> fvals;
100 
101 public:
105  explicit LinVecFunc(const char* file, int c = 2);
106 
108  bool isZero() const override;
110  bool isConstant() const override { return fvals.size() == 1; }
111 
112 protected:
114  Vec3 evaluate(const Real& x) const override;
115 };
116 
117 
122 class RampFunc : public ScalarFunc
123 {
126 
127 public:
129  explicit RampFunc(Real f = Real(1), Real x = Real(1)) : fval(f), xmax(x) {}
130 
132  bool isZero() const override { return fval == Real(0); }
134  bool isConstant() const override { return xmax <= Real(0); }
135 
137  Real deriv(Real x) const override;
138 
139 protected:
141  Real evaluate(const Real& x) const override;
142 };
143 
144 
149 class DiracFunc : public ScalarFunc
150 {
153 
154 public:
156  explicit DiracFunc(Real a = Real(1), Real x = Real(0)) : amp(a), xmax(x) {}
157 
159  bool isZero() const override { return amp == Real(0); }
160 
161 protected:
163  Real evaluate(const Real& x) const override;
164 };
165 
166 
171 class StepFunc : public ScalarFunc
172 {
175 
176 public:
178  explicit StepFunc(Real a, Real x = Real(0)) : amp(a), xmax(x) {}
179 
181  bool isZero() const override { return amp == Real(0); }
182 
183 protected:
185  Real evaluate(const Real& x) const override;
186 };
187 
188 
193 class SineFunc : public ScalarFunc
194 {
198 
199 public:
201  explicit SineFunc(Real s = Real(1), Real f = Real(1), Real p = Real(0))
202  : scale(s), freq(f), phase(p) {}
203 
205  bool isZero() const override { return scale == Real(0); }
207  bool isConstant() const override { return this->isZero(); }
208 
210  Real deriv(Real x) const override;
211 
212 protected:
214  Real evaluate(const Real& x) const override;
215 };
216 
217 
222 class ConstFunc : public RealFunc
223 {
225 
226 public:
228  explicit ConstFunc(Real v) : fval(v) {}
229 
231  bool isZero() const override { return fval == Real(0); }
232 
233 protected:
235  Real evaluate(const Vec3&) const override { return fval; }
236 };
237 
238 
243 class ConstTimeFunc : public RealFunc
244 {
245  const ScalarFunc* tfunc;
246 
247 public:
249  explicit ConstTimeFunc(const ScalarFunc* f) : tfunc(f) {}
251  virtual ~ConstTimeFunc() { delete tfunc; }
252 
254  bool isZero() const override { return tfunc->isZero(); }
256  bool isConstant() const override { return tfunc->isConstant(); }
257 
259  Real deriv(const Vec3& X, int dir) const override;
260 
261 protected:
263  Real evaluate(const Vec3& X) const override;
264 };
265 
266 
273 class SpaceTimeFunc : public RealFunc
274 {
275  const RealFunc* sfunc;
276  const ScalarFunc* tfunc;
277 
278 public:
280  SpaceTimeFunc(const RealFunc* s, const ScalarFunc* t) : sfunc(s), tfunc(t) {}
282  virtual ~SpaceTimeFunc() { delete sfunc; delete tfunc; }
283 
285  bool isZero() const override { return sfunc->isZero() || tfunc->isZero(); }
287  bool isConstant() const override { return tfunc->isConstant(); }
288 
290  Real deriv(const Vec3& X, int dir) const override;
292  Real dderiv(const Vec3& X, int dir1, int dir2) const override;
293 
294 protected:
296  Real evaluate(const Vec3& X) const override;
297 };
298 
299 
304 class LinearXFunc : public RealFunc
305 {
306  Real a;
307  Real b;
308 
309 public:
311  explicit LinearXFunc(Real A, Real B = Real(0)) : a(A), b(B) {}
312 
314  bool isZero() const override { return a == Real(0) && b == Real(0); }
315 
317  Real deriv(const Vec3&, int dir) const override;
318 
319 protected:
321  Real evaluate(const Vec3& X) const override;
322 };
323 
324 
329 class LinearYFunc : public RealFunc
330 {
331  Real a;
332  Real b;
333 
334 public:
336  explicit LinearYFunc(Real A, Real B = Real(0)) : a(A), b(B) {}
337 
339  bool isZero() const override { return a == Real(0) && b == Real(0); }
340 
342  Real deriv(const Vec3&, int dir) const override;
343 
344 protected:
346  Real evaluate(const Vec3& X) const override;
347 };
348 
349 
354 class LinearZFunc : public RealFunc
355 {
356  Real a;
357  Real b;
358 
359 public:
361  explicit LinearZFunc(Real A, Real B = Real(0)) : a(A), b(B) {}
362 
364  bool isZero() const override { return a == Real(0) && b == Real(0); }
365 
367  Real deriv(const Vec3&, int dir) const override;
368 
369 protected:
371  Real evaluate(const Vec3& X) const override;
372 };
373 
374 
379 class QuadraticXFunc : public RealFunc
380 {
382  Real a;
383  Real b;
384 
385 public:
387  QuadraticXFunc(Real MAX, Real A, Real B) : max(MAX), a(A), b(B) {}
388 
390  bool isZero() const override { return max == Real(0); }
391 
393  Real deriv(const Vec3& X, int dir) const override;
395  Real dderiv(const Vec3&, int dir1, int dir2) const override;
396 
397 protected:
399  Real evaluate(const Vec3& X) const override;
400 };
401 
402 
407 class QuadraticYFunc : public RealFunc
408 {
410  Real a;
411  Real b;
412 
413 public:
415  QuadraticYFunc(Real MAX, Real A, Real B) : max(MAX), a(A), b(B) {}
416 
418  bool isZero() const override { return max == Real(0); }
419 
421  Real deriv(const Vec3& X, int dir) const override;
423  Real dderiv(const Vec3&, int dir1, int dir2) const override;
424 
425 protected:
427  Real evaluate(const Vec3& X) const override;
428 };
429 
430 
435 class QuadraticZFunc : public RealFunc
436 {
438  Real a;
439  Real b;
440 
441 public:
443  QuadraticZFunc(Real MAX, Real A, Real B) : max(MAX), a(A), b(B) {}
444 
446  bool isZero() const override { return max == Real(0); }
447 
449  Real deriv(const Vec3& X, int dir) const override;
451  Real dderiv(const Vec3&, int dir1, int dir2) const override;
452 
453 protected:
455  Real evaluate(const Vec3& X) const override;
456 };
457 
458 
471 class LinearRotZFunc : public RealFunc
472 {
473  bool rX;
474  Real A;
477 
478 public:
480  LinearRotZFunc(bool retX, Real a, Real x_0 = Real(0), Real y_0 = Real(0))
481  : rX(retX), A(a), x0(x_0), y0(y_0) {}
482 
484  bool isZero() const override { return A == Real(0); }
486  bool isConstant() const override { return this->isZero(); }
487 
489  Real deriv(const Vec3&, int dir) const override;
490 
491 protected:
493  Real evaluate(const Vec3& X) const override;
494 };
495 
496 
501 class StepXFunc : public RealFunc
502 {
506  char d;
507 
508 public:
510  explicit StepXFunc(Real v, Real a = Real(0), Real b = Real(1), char dir = 'X')
511  : fv(v), x0(a), x1(b), d(dir) {}
512 
514  bool isZero() const override { return fv == Real(0); }
515 
516 protected:
518  Real evaluate(const Vec3& X) const override;
519 };
520 
521 
526 class StepXYFunc : public RealFunc
527 {
533 
534 public:
536  explicit StepXYFunc(Real v,
537  Real X1 = Real( 1), Real Y1 = Real( 1),
538  Real X0 = Real(-1), Real Y0 = Real(-1))
539  : fv(v), x0(X0), y0(Y0), x1(X1), y1(Y1) {}
540 
542  bool isZero() const override { return fv == Real(0); }
543 
544 protected:
546  Real evaluate(const Vec3& X) const override;
547 };
548 
549 
554 class Interpolate1D : public RealFunc
555 {
557  int dir;
559 
560 public:
566  Interpolate1D(const char* file, int dir_, int col = 2, Real ramp = Real(0))
567  : lfunc(file,col), dir(dir_), time(ramp) {}
568 
574  Interpolate1D(const std::vector<Real>& xVal, const std::vector<Real>& yVal,
575  int dir_ = 1, Real ramp = Real(0))
576  : lfunc(xVal,yVal), dir(dir_), time(ramp) {}
577 
579  bool isZero() const override { return lfunc.isZero(); }
581  bool isConstant() const override { return time <= Real(0); }
582 
584  Real deriv(const Vec3&, int ddir) const override;
585 
586 protected:
588  Real evaluate(const Vec3& X) const override;
589 };
590 
591 
596 class ConstVecFunc : public VecFunc
597 {
599 
600 public:
602  explicit ConstVecFunc(const Vec3& v) : fval(v) {}
603 
605  bool isZero() const override { return fval.isZero(0.0); }
606 
607 protected:
609  Vec3 evaluate(const Vec3&) const override { return fval; }
610 };
611 
612 
613 namespace utl
614 {
616  const RealFunc* parseRealFunc(char* cline, Real A = Real(1),
617  bool print = true);
618 
623  ScalarFunc* parseTimeFunc(const char* func,
624  const std::string& type = "expression",
625  Real eps = Real(1.0e-8));
626 
630  VecTimeFunc* parseVecTimeFunc(const char* func,
631  const std::string& type);
632 
637  RealFunc* parseRealFunc(const std::string& func,
638  const std::string& type = "expression",
639  bool print = true);
640 
647  RealFunc* parseExprRealFunc(const std::string& function, bool autodiff);
648 
655  VecFunc* parseExprVecFunc(const std::string& function, bool autodiff);
656 
660  IntFunc* parseIntFunc(const std::string& func,
661  const std::string& type = "expression");
662 
667  VecFunc* parseVecFunc(const std::string& func,
668  const std::string& type = "expression",
669  const std::string& variables = "");
670 
674  TensorFunc* parseTensorFunc(const std::string& func,
675  const std::string& type);
676 
681  TractionFunc* parseTracFunc(const std::string& func,
682  const std::string& type = "expression",
683  int dir = 0);
684 
687  TractionFunc* parseTracFunc(const tinyxml2::XMLElement* elem);
688 }
689 
690 #endif
General functions with arbitrary argument and value type.
#define Real
The floating point type to use.
Definition: ImmersedBoundaries.h:18
A scalar-valued spatial function, constant in space and time.
Definition: Functions.h:223
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:231
Real fval
The function value.
Definition: Functions.h:224
ConstFunc(Real v)
Constructor initializing the function value.
Definition: Functions.h:228
Real evaluate(const Vec3 &) const override
Evaluates the constant function.
Definition: Functions.h:235
A scalar-valued spatial function, constant in space, varying in time.
Definition: Functions.h:244
const ScalarFunc * tfunc
The time-dependent function value.
Definition: Functions.h:245
Real deriv(const Vec3 &X, int dir) const override
Returns first-derivative of the function.
Definition: Functions.C:408
ConstTimeFunc(const ScalarFunc *f)
Constructor initializing the function value.
Definition: Functions.h:249
bool isConstant() const override
Returns whether the function is time-independent or not.
Definition: Functions.h:256
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:254
virtual ~ConstTimeFunc()
The destructor frees the time function.
Definition: Functions.h:251
Real evaluate(const Vec3 &X) const override
Evaluates the time-varying function.
Definition: Functions.C:401
A vector-valued spatial function, constant in space and time.
Definition: Functions.h:597
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:605
ConstVecFunc(const Vec3 &v)
Constructor initializing the function value.
Definition: Functions.h:602
Vec3 evaluate(const Vec3 &) const override
Evaluates the constant function.
Definition: Functions.h:609
Vec3 fval
The function value.
Definition: Functions.h:598
A scalar-valued constant function.
Definition: Functions.h:31
Real evaluate(const Real &) const override
Evaluates the constant function.
Definition: Functions.h:43
Real fval
The function value.
Definition: Functions.h:32
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:39
ConstantFunc(Real v)
Constructor initializing the function value.
Definition: Functions.h:36
A scalar-valued dirac function.
Definition: Functions.h:150
DiracFunc(Real a=Real(1), Real x=Real(0))
Constructor initializing the function parameters.
Definition: Functions.h:156
Real amp
The amplitude of the dirac function.
Definition: Functions.h:151
Real xmax
Associated x value.
Definition: Functions.h:152
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:159
Real evaluate(const Real &x) const override
Evaluates the function at x.
Definition: Functions.C:377
A scalar-valued spatial function, linear interpolation.
Definition: Functions.h:555
Real deriv(const Vec3 &, int ddir) const override
Returns first-derivative of the function.
Definition: Functions.C:614
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:579
int dir
In which direction to perform the interpolation.
Definition: Functions.h:557
Interpolate1D(const std::vector< Real > &xVal, const std::vector< Real > &yVal, int dir_=1, Real ramp=Real(0))
Constructor initializing the function parameters from two lists.
Definition: Functions.h:574
Real time
Ramp-up time.
Definition: Functions.h:558
LinearFunc lfunc
The piece-wise linear function doing the interpolation.
Definition: Functions.h:556
Interpolate1D(const char *file, int dir_, int col=2, Real ramp=Real(0))
Constructor initializing the function parameters from a file.
Definition: Functions.h:566
Real evaluate(const Vec3 &X) const override
Evaluates the function by interpolation.
Definition: Functions.C:602
bool isConstant() const override
Returns whether the function is time-independent or not.
Definition: Functions.h:581
A vector-valued linear function.
Definition: Functions.h:96
LinVecFunc(const char *file, int c=2)
Constructor initializing piece-wise linear function values.
Definition: Functions.C:278
std::pair< Real, Vec3 > Point
Convenience type.
Definition: Functions.h:97
bool isConstant() const override
Returns whether the function is constant or not.
Definition: Functions.h:110
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.C:329
std::vector< Point > fvals
Values for piece-wise linear function.
Definition: Functions.h:99
Vec3 evaluate(const Real &x) const override
Evaluates the function at x.
Definition: Functions.C:339
A scalar-valued linear function.
Definition: Functions.h:52
LinearFunc(Real s=Real(1))
Constructor initializing the scaling parameter.
Definition: Functions.h:60
std::vector< Point > fvals
Values for piece-wise linear function.
Definition: Functions.h:55
bool isConstant() const override
Returns whether the function is constant or not.
Definition: Functions.h:76
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.C:230
Real scale
Scaling factor.
Definition: Functions.h:56
size_t locate(Real x) const
Retuns the index of the first point after x.
Definition: Functions.C:220
Real deriv(Real x) const override
Returns the first-derivative of the function.
Definition: Functions.C:240
Real evaluate(const Real &x) const override
Evaluates the function at x.
Definition: Functions.C:258
std::pair< Real, Real > Point
Convenience type.
Definition: Functions.h:53
A scalar-valued spatial function, defining a rotation about the Z-axis.
Definition: Functions.h:472
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:484
bool rX
Flag telling whether to return the X- (true) or Y-component.
Definition: Functions.h:473
bool isConstant() const override
Returns whether the function is time-independent or not.
Definition: Functions.h:486
Real deriv(const Vec3 &, int dir) const override
Returns first-derivative of the function.
Definition: Functions.C:573
Real y0
Global Y-coordinate of rotation centre.
Definition: Functions.h:476
Real A
Magnitude of the rotation.
Definition: Functions.h:474
LinearRotZFunc(bool retX, Real a, Real x_0=Real(0), Real y_0=Real(0))
Constructor initializing the function parameters.
Definition: Functions.h:480
Real evaluate(const Vec3 &X) const override
Evaluates the rotation function.
Definition: Functions.C:559
Real x0
Global X-coordinate of rotation centre.
Definition: Functions.h:475
A scalar-valued spatial function, linear in x.
Definition: Functions.h:305
Real evaluate(const Vec3 &X) const override
Evaluates the linear function.
Definition: Functions.C:448
Real deriv(const Vec3 &, int dir) const override
Returns first-derivative of the function.
Definition: Functions.C:454
Real a
The function derivative.
Definition: Functions.h:306
Real b
The function value at x = 0.
Definition: Functions.h:307
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:314
LinearXFunc(Real A, Real B=Real(0))
Constructor initializing the function parameters.
Definition: Functions.h:311
A scalar-valued spatial function, linear in y.
Definition: Functions.h:330
LinearYFunc(Real A, Real B=Real(0))
Constructor initializing the function parameters.
Definition: Functions.h:336
Real b
The function value at y = 0.
Definition: Functions.h:332
Real evaluate(const Vec3 &X) const override
Evaluates the linear function.
Definition: Functions.C:460
Real a
The function derivative.
Definition: Functions.h:331
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:339
Real deriv(const Vec3 &, int dir) const override
Returns first-derivative of the function.
Definition: Functions.C:466
A scalar-valued spatial function, linear in z.
Definition: Functions.h:355
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:364
Real deriv(const Vec3 &, int dir) const override
Returns first-derivative of the function.
Definition: Functions.C:478
Real a
The function derivative.
Definition: Functions.h:356
Real evaluate(const Vec3 &X) const override
Evaluates the linear function.
Definition: Functions.C:472
LinearZFunc(Real A, Real B=Real(0))
Constructor initializing the function parameters.
Definition: Functions.h:361
Real b
The function value at z = 0.
Definition: Functions.h:357
A scalar-valued spatial function, quadratic in x.
Definition: Functions.h:380
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:390
Real deriv(const Vec3 &X, int dir) const override
Returns first-derivative of the function.
Definition: Functions.C:491
QuadraticXFunc(Real MAX, Real A, Real B)
Constructor initializing the function parameters.
Definition: Functions.h:387
Real b
Second root where function is zero.
Definition: Functions.h:383
Real max
Max value of function.
Definition: Functions.h:381
Real a
First root where function is zero.
Definition: Functions.h:382
Real evaluate(const Vec3 &X) const override
Evaluates the quadratic function.
Definition: Functions.C:484
Real dderiv(const Vec3 &, int dir1, int dir2) const override
Returns second-derivative of the function.
Definition: Functions.C:500
A scalar-valued spatial function, quadratic in y.
Definition: Functions.h:408
QuadraticYFunc(Real MAX, Real A, Real B)
Constructor initializing the function parameters.
Definition: Functions.h:415
Real dderiv(const Vec3 &, int dir1, int dir2) const override
Returns second-derivative of the function.
Definition: Functions.C:525
Real a
First root where function is zero.
Definition: Functions.h:410
Real deriv(const Vec3 &X, int dir) const override
Returns first-derivative of the function.
Definition: Functions.C:516
Real evaluate(const Vec3 &X) const override
Evaluates the quadratic function.
Definition: Functions.C:509
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:418
Real max
Max value of function.
Definition: Functions.h:409
Real b
Second root where function is zero.
Definition: Functions.h:411
A scalar-valued spatial function, quadratic in z.
Definition: Functions.h:436
Real dderiv(const Vec3 &, int dir1, int dir2) const override
Returns second-derivative of the function.
Definition: Functions.C:541
Real max
Max value of function.
Definition: Functions.h:437
QuadraticZFunc(Real MAX, Real A, Real B)
Constructor initializing the function parameters.
Definition: Functions.h:443
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:446
Real deriv(const Vec3 &X, int dir) const override
Returns first-derivative of the function.
Definition: Functions.C:550
Real a
First root where function is zero.
Definition: Functions.h:438
Real b
Second root where function is zero.
Definition: Functions.h:439
Real evaluate(const Vec3 &X) const override
Evaluates the quadratic function.
Definition: Functions.C:534
A scalar-valued ramp function, linear up to xmax.
Definition: Functions.h:123
Real deriv(Real x) const override
Returns the first-derivative of the function.
Definition: Functions.C:371
Real fval
Max function value.
Definition: Functions.h:124
Real xmax
The function is linear from x = 0 to x = xmax.
Definition: Functions.h:125
bool isConstant() const override
Returns whether the function is time-independent or not.
Definition: Functions.h:134
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:132
RampFunc(Real f=Real(1), Real x=Real(1))
Constructor initializing the function parameters.
Definition: Functions.h:129
Real evaluate(const Real &x) const override
Evaluates the function at x.
Definition: Functions.C:365
Scalar-valued unary function of a spatial point.
Definition: Function.h:193
Scalar-valued unary function of a scalar value.
Definition: Function.h:127
A scalar-valued sinusoidal function.
Definition: Functions.h:194
Real freq
Angular frequency of the sine function.
Definition: Functions.h:196
Real evaluate(const Real &x) const override
Evaluates the function at x.
Definition: Functions.C:389
SineFunc(Real s=Real(1), Real f=Real(1), Real p=Real(0))
Constructor initializing the function parameters.
Definition: Functions.h:201
Real scale
Amplitude of the sine function.
Definition: Functions.h:195
Real phase
Phase shift of the sine function.
Definition: Functions.h:197
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:205
bool isConstant() const override
Returns whether the function is time-independent or not.
Definition: Functions.h:207
Real deriv(Real x) const override
Returns the first-derivative of the function.
Definition: Functions.C:395
A scalar-valued spatial function, varying in space and time.
Definition: Functions.h:274
SpaceTimeFunc(const RealFunc *s, const ScalarFunc *t)
Constructor initializing the function terms.
Definition: Functions.h:280
Real dderiv(const Vec3 &X, int dir1, int dir2) const override
Returns second-derivative of the function.
Definition: Functions.C:434
virtual ~SpaceTimeFunc()
The destructor frees the space and time functions.
Definition: Functions.h:282
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:285
const ScalarFunc * tfunc
The time-dependent term.
Definition: Functions.h:276
Real deriv(const Vec3 &X, int dir) const override
Returns first-derivative of the function.
Definition: Functions.C:424
const RealFunc * sfunc
The space-dependent term.
Definition: Functions.h:275
bool isConstant() const override
Returns whether the function is time-independent or not.
Definition: Functions.h:287
Real evaluate(const Vec3 &X) const override
Evaluates the space-time function.
Definition: Functions.C:417
A scalar-valued step function.
Definition: Functions.h:172
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:181
Real xmax
Associated x value.
Definition: Functions.h:174
Real evaluate(const Real &x) const override
Evaluates the function at x.
Definition: Functions.C:383
Real amp
The amplitude of the step function.
Definition: Functions.h:173
StepFunc(Real a, Real x=Real(0))
Constructor initializing the function parameters.
Definition: Functions.h:178
A scalar-valued spatial function, step in x.
Definition: Functions.h:502
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:514
Real evaluate(const Vec3 &X) const override
Evaluates the step function.
Definition: Functions.C:590
Real x1
The function is zero for x > x1.
Definition: Functions.h:505
Real x0
The function is zero for x < x0.
Definition: Functions.h:504
char d
Coordinate to step in (default X).
Definition: Functions.h:506
Real fv
The non-zero function value.
Definition: Functions.h:503
StepXFunc(Real v, Real a=Real(0), Real b=Real(1), char dir='X')
Constructor initializing the function parameters.
Definition: Functions.h:510
A scalar-valued spatial function, step in x and y.
Definition: Functions.h:527
Real y0
The function is zero for y < y0.
Definition: Functions.h:530
bool isZero() const override
Returns whether the function is identically zero or not.
Definition: Functions.h:542
Real fv
The non-zero function value.
Definition: Functions.h:528
Real x0
The function is zero for x < x0.
Definition: Functions.h:529
Real y1
The function is zero for y > y1.
Definition: Functions.h:532
Real evaluate(const Vec3 &X) const override
Evaluates the step function.
Definition: Functions.C:596
Real x1
The function is zero for x > x1.
Definition: Functions.h:531
StepXYFunc(Real v, Real X1=Real(1), Real Y1=Real(1), Real X0=Real(-1), Real Y0=Real(-1))
Constructor initializing the function parameters.
Definition: Functions.h:536
Tensor-valued unary function of a spatial point.
Definition: TensorFunction.h:27
Vector-valued binary function of a spatial point and normal vector.
Definition: Function.h:292
Simple class for representing a point in 3D space.
Definition: Vec3.h:27
bool isZero(double tol=1.0e-6) const
Check if the vector is zero with the given tolerance.
Definition: Vec3.h:144
Vector-valued unary function of a spatial point.
Definition: Function.h:242
Base class for unary functions of arbitrary result and argument type.
Definition: Function.h:31
virtual bool isZero() const
Returns whether the function is identically zero or not.
Definition: Function.h:41
virtual bool isConstant() const
Returns whether the function is time-independent or not.
Definition: Function.h:43
General utility classes and functions.
Definition: SIMoptions.h:22
VecTimeFunc * parseVecTimeFunc(const char *func, const std::string &type)
Creates a vector-valued time function by parsing a char string.
Definition: Functions.C:962
const RealFunc * parseRealFunc(char *cline, Real A=Real(1), bool print=true)
Creates a scalar-valued function by parsing a character string.
Definition: Functions.C:647
RealFunc * parseExprRealFunc(const std::string &function, bool autodiff)
Creates a scalar-valued function by parsing a character string.
Definition: ExprFunctions.C:722
TensorFunc * parseTensorFunc(const std::string &func, const std::string &type)
Creates a tensor-valued function by parsing a character string.
Definition: Functions.C:1097
IntFunc * parseIntFunc(const std::string &func, const std::string &type="expression")
Creates a scalar-valued int function by parsing a character string.
Definition: Functions.C:850
ScalarFunc * parseTimeFunc(const char *func, const std::string &type="expression", Real eps=Real(1.0e-8))
Creates a time function by parsing a character string.
Definition: Functions.C:943
TractionFunc * parseTracFunc(const std::string &func, const std::string &type="expression", int dir=0)
Creates a vector-valued function defining a surface traction.
Definition: Functions.C:1129
VecFunc * parseExprVecFunc(const std::string &function, bool autodiff)
Creates a Vector-valued function by parsing a character string.
Definition: ExprFunctions.C:731
VecFunc * parseVecFunc(const std::string &func, const std::string &type="expression", const std::string &variables="")
Creates a vector-valued function by parsing a character string.
Definition: Functions.C:1038