All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // Jeremie Gaidamour (jngaida@sandia.gov)
40 // Jonathan Hu (jhu@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  EpetraImport::EpetraImport(const Teuchos::RCP<const Map<int,int> > & source, const Teuchos::RCP<const Map<int,int> > & target)
52  : import_(rcp(new Epetra_Import(toEpetra(target), toEpetra(source)))) { } // Warning: Epetra(Target, Source) vs. Tpetra(Source, Target)
53 
54  // //! copy constructor.
55  // EpetraImport::EpetraImport(const Import<int,int> & import) { // TODO: refactoring
56  // XPETRA_DYNAMIC_CAST(const EpetraImport, import, tImport, "Xpetra::EpetraImport copy constructors only accept Xpetra::EpetraImport as input arguments.");
57  // import_ = rcp(new Epetra_Import(*tImport.getEpetra_Import()));
58  // }
59 
60  // TODO: move that elsewhere
61  // const Epetra_Import & toEpetra(const Import<int, int> &import) {
62  // // TODO: throw exception
63  // const EpetraImport & tpetraImport = dynamic_cast<const EpetraImport &>(import);
64  // return *tpetraImport.getEpetra_Import();
65  // }
66 
67  RCP< const Import<int, int > > toXpetra(const Epetra_Import *import) {
68  RCP<const Epetra_Import> imp = rcp(new Epetra_Import(*import)); //NOTE: non consitent: return pointer, take ref
69  return rcp ( new Xpetra::EpetraImport(imp) );
70  }
71  //
72 
73  ArrayView< const int > EpetraImport::getExportPIDs() const { XPETRA_MONITOR("EpetraImport::getExportImageIDs"); return ArrayView<const int> (import_->ExportPIDs(),import_->NumExportIDs()); }
74 
75  ArrayView< const int > EpetraImport::getPermuteFromLIDs() const {
76  XPETRA_MONITOR("EpetraImport::getPermuteFromLIDs");
77  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImport::getExportImageIDs not implemented"); }
78 
79  ArrayView< const int > EpetraImport::getPermuteToLIDs() const {
80  XPETRA_MONITOR("EpetraImport::getPermuteToLIDs");
81  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImport::getPermuteToLIDs not implemented"); }
82 
83  size_t EpetraImport::getNumRemoteIDs() const {
84  XPETRA_MONITOR("EpetraImport::getNumRemoteIDs");
85  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImport::getNumRemoteIDs not implemented"); }
86 
87  ArrayView< const int > EpetraImport::getRemoteLIDs() const {
88  XPETRA_MONITOR("EpetraImport::getRemoteLIDs");
89  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImport::getRemoteLIDs not implemented"); }
90 
91  size_t EpetraImport::getNumExportIDs() const {
92  XPETRA_MONITOR("EpetraImport::getNumExportIDs");
93  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImport::getNumExportIDs not implemented"); }
94 
95  ArrayView< const int > EpetraImport::getExportLIDs() const {
96  XPETRA_MONITOR("EpetraImport::getExportLIDs");
97  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO EpetraImport::getExportLIDs not implemented"); }
98 
99  void EpetraImport::print(std::ostream &os) const { XPETRA_MONITOR("EpetraImport::print"); import_->Print(os); }
100 
101 
102 } // Xpetra namespace
103 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
EpetraImport(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, int > > &graph)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Exception throws when you call an unimplemented method of Xpetra.
#define XPETRA_MONITOR(funcName)
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > > toXpetra(RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > >)
Convert an Epetra_Comm.to a Teuchos_Comm.