Tatooine
Fields

Introduction

Fields are functors that map a spatio-temporal domain to a tensor.

There is tatooine::polymorphic::field that every field is derived from. Use references or pointers of this type to be able to write generic code that involves fields.

Then there is tatooine::field that uses CRTP to provide some more compile-time-optimization.

Every field should be derived from tatooine::field.

Analytical Fields

For each analytical field exists a numerical and a symbolic version. The symbolic versions use GiNaC. The numerical versions simply use functions from the cmath header and tatooine::vec, tatooine::mat or tatooine::tensor and its Operations and.

See also
tatooine::analytical::numerical::doublegyre
tatooine::analytical::symbolic::doublegyre
tatooine::analytical::numerical::abcflow
tatooine::analytical::symbolic::abcflow

Minimal Example

The following example shows how to define an easy vector field. When creating a field two methods have to be provided:

  • in_domain and
  • evaluate.

Both methods get a position and a time. in_domain defines the domain of a field. In this example the domain is unbounded. evaluate returns a tensor. In this case parent_type::tensor_type is tatooine::vec2. The methods do not need to be marked virtual or override. The CRTP mechanism just needs those two methods with the correct signature.

#include <tatooine/field.h>
//==============================================================================
using namespace tatooine;
//==============================================================================
struct my_vectorfield : vectorfield<my_vectorfield, tatooine::real_type, 2> {
using this_type = my_vectorfield;
using parent_type::real_type;
using parent_type::pos_type;
using parent_type::tensor_type;
auto constexpr in_domain(pos_type const& x, real_type const t) const -> bool {
return true;
}
auto constexpr evaluate(pos_type const& x, real_type const t) const -> tensor_type {
return x * t;
}
};
auto main() -> int {
auto v = my_vectorfield{};
// evaluates the field at position [1,2] and at time 0
auto sample = v({1, 2}, 0);
}
Definition: algorithm.h:6
Definition: field.h:134

Typedefs

There are some typedefs that should be used due to their shortness.

See also
tatooine::polymorphic::vectorfield
tatooine::polymorphic::matrixfield
tatooine::vectorfield
tatooine::matrixfield

Differentiation

Fields can be derived using the tatooine::diff operator. This function creates a tatooine::differentiated_field that computes the derivative by using central differences.

using tatooine::diff(<scalarfield>) you will get the gradient of field.

using tatooine::diff(<vectorfield>) you will get the jacobian of field.

using tatooine::diff(<matrixfield>) you will get a field that evaluates to a rank-3 tensor that describes the derivative of this rank-2 tensor field.

In some specific cases one can specialize tatooine::differentiated_field. Checkout center.h for example.

Flowmaps of Vector Fields

Flow Maps of vector fields can be created by using the tatooine::flowmap operator.

By default a numerical integration is used to perform this action.

tatooine::flowmap is a templated function that can use a specific ODE solver. By default tatooine::ode::vclibs::rungekutta43 is used.

Example using the Double Gyre Dataset

//==============================================================================
using namespace tatooine;
//==============================================================================
auto main() -> int {
auto phi = flowmap(v);
auto x0 = vec2{0.1, 0.1};
auto t0 = 0.0;
auto tau = 10.0;
// performs a numerical integration from t0 up to t0 + tau
auto x10 = phi(x0, t0, tau);
// starts integration starting from t = t0 + tau because this integral curve is cached until t0 + tau
auto x20 = phi(x0, t0, tau * 2);
// uses an interpolated position of the cached line
auto x5 = phi(x0, t0, tau / 2);
// Check if phi is actually cacheable. This might not be the case for some
// predefined linear fields.
if constexpr (is_cacheable<decltype(phi)>()) {
phi.use_caching(false);
}
// uses phi's ode solver starting from t0 up to tau/2
auto x5_uncached = phi(x0, t0, tau / 2); }
Double Gyre dataset.
Definition: doublegyre.h:12
Definition: vec.h:12

Examples of fields:

See also
Sampling Properties of Rectilinear Grids
Unstructured Grids