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 
00121   template <class LocalOrdinal = int,
00122             class GlobalOrdinal = LocalOrdinal,
00123             class Node = KokkosClassic::DefaultNode::DefaultNodeType>
00124   class Export:
00125     public ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>
00126   {
00127   private:
00128     friend class Import<LocalOrdinal,GlobalOrdinal,Node>;
00129   public:
00131     typedef ::Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
00132 
00134 
00135 
00143     Export (const Teuchos::RCP<const map_type>& source,
00144             const Teuchos::RCP<const map_type>& target);
00145 
00156     Export (const Teuchos::RCP<const map_type>& source,
00157             const Teuchos::RCP<const map_type>& target,
00158             const RCP<Teuchos::FancyOStream>& out);
00159 
00172     Export (const Teuchos::RCP<const map_type>& source,
00173             const Teuchos::RCP<const map_type>& target,
00174             const Teuchos::RCP<Teuchos::ParameterList>& plist);
00175 
00191     Export (const Teuchos::RCP<const map_type>& source,
00192             const Teuchos::RCP<const map_type>& target,
00193             const RCP<Teuchos::FancyOStream>& out,
00194             const Teuchos::RCP<Teuchos::ParameterList>& plist);
00195 
00200     Export (const Export<LocalOrdinal,GlobalOrdinal,Node>& rhs);
00201 
00208     Export (const Import<LocalOrdinal,GlobalOrdinal,Node> & importer);
00209 
00211     virtual ~Export ();
00212 
00217     void setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& plist);
00218 
00220 
00221 
00222 
00227     size_t getNumSameIDs() const;
00228 
00235     size_t getNumPermuteIDs() const;
00236 
00238     ArrayView<const LocalOrdinal> getPermuteFromLIDs() const;
00239 
00241     ArrayView<const LocalOrdinal> getPermuteToLIDs() const;
00242 
00244     size_t getNumRemoteIDs() const;
00245 
00247     ArrayView<const LocalOrdinal> getRemoteLIDs() const;
00248 
00250     size_t getNumExportIDs() const;
00251 
00253     ArrayView<const LocalOrdinal> getExportLIDs() const;
00254 
00259     ArrayView<const int> getExportPIDs() const;
00260 
00262     Teuchos::RCP<const map_type> getSourceMap () const;
00263 
00265     Teuchos::RCP<const map_type> getTargetMap () const;
00266 
00268     Distributor & getDistributor() const;
00269 
00271     Export<LocalOrdinal,GlobalOrdinal,Node>&
00272     operator= (const Export<LocalOrdinal,GlobalOrdinal,Node>& rhs);
00273 
00275 
00276 
00277 
00293     virtual void print (std::ostream& os) const;
00294 
00296 
00297   private:
00299     RCP<ImportExportData<LocalOrdinal,GlobalOrdinal,Node> > ExportData_;
00301     Teuchos::RCP<Teuchos::FancyOStream> out_;
00303     bool debug_;
00304 
00306 
00307 
00308     //==============================================================================
00309     // sets up numSameIDs_, numPermuteIDs_, and the export IDs
00310     // these variables are already initialized to 0 by the ImportExportData ctr.
00311     // also sets up permuteToLIDs_, permuteFromLIDs_, and exportLIDs_
00312     void setupSamePermuteExport(Teuchos::Array<GlobalOrdinal> & exportGIDs);
00313     void setupRemote(Teuchos::Array<GlobalOrdinal> & exportGIDs);
00315   }; // class Export
00316 
00327   template <class LocalOrdinal, class GlobalOrdinal, class Node>
00328   Teuchos::RCP<const Export<LocalOrdinal, GlobalOrdinal, Node> >
00329   createExport (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& src,
00330                 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& tgt)
00331   {
00332     if (src == tgt) {
00333       return Teuchos::null;
00334     }
00335 #ifdef HAVE_TPETRA_DEBUG
00336     TEUCHOS_TEST_FOR_EXCEPTION(
00337       src == null || tgt == null, std::runtime_error,
00338       "Tpetra::createExport(): neither source nor target map may be null:"
00339       << std::endl << "source: " << src << std::endl << "target: " << tgt
00340       << std::endl);
00341 #endif // HAVE_TPETRA_DEBUG
00342     return Teuchos::rcp (new Export<LocalOrdinal, GlobalOrdinal, Node> (src, tgt));
00343   }
00344 
00345 } // namespace Tpetra
00346 
00347 #endif // TPETRA_EXPORT_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines