Xpetra_EpetraImport.cpp
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 #include "Xpetra_EpetraImport.hpp"
47 #include "Xpetra_Exceptions.hpp"
48 
49 namespace Xpetra {
50 
51  template<class EpetraGlobalOrdinal>
53  : import_(rcp(new Epetra_Import(toEpetra(target), toEpetra(source)))) { } // Warning: Epetra(Target, Source) vs. Tpetra(Source, Target)
54 
55  // //! copy constructor.
56  // EpetraImportT<EpetraGlobalOrdinal>::EpetraImportT(const Import<int,GlobalOrdinal> & import) { // TODO: refactoring
57  // XPETRA_DYNAMIC_CAST(const EpetraImportT, import, tImport, "Xpetra::EpetraImportT copy constructors only accept Xpetra::EpetraImportT as input arguments.");
58  // import_ = rcp(new Epetra_Import(*tImport.getEpetra_Import()));
59  // }
60 
61  // TODO: move that elsewhere
62  // template<class GlobalOrdinal>
63  // const Epetra_Import & toEpetra(const Import<int, GlobalOrdinal> &import) {
64  // // TODO: throw exception
65  // const EpetraImportT & tpetraImport = dynamic_cast<const EpetraImportT<GlobalOrdinal> &>(import);
66  // return *tpetraImport.getEpetra_Import();
67  // }
68 
69  template<class GlobalOrdinal>
70  RCP< const Import<int, GlobalOrdinal > > toXpetra(const Epetra_Import *import) {
71  if (import != NULL) {
72  RCP<const Epetra_Import> imp = rcp(new Epetra_Import(*import)); //NOTE: non consitent: return pointer, take ref
74  }
75 
76  return Teuchos::null;
77  }
78  //
79 
80  template<class EpetraGlobalOrdinal>
81  ArrayView< const int > EpetraImportT<EpetraGlobalOrdinal>::getExportPIDs() const { XPETRA_MONITOR("EpetraImportT::getExportImageIDs"); return ArrayView<const int> (import_->ExportPIDs(),import_->NumExportIDs()); }
82 
83  template<class EpetraGlobalOrdinal>
84  size_t EpetraImportT<EpetraGlobalOrdinal>::getNumRemoteIDs() const { XPETRA_MONITOR("EpetraImportT::getNumRemoteIDs"); return import_->NumRemoteIDs(); }
85  template<class EpetraGlobalOrdinal>
86  size_t EpetraImportT<EpetraGlobalOrdinal>::getNumExportIDs() const { XPETRA_MONITOR("EpetraImportT::getNumExportIDs"); return import_->NumExportIDs(); }
87 
88  template<class EpetraGlobalOrdinal>
90  XPETRA_MONITOR("EpetraImportT::getPermuteFromLIDs");
91  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImportT<EpetraGlobalOrdinal>::getExportImageIDs not implemented"); }
92 
93  template<class EpetraGlobalOrdinal>
95  XPETRA_MONITOR("EpetraImportT::getPermuteToLIDs");
96  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImportT<EpetraGlobalOrdinal>::getPermuteToLIDs not implemented"); }
97 
98  template<class EpetraGlobalOrdinal>
100  XPETRA_MONITOR("EpetraImportT::getRemoteLIDs");
101  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImportT<EpetraGlobalOrdinal>::getRemoteLIDs not implemented"); }
102 
103  template<class EpetraGlobalOrdinal>
105  XPETRA_MONITOR("EpetraImportT::getRemotePIDs");
106  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImportT<EpetraGlobalOrdinal>::getRemotePIDs not implemented"); }
107 
108  template<class EpetraGlobalOrdinal>
110  XPETRA_MONITOR("EpetraImportT::getExportLIDs");
111  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImportT<EpetraGlobalOrdinal>::getExportLIDs not implemented"); }
112 
113  template<class EpetraGlobalOrdinal>
114  void EpetraImportT<EpetraGlobalOrdinal>::print(std::ostream &os) const { XPETRA_MONITOR("EpetraImportT::print"); import_->Print(os); }
115 
116 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
117 template class EpetraImportT<int>;
118 template RCP< const Import<int, int> > toXpetra<int>(const Epetra_Import *);
119 #endif
120 
121 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
122 template class EpetraImportT<long long>;
123 template RCP< const Import<int, long long> > toXpetra<long long>(const Epetra_Import *);
124 #endif
125 
126 } // Xpetra namespace
127 
template RCP< const CrsGraph< int, long long > > toXpetra< long long >(const Epetra_CrsGraph &g)
EpetraImportT(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target)
Construct an Import from the source and target Maps.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal > > &graph)
size_t getNumExportIDs() const
Number of entries that must be sent by the calling process to other processes.
ArrayView< const LocalOrdinal > getPermuteFromLIDs() const
List of local IDs in the source Map that are permuted.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Xpetra namespace
ArrayView< const int > getExportPIDs() const
List of processes to which entries will be sent.
RCP< const CrsGraph< int, GlobalOrdinal > > toXpetra(const Epetra_CrsGraph &g)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
ArrayView< const LocalOrdinal > getRemotePIDs() const
List of entries in the target Map to receive from other processes.
template RCP< const CrsGraph< int, int > > toXpetra< int >(const Epetra_CrsGraph &g)
Exception throws when you call an unimplemented method of Xpetra.
ArrayView< const LocalOrdinal > getExportLIDs() const
List of entries in the source Map that will be sent to other processes.
RCP< const Epetra_Import > import_
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.
#define XPETRA_MONITOR(funcName)
ArrayView< const LocalOrdinal > getPermuteToLIDs() const
List of local IDs in the target Map that are permuted.
void print(std::ostream &os) const
Print the Import&#39;s data to the given output stream.