Xpetra_EpetraMap.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_ConfigDefs.hpp"
47 
48 #ifdef HAVE_XPETRA_EPETRA
49 
50 #include "Xpetra_EpetraMap.hpp"
51 
52 namespace Xpetra {
53 
54  template<class GlobalOrdinal>
55  const Epetra_Map & toEpetra(const Map<int,GlobalOrdinal> &map) {
56  // TODO: throw exception
57  const EpetraMapT<GlobalOrdinal> & epetraMap = dynamic_cast<const EpetraMapT<GlobalOrdinal> &>(*map.getMap());
58  return epetraMap.getEpetra_Map();
59  }
60 
61  template<class GlobalOrdinal>
62  const Epetra_Map & toEpetra(const RCP< const Map<int,GlobalOrdinal> > &map) {
63  XPETRA_RCP_DYNAMIC_CAST(const EpetraMapT<GlobalOrdinal>, map->getMap(), epetraMap, "toEpetra");
64  return epetraMap->getEpetra_Map();
65  }
66 
67 
68 // template<class GlobalOrdinal>
69 // const RCP<const Map<int,GlobalOrdinal> > toXpetra(const RCP<const Epetra_Map>& map) {
70 // return rcp(new EpetraMapT(map));
71 // }
72 
73  template<class GlobalOrdinal>
74  const RCP< const Map<int, GlobalOrdinal> > toXpetra(const Epetra_BlockMap &map) {
75  RCP<const Epetra_BlockMap> m = rcp(new Epetra_BlockMap(map));
76  return rcp( new EpetraMapT<GlobalOrdinal>(m) );
77  }
78  //
79 
80 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
81 template const Epetra_Map & toEpetra<int>(const Map<int,int> &map);
82 template const Epetra_Map & toEpetra<int>(const RCP< const Map<int, int> > &);
83 template const RCP< const Map<int, int> > toXpetra<int>(const Epetra_BlockMap &map);
84 #endif
85 
86 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
87 template const Epetra_Map & toEpetra<long long>(const Map<int,long long> &map);
88 template const Epetra_Map & toEpetra<long long>(const RCP< const Map<int, long long> > &);
89 template const RCP< const Map<int, long long> > toXpetra<long long>(const Epetra_BlockMap &map);
90 #endif
91 
92 }
93 
94 
95 #endif
template const Epetra_CrsGraph & toEpetra< long long >(const RCP< const CrsGraph< int, long long > > &graph)
template RCP< const CrsGraph< int, long long > > toXpetra< long long >(const Epetra_CrsGraph &g)
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal > > &graph)
Xpetra namespace
virtual RCP< const Map > getMap() const
Definition: Xpetra_Map.hpp:196
RCP< const CrsGraph< int, GlobalOrdinal > > toXpetra(const Epetra_CrsGraph &g)
template const Epetra_CrsGraph & toEpetra< int >(const RCP< const CrsGraph< int, int > > &graph)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
template RCP< const CrsGraph< int, int > > toXpetra< int >(const Epetra_CrsGraph &g)
#define XPETRA_RCP_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
const Epetra_Map & getEpetra_Map() const