Tpetra Matrix/Vector Services  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Tpetra_Import_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_IMPORT_DECL_HPP
43 #define TPETRA_IMPORT_DECL_HPP
44 
45 #include <Tpetra_ConfigDefs.hpp>
46 #include <Kokkos_DefaultNode.hpp>
47 #include <Teuchos_Describable.hpp>
48 
49 namespace Tpetra {
50  //
51  // Forward declarations. The "doxygen" bit simply tells Doxygen
52  // (our automatic documentation generation system) to skip forward
53  // declarations.
54  //
55 #ifndef DOXYGEN_SHOULD_SKIP_THIS
56  class Distributor;
57 
58  template<class LocalOrdinal, class GlobalOrdinal, class Node>
59  class ImportExportData;
60 
61  template<class LocalOrdinal, class GlobalOrdinal, class Node>
62  class Export;
63 
64  template<class LocalOrdinal, class GlobalOrdinal, class Node>
65  class Map;
66 #endif // DOXYGEN_SHOULD_SKIP_THIS
67 
121  template <class LocalOrdinal,
122  class GlobalOrdinal = LocalOrdinal,
123  class Node = Kokkos::DefaultNode::DefaultNodeType>
124  class Import: public Teuchos::Describable {
125  friend class Export<LocalOrdinal,GlobalOrdinal,Node>;
126  public:
129 
131 
132 
140  Import (const Teuchos::RCP<const map_type>& source,
141  const Teuchos::RCP<const map_type>& target);
142 
153  Import (const Teuchos::RCP<const map_type>& source,
154  const Teuchos::RCP<const map_type>& target,
155  const RCP<Teuchos::FancyOStream>& out);
156 
169  Import (const Teuchos::RCP<const map_type>& source,
170  const Teuchos::RCP<const map_type>& target,
171  const Teuchos::RCP<Teuchos::ParameterList>& plist);
172 
188  Import (const Teuchos::RCP<const map_type>& source,
189  const Teuchos::RCP<const map_type>& target,
190  const RCP<Teuchos::FancyOStream>& out,
191  const Teuchos::RCP<Teuchos::ParameterList>& plist);
192 
198 
206 
208  ~Import();
209 
214  void setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& plist);
215 
217 
219 
224  size_t getNumSameIDs() const;
225 
232  size_t getNumPermuteIDs() const;
233 
235  ArrayView<const LocalOrdinal> getPermuteFromLIDs() const;
236 
238  ArrayView<const LocalOrdinal> getPermuteToLIDs() const;
239 
241  size_t getNumRemoteIDs() const;
242 
244  ArrayView<const LocalOrdinal> getRemoteLIDs() const;
245 
247  size_t getNumExportIDs() const;
248 
250  ArrayView<const LocalOrdinal> getExportLIDs() const;
251 
256  ArrayView<const int> getExportPIDs() const;
257 
259  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& getSourceMap() const;
260 
262  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& getTargetMap() const;
263 
265  Distributor & getDistributor() const;
266 
270 
304  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
306 
308 
310 
326  virtual void print (std::ostream& os) const;
327 
329 
330  private:
332  RCP<ImportExportData<LocalOrdinal,GlobalOrdinal,Node> > ImportData_;
334  RCP<Teuchos::FancyOStream> out_;
336  bool debug_;
337 
339 
340 
352  void
353  init (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& source,
354  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& target,
355  const Teuchos::RCP<Teuchos::ParameterList>& plist);
356 
388  void setupSamePermuteRemote (Teuchos::Array<GlobalOrdinal>& remoteGIDs);
389 
414  void
415  setupExport (Teuchos::Array<GlobalOrdinal>& remoteGIDs);
417 
418 
426  Import (const Teuchos::RCP<const map_type>& source,
427  const Teuchos::RCP<const map_type>& target,
428  const size_t numSameIDs,
429  Teuchos::Array<LocalOrdinal>& permuteToLIDs,
430  Teuchos::Array<LocalOrdinal>& permuteFromLIDs,
431  Teuchos::Array<LocalOrdinal>& remoteLIDs,
432  Teuchos::Array<LocalOrdinal>& exportLIDs,
433  Teuchos::Array<int>& exportPIDs,
434  Distributor& distributor,
435  const Teuchos::RCP<Teuchos::FancyOStream>& out = Teuchos::null,
436  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::null);
437 
439  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
440  setUnionNaiveImpl (const Import<LocalOrdinal, GlobalOrdinal, Node>& rhs) const;
441 
443  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
444  setUnionImpl (const Import<LocalOrdinal, GlobalOrdinal, Node>& rhs) const;
445  }; // class Import
446 
457  template<class LocalOrdinal, class GlobalOrdinal, class Node>
458  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
459  createImport (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& src,
460  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& tgt)
461  {
462  if (src == tgt) {
463  return Teuchos::null;
464  }
465 #ifdef HAVE_TPETRA_DEBUG
466  TEUCHOS_TEST_FOR_EXCEPTION(
467  src == null || tgt == null, std::runtime_error,
468  "Tpetra::createImport(): neither source nor target map may be null:"
469  << std::endl << "source: " << src << std::endl << "target: " << tgt
470  << std::endl);
471 #endif // HAVE_TPETRA_DEBUG
472  return Teuchos::rcp (new Import<LocalOrdinal, GlobalOrdinal, Node> (src, tgt));
473  }
474 
486  template<class LocalOrdinal, class GlobalOrdinal, class Node>
487  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
488  createImport (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& src,
489  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& tgt,
490  const Teuchos::RCP<Teuchos::ParameterList>& plist)
491  {
492  if (src == tgt) {
493  return Teuchos::null;
494  }
495 #ifdef HAVE_TPETRA_DEBUG
496  TEUCHOS_TEST_FOR_EXCEPTION(
497  src == null || tgt == null, std::runtime_error,
498  "Tpetra::createImport(): neither source nor target map may be null:"
499  << std::endl << "source: " << src << std::endl << "target: " << tgt
500  << std::endl);
501 #endif // HAVE_TPETRA_DEBUG
502  typedef Import<LocalOrdinal, GlobalOrdinal, Node> import_type;
503  return Teuchos::rcp (new import_type (src, tgt, plist));
504  }
505 } // namespace Tpetra
506 
507 #endif // TPETRA_IMPORT_DECL_HPP
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & getTargetMap() const
The Target Map used to construct this Import object.
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
~Import()
Destructor.
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
Import(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct an Import from the source and target Maps.
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
Import< LocalOrdinal, GlobalOrdinal, Node > & operator=(const Import< LocalOrdinal, GlobalOrdinal, Node > &Source)
Assignment operator.
Sets up and executes a communication plan for a Tpetra DistObject.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
Set parameters.
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > createImport(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &src, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &tgt)
Nonmember constructor for Import.
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
Describes a parallel distribution of objects over processes.
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & getSourceMap() const
The Source Map used to construct this Import object.
size_t getNumSameIDs() const
Number of initial identical IDs.
Distributor & getDistributor() const
The Distributor that this Import object uses to move data.
virtual void print(std::ostream &os) const
Print the Import&#39;s data to the given output stream.
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > setUnion(const Import< LocalOrdinal, GlobalOrdinal, Node > &rhs) const
Return the union of this Import and rhs.