Epetra Package Browser (Single Doxygen Collection)
Development
Toggle main menu visibility
Loading...
Searching...
No Matches
src
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
//============================================================================
86
Epetra_LocalMap::Epetra_LocalMap
(
const
Epetra_LocalMap
& map)
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
//============================================================================
94
int
Epetra_LocalMap::CheckInput
() {
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
//=========================================================================
110
Epetra_LocalMap::~Epetra_LocalMap
()
111
{
112
}
113
//=============================================================================
114
Epetra_LocalMap
&
Epetra_LocalMap::operator=
(
const
Epetra_LocalMap
& map) {
115
if
(
this
!= &map)
116
Epetra_BlockMap::operator=
(map);
// call this->Epetra_BlockMap::operator=
117
return
(*
this
);
118
}
Epetra_Comm.h
Epetra_ConfigDefs.h
Epetra_LocalMap.h
Epetra_BlockMap::operator=
Epetra_BlockMap & operator=(const Epetra_BlockMap &map)
Assignment Operator.
Definition
Epetra_BlockMap.cpp:1541
Epetra_BlockMap::Epetra_LocalMap
friend class Epetra_LocalMap
Definition
Epetra_BlockMap.h:196
Epetra_BlockMap::Comm
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
Definition
Epetra_BlockMap.h:770
Epetra_BlockMap::NumMyElements
int NumMyElements() const
Number of elements on the calling processor.
Definition
Epetra_BlockMap.h:555
Epetra_Comm
Epetra_Comm: The Epetra Communication Abstract Base Class.
Definition
Epetra_Comm.h:73
Epetra_Comm::MaxAll
virtual int MaxAll(double *PartialMaxs, double *GlobalMaxs, int Count) const =0
Epetra_Comm Global Max function.
Epetra_LocalMap::CheckInput
int CheckInput()
Definition
Epetra_LocalMap.cpp:94
Epetra_LocalMap::~Epetra_LocalMap
virtual ~Epetra_LocalMap()
Epetra_LocalMap destructor.
Definition
Epetra_LocalMap.cpp:110
Epetra_LocalMap::Epetra_LocalMap
Epetra_LocalMap(int NumMyElements, int IndexBase, const Epetra_Comm &Comm)
Epetra_LocalMap constructor for a user-defined replicate distribution of elements.
Definition
Epetra_LocalMap.cpp:50
Epetra_LocalMap::operator=
Epetra_LocalMap & operator=(const Epetra_LocalMap &map)
Assignment Operator.
Definition
Epetra_LocalMap.cpp:114
Epetra_Map::Epetra_Map
Epetra_Map(int NumGlobalElements, int IndexBase, const Epetra_Comm &Comm)
Epetra_Map constructor for a Epetra-defined uniform linear distribution of elements.
Definition
Epetra_Map.cpp:54
Epetra_Object::ReportError
virtual int ReportError(const std::string Message, int ErrorCode) const
Error reporting method.
Definition
Epetra_Object.cpp:103
Epetra_Object::SetLabel
virtual void SetLabel(const char *const Label)
Epetra_Object Label definition using char *.
Definition
Epetra_Object.cpp:134
Generated by
1.17.0