MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_Amesos2Smoother_def.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// MueLu: A package for multigrid based preconditioning
4//
5// Copyright 2012 NTESS and the MueLu contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef MUELU_AMESOS2SMOOTHER_DEF_HPP
11#define MUELU_AMESOS2SMOOTHER_DEF_HPP
12
13#include <algorithm>
14
15#include "Kokkos_Core_fwd.hpp"
16#include "MueLu_ConfigDefs.hpp"
17#include <Xpetra_Matrix.hpp>
18#include <Xpetra_IO.hpp>
19
20#include <Amesos2_config.h>
21#include <Amesos2.hpp>
22
24#include "MueLu_Level.hpp"
25#include "MueLu_Utilities.hpp"
26#include "MueLu_Monitor.hpp"
27#include "Tpetra_Access.hpp"
28
29#if KOKKOSKERNELS_VERSION >= 50200
30#include "KokkosLapack_potrf.hpp"
31#include "KokkosLapack_trtri.hpp"
32#else
33#include <Teuchos_LAPACK.hpp>
34#endif
35
36namespace MueLu {
37
38template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
40 Projection(RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& Nullspace) {
41 localMap_ = Xpetra::MapFactory<LocalOrdinal, GlobalOrdinal, Node>::Build(Nullspace->getMap()->lib(),
42 Nullspace->getNumVectors(),
43 Nullspace->getMap()->getIndexBase(),
44 Nullspace->getMap()->getComm(),
45 Xpetra::LocallyReplicated);
46
47 Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > tempMV = Xpetra::MultiVectorFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build(localMap_, Nullspace->getNumVectors(), false);
48 const Scalar ONE = Teuchos::ScalarTraits<Scalar>::one();
49 const Scalar ZERO = Teuchos::ScalarTraits<Scalar>::zero();
50 tempMV->multiply(Teuchos::CONJ_TRANS, Teuchos::NO_TRANS, ONE, *Nullspace, *Nullspace, ZERO);
51
52#if KOKKOSKERNELS_VERSION >= 50200
53 Kokkos::View<typename Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::impl_scalar_type**, Kokkos::LayoutLeft, Kokkos::HostSpace> Q("Q", Nullspace->getNumVectors(), Nullspace->getNumVectors());
54 {
55 auto dots = tempMV->getLocalViewHost(Tpetra::Access::ReadOnly);
56 Kokkos::deep_copy(Q, dots);
57 }
58
59 KokkosLapack::potrf("L", Q);
60 int ret = KokkosLapack::trtri("L", "N", Q);
61 TEUCHOS_ASSERT(ret == 0);
62#else
63 Kokkos::View<Scalar**, Kokkos::LayoutLeft, Kokkos::HostSpace> Q("Q", Nullspace->getNumVectors(), Nullspace->getNumVectors());
64 int LDQ;
65 {
66 auto dots = tempMV->getLocalViewHost(Tpetra::Access::ReadOnly);
67 Kokkos::deep_copy(Q, dots);
68 LDQ = Q.stride(1);
69 }
70
71 Teuchos::LAPACK<LocalOrdinal, Scalar> lapack;
72 int info = 0;
73 lapack.POTRF('L', Nullspace->getNumVectors(), Q.data(), LDQ, &info);
74 TEUCHOS_ASSERT(info == 0);
75 lapack.TRTRI('L', 'N', Nullspace->getNumVectors(), Q.data(), LDQ, &info);
76 TEUCHOS_ASSERT(info == 0);
77#endif
78
79 Nullspace_ = Xpetra::MultiVectorFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build(Nullspace->getMap(), Nullspace->getNumVectors());
80
81 for (size_t i = 0; i < Nullspace->getNumVectors(); i++) {
82 for (size_t j = 0; j <= i; j++) {
83 Nullspace_->getVectorNonConst(i)->update(Q(i, j), *Nullspace->getVector(j), ONE);
84 }
85 }
86}
87
88template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
90 projectOut(Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& X) {
91 const Scalar ONE = Teuchos::ScalarTraits<Scalar>::one();
92 const Scalar ZERO = Teuchos::ScalarTraits<Scalar>::zero();
93
94 // Project X onto orthonormal nullspace
95 // Nullspace_ ^T * X
96 if (tempMV_.is_null() || tempMV_->getNumVectors() != X.getNumVectors())
97 tempMV_ = Xpetra::MultiVectorFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build(localMap_, X.getNumVectors());
98 Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& tempMV = tempMV_;
99 tempMV->multiply(Teuchos::CONJ_TRANS, Teuchos::NO_TRANS, ONE, *Nullspace_, X, ZERO);
100 auto dots = tempMV->getLocalViewHost(Tpetra::Access::ReadOnly);
101 bool doProject = true;
102 for (size_t i = 0; i < X.getNumVectors(); i++) {
103 for (size_t j = 0; j < Nullspace_->getNumVectors(); j++) {
104 doProject = doProject || (Teuchos::ScalarTraits<Scalar>::magnitude(dots(j, i)) > 100 * Teuchos::ScalarTraits<Scalar>::eps());
105 }
106 }
107 if (doProject) {
108 for (size_t i = 0; i < X.getNumVectors(); i++) {
109 for (size_t j = 0; j < Nullspace_->getNumVectors(); j++) {
110 X.getVectorNonConst(i)->update(-dots(j, i), *Nullspace_->getVector(j), ONE);
111 }
112 }
113 }
114}
115
116template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
117Amesos2Smoother<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Amesos2Smoother(const std::string& type, const Teuchos::ParameterList& paramList)
118 : type_(type)
119 , useTransformation_(false) {
120 this->SetParameterList(paramList);
121
122 if (!type_.empty()) {
123 // Transform string to "Abcde" notation
124 std::transform(type_.begin(), type_.end(), type_.begin(), ::tolower);
125 std::transform(type_.begin(), ++type_.begin(), type_.begin(), ::toupper);
126 }
127 if (type_ == "Superlu_dist")
128 type_ = "Superludist";
129
130 // Try to come up with something availble
131 // Order corresponds to our preference
132 // TODO: It would be great is Amesos2 provides directly this kind of logic for us
133 if (type_ == "" || Amesos2::query(type_) == false) {
134 std::string oldtype = type_;
135#if defined(HAVE_AMESOS2_KLU2)
136 type_ = "Klu";
137#elif defined(HAVE_AMESOS2_SUPERLU)
138 type_ = "Superlu";
139#elif defined(HAVE_AMESOS2_SUPERLUDIST)
140 type_ = "Superludist";
141#elif defined(HAVE_AMESOS2_BASKER)
142 type_ = "Basker";
143#else
144 this->declareConstructionOutcome(true, std::string("Amesos2 has been compiled without SuperLU_DIST, SuperLU, Klu, or Basker. By default, MueLu tries") +
145 "to use one of these libraries. Amesos2 must be compiled with one of these solvers, " +
146 "or a valid Amesos2 solver has to be specified explicitly.");
147 return;
148#endif
149 if (oldtype != "")
150 this->GetOStream(Warnings0) << "MueLu::Amesos2Smoother: \"" << oldtype << "\" is not available. Using \"" << type_ << "\" instead" << std::endl;
151 else
152 this->GetOStream(Runtime1) << "MueLu::Amesos2Smoother: using \"" << type_ << "\"" << std::endl;
153 }
154
155 // Check the validity of the solver type parameter
156 this->declareConstructionOutcome(Amesos2::query(type_) == false, "The Amesos2 library reported that the solver '" + type_ + "' is not available. " +
157 "Amesos2 has been compiled without the support of this solver, or the solver name is misspelled.");
158}
159
160template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
162
163template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
165 RCP<ParameterList> validParamList = rcp(new ParameterList());
166 validParamList->set<RCP<const FactoryBase> >("A", null, "Factory of the coarse matrix");
167 validParamList->set<RCP<const FactoryBase> >("Nullspace", null, "Factory of the nullspace");
168 validParamList->set<bool>("fix nullspace", false, "Remove zero eigenvalue by adding rank one correction.");
169 ParameterList norecurse;
170 norecurse.disableRecursiveValidation();
171 validParamList->set<ParameterList>("Amesos2", norecurse, "Parameters that are passed to Amesos2");
172 return validParamList;
173}
174
175template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
177 ParameterList pL = this->GetParameterList();
178
179 this->Input(currentLevel, "A");
180 if (pL.get<bool>("fix nullspace"))
181 this->Input(currentLevel, "Nullspace");
182}
183
184template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
186 FactoryMonitor m(*this, "Setup Smoother", currentLevel);
187
188 if (SmootherPrototype::IsSetup() == true)
189 this->GetOStream(Warnings0) << "MueLu::Amesos2Smoother::Setup(): Setup() has already been called" << std::endl;
190
191 RCP<Matrix> A = Factory::Get<RCP<Matrix> >(currentLevel, "A");
192 auto A_block = rcp_dynamic_cast<BlockedCrsMatrix>(A);
193 if (A_block) {
194 A = A_block->Merge();
195 }
196
197 // Do a quick check if we need to modify the matrix
198 RCP<const Map> rowMap = A->getRowMap();
199 RCP<Matrix> factorA;
200 Teuchos::ParameterList pL = this->GetParameterList();
201
202 if (pL.get<bool>("fix nullspace")) {
203 this->GetOStream(Runtime1) << "MueLu::Amesos2Smoother::Setup(): fixing nullspace" << std::endl;
204
205 rowMap = A->getRowMap();
206 auto tpRowMap = Xpetra::toTpetra(rowMap);
207 if (!tpRowMap->haveGlobalConstants()) {
208 Teuchos::rcp_const_cast<Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >(tpRowMap)->computeGlobalConstants();
209 }
210 size_t gblNumCols = rowMap->getGlobalNumElements();
211
212 RCP<MultiVector> NullspaceOrig = Factory::Get<RCP<MultiVector> >(currentLevel, "Nullspace");
213
215 RCP<MultiVector> Nullspace = projection_->Nullspace_;
216
217 RCP<MultiVector> ghostedNullspace;
218 RCP<const Map> colMap;
219 RCP<const Import> importer;
220 if (rowMap->getComm()->getSize() > 1) {
221 this->GetOStream(Warnings0) << "MueLu::Amesos2Smoother::Setup(): Applying nullspace fix on distributed matrix. Try rebalancing to single rank!" << std::endl;
222 ArrayRCP<GO> elements_RCP;
223 elements_RCP.resize(gblNumCols);
224 ArrayView<GO> elements = elements_RCP();
225 for (size_t k = 0; k < gblNumCols; k++)
226 elements[k] = Teuchos::as<GO>(k);
227 colMap = MapFactory::Build(rowMap->lib(), gblNumCols * rowMap->getComm()->getSize(), elements, Teuchos::ScalarTraits<GO>::zero(), rowMap->getComm());
228 importer = ImportFactory::Build(rowMap, colMap);
229 ghostedNullspace = MultiVectorFactory::Build(colMap, Nullspace->getNumVectors(), false);
230 ghostedNullspace->doImport(*Nullspace, *importer, Xpetra::INSERT);
231 } else {
232 ghostedNullspace = Nullspace;
233 colMap = rowMap;
234 }
235
236 using ATS = KokkosKernels::ArithTraits<SC>;
237 using impl_Scalar = typename ATS::val_type;
238 using impl_ATS = KokkosKernels::ArithTraits<impl_Scalar>;
239 using range_type = Kokkos::RangePolicy<LO, typename NO::execution_space>;
240
241 typedef typename Matrix::local_matrix_device_type KCRS;
242 typedef typename KCRS::StaticCrsGraphType graph_t;
243 typedef typename graph_t::row_map_type::non_const_type lno_view_t;
244 typedef typename graph_t::entries_type::non_const_type lno_nnz_view_t;
245 typedef typename KCRS::values_type::non_const_type scalar_view_t;
246
247 const impl_Scalar impl_SC_ZERO = impl_ATS::zero();
248
249 size_t lclNumRows = rowMap->getLocalNumElements();
250 LocalOrdinal lclNumCols = Teuchos::as<LocalOrdinal>(gblNumCols);
251 lno_view_t newRowPointers("newRowPointers", lclNumRows + 1);
252 lno_nnz_view_t newColIndices("newColIndices", lclNumRows * gblNumCols);
253 scalar_view_t newValues("newValues", lclNumRows * gblNumCols);
254
255 impl_Scalar shift;
256 {
257 RCP<Vector> diag = VectorFactory::Build(A->getRowMap());
258 A->getLocalDiagCopy(*diag);
259 shift = diag->normInf();
260 }
261
262 // form normalization * nullspace * nullspace^T
263 {
264 auto lclNullspace = Nullspace->getLocalViewDevice(Tpetra::Access::ReadOnly);
265 auto lclGhostedNullspace = ghostedNullspace->getLocalViewDevice(Tpetra::Access::ReadOnly);
266 Kokkos::parallel_for(
267 "MueLu:Amesos2Smoother::fixNullspace_1", range_type(0, lclNumRows + 1),
268 KOKKOS_LAMBDA(const size_t i) {
269 if (i < lclNumRows) {
270 newRowPointers(i) = i * gblNumCols;
271 for (LocalOrdinal j = 0; j < lclNumCols; j++) {
272 newColIndices(i * gblNumCols + j) = j;
273 newValues(i * gblNumCols + j) = impl_SC_ZERO;
274 for (size_t I = 0; I < lclNullspace.extent(1); I++)
275 for (size_t J = 0; J < lclGhostedNullspace.extent(1); J++)
276 newValues(i * gblNumCols + j) += shift * lclNullspace(i, I) * impl_ATS::conjugate(lclGhostedNullspace(j, J));
277 }
278 } else
279 newRowPointers(lclNumRows) = lclNumRows * gblNumCols;
280 });
281 }
282
283 // add A
284 if (colMap->lib() == Xpetra::UseTpetra) {
285 auto lclA = A->getLocalMatrixDevice();
286 auto lclColMapA = A->getColMap()->getLocalMap();
287 auto lclColMapANew = colMap->getLocalMap();
288 Kokkos::parallel_for(
289 "MueLu:Amesos2Smoother::fixNullspace_2", range_type(0, lclNumRows),
290 KOKKOS_LAMBDA(const size_t i) {
291 for (size_t jj = lclA.graph.row_map(i); jj < lclA.graph.row_map(i + 1); jj++) {
292 LO j = lclColMapANew.getLocalElement(lclColMapA.getGlobalElement(lclA.graph.entries(jj)));
293 impl_Scalar v = lclA.values(jj);
294 newValues(i * gblNumCols + j) += v;
295 }
296 });
297 } else {
298 auto lclA = A->getLocalMatrixHost();
299 for (size_t i = 0; i < lclNumRows; i++) {
300 for (size_t jj = lclA.graph.row_map(i); jj < lclA.graph.row_map(i + 1); jj++) {
301 LO j = colMap->getLocalElement(A->getColMap()->getGlobalElement(lclA.graph.entries(jj)));
302 SC v = lclA.values(jj);
303 newValues(i * gblNumCols + j) += v;
304 }
305 }
306 }
307
308 RCP<Matrix> newA = rcp(new CrsMatrixWrap(rowMap, colMap, 0));
309 RCP<CrsMatrix> newAcrs = toCrsMatrix(newA);
310 newAcrs->setAllValues(newRowPointers, newColIndices, newValues);
311 newAcrs->expertStaticFillComplete(A->getDomainMap(), A->getRangeMap(),
312 importer, A->getCrsGraph()->getExporter());
313
314 factorA = newA;
315 rowMap = factorA->getRowMap();
316 } else {
317 factorA = A;
318 }
319
320 RCP<Tpetra_CrsMatrix> tA = toTpetra(factorA);
321 if (!tA->haveGlobalConstants())
322 Teuchos::rcp_const_cast<typename Tpetra_CrsMatrix::crs_graph_type>(tA->getCrsGraph())->computeGlobalConstants();
323
324 prec_ = Amesos2::create<Tpetra_CrsMatrix, Tpetra_MultiVector>(type_, tA);
325 TEUCHOS_TEST_FOR_EXCEPTION(prec_ == Teuchos::null, Exceptions::RuntimeError, "Amesos2::create returns Teuchos::null");
326 RCP<Teuchos::ParameterList> amesos2_params = Teuchos::rcpFromRef(pL.sublist("Amesos2"));
327 amesos2_params->setName("Amesos2");
328 if ((rowMap->getGlobalNumElements() != as<size_t>((rowMap->getMaxAllGlobalIndex() - rowMap->getMinAllGlobalIndex()) + 1)) ||
329 (!rowMap->isContiguous() && (rowMap->getComm()->getSize() == 1))) {
330 if (((type_ != "Cusolver") && (type_ != "Tacho")) && !(amesos2_params->sublist(prec_->name()).template isType<bool>("IsContiguous")))
331 amesos2_params->sublist(prec_->name()).set("IsContiguous", false, "Are GIDs Contiguous");
332 }
333 prec_->setParameters(amesos2_params);
334
335 prec_->numericFactorization();
336
338}
339
340template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
341void Amesos2Smoother<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Apply(MultiVector& X, const MultiVector& B, bool /* InitialGuessIsZero */) const {
342 TEUCHOS_TEST_FOR_EXCEPTION(SmootherPrototype::IsSetup() == false, Exceptions::RuntimeError, "MueLu::Amesos2Smoother::Apply(): Setup() has not been called");
343
344 RCP<BlockedMultiVector> blockedX = rcp_dynamic_cast<BlockedMultiVector>(rcpFromRef(X));
345 bool blocked = blockedX != Teuchos::null;
346 if (blocked) {
347 this->ApplyBlocked(X, B);
348 return;
349 }
350
351 RCP<Tpetra_MultiVector> tX, tB;
352 if (!useTransformation_) {
353 tX = toTpetra(Teuchos::rcpFromRef(X));
354 tB = toTpetra(Teuchos::rcpFromRef(const_cast<MultiVector&>(B)));
355 } else {
356 // Copy data of the original vectors into the transformed ones
357 size_t numVectors = X.getNumVectors();
358 size_t length = X.getLocalLength();
359
360 TEUCHOS_TEST_FOR_EXCEPTION(numVectors > 1, Exceptions::RuntimeError,
361 "MueLu::Amesos2Smoother::Apply: Fixing coarse matrix for Amesos2 for multivectors has not been implemented yet.");
362 ArrayRCP<const SC> Xdata = X.getData(0), Bdata = B.getData(0);
363 ArrayRCP<SC> X_data = X_->getDataNonConst(0), B_data = B_->getDataNonConst(0);
364
365 for (size_t i = 0; i < length; i++) {
366 X_data[i] = Xdata[i];
367 B_data[i] = Bdata[i];
368 }
369
370 tX = toTpetra(X_);
371 tB = toTpetra(B_);
372 }
373
374 prec_->setX(tX);
375 prec_->setB(tB);
376
377 prec_->solve();
378
379 prec_->setX(Teuchos::null);
380 prec_->setB(Teuchos::null);
381
382 if (useTransformation_) {
383 // Copy data from the transformed vectors into the original ones
384 size_t length = X.getLocalLength();
385
386 ArrayRCP<SC> Xdata = X.getDataNonConst(0);
387 ArrayRCP<const SC> X_data = X_->getData(0);
388
389 for (size_t i = 0; i < length; i++)
390 Xdata[i] = X_data[i];
391 }
392
393 {
394 Teuchos::ParameterList pL = this->GetParameterList();
395 if (pL.get<bool>("fix nullspace")) {
396 projection_->projectOut(X);
397 }
398 }
399}
400
401template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
402void Amesos2Smoother<Scalar, LocalOrdinal, GlobalOrdinal, Node>::ApplyBlocked(MultiVector& X, const MultiVector& B) const {
403 TEUCHOS_TEST_FOR_EXCEPTION(useTransformation_, Exceptions::RuntimeError,
404 "MueLu::Amesos2Smoother::ApplyBlocked: useTransformation_ == true is not supported");
405
406 Teuchos::ParameterList pL = this->GetParameterList();
407 const auto fixNullspace = pL.get<bool>("fix nullspace");
408 TEUCHOS_TEST_FOR_EXCEPTION(fixNullspace, Exceptions::RuntimeError,
409 "MueLu::Amesos2Smoother::ApplyBlocked: \"fix nullspace\" == true is not supported");
410
411 RCP<BlockedMultiVector> blockedX = rcp_dynamic_cast<BlockedMultiVector>(rcpFromRef(X));
412 RCP<const BlockedMultiVector> blockedB = rcp_dynamic_cast<const BlockedMultiVector>(rcpFromRef(B));
413 TEUCHOS_TEST_FOR_EXCEPTION(blockedX == Teuchos::null || blockedB == Teuchos::null, Exceptions::RuntimeError,
414 "MueLu::Amesos2Smoother::ApplyBlocked: Input and/or output vector are not BlockedMultiVector!");
415
416 RCP<MultiVector> mergedX = blockedX->Merge();
417 RCP<MultiVector> mergedB = blockedB->Merge();
418
419 RCP<Tpetra_MultiVector> tX, tB;
420 tX = toTpetra(mergedX);
421 tB = toTpetra(mergedB);
422
423 prec_->setX(tX);
424 prec_->setB(tB);
425
426 prec_->solve();
427
428 prec_->setX(Teuchos::null);
429 prec_->setB(Teuchos::null);
430
431 RCP<MultiVector> xx = Teuchos::rcp(new BlockedMultiVector(blockedX->getBlockedMap(), mergedX));
432 SC zero = Teuchos::ScalarTraits<SC>::zero(), one = Teuchos::ScalarTraits<SC>::one();
433 X.update(one, *xx, zero);
434}
435
436template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
437RCP<MueLu::SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
442
443template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
445 std::ostringstream out;
446
447 if (SmootherPrototype::IsSetup() == true) {
448 out << prec_->description();
449
450 } else {
452 out << "{type = " << type_ << "}";
453 }
454 return out.str();
455}
456
457template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
458void Amesos2Smoother<Scalar, LocalOrdinal, GlobalOrdinal, Node>::print(Teuchos::FancyOStream& out, const VerbLevel verbLevel) const {
460
461 if (verbLevel & Parameters0)
462 out0 << "Prec. type: " << type_ << std::endl;
463
464 if (verbLevel & Parameters1) {
465 out0 << "Parameter list: " << std::endl;
466 Teuchos::OSTab tab2(out);
467 out << this->GetParameterList();
468 }
469
470 if ((verbLevel & External) && prec_ != Teuchos::null) {
471 Teuchos::OSTab tab2(out);
472 out << *prec_ << std::endl;
473 }
474
475 if (verbLevel & Debug)
476 out0 << "IsSetup: " << Teuchos::toString(SmootherPrototype::IsSetup()) << std::endl
477 << "-" << std::endl
478 << "RCP<prec_>: " << prec_ << std::endl;
479}
480
481template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
483 if (!prec_.is_null())
484 return prec_->getStatus().getNnzLU();
485 else
486 return 0.0;
487}
488} // namespace MueLu
489
490#endif // MUELU_AMESOS2SMOOTHER_DEF_HPP
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultScalar Scalar
void DeclareInput(Level &currentLevel) const
Input.
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
std::string type_
amesos2-specific key phrase that denote smoother type
void ApplyBlocked(MultiVector &X, const MultiVector &B) const
RCP< SmootherPrototype > Copy() const
std::string description() const
Return a simple one-line description of this object.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
RCP< Projection< Scalar, LocalOrdinal, GlobalOrdinal, Node > > projection_
RCP< Amesos2::Solver< Tpetra_CrsMatrix, Tpetra_MultiVector > > prec_
pointer to Amesos2 solver object
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void Setup(Level &currentLevel)
Set up the direct solver. This creates the underlying Amesos2 solver object according to the paramete...
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the direct solver. Solves the linear system AX=B using the constructed solver.
Amesos2Smoother(const std::string &type="", const Teuchos::ParameterList &paramList=Teuchos::ParameterList())
Constructor Creates a MueLu interface to the direct solvers in the Amesos2 package....
virtual std::string description() const
Return a simple one-line description of this object.
Exception throws to report errors in the internal logical of the program.
void Input(Level &level, const std::string &varName) const
T Get(Level &level, const std::string &varName) const
Timer to be used in factories. Similar to Monitor but with additional timers.
Class that holds all level-specific information.
virtual void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
virtual const Teuchos::ParameterList & GetParameterList() const
Projection(RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &Nullspace)
void projectOut(Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X)
Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > localMap_
Teuchos::RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > tempMV_
Teuchos::RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Nullspace_
void declareConstructionOutcome(bool fail, std::string msg)
bool IsSetup() const
Get the state of a smoother prototype.
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
Namespace for MueLu classes and methods.
@ Warnings0
Important warning messages (one line).
@ Debug
Print additional debugging information.
@ External
Print external lib objects.
@ Runtime1
Description of what is happening (more verbose).
@ Parameters0
Print class parameters.
@ Parameters1
Print class parameters (more parameters, more verbose).