Xpetra
Version of the Day
Loading...
Searching...
No Matches
Xpetra_IO_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
#ifndef PACKAGES_XPETRA_SUP_UTILS_XPETRA_IO_HPP_
11
#define PACKAGES_XPETRA_SUP_UTILS_XPETRA_IO_HPP_
12
13
#include <fstream>
14
#include "
Xpetra_ConfigDefs.hpp
"
15
16
#include <
MatrixMarket_Tpetra.hpp
>
17
#include <Tpetra_RowMatrixTransposer.hpp>
18
#include <TpetraExt_MatrixMatrix.hpp>
19
#include <Xpetra_TpetraMultiVector.hpp>
20
#include <Xpetra_TpetraCrsGraph.hpp>
21
#include <Xpetra_TpetraCrsMatrix.hpp>
22
#include <Xpetra_TpetraBlockCrsMatrix.hpp>
23
#include "
Tpetra_Util.hpp
"
24
25
#include "Xpetra_Matrix.hpp"
26
#include "Xpetra_MatrixMatrix.hpp"
27
#include "Xpetra_Helpers.hpp"
28
#include "
Xpetra_CrsGraph.hpp
"
29
#include "Xpetra_CrsMatrixWrap.hpp"
30
#include "Xpetra_BlockedCrsMatrix.hpp"
31
32
#include "Xpetra_Map.hpp"
33
#include "Xpetra_StridedMap.hpp"
34
#include "Xpetra_StridedMapFactory.hpp"
35
#include "Xpetra_MapExtractor.hpp"
36
#include "Xpetra_MatrixFactory.hpp"
37
38
#include <
Teuchos_TestForException.hpp
>
39
#include <Teuchos_MatrixMarket_Raw_Writer.hpp>
40
#include <Teuchos_MatrixMarket_Raw_Reader.hpp>
41
#include <string>
42
43
namespace
Xpetra
{
44
49
template
<
class
Scalar,
50
class
LocalOrdinal = int,
51
class
GlobalOrdinal = LocalOrdinal,
52
class
Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
53
class
IO {
54
private
:
55
#undef XPETRA_IO_SHORT
56
#include "
Xpetra_UseShortNames.hpp
"
57
58
public
:
60
// @{
61
/*static RCP<const Tpetra::MultiVector<SC,LO,GO,NO> > MV2TpetraMV(RCP<MultiVector> const vec);
62
static RCP< Tpetra::MultiVector<SC,LO,GO,NO> > MV2NonConstTpetraMV(RCP<MultiVector> vec);
63
static RCP< Tpetra::MultiVector<SC,LO,GO,NO> > MV2NonConstTpetraMV2(MultiVector& vec);
64
65
static const Tpetra::MultiVector<SC,LO,GO,NO>& MV2TpetraMV(const MultiVector& vec);
66
static Tpetra::MultiVector<SC,LO,GO,NO>& MV2NonConstTpetraMV(MultiVector& vec);
67
68
static RCP<const Tpetra::CrsMatrix<SC,LO,GO,NO> > Op2TpetraCrs(RCP<const Matrix> Op);
69
static RCP< Tpetra::CrsMatrix<SC,LO,GO,NO> > Op2NonConstTpetraCrs(RCP<Matrix> Op);
70
71
static const Tpetra::CrsMatrix<SC,LO,GO,NO>& Op2TpetraCrs(const Matrix& Op);
72
static Tpetra::CrsMatrix<SC,LO,GO,NO>& Op2NonConstTpetraCrs(Matrix& Op);
73
74
static RCP<const Tpetra::RowMatrix<SC,LO,GO,NO> > Op2TpetraRow(RCP<const Matrix> Op);
75
static RCP< Tpetra::RowMatrix<SC,LO,GO,NO> > Op2NonConstTpetraRow(RCP<Matrix> Op);*/
76
77
static
const
RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node>
> Map2TpetraMap(
const
Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>
& map);
78
80
81
82
static
void
Write(
const
std::string& fileName,
const
Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>
& M);
83
85
static
void
Write(
const
std::string& fileName,
const
Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>
& vec);
86
87
// CAG:
88
// The class is templated on the usual SC-LO-GO-NO.
89
// Instead of instantiating the entire class using Scalar=LO or GO and then dealing with the headaches that integer-valued CrsMatrix creates, we use these two methods.
90
92
static
void
WriteLOMV(
const
std::string& fileName,
const
Xpetra::MultiVector<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node>
& vec);
93
95
static
void
WriteGOMV(
const
std::string& fileName,
const
Xpetra::MultiVector<GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node>
& vec);
96
98
static
void
Write(
const
std::string& fileName,
const
Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>
& Op,
const
bool
& writeAllMaps =
false
);
99
101
static
void
WriteLocal(
const
std::string& fileName,
const
Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>
& Op);
102
117
static
void
WriteBlockedCrsMatrix(
const
std::string& fileName,
const
Xpetra::BlockedCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Op,
const
bool
& writeAllMaps =
false
);
118
120
static
Teuchos::RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>
> Read(
const
std::string& fileName,
Xpetra::UnderlyingLib
lib,
const
RCP
<
const
Teuchos::Comm<int>
>& comm,
bool
binary =
false
);
121
126
static
Teuchos::RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>
>
127
Read(
const
std::string& filename,
128
const
RCP
<
const
Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>
> rowMap,
129
RCP
<
const
Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>
> colMap = Teuchos::null,
130
const
RCP
<
const
Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>
> domainMap = Teuchos::null,
131
const
RCP
<
const
Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>
> rangeMap = Teuchos::null,
132
const
bool
callFillComplete =
true
,
133
const
bool
binary =
false
,
134
const
bool
tolerant =
false
,
135
const
bool
debug =
false
);
136
140
size of the communicator of the rowMap and RANK is the MPI ranks
141
of the calling process.
142
143
If only rowMap is specified, then it is used for the domainMap and rangeMap, as well.
144
*/
145
static
Teuchos::RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>
> ReadLocal(
const
std::string& filename,
146
const
RCP
<
const
Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>
> rowMap,
147
RCP
<
const
Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>
> colMap,
148
const
RCP
<
const
Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>
> domainMap = Teuchos::null,
149
const
RCP
<
const
Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>
> rangeMap = Teuchos::null,
150
const
bool
callFillComplete =
true
,
151
const
bool
binary =
false
,
152
const
bool
tolerant =
false
,
153
const
bool
debug =
false
);
155
156
157
static
RCP<MultiVector>
ReadMultiVector(
const
std::string& fileName,
158
const
RCP<const Map>
& map,
159
const
bool
binary =
false
);
160
162
static
RCP<Xpetra::MultiVector<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node>
> ReadMultiVectorLO(
const
std::string& fileName,
163
const
RCP<const Map>
& map,
164
const
bool
binary =
false
);
165
166
static
RCP<const Map>
ReadMap(
const
std::string& fileName,
167
Xpetra::UnderlyingLib
lib,
168
const
RCP
<
const
Teuchos::Comm<int>
>& comm,
169
const
bool
binary =
false
);
170
175
the block in row = 0 and col = 2, for example.
176
177
We also read the range and domain maps of each block as well of the full blocked operator
178
in order to enable reconstruction of the MapExtractor objects for range and domain maps.
179
180
@param fileName String to indicate file name of files to be written
181
@param lib Underlying type of linear algebra package
182
@param comm Communicator
183
*/
184
static
RCP<const Xpetra::BlockedCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>
> ReadBlockedCrsMatrix(
const
std::string& fileName,
Xpetra::UnderlyingLib
lib,
const
RCP
<
const
Teuchos::Comm<int>
>& comm);
185
187
template
<
class
T>
188
static
std::string
toString
(
const
T& what);
189
};
190
191
}
// end namespace Xpetra
192
193
#define XPETRA_IO_SHORT
194
195
#endif
/* PACKAGES_XPETRA_SUP_UTILS_XPETRA_IO_HPP_ */
MatrixMarket_Tpetra.hpp
Teuchos_TestForException.hpp
Tpetra_Util.hpp
Xpetra_ConfigDefs.hpp
Xpetra_CrsGraph.hpp
Xpetra_UseShortNames.hpp
Teuchos::Comm
Teuchos::RCP
Xpetra::Map
Definition
Xpetra_Map_decl.hpp:35
Xpetra::Matrix
Xpetra-specific matrix class.
Definition
Xpetra_Matrix_decl.hpp:60
Xpetra::MultiVector
Definition
Xpetra_MultiVector_decl.hpp:45
Xpetra
Xpetra namespace
Definition
Xpetra_BlockedCrsMatrix_decl.hpp:52
Xpetra::UnderlyingLib
UnderlyingLib
Definition
Xpetra_Map_decl.hpp:26
Xpetra::toString
std::string toString(Xpetra::UnderlyingLib lib)
Convert a Xpetra::UnderlyingLib to a std::string.
Definition
Xpetra_Utils.cpp:15
src
Utils
Xpetra_IO_decl.hpp
Generated by
1.15.0