queso-0.57.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-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 #include <queso/Map.h>
26 #include <queso/MpiComm.h>
27 
28 namespace QUESO {
29 
30 // --------------------------------------------------
31 // Constructor/Destructor methods -------------------
32 
33 // Usable constructor ------------------------------
34 Map::Map(
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&
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
int m_numMyElements
Number of elements owned by the calling processor.
Definition: Map.h:122
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
int MinMyGID() const
The minimum global index value on the calling processor.
Definition: Map.C:118
A class for partitioning vectors and matrices.
Definition: Map.h:49
The QUESO MPI Communicator Class.
Definition: MpiComm.h:203
void copy(const Map &src)
Copies the map.
Definition: Map.C:146
int IndexBase() const
Definition: Map.C:96
Epetra_Map * m_epetraMap
Epetra_Map.
Definition: Map.h:113
Map & operator=(const Map &rhs)
Assignment operator.
Definition: Map.C:76
MpiComm m_MpiComm
This communicator can be queried for processor rank and size information.
Definition: Map.h:109
const MpiComm & Comm() const
Access function for MpiComm communicator.
Definition: Map.C:131
and that you are informed that you can do these things To protect your we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it For if you distribute copies of the whether gratis or for a you must give the recipients all the rights that we gave you You must make sure that receive or can get the source code If you link other code with the you must provide complete object files to the so that they can relink them with the library after making changes to the library and recompiling it And you must show them these terms so they know their rights We protect your rights with a two step which gives you legal permission to copy
Definition: License.txt:60
const Epetra_Map & epetraMap() const
Trilinos Epetra_Map: A class for partitioning vectors and matrices.
Definition: Map.C:138
int m_numGlobalElements
Total number of elements across all processors.
Definition: Map.h:116
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:107
~Map()
Destructor.
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:63

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