Epetra Package Browser (Single Doxygen Collection) Development
Epetra_SerialComm.cpp
Go to the documentation of this file.
00001 
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright 2011 Sandia Corporation
00007 // 
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00039 // 
00040 // ************************************************************************
00041 //@HEADER
00042 
00043 #include "Epetra_SerialComm.h"
00044 #include "Epetra_BasicDirectory.h"
00045 #include "Epetra_SerialDistributor.h"
00046 
00047 //=============================================================================
00048 Epetra_SerialComm::Epetra_SerialComm()
00049   : Epetra_Object("Epetra::Comm"), 
00050     SerialCommData_(new Epetra_SerialCommData()) {}
00051  
00052 //=============================================================================
00053 Epetra_SerialComm::Epetra_SerialComm(const Epetra_SerialComm& Comm) 
00054   : Epetra_Object(Comm.Label()), 
00055     SerialCommData_(Comm.SerialCommData_) 
00056 {
00057   SerialCommData_->IncrementReferenceCount();
00058 }
00059 //=============================================================================
00060 void Epetra_SerialComm::Barrier() const {}
00061 //=============================================================================
00062 int Epetra_SerialComm::Broadcast(double * Values, int Count, int Root) const {
00063   (void)Values;
00064   (void)Count;
00065   (void)Root;
00066   return(0);
00067 }
00068 //=============================================================================
00069 int Epetra_SerialComm::Broadcast(int * Values, int Count, int Root) const {
00070   (void)Values;
00071   (void)Count;
00072   (void)Root;
00073   return(0);
00074 }
00075 //=============================================================================
00076 int Epetra_SerialComm::Broadcast(long * Values, int Count, int Root) const {
00077   (void)Values;
00078   (void)Count;
00079   (void)Root;
00080   return(0);
00081 }
00082 //=============================================================================
00083 int Epetra_SerialComm::Broadcast(char * Values, int Count, int Root) const {
00084   (void)Values;
00085   (void)Count;
00086   (void)Root;
00087   return(0);
00088 }
00089 //=============================================================================
00090 int Epetra_SerialComm::GatherAll(double * MyVals, double * AllVals, int Count) const {
00091   for (int i=0; i<Count; ++i) AllVals[i] = MyVals[i];
00092   return(0);
00093 }
00094 //=============================================================================
00095 int Epetra_SerialComm::GatherAll(int * MyVals, int * AllVals, int Count) const {
00096   for (int i=0; i<Count; ++i) AllVals[i] = MyVals[i];
00097   return(0);
00098 }
00099 //=============================================================================
00100 int Epetra_SerialComm::GatherAll(long * MyVals, long * AllVals, int Count) const {
00101   for (int i=0; i<Count; ++i) AllVals[i] = MyVals[i];
00102   return(0);
00103 }
00104 //=============================================================================
00105 int Epetra_SerialComm::SumAll(double * PartialSums, double * GlobalSums, int Count) const {
00106   for (int i=0; i<Count; i++) GlobalSums[i] = PartialSums[i];
00107   return(0);
00108 }
00109 //=============================================================================
00110 int Epetra_SerialComm::SumAll(int * PartialSums, int * GlobalSums, int Count) const {
00111   for (int i=0; i<Count; i++) GlobalSums[i] = PartialSums[i];
00112   return(0);
00113 }
00114 //=============================================================================
00115 int Epetra_SerialComm::SumAll(long * PartialSums, long * GlobalSums, int Count) const {
00116   for (int i=0; i<Count; i++) GlobalSums[i] = PartialSums[i];
00117   return(0);
00118 }
00119 //=============================================================================
00120 int Epetra_SerialComm::MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const {
00121   for (int i=0; i<Count; i++) GlobalMaxs[i] = PartialMaxs[i];
00122   return(0);
00123 }
00124 //=============================================================================
00125 int Epetra_SerialComm::MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const {
00126   for (int i=0; i<Count; i++) GlobalMaxs[i] = PartialMaxs[i];
00127   return(0);
00128 }
00129 //=============================================================================
00130 int Epetra_SerialComm::MaxAll(long * PartialMaxs, long * GlobalMaxs, int Count) const {
00131   for (int i=0; i<Count; i++) GlobalMaxs[i] = PartialMaxs[i];
00132   return(0);
00133 }
00134 //=============================================================================
00135 int Epetra_SerialComm::MinAll(double * PartialMins, double * GlobalMins, int Count) const {
00136   for (int i=0; i<Count; i++) GlobalMins[i] = PartialMins[i];
00137   return(0);
00138 }
00139 //=============================================================================
00140 int Epetra_SerialComm::MinAll(int * PartialMins, int * GlobalMins, int Count) const {
00141   for (int i=0; i<Count; i++) GlobalMins[i] = PartialMins[i];
00142   return(0);
00143 }
00144 //=============================================================================
00145 int Epetra_SerialComm::MinAll(long * PartialMins, long * GlobalMins, int Count) const {
00146   for (int i=0; i<Count; i++) GlobalMins[i] = PartialMins[i];
00147   return(0);
00148 }
00149 //=============================================================================
00150 int Epetra_SerialComm::ScanSum(double * MyVals, double * ScanSums, int Count) const {
00151   for (int i=0; i<Count; i++) ScanSums[i] = MyVals[i];
00152   return(0);
00153 }
00154 //=============================================================================
00155 int Epetra_SerialComm::ScanSum(int * MyVals, int * ScanSums, int Count) const {
00156   for (int i=0; i<Count; i++) ScanSums[i] = MyVals[i];
00157   return(0);
00158 }
00159 //=============================================================================
00160 int Epetra_SerialComm::ScanSum(long * MyVals, long * ScanSums, int Count) const {
00161   for (int i=0; i<Count; i++) ScanSums[i] = MyVals[i];
00162   return(0);
00163 }
00164 //=============================================================================
00165 Epetra_Distributor * Epetra_SerialComm::CreateDistributor() const {
00166 
00167   Epetra_Distributor * dist = dynamic_cast<Epetra_Distributor *>(new Epetra_SerialDistributor(*this));
00168   return(dist);
00169 }
00170 //=============================================================================
00171 Epetra_Directory * Epetra_SerialComm::CreateDirectory(const Epetra_BlockMap & map) const {
00172 
00173   Epetra_Directory * dir = dynamic_cast<Epetra_Directory *>(new Epetra_BasicDirectory(map));
00174   return(dir);
00175 }
00176 //=============================================================================
00177 Epetra_SerialComm::~Epetra_SerialComm()  {
00178   CleanupData();
00179 }
00180 //=============================================================================
00181 Epetra_SerialComm& Epetra_SerialComm::operator= (const Epetra_SerialComm & Comm) {
00182   if((this != &Comm) && (SerialCommData_ != Comm.SerialCommData_)) {
00183     CleanupData();
00184     SerialCommData_ = Comm.SerialCommData_;
00185     SerialCommData_->IncrementReferenceCount();
00186   }
00187   return(*this);
00188 }
00189 //=============================================================================
00190 void Epetra_SerialComm::CleanupData() {
00191   if(SerialCommData_ != 0) {
00192     SerialCommData_->DecrementReferenceCount();
00193     if(SerialCommData_->ReferenceCount() == 0) {
00194       delete SerialCommData_;
00195       SerialCommData_ = 0;
00196     }
00197   }
00198 }
00199 //=============================================================================
00200 int Epetra_SerialComm::ReferenceCount() const {
00201   return(SerialCommData_->ReferenceCount());
00202 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines