COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
ArrayBufferT< T > Class Template Reference

A Buffer that is constructed passing a boost::multi_array<T,2> table. This class allows to interface this table by using a buffer. More...

#include <ArrayBufferT.hpp>

Classes

struct  Buffer
 

Public Types

typedef boost::multi_array< T, 2 > Array_t
 
typedef T value_type
 
typedef boost::detail::multi_array::sub_array< T, 1 > SubArray_t
 
typedef boost::detail::multi_array::const_sub_array< T, 1 > ConstSubArray_t
 

Public Member Functions

 ArrayBufferT (Array_t &array, size_t nbRows)
 
virtual ~ArrayBufferT ()
 Virtual destructor. More...
 
void change_buffersize (const size_t nbRows)
 Change the buffer to the new size. More...
 
void flush ()
 
template<typename vectorType >
Uint add_row (const vectorType &row)
 
Uint add_empty_row ()
 
template<typename vectorType >
Uint add_row_directly (const vectorType &row)
 
template<typename vectorType >
void set_row (const Uint array_idx, const vectorType &row)
 
SubArray_t get_row (const Uint idx)
 
void rm_row (const Uint array_idx)
 
Array_tget_appointed ()
 
Uint total_allocated ()
 
Uint buffers_count () const
 
void increase_array_size (const size_t increase)
 increase the size of the array, only to be used when going to write directly in array More...
 

Static Public Member Functions

static std::string type_name ()
 Get the class name. More...
 

Private Member Functions

void add_buffer ()
 Create a new buffer, allocate it with m_buffersize, and fill m_new_buffer_rows with the new ones. More...
 
bool is_array_row_empty (const Uint row) const
 
void reset ()
 
std::string string ()
 

Private Attributes

Array_tm_array
 reference to the array that is buffered More...
 
Uint m_nb_cols
 the number of columns of the array More...
 
Uint m_buffersize
 
std::vector< Bufferm_buffers
 vector of temporary buffers More...
 
std::deque< Uintm_empty_array_rows
 storage of removed array rows More...
 
std::deque< Uintm_new_array_rows
 storage of array rows where rows can be added directly using add_row_directly More...
 
std::deque< Uintm_empty_buffer_rows
 storage of removed buffer rows More...
 
std::deque< Uintm_new_buffer_rows
 storage of buffer rows where rows can be added More...
 

Detailed Description

template<typename T>
class cf3::common::ArrayBufferT< T >

A Buffer that is constructed passing a boost::multi_array<T,2> table. This class allows to interface this table by using a buffer.

The idea is to add and remove rows from the table through this buffer. The table is resized when the buffer is full, and values are copied from the buffer into the table.

First entry that is removed from the array using rm_row(), will also be the first to be filled when non-empty buffers are flushed. So in order of removal.

Note
Before using the matching array in algorithms, one has to be sure that the buffer is flushed. This is done automatically at buffer destruction, or manually by calling flush().
Author
Willem Deconinck

Definition at line 44 of file ArrayBufferT.hpp.

Member Typedef Documentation

typedef boost::multi_array<T,2> Array_t

Definition at line 49 of file ArrayBufferT.hpp.

typedef boost::detail::multi_array::const_sub_array<T,1> ConstSubArray_t

Definition at line 53 of file ArrayBufferT.hpp.

typedef boost::detail::multi_array::sub_array<T,1> SubArray_t

Definition at line 52 of file ArrayBufferT.hpp.

typedef T value_type

Definition at line 50 of file ArrayBufferT.hpp.

Constructor & Destructor Documentation

ArrayBufferT ( Array_t array,
size_t  nbRows 
)

Contructor

Parameters
arrayThe table that will be interfaced with
nbRowsThe size the buffer will be allocated with

Definition at line 208 of file ArrayBufferT.hpp.

~ArrayBufferT ( )
virtual

Virtual destructor.

Definition at line 218 of file ArrayBufferT.hpp.

Member Function Documentation

void add_buffer ( )
inlineprivate

Create a new buffer, allocate it with m_buffersize, and fill m_new_buffer_rows with the new ones.

Definition at line 373 of file ArrayBufferT.hpp.

Uint add_empty_row ( )
inline

Definition at line 399 of file ArrayBufferT.hpp.

Uint add_row ( const vectorType &  row)
inline

Add a row to the buffer. rows are only added to the buffer, even if there are empty rows in the array! Only when flush() is called, will the empty rows be filled.

Parameters
[in]rowRow to be added to buffer
Returns
the index in the array+buffers. If array has size 4, and buffer size 3, the last idx will be 6;

Definition at line 386 of file ArrayBufferT.hpp.

Uint add_row_directly ( const vectorType &  row)
inline

Add a row directly to the array

Parameters
[in]rowRow to be added to buffer or array
Returns
the index in the array+buffers

Definition at line 414 of file ArrayBufferT.hpp.

Uint buffers_count ( ) const
inline
Returns
the number of buffers that are created

Definition at line 143 of file ArrayBufferT.hpp.

void change_buffersize ( const size_t  nbRows)
inline

Change the buffer to the new size.

Definition at line 486 of file ArrayBufferT.hpp.

void flush ( )

Flush the buffer in the connectivity Buffer 2 cases:

  • Array has to expand
    • resize array
    • copy all non-empty buffer entries in sequence to array entries marked to be removed (first one removed, is first one refilled)
    • copy all non-empty buffer entries in sequence to array entries in the expanded part
  • Array has to shrink
    • copy all non-empty buffer entries in sequence to array entries marked to be removed (lower indices first)
    • swap entries in the array starting from the index old_array_size to remaining empty array entries in the new array
    • resize array

Definition at line 238 of file ArrayBufferT.hpp.

Array_t& get_appointed ( )
inline
Returns
the array that the buffer operates on

Definition at line 137 of file ArrayBufferT.hpp.

ArrayBufferT< T >::SubArray_t get_row ( const Uint  idx)
inline
Returns
the row with index idx, searching both in array and buffers

Definition at line 336 of file ArrayBufferT.hpp.

void increase_array_size ( const size_t  increase)
inline

increase the size of the array, only to be used when going to write directly in array

Definition at line 359 of file ArrayBufferT.hpp.

bool is_array_row_empty ( const Uint  row) const
inlineprivate

Definition at line 153 of file ArrayBufferT.hpp.

void reset ( )
inlineprivate

Definition at line 158 of file ArrayBufferT.hpp.

void rm_row ( const Uint  array_idx)
inline

Mark row as empty in array or buffer

Parameters
[in]array_idxthe index of the row to be removed

Definition at line 458 of file ArrayBufferT.hpp.

void set_row ( const Uint  array_idx,
const vectorType &  row 
)
inline

copy a given row into the array or buffer, depending on the given index

Parameters
[in]array_idxthe index of the row that will be set (both in array and buffers)
[in]rowthe row that will be copied into the buffer or array

Definition at line 427 of file ArrayBufferT.hpp.

std::string string ( )
inlineprivate

Definition at line 494 of file ArrayBufferT.hpp.

Uint total_allocated ( )
inline
Returns
total number of allocated rows, including all buffers and the array

Definition at line 227 of file ArrayBufferT.hpp.

static std::string type_name ( )
inlinestatic

Get the class name.

Definition at line 87 of file ArrayBufferT.hpp.

Member Data Documentation

Array_t& m_array
private

reference to the array that is buffered

Definition at line 179 of file ArrayBufferT.hpp.

std::vector<Buffer> m_buffers
private

vector of temporary buffers

Definition at line 189 of file ArrayBufferT.hpp.

Uint m_buffersize
private

The size newly created buffers will have

Note
it is safe to change in the middle of buffer operations

Definition at line 186 of file ArrayBufferT.hpp.

std::deque<Uint> m_empty_array_rows
private

storage of removed array rows

Definition at line 192 of file ArrayBufferT.hpp.

std::deque<Uint> m_empty_buffer_rows
private

storage of removed buffer rows

Definition at line 198 of file ArrayBufferT.hpp.

Uint m_nb_cols
private

the number of columns of the array

Definition at line 182 of file ArrayBufferT.hpp.

std::deque<Uint> m_new_array_rows
private

storage of array rows where rows can be added directly using add_row_directly

Definition at line 195 of file ArrayBufferT.hpp.

std::deque<Uint> m_new_buffer_rows
private

storage of buffer rows where rows can be added

Definition at line 201 of file ArrayBufferT.hpp.


The documentation for this class was generated from the following file:
Send comments to:
COOLFluiD Web Admin