queso-0.51.1
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 ()
 Default constructor. Do not call this directly. More...
 
 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

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 ( )

Default constructor. Do not call this directly.

Definition at line 36 of file DistArray.C.

References UQ_FATAL_TEST_MACRO, and QUESO::UQ_UNAVAILABLE_RANK.

37  : m_Map()
38 {
41  "DistArray<T>::constructor()",
42  "should not be called");
43 }
const int UQ_UNAVAILABLE_RANK
Definition: Defines.h:74
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
template<typename T >
QUESO::DistArray< T >::DistArray ( const Map inputMap,
const int  inputRowSize 
)

Constructor for a given inputMap and inputRowSize.

Definition at line 47 of file DistArray.C.

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

48  : m_Map(inputMap),
49 #ifdef QUESO_HAS_TRILINOS
50  m_epetraDistArray(new EpetraExt::DistArray<T>(inputMap.epetraMap(),inputRowSize))
51 #else
52  m_rowSize(inputRowSize)
53 #endif
54 {
55 #ifdef QUESO_HAS_TRILINOS
56 #else
58  for (int i = 0; i < m_Map.NumGlobalElements(); ++i) {
59  m_elements[i].resize(m_rowSize);
60  }
61 #endif
62 }
unsigned int m_rowSize
Definition: DistArray.h:123
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:96
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:124
template<typename T>
QUESO::DistArray< T >::DistArray ( const DistArray< T > &  src)

Copy constructor.

Definition at line 66 of file DistArray.C.

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

67  : m_Map(src.m_Map)
68 #ifdef QUESO_HAS_TRILINOS
69  ,
70  m_epetraDistArray(NULL)
71 #endif
72 {
73 #ifdef QUESO_HAS_TRILINOS
74 #else
75  m_elements.clear();
76 #endif
77  this->copy(src);
78 }
void copy(const DistArray< T > &src)
Copies the array.
Definition: DistArray.C:170
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:124
template<typename T >
QUESO::DistArray< T >::~DistArray ( )

Destructor.

Definition at line 82 of file DistArray.C.

83 {
84 #ifdef QUESO_HAS_TRILINOS
85  delete m_epetraDistArray;
86  m_epetraDistArray = NULL;
87 #else
88  for (int i = 0; i < m_Map.NumGlobalElements(); ++i) {
89  m_elements[i].clear();
90  }
91  m_elements.clear();
92 #endif
93 }
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:96
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:124

Member Function Documentation

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

Copies the array.

Definition at line 170 of file DistArray.C.

References queso_not_implemented.

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

171 {
173 }
#define queso_not_implemented()
Definition: asserts.h:88
template<typename T >
int QUESO::DistArray< T >::GlobalLength ( ) const

Returns the global length of the array.

Definition at line 136 of file DistArray.C.

137 {
138 #ifdef QUESO_HAS_TRILINOS
139  return m_epetraDistArray->GlobalLength();
140 #else
141  return m_Map.NumGlobalElements();
142 #endif
143 }
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:96
template<typename T >
int QUESO::DistArray< T >::MyLength ( ) const

Returns the length of the locally owned array.

Definition at line 147 of file DistArray.C.

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

148 {
149 #ifdef QUESO_HAS_TRILINOS
150  return m_epetraDistArray->MyLength();
151 #else
152  return m_Map.NumMyElements();
153 #endif
154 }
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:118
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 114 of file DistArray.C.

115 {
116 #ifdef QUESO_HAS_TRILINOS
117  return (*m_epetraDistArray)(localElementId,colId);
118 #else
119  return m_elements[localElementId][colId];
120 #endif
121 }
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:124
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 125 of file DistArray.C.

126 {
127 #ifdef QUESO_HAS_TRILINOS
128  return (*m_epetraDistArray)(localElementId,colId);
129 #else
130  return m_elements[localElementId][colId];
131 #endif
132 }
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:124
template<typename T>
DistArray< T > & QUESO::DistArray< T >::operator= ( const DistArray< T > &  rhs)

Assignment operator.

Definition at line 98 of file DistArray.C.

99 {
100 #ifdef QUESO_HAS_TRILINOS
101 #else
102  for (int i = 0; i < m_Map.NumGlobalElements(); ++i) {
103  m_elements[i].clear();
104  }
105  m_elements.clear();
106 #endif
107  this->copy(rhs);
108  return *this;
109 }
void copy(const DistArray< T > &src)
Copies the array.
Definition: DistArray.C:170
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:96
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:124
template<typename T >
void QUESO::DistArray< T >::print ( std::ostream &  os) const

Definition at line 178 of file DistArray.C.

179 {
180 #ifdef QUESO_HAS_TRILINOS
181  os << *m_epetraDistArray;
182 #else
183  os << "m_rowSize = " << m_rowSize
184  << ", m_elements.size() = " << m_elements.size()
185  << std::endl;
186 #endif
187 
188  return;
189 }
unsigned int m_rowSize
Definition: DistArray.h:123
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:124
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 158 of file DistArray.C.

159 {
160 #ifdef QUESO_HAS_TRILINOS
161  return m_epetraDistArray->RowSize();
162 #else
163  return m_rowSize;
164 #endif
165 }
unsigned int m_rowSize
Definition: DistArray.h:123

Friends And Related Function Documentation

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

Definition at line 106 of file DistArray.h.

107  {
108  obj.print(os);
109 
110  return os;
111  }

Member Data Documentation

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

Definition at line 124 of file DistArray.h.

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

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

Definition at line 119 of file DistArray.h.

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

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

Definition at line 123 of file DistArray.h.

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


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

Generated on Thu Apr 23 2015 19:26:16 for queso-0.51.1 by  doxygen 1.8.5