queso-0.57.0
DistArray.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2017 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #ifndef UQ_DIST_ARRAY_H
26 #define UQ_DIST_ARRAY_H
27 
28 #include <queso/Defines.h>
29 #include <queso/Map.h>
30 #ifdef QUESO_HAS_TRILINOS
31 #include <EpetraExt_DistArray.h>
32 #endif
33 #include <ostream>
34 
35 namespace QUESO {
36 
55 template <typename T>
56 class DistArray
57 {
58 public:
60 
61 
63  DistArray(const Map& inputMap,
64  const int inputRowSize);
65 
67  ~DistArray();
69 
71 
72 
74  T& operator ()(int localElementId, int colId);
75 
77  const T& operator ()(int localElementId, int colId) const;
78 
80  int GlobalLength() const;
81 
83  int MyLength () const;
84 
86  int RowSize () const;
87 
89 
91 
92  void print (std::ostream& os) const;
93  friend std::ostream & operator<<(std::ostream& os, const DistArray<T>& obj)
94  {
95  obj.print(os);
96 
97  return os;
98  }
100 
101 private:
103  DistArray();
104 
106  DistArray(const DistArray<T>& src) : m_Map(src.m_Map) { }
107 
109  DistArray<T>& operator=(const DistArray<T>& rhs);
110 
112 #ifdef QUESO_HAS_TRILINOS
113  EpetraExt::DistArray<T>* m_epetraDistArray;
114 #else
115  unsigned int m_rowSize;
116  std::vector<std::vector<T> > m_elements;
117 #endif
118 };
119 
120 } // End namespace QUESO
121 
122 #endif // UQ_DIST_ARRAY_H
void print(std::ostream &os) const
Definition: DistArray.C:141
DistArray(const DistArray< T > &src)
Copy constructor. Private.
Definition: DistArray.h:106
DistArray()
Default constructor. Do not call this directly.
A class for partitioning vectors and matrices.
Definition: Map.h:49
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:116
unsigned int m_rowSize
Definition: DistArray.h:115
int MyLength() const
Returns the length of the locally owned array.
Definition: DistArray.C:118
~DistArray()
Destructor.
Definition: DistArray.C:61
EpetraExt::DistArray< T > * m_epetraDistArray
Definition: DistArray.h:113
A class for partitioning vectors and matrices.
Definition: DistArray.h:56
int RowSize() const
Returns the row size, that is, the amount of data associated with each element.
Definition: DistArray.C:129
int GlobalLength() const
Returns the global length of the array.
Definition: DistArray.C:107
T & operator()(int localElementId, int colId)
Returns a reference to the colId column component of the localElementId local element.
Definition: DistArray.C:85
DistArray< T > & operator=(const DistArray< T > &rhs)
Assignment operator.
Definition: DistArray.C:77

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