Tpetra parallel linear algebra  Version of the Day
Tpetra_Export_decl.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Tpetra: Templated Linear Algebra Services Package
5 // Copyright (2008) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ************************************************************************
40 // @HEADER
41 
42 #ifndef TPETRA_EXPORT_DECL_HPP
43 #define TPETRA_EXPORT_DECL_HPP
44 
45 #include "Tpetra_Details_Transfer.hpp"
46 #include "Tpetra_Export_fwd.hpp"
47 #include "Tpetra_Import_fwd.hpp"
49 #include "Teuchos_ArrayView.hpp"
50 #include "Teuchos_RCP.hpp"
51 
52 #ifndef DOXYGEN_SHOULD_SKIP_THIS
53 namespace Teuchos {
54 template<class T> class Array; // forward declaration
55 class ParameterList; // forward declaration
56 } // namespace Teuchos
57 #endif // DOXYGEN_SHOULD_SKIP_THIS
58 
59 namespace Tpetra {
60 namespace Classes {
121  template<class LocalOrdinal = ::Tpetra::Details::DefaultTypes::local_ordinal_type,
122  class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
124  class Export:
125  public ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>
126  {
127  private:
128  friend class Import<LocalOrdinal,GlobalOrdinal,Node>;
129  public:
131  typedef ::Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> map_type;
132 
134 
135 
143  Export (const Teuchos::RCP<const map_type>& source,
144  const Teuchos::RCP<const map_type>& target);
145 
156  Export (const Teuchos::RCP<const map_type>& source,
157  const Teuchos::RCP<const map_type>& target,
158  const Teuchos::RCP<Teuchos::FancyOStream>& out);
159 
172  Export (const Teuchos::RCP<const map_type>& source,
173  const Teuchos::RCP<const map_type>& target,
174  const Teuchos::RCP<Teuchos::ParameterList>& plist);
175 
191  Export (const Teuchos::RCP<const map_type>& source,
192  const Teuchos::RCP<const map_type>& target,
193  const Teuchos::RCP<Teuchos::FancyOStream>& out,
194  const Teuchos::RCP<Teuchos::ParameterList>& plist);
195 
201 
209 
211  virtual ~Export ();
212 
217  void setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& plist);
218 
220 
222 
227  size_t getNumSameIDs() const;
228 
235  size_t getNumPermuteIDs() const;
236 
238  Teuchos::ArrayView<const LocalOrdinal> getPermuteFromLIDs() const;
239 
241  Teuchos::ArrayView<const LocalOrdinal> getPermuteToLIDs() const;
242 
244  size_t getNumRemoteIDs() const;
245 
247  Teuchos::ArrayView<const LocalOrdinal> getRemoteLIDs() const;
248 
250  size_t getNumExportIDs() const;
251 
253  Teuchos::ArrayView<const LocalOrdinal> getExportLIDs() const;
254 
259  Teuchos::ArrayView<const int> getExportPIDs() const;
260 
262  Teuchos::RCP<const map_type> getSourceMap () const;
263 
265  Teuchos::RCP<const map_type> getTargetMap () const;
266 
268  Distributor & getDistributor() const;
269 
278  bool isLocallyComplete () const;
279 
283 
285 
287 
310  virtual void
311  describe (Teuchos::FancyOStream& out,
312  const Teuchos::EVerbosityLevel verbLevel =
313  Teuchos::Describable::verbLevel_default) const;
314 
330  virtual void print (std::ostream& os) const;
331 
333 
334  private:
336  Teuchos::RCP<ImportExportData<LocalOrdinal,GlobalOrdinal,Node> > ExportData_;
338  Teuchos::RCP<Teuchos::FancyOStream> out_;
340  bool debug_;
341 
343 
344 
345  //==============================================================================
346  // sets up numSameIDs_, numPermuteIDs_, and the export IDs
347  // these variables are already initialized to 0 by the ImportExportData ctr.
348  // also sets up permuteToLIDs_, permuteFromLIDs_, and exportLIDs_
349  void setupSamePermuteExport(Teuchos::Array<GlobalOrdinal> & exportGIDs);
350  void setupRemote(Teuchos::Array<GlobalOrdinal> & exportGIDs);
352  }; // class Export
353 } // namespace Classes
354 
365  template <class LocalOrdinal, class GlobalOrdinal, class Node>
366  Teuchos::RCP<const Export<LocalOrdinal, GlobalOrdinal, Node> >
367  createExport (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& src,
368  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& tgt)
369  {
370  if (src == tgt) {
371  return Teuchos::null;
372  }
373 #ifdef HAVE_TPETRA_DEBUG
374  TEUCHOS_TEST_FOR_EXCEPTION(
375  src == Teuchos::null || tgt == Teuchos::null, std::runtime_error,
376  "Tpetra::createExport(): neither source nor target map may be null:"
377  << std::endl << "source: " << src << std::endl << "target: " << tgt
378  << std::endl);
379 #endif // HAVE_TPETRA_DEBUG
380  return Teuchos::rcp (new Export<LocalOrdinal, GlobalOrdinal, Node> (src, tgt));
381  }
382 
383 } // namespace Tpetra
384 
385 #endif // TPETRA_EXPORT_DECL_HPP
Tpetra::Classes::Export::setParameterList
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
Set parameters.
Definition: Tpetra_Export_def.hpp:65
Tpetra_Export_fwd.hpp
Forward declaration of Tpetra::Export.
Tpetra::Classes::Export::getNumRemoteIDs
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
Definition: Tpetra_Export_def.hpp:334
Tpetra::Details::DefaultTypes::node_type
::Kokkos::Compat::KokkosDeviceWrapperNode< execution_space > node_type
Default value of Node template parameter.
Definition: Tpetra_Details_DefaultTypes.hpp:105
Tpetra_Import_fwd.hpp
Forward declaration of Tpetra::Import.
Tpetra::Classes::Export::getDistributor
Distributor & getDistributor() const
The Distributor that this Export object uses to move data.
Definition: Tpetra_Export_def.hpp:375
Tpetra::Classes::Export::~Export
virtual ~Export()
Destructor.
Definition: Tpetra_Export_def.hpp:308
Tpetra::Classes::Export::getPermuteFromLIDs
Teuchos::ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
Definition: Tpetra_Export_def.hpp:323
Tpetra::Classes::Export::getSourceMap
Teuchos::RCP< const map_type > getSourceMap() const
The source Map used to construct this Export.
Definition: Tpetra_Export_def.hpp:363
Tpetra::Classes::Export::Export
Export(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct a Export object from the source and target Map.
Definition: Tpetra_Export_def.hpp:79
Tpetra::Classes::Export::getRemoteLIDs
Teuchos::ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
Definition: Tpetra_Export_def.hpp:340
Tpetra::Classes::Export::getTargetMap
Teuchos::RCP< const map_type > getTargetMap() const
The target Map used to construct this Export.
Definition: Tpetra_Export_def.hpp:369
Tpetra::Classes::Export::getPermuteToLIDs
Teuchos::ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
Definition: Tpetra_Export_def.hpp:329
Tpetra::Classes::Import
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
Definition: Tpetra_Import_decl.hpp:115
Tpetra::Distributor
Sets up and executes a communication plan for a Tpetra DistObject.
Definition: Tpetra_Distributor.hpp:188
Tpetra::Classes::Export::describe
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Describe this object in a human-readable way to the given output stream.
Definition: Tpetra_Export_def.hpp:398
Tpetra::Classes::Export::map_type
::Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
Definition: Tpetra_Export_decl.hpp:131
Tpetra::Details::DefaultTypes::local_ordinal_type
int local_ordinal_type
Default value of Scalar template parameter.
Definition: Tpetra_Details_DefaultTypes.hpp:72
Tpetra::Classes::Export::print
virtual void print(std::ostream &os) const
Print the Export's data to the given output stream.
Definition: Tpetra_Export_def.hpp:407
Tpetra::Details::Classes::Transfer
Common base class of Import and Export.
Definition: Tpetra_Details_Transfer_decl.hpp:69
Tpetra::Classes::Export::getExportLIDs
Teuchos::ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
Definition: Tpetra_Export_def.hpp:351
Tpetra::Classes::Map
A parallel distribution of indices over processes.
Definition: Tpetra_Map_decl.hpp:247
Tpetra::Classes::Export::getExportPIDs
Teuchos::ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
Definition: Tpetra_Export_def.hpp:357
Tpetra::Classes::Export::isLocallyComplete
bool isLocallyComplete() const
Do all source Map indices on the calling process exist on at least one process (not necessarily this ...
Definition: Tpetra_Export_def.hpp:381
Tpetra::Classes::Export::getNumPermuteIDs
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
Definition: Tpetra_Export_def.hpp:317
Tpetra::Classes::Export::getNumSameIDs
size_t getNumSameIDs() const
Number of initial identical IDs.
Definition: Tpetra_Export_def.hpp:312
Tpetra_ImportExportData_fwd.hpp
Forward declaration of Tpetra::ImportExportData.
Tpetra
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Tpetra::Classes::Export::getNumExportIDs
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
Definition: Tpetra_Export_def.hpp:345
Tpetra::createExport
Teuchos::RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > createExport(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &src, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &tgt)
Non-member constructor for Export objects.
Definition: Tpetra_Export_decl.hpp:367
Tpetra::Classes::Export
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
Definition: Tpetra_Export_decl.hpp:124
Tpetra::Classes::Export::operator=
Export< LocalOrdinal, GlobalOrdinal, Node > & operator=(const Export< LocalOrdinal, GlobalOrdinal, Node > &rhs)
Assignment operator.
Definition: Tpetra_Export_def.hpp:388