IFEM  90A354
TensorFunction.h
Go to the documentation of this file.
1 // $Id$
2 //==============================================================================
12 //==============================================================================
13 
14 #ifndef _TENSOR_FUNCTION_H
15 #define _TENSOR_FUNCTION_H
16 
17 #include "Function.h"
18 #include "matrixnd.h"
19 #include "Tensor.h"
20 
21 
26 class TensorFunc : public utl::SpatialFunction<Tensor>, public FunctionBase
27 {
28 protected:
30  explicit TensorFunc(size_t n = 0) : utl::SpatialFunction<Tensor>(Tensor(n))
31  {
32  ncmp = zero.size();
33  }
34 
35 public:
37  virtual ~TensorFunc() {}
38 
40  virtual unsigned char getType() const { return 3; }
41 
43  virtual std::vector<Real> getValue(const Vec3& X) const
44  {
45  return this->evaluate(X);
46  }
47 
49  virtual Real getScalarValue(const Vec3& X) const
50  {
51  return this->evaluate(X).trace();
52  }
53 
55  utl::matrix3d<Real> gradient(const Vec3& X) const;
56 
58  utl::matrix4d<Real> hessian(const Vec3& X) const;
59 
61  Tensor timeDerivative(const Vec3& X) const;
62 };
63 
64 
69 class STensorFunc : public utl::SpatialFunction<SymmTensor>,
70  public FunctionBase
71 {
73  size_t index(size_t nsd, size_t i, size_t j) const;
74 
75 protected:
77  STensorFunc(size_t n = 0, bool with33 = false)
79  {
80  ncmp = zero.size();
81  }
82 
83 public:
85  virtual ~STensorFunc() {}
86 
88  virtual unsigned char getType() const { return 3; }
89 
91  virtual std::vector<Real> getValue(const Vec3& X) const
92  {
93  return this->evaluate(X);
94  }
95 
97  virtual Real getScalarValue(const Vec3& X) const
98  {
99  return this->evaluate(X).trace();
100  }
101 
103  utl::matrix3d<Real> gradient(const Vec3& X) const;
104 
106  utl::matrix4d<Real> hessian(const Vec3& X) const;
107 
109  SymmTensor timeDerivative(const Vec3& X) const;
110 };
111 
112 #endif
General functions with arbitrary argument and value type.
#define Real
The floating point type to use.
Definition: ImmersedBoundaries.h:18
Representation of second-order tensors with some basic operations.
Base class for unary spatial functions of arbitrary result type.
Definition: Function.h:147
size_t ncmp
Number of components in the return value.
Definition: Function.h:184
Symmetric tensor-valued unary function of a spatial point.
Definition: TensorFunction.h:71
virtual unsigned char getType() const
Returns the function type flag.
Definition: TensorFunction.h:88
virtual std::vector< Real > getValue(const Vec3 &X) const
Returns the function value as an array.
Definition: TensorFunction.h:91
STensorFunc(size_t n=0, bool with33=false)
The constructor is protected to allow sub-class instances only.
Definition: TensorFunction.h:77
utl::matrix3d< Real > gradient(const Vec3 &X) const
Evaluates first derivatives of the function.
Definition: TensorFunction.C:58
size_t index(size_t nsd, size_t i, size_t j) const
Returns the flat indices of the symmetric tensor.
Definition: TensorFunction.C:44
SymmTensor timeDerivative(const Vec3 &X) const
Evaluates time derivatives of the function.
Definition: TensorFunction.C:91
virtual ~STensorFunc()
Empty destructor.
Definition: TensorFunction.h:85
utl::matrix4d< Real > hessian(const Vec3 &X) const
Evaluates second derivatives of the function.
Definition: TensorFunction.C:73
virtual Real getScalarValue(const Vec3 &X) const
Returns a representative scalar equivalent of the function value.
Definition: TensorFunction.h:97
Simple class for representing a symmetric second-order tensor.
Definition: Tensor.h:183
Tensor-valued unary function of a spatial point.
Definition: TensorFunction.h:27
virtual ~TensorFunc()
Empty destructor.
Definition: TensorFunction.h:37
virtual std::vector< Real > getValue(const Vec3 &X) const
Returns the function value as an array.
Definition: TensorFunction.h:43
TensorFunc(size_t n=0)
The constructor is protected to allow sub-class instances only.
Definition: TensorFunction.h:30
utl::matrix4d< Real > hessian(const Vec3 &X) const
Evaluates second derivatives of the function.
Definition: TensorFunction.C:26
virtual unsigned char getType() const
Returns the function type flag.
Definition: TensorFunction.h:40
Tensor timeDerivative(const Vec3 &X) const
Evaluates time derivatives of the function.
Definition: TensorFunction.C:35
utl::matrix3d< Real > gradient(const Vec3 &X) const
Evaluates first derivatives of the function.
Definition: TensorFunction.C:17
virtual Real getScalarValue(const Vec3 &X) const
Returns a representative scalar equivalent of the function value.
Definition: TensorFunction.h:49
Simple class for representing a non-symmetric second-order tensor.
Definition: Tensor.h:28
size_t size() const
Returns the size of this tensor.
Definition: Tensor.h:124
Simple class for representing a point in 3D space.
Definition: Vec3.h:27
virtual Result evaluate(const Arg &x) const =0
Evaluates the function for the argument x.
Base class for unary spatial function of arbitrary result type.
Definition: Function.h:98
SpatialFunction(const Tensor &val)
The constructor is protected to allow sub-class instances only.
Definition: Function.h:101
Tensor zero
Return value for default implementations of derivatives.
Definition: Function.h:117
Simple template classes for dense multi-dimensional matrices.
General utility classes and functions.
Definition: SIMoptions.h:22