Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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_Details_Transfer.hpp"
46 #include "Tpetra_Import_fwd.hpp"
47 #include "Tpetra_Export_fwd.hpp"
48 
49 namespace Tpetra {
50 
106  template<class LocalOrdinal,
107  class GlobalOrdinal,
108  class Node>
109  class Import:
110  public ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>
111  {
112  private:
113  friend class Export<LocalOrdinal,GlobalOrdinal,Node>;
114  using base_type =
116  public:
119 
121 
122 
130  Import (const Teuchos::RCP<const map_type>& source,
131  const Teuchos::RCP<const map_type>& target);
132 
143  Import (const Teuchos::RCP<const map_type>& source,
144  const Teuchos::RCP<const map_type>& target,
145  const Teuchos::RCP<Teuchos::FancyOStream>& out);
146 
159  Import (const Teuchos::RCP<const map_type>& source,
160  const Teuchos::RCP<const map_type>& target,
161  const Teuchos::RCP<Teuchos::ParameterList>& plist);
162 
178  Import (const Teuchos::RCP<const map_type>& source,
179  const Teuchos::RCP<const map_type>& target,
180  const Teuchos::RCP<Teuchos::FancyOStream>& out,
181  const Teuchos::RCP<Teuchos::ParameterList>& plist);
182 
194  Import (const Teuchos::RCP<const map_type>& source,
195  const Teuchos::RCP<const map_type>& target,
196  Teuchos::Array<int> & remotePIDs,
197  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::rcp(new Teuchos::ParameterList) );
198 
204 
212 
243  Import (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& sourceMap,
244  const GlobalOrdinal targetMapRemoteOrPermuteGlobalIndices[],
245  const int targetMapRemoteOrPermuteProcessRanks[],
246  const LocalOrdinal numTargetMapRemoteOrPermuteGlobalIndices,
247  const bool mayReorderTargetMapIndicesLocally,
248  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::null,
249  const Teuchos::RCP<Teuchos::FancyOStream>& out = Teuchos::null);
250 
252  Import (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& source,
253  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& target,
254  const Teuchos::ArrayView<int> & remotePIDs,
255  const Teuchos::ArrayView<const LocalOrdinal> & userExportLIDs,
256  const Teuchos::ArrayView<const int> & userExportPIDs,
257  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::null,
258  const Teuchos::RCP<Teuchos::FancyOStream>& out = Teuchos::null);
259 
262  operator= (const Import<LocalOrdinal,GlobalOrdinal,Node>& Source) = default;
263 
265  virtual ~Import () = default;
266 
268 
270 
279  void
280  findUnionTargetGIDs(Teuchos::Array<GlobalOrdinal>& unionTgtGIDs,
281  Teuchos::Array<std::pair<int,GlobalOrdinal>>& remotePGIDs,
282  typename Teuchos::Array<GlobalOrdinal>::size_type& numSameGIDs,
283  typename Teuchos::Array<GlobalOrdinal>::size_type& numPermuteGIDs,
284  typename Teuchos::Array<GlobalOrdinal>::size_type& numRemoteGIDs,
285  const Teuchos::ArrayView<const GlobalOrdinal>& sameGIDs1,
286  const Teuchos::ArrayView<const GlobalOrdinal>& sameGIDs2,
287  Teuchos::Array<GlobalOrdinal>& permuteGIDs1,
288  Teuchos::Array<GlobalOrdinal>& permuteGIDs2,
289  Teuchos::Array<GlobalOrdinal>& remoteGIDs1,
290  Teuchos::Array<GlobalOrdinal>& remoteGIDs2,
291  Teuchos::Array<int>& remotePIDs1,
292  Teuchos::Array<int>& remotePIDs2) const;
293 
327  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
329 
346  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
347  setUnion () const;
348 
353  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
354  createRemoteOnlyImport (const Teuchos::RCP<const map_type>& remoteTarget) const;
355 
357 
359 
382  virtual void
383  describe (Teuchos::FancyOStream& out,
384  const Teuchos::EVerbosityLevel verbLevel =
385  Teuchos::Describable::verbLevel_default) const;
386 
402  virtual void print (std::ostream& os) const;
403 
405  private:
407 
408 
425  void
426  init (const Teuchos::RCP<const map_type>& source,
427  const Teuchos::RCP<const map_type>& target,
428  bool useRemotePIDs,
429  Teuchos::Array<int> & remotePIDs,
430  const Teuchos::RCP<Teuchos::ParameterList>& plist);
431 
463  void setupSamePermuteRemote (Teuchos::Array<GlobalOrdinal>& remoteGIDs);
464 
493  void
494  setupExport (Teuchos::Array<GlobalOrdinal>& remoteGIDs,
495  bool useRemotePIDs, Teuchos::Array<int> & remotePIDs,
496  const Teuchos::RCP<Teuchos::ParameterList>& plist= Teuchos::null);
498 
506  Import (const Teuchos::RCP<const map_type>& source,
507  const Teuchos::RCP<const map_type>& target,
508  const size_t numSameID,
509  Teuchos::Array<LocalOrdinal>& permuteToLIDs,
510  Teuchos::Array<LocalOrdinal>& permuteFromLIDs,
511  Teuchos::Array<LocalOrdinal>& remoteLIDs,
512  Teuchos::Array<LocalOrdinal>& exportLIDs,
513  Teuchos::Array<int>& exportPIDs,
514  Distributor& distributor,
515  const Teuchos::RCP<Teuchos::FancyOStream>& out = Teuchos::null,
516  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::null);
517 
518 
519  }; // class Import
520 
530  template<class LocalOrdinal, class GlobalOrdinal, class Node>
531  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
532  createImport (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& src,
533  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& tgt)
534  {
535  if (src == tgt) {
536  return Teuchos::null;
537  }
538 #ifdef HAVE_TPETRA_DEBUG
539  TEUCHOS_TEST_FOR_EXCEPTION(
540  src == Teuchos::null || tgt == Teuchos::null, std::runtime_error,
541  "Tpetra::createImport: Neither source nor target Map may be null.");
542 #endif // HAVE_TPETRA_DEBUG
543  using import_type = Import<LocalOrdinal, GlobalOrdinal, Node>;
544  return Teuchos::rcp (new import_type (src, tgt));
545  }
546 
557  template<class LocalOrdinal, class GlobalOrdinal, class Node>
558  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
559  createImport (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& src,
560  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& tgt,
561  const Teuchos::RCP<Teuchos::ParameterList>& plist)
562  {
563  if (src == tgt) {
564  return Teuchos::null;
565  }
566 #ifdef HAVE_TPETRA_DEBUG
567  TEUCHOS_TEST_FOR_EXCEPTION(
568  src == Teuchos::null || tgt == Teuchos::null, std::runtime_error,
569  "Tpetra::createImport(): neither source nor target map may be null:"
570  << std::endl << "source: " << src << std::endl << "target: " << tgt
571  << std::endl);
572 #endif // HAVE_TPETRA_DEBUG
573  typedef Import<LocalOrdinal, GlobalOrdinal, Node> import_type;
574  return Teuchos::rcp (new import_type (src, tgt, plist));
575  }
576 
577 } // namespace Tpetra
578 
579 #endif // TPETRA_IMPORT_DECL_HPP
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
Common base class of Import and Export.
Import< LocalOrdinal, GlobalOrdinal, Node > & operator=(const Import< LocalOrdinal, GlobalOrdinal, Node > &Source)=default
Assignment operator.
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > createRemoteOnlyImport(const Teuchos::RCP< const map_type > &remoteTarget) const
Returns an importer that contains only the remote entries of this.
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.
Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > setUnion() const
Return the union of this Import this-&gt;getSourceMap()
Forward declaration of Tpetra::Export.
Import(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct an Import from the source and target Maps.
Forward declaration of Tpetra::Import.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
Sets up and executes a communication plan for a Tpetra DistObject.
virtual ~Import()=default
Destructor.
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.
void findUnionTargetGIDs(Teuchos::Array< GlobalOrdinal > &unionTgtGIDs, Teuchos::Array< std::pair< int, GlobalOrdinal >> &remotePGIDs, typename Teuchos::Array< GlobalOrdinal >::size_type &numSameGIDs, typename Teuchos::Array< GlobalOrdinal >::size_type &numPermuteGIDs, typename Teuchos::Array< GlobalOrdinal >::size_type &numRemoteGIDs, const Teuchos::ArrayView< const GlobalOrdinal > &sameGIDs1, const Teuchos::ArrayView< const GlobalOrdinal > &sameGIDs2, Teuchos::Array< GlobalOrdinal > &permuteGIDs1, Teuchos::Array< GlobalOrdinal > &permuteGIDs2, Teuchos::Array< GlobalOrdinal > &remoteGIDs1, Teuchos::Array< GlobalOrdinal > &remoteGIDs2, Teuchos::Array< int > &remotePIDs1, Teuchos::Array< int > &remotePIDs2) const
Find the union of the target IDs from two Import objects.
A parallel distribution of indices over processes.
virtual void print(std::ostream &os) const
Print the Import&#39;s data to the given output stream.