Tpetra Matrix/Vector Services Version of the Day
Tpetra_Import_decl.hpp
00001 // @HEADER
00002 // ***********************************************************************
00003 //
00004 //          Tpetra: Templated Linear Algebra Services Package
00005 //                 Copyright (2008) Sandia Corporation
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ************************************************************************
00040 // @HEADER
00041 
00042 #ifndef TPETRA_IMPORT_DECL_HPP
00043 #define TPETRA_IMPORT_DECL_HPP
00044 
00045 #include <Tpetra_Details_Transfer.hpp>
00046 
00047 namespace Tpetra {
00048   //
00049   // Forward declarations.  The "doxygen" bit simply tells Doxygen
00050   // (our automatic documentation generation system) to skip forward
00051   // declarations.
00052   //
00053 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00054   template<class LocalOrdinal, class GlobalOrdinal, class Node>
00055   class ImportExportData;
00056 
00057   template<class LocalOrdinal, class GlobalOrdinal, class Node>
00058   class Export;
00059 #endif // DOXYGEN_SHOULD_SKIP_THIS
00060 
00114   template <class LocalOrdinal,
00115             class GlobalOrdinal = LocalOrdinal,
00116             class Node = KokkosClassic::DefaultNode::DefaultNodeType>
00117   class Import:
00118     public ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>
00119   {
00120   private:
00121     friend class Export<LocalOrdinal,GlobalOrdinal,Node>;
00122   public:
00124     //typedef typename ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>::map_type map_type;
00125     typedef ::Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
00126 
00128 
00129 
00137     Import (const Teuchos::RCP<const map_type>& source,
00138             const Teuchos::RCP<const map_type>& target);
00139 
00150     Import (const Teuchos::RCP<const map_type>& source,
00151             const Teuchos::RCP<const map_type>& target,
00152             const RCP<Teuchos::FancyOStream>& out);
00153 
00166     Import (const Teuchos::RCP<const map_type>& source,
00167             const Teuchos::RCP<const map_type>& target,
00168             const Teuchos::RCP<Teuchos::ParameterList>& plist);
00169 
00185     Import (const Teuchos::RCP<const map_type>& source,
00186             const Teuchos::RCP<const map_type>& target,
00187             const RCP<Teuchos::FancyOStream>& out,
00188             const Teuchos::RCP<Teuchos::ParameterList>& plist);
00189 
00201     Import (const Teuchos::RCP<const map_type>& source,
00202             const Teuchos::RCP<const map_type>& target,
00203             Teuchos::Array<int> & remotePIDs);
00204 
00209     Import (const Import<LocalOrdinal,GlobalOrdinal,Node>& importer);
00210 
00217     Import (const Export<LocalOrdinal,GlobalOrdinal,Node>& exporter);
00218 
00220     virtual ~Import ();
00221 
00226     void setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& plist);
00227 
00229 
00230 
00231 
00236     size_t getNumSameIDs() const;
00237 
00244     size_t getNumPermuteIDs() const;
00245 
00247     ArrayView<const LocalOrdinal> getPermuteFromLIDs() const;
00248 
00250     ArrayView<const LocalOrdinal> getPermuteToLIDs() const;
00251 
00253     size_t getNumRemoteIDs() const;
00254 
00256     ArrayView<const LocalOrdinal> getRemoteLIDs() const;
00257 
00259     size_t getNumExportIDs() const;
00260 
00262     ArrayView<const LocalOrdinal> getExportLIDs() const;
00263 
00268     ArrayView<const int> getExportPIDs() const;
00269 
00271     Teuchos::RCP<const map_type> getSourceMap () const;
00272 
00274     Teuchos::RCP<const map_type> getTargetMap () const;
00275 
00277     Distributor & getDistributor() const;
00278 
00280     Import<LocalOrdinal,GlobalOrdinal,Node>&
00281     operator= (const Import<LocalOrdinal,GlobalOrdinal,Node>& Source);
00282 
00316     Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
00317     setUnion (const Import<LocalOrdinal, GlobalOrdinal, Node>& rhs) const;
00318 
00335     Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
00336     setUnion () const;
00337 
00338 
00343     Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
00344     createRemoteOnlyImport (const Teuchos::RCP<const map_type>& remoteTarget) const;
00345 
00346 
00348 
00349 
00350 
00366     virtual void print (std::ostream& os) const;
00367 
00369 
00370   private:
00372     RCP<ImportExportData<LocalOrdinal,GlobalOrdinal,Node> > ImportData_;
00374     RCP<Teuchos::FancyOStream> out_;
00376     bool debug_;
00377 
00379 
00380 
00397     void
00398     init (const Teuchos::RCP<const map_type>& source,
00399           const Teuchos::RCP<const map_type>& target,
00400           bool useRemotePIDs,
00401           Teuchos::Array<int> & remotePIDs,
00402           const Teuchos::RCP<Teuchos::ParameterList>& plist);
00403 
00435     void setupSamePermuteRemote (Teuchos::Array<GlobalOrdinal>& remoteGIDs);
00436 
00465     void
00466     setupExport (Teuchos::Array<GlobalOrdinal>& remoteGIDs, bool useRemotePIDs, Teuchos::Array<int> & remotePIDs);
00468 
00469 
00477     Import (const Teuchos::RCP<const map_type>& source,
00478             const Teuchos::RCP<const map_type>& target,
00479             const size_t numSameIDs,
00480             Teuchos::Array<LocalOrdinal>& permuteToLIDs,
00481             Teuchos::Array<LocalOrdinal>& permuteFromLIDs,
00482             Teuchos::Array<LocalOrdinal>& remoteLIDs,
00483             Teuchos::Array<LocalOrdinal>& exportLIDs,
00484             Teuchos::Array<int>& exportPIDs,
00485             Distributor& distributor,
00486             const Teuchos::RCP<Teuchos::FancyOStream>& out = Teuchos::null,
00487             const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::null);
00488 
00489 
00490   }; // class Import
00491 
00502   template<class LocalOrdinal, class GlobalOrdinal, class Node>
00503   Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
00504   createImport (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& src,
00505                 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& tgt)
00506   {
00507     if (src == tgt) {
00508       return Teuchos::null;
00509     }
00510 #ifdef HAVE_TPETRA_DEBUG
00511     TEUCHOS_TEST_FOR_EXCEPTION(
00512       src == null || tgt == null, std::runtime_error,
00513       "Tpetra::createImport(): neither source nor target map may be null:"
00514       << std::endl << "source: " << src << std::endl << "target: " << tgt
00515       << std::endl);
00516 #endif // HAVE_TPETRA_DEBUG
00517     typedef Import<LocalOrdinal, GlobalOrdinal, Node> import_type;
00518     return Teuchos::rcp (new import_type (src, tgt));
00519   }
00520 
00532   template<class LocalOrdinal, class GlobalOrdinal, class Node>
00533   Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
00534   createImport (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& src,
00535                 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& tgt,
00536                 const Teuchos::RCP<Teuchos::ParameterList>& plist)
00537   {
00538     if (src == tgt) {
00539       return Teuchos::null;
00540     }
00541 #ifdef HAVE_TPETRA_DEBUG
00542     TEUCHOS_TEST_FOR_EXCEPTION(
00543       src == null || tgt == null, std::runtime_error,
00544       "Tpetra::createImport(): neither source nor target map may be null:"
00545       << std::endl << "source: " << src << std::endl << "target: " << tgt
00546       << std::endl);
00547 #endif // HAVE_TPETRA_DEBUG
00548     typedef Import<LocalOrdinal, GlobalOrdinal, Node> import_type;
00549     return Teuchos::rcp (new import_type (src, tgt, plist));
00550   }
00551 
00552 } // namespace Tpetra
00553 
00554 #endif // TPETRA_IMPORT_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines