expressions.md 5.39 KB
 Praetorius, Simon committed Nov 27, 2018 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 ``````## List of Expressions ### Terminal/elemental epressions In the following table, a `DV` represents a pointer or reference to a `DOFVector` of some value type `T`: | Expression | Semantics | | --------------- | ----------------------------- | | `valueOf(DV)` | Evaluation of a DOFVector in local coordinates | | `gradientOf(DV)`| Evaluation of the gradient of a DOFVector in local coodinates | | `derivativeOf(DV, i)` | Evaluation of the partial derivative of a DOFVector w.r.t. component i | | `hessianOf(DV)` | Evaluation of the hessian of a DOFVector, i.e. `H_ij = d_i(d_j(DV))` | | `laplacianOf(DV)` | Evaluation of the Lacplacian of a DOFVector, i.e. `L = sum_i(d_i(d_i(DV)))` | | `componentOf(DV, i)` | The i-th Component of a (vector valued) DOFVector | | `X(), X(i)` | The global coordinate `x(lambda)` of the local coordinate `lambda`, or its i-th component. | | `N(b), N(b,i)` | The outer boundary normal vector, w.r.t. the boundary face wiht nr `b`, or its i-th component. | | `M(), M(i)` | The surface normal vector (element normal) for surface grids, or its i-th component. | | `constant(c), c` | A constant numeric value | | `constant()` | A constant numeric value evaluable at compile time. Useful for symbolic differentiation, see below. | | `ref_(c)` | A reference wrapper of a dynamic numeric value. | The expression `valueOf(DV)` can also be applied to vector or matrices of DOFVectors.: | Expression | Semantics | | ---------- | --------- | | `valueOf(DV)` | Evaluation of a DOFVector in local coordinates | | `valueOf(vector>)` | Results in a `vector` with values from the DOFVectors evaluated in the local coordinates. | | `valueOf(matrix>)` | Results in a `matrix` with values from the DOFVectors evaluated in the local coordinates | | `valueOf(X)` | An expression with a name, i.e. a unique type `Name`. Usefull for symbolic differentiation. | ### Operations on expressions In the following table operations are listed that can be applied to elemental expressions or combination of those. In the list `T` and `Tn` represent an expression (term) and `F` represents a funktor-objekt (see below). | Expression | Semantics | | ---------- | --------- | | `+, -, *, /` | Arithmetic operations | | `pow
(T)` | The p-th power of an expression. | | `sqrt(T)` | The square-root of an expression | | `exp(T)` | The exponential function applied to the evaluated expression | | `log(T)` | The natural logarithm applied to an evaluated expression. | `````` Praetorius, Simon committed Nov 28, 2018 40 41 42 43 44 45 46 47 48 49 ``````| `cos(T), sin(T), tan(T)` | Cosine, sine, and tangens applied to an evaluated expression. | | `acos(T), asin(T), atan(T)` | Arccosine, Arcsine, and arctangent applied to an evaluated expression | | `atan2(T1, T2)` | The atan2 function, i.e. arctan(T1 / T2). | | `cosh(T), sinh(T), tanh(T)` | Hyperbolic cosine, hyperbolic sine, and hyperbolic tangent. | | `acosh(T), asinh(T), atanh(T)` | Inverse hyperbolic functions applied to an evaluated expression. | | `max(T1, T2), min(T1, T2)` | The maximum/minimum of two evaluated expressions T1 and T2. | | `abs_(T), signum(T)` | The absolute value and the sign (`T < 0 => signum(T) := -1, T>0 => signum(T) := 1, T==0 => signum(T) := 0`) | | `clamp(T, lo, hi)` | Applies the `std::clamp` function locally to the evaluated expression `T`, where `lo` and `hi` are fixed values. | | `ceil(T), floor(T)` | Round down or up the evaluated expression. | | `function_(F, T1, T2, T3, ...)` | Apply a functor to the evaluated expressions `T1,T2,...` | `````` Praetorius, Simon committed Nov 27, 2018 50 `````` `````` Praetorius, Simon committed Nov 28, 2018 51 ``````A functor is a class with the following structure: `````` Praetorius, Simon committed Nov 27, 2018 52 53 54 55 56 57 58 59 60 `````````c++ struct Functor : public FunctorBase { typedef (...) value_type; int getDegree(int d1, int d2, ...) const { return (...); } value_type operator()(const T1::value_type&, const T2::value_type&, ...) const { return (...); } }; ``` `````` Praetorius, Simon committed Nov 28, 2018 61 62 63 ``````or any valid function object in c++. When it is derived from `FunctorBase` one can specify an polynomial degree of the functor, relative to the polynomial degrees of the arguments passed to the functor, i.e. the polynomial degrees of the passed expressions. The `getDegree()` functor is then evaluated in the following form: `````` Praetorius, Simon committed Nov 27, 2018 64 65 66 67 68 `````````c++ getDegree(T1.getDegree(), T2.getDegree(), ...) ``` `````` Praetorius, Simon committed Nov 28, 2018 69 70 71 ``````### Vektor-/Matrix-Expressions For vector- and matrix-valued expressions, like, e.g., `gradientOf(DV)` one can apply functions that act on the vectors/matrices on evaluation. In the following list, the notation `V` refers to a vector expressions and `M` to a matrix expression: `````` Praetorius, Simon committed Nov 27, 2018 72 73 74 `````` | Expression | Semantics | | ---------- | --------- | `````` Praetorius, Simon committed Nov 28, 2018 75 76 77 78 79 80 81 82 83 84 85 86 87 ``````| `+, -` | Arithmetic operations (elementwise) | | `unary_dot(V)` | Scalarprodukt (dorproduct) of a vector with itself: `result = V^H * V`. | | `dot(V1, V2)` | Scalarprodukt (dorproduct) of two vectors: `result = V1^H * V2`. | | `one_norm(V)` | The 1-norm of a vectors `result = sum_i(abs(V_i))`. | | `one_norm(M)` | The 1-norm of a matrix `result = max_j(sum_i(abs(M_ij)))`. | | `two_norm(V)` | The 2-norm of a vector `result = sqrt(V^H * V)`. | | `p_norm