Numeric containers

Containers that hold a list of numerical values may be constant or variable. It has an incidence on the behaviour of the tensor system using them. Constant propagation may occur in the former case. It is discouraged to use constant containers to store a huge or infinitesimal value (used in finite differences, or penalization methods), even if it is constant, for the risk of rounding surprises: it’s better using a variable one, forcing the system to respect its unknown-value nature.

When variable, a range may constrain the container and the tensor system may take it into account to ensure the validity of some formulations.

Composition of containers are used to form more complex data structures, as is the case with CSR sparse matrices for instance.

Constant containers: NumericList

auto listA = NaturalList{1};      // a constant single value container containing (1)
auto listB = DecimalList{10.1,10.2,10.6};  // a constant 3-values container containing (10.1,1à.2,10.6)

Variable containers: NumericData

auto dataA1 = NaturalData1{"A"};       // a single value container initialized to 0
auto dataB1 = NaturalData1{"B",50};    // a single value container initialized to 50
auto dataC1 = NaturalData1{"C",{1,9}}; // a single value container of values in [1,9] initialized to 1

dataC1.set_value(10); // run-time error
dataC1.set_value(0);  // run-time error
dataC1.set_value(5);  // correct

auto dataAn = NaturalDataN("A",5);        // a 5-values container initialized to 0;
auto dataBn = NaturalDataN{"B",{4,5,6}};  // a 3-values container initialized to (4,5,6);
auto dataCn = DecimalDataN{"C",5,{1,9}};  // a 5-values container of values in [1,9] initialized to 1;

Variable containers: NumericStorage

The NumericStorage is less constrained than NumericDataN. - no range may be applied on the values; - they are given a size range; - they are not allocated at their creation. - the may be allocated and deallocated at the user request.

auto stoA = NaturalStorage{"A",10};      // a storage with a size of 10
auto stoB = NaturalStorage{"B",10,20};   // a storage with a size in [10,20]
auto stoC = DecimalStorage{"C",{1.,4.,5.,9.}}; // a storage with size 4 allocated and initialized with the given values

stoA.allocate();      // stoA is allocated and holds 10 uninitialized values
stoB.allocate(5);     // run-time error
stoB.allocate(16);    // stoB is allocated and holds 10 uninitialized values
stoB.allocate(10,0);  // stoB has now 10 values set to 0 (internally, it may have kept a 16-values storage)
stoC.deallocate();    // stoC is now deallocated; but the name remains.

Range constraints

To provide robustness to the formulation engine, assuming a range for some given pack of values may prove useful.

The dummy range

It is not really a container, but the name of a dummy variable within a possible range. When mixing dummy indices, wether they stand for the same one or not does not lead to the same results; thus a name is given to distinguish them.

auto rangeI1 = NaturalRange{"I",{0,9};   // a range of indices in [0,9], named "I"
auto rangeI2 = NaturalRange("I",10);     // the same range: 10 values starting at 0 and named "I"
assert(rangeI1==rangeI2);

Sparse matrices

Sparse matrices are defined as compact-sparse rows matrices (CSR). THey store their values with three NumericStorage’s: - a NaturalStorage for the starting index of each row. - a NumericStorage<size_t> for the columns - a DecimalStorage for the values.

The two integer storage are combined in a SparseMatrixStructure object. With the coefficients storage, one gets the SparseMatrixStorage. They are generally used in a indirect way: they are given to the matrix assembler. Once built, the storages may be passed to sparse linear solvers.

Note that a FullMatrixStorage is provided by Navpactos to be used in the same contexts as SparseMatrixStorage.