sup
Cloner
Xpetra_Cloner.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
47
// WARNING: This code is experimental. Backwards compatibility should not be expected.
48
49
#ifndef XPETRA_CLONER_HPP
50
#define XPETRA_CLONER_HPP
51
52
#include <
Kokkos_DefaultNode.hpp
>
53
54
#include "
Xpetra_ConfigDefs.hpp
"
55
#include "
Xpetra_Exceptions.hpp
"
56
57
#include "
Xpetra_Map.hpp
"
58
#ifdef HAVE_XPETRA_TPETRA
59
#include "
Xpetra_TpetraMap.hpp
"
60
#endif
61
62
#include "
Xpetra_Matrix.hpp
"
63
#include "
Xpetra_CrsMatrixWrap.hpp
"
64
#include "
Xpetra_MultiVector.hpp
"
69
namespace
Xpetra
{
70
71
template
<
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node1,
class
Node2>
72
RCP<Map<LocalOrdinal,GlobalOrdinal,Node2>
>
clone
(
const
Map<LocalOrdinal,GlobalOrdinal,Node1>
& map,
const
RCP<Node2>
& node2) {
73
if
(map.
lib
() ==
UseEpetra
)
74
throw
std::invalid_argument(
"Map::clone() functionality is only available for Tpetra"
);
75
#ifdef HAVE_XPETRA_TPETRA
76
RCP<const TpetraMap<LocalOrdinal,GlobalOrdinal,Node1>
> tMap = Teuchos::rcp_dynamic_cast<
const
TpetraMap<LocalOrdinal,GlobalOrdinal,Node1>
>(rcpFromRef(map));
77
78
return
tMap->clone(node2);
79
#else
80
return
Teuchos::null;
81
#endif
82
}
83
84
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node1,
class
Node2>
85
RCP<Matrix<Scalar,LocalOrdinal,GlobalOrdinal,Node2>
>
clone
(
const
Matrix<Scalar,LocalOrdinal,GlobalOrdinal,Node1>
& matrix,
const
RCP<Node2>
& node2) {
86
if
(matrix.
getRowMap
()->lib() ==
UseEpetra
)
87
throw
std::invalid_argument(
"Matrix::clone() functionality is only available for Tpetra"
);
88
89
RCP<const CrsMatrixWrap<Scalar,LocalOrdinal,GlobalOrdinal,Node1>
> tMatrix =
90
Teuchos::rcp_dynamic_cast<
const
CrsMatrixWrap<Scalar,LocalOrdinal,GlobalOrdinal,Node1>
>(rcpFromRef(matrix));
91
92
return
tMatrix->clone(node2);
93
}
94
95
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node1,
class
Node2>
96
RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node2>
>
clone
(
const
MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node1>
& MV,
const
RCP<Node2>
& node2) {
97
if
(MV.
getMap
()->lib() ==
UseEpetra
)
98
throw
std::invalid_argument(
"MultiVector::clone() functionality is only available for Tpetra"
);
99
#ifdef HAVE_XPETRA_TPETRA
100
RCP<const TpetraMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node1>
> tMV =
101
Teuchos::rcp_dynamic_cast<
const
TpetraMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node1>
>(rcpFromRef(MV));
102
103
return
tMV->clone(node2);
104
#else
105
return
Teuchos::null;
106
#endif
107
}
108
109
110
}
//namespace Xpetra
111
112
#define XPETRA_CLONER_SHORT
113
#endif //XPETRA_CLONER_HPP
Xpetra_MultiVector.hpp
Xpetra
Xpetra namespace
Definition:
Xpetra_BlockedCrsMatrix.hpp:86
Xpetra_CrsMatrixWrap.hpp
Xpetra::MultiVector
Definition:
Xpetra_MultiVector.hpp:76
Xpetra::Map
Definition:
Xpetra_Map.hpp:90
Teuchos::RCP
Xpetra::Matrix
Xpetra-specific matrix class.
Definition:
Xpetra_Matrix_fwd.hpp:51
Xpetra_TpetraMap.hpp
Xpetra::clone
RCP< Map< LocalOrdinal, GlobalOrdinal, Node2 > > clone(const Map< LocalOrdinal, GlobalOrdinal, Node1 > &map, const RCP< Node2 > &node2)
Definition:
Xpetra_Cloner.hpp:72
Xpetra::TpetraMultiVector
Definition:
Xpetra_TpetraMultiVector.hpp:90
Kokkos_DefaultNode.hpp
Xpetra::TpetraMap
Definition:
Xpetra_TpetraMap.hpp:79
Xpetra::Map::lib
virtual UnderlyingLib lib() const =0
Get the library used by this object (Tpetra or Epetra?)
Xpetra::DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node >::getMap
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const=0
The Map describing the parallel distribution of this object.
Xpetra_ConfigDefs.hpp
Xpetra::CrsMatrixWrap
Concrete implementation of Xpetra::Matrix.
Definition:
Xpetra_CrsMatrixWrap_fwd.hpp:51
Xpetra::Matrix::getRowMap
virtual const RCP< const Map > & getRowMap() const
Returns the Map that describes the row distribution in this matrix.
Definition:
Xpetra_Matrix.hpp:320
Xpetra_Exceptions.hpp
Xpetra::UseEpetra
Definition:
Xpetra_Map.hpp:82
Xpetra_Matrix.hpp
Xpetra_Map.hpp
Generated by
1.8.16