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 
111  template<class LocalOrdinal,
112  class GlobalOrdinal,
113  class Node>
114  class Import:
115  public ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>
116  {
117  private:
118  friend class Export<LocalOrdinal,GlobalOrdinal,Node>;
119  using base_type =
121  public:
124 
126 
127 
135  Import (const Teuchos::RCP<const map_type>& source,
136  const Teuchos::RCP<const map_type>& target);
137 
148  Import (const Teuchos::RCP<const map_type>& source,
149  const Teuchos::RCP<const map_type>& target,
150  const Teuchos::RCP<Teuchos::FancyOStream>& out);
151 
164  Import (const Teuchos::RCP<const map_type>& source,
165  const Teuchos::RCP<const map_type>& target,
166  const Teuchos::RCP<Teuchos::ParameterList>& plist);
167 
183  Import (const Teuchos::RCP<const map_type>& source,
184  const Teuchos::RCP<const map_type>& target,
185  const Teuchos::RCP<Teuchos::FancyOStream>& out,
186  const Teuchos::RCP<Teuchos::ParameterList>& plist);
187 
199  Import (const Teuchos::RCP<const map_type>& source,
200  const Teuchos::RCP<const map_type>& target,
201  Teuchos::Array<int> & remotePIDs,
202  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::rcp(new Teuchos::ParameterList) );
203 
209 
217 
248  Import (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& sourceMap,
249  const GlobalOrdinal targetMapRemoteOrPermuteGlobalIndices[],
250  const int targetMapRemoteOrPermuteProcessRanks[],
251  const LocalOrdinal numTargetMapRemoteOrPermuteGlobalIndices,
252  const bool mayReorderTargetMapIndicesLocally,
253  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::null,
254  const Teuchos::RCP<Teuchos::FancyOStream>& out = Teuchos::null);
255 
257  Import (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& source,
258  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& target,
259  const Teuchos::ArrayView<int> & remotePIDs,
260  const Teuchos::ArrayView<const LocalOrdinal> & userExportLIDs,
261  const Teuchos::ArrayView<const int> & userExportPIDs,
262  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::null,
263  const Teuchos::RCP<Teuchos::FancyOStream>& out = Teuchos::null);
264 
267  operator= (const Import<LocalOrdinal,GlobalOrdinal,Node>& Source) = default;
268 
270  virtual ~Import () = default;
271 
273 
275 
284  void
285  findUnionTargetGIDs(Teuchos::Array<GlobalOrdinal>& unionTgtGIDs,
286  Teuchos::Array<std::pair<int,GlobalOrdinal>>& remotePGIDs,
287  typename Teuchos::Array<GlobalOrdinal>::size_type& numSameGIDs,
288  typename Teuchos::Array<GlobalOrdinal>::size_type& numPermuteGIDs,
289  typename Teuchos::Array<GlobalOrdinal>::size_type& numRemoteGIDs,
290  const Teuchos::ArrayView<const GlobalOrdinal>& sameGIDs1,
291  const Teuchos::ArrayView<const GlobalOrdinal>& sameGIDs2,
292  Teuchos::Array<GlobalOrdinal>& permuteGIDs1,
293  Teuchos::Array<GlobalOrdinal>& permuteGIDs2,
294  Teuchos::Array<GlobalOrdinal>& remoteGIDs1,
295  Teuchos::Array<GlobalOrdinal>& remoteGIDs2,
296  Teuchos::Array<int>& remotePIDs1,
297  Teuchos::Array<int>& remotePIDs2) const;
298 
332  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
334 
351  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
352  setUnion () const;
353 
358  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
359  createRemoteOnlyImport (const Teuchos::RCP<const map_type>& remoteTarget) const;
360 
362 
364 
387  virtual void
388  describe (Teuchos::FancyOStream& out,
389  const Teuchos::EVerbosityLevel verbLevel =
390  Teuchos::Describable::verbLevel_default) const;
391 
407  virtual void print (std::ostream& os) const;
408 
410  private:
412 
413 
430  void
431  init (const Teuchos::RCP<const map_type>& source,
432  const Teuchos::RCP<const map_type>& target,
433  bool useRemotePIDs,
434  Teuchos::Array<int> & remotePIDs,
435  const Teuchos::RCP<Teuchos::ParameterList>& plist);
436 
468  void setupSamePermuteRemote (Teuchos::Array<GlobalOrdinal>& remoteGIDs);
469 
498  void
499  setupExport (Teuchos::Array<GlobalOrdinal>& remoteGIDs,
500  bool useRemotePIDs, Teuchos::Array<int> & remotePIDs,
501  const Teuchos::RCP<Teuchos::ParameterList>& plist= Teuchos::null);
503 
511  Import (const Teuchos::RCP<const map_type>& source,
512  const Teuchos::RCP<const map_type>& target,
513  const size_t numSameID,
514  Teuchos::Array<LocalOrdinal>& permuteToLIDs,
515  Teuchos::Array<LocalOrdinal>& permuteFromLIDs,
516  Teuchos::Array<LocalOrdinal>& remoteLIDs,
517  Teuchos::Array<LocalOrdinal>& exportLIDs,
518  Teuchos::Array<int>& exportPIDs,
519  Distributor& distributor,
520  const Teuchos::RCP<Teuchos::FancyOStream>& out = Teuchos::null,
521  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::null);
522 
523 
524  }; // class Import
525 
535  template<class LocalOrdinal, class GlobalOrdinal, class Node>
536  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
537  createImport (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& src,
538  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& tgt)
539  {
540  if (src == tgt) {
541  return Teuchos::null;
542  }
543 #ifdef HAVE_TPETRA_DEBUG
544  TEUCHOS_TEST_FOR_EXCEPTION(
545  src == Teuchos::null || tgt == Teuchos::null, std::runtime_error,
546  "Tpetra::createImport: Neither source nor target Map may be null.");
547 #endif // HAVE_TPETRA_DEBUG
548  using import_type = Import<LocalOrdinal, GlobalOrdinal, Node>;
549  return Teuchos::rcp (new import_type (src, tgt));
550  }
551 
562  template<class LocalOrdinal, class GlobalOrdinal, class Node>
563  Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> >
564  createImport (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& src,
565  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& tgt,
566  const Teuchos::RCP<Teuchos::ParameterList>& plist)
567  {
568  if (src == tgt) {
569  return Teuchos::null;
570  }
571 #ifdef HAVE_TPETRA_DEBUG
572  TEUCHOS_TEST_FOR_EXCEPTION(
573  src == Teuchos::null || tgt == Teuchos::null, std::runtime_error,
574  "Tpetra::createImport(): neither source nor target map may be null:"
575  << std::endl << "source: " << src << std::endl << "target: " << tgt
576  << std::endl);
577 #endif // HAVE_TPETRA_DEBUG
578  typedef Import<LocalOrdinal, GlobalOrdinal, Node> import_type;
579  return Teuchos::rcp (new import_type (src, tgt, plist));
580  }
581 
582 } // namespace Tpetra
583 
584 #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.