queso-0.53.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 (const DistArray< T > &src)
 Copy constructor. More...
 
 ~DistArray ()
 Destructor. More...
 
Set methods
DistArray< T > & operator= (const DistArray< T > &rhs)
 Assignment operator. 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...
 
void copy (const DistArray< T > &src)
 Copies the array. More...
 

Private Attributes

Map m_Map
 
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.

Definition at line 37 of file DistArray.C.

References QUESO::DistArray< T >::m_elements, QUESO::DistArray< T >::m_Map, QUESO::DistArray< T >::m_rowSize, and QUESO::Map::NumGlobalElements().

38  : m_Map(inputMap),
39 #ifdef QUESO_HAS_TRILINOS
40  m_epetraDistArray(new EpetraExt::DistArray<T>(inputMap.epetraMap(),inputRowSize))
41 #else
42  m_rowSize(inputRowSize)
43 #endif
44 {
45 #ifdef QUESO_HAS_TRILINOS
46 #else
48  for (int i = 0; i < m_Map.NumGlobalElements(); ++i) {
49  m_elements[i].resize(m_rowSize);
50  }
51 #endif
52 }
unsigned int m_rowSize
Definition: DistArray.h:121
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:122
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
template<typename T>
QUESO::DistArray< T >::DistArray ( const DistArray< T > &  src)

Copy constructor.

Definition at line 56 of file DistArray.C.

References QUESO::DistArray< T >::copy(), and QUESO::DistArray< T >::m_elements.

57  : m_Map(src.m_Map)
58 #ifdef QUESO_HAS_TRILINOS
59  ,
60  m_epetraDistArray(NULL)
61 #endif
62 {
63 #ifdef QUESO_HAS_TRILINOS
64 #else
65  m_elements.clear();
66 #endif
67  this->copy(src);
68 }
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:122
void copy(const DistArray< T > &src)
Copies the array.
Definition: DistArray.C:160
template<typename T >
QUESO::DistArray< T >::~DistArray ( )

Destructor.

Definition at line 72 of file DistArray.C.

73 {
74 #ifdef QUESO_HAS_TRILINOS
75  delete m_epetraDistArray;
76  m_epetraDistArray = NULL;
77 #else
78  for (int i = 0; i < m_Map.NumGlobalElements(); ++i) {
79  m_elements[i].clear();
80  }
81  m_elements.clear();
82 #endif
83 }
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:122
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
template<typename T>
QUESO::DistArray< T >::DistArray ( )
private

Default constructor. Do not call this directly.

Member Function Documentation

template<typename T>
void QUESO::DistArray< T >::copy ( const DistArray< T > &  src)
private

Copies the array.

Definition at line 160 of file DistArray.C.

References queso_not_implemented.

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

161 {
163 }
#define queso_not_implemented()
Definition: asserts.h:56
template<typename T >
int QUESO::DistArray< T >::GlobalLength ( ) const

Returns the global length of the array.

Definition at line 126 of file DistArray.C.

Referenced by QUESO::VectorSpace< V, M >::VectorSpace().

127 {
128 #ifdef QUESO_HAS_TRILINOS
129  return m_epetraDistArray->GlobalLength();
130 #else
131  return m_Map.NumGlobalElements();
132 #endif
133 }
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
template<typename T >
int QUESO::DistArray< T >::MyLength ( ) const

Returns the length of the locally owned array.

Definition at line 137 of file DistArray.C.

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

138 {
139 #ifdef QUESO_HAS_TRILINOS
140  return m_epetraDistArray->MyLength();
141 #else
142  return m_Map.NumMyElements();
143 #endif
144 }
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 104 of file DistArray.C.

105 {
106 #ifdef QUESO_HAS_TRILINOS
107  return (*m_epetraDistArray)(localElementId,colId);
108 #else
109  return m_elements[localElementId][colId];
110 #endif
111 }
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:122
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 115 of file DistArray.C.

116 {
117 #ifdef QUESO_HAS_TRILINOS
118  return (*m_epetraDistArray)(localElementId,colId);
119 #else
120  return m_elements[localElementId][colId];
121 #endif
122 }
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:122
template<typename T>
DistArray< T > & QUESO::DistArray< T >::operator= ( const DistArray< T > &  rhs)

Assignment operator.

Definition at line 88 of file DistArray.C.

References copy.

89 {
90 #ifdef QUESO_HAS_TRILINOS
91 #else
92  for (int i = 0; i < m_Map.NumGlobalElements(); ++i) {
93  m_elements[i].clear();
94  }
95  m_elements.clear();
96 #endif
97  this->copy(rhs);
98  return *this;
99 }
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:122
void copy(const DistArray< T > &src)
Copies the array.
Definition: DistArray.C:160
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
template<typename T >
void QUESO::DistArray< T >::print ( std::ostream &  os) const

Definition at line 168 of file DistArray.C.

169 {
170 #ifdef QUESO_HAS_TRILINOS
171  os << *m_epetraDistArray;
172 #else
173  os << "m_rowSize = " << m_rowSize
174  << ", m_elements.size() = " << m_elements.size()
175  << std::endl;
176 #endif
177 
178  return;
179 }
unsigned int m_rowSize
Definition: DistArray.h:121
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:122
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 148 of file DistArray.C.

149 {
150 #ifdef QUESO_HAS_TRILINOS
151  return m_epetraDistArray->RowSize();
152 #else
153  return m_rowSize;
154 #endif
155 }
unsigned int m_rowSize
Definition: DistArray.h:121

Friends And Related Function Documentation

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

Definition at line 102 of file DistArray.h.

103  {
104  obj.print(os);
105 
106  return os;
107  }

Member Data Documentation

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

Definition at line 122 of file DistArray.h.

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

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

Definition at line 117 of file DistArray.h.

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

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

Definition at line 121 of file DistArray.h.

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


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

Generated on Thu Jun 11 2015 13:52:34 for queso-0.53.0 by  doxygen 1.8.5