14 #ifndef UTL_FUNCTION_H
15 #define UTL_FUNCTION_H
29 template<
class Arg,
class Result>
41 virtual bool isZero()
const {
return false; }
47 virtual Result
evaluate(
const Arg& x)
const = 0;
63 template<
class Arg,
class Result>
75 virtual bool isZero()
const {
return false; }
79 virtual Result
evaluate(
const Arg& x,
const Arg& y)
const = 0;
96 template<
class Result>
200 unsigned char getType()
const override {
return 1; }
205 return std::vector<Real>(1,this->
evaluate(X));
212 for (
size_t d = 1; d <= 3; ++d)
213 result[d-1] = this->
deriv(X,d);
222 for (
size_t d1 = 1; d1 <= 3; ++d1)
223 for (
size_t d2 = d1; d2 <= 3; ++d2)
224 result(d1,d2) = this->
dderiv(X, d1, d2);
252 unsigned char getType()
const override {
return 2; }
#define Real
The floating point type to use.
Definition: ImmersedBoundaries.h:18
Representation of second-order tensors with some basic operations.
Representation of a point in 3D space with some basic operations.
Base class for unary spatial functions of arbitrary result type.
Definition: Function.h:147
FunctionBase()
The constructor is protected to allow sub-class instances only.
Definition: Function.h:150
virtual ~FunctionBase()
Empty destructor.
Definition: Function.h:154
virtual Real getScalarValue(const Vec3 &) const =0
Returns a representative scalar equivalent of the function value.
void setParam(const std::string &name, const Vec3 &value)
Sets additional parameter values in the function.
Definition: Function.h:176
virtual unsigned char getType() const =0
Returns the function type flag.
virtual std::vector< Real > getValue(const Vec3 &) const =0
Returns the function value as an array.
size_t ncmp
Number of components in the return value.
Definition: Function.h:184
size_t dim() const
Returns the number of components of the return value.
Definition: Function.h:165
virtual bool inDomain(const Vec3 &) const
Checks if a specified point is within the function domain.
Definition: Function.h:171
virtual bool initPatch(size_t)
Sets the active patch.
Definition: Function.h:168
virtual void setParam(const std::string &, Real)
Sets an additional parameter in the function.
Definition: Function.h:174
Scalar-valued unary function of a spatial point.
Definition: Function.h:193
Real getScalarValue(const Vec3 &X) const override
Returns a representative scalar equivalent of the function value.
Definition: Function.h:230
RealFunc()
The constructor is protected to allow sub-class instances only.
Definition: Function.h:196
std::vector< Real > getValue(const Vec3 &X) const override
Returns the function value as an array.
Definition: Function.h:203
unsigned char getType() const override
Returns the function type flag.
Definition: Function.h:200
virtual Vec3 gradient(const Vec3 &X) const
Evaluates first derivatives of the function.
Definition: Function.h:209
virtual SymmTensor hessian(const Vec3 &X) const
Evaluates second derivatives of the function.
Definition: Function.h:219
Real timeDerivative(const Vec3 &X) const
Returns the time derivative of the function.
Definition: Function.h:233
Scalar-valued unary function of a scalar value.
Definition: Function.h:127
virtual Real deriv(Real) const
Returns the first-derivative of the function.
Definition: Function.h:136
ScalarFunc()
The constructor is protected to allow sub-class instances only.
Definition: Function.h:130
Real eval(Real x) const
Returns the function value for the argument x.
Definition: Function.h:134
Simple class for representing a symmetric second-order tensor.
Definition: Tensor.h:183
Simple class for representing a non-symmetric second-order tensor.
Definition: Tensor.h:28
Vector-valued binary function of a spatial point and normal vector.
Definition: Function.h:292
virtual bool isNormalPressure() const
Returns whether the traction is always normal to the face or not.
Definition: Function.h:295
virtual Vec3 timeDerivative(const Vec3 &, const Vec3 &) const
Returns the time-derivative of the function.
Definition: Function.h:298
Simple class for representing a point in 3D space.
Definition: Vec3.h:27
Real & x
Reference to X-component.
Definition: Vec3.h:31
Real & z
Reference to Z-component.
Definition: Vec3.h:33
Real & y
Reference to Y-component.
Definition: Vec3.h:32
Vector-valued unary function of a spatial point.
Definition: Function.h:242
Vec3 timeDerivative(const Vec3 &X) const
Evaluates time derivatives of the function.
Definition: Function.h:283
unsigned char getType() const override
Returns the function type flag.
Definition: Function.h:252
Tensor gradient(const Vec3 &X) const
Evaluates first derivatives of the function.
Definition: Function.h:267
Real getScalarValue(const Vec3 &X) const override
Returns a representative scalar equivalent of the function value.
Definition: Function.h:261
utl::matrix3d< Real > hessian(const Vec3 &X) const
Evaluates second derivatives of the function.
Definition: Function.h:275
std::vector< Real > getValue(const Vec3 &X) const override
Returns the function value as an array.
Definition: Function.h:255
VecFunc(size_t n=3)
The constructor is protected to allow sub-class instances only.
Definition: Function.h:245
Base class for binary function of arbitrary result and argument type.
Definition: Function.h:65
virtual Result evaluate(const Arg &x, const Arg &y) const =0
Evaluates the function for the arguments x and y.
virtual ~Function2()
Empty destructor.
Definition: Function.h:72
Result Output
Output type.
Definition: Function.h:87
Result operator()(const Arg &x, const Arg &y) const
Operator returning the function value for the given arguments.
Definition: Function.h:83
Function2()
The constructor is protected to allow sub-class instances only.
Definition: Function.h:68
virtual bool isZero() const
Returns whether the function is identically zero or not.
Definition: Function.h:75
Arg Input
Input type.
Definition: Function.h:86
Base class for unary functions of arbitrary result and argument type.
Definition: Function.h:31
virtual ~Function()
Empty destructor.
Definition: Function.h:38
virtual bool isZero() const
Returns whether the function is identically zero or not.
Definition: Function.h:41
Result operator()(const Arg &x) const
Operator returning the function value for the given argument.
Definition: Function.h:51
Result Output
Output type.
Definition: Function.h:54
virtual Result evaluate(const Arg &x) const =0
Evaluates the function for the argument x.
Function()
The constructor is protected to allow sub-class instances only.
Definition: Function.h:34
Arg Input
Input type.
Definition: Function.h:53
virtual bool isConstant() const
Returns whether the function is time-independent or not.
Definition: Function.h:43
Base class for unary spatial function of arbitrary result type.
Definition: Function.h:98
virtual std::vector< Real > evalHessian(const Vec3 &) const
Returns the hessian of the function as a 1D array.
Definition: Function.h:113
virtual std::vector< Real > evalTimeDerivative(const Vec3 &) const
Returns the time derivatives of the function as a 1D array.
Definition: Function.h:115
virtual Result dderiv(const Vec3 &, int, int) const
Returns a second-derivative of the function.
Definition: Function.h:107
virtual std::vector< Real > evalGradient(const Vec3 &) const
Returns the gradient of the function as a 1D array.
Definition: Function.h:111
virtual Result deriv(const Vec3 &, int) const
Returns a first-derivative of the function.
Definition: Function.h:105
SpatialFunction(const Result &val)
The constructor is protected to allow sub-class instances only.
Definition: Function.h:101
Result zero
Return value for default implementations of derivatives.
Definition: Function.h:117
void fill(T s)
Fill the matrix with a scalar value.
Definition: matrix.h:411
Simple template classes for dense multi-dimensional matrices.
General utility classes and functions.
Definition: SIMoptions.h:22