queso-0.57.0
Private Member Functions | Private Attributes | List of all members
QUESO::DistArray< T > Class Template Reference

A class for partitioning vectors and matrices. More...

#include <DistArray.h>

Collaboration diagram for QUESO::DistArray< T >:
Collaboration graph
[legend]

Public Member Functions

Constructor/Destructor methods
 DistArray (const Map &inputMap, const int inputRowSize)
 Constructor for a given inputMap and inputRowSize. More...
 
 ~DistArray ()
 Destructor. More...
 
Query methods
T & operator() (int localElementId, int colId)
 Returns a reference to the colId column component of the localElementId local element. More...
 
const T & operator() (int localElementId, int colId) const
 Returns a reference to the colId column component of the localElementId local element.(const) More...
 
int GlobalLength () const
 Returns the global length of the array. More...
 
int MyLength () const
 Returns the length of the locally owned array. More...
 
int RowSize () const
 Returns the row size, that is, the amount of data associated with each element. More...
 

Private Member Functions

 DistArray ()
 Default constructor. Do not call this directly. More...
 
 DistArray (const DistArray< T > &src)
 Copy constructor. Private. More...
 
DistArray< T > & operator= (const DistArray< T > &rhs)
 Assignment operator. More...
 

Private Attributes

Map m_Map
 
EpetraExt::DistArray< T > * m_epetraDistArray
 
unsigned int m_rowSize
 
std::vector< std::vector< T > > m_elements
 

I/O methods

void print (std::ostream &os) const
 
std::ostream & operator<< (std::ostream &os, const DistArray< T > &obj)
 

Detailed Description

template<typename T>
class QUESO::DistArray< T >

A class for partitioning vectors and matrices.

Class DistArray allows the construction and usage of multi-vectors. These vectors contain element of type T, and the storage is row-oriented (instead of and not column-oriented; thus his class should be used as a container for data, on which no BLAS-like operations are performed).

DistArray objects are identified by an Map and a RowSize. The map specifies the distribution of the elements across the processors and therefore the number of local elements, while the RowSize gives the total number of data assigned to each node. RowSize is constant for all elements.

Definition at line 56 of file DistArray.h.

Constructor & Destructor Documentation

template<typename T>
QUESO::DistArray< T >::DistArray ( const Map inputMap,
const int  inputRowSize 
)

Constructor for a given inputMap and inputRowSize.

template<typename T >
QUESO::DistArray< T >::~DistArray ( )

Destructor.

Definition at line 61 of file DistArray.C.

62 {
63 #ifdef QUESO_HAS_TRILINOS
64  delete m_epetraDistArray;
65  m_epetraDistArray = NULL;
66 #else
67  for (int i = 0; i < m_Map.NumGlobalElements(); ++i) {
68  m_elements[i].clear();
69  }
70  m_elements.clear();
71 #endif
72 }
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:116
EpetraExt::DistArray< T > * m_epetraDistArray
Definition: DistArray.h:113
template<typename T>
QUESO::DistArray< T >::DistArray ( )
private

Default constructor. Do not call this directly.

template<typename T>
QUESO::DistArray< T >::DistArray ( const DistArray< T > &  src)
inlineprivate

Copy constructor. Private.

Definition at line 106 of file DistArray.h.

106 : m_Map(src.m_Map) { }

Member Function Documentation

template<typename T >
int QUESO::DistArray< T >::GlobalLength ( ) const

Returns the global length of the array.

Definition at line 107 of file DistArray.C.

References QUESO::DistArray< T >::GlobalLength().

Referenced by QUESO::DistArray< T >::GlobalLength(), and QUESO::VectorSpace< V, M >::VectorSpace().

108 {
109 #ifdef QUESO_HAS_TRILINOS
110  return m_epetraDistArray->GlobalLength();
111 #else
112  return m_Map.NumGlobalElements();
113 #endif
114 }
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
EpetraExt::DistArray< T > * m_epetraDistArray
Definition: DistArray.h:113
template<typename T >
int QUESO::DistArray< T >::MyLength ( ) const

Returns the length of the locally owned array.

Definition at line 118 of file DistArray.C.

References QUESO::DistArray< T >::MyLength().

Referenced by QUESO::ArrayOfOneDTables< V, M >::ArrayOfOneDTables(), QUESO::DistArray< T >::MyLength(), and QUESO::VectorSpace< V, M >::VectorSpace().

119 {
120 #ifdef QUESO_HAS_TRILINOS
121  return m_epetraDistArray->MyLength();
122 #else
123  return m_Map.NumMyElements();
124 #endif
125 }
EpetraExt::DistArray< T > * m_epetraDistArray
Definition: DistArray.h:113
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:107
template<typename T >
T & QUESO::DistArray< T >::operator() ( int  localElementId,
int  colId 
)

Returns a reference to the colId column component of the localElementId local element.

Definition at line 85 of file DistArray.C.

86 {
87 #ifdef QUESO_HAS_TRILINOS
88  return (*m_epetraDistArray)(localElementId,colId);
89 #else
90  return m_elements[localElementId][colId];
91 #endif
92 }
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:116
EpetraExt::DistArray< T > * m_epetraDistArray
Definition: DistArray.h:113
template<typename T >
const T & QUESO::DistArray< T >::operator() ( int  localElementId,
int  colId 
) const

Returns a reference to the colId column component of the localElementId local element.(const)

Definition at line 96 of file DistArray.C.

97 {
98 #ifdef QUESO_HAS_TRILINOS
99  return (*m_epetraDistArray)(localElementId,colId);
100 #else
101  return m_elements[localElementId][colId];
102 #endif
103 }
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:116
EpetraExt::DistArray< T > * m_epetraDistArray
Definition: DistArray.h:113
template<typename T>
DistArray< T > & QUESO::DistArray< T >::operator= ( const DistArray< T > &  rhs)
private

Assignment operator.

Definition at line 77 of file DistArray.C.

78 {
79  return *this;
80 }
template<typename T >
void QUESO::DistArray< T >::print ( std::ostream &  os) const

Definition at line 141 of file DistArray.C.

142 {
143 #ifdef QUESO_HAS_TRILINOS
144  os << *m_epetraDistArray;
145 #else
146  os << "m_rowSize = " << m_rowSize
147  << ", m_elements.size() = " << m_elements.size()
148  << std::endl;
149 #endif
150 
151  return;
152 }
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:116
unsigned int m_rowSize
Definition: DistArray.h:115
EpetraExt::DistArray< T > * m_epetraDistArray
Definition: DistArray.h:113
template<typename T >
int QUESO::DistArray< T >::RowSize ( ) const

Returns the row size, that is, the amount of data associated with each element.

Definition at line 129 of file DistArray.C.

References QUESO::DistArray< T >::RowSize().

Referenced by QUESO::DistArray< T >::RowSize().

130 {
131 #ifdef QUESO_HAS_TRILINOS
132  return m_epetraDistArray->RowSize();
133 #else
134  return m_rowSize;
135 #endif
136 }
unsigned int m_rowSize
Definition: DistArray.h:115
EpetraExt::DistArray< T > * m_epetraDistArray
Definition: DistArray.h:113

Friends And Related Function Documentation

template<typename T>
std::ostream& operator<< ( std::ostream &  os,
const DistArray< T > &  obj 
)
friend

Definition at line 93 of file DistArray.h.

94  {
95  obj.print(os);
96 
97  return os;
98  }

Member Data Documentation

template<typename T>
std::vector<std::vector<T> > QUESO::DistArray< T >::m_elements
private

Definition at line 116 of file DistArray.h.

template<typename T>
EpetraExt::DistArray<T>* QUESO::DistArray< T >::m_epetraDistArray
private

Definition at line 113 of file DistArray.h.

template<typename T>
Map QUESO::DistArray< T >::m_Map
private

Definition at line 111 of file DistArray.h.

template<typename T>
unsigned int QUESO::DistArray< T >::m_rowSize
private

Definition at line 115 of file DistArray.h.


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

Generated on Sat Apr 22 2017 14:04:38 for queso-0.57.0 by  doxygen 1.8.5