Skip to content
Ondrej Meca edited this page Apr 22, 2021 · 4 revisions

Basis utilities

The directory with basis utilities contains classes that are widely used through the library. Each programmer should be familiar with them in order to avoid re-implement the provided functionality.

Containers

Containers provide the following lightweight data holders:

  • Point
  • tarray - threaded array
  • edata - element data
  • serializededata - serialized element data

Class Point is an encapsulation of x, y, z coordinates representing 3D point. The class provides standard vector operations and it can be also templated to arbitrary datatype.

Classes tarray, edata, and serializededata are data holders used instead of std::vector. The tarray class holds a vector of data with the fixed size. The main aim of this class is to avoid NUMA effect when data are used inside OpenMP parallel for. The NUMA effect is suppressed by forcing the first touch to a part of data that is assigned to a particular thread. Hence, besides the size, one has to provide a distribution of data among threads when tarray is constructed. This distribution is stored together with data, in order to allow processing a particular part of the array by the same thread.

The serializededata class is a holder for elements data. The class is suitable for data arranged as arrays withing structure. The class is composed from two tarray classes in order to allow describe data with various length for each element. The first tarray is used for data, the second tarray is used for description of boundaries - start and end offset of each element. Since tarray are used, we can fix thread distribution for both boundaries and data (hence, avoid NUMA effects).

The edata class serves for iterating the serializededata class. It is composed from two pointers - start and end positions of a given element. The serializededata class provides an iterator that is build upon edata class.

The picture below shows how these three classes are interconnected. Both data and boundaries are instances of tarray. Hence, they are divided into threads (denoted by different gray colors in the figure). The boundaries array holds information about element's data boundaries (e.g., the second element's data start at position 2 and end at position 4; and the element's data are $x_2, x_3$). Since tarray holds data distribution among threads, it is possible to always process the same memory by the same thread.

Let enodes holds elements' nodes in the serializededata class. Then nodes of each element can be listed in the following way:

void getParallel()
{
    #pragma omp parallel for
	for (int t = 0; t < info::env::threads; ++t) {
        // get current element (edata class)
		for (auto nodes = enodes.begin(t); nodes != enodes.end(t); ++nodes) {
            // iterate edata values
			for (auto n = nodes->begin(); n != nodes->end(); ++n) {
				// fnc(*n);
			}
		}
	}
}

void getSequential()
{
    for (auto nodes = enodes.begin(); nodes != enodes.end(); ++nodes) {
        for (auto n = nodes->begin(); n != nodes->end(); ++n) {
            // fnc(*n);
        }
    }
}

Evaluator

Evaluator is the main class used for evaluation parameters from ecf files. Currently, each parameter can be set to an arbitrary expression that can be parsed by the ExprTk library or a table. In addition, each expression can contain parameters COORDINATE_X, COORDINATE_Y, COORDINATE_Z, TEMPERATURE, TIME, FREQUENCY. A particular set of allowed parameters are described in ecf configuration.

I/O files

Input of the library can be loaded by MPI I/O or by the POSIX interface. Output is always stored by MPI I/O. The I/O interface supports loading/storing more file at the same time by InputFilePack and OutputFilePack. Since the interface use only subset of MPI processes for I/O operations, then, data are re-arranged to required positions, it is strongly recommended to load/store all files at the same time in order to avoid re-arrangement of small data more times (see input or output documentation for more details).

Logging

Base classes for logging progress and duration of particular library's functions. Loggers are used by eslog namespace.

Space filling curve, K-D-tree, Interval-tree

The basis directory also contains an implementation of basic structures for searching geometrically close nodes or elements. These structures are utilized during loading an input mesh or searching contact interface.

Utilities

The utils namespace provides the following general purpose functions:

  • packing - utilities for serialization and de-serialization of general structures
  • parser - parsing of string parameters and string compare functions
  • print - functions for insert the library structures into streams
  • sysutils - system utility functions (create directories, links, etc.)
  • xml - storing and extract data into/from XML file
  • utils - functions for manipulations with threaded data
Clone this wiki locally