Tensors

The tensor objects provide a method for easily managing scalar, vector, and tensor mathematical operations. The classes maintain a representation of the tensor type and provide common mathematical operations, both single tensors operations and binary operations between various types of tensors.

The classes are structured to either maintain their own memory or to use externally managed memory. The latter mode is useful in finite element calculations where the calling program can present a large collection of material points in a blocked array. If this type of memory management can be used it reduces copying when NEML models are called from external program and allows optimizing compilers to attempt vectorization.

The objects are set up to be transparent as to the type of memory model used to store the data. Generally, initializing an object with a raw pointer sets the objects to external memory management. This means that when the object is deleted the memory is not deallocated. Initializing an object with either a default (no parameter) constructor or a STL container sets the classes to manage their own memory and hence the memory will be freed when the object is deleted.

All the tensor classes derive from a common base class (see below). NEML implements the following tensor types:

Binary operators

The module provides a large variety of binary operators. All scalar multiplication and division operations are covered as are all rational addition/subtraction operations between tensors. Implemented tensor products include the outer products between vectors (C_{ij} = a_i b_j) and rank two tensors (C_{ijkl} = A_{ij} B_{kl}), matrix-vector products (c_j = A_{ij} b_j), matrix-matrix products (C_{ij} = A_{ik} B_{kj}), rank four/rank two composition (C_{ij} = A_{ijkl} B_{kl}), rank four/rank four composition (C_{ijkl} = A_{ijmn} B_{mnkl}), and a few specialized operators that occur in the crystal plasticity integration formula.

These binary operators are implemented for all sensible combinations of specialized tensor types (for example, all RankTwo binary operations can be completed with any combination of RankTwo, Symmetric, and Skew tensors).

Base class description

class Tensor

Subclassed by neml::RankFour, neml::RankTwo, neml::Skew, neml::SkewSymR4, neml::Symmetric, neml::SymSkewR4, neml::SymSymR4, neml::SymSymSymR6, neml::Vector

Public Functions

Tensor(std::size_t n)
Tensor(const Tensor &other)
Tensor(Tensor &&other)
Tensor(const std::vector<double> flat)
Tensor(double *flat, size_t n)
Tensor(const double *flat, size_t n)
virtual ~Tensor()
inline bool istore() const

Do I own my own data?

Tensor &operator=(const Tensor &rhs)
Tensor &operator=(Tensor &&rhs)
inline const double *data() const
inline double *s()
inline std::size_t n() const
void copy_data(const double *const indata)
Tensor &operator*=(double s)
Tensor &operator/=(double s)