Template Numerical Library version\ main:88903d64
Loading...
Searching...
No Matches
Namespaces | Classes | Enumerations | Functions
TNL::Containers Namespace Reference

Namespace for TNL containers. More...

Namespaces

namespace  NDArraySyncPatterns
 Namespace where synchronization patterns for distributed N-dimensional arrays are defined.
 

Classes

class  Array
 Array is responsible for memory management, access to array elements, and general array operations. More...
 
class  ArrayView
 ArrayView is a simple data structure which provides a non-owning encapsulation of array data. That is, ArrayView is like Array without memory management. More...
 
struct  Block
 Minimal class representing a block of an equidistant D-dimensional lattice. More...
 
class  ByteArraySynchronizer
 
class  ConstStaticSizesHolder
 
class  DistributedArray
 Distributed array. More...
 
class  DistributedArraySynchronizer
 
class  DistributedArrayView
 Distributed array view. More...
 
class  DistributedNDArray
 Distributed N-dimensional array. More...
 
class  DistributedNDArraySynchronizer
 Synchronizer for DistributedNDArray. More...
 
class  DistributedNDArrayView
 Distributed N-dimensional array view. More...
 
class  DistributedVector
 DistributedVector extends DistributedArray with algebraic operations. More...
 
class  DistributedVectorView
 DistributedVectorView extends DistributedArrayView with algebraic operations. More...
 
class  GinkgoVector
 Wrapper for representing vectors using Ginkgo data structure. More...
 
class  HypreParVector
 Wrapper for Hypre's parallel vector. More...
 
class  HypreVector
 Wrapper for Hypre's sequential vector. More...
 
class  IndexedMap
 
class  IndexedSet
 
struct  LocalBeginsHolder
 
class  NDArray
 Dynamic N-dimensional array. More...
 
class  NDArrayIndexer
 Indexer for N-dimensional arrays. It does not store any data, only the sizes of each dimension. More...
 
class  NDArrayStorage
 Base storage class for NDArray, StaticNDArray and SlicedNDArray. More...
 
class  NDArrayView
 Simple data structure which provides a non-owning encapsulation of N-dimensional array data. More...
 
class  SizesHolder
 Holds static and dynamic sizes of an N-dimensional array. More...
 
class  SlicedNDArray
 Dynamic N-dimensional array with configurable slicing/tiling. More...
 
struct  SliceInfo
 Describes slicing configuration for SlicedNDArray. More...
 
class  StaticArray
 Array with constant size. More...
 
class  StaticNDArray
 Static N-dimensional array. More...
 
class  StaticSizesHolder
 Holds static sizes of an N-dimensional array. More...
 
class  StaticVector
 Vector with constant size. More...
 
class  Subrange
 
class  UnorderedIndexedSet
 
class  Vector
 Vector extends Array with algebraic operations. More...
 
class  VectorView
 VectorView extends ArrayView with algebraic operations. More...
 

Enumerations

enum class  SyncDirection : std::uint8_t {
  SyncDirection::All = 0xff , SyncDirection::None = 0 , SyncDirection::Right = 1 << 0 , SyncDirection::Left = 1 << 1 ,
  SyncDirection::Top = 1 << 2 , SyncDirection::Bottom = 1 << 3 , SyncDirection::Front = 1 << 4 , SyncDirection::Back = 1 << 5 ,
  SyncDirection::TopRight = Top | Right , SyncDirection::TopLeft = Top | Left , SyncDirection::BottomRight = Bottom | Right , SyncDirection::BottomLeft = Bottom | Left ,
  SyncDirection::BackRight = Back | Right , SyncDirection::BackLeft = Back | Left , SyncDirection::FrontRight = Front | Right , SyncDirection::FrontLeft = Front | Left ,
  SyncDirection::BackTop = Back | Top , SyncDirection::BackBottom = Back | Bottom , SyncDirection::FrontTop = Front | Top , SyncDirection::FrontBottom = Front | Bottom ,
  SyncDirection::BackTopRight = Back | Top | Right , SyncDirection::BackTopLeft = Back | Top | Left , SyncDirection::BackBottomRight = Back | Bottom | Right , SyncDirection::BackBottomLeft = Back | Bottom | Left ,
  SyncDirection::FrontTopRight = Front | Top | Right , SyncDirection::FrontTopLeft = Front | Top | Left , SyncDirection::FrontBottomRight = Front | Bottom | Right , SyncDirection::FrontBottomLeft = Front | Bottom | Left
}
 Directions for data synchronization in a distributed N-dimensional array. More...
 

Functions

template<typename idx >
std::set< Block< 3, idx > > createInteriorSides (const std::vector< Block< 3, idx > > &decomposition)
 Creates all unique sides of blocks in a 3D decomposition.
 
template<typename idx , typename OutputIterator >
void createSides (const Block< 3, idx > &block, OutputIterator output)
 Creates the sides of a 3D block and adds them to the output vector.
 
template<typename idx >
std::set< Block< 3, idx > > createSides (const std::vector< Block< 3, idx > > &decomposition)
 Creates all unique sides of blocks in a 3D decomposition.
 
template<typename Index >
std::vector< Block< 3, Index > > decomposeBlock (const Block< 3, Index > &global, Index num_x, Index num_y=1, Index num_z=1)
 Decompose a "global" block into several (sub-)blocks in a 3D manner with given block counts along each axis.
 
template<typename Index >
std::vector< Block< 3, Index > > decomposeBlockOptimal (const Block< 3, Index > &global, Index num_blocks, const std::function< Index(const std::vector< Block< 3, Index > > &) > &f=[](const std::vector< Block< 3, Index > > &decomposition) -> Index { return getInterfaceArea(decomposition);})
 Decompose a "global" block into several (sub-)blocks in an optimal 3D manner.
 
template<std::size_t I, int N, class T >
constexpr const T && get (const StaticArray< N, T > &&a) noexcept
 
template<std::size_t I, int N, class T >
constexpr const T & get (const StaticArray< N, T > &a) noexcept
 
template<std::size_t I, int N, class T >
constexpr const T && get (const StaticVector< N, T > &&a) noexcept
 
template<std::size_t I, int N, class T >
constexpr const T & get (const StaticVector< N, T > &a) noexcept
 
template<std::size_t I, int N, class T >
constexpr T && get (StaticArray< N, T > &&a) noexcept
 
template<std::size_t I, int N, class T >
constexpr T & get (StaticArray< N, T > &a) noexcept
 
template<std::size_t I, int N, class T >
constexpr T && get (StaticVector< N, T > &&a) noexcept
 
template<std::size_t I, int N, class T >
constexpr T & get (StaticVector< N, T > &a) noexcept
 
template<typename idx >
idx getArea (const Block< 3, idx > &block, const StaticVector< 3, idx > &axes_weights={ 1, 1, 1 })
 Calculates the area of a 2D block in 3D space.
 
template<int D, typename Index >
Block< D, Index >::CoordinatesType getBlockVertex (const Block< D, Index > &block, SyncDirection direction)
 Selects a vertex of a block based on a direction from its center.
 
template<typename idx >
idx getInterfaceArea (const std::vector< Block< 3, idx > > &decomposition, const StaticVector< 3, idx > &axes_weights={ 1, 1, 1 })
 Calculates the total area of interior sides in a 3D decomposition.
 
template<typename idx >
double getMaximumImbalance (const std::vector< Block< 3, idx > > &decomposition, idx global_volume=0)
 Calculates the maximum imbalance of blocks in a decomposition.
 
template<int D, typename idx >
idx getVolume (const Block< D, idx > &block)
 Calculates the volume of a D-dimensional block.
 
template<int D, typename idx >
idx getVolume (const std::vector< Block< D, idx > > &decomposition)
 Calculates the volume occupied by blocks in a decomposition.
 
template<typename Output , typename Input >
void nd_absolute (Output &output, const Input &input)
 
template<typename Output , typename Input1 , typename Input2 >
void nd_add (Output &output, const Input1 &input1, const Input2 &input2)
 
template<typename Output , typename Input >
void nd_assign (Output &output, const Input &input)
 
template<typename Output , typename Input1 , typename Input2 >
void nd_divide (Output &output, const Input1 &input1, const Input2 &input2)
 
template<typename Output , typename Func , typename... Input>
void nd_map (Output &output, Func f, const Input &... input)
 
template<typename Output , typename Input1 , typename Input2 >
void nd_maximum (Output &output, const Input1 &input1, const Input2 &input2)
 
template<typename Output , typename Input1 , typename Input2 >
void nd_minimum (Output &output, const Input1 &input1, const Input2 &input2)
 
template<typename Output , typename Input1 , typename Input2 >
void nd_multiply (Output &output, const Input1 &input1, const Input2 &input2)
 
template<typename Output , typename Input1 , typename Input2 >
void nd_pow (Output &output, const Input1 &input1, const Input2 &input2)
 
template<typename Output , typename Input >
void nd_sign (Output &output, const Input &input)
 
template<typename Output , typename Input >
void nd_sqrt (Output &output, const Input &input)
 
template<typename Output , typename Input >
void nd_square (Output &output, const Input &input)
 
template<typename Output , typename Input1 , typename Input2 >
void nd_subtract (Output &output, const Input1 &input1, const Input2 &input2)
 
template<int D, typename idx >
bool operator!= (const Block< D, idx > &left, const Block< D, idx > &right)
 Compares two blocks point-wise.
 
SyncDirection operator& (SyncDirection a, SyncDirection b)
 Bitwise AND operator for SyncDirection.
 
template<typename SizesHolder , std::size_t ConstValue, typename OtherHolder >
LocalBeginsHolder< SizesHolder, ConstValueoperator+ (const LocalBeginsHolder< SizesHolder, ConstValue > &lhs, const OtherHolder &rhs)
 
template<typename Index , std::size_t... sizes, typename OtherHolder >
SizesHolder< Index, sizes... > operator+ (const SizesHolder< Index, sizes... > &lhs, const OtherHolder &rhs)
 Combines the sizes of two instance of SizesHolder with the operator +.
 
template<typename SizesHolder , std::size_t ConstValue, typename OtherHolder >
LocalBeginsHolder< SizesHolder, ConstValueoperator- (const LocalBeginsHolder< SizesHolder, ConstValue > &lhs, const OtherHolder &rhs)
 
template<typename Index , std::size_t... sizes, typename OtherHolder >
SizesHolder< Index, sizes... > operator- (const SizesHolder< Index, sizes... > &lhs, const OtherHolder &rhs)
 Combines the sizes of two instance of SizesHolder with the operator -.
 
SyncDirectionoperator-= (SyncDirection &a, SyncDirection b)
 Bitwise operator which clears all bits from b in a.
 
template<int D, typename idx >
bool operator< (const Block< D, idx > &left, const Block< D, idx > &right)
 Lexicographically compares two blocks by joining their begin and end points.
 
template<typename Value , typename Device , typename Index >
Fileoperator<< (File &&file, ArrayView< Value, Device, Index > view)
 
template<typename Value , typename Device , typename Index , typename Allocator >
Fileoperator<< (File &&file, const Array< Value, Device, Index, Allocator > &array)
 
template<int Size, typename Value >
Fileoperator<< (File &&file, const StaticArray< Size, Value > &array)
 Serialization of static arrays into binary files.
 
template<typename Value , typename Device , typename Index >
Fileoperator<< (File &file, ArrayView< Value, Device, Index > view)
 Serialization of array views into binary files.
 
template<typename Value , typename Device , typename Index , typename Allocator >
Fileoperator<< (File &file, const Array< Value, Device, Index, Allocator > &array)
 Serialization of arrays into binary files.
 
template<int Size, typename Value >
Fileoperator<< (File &file, const StaticArray< Size, Value > &array)
 Serialization of static arrays into binary files.
 
template<typename Value , typename Device , typename Index , typename Allocator >
std::ostreamoperator<< (std::ostream &str, const Array< Value, Device, Index, Allocator > &array)
 Overloaded insertion operator for printing an array to output stream.
 
template<typename Value , typename Device , typename Index >
std::ostreamoperator<< (std::ostream &str, const ArrayView< Value, Device, Index > &view)
 Overloaded insertion operator for printing an array view to output stream.
 
template<int D, typename idx >
std::ostreamoperator<< (std::ostream &str, const Block< D, idx > &block)
 Writes a textual representation of the given multiindex into the given stream.
 
template<typename SizesHolder , std::size_t ConstValue>
std::ostreamoperator<< (std::ostream &str, const LocalBeginsHolder< SizesHolder, ConstValue > &holder)
 
template<typename Index , std::size_t... sizes>
std::ostreamoperator<< (std::ostream &str, const SizesHolder< Index, sizes... > &holder)
 Prints the sizes contained in an instance of SizesHolder to the given output stream.
 
template<int Size, typename Value >
std::ostreamoperator<< (std::ostream &str, const StaticArray< Size, Value > &a)
 
template<typename Index >
std::ostreamoperator<< (std::ostream &str, const Subrange< Index > &range)
 
template<typename Value , typename Index , typename Key >
std::ostreamoperator<< (std::ostream &str, IndexedMap< Value, Index, Key > &set)
 
template<typename Element , typename Index >
std::ostreamoperator<< (std::ostream &str, IndexedSet< Element, Index > &set)
 
template<class Key , class Index , class Compare , class Allocator >
std::ostreamoperator<< (std::ostream &str, IndexedSet< Key, Index, Compare, Allocator > &set)
 
template<typename Element , typename Index >
std::ostreamoperator<< (std::ostream &str, UnorderedIndexedSet< Element, Index > &set)
 
template<class Key , class Index , class Hash , class KeyEqual , class Allocator >
std::ostreamoperator<< (std::ostream &str, UnorderedIndexedSet< Key, Index, Hash, KeyEqual, Allocator > &set)
 
template<int D, typename idx >
bool operator== (const Block< D, idx > &left, const Block< D, idx > &right)
 Compares two blocks point-wise.
 
template<typename Value , typename Device , typename Index , typename Allocator >
Fileoperator>> (File &&file, Array< Value, Device, Index, Allocator > &array)
 
template<typename Value , typename Device , typename Index >
Fileoperator>> (File &&file, ArrayView< Value, Device, Index > view)
 
template<int Size, typename Value >
Fileoperator>> (File &&file, StaticArray< Size, Value > &array)
 Deserialization of static arrays from binary files.
 
template<typename Value , typename Device , typename Index , typename Allocator >
Fileoperator>> (File &file, Array< Value, Device, Index, Allocator > &array)
 Deserialization of arrays from binary files.
 
template<typename Value , typename Device , typename Index >
Fileoperator>> (File &file, ArrayView< Value, Device, Index > view)
 Deserialization of array views from binary files.
 
template<int Size, typename Value >
Fileoperator>> (File &file, StaticArray< Size, Value > &array)
 Deserialization of static arrays from binary files.
 
SyncDirection operator| (SyncDirection a, SyncDirection b)
 Bitwise OR operator for SyncDirection.
 
SyncDirection opposite (SyncDirection direction)
 Returns an opposite direction for given direction.
 
template<typename DistributedNDArray , std::size_t Q, typename BlockType >
void setNeighbors (DistributedNDArraySynchronizer< DistributedNDArray > &synchronizer, const std::array< SyncDirection, Q > &pattern, int rank, const std::vector< BlockType > &decomposition, const BlockType &global)
 Set neighbors for a synchronizer according to given synchronization pattern and decomposition of a global block.
 
template<typename Index >
Subrange< Index > splitRange (Index globalSize, const MPI::Comm &communicator)
 A helper function which splits a one-dimensional range.
 
template<typename Index >
Subrange< Index > splitRange (Index rangeBegin, Index rangeEnd, int rank, int num_subintervals)
 A helper function which splits a one-dimensional range.
 
template<typename Real >
__cuda_callable__ Real TriangleArea (const StaticVector< 2, Real > &a, const StaticVector< 2, Real > &b, const StaticVector< 2, Real > &c)
 
template<typename Real >
__cuda_callable__ Real TriangleArea (const StaticVector< 3, Real > &a, const StaticVector< 3, Real > &b, const StaticVector< 3, Real > &c)
 
template<typename Real >
__cuda_callable__ StaticVector< 3, RealVectorProduct (const StaticVector< 3, Real > &u, const StaticVector< 3, Real > &v)
 

Detailed Description

Namespace for TNL containers.

Function Documentation

◆ decomposeBlock()

template<typename Index >
std::vector< Block< 3, Index > > TNL::Containers::decomposeBlock ( const Block< 3, Index > & global,
Index num_x,
Index num_y = 1,
Index num_z = 1 )

Decompose a "global" block into several (sub-)blocks in a 3D manner with given block counts along each axis.

Parameters
globalThe large block to decompose.
num_xNumber of blocks along the x-axis.
num_yNumber of blocks along the y-axis.
num_zNumber of blocks along the z-axis.
Returns
A vector of the blocks into which the input was decomposed.

◆ decomposeBlockOptimal()

template<typename Index >
std::vector< Block< 3, Index > > TNL::Containers::decomposeBlockOptimal ( const Block< 3, Index > & global,
Index num_blocks,
const std::function< Index(const std::vector< Block< 3, Index > > &) > & f = []( const std::vectorBlock< 3, Index > >& decomposition ) -> Index { return getInterfaceAreadecomposition ); } )

Decompose a "global" block into several (sub-)blocks in an optimal 3D manner.

Parameters
globalThe large block to decompose.
num_blocksNumber of blocks.
fThe objective function that should be minimized.
Returns
A vector of the blocks into which the input was decomposed.

◆ getArea()

template<typename idx >
idx TNL::Containers::getArea ( const Block< 3, idx > & block,
const StaticVector< 3, idx > & axes_weights = { 1, 1, 1 } )

Calculates the area of a 2D block in 3D space.

Parameters
blockThe block whose area will be calculated.
axes_weightsOptional weights that modify the area based on the block orientation. axes_weights.x() multiplies the area of blocks normal to the x-axis, axes_weights.y() multiplies the area of blocks normal to the y-axis, and axes_weights.z() multiplies the area of blocks normal to the z-axis.

◆ getBlockVertex()

template<int D, typename Index >
Block< D, Index >::CoordinatesType TNL::Containers::getBlockVertex ( const Block< D, Index > & block,
SyncDirection direction )

Selects a vertex of a block based on a direction from its center.

Parameters
blockis the block.
directionis the direction from the center of the block to one of its vertices.
Returns
coordinates of the block vertex.
Exceptions
std::invalid_argumentwhen the direction does not point to a vertex. E.g., SyncDirection::BackBottomLeft is valid, but SyncDirection::TopRight or SyncDirection::Left are not.

◆ getInterfaceArea()

template<typename idx >
idx TNL::Containers::getInterfaceArea ( const std::vector< Block< 3, idx > > & decomposition,
const StaticVector< 3, idx > & axes_weights = { 1, 1, 1 } )

Calculates the total area of interior sides in a 3D decomposition.

Parameters
decompositionA vector of blocks that form a 3D decomposition of a large block.
axes_weightsOptional weights that modify interface areas based on the interior side orientation. axes_weights.x() multiplies the area of sides normal to the x-axis, axes_weights.y() multiplies the area of sides normal to the y-axis, and axes_weights.z() multiplies the area of sides normal to the z-axis.

◆ getMaximumImbalance()

template<typename idx >
double TNL::Containers::getMaximumImbalance ( const std::vector< Block< 3, idx > > & decomposition,
idx global_volume = 0 )

Calculates the maximum imbalance of blocks in a decomposition.

Imbalance is a non-negative quantity that measures how much the block's volume differs from the ideal, average volume. If all blocks have the ideal volume, then all blocks have zero imbalance.

Parameters
decompositionVector of blocks in the decomposition.
global_volumeOptional pre-computed volume of all blocks.

◆ operator<<() [1/4]

template<int Size, typename Value >
File & TNL::Containers::operator<< ( File && file,
const StaticArray< Size, Value > & array )

Serialization of static arrays into binary files.

Parameters
fileoutput file
arrayis an array to be written into the output file.

◆ operator<<() [2/4]

template<int Size, typename Value >
File & TNL::Containers::operator<< ( File & file,
const StaticArray< Size, Value > & array )

Serialization of static arrays into binary files.

Parameters
fileoutput file
arrayis an array to be written into the output file.

◆ operator<<() [3/4]

template<typename Value , typename Device , typename Index , typename Allocator >
std::ostream & TNL::Containers::operator<< ( std::ostream & str,
const Array< Value, Device, Index, Allocator > & array )

Overloaded insertion operator for printing an array to output stream.

Template Parameters
Valueis a type of the array elements.
Deviceis a device where the array is allocated.
Indexis a type used for the indexing of the array elements.
Parameters
stris a output stream.
arrayis the array to be printed.
Returns
a reference to the output stream std::ostream.

◆ operator<<() [4/4]

template<typename Value , typename Device , typename Index >
std::ostream & TNL::Containers::operator<< ( std::ostream & str,
const ArrayView< Value, Device, Index > & view )

Overloaded insertion operator for printing an array view to output stream.

Template Parameters
Valueis a type of the array view elements.
Deviceis a device where the array view is allocated.
Indexis a type used for the indexing of the array view elements.
Parameters
stris a output stream.
viewis the array view to be printed.
Returns
a reference to the output stream std::ostream.

◆ operator>>() [1/2]

template<int Size, typename Value >
File & TNL::Containers::operator>> ( File && file,
StaticArray< Size, Value > & array )

Deserialization of static arrays from binary files.

Parameters
fileinput file
arrayis an array to be read from the input file.

◆ operator>>() [2/2]

template<int Size, typename Value >
File & TNL::Containers::operator>> ( File & file,
StaticArray< Size, Value > & array )

Deserialization of static arrays from binary files.

Parameters
fileinput file
arrayis an array to be read from the input file.

◆ splitRange() [1/2]

template<typename Index >
Subrange< Index > TNL::Containers::splitRange ( Index globalSize,
const MPI::Comm & communicator )

A helper function which splits a one-dimensional range.

Parameters
globalSizeSize of the global range [0, globalSize) to be split.
communicatorMPI communicator consisting of ranks for which the range is split.
Returns
A subrange [begin, end) for the calling MPI rank.

◆ splitRange() [2/2]

template<typename Index >
Subrange< Index > TNL::Containers::splitRange ( Index rangeBegin,
Index rangeEnd,
int rank,
int num_subintervals )

A helper function which splits a one-dimensional range.

Parameters
rangeBeginBeginning of the interval [rangeBegin, rangeEnd).
rangeEndEnd of the interval [rangeBegin, rangeEnd).
rankIndex of the subinterval for which the output is calculated.
num_subintervalsTotal number of subintervals.
Returns
A subrange [begin, end) for the specified rank.