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 2001 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       cerr << "Epetra_SerialDistributor::CreateFromSends: ExportPIDs["<<i
00091           <<"]=="<<ExportPIDs[i]<<", not allowed for serial case."<<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 // GSComm_Comm Do method
00128 int Epetra_SerialDistributor::Do(char * export_objs,
00129                                  int obj_size,
00130                                  int & len_import_objs,
00131                                  char *& import_objs )
00132 {
00133   len_import_objs = obj_size*nrecvs_;
00134   if (len_import_objs > 0) {
00135     import_objs = new char[len_import_objs];
00136   }
00137 
00138   for(int i=0; i<len_import_objs; ++i) import_objs[i] = export_objs[i];
00139 
00140   return(0);
00141 }
00142 
00143 //==============================================================================
00144 // GSComm_Comm DoReverse method
00145 int Epetra_SerialDistributor::DoReverse(char * export_objs,
00146                                         int obj_size,
00147                                         int & len_import_objs,
00148                                         char *& import_objs )
00149 {
00150   (void)export_objs;
00151   (void)obj_size;
00152   (void)len_import_objs;
00153   (void)import_objs;
00154   EPETRA_CHK_ERR(-1); // This method should never be called 
00155   return(-1);
00156 }
00157 //==============================================================================
00158 //---------------------------------------------------------------------------
00159 //Do_Posts Method
00160 //---------------------------------------------------------------------------
00161 int Epetra_SerialDistributor::DoPosts(char * export_objs,
00162                                       int obj_size,
00163                                       int & len_import_objs,
00164                                       char *& import_objs )
00165 {
00166   (void)export_objs;
00167   (void)obj_size;
00168   (void)len_import_objs;
00169   (void)import_objs;
00170   EPETRA_CHK_ERR(-1); // This method should never be called 
00171   return(-1);
00172 }
00173 //==============================================================================
00174 //---------------------------------------------------------------------------
00175 //Do_Waits Method
00176 //---------------------------------------------------------------------------
00177 int Epetra_SerialDistributor::DoWaits()
00178 {
00179   EPETRA_CHK_ERR(-1); // This method should never be called 
00180   return(-1);
00181 }
00182 
00183 //==============================================================================
00184 //---------------------------------------------------------------------------
00185 //DoReverse_Posts Method
00186 //---------------------------------------------------------------------------
00187 int Epetra_SerialDistributor::DoReversePosts(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 //---------------------------------------------------------------------------
00202 //DoReverse_Waits Method
00203 //---------------------------------------------------------------------------
00204 int Epetra_SerialDistributor::DoReverseWaits()
00205 {
00206   EPETRA_CHK_ERR(-1); // This method should never be called 
00207   return(-1);
00208 }
00209 
00210 //==============================================================================
00211 // GSComm_Comm Do method
00212 int Epetra_SerialDistributor::Do(char * export_objs,
00213                                  int obj_size,
00214                                  int *& sizes,
00215                                  int & len_import_objs,
00216                                  char *& import_objs )
00217 {
00218   (void)export_objs;
00219   (void)obj_size;
00220   (void)sizes;
00221   (void)len_import_objs;
00222   (void)import_objs;
00223   EPETRA_CHK_ERR(-1); // This method should never be called 
00224   return(-1);
00225 }
00226 
00227 //==============================================================================
00228 // GSComm_Comm DoReverse method
00229 int Epetra_SerialDistributor::DoReverse(char * export_objs,
00230                                         int obj_size,
00231                                         int *& sizes,
00232                                         int & len_import_objs,
00233                                         char *& import_objs )
00234 {
00235   (void)export_objs;
00236   (void)obj_size;
00237   (void)sizes;
00238   (void)len_import_objs;
00239   (void)import_objs;
00240   EPETRA_CHK_ERR(-1); // This method should never be called 
00241   return(-1);
00242 }
00243 //==============================================================================
00244 //---------------------------------------------------------------------------
00245 //Do_Posts Method
00246 //---------------------------------------------------------------------------
00247 int Epetra_SerialDistributor::DoPosts(char * export_objs,
00248                                       int obj_size,
00249                                       int *& sizes,
00250                                       int & len_import_objs,
00251                                       char *& import_objs )
00252 {
00253   (void)export_objs;
00254   (void)obj_size;
00255   (void)sizes;
00256   (void)len_import_objs;
00257   (void)import_objs;
00258   EPETRA_CHK_ERR(-1); // This method should never be called 
00259   return(-1);
00260 }
00261 
00262 //==============================================================================
00263 //---------------------------------------------------------------------------
00264 //DoReverse_Posts Method
00265 //---------------------------------------------------------------------------
00266 int Epetra_SerialDistributor::DoReversePosts(char * export_objs,
00267                                              int obj_size,
00268                                              int *& sizes,
00269                                              int & len_import_objs,
00270                                              char *& import_objs )
00271 {
00272   (void)export_objs;
00273   (void)obj_size;
00274   (void)sizes;
00275   (void)len_import_objs;
00276   (void)import_objs;
00277   EPETRA_CHK_ERR(-1); // This method should never be called 
00278   return(-1);
00279 }
00280 
00281 //==============================================================================
00282 void Epetra_SerialDistributor::Print( ostream & os) const
00283 {
00284   os << "Trivial Distributor" << endl;
00285   return;
00286 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines