Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_LocalMap.cpp
Go to the documentation of this file.
1 
2 //@HEADER
3 // ************************************************************************
4 //
5 // Epetra: Linear Algebra Services Package
6 // Copyright 2011 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 
43 #include "Epetra_ConfigDefs.h"
44 #include "Epetra_LocalMap.h"
45 #include "Epetra_Comm.h"
46 #include <assert.h>
47 
48 //============================================================================
49 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
50 Epetra_LocalMap::Epetra_LocalMap(int numMyElements, int indexBase,
51  const Epetra_Comm& comm)
52  // LocalMap is just a special case of Map
53  : Epetra_Map(numMyElements, numMyElements, indexBase, comm)
54 {
55  SetLabel("Epetra::LocalMap");
56  if (CheckInput()!=0)
57  throw ReportError("Replicated Local Map not the same size on all PEs",-1);
58 }
59 #endif
60 //============================================================================
61 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
62 #include <limits>
63 Epetra_LocalMap::Epetra_LocalMap(long long numMyElements, int indexBase,
64  const Epetra_Comm& comm)
65  // LocalMap is just a special case of Map
66  : Epetra_Map(numMyElements, static_cast<int>(numMyElements), indexBase, comm)
67 {
68  assert(numMyElements <= (long long) std::numeric_limits<int>::max());
69  SetLabel("Epetra::LocalMap");
70  if (CheckInput()!=0)
71  throw ReportError("Replicated Local Map not the same size on all PEs",-1);
72 }
73 
74 Epetra_LocalMap::Epetra_LocalMap(long long numMyElements, long long indexBase,
75  const Epetra_Comm& comm)
76  // LocalMap is just a special case of Map
77  : Epetra_Map(numMyElements, static_cast<int>(numMyElements), indexBase, comm)
78 {
79  assert(numMyElements <= (long long) std::numeric_limits<int>::max());
80  SetLabel("Epetra::LocalMap");
81  if (CheckInput()!=0)
82  throw ReportError("Replicated Local Map not the same size on all PEs",-1);
83 }
84 #endif
85 //============================================================================
87  : Epetra_Map(map)
88 {
89  if (CheckInput()!=0)
90  throw ReportError("Replicated Local Map not the same size on all PEs",-1);
91 }
92 
93 //============================================================================
95  int * tmp = new int[4];
96  tmp[0] = NumMyElements();
97  tmp[1] = - NumMyElements();
98  Comm().MaxAll(tmp, tmp+2, 2);
99 
100  int tmp1 = tmp[2]; // Max of all NumMyElements across all processors
101  int tmp2 = - tmp[3]; // Min of all ...
102  delete [] tmp;
103 
104  if (tmp1==tmp2)
105  return(0);
106  else
107  return(-1);
108 }
109 //=========================================================================
111 {
112 }
113 //=============================================================================
115  if(this != &map)
116  Epetra_BlockMap::operator=(map); // call this->Epetra_BlockMap::operator=
117  return(*this);
118 }
virtual ~Epetra_LocalMap()
Epetra_LocalMap destructor.
Epetra_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:127
Epetra_LocalMap(int NumMyElements, int IndexBase, const Epetra_Comm &Comm)
Epetra_LocalMap constructor for a user-defined replicate distribution of elements.
virtual void SetLabel(const char *const Label)
Epetra_Object Label definition using char *.
virtual int MaxAll(double *PartialMaxs, double *GlobalMaxs, int Count) const =0
Epetra_Comm Global Max function.
int NumMyElements() const
Number of elements on the calling processor.
Epetra_LocalMap & operator=(const Epetra_LocalMap &map)
Assignment Operator.
Epetra_Comm: The Epetra Communication Abstract Base Class.
Definition: Epetra_Comm.h:81
Epetra_BlockMap & operator=(const Epetra_BlockMap &map)
Assignment Operator.
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
virtual int ReportError(const std::string Message, int ErrorCode) const
Error reporting method.
Epetra_LocalMap: A class for replicating vectors and matrices across multiple processors.