queso-0.51.1
Map.C
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,2009,2010,2011,2012,2013 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 #include <queso/Map.h>
26 #include <queso/MpiComm.h>
27 
28 namespace QUESO {
29 
30 // --------------------------------------------------
31 // Constructor/Destructor methods -------------------
32 
33 // Default constructor ------------------------------
35  :
36  m_MpiComm() // *(new MpiComm()) )
37 {
40  "Map::constructor()",
41  "should not be called");
42 }
43 
44 // Usable constructor ------------------------------
46  int numGlobalElements,
47  int indexBase,
48  const MpiComm& comm)
49  :
50  m_MpiComm (comm),
51 #ifdef QUESO_HAS_TRILINOS
52  m_epetraMap ( new Epetra_Map(numGlobalElements,0,comm.epetraMpiComm()) )
53 #else
54  m_numGlobalElements(numGlobalElements),
55  m_indexBase (indexBase),
56  m_numMyElements (numGlobalElements)
57 #endif
58 {
59 }
60 
61 // Copy constructor ---------------------------------
62 Map::Map(const Map& src)
63  :
64  m_MpiComm(src.m_MpiComm)
65 #ifdef QUESO_HAS_TRILINOS
66  ,
67  m_epetraMap(NULL)
68 #endif
69 {
70  this->copy(src);
71 }
72 
73 // Destructor ---------------------------------------
75 {
76 #ifdef QUESO_HAS_TRILINOS
77  delete m_epetraMap;
78  m_epetraMap = NULL;
79 #else
80  // Nothing to do
81 #endif
82 }
83 
84 // --------------------------------------------------
85 // Set methodos -------------------------------------
86 Map&
87 Map::operator=(const Map& rhs)
88 {
89  this->copy(rhs);
90  return *this;
91 }
92 
93 // --------------------------------------------------
94 // Size, dimension and local ID accessor methods ----
95 int
97 {
98 #ifdef QUESO_HAS_TRILINOS
99  return m_epetraMap->NumGlobalElements();
100 #else
101  return m_numGlobalElements;
102 #endif
103 }
104 
105 // --------------------------------------------------
106 int
108 {
109 #ifdef QUESO_HAS_TRILINOS
110  return m_epetraMap->IndexBase();
111 #else
112  return m_indexBase;
113 #endif
114 }
115 
116 // --------------------------------------------------
117 int
119 {
120 #ifdef QUESO_HAS_TRILINOS
121  return m_epetraMap->NumMyElements();
122 #else
123  return m_numMyElements;
124 #endif
125 }
126 
127 // --------------------------------------------------
128 int
130 {
131 #ifdef QUESO_HAS_TRILINOS
132  return m_epetraMap->MinMyGID();
133 #else
134  return 0;
135 #endif
136 }
137 
138 
139 // --------------------------------------------------
140 // Misc methods -------------------------------------
141 const MpiComm&
142 Map::Comm() const
143 {
144  return m_MpiComm;
145 }
146 
147 #ifdef QUESO_HAS_TRILINOS
148 const Epetra_Map&
149 Map::epetraMap() const
150 {
151  return *m_epetraMap;
152 }
153 #endif
154 
155 // --------------------------------------------------
156 void
157 Map::copy(const Map& src)
158 {
159  m_MpiComm = src.m_MpiComm;
160 #ifdef QUESO_HAS_TRILINOS
161  delete m_epetraMap;
162  m_epetraMap = new Epetra_Map(*src.m_epetraMap);
163 #else
165  m_indexBase = src.m_indexBase;
167 #endif
168 
169  return;
170 }
171 
172 } // End namespace QUESO
The QUESO MPI Communicator Class.
Definition: MpiComm.h:75
int m_indexBase
Base integer value for indexed array references.
Definition: Map.h:119
Map()
Default constructor. Do not call this directly.
Definition: Map.C:34
A class for partitioning vectors and matrices.
Definition: Map.h:49
Map & operator=(const Map &rhs)
Assignment operator.
Definition: Map.C:87
const int UQ_UNAVAILABLE_RANK
Definition: Defines.h:74
~Map()
Destructor.
Definition: Map.C:74
int m_numMyElements
Number of elements owned by the calling processor.
Definition: Map.h:122
MpiComm m_MpiComm
This communicator can be queried for processor rank and size information.
Definition: Map.h:109
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:118
const MpiComm & Comm() const
Access function for MpiComm communicator.
Definition: Map.C:142
int IndexBase() const
Definition: Map.C:107
int m_numGlobalElements
Total number of elements across all processors.
Definition: Map.h:116
void copy(const Map &src)
Copies the map.
Definition: Map.C:157
int MinMyGID() const
The minimum global index value on the calling processor.
Definition: Map.C:129
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:96
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223

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