Xpetra Version of the Day
Loading...
Searching...
No Matches
Xpetra_MatrixFactory2_decl.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Xpetra: A linear algebra interface package
4//
5// Copyright 2012 NTESS and the Xpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10// WARNING: This code is experimental. Backwards compatibility should not be expected.
11
12#ifndef XPETRA_MATRIXFACTORY2_DECL_HPP
13#define XPETRA_MATRIXFACTORY2_DECL_HPP
14
15#include "Xpetra_ConfigDefs.hpp"
17#include "Xpetra_Matrix.hpp"
18#include "Xpetra_CrsMatrixWrap.hpp"
20#include "Xpetra_Map.hpp"
21#include "Xpetra_BlockedMap.hpp"
22#include "Xpetra_Vector.hpp"
23#include "Xpetra_BlockedVector.hpp"
24#include "Xpetra_Exceptions.hpp"
25
26namespace Xpetra {
27
28template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
30#undef XPETRA_MATRIXFACTORY2_SHORT
32
33 public:
35};
36#define XPETRA_MATRIXFACTORY2_SHORT
37
38// template<>
39// class MatrixFactory2<double,int,int,typename Xpetra::Matrix<double, int, int>::node_type> {
40template <class Node>
41class MatrixFactory2<double, int, int, Node> {
42 typedef double Scalar;
43 typedef int LocalOrdinal;
44 typedef int GlobalOrdinal;
45 // typedef Matrix<double, int, GlobalOrdinal>::node_type Node;
46#undef XPETRA_MATRIXFACTORY2_SHORT
48 public:
50 RCP<const CrsMatrixWrap> oldOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(A);
51 if (oldOp == Teuchos::null)
52 throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
53
54 RCP<const CrsMatrix> oldCrsOp = oldOp->getCrsMatrix();
55
56 // Underlying matrix is Tpetra
57 RCP<const TpetraCrsMatrix> oldTCrsOp = Teuchos::rcp_dynamic_cast<const TpetraCrsMatrix>(oldCrsOp);
58 if (oldTCrsOp != Teuchos::null) {
59 RCP<CrsMatrix> newTCrsOp(new TpetraCrsMatrix(*oldTCrsOp));
60 RCP<CrsMatrixWrap> newOp(new CrsMatrixWrap(newTCrsOp));
61 if (setFixedBlockSize)
62 newOp->SetFixedBlockSize(A->GetFixedBlockSize());
63 return newOp;
64 }
65 return Teuchos::null;
66
67 } // BuildCopy
68};
69
70#define XPETRA_MATRIXFACTORY2_SHORT
71
72#ifdef HAVE_XPETRA_INT_LONG_LONG
73template <class Node>
74class MatrixFactory2<double, int, long long, Node> {
75 typedef double Scalar;
76 typedef int LocalOrdinal;
77 typedef long long GlobalOrdinal;
78 // typedef Matrix<double, int, GlobalOrdinal>::node_type Node;
79#undef XPETRA_MATRIXFACTORY2_SHORT
81 public:
82 static RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > BuildCopy(const RCP<const Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > A, bool setFixedBlockSize = true) {
83 RCP<const CrsMatrixWrap> oldOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(A);
84 if (oldOp == Teuchos::null)
85 throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
86
87 RCP<const CrsMatrix> oldCrsOp = oldOp->getCrsMatrix();
88
89 // Underlying matrix is Tpetra
90 RCP<const TpetraCrsMatrix> oldTCrsOp = Teuchos::rcp_dynamic_cast<const TpetraCrsMatrix>(oldCrsOp);
91 if (oldTCrsOp != Teuchos::null) {
92 RCP<CrsMatrix> newTCrsOp(new TpetraCrsMatrix(*oldTCrsOp));
93 RCP<CrsMatrixWrap> newOp(new CrsMatrixWrap(newTCrsOp));
94 if (setFixedBlockSize)
95 newOp->SetFixedBlockSize(A->GetFixedBlockSize());
96 return newOp;
97 }
98
99 return Teuchos::null; // make compiler happy
100 }
101};
102#endif // HAVE_XPETRA_INT_LONG_LONG
103
104#define XPETRA_MATRIXFACTORY2_SHORT
105
106} // namespace Xpetra
107
108#define XPETRA_MATRIXFACTORY2_SHORT
109
110#endif // ifndef XPETRA_MATRIXFACTORY2_DECL_HPP
Concrete implementation of Xpetra::Matrix.
Exception indicating invalid cast attempted.
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > BuildCopy(const RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > A, bool setFixedBlockSize=true)
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > BuildCopy(const RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > A, bool setFixedBlockSize=true)
Xpetra-specific matrix class.