---
name: "expression"
section: "3rheolef"
platform: "linux"
package: "librheolef-dev"
version: "7.2-4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/expression"
---

# expression(3rheolef)

involved by interpolate and integrate (rheolef-7.2)

## NAME

expression - involved by interpolate and integrate (rheolef-7.2)

## SYNOPSIS

```
template <class Expression>
field interpolate (const space& Xh, const Expression& expr);
template <class Expression>
Result integrate (const Expression& expr);
```

## DESCRIPTION

The expressions involved by **interpolate(3)** and **integrate(3)** functions base on several predefined operators and functions that are reviewed here. Let `phi`, `psi` be two scalar-valued **field(2)** or **test(2)** objects. Similarly, let `u`, `v` be two vector-valued objects and `sigma` and `tau` be two tensor-valued objects. In the following table, the indexes i and j are summed from 0 to d-1 where d is the dimension of the physical geometry, as described by the **geo(2)** class.

```
c++ code                | mathematics
------------------------+----------------------------------------------
dot(u,v)                | u.v = sum_i u_i v_i
ddot(sigma,tau)         | sigma:tau = sum_ij sigma_ij tau_ij
dddot(sigma,tau)        | A:.B = sum_ijk A_ijk B_ijk
tr(sigma)               | sum_i sigma_ii
trans(sigma)            | sigma^T the transpose
sqr(phi), norm2(phi)    | phi^2
norm2(u)                | sum_i u_i^2
norm2(sigma)            | sum_ij sigma_ij^2
abs(phi), norm(phi)     | absolute value
norm(u)                 | sqrt(norm2(u))
norm(sigma)             | sqrt(norm2(sigma))
------------------------+----------------------------------------------
grad(phi)               | (d phi/d x_i)_i
grad(u)                 | (d u_i/d x_j)_ij
D(u)                    | (grad(u) + grad(u)^T)/2
div(u)                  | sum_i d u_i/d x_i = tr(D(u))
curl(phi)               | (d phi/d x_1, - d phi/d x_0) when d=2
curl(u)                 | grad^u when d=3
------------------------+----------------------------------------------
normal()                | n, the outward unit normal
grad_s(phi)             | P*grad(phi) where P = I - n otimes n
grad_s(u)               | grad(u)*P
Ds(u)                   | P*D(u)*P
div_s(u)                | tr(Ds(u))
------------------------+----------------------------------------------
grad_h(phi)             | grad(phi|K) broken gradient, piecewise
div_h(u)                | div(u|K)
Dh(u)                   | D(u|K)
------------------------+----------------------------------------------
jump(phi)               | [phi] = phi|K0 - phi|K1
                        |         on an oriented side S = dK0 inter dK1
average(phi)            | {phi} = (phi|K0 + phi|K1)/2
inner(phi)              | phi|K0
outer(phi)              | phi|K1
h_local()               | meas(K)^(1/d)
penalty()               | max(meas(dK0)/meas(K0), meas(dK1)/meas(K1))
------------------------+----------------------------------------------
sin, cos, tan, acos,    | standard math function extended to field
asin, atan, cosh, sinh, | and test functions
tanh, log, log10, floor |
ceil                    |
pow(phi,psi)            |
atan2(phi,psi)          | atan(psi/phi)
fmod(phi,psi)           | phi - floor(phi/psi+0.5)*psi
min(phi,psi)            |
max(phi,psi)            |
------------------------+----------------------------------------------
compose(f,phi)          | f(phi), for a given function f
compose(f,phi1,..,phin) | f(phi0,...,phin)
compose(phi,X)          | phi(X) for a characteristic X
```

 See also **compose(3)** and **characteristic(2)** for details.

## IMPLEMENTATION

The practical implementation of expressions involved by **interpolate(3)** and **integrate(3)** functions bases on two very classical C++ idioms: the `expression template` and the `Substitution failure is not an error (SFINAE)`. These C++ idioms are described in the following book:

D. Vandevoorde and N. M. Josuttis, C++ templates: the complete guide, Addison-Wesley, 2002

## AUTHOR

Pierre  Saramito  \<Pierre.Saramito@imag.fr\>

## COPYRIGHT

Copyright   (C)  2000-2018  Pierre  Saramito  \<Pierre.Saramito@imag.fr\> GPLv3+: GNU GPL version 3 or later  \<http://gnu.org/licenses/gpl.html\>. This  is  free  software:  you  are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
