Epetra Package Browser (Single Doxygen Collection) Development
Epetra_SerialDistributor.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_SerialDistributor.h"
00044 #include "Epetra_SerialComm.h"
00045 
00046 
00047 //==============================================================================
00048 // Epetra_SerialDistributor constructor
00049 Epetra_SerialDistributor::Epetra_SerialDistributor(const Epetra_SerialComm & Comm)
00050   : Epetra_Object("Epetra::SerialDistributor"),
00051     nrecvs_(0),
00052     nsends_(0)
00053 {
00054   (void)Comm;
00055 }
00056 
00057 //==============================================================================
00058 Epetra_SerialDistributor::Epetra_SerialDistributor(const Epetra_SerialDistributor & Plan)
00059   : Epetra_Object("Epetra::SerialDistributor"),
00060     nrecvs_(Plan.nrecvs_),
00061     nsends_(Plan.nsends_)
00062 {
00063 }
00064 
00065 //==============================================================================
00066 // Epetra_SerialDistributor destructor
00067 Epetra_SerialDistributor::~Epetra_SerialDistributor() {
00068 }
00069 
00070 
00071 //==============================================================================
00072 //---------------------------------------------------------------------------
00073 //CreateFromSends Method
00074 // - create communication plan given a known list of procs to send to
00075 //---------------------------------------------------------------------------
00076 int Epetra_SerialDistributor::CreateFromSends( const int & NumExportIDs,
00077                  const int * ExportPIDs,
00078                  bool Deterministic,
00079                  int & NumRemoteIDs )
00080 {
00081   (void)Deterministic;
00082   NumRemoteIDs = 0;
00083 
00084   //In a SerialDistributor, myproc == 0 by definition.
00085   int myproc = 0;
00086 
00087   //basically just do a sanity check.
00088   for(int i=0; i<NumExportIDs; ++i) {
00089     if (ExportPIDs[i] != myproc) {
00090       std::cerr << "Epetra_SerialDistributor::CreateFromSends: ExportPIDs["<<i
00091           <<"]=="<<ExportPIDs[i]<<", not allowed for serial case."<< std::endl;
00092       return(-1);
00093     }
00094     ++NumRemoteIDs;
00095   }
00096 
00097   nrecvs_ = NumRemoteIDs;
00098 
00099   return(0);
00100 }
00101 
00102 //==============================================================================
00103 //---------------------------------------------------------------------------
00104 //CreateFromRecvs Method
00105 // - create communication plan given a known list of procs to recv from
00106 //---------------------------------------------------------------------------
00107 int Epetra_SerialDistributor::CreateFromRecvs( const int & NumRemoteIDs,
00108            const int * RemoteGIDs,
00109                  const int * RemotePIDs,
00110            bool Deterministic,
00111                  int & NumExportIDs,
00112            int *& ExportGIDs,
00113            int *& ExportPIDs )
00114 {
00115   (void)NumRemoteIDs;
00116   (void)RemoteGIDs;
00117   (void)RemotePIDs;
00118   (void)Deterministic;
00119   (void)NumExportIDs;
00120   (void)ExportGIDs;
00121   (void)ExportPIDs;
00122   EPETRA_CHK_ERR(-1); // This method should never be called
00123   return(-1);
00124 }
00125 
00126 //==============================================================================
00127 //---------------------------------------------------------------------------
00128 //CreateFromRecvs Method
00129 // - create communication plan given a known list of procs to recv from
00130 //---------------------------------------------------------------------------
00131 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00132 int Epetra_SerialDistributor::CreateFromRecvs( const int & NumRemoteIDs,
00133            const long long * RemoteGIDs,
00134                  const int * RemotePIDs,
00135            bool Deterministic,
00136                  int & NumExportIDs,
00137            long long *& ExportGIDs,
00138            int *& ExportPIDs )
00139 {
00140   (void)NumRemoteIDs;
00141   (void)RemoteGIDs;
00142   (void)RemotePIDs;
00143   (void)Deterministic;
00144   (void)NumExportIDs;
00145   (void)ExportGIDs;
00146   (void)ExportPIDs;
00147   EPETRA_CHK_ERR(-1); // This method should never be called
00148   return(-1);
00149 }
00150 #endif
00151 
00152 //==============================================================================
00153 // GSComm_Comm Do method
00154 int Epetra_SerialDistributor::Do(char * export_objs,
00155                                  int obj_size,
00156                                  int & len_import_objs,
00157                                  char *& import_objs )
00158 {
00159   len_import_objs = obj_size*nrecvs_;
00160   if (len_import_objs > 0) {
00161     import_objs = new char[len_import_objs];
00162   }
00163 
00164   for(int i=0; i<len_import_objs; ++i) import_objs[i] = export_objs[i];
00165 
00166   return(0);
00167 }
00168 
00169 //==============================================================================
00170 // GSComm_Comm DoReverse method
00171 int Epetra_SerialDistributor::DoReverse(char * export_objs,
00172                                         int obj_size,
00173                                         int & len_import_objs,
00174                                         char *& import_objs )
00175 {
00176   (void)export_objs;
00177   (void)obj_size;
00178   (void)len_import_objs;
00179   (void)import_objs;
00180   EPETRA_CHK_ERR(-1); // This method should never be called
00181   return(-1);
00182 }
00183 //==============================================================================
00184 //---------------------------------------------------------------------------
00185 //Do_Posts Method
00186 //---------------------------------------------------------------------------
00187 int Epetra_SerialDistributor::DoPosts(char * export_objs,
00188                                       int obj_size,
00189                                       int & len_import_objs,
00190                                       char *& import_objs )
00191 {
00192   (void)export_objs;
00193   (void)obj_size;
00194   (void)len_import_objs;
00195   (void)import_objs;
00196   EPETRA_CHK_ERR(-1); // This method should never be called
00197   return(-1);
00198 }
00199 //==============================================================================
00200 //---------------------------------------------------------------------------
00201 //Do_Waits Method
00202 //---------------------------------------------------------------------------
00203 int Epetra_SerialDistributor::DoWaits()
00204 {
00205   EPETRA_CHK_ERR(-1); // This method should never be called
00206   return(-1);
00207 }
00208 
00209 //==============================================================================
00210 //---------------------------------------------------------------------------
00211 //DoReverse_Posts Method
00212 //---------------------------------------------------------------------------
00213 int Epetra_SerialDistributor::DoReversePosts(char * export_objs,
00214                                              int obj_size,
00215                                              int & len_import_objs,
00216                                              char *& import_objs )
00217 {
00218   (void)export_objs;
00219   (void)obj_size;
00220   (void)len_import_objs;
00221   (void)import_objs;
00222   EPETRA_CHK_ERR(-1); // This method should never be called
00223   return(-1);
00224 }
00225 
00226 //==============================================================================
00227 //---------------------------------------------------------------------------
00228 //DoReverse_Waits Method
00229 //---------------------------------------------------------------------------
00230 int Epetra_SerialDistributor::DoReverseWaits()
00231 {
00232   EPETRA_CHK_ERR(-1); // This method should never be called
00233   return(-1);
00234 }
00235 
00236 //==============================================================================
00237 // GSComm_Comm Do method
00238 int Epetra_SerialDistributor::Do(char * export_objs,
00239                                  int obj_size,
00240                                  int *& sizes,
00241                                  int & len_import_objs,
00242                                  char *& import_objs )
00243 {
00244   (void)export_objs;
00245   (void)obj_size;
00246   (void)sizes;
00247   (void)len_import_objs;
00248   (void)import_objs;
00249   EPETRA_CHK_ERR(-1); // This method should never be called
00250   return(-1);
00251 }
00252 
00253 //==============================================================================
00254 // GSComm_Comm DoReverse method
00255 int Epetra_SerialDistributor::DoReverse(char * export_objs,
00256                                         int obj_size,
00257                                         int *& sizes,
00258                                         int & len_import_objs,
00259                                         char *& import_objs )
00260 {
00261   (void)export_objs;
00262   (void)obj_size;
00263   (void)sizes;
00264   (void)len_import_objs;
00265   (void)import_objs;
00266   EPETRA_CHK_ERR(-1); // This method should never be called
00267   return(-1);
00268 }
00269 //==============================================================================
00270 //---------------------------------------------------------------------------
00271 //Do_Posts Method
00272 //---------------------------------------------------------------------------
00273 int Epetra_SerialDistributor::DoPosts(char * export_objs,
00274                                       int obj_size,
00275                                       int *& sizes,
00276                                       int & len_import_objs,
00277                                       char *& import_objs )
00278 {
00279   (void)export_objs;
00280   (void)obj_size;
00281   (void)sizes;
00282   (void)len_import_objs;
00283   (void)import_objs;
00284   EPETRA_CHK_ERR(-1); // This method should never be called
00285   return(-1);
00286 }
00287 
00288 //==============================================================================
00289 //---------------------------------------------------------------------------
00290 //DoReverse_Posts Method
00291 //---------------------------------------------------------------------------
00292 int Epetra_SerialDistributor::DoReversePosts(char * export_objs,
00293                                              int obj_size,
00294                                              int *& sizes,
00295                                              int & len_import_objs,
00296                                              char *& import_objs )
00297 {
00298   (void)export_objs;
00299   (void)obj_size;
00300   (void)sizes;
00301   (void)len_import_objs;
00302   (void)import_objs;
00303   EPETRA_CHK_ERR(-1); // This method should never be called
00304   return(-1);
00305 }
00306 
00307 //==============================================================================
00308 void Epetra_SerialDistributor::Print(std::ostream & os) const
00309 {
00310   os << "Trivial Distributor" << std::endl;
00311   return;
00312 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines