Tpetra Matrix/Vector Services Version of the Day
Tpetra_Export_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_EXPORT_DECL_HPP
00043 #define TPETRA_EXPORT_DECL_HPP
00044 
00045 #include <Tpetra_ConfigDefs.hpp>
00046 #include <Kokkos_DefaultNode.hpp>
00047 #include <Teuchos_Describable.hpp>
00048 
00049 namespace Tpetra {
00050   //
00051   // Forward declarations.  The "doxygen" bit simply tells Doxygen
00052   // (our automatic documentation generation system) to skip forward
00053   // declarations.
00054   //
00055 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00056   class Distributor;
00057 
00058   template<class LocalOrdinal, class GlobalOrdinal, class Node>
00059   class ImportExportData;
00060 
00061   template<class LocalOrdinal, class GlobalOrdinal, class Node>
00062   class Import;
00063 
00064   template<class LocalOrdinal, class GlobalOrdinal, class Node>
00065   class Map;
00066 #endif // DOXYGEN_SHOULD_SKIP_THIS
00067 
00121   template <class LocalOrdinal,
00122             class GlobalOrdinal = LocalOrdinal,
00123             class Node = KokkosClassic::DefaultNode::DefaultNodeType>
00124   class Export: public Teuchos::Describable {
00125       friend class Import<LocalOrdinal,GlobalOrdinal,Node>;
00126   public:
00128     typedef Map<LocalOrdinal,GlobalOrdinal,Node> map_type;
00129 
00131 
00132 
00140     Export (const Teuchos::RCP<const map_type>& source,
00141             const Teuchos::RCP<const map_type>& target);
00142 
00153     Export (const Teuchos::RCP<const map_type>& source,
00154             const Teuchos::RCP<const map_type>& target,
00155             const RCP<Teuchos::FancyOStream>& out);
00156 
00169     Export (const Teuchos::RCP<const map_type>& source,
00170             const Teuchos::RCP<const map_type>& target,
00171             const Teuchos::RCP<Teuchos::ParameterList>& plist);
00172 
00188     Export (const Teuchos::RCP<const map_type>& source,
00189             const Teuchos::RCP<const map_type>& target,
00190             const RCP<Teuchos::FancyOStream>& out,
00191             const Teuchos::RCP<Teuchos::ParameterList>& plist);
00192 
00197     Export (const Export<LocalOrdinal,GlobalOrdinal,Node>& rhs);
00198 
00205     Export (const Import<LocalOrdinal,GlobalOrdinal,Node> & importer);
00206 
00208     ~Export();
00209 
00214     void setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& plist);
00215 
00217 
00218 
00219 
00224     size_t getNumSameIDs() const;
00225 
00232     size_t getNumPermuteIDs() const;
00233 
00235     ArrayView<const LocalOrdinal> getPermuteFromLIDs() const;
00236 
00238     ArrayView<const LocalOrdinal> getPermuteToLIDs() const;
00239 
00241     size_t getNumRemoteIDs() const;
00242 
00244     ArrayView<const LocalOrdinal> getRemoteLIDs() const;
00245 
00247     size_t getNumExportIDs() const;
00248 
00250     ArrayView<const LocalOrdinal> getExportLIDs() const;
00251 
00256     ArrayView<const int> getExportPIDs() const;
00257 
00259     Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > 
00260     getSourceMap () const;
00261 
00263     Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > 
00264     getTargetMap () const;
00265 
00267     Distributor & getDistributor() const;
00268 
00270     Export<LocalOrdinal,GlobalOrdinal,Node>&
00271     operator= (const Export<LocalOrdinal,GlobalOrdinal,Node>& rhs);
00272 
00274 
00275 
00276 
00292     virtual void print (std::ostream& os) const;
00293 
00295 
00296   private:
00298     RCP<ImportExportData<LocalOrdinal,GlobalOrdinal,Node> > ExportData_;
00300     Teuchos::RCP<Teuchos::FancyOStream> out_;
00302     bool debug_;
00303 
00305 
00306 
00307     //==============================================================================
00308     // sets up numSameIDs_, numPermuteIDs_, and the export IDs
00309     // these variables are already initialized to 0 by the ImportExportData ctr.
00310     // also sets up permuteToLIDs_, permuteFromLIDs_, and exportLIDs_
00311     void setupSamePermuteExport(Teuchos::Array<GlobalOrdinal> & exportGIDs);
00312     void setupRemote(Teuchos::Array<GlobalOrdinal> & exportGIDs);
00314   }; // class Export
00315 
00326   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00327   Teuchos::RCP<const Export<LocalOrdinal, GlobalOrdinal, Node> >
00328   createExport (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& src,
00329                 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& tgt)
00330   {
00331     if (src == tgt) {
00332       return Teuchos::null;
00333     }
00334 #ifdef HAVE_TPETRA_DEBUG
00335     TEUCHOS_TEST_FOR_EXCEPTION(
00336       src == null || tgt == null, std::runtime_error,
00337       "Tpetra::createExport(): neither source nor target map may be null:"
00338       << std::endl << "source: " << src << std::endl << "target: " << tgt
00339       << std::endl);
00340 #endif // HAVE_TPETRA_DEBUG
00341     return Teuchos::rcp (new Export<LocalOrdinal, GlobalOrdinal, Node> (src, tgt));
00342   }
00343 } // namespace Tpetra
00344 
00345 #endif // TPETRA_EXPORT_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines