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

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