Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_TpetraExport_def.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_TPETRAEXPORT_DEF_HPP
47 #define XPETRA_TPETRAEXPORT_DEF_HPP
48 
50 #include "Tpetra_Distributor.hpp"
51 
52 namespace Xpetra {
53 
54 template <class LocalOrdinal, class GlobalOrdinal, class Node>
56  TpetraExport(const Teuchos::RCP<const map_type>& source,
57  const Teuchos::RCP<const map_type>& target)
58  : export_(Teuchos::rcp(new Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>(toTpetra(source), toTpetra(target)))) {
59 }
60 
61 template <class LocalOrdinal, class GlobalOrdinal, class Node>
63  TpetraExport(const Teuchos::RCP<const map_type>& source,
64  const Teuchos::RCP<const map_type>& target,
65  const Teuchos::RCP<Teuchos::ParameterList>& plist)
66  : export_(Teuchos::rcp(new Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>(toTpetra(source), toTpetra(target), plist))) {
67 }
68 
69 template <class LocalOrdinal, class GlobalOrdinal, class Node>
72  : export_(Teuchos::rcp(new Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>(toTpetra(rhs)))) {
73 }
74 
75 template <class LocalOrdinal, class GlobalOrdinal, class Node>
78 }
79 
80 template <class LocalOrdinal, class GlobalOrdinal, class Node>
81 size_t
83  getNumSameIDs() const {
84  XPETRA_MONITOR("TpetraExport::getNumSameIDs");
85  return export_->getNumSameIDs();
86 }
87 
88 template <class LocalOrdinal, class GlobalOrdinal, class Node>
89 size_t
92  XPETRA_MONITOR("TpetraExport::getNumPermuteIDs");
93  return export_->getNumPermuteIDs();
94 }
95 
96 template <class LocalOrdinal, class GlobalOrdinal, class Node>
97 ArrayView<const LocalOrdinal>
100  XPETRA_MONITOR("TpetraExport::getPermuteFromLIDs");
101  return export_->getPermuteFromLIDs();
102 }
103 
104 template <class LocalOrdinal, class GlobalOrdinal, class Node>
105 ArrayView<const LocalOrdinal>
108  XPETRA_MONITOR("TpetraExport::getPermuteToLIDs");
109  return export_->getPermuteToLIDs();
110 }
111 
112 template <class LocalOrdinal, class GlobalOrdinal, class Node>
113 size_t
116  XPETRA_MONITOR("TpetraExport::getNumRemoteIDs");
117  return export_->getNumRemoteIDs();
118 }
119 
120 template <class LocalOrdinal, class GlobalOrdinal, class Node>
121 ArrayView<const LocalOrdinal>
123  getRemoteLIDs() const {
124  XPETRA_MONITOR("TpetraExport::getRemoteLIDs");
125  return export_->getRemoteLIDs();
126 }
127 
128 template <class LocalOrdinal, class GlobalOrdinal, class Node>
129 size_t
132  XPETRA_MONITOR("TpetraExport::getNumExportIDs");
133  return export_->getNumExportIDs();
134 }
135 
136 template <class LocalOrdinal, class GlobalOrdinal, class Node>
137 ArrayView<const LocalOrdinal>
139  getExportLIDs() const {
140  XPETRA_MONITOR("TpetraExport::getExportLIDs");
141  return export_->getExportLIDs();
142 }
143 
144 template <class LocalOrdinal, class GlobalOrdinal, class Node>
145 ArrayView<const int>
147  getExportPIDs() const {
148  XPETRA_MONITOR("TpetraExport::getExportPIDs");
149  return export_->getExportPIDs();
150 }
151 
152 template <class LocalOrdinal, class GlobalOrdinal, class Node>
153 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
155  getSourceMap() const {
156  XPETRA_MONITOR("TpetraExport::getSourceMap");
157  return toXpetra(export_->getSourceMap());
158 }
159 
160 template <class LocalOrdinal, class GlobalOrdinal, class Node>
161 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
163  getTargetMap() const {
164  XPETRA_MONITOR("TpetraExport::getTargetMap");
165  return toXpetra(export_->getTargetMap());
166 }
167 
168 template <class LocalOrdinal, class GlobalOrdinal, class Node>
170  setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const {
171  XPETRA_MONITOR("TpetraExport::setDistributorParameters");
172  export_->getDistributor().setParameterList(params);
173  auto revDistor = export_->getDistributor().getReverse(false);
174  if (!revDistor.is_null())
175  revDistor->setParameterList(params);
176 }
177 
178 template <class LocalOrdinal, class GlobalOrdinal, class Node>
180  print(std::ostream& os) const {
181  XPETRA_MONITOR("TpetraExport::print");
182  export_->print(os);
183 }
184 
185 template <class LocalOrdinal, class GlobalOrdinal, class Node>
188  const RCP<const Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>>& exp)
189  : export_(exp) {
190 }
191 
192 template <class LocalOrdinal, class GlobalOrdinal, class Node>
193 RCP<const Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>>
196  return export_;
197 }
198 
199 #ifdef HAVE_XPETRA_EPETRA
200 
201 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
202 
203 // stub implementation for GO=int and NO=EpetraNode
204 template <>
205 class TpetraExport<int, int, EpetraNode>
206  : public Export<int, int, EpetraNode> {
207  public:
208  typedef int LocalOrdinal;
209  typedef int GlobalOrdinal;
210  typedef EpetraNode Node;
211 
214 
216 
217 
219  TpetraExport(const Teuchos::RCP<const map_type>& source, const Teuchos::RCP<const map_type>& target) {
222  "int",
223  typeid(EpetraNode).name());
224  }
225 
227  TpetraExport(const Teuchos::RCP<const map_type>& source,
228  const Teuchos::RCP<const map_type>& target,
229  const Teuchos::RCP<Teuchos::ParameterList>& plist) {
232  "int",
233  typeid(EpetraNode).name());
234  }
235 
240  "int",
241  typeid(EpetraNode).name());
242  }
243 
246 
248 
250 
251 
253  size_t getNumSameIDs() const { return 0; }
254 
256  size_t getNumPermuteIDs() const { return 0; }
257 
259  ArrayView<const LocalOrdinal> getPermuteFromLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
260 
262  ArrayView<const LocalOrdinal> getPermuteToLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
263 
265  size_t getNumRemoteIDs() const { return 0; }
266 
268  ArrayView<const LocalOrdinal> getRemoteLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
269 
271  size_t getNumExportIDs() const { return 0; }
272 
274  ArrayView<const LocalOrdinal> getExportLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
275 
277  ArrayView<const int> getExportPIDs() const { return Teuchos::ArrayView<const int>(); }
278 
280  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> getSourceMap() const { return Teuchos::null; }
281 
283  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> getTargetMap() const { return Teuchos::null; }
284 
286  void setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const {};
287 
289 
291 
292 
294  void print(std::ostream& os) const { /* noop */
295  }
296 
298 
300 
301 
303  TpetraExport(const RCP<const Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>>& exp) {
306  "int",
307  typeid(EpetraNode).name());
308  }
309 
310  RCP<const Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>> getTpetra_Export() const { return Teuchos::null; }
311 
313 
314 }; // TpetraExport class (specialization for LO=GO=int)
315 #endif // #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT)))
316 
317 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
318 
319 // stub implementation for GO=long long and NO=EpetraNode
320 template <>
321 class TpetraExport<int, long long, EpetraNode>
322  : public Export<int, long long, EpetraNode> {
323  public:
324  typedef int LocalOrdinal;
325  typedef long long GlobalOrdinal;
326  typedef EpetraNode Node;
327 
330 
332 
333 
335  TpetraExport(const Teuchos::RCP<const map_type>& source, const Teuchos::RCP<const map_type>& target) {
338  "long long",
339  typeid(EpetraNode).name());
340  }
341 
343  TpetraExport(const Teuchos::RCP<const map_type>& source,
344  const Teuchos::RCP<const map_type>& target,
345  const Teuchos::RCP<Teuchos::ParameterList>& plist) {
348  "long long",
349  typeid(EpetraNode).name());
350  }
351 
356  "long long",
357  typeid(EpetraNode).name());
358  }
359 
362 
364 
366 
367 
369  size_t getNumSameIDs() const { return 0; }
370 
372  size_t getNumPermuteIDs() const { return 0; }
373 
375  ArrayView<const LocalOrdinal> getPermuteFromLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
376 
378  ArrayView<const LocalOrdinal> getPermuteToLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
379 
381  size_t getNumRemoteIDs() const { return 0; }
382 
384  ArrayView<const LocalOrdinal> getRemoteLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
385 
387  size_t getNumExportIDs() const { return 0; }
388 
390  ArrayView<const LocalOrdinal> getExportLIDs() const { return Teuchos::ArrayView<const LocalOrdinal>(); }
391 
393  ArrayView<const int> getExportPIDs() const { return Teuchos::ArrayView<const int>(); }
394 
396  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> getSourceMap() const { return Teuchos::null; }
397 
399  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> getTargetMap() const { return Teuchos::null; }
400 
402  void setDistributorParameters(const Teuchos::RCP<Teuchos::ParameterList> params) const {};
403 
405 
407 
408 
410  void print(std::ostream& os) const { /* noop */
411  }
412 
414 
416 
417 
419  TpetraExport(const RCP<const Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>>& exp) {
422  "long long",
423  typeid(EpetraNode).name());
424  }
425 
426  RCP<const Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>> getTpetra_Export() const { return Teuchos::null; }
427 
429 
430 }; // TpetraExport class (specialization for GO=long long, NO=EpetraNode)
431 #endif // #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG)))
432 
433 #endif // HAVE_XPETRA_EPETRA
434 
435 } // namespace Xpetra
436 
437 #endif // XPETRA_TPETRAEXPORT_DEF_HPP
size_t getNumSameIDs() const
Number of initial identical IDs.
TpetraExport(const Export< LocalOrdinal, GlobalOrdinal, Node > &rhs)
Copy constructor.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const
The source Map used to construct this Export.
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const
The target Map used to construct this Export.
TpetraExport(const RCP< const Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node >> &exp)
TpetraExport constructor to wrap a Tpetra::Export object.
TpetraExport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist)
Constructor (with list of parameters).
RCP< const Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Export() const
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
TpetraExport(const Export< LocalOrdinal, GlobalOrdinal, Node > &rhs)
Copy constructor.
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
RCP< const Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Export() const
#define XPETRA_TPETRA_ETI_EXCEPTION(cl, obj, go, node)
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
void print(std::ostream &os) const
Print the Export&#39;s data to the given output stream.
TpetraExport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct a Export object from the source and target Map.
size_t getNumSameIDs() const
Number of initial identical IDs.
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
size_t getNumSameIDs() const
Number of initial identical IDs.
TpetraExport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist)
Constructor (with list of parameters).
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const
The target Map used to construct this Export.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const
The source Map used to construct this Export.
TpetraExport(const RCP< const Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node >> &exp)
TpetraExport constructor to wrap a Tpetra::Export object.
void setDistributorParameters(const Teuchos::RCP< Teuchos::ParameterList > params) const
Set parameters on the underlying object.
void setDistributorParameters(const Teuchos::RCP< Teuchos::ParameterList > params) const
Set parameters on the underlying object.
RCP< const Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Export() const
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const
The target Map used to construct this Export.
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
void print(std::ostream &os) const
Print the Export&#39;s data to the given output stream.
TpetraExport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct a Export object from the source and target Map.
void setDistributorParameters(const Teuchos::RCP< Teuchos::ParameterList > params) const
Set distributor parameters.
#define XPETRA_MONITOR(funcName)
size_t getNumRemoteIDs() const
Number of entries not on the calling process.
size_t getNumPermuteIDs() const
Number of IDs to permute but not to communicate.
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
TpetraExport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct a Export object from the source and target Map.
ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
ArrayView< const LocalOrdinal > getRemoteLIDs() const
List of entries in the target Map to receive from other processes.
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getSourceMap() const
The source Map used to construct this Export.
void print(std::ostream &os) const
Print the Export&#39;s data to the given output stream.
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)