Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_SerialComm.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_SerialComm.h"
44 #include "Epetra_BasicDirectory.h"
46 
47 //=============================================================================
49  : Epetra_Object("Epetra::Comm"),
50  SerialCommData_(new Epetra_SerialCommData()) {}
51 
52 //=============================================================================
54  : Epetra_Object(Comm.Label()),
55  SerialCommData_(Comm.SerialCommData_)
56 {
58 }
59 //=============================================================================
61 //=============================================================================
62 int Epetra_SerialComm::Broadcast(double * Values, int Count, int Root) const {
63  (void)Values;
64  (void)Count;
65  (void)Root;
66  return(0);
67 }
68 //=============================================================================
69 int Epetra_SerialComm::Broadcast(int * Values, int Count, int Root) const {
70  (void)Values;
71  (void)Count;
72  (void)Root;
73  return(0);
74 }
75 //=============================================================================
76 int Epetra_SerialComm::Broadcast(long * Values, int Count, int Root) const {
77  (void)Values;
78  (void)Count;
79  (void)Root;
80  return(0);
81 }
82 //=============================================================================
83 int Epetra_SerialComm::Broadcast(long long * Values, int Count, int Root) const{
84  (void)Values;
85  (void)Count;
86  (void)Root;
87  return(0);
88 }
89 //=============================================================================
90 int Epetra_SerialComm::Broadcast(char * Values, int Count, int Root) const {
91  (void)Values;
92  (void)Count;
93  (void)Root;
94  return(0);
95 }
96 //=============================================================================
97 int Epetra_SerialComm::GatherAll(double * MyVals, double * AllVals, int Count) const {
98  for (int i=0; i<Count; ++i) AllVals[i] = MyVals[i];
99  return(0);
100 }
101 //=============================================================================
102 int Epetra_SerialComm::GatherAll(int * MyVals, int * AllVals, int Count) const {
103  for (int i=0; i<Count; ++i) AllVals[i] = MyVals[i];
104  return(0);
105 }
106 //=============================================================================
107 int Epetra_SerialComm::GatherAll(long * MyVals, long * AllVals, int Count) const {
108  for (int i=0; i<Count; ++i) AllVals[i] = MyVals[i];
109  return(0);
110 }
111 //=============================================================================
112 int Epetra_SerialComm::GatherAll(long long * MyVals, long long * AllVals, int Count) const {
113  for (int i=0; i<Count; ++i) AllVals[i] = MyVals[i];
114  return(0);
115 }
116 //=============================================================================
117 int Epetra_SerialComm::SumAll(double * PartialSums, double * GlobalSums, int Count) const {
118  for (int i=0; i<Count; i++) GlobalSums[i] = PartialSums[i];
119  return(0);
120 }
121 //=============================================================================
122 int Epetra_SerialComm::SumAll(int * PartialSums, int * GlobalSums, int Count) const {
123  for (int i=0; i<Count; i++) GlobalSums[i] = PartialSums[i];
124  return(0);
125 }
126 //=============================================================================
127 int Epetra_SerialComm::SumAll(long * PartialSums, long * GlobalSums, int Count) const {
128  for (int i=0; i<Count; i++) GlobalSums[i] = PartialSums[i];
129  return(0);
130 }
131 //=============================================================================
132 int Epetra_SerialComm::SumAll(long long * PartialSums, long long * GlobalSums, int Count) const {
133  for (int i=0; i<Count; i++) GlobalSums[i] = PartialSums[i];
134  return(0);
135 }
136 //=============================================================================
137 int Epetra_SerialComm::MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const {
138  for (int i=0; i<Count; i++) GlobalMaxs[i] = PartialMaxs[i];
139  return(0);
140 }
141 //=============================================================================
142 int Epetra_SerialComm::MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const {
143  for (int i=0; i<Count; i++) GlobalMaxs[i] = PartialMaxs[i];
144  return(0);
145 }
146 //=============================================================================
147 int Epetra_SerialComm::MaxAll(long * PartialMaxs, long * GlobalMaxs, int Count) const {
148  for (int i=0; i<Count; i++) GlobalMaxs[i] = PartialMaxs[i];
149  return(0);
150 }
151 //=============================================================================
152 int Epetra_SerialComm::MaxAll(long long * PartialMaxs, long long * GlobalMaxs, int Count) const {
153  for (int i=0; i<Count; i++) GlobalMaxs[i] = PartialMaxs[i];
154  return(0);
155 }
156 //=============================================================================
157 int Epetra_SerialComm::MinAll(double * PartialMins, double * GlobalMins, int Count) const {
158  for (int i=0; i<Count; i++) GlobalMins[i] = PartialMins[i];
159  return(0);
160 }
161 //=============================================================================
162 int Epetra_SerialComm::MinAll(int * PartialMins, int * GlobalMins, int Count) const {
163  for (int i=0; i<Count; i++) GlobalMins[i] = PartialMins[i];
164  return(0);
165 }
166 //=============================================================================
167 int Epetra_SerialComm::MinAll(long * PartialMins, long * GlobalMins, int Count) const {
168  for (int i=0; i<Count; i++) GlobalMins[i] = PartialMins[i];
169  return(0);
170 }
171 //=============================================================================
172 int Epetra_SerialComm::MinAll(long long * PartialMins, long long * GlobalMins, int Count) const {
173  for (int i=0; i<Count; i++) GlobalMins[i] = PartialMins[i];
174  return(0);
175 }
176 //=============================================================================
177 int Epetra_SerialComm::ScanSum(double * MyVals, double * ScanSums, int Count) const {
178  for (int i=0; i<Count; i++) ScanSums[i] = MyVals[i];
179  return(0);
180 }
181 //=============================================================================
182 int Epetra_SerialComm::ScanSum(int * MyVals, int * ScanSums, int Count) const {
183  for (int i=0; i<Count; i++) ScanSums[i] = MyVals[i];
184  return(0);
185 }
186 //=============================================================================
187 int Epetra_SerialComm::ScanSum(long * MyVals, long * ScanSums, int Count) const {
188  for (int i=0; i<Count; i++) ScanSums[i] = MyVals[i];
189  return(0);
190 }
191 //=============================================================================
192 int Epetra_SerialComm::ScanSum(long long * MyVals, long long * ScanSums, int Count) const {
193  for (int i=0; i<Count; i++) ScanSums[i] = MyVals[i];
194  return(0);
195 }
196 //=============================================================================
198 
199  Epetra_Distributor * dist = dynamic_cast<Epetra_Distributor *>(new Epetra_SerialDistributor(*this));
200  return(dist);
201 }
202 //=============================================================================
204 
205  Epetra_Directory * dir = dynamic_cast<Epetra_Directory *>(new Epetra_BasicDirectory(map));
206  return(dir);
207 }
208 //=============================================================================
210  CleanupData();
211 }
212 //=============================================================================
214  if((this != &Comm) && (SerialCommData_ != Comm.SerialCommData_)) {
215  CleanupData();
218  }
219  return(*this);
220 }
221 //=============================================================================
223  if(SerialCommData_ != 0) {
225  if(SerialCommData_->ReferenceCount() == 0) {
226  delete SerialCommData_;
227  SerialCommData_ = 0;
228  }
229  }
230 }
231 //=============================================================================
233  return(SerialCommData_->ReferenceCount());
234 }
int ScanSum(double *MyVals, double *ScanSums, int Count) const
Epetra_SerialComm Scan Sum function.
Epetra_SerialDistributor: The Epetra Serial implementation of the Epetra_Distributor Gather/Scatter S...
Epetra_Distributor: The Epetra Gather/Scatter Setup Base Class.
void DecrementReferenceCount()
Decrement reference count.
Definition: Epetra_Data.cpp:66
Epetra_SerialComm & operator=(const Epetra_SerialComm &Comm)
Assignment Operator.
int GatherAll(double *MyVals, double *AllVals, int Count) const
Epetra_SerialComm All Gather function.
int MinAll(double *PartialMins, double *GlobalMins, int Count) const
Epetra_SerialComm Global Min function.
Epetra_SerialComm()
Epetra_SerialComm Serial Constructor.
Epetra_Directory: This class is a pure virtual class whose interface allows Epetra_Map and Epetr_Bloc...
Epetra_SerialCommData: The Epetra Serial Communication Data Class.
Epetra_BasicDirectory: This class allows Epetra_Map objects to reference non-local elements...
Epetra_Object: The base Epetra class.
Definition: Epetra_Object.h:57
int ReferenceCount() const
Get reference count.
Definition: Epetra_Data.cpp:71
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
virtual ~Epetra_SerialComm()
Epetra_SerialComm Destructor.
void IncrementReferenceCount()
Increment reference count.
Definition: Epetra_Data.cpp:61
Epetra_SerialComm: The Epetra Serial Communication Class.
Epetra_Directory * CreateDirectory(const Epetra_BlockMap &Map) const
Create a directory object for the given Epetra_BlockMap.
Epetra_SerialCommData * SerialCommData_
int MaxAll(double *PartialMaxs, double *GlobalMaxs, int Count) const
Epetra_SerialComm Global Max function.
int SumAll(double *PartialSums, double *GlobalSums, int Count) const
Epetra_SerialComm Global Sum function.
void Barrier() const
Epetra_SerialComm Barrier function.
int ReferenceCount() const
Returns the reference count of SerialCommData.
Epetra_Distributor * CreateDistributor() const
Create a distributor object.
int Broadcast(double *MyVals, int Count, int Root) const
Epetra_SerialComm Broadcast function.