Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
Ifpack2_Details_FastILU_Base_def.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
4//
5// Copyright 2009 NTESS and the Ifpack2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
11
12#ifndef __IFPACK2_FASTILU_BASE_DEF_HPP__
13#define __IFPACK2_FASTILU_BASE_DEF_HPP__
14
16#include "Tpetra_BlockCrsMatrix.hpp"
17#include "Tpetra_BlockCrsMatrix_Helpers.hpp"
18#include "Ifpack2_Details_getCrsMatrix.hpp"
19#include <KokkosKernels_Utils.hpp>
20#include <Kokkos_Timer.hpp>
21#include <Teuchos_TimeMonitor.hpp>
22#include <Teuchos_Array.hpp>
23#include <stdexcept>
24
25namespace Ifpack2 {
26namespace Details {
27
28template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
30 FastILU_Base(Teuchos::RCP<const TRowMatrix> A)
31 : mat_(A)
32 , initFlag_(false)
33 , computedFlag_(false)
34 , nInit_(0)
35 , nComputed_(0)
36 , nApply_(0)
37 , localCrs_(Teuchos::null)
38 , localCrsNonConst_(Teuchos::null)
39 , localCrsIsOwnedCopy_(false)
40 , initTime_(0.0)
41 , computeTime_(0.0)
42 , applyTime_(0.0)
43 , crsCopyTime_(0.0)
44 , params_(Params::getDefaults()) {}
45
46template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
47Teuchos::RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
49 getDomainMap() const {
50 return mat_->getDomainMap();
51}
52
53template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
54Teuchos::RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
56 getRangeMap() const {
57 return mat_->getRangeMap();
58}
59
60template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
62 apply(const Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& X,
63 Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Y,
64 Teuchos::ETransp /*mode*/,
65 Scalar /*alpha*/,
66 Scalar /*beta*/) const {
67 const std::string timerName("Ifpack2::FastILU::apply");
68 Teuchos::RCP<Teuchos::Time> timer = Teuchos::TimeMonitor::lookupCounter(timerName);
69 if (timer.is_null()) {
70 timer = Teuchos::TimeMonitor::getNewCounter(timerName);
71 }
72 Teuchos::TimeMonitor timeMon(*timer);
73
74 if (!isInitialized() || !isComputed()) {
75 throw std::runtime_error(std::string("Called ") + getName() + "::apply() without first calling initialize() and/or compute().");
76 }
77 if (X.getNumVectors() != Y.getNumVectors()) {
78 throw std::invalid_argument(getName() + "::apply: X and Y have different numbers of vectors (pass X and Y with exactly matching dimensions)");
79 }
80 if (X.getLocalLength() != Y.getLocalLength()) {
81 throw std::invalid_argument(getName() + "::apply: X and Y have different lengths (pass X and Y with exactly matching dimensions)");
82 }
83 // zero out applyTime_ now, because the calls to applyLocalPrec() will add to it
84 applyTime_ = 0;
85 int nvecs = X.getNumVectors();
86 auto nrowsX = X.getLocalLength();
87 auto nrowsY = Y.getLocalLength();
88 if (nvecs == 1) {
89 auto x2d = X.getLocalViewDevice(Tpetra::Access::ReadOnly);
90 auto y2d = Y.getLocalViewDevice(Tpetra::Access::ReadWrite);
91 ImplScalarArray x1d(const_cast<ImplScalar*>(x2d.data()), nrowsX);
92 ImplScalarArray y1d(const_cast<ImplScalar*>(y2d.data()), nrowsY);
93
94 applyLocalPrec(x1d, y1d);
95 } else {
96 // Solve each vector one at a time (until FastILU supports multiple RHS)
97 auto x2d = X.getLocalViewDevice(Tpetra::Access::ReadOnly);
98 auto y2d = Y.getLocalViewDevice(Tpetra::Access::ReadWrite);
99 for (int i = 0; i < nvecs; i++) {
100 auto xColView1d = Kokkos::subview(x2d, Kokkos::ALL(), i);
101 auto yColView1d = Kokkos::subview(y2d, Kokkos::ALL(), i);
102 ImplScalarArray x1d(const_cast<ImplScalar*>(xColView1d.data()), nrowsX);
103 ImplScalarArray y1d(const_cast<ImplScalar*>(yColView1d.data()), nrowsY);
104
105 applyLocalPrec(x1d, y1d);
106 }
107 }
108}
109
110template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
112 setParameters(const Teuchos::ParameterList& List) {
113 // Params constructor does all parameter validation, and sets default values
114 params_ = Params(List, getName());
115}
116
117template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
119 isBlockCrs() const {
120 return params_.blockCrs && params_.blockCrsSize > 1;
121}
122
123template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
125 initialize() {
126 const std::string timerName("Ifpack2::FastILU::initialize");
127 Teuchos::RCP<Teuchos::Time> timer = Teuchos::TimeMonitor::lookupCounter(timerName);
128 if (timer.is_null()) {
129 timer = Teuchos::TimeMonitor::getNewCounter(timerName);
130 }
131 Teuchos::TimeMonitor timeMon(*timer);
132
133 if (mat_.is_null()) {
134 throw std::runtime_error(std::string("Called ") + getName() + "::initialize() but matrix was null (call setMatrix() with a non-null matrix first)");
135 }
136
137 if (isBlockCrs()) {
138 auto crs_matrix = Ifpack2::Details::getCrsMatrix(this->mat_);
139
140 if (params_.fillBlocks) {
141 // Create new TCrsMatrix with the new filled data and conver to Bcrs
142 auto crs_matrix_block_filled = Tpetra::fillLogicalBlocks(*crs_matrix, params_.blockCrsSize);
143 auto bcrs_matrix = Tpetra::convertToBlockCrsMatrix(*crs_matrix_block_filled, params_.blockCrsSize);
144 mat_ = bcrs_matrix;
145 } else {
146 // Assume input is already filled, just convert to Bcrs
147 auto bcrs_matrix = Tpetra::convertToBlockCrsMatrix(*crs_matrix, params_.blockCrsSize);
148 mat_ = bcrs_matrix;
149 }
150 }
151
152 Kokkos::Timer copyTimer;
153
154 // Try to ensure that FastILU reads structure and values from a concrete
155 // Tpetra::CrsMatrix whenever possible. This lets CrsArrayReader use its
156 // getStructureCrs/getValuesCrs fast paths instead of the generic RowMatrix
157 // host-row loop. In BlockCrs mode, keep using mat_ directly so the BCRS
158 // specialization in CrsArrayReader remains available.
159 localCrs_ = Teuchos::null;
160 localCrsNonConst_ = Teuchos::null;
161 localCrsIsOwnedCopy_ = false;
162
163 const TRowMatrix* crsArraySource = mat_.get();
164 if (!isBlockCrs()) {
165 localCrs_ = Ifpack2::Details::getCrsMatrix(mat_);
166
167 if (localCrs_.is_null()) {
168 const LocalOrdinal numRows = static_cast<LocalOrdinal>(mat_->getLocalNumRows());
169 Teuchos::Array<size_t> entriesPerRow(numRows);
170 for (LocalOrdinal i = 0; i < numRows; ++i) {
171 entriesPerRow[i] = mat_->getNumEntriesInLocalRow(i);
172 }
173
174 localCrsNonConst_ = Teuchos::rcp(new TCrsMatrix(mat_->getRowMap(), mat_->getColMap(), entriesPerRow()));
175
176 using local_inds_host_view_type = typename TRowMatrix::nonconst_local_inds_host_view_type;
177 using values_host_view_type = typename TRowMatrix::nonconst_values_host_view_type;
178
179 const size_t maxNnz = mat_->getLocalMaxNumRowEntries();
180 local_inds_host_view_type indices("FastILU local CRS indices", maxNnz);
181 values_host_view_type values("FastILU local CRS values", maxNnz);
182
183 for (LocalOrdinal i = 0; i < numRows; ++i) {
184 size_t numEntries = 0;
185 mat_->getLocalRowCopy(i, indices, values, numEntries);
186 localCrsNonConst_->insertLocalValues(
187 i,
189 reinterpret_cast<Scalar*>(values.data()),
190 indices.data());
191 }
192
193 localCrsNonConst_->fillComplete(mat_->getDomainMap(), mat_->getRangeMap());
194 localCrs_ = localCrsNonConst_;
195 localCrsIsOwnedCopy_ = true;
196 }
197
198 crsArraySource = localCrs_.get();
199 }
200
201 {
202 CrsArrayReader<Scalar, ImplScalar, LocalOrdinal, GlobalOrdinal, Node>::getStructure(
203 crsArraySource, localRowPtrsHost_, localRowPtrs_, localColInds_);
204 }
205
206 {
207 CrsArrayReader<Scalar, ImplScalar, LocalOrdinal, GlobalOrdinal, Node>::getValues(
208 crsArraySource, localValues_, localRowPtrsHost_);
209 }
210
211 crsCopyTime_ = copyTimer.seconds();
212
213 if (params_.use_metis) {
214 assert(!params_.blockCrs);
215 const std::string timerNameMetis("Ifpack2::FastILU::Metis");
216 Teuchos::RCP<Teuchos::Time> timerMetis = Teuchos::TimeMonitor::lookupCounter(timerNameMetis);
217 if (timerMetis.is_null()) {
218 timerMetis = Teuchos::TimeMonitor::getNewCounter(timerNameMetis);
219 }
220 Teuchos::TimeMonitor timeMonMetis(*timerMetis);
221#ifdef HAVE_IFPACK2_METIS
222 idx_t nrows = localRowPtrsHost_.size() - 1;
223 if (nrows > 0) {
224 // reorder will convert both graph and perm/iperm to the internal METIS integer type
225 metis_perm_ = MetisArrayHost(Kokkos::ViewAllocateWithoutInitializing("metis_perm"), nrows);
226 metis_iperm_ = MetisArrayHost(Kokkos::ViewAllocateWithoutInitializing("metis_iperm"), nrows);
227
228 // copy ColInds to host
229 auto localColIndsHost_ = Kokkos::create_mirror_view(localColInds_);
230 Kokkos::deep_copy(localColIndsHost_, localColInds_);
231
232 // prepare for calling metis
233 idx_t nnz = localColIndsHost_.size();
236
237 bool metis_symmetrize = true;
238 if (metis_symmetrize) {
239 // symmetrize
240 using OrdinalArrayMirror = typename OrdinalArray::host_mirror_type;
241 KokkosKernels::Impl::symmetrize_graph_symbolic_hashmap<
242 OrdinalArrayHost, OrdinalArrayMirror, MetisArrayHost, MetisArrayHost, Kokkos::HostSpace::execution_space>(nrows, localRowPtrsHost_, localColIndsHost_, metis_rowptr, metis_colidx);
243
244 // remove diagonals
245 idx_t old_nnz = nnz = 0;
246 for (idx_t i = 0; i < nrows; i++) {
247 for (LocalOrdinal k = old_nnz; k < metis_rowptr(i + 1); k++) {
248 if (metis_colidx(k) != i) {
250 nnz++;
251 }
252 }
253 old_nnz = metis_rowptr(i + 1);
254 metis_rowptr(i + 1) = nnz;
255 }
256 } else {
257 // copy and remove diagonals
258 metis_rowptr = MetisArrayHost(Kokkos::ViewAllocateWithoutInitializing("metis_rowptr"), nrows + 1);
259 metis_colidx = MetisArrayHost(Kokkos::ViewAllocateWithoutInitializing("metis_colidx"), nnz);
260 nnz = 0;
261 metis_rowptr(0) = 0;
262 for (idx_t i = 0; i < nrows; i++) {
263 for (LocalOrdinal k = localRowPtrsHost_(i); k < localRowPtrsHost_(i + 1); k++) {
264 if (localColIndsHost_(k) != i) {
266 nnz++;
267 }
268 }
269 metis_rowptr(i + 1) = nnz;
270 }
271 }
272
273 // call metis
274 int info = METIS_NodeND(&nrows, metis_rowptr.data(), metis_colidx.data(),
275 NULL, NULL, metis_perm_.data(), metis_iperm_.data());
276 if (METIS_OK != info) {
277 throw std::runtime_error(std::string("METIS_NodeND returned info = ") + std::to_string(info));
278 }
279 }
280#else
281 throw std::runtime_error(std::string("TPL METIS is not enabled"));
282#endif
283 }
284
285 initLocalPrec(); // note: initLocalPrec updates initTime
286 initFlag_ = true;
287 nInit_++;
288}
289
290template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
295
296template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
298 compute() {
299 if (!initFlag_) {
300 throw std::runtime_error(getName() + ": initialize() must be called before compute()");
301 }
302
303 const std::string timerName("Ifpack2::FastILU::compute");
304 Teuchos::RCP<Teuchos::Time> timer = Teuchos::TimeMonitor::lookupCounter(timerName);
305 if (timer.is_null()) {
306 timer = Teuchos::TimeMonitor::getNewCounter(timerName);
307 }
308 Teuchos::TimeMonitor timeMon(*timer);
309
310 // get copy of values array from matrix
311 Kokkos::Timer copyTimer;
312 const TRowMatrix* crsArraySource = mat_.get();
313
314 if (!isBlockCrs() && !localCrs_.is_null()) {
315 if (localCrsIsOwnedCopy_) {
316 localCrsNonConst_->resumeFill();
317
318 using local_inds_host_view_type = typename TRowMatrix::nonconst_local_inds_host_view_type;
319 using values_host_view_type = typename TRowMatrix::nonconst_values_host_view_type;
320
321 const LocalOrdinal numRows = static_cast<LocalOrdinal>(mat_->getLocalNumRows());
322 const size_t maxNnz = mat_->getLocalMaxNumRowEntries();
323 local_inds_host_view_type indices("FastILU refresh CRS indices", maxNnz);
324 values_host_view_type values("FastILU refresh CRS values", maxNnz);
325
326 for (LocalOrdinal i = 0; i < numRows; ++i) {
327 size_t numEntries = 0;
328 mat_->getLocalRowCopy(i, indices, values, numEntries);
329 localCrsNonConst_->replaceLocalValues(
330 i,
332 reinterpret_cast<Scalar*>(values.data()),
333 indices.data());
334 }
335
336 localCrsNonConst_->fillComplete(mat_->getDomainMap(), mat_->getRangeMap());
337 localCrs_ = localCrsNonConst_;
338 }
339
340 crsArraySource = localCrs_.get();
341 }
342
343 {
344 CrsArrayReader<Scalar, ImplScalar, LocalOrdinal, GlobalOrdinal, Node>::getValues(
345 crsArraySource, localValues_, localRowPtrsHost_);
346 }
347
348 crsCopyTime_ += copyTimer.seconds(); // add to the time spent getting rowptrs/colinds
349 computeLocalPrec(); // this updates computeTime_
350 computedFlag_ = true;
351 nComputed_++;
352}
353
354template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
356 isComputed() const {
357 return computedFlag_;
358}
359
360template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
361Teuchos::RCP<const Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
366
367template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
372
373template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
378
379template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
384
385template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
390
391template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
393 getComputeTime() const {
394 return computeTime_;
395}
396
397template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
399 getApplyTime() const {
400 return applyTime_;
401}
402
403template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
405 getCopyTime() const {
406 return crsCopyTime_;
407}
408
409template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
411 checkLocalILU() const {
412 // if the underlying type of this doesn't implement checkLocalILU, it's an illegal operation
413 throw std::runtime_error(std::string("Preconditioner type Ifpack2::Details::") + getName() + " doesn't support checkLocalILU().");
414}
415
416template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
418 checkLocalIC() const {
419 // if the underlying type of this doesn't implement checkLocalIC, it's an illegal operation
420 throw std::runtime_error(std::string("Preconditioner type Ifpack2::Details::") + getName() + " doesn't support checkLocalIC().");
421}
422
423template <typename Scalar, typename LocalOrdinal, typename GlobalOrdinal, typename Node>
425 std::ostringstream os;
426 // Output is a YAML dictionary
427 os << "\"Ifpack2::Details::" << getName() << "\": {";
428 os << "Initialized: " << (isInitialized() ? "true" : "false") << ", ";
429 os << "Computed: " << (isComputed() ? "true" : "false") << ", ";
430 os << "Sweeps: " << getSweeps() << ", ";
431 os << "Triangular solve type: " << getSpTrsvType() << ", ";
432 if (getSpTrsvType() == "Fast") {
433 os << "# of triangular solve iterations: " << getNTrisol() << ", ";
434 }
435 if (mat_.is_null()) {
436 os << "Matrix: null";
437 } else {
438 os << "Global matrix dimensions: [" << mat_->getGlobalNumRows() << ", " << mat_->getGlobalNumCols() << "]";
439 os << ", Global nnz: " << mat_->getGlobalNumEntries();
440 }
441 return os.str();
442}
443
444template <typename Scalar, typename LocalOrdinal, typename GlobalOrdinal, typename Node>
446 setMatrix(const Teuchos::RCP<const TRowMatrix>& A) {
447 if (A.is_null()) {
448 throw std::invalid_argument(std::string("Ifpack2::Details::") + getName() + "::setMatrix() called with a null matrix. Pass a non-null matrix.");
449 }
450 // bmk note: this modeled after RILUK::setMatrix
451 if (mat_.get() != A.get()) {
452 mat_ = A;
453 localCrs_ = Teuchos::null;
454 localCrsNonConst_ = Teuchos::null;
455 localCrsIsOwnedCopy_ = false;
456 initFlag_ = false;
457 computedFlag_ = false;
458 }
459}
460
461template <typename Scalar, typename LocalOrdinal, typename GlobalOrdinal, typename Node>
465 Params p;
466 p.use_metis = false;
467 p.sptrsv_algo = FastILU::SpTRSV::Fast;
468 p.nFact = 5; // # of sweeps for computing fastILU
469 p.nTrisol = 5; // # of sweeps for applying fastSpTRSV
470 p.level = 0; // level of ILU
471 p.omega = 1.0; // damping factor for fastILU
472 p.shift = 0;
473 p.guessFlag = true;
474 p.blockSizeILU = 1; // # of nonzeros / thread, for fastILU
475 p.blockSize = 1; // # of rows / thread, for SpTRSV
476 p.blockCrs = false; // whether to use block CRS for fastILU
477 p.blockCrsSize = 1; // block size for block CRS
478 p.fillBlocks = false; // whether input matrix needs to be filled
479 return p;
480}
481
482template <typename Scalar, typename LocalOrdinal, typename GlobalOrdinal, typename Node>
483FastILU_Base<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
484 Params::Params(const Teuchos::ParameterList& pL, std::string precType) {
485 *this = getDefaults();
486// For each parameter, check that if the parameter exists, it has the right type
487// Then get the value and sanity check it
488// If the parameter doesn't exist, leave it as default (from Params::getDefaults())
489//"sweeps" aka nFact
490#define TYPE_ERROR(name, correctTypeName) \
491 { throw std::invalid_argument(precType + "::setParameters(): parameter \"" + name + "\" has the wrong type (must be " + correctTypeName + ")"); }
492#define CHECK_VALUE(param, member, cond, msg) \
493 { \
494 if (cond) { \
495 throw std::invalid_argument(precType + "::setParameters(): parameter \"" + param + "\" has value " + std::to_string(member) + " but " + msg); \
496 } \
497 }
498
499 // metis
500 if (pL.isParameter("metis")) {
501 if (pL.isType<bool>("metis"))
502 use_metis = pL.get<bool>("metis");
503 else
504 TYPE_ERROR("metis", "bool");
505 }
506
507 if (pL.isParameter("sweeps")) {
508 if (pL.isType<int>("sweeps")) {
509 nFact = pL.get<int>("sweeps");
510 CHECK_VALUE("sweeps", nFact, nFact < 1, "must have a value of at least 1");
511 } else
512 TYPE_ERROR("sweeps", "int");
513 }
514 std::string sptrsv_type = "Fast";
515 if (pL.isParameter("triangular solve type")) {
516 sptrsv_type = pL.get<std::string>("triangular solve type");
517 }
518 if (sptrsv_type == "Standard Host") {
519 sptrsv_algo = FastILU::SpTRSV::StandardHost;
520 } else if (sptrsv_type == "Standard") {
521 sptrsv_algo = FastILU::SpTRSV::Standard;
522 }
523
524 //"triangular solve iterations" aka nTrisol
525 if (pL.isParameter("triangular solve iterations")) {
526 if (pL.isType<int>("triangular solve iterations")) {
527 nTrisol = pL.get<int>("triangular solve iterations");
528 CHECK_VALUE("triangular solve iterations", nTrisol, nTrisol < 1, "must have a value of at least 1");
529 } else
530 TYPE_ERROR("triangular solve iterations", "int");
531 }
532 //"level"
533 if (pL.isParameter("level")) {
534 if (pL.isType<int>("level")) {
535 level = pL.get<int>("level");
536 } else if (pL.isType<double>("level")) {
537 // Level can be read as double (like in ILUT), but must be an exact integer
538 // Any integer used for level-of-fill can be represented exactly in double (so use exact compare)
539 double dval = pL.get<double>("level");
540 double ipart;
541 double fpart = modf(dval, &ipart);
542 level = ipart;
543 CHECK_VALUE("level", level, fpart != 0, "must be an integral value");
544 } else {
545 TYPE_ERROR("level", "int");
546 }
547 CHECK_VALUE("level", level, level < 0, "must be nonnegative");
548 }
549 if (pL.isParameter("damping factor")) {
550 if (pL.isType<double>("damping factor"))
551 omega = pL.get<double>("damping factor");
552 else
553 TYPE_ERROR("damping factor", "double");
554 }
555 if (pL.isParameter("shift")) {
556 if (pL.isType<double>("shift"))
557 shift = pL.get<double>("shift");
558 else
559 TYPE_ERROR("shift", "double");
560 }
561 //"guess" aka guessFlag
562 if (pL.isParameter("guess")) {
563 if (pL.isType<bool>("guess"))
564 guessFlag = pL.get<bool>("guess");
565 else
566 TYPE_ERROR("guess", "bool");
567 }
568 //"block size" aka blkSz
569 if (pL.isParameter("block size for ILU")) {
570 if (pL.isType<int>("block size for ILU")) {
571 blockSizeILU = pL.get<int>("block size for ILU");
572 CHECK_VALUE("block size for ILU", blockSizeILU, blockSizeILU < 1, "must have a value of at least 1");
573 } else
574 TYPE_ERROR("block size for ILU", "int");
575 }
576 //"block size" aka blkSz
577 if (pL.isParameter("block size for SpTRSV")) {
578 if (pL.isType<int>("block size for SpTRSV"))
579 blockSize = pL.get<int>("block size for SpTRSV");
580 else
581 TYPE_ERROR("block size for SpTRSV", "int");
582 }
583 //"block crs" aka blockCrs
584 if (pL.isParameter("block crs")) {
585 if (pL.isType<bool>("block crs"))
586 blockCrs = pL.get<bool>("block crs");
587 else
588 TYPE_ERROR("block crs", "bool");
589 }
590 //"block crs block size" aka blockCrsSize
591 if (pL.isParameter("block crs block size")) {
592 if (pL.isType<int>("block crs block size"))
593 blockCrsSize = pL.get<int>("block crs block size");
594 else
595 TYPE_ERROR("block crs block size", "int");
596 }
597 //"fill blocks for input" aka fillBlocks
598 if (pL.isParameter("fill blocks for input")) {
599 if (pL.isType<bool>("fill blocks for input"))
600 blockCrsSize = pL.get<bool>("fill blocks for input");
601 else
602 TYPE_ERROR("fill blocks for input", "bool");
603 }
604
605#undef CHECK_VALUE
606#undef TYPE_ERROR
607}
608
609#define IFPACK2_DETAILS_FASTILU_BASE_INSTANT(S, L, G, N) \
610 template class Ifpack2::Details::FastILU_Base<S, L, G, N>;
611
612} // namespace Details
613} // namespace Ifpack2
614
615#endif
Provides functions for retrieving local CRS arrays (row pointers, column indices, and values) from Tp...
The base class of the Ifpack2 FastILU wrappers (Filu, Fildl and Fic)
Definition Ifpack2_Details_FastILU_Base_decl.hpp:38
Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::impl_scalar_type ImplScalar
Kokkos scalar type.
Definition Ifpack2_Details_FastILU_Base_decl.hpp:45
double getInitializeTime() const
Get the time spent in the last initialize() call.
Definition Ifpack2_Details_FastILU_Base_def.hpp:387
virtual void checkLocalILU() const
Verify and print debug information about the underlying ILU preconditioner (only supported if this is...
Definition Ifpack2_Details_FastILU_Base_def.hpp:411
void setMatrix(const Teuchos::RCP< const TRowMatrix > &A)
Definition Ifpack2_Details_FastILU_Base_def.hpp:446
void compute()
Compute the preconditioner.
Definition Ifpack2_Details_FastILU_Base_def.hpp:298
double getComputeTime() const
Get the time spent in the last compute() call.
Definition Ifpack2_Details_FastILU_Base_def.hpp:393
Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > TCrsMatrix
Tpetra CRS matrix.
Definition Ifpack2_Details_FastILU_Base_decl.hpp:49
Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > TRowMatrix
Tpetra row matrix.
Definition Ifpack2_Details_FastILU_Base_decl.hpp:47
double getCopyTime() const
Get the time spent deep copying local 3-array CRS out of the matrix.
Definition Ifpack2_Details_FastILU_Base_def.hpp:405
int getNumApply() const
Get the number of times apply() was called.
Definition Ifpack2_Details_FastILU_Base_def.hpp:381
void initialize()
Initialize the preconditioner.
Definition Ifpack2_Details_FastILU_Base_def.hpp:125
bool isInitialized() const
Whether initialize() has been called since the last time the matrix's structure was changed.
Definition Ifpack2_Details_FastILU_Base_def.hpp:292
Kokkos::View< LocalOrdinal *, execution_space >::host_mirror_type OrdinalArrayHost
Array of LocalOrdinal on host.
Definition Ifpack2_Details_FastILU_Base_decl.hpp:57
FastILU_Base(Teuchos::RCP< const TRowMatrix > mat_)
Constructor.
Definition Ifpack2_Details_FastILU_Base_def.hpp:30
void setParameters(const Teuchos::ParameterList &List)
Validate parameters, and set defaults when parameters are not provided.
Definition Ifpack2_Details_FastILU_Base_def.hpp:112
void apply(const TMultiVec &X, TMultiVec &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Apply the preconditioner.
Definition Ifpack2_Details_FastILU_Base_def.hpp:62
double getApplyTime() const
Get the time spent in the last apply() call.
Definition Ifpack2_Details_FastILU_Base_def.hpp:399
Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Get the domain map of the matrix.
Definition Ifpack2_Details_FastILU_Base_def.hpp:49
virtual void checkLocalIC() const
Verify and print debug information about the underlying IC preconditioner.
Definition Ifpack2_Details_FastILU_Base_def.hpp:418
int getNumInitialize() const
Get the number of times initialize() was called.
Definition Ifpack2_Details_FastILU_Base_def.hpp:369
Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
Get the range map of the matrix.
Definition Ifpack2_Details_FastILU_Base_def.hpp:56
Teuchos::RCP< const TRowMatrix > getMatrix() const
Get the current matrix.
Definition Ifpack2_Details_FastILU_Base_def.hpp:363
std::string description() const
Return a brief description of the preconditioner, in YAML format.
Definition Ifpack2_Details_FastILU_Base_def.hpp:424
Kokkos::View< ImplScalar *, execution_space > ImplScalarArray
Array of Scalar on device.
Definition Ifpack2_Details_FastILU_Base_decl.hpp:59
int getNumCompute() const
Get the number of times compute() was called.
Definition Ifpack2_Details_FastILU_Base_def.hpp:375
bool isComputed() const
Whether compute() has been called since the last time the matrix's values or structure were changed.
Definition Ifpack2_Details_FastILU_Base_def.hpp:356
Ifpack2's implementation of Trilinos::Details::LinearSolver interface.
Definition Ifpack2_Details_LinearSolver_decl.hpp:75
Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:40