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_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 Import;
00059 #endif // DOXYGEN_SHOULD_SKIP_THIS
00060 
00114   template <class LocalOrdinal,
00115             class GlobalOrdinal = LocalOrdinal,
00116             class Node = KokkosClassic::DefaultNode::DefaultNodeType>
00117   class Export:
00118     public ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>
00119   {
00120   private:
00121     friend class Import<LocalOrdinal,GlobalOrdinal,Node>;
00122   public:
00124     typedef ::Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
00125 
00127 
00128 
00136     Export (const Teuchos::RCP<const map_type>& source,
00137             const Teuchos::RCP<const map_type>& target);
00138 
00149     Export (const Teuchos::RCP<const map_type>& source,
00150             const Teuchos::RCP<const map_type>& target,
00151             const RCP<Teuchos::FancyOStream>& out);
00152 
00165     Export (const Teuchos::RCP<const map_type>& source,
00166             const Teuchos::RCP<const map_type>& target,
00167             const Teuchos::RCP<Teuchos::ParameterList>& plist);
00168 
00184     Export (const Teuchos::RCP<const map_type>& source,
00185             const Teuchos::RCP<const map_type>& target,
00186             const RCP<Teuchos::FancyOStream>& out,
00187             const Teuchos::RCP<Teuchos::ParameterList>& plist);
00188 
00193     Export (const Export<LocalOrdinal,GlobalOrdinal,Node>& rhs);
00194 
00201     Export (const Import<LocalOrdinal,GlobalOrdinal,Node> & importer);
00202 
00204     virtual ~Export ();
00205 
00210     void setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& plist);
00211 
00213 
00214 
00215 
00220     size_t getNumSameIDs() const;
00221 
00228     size_t getNumPermuteIDs() const;
00229 
00231     ArrayView<const LocalOrdinal> getPermuteFromLIDs() const;
00232 
00234     ArrayView<const LocalOrdinal> getPermuteToLIDs() const;
00235 
00237     size_t getNumRemoteIDs() const;
00238 
00240     ArrayView<const LocalOrdinal> getRemoteLIDs() const;
00241 
00243     size_t getNumExportIDs() const;
00244 
00246     ArrayView<const LocalOrdinal> getExportLIDs() const;
00247 
00252     ArrayView<const int> getExportPIDs() const;
00253 
00255     Teuchos::RCP<const map_type> getSourceMap () const;
00256 
00258     Teuchos::RCP<const map_type> getTargetMap () const;
00259 
00261     Distributor & getDistributor() const;
00262 
00264     Export<LocalOrdinal,GlobalOrdinal,Node>&
00265     operator= (const Export<LocalOrdinal,GlobalOrdinal,Node>& rhs);
00266 
00268 
00269 
00270 
00286     virtual void print (std::ostream& os) const;
00287 
00289 
00290   private:
00292     RCP<ImportExportData<LocalOrdinal,GlobalOrdinal,Node> > ExportData_;
00294     Teuchos::RCP<Teuchos::FancyOStream> out_;
00296     bool debug_;
00297 
00299 
00300 
00301     //==============================================================================
00302     // sets up numSameIDs_, numPermuteIDs_, and the export IDs
00303     // these variables are already initialized to 0 by the ImportExportData ctr.
00304     // also sets up permuteToLIDs_, permuteFromLIDs_, and exportLIDs_
00305     void setupSamePermuteExport(Teuchos::Array<GlobalOrdinal> & exportGIDs);
00306     void setupRemote(Teuchos::Array<GlobalOrdinal> & exportGIDs);
00308   }; // class Export
00309 
00320   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00321   Teuchos::RCP<const Export<LocalOrdinal, GlobalOrdinal, Node> >
00322   createExport (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& src,
00323                 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& tgt)
00324   {
00325     if (src == tgt) {
00326       return Teuchos::null;
00327     }
00328 #ifdef HAVE_TPETRA_DEBUG
00329     TEUCHOS_TEST_FOR_EXCEPTION(
00330       src == null || tgt == null, std::runtime_error,
00331       "Tpetra::createExport(): neither source nor target map may be null:"
00332       << std::endl << "source: " << src << std::endl << "target: " << tgt
00333       << std::endl);
00334 #endif // HAVE_TPETRA_DEBUG
00335     return Teuchos::rcp (new Export<LocalOrdinal, GlobalOrdinal, Node> (src, tgt));
00336   }
00337 
00338 } // namespace Tpetra
00339 
00340 #endif // TPETRA_EXPORT_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines