Opm::SparseTable< T, Storage > Class Template Reference

#include <SparseTable.hpp>

Inheritance diagram for Opm::SparseTable< T, Storage >:
Inheritance graph

Classes

class  Iterator
 
struct  row_type_helper
 
struct  row_type_helper< U, std::void_t< typename U::const_iterator > >
 

Public Types

using row_type = typename row_type_helper< Storage< T > >::const_type
 
using mutable_row_type = typename row_type_helper< Storage< T > >::mutable_type
 

Public Member Functions

 SparseTable ()
 Default constructor. Yields an empty SparseTable. More...
 
template<typename DataIter , typename IntegerIter >
 SparseTable (DataIter data_beg, DataIter data_end, IntegerIter rowsize_beg, IntegerIter rowsize_end)
 
 SparseTable (Storage< T > &&data, Storage< int > &&row_starts)
 
template<typename DataIter , typename IntegerIter >
void assign (DataIter data_beg, DataIter data_end, IntegerIter rowsize_beg, IntegerIter rowsize_end)
 
template<typename IntegerIter >
void allocate (IntegerIter rowsize_beg, IntegerIter rowsize_end)
 
template<typename DataIter >
void appendRow (DataIter row_beg, DataIter row_end)
 Appends a row to the table. More...
 
OPM_HOST_DEVICE bool empty () const
 True if the table contains no rows. More...
 
OPM_HOST_DEVICE int size () const
 Returns the number of rows in the table. More...
 
void reserve (int exptd_nrows, int exptd_ndata)
 Allocate storage for table of expected size. More...
 
void swap (SparseTable< T > &other)
 Swap contents for other SparseTable<T> More...
 
OPM_HOST_DEVICE int dataSize () const
 Returns the number of data elements. More...
 
OPM_HOST_DEVICE int rowSize (int row) const
 Returns the size of a table row. More...
 
void clear ()
 Makes the table empty(). More...
 
OPM_HOST_DEVICE row_type operator[] (int row) const
 Returns a row of the table. More...
 
OPM_HOST_DEVICE mutable_row_type operator[] (int row)
 Returns a mutable row of the table. More...
 
OPM_HOST_DEVICE Iterator begin () const
 Iterator access. More...
 
OPM_HOST_DEVICE Iterator end () const
 
OPM_HOST_DEVICE bool operator== (const SparseTable &other) const
 Equality. More...
 
template<class charT , class traits >
void print (std::basic_ostream< charT, traits > &os) const
 
const T data (int i) const
 
const T * dataPtr () const
 
const Storage< T > & dataStorage () const
 
const Storage< int > & rowStarts () const
 

Detailed Description

template<typename T, template< typename, typename... > class Storage = std::vector>
class Opm::SparseTable< T, Storage >

A SparseTable stores a table with rows of varying size as efficiently as possible. It is supposed to behave similarly to a vector of vectors. Its behaviour is similar to compressed row sparse matrices.

Member Typedef Documentation

◆ mutable_row_type

template<typename T , template< typename, typename... > class Storage = std::vector>
using Opm::SparseTable< T, Storage >::mutable_row_type = typename row_type_helper<Storage<T> >::mutable_type

◆ row_type

template<typename T , template< typename, typename... > class Storage = std::vector>
using Opm::SparseTable< T, Storage >::row_type = typename row_type_helper<Storage<T> >::const_type

Constructor & Destructor Documentation

◆ SparseTable() [1/3]

template<typename T , template< typename, typename... > class Storage = std::vector>
Opm::SparseTable< T, Storage >::SparseTable ( )
inline

Default constructor. Yields an empty SparseTable.

◆ SparseTable() [2/3]

template<typename T , template< typename, typename... > class Storage = std::vector>
template<typename DataIter , typename IntegerIter >
Opm::SparseTable< T, Storage >::SparseTable ( DataIter  data_beg,
DataIter  data_end,
IntegerIter  rowsize_beg,
IntegerIter  rowsize_end 
)
inline

A constructor taking all the data for the table and row sizes.

Parameters
data_begThe start of the table data.
data_endOne-beyond-end of the table data.
rowsize_begThe start of the row length data.
rowsize_endOne beyond the end of the row length data.

◆ SparseTable() [3/3]

template<typename T , template< typename, typename... > class Storage = std::vector>
Opm::SparseTable< T, Storage >::SparseTable ( Storage< T > &&  data,
Storage< int > &&  row_starts 
)
inline

Member Function Documentation

◆ allocate()

template<typename T , template< typename, typename... > class Storage = std::vector>
template<typename IntegerIter >
void Opm::SparseTable< T, Storage >::allocate ( IntegerIter  rowsize_beg,
IntegerIter  rowsize_end 
)
inline

Request storage for table of given size.

Parameters
rowsize_begStart of row size data.
rowsize_endOne beyond end of row size data.

◆ appendRow()

template<typename T , template< typename, typename... > class Storage = std::vector>
template<typename DataIter >
void Opm::SparseTable< T, Storage >::appendRow ( DataIter  row_beg,
DataIter  row_end 
)
inline

Appends a row to the table.

Referenced by Dune::cpgrid::Geometry< 3, cdim >::refineCellifiedPatch().

◆ assign()

template<typename T , template< typename, typename... > class Storage = std::vector>
template<typename DataIter , typename IntegerIter >
void Opm::SparseTable< T, Storage >::assign ( DataIter  data_beg,
DataIter  data_end,
IntegerIter  rowsize_beg,
IntegerIter  rowsize_end 
)
inline

Sets the table to contain the given data, organized into rows as indicated by the given row sizes.

Parameters
data_begThe start of the table data.
data_endOne-beyond-end of the table data.
rowsize_begThe start of the row length data.
rowsize_endOne beyond the end of the row length data.

◆ begin()

template<typename T , template< typename, typename... > class Storage = std::vector>
OPM_HOST_DEVICE Iterator Opm::SparseTable< T, Storage >::begin ( ) const
inline

Iterator access.

◆ clear()

template<typename T , template< typename, typename... > class Storage = std::vector>
void Opm::SparseTable< T, Storage >::clear ( )
inline

Makes the table empty().

◆ data()

template<typename T , template< typename, typename... > class Storage = std::vector>
const T Opm::SparseTable< T, Storage >::data ( int  i) const
inline

◆ dataPtr()

template<typename T , template< typename, typename... > class Storage = std::vector>
const T * Opm::SparseTable< T, Storage >::dataPtr ( ) const
inline

◆ dataSize()

template<typename T , template< typename, typename... > class Storage = std::vector>
OPM_HOST_DEVICE int Opm::SparseTable< T, Storage >::dataSize ( ) const
inline

Returns the number of data elements.

◆ dataStorage()

template<typename T , template< typename, typename... > class Storage = std::vector>
const Storage< T > & Opm::SparseTable< T, Storage >::dataStorage ( ) const
inline

◆ empty()

template<typename T , template< typename, typename... > class Storage = std::vector>
OPM_HOST_DEVICE bool Opm::SparseTable< T, Storage >::empty ( ) const
inline

True if the table contains no rows.

◆ end()

template<typename T , template< typename, typename... > class Storage = std::vector>
OPM_HOST_DEVICE Iterator Opm::SparseTable< T, Storage >::end ( ) const
inline

◆ operator==()

template<typename T , template< typename, typename... > class Storage = std::vector>
OPM_HOST_DEVICE bool Opm::SparseTable< T, Storage >::operator== ( const SparseTable< T, Storage > &  other) const
inline

◆ operator[]() [1/2]

template<typename T , template< typename, typename... > class Storage = std::vector>
OPM_HOST_DEVICE mutable_row_type Opm::SparseTable< T, Storage >::operator[] ( int  row)
inline

Returns a mutable row of the table.

References Opm::SparseTable< T, Storage >::size().

◆ operator[]() [2/2]

template<typename T , template< typename, typename... > class Storage = std::vector>
OPM_HOST_DEVICE row_type Opm::SparseTable< T, Storage >::operator[] ( int  row) const
inline

◆ print()

template<typename T , template< typename, typename... > class Storage = std::vector>
template<class charT , class traits >
void Opm::SparseTable< T, Storage >::print ( std::basic_ostream< charT, traits > &  os) const
inline

◆ reserve()

template<typename T , template< typename, typename... > class Storage = std::vector>
void Opm::SparseTable< T, Storage >::reserve ( int  exptd_nrows,
int  exptd_ndata 
)
inline

Allocate storage for table of expected size.

◆ rowSize()

template<typename T , template< typename, typename... > class Storage = std::vector>
OPM_HOST_DEVICE int Opm::SparseTable< T, Storage >::rowSize ( int  row) const
inline

◆ rowStarts()

template<typename T , template< typename, typename... > class Storage = std::vector>
const Storage< int > & Opm::SparseTable< T, Storage >::rowStarts ( ) const
inline

◆ size()

template<typename T , template< typename, typename... > class Storage = std::vector>
OPM_HOST_DEVICE int Opm::SparseTable< T, Storage >::size ( ) const
inline

◆ swap()

template<typename T , template< typename, typename... > class Storage = std::vector>
void Opm::SparseTable< T, Storage >::swap ( SparseTable< T > &  other)
inline

Swap contents for other SparseTable<T>

Referenced by Dune::cpgrid::OrientedEntityTable< codim_from, codim_to >::swap().


The documentation for this class was generated from the following file: