45#ifndef MUELU_MAXWELL1_DEF_HPP
46#define MUELU_MAXWELL1_DEF_HPP
53#include "Xpetra_Map.hpp"
54#include "Xpetra_CrsMatrixUtils.hpp"
55#include "Xpetra_MatrixUtils.hpp"
58#include "MueLu_Maxwell_Utils.hpp"
60#include "MueLu_ReitzingerPFactory.hpp"
61#include "MueLu_Utilities.hpp"
63#include "MueLu_Hierarchy.hpp"
64#include "MueLu_RAPFactory.hpp"
66#include "MueLu_PerfUtils.hpp"
67#include "MueLu_ParameterListInterpreter.hpp"
69#include <MueLu_HierarchyUtils.hpp>
73#include <MueLu_RefMaxwellSmoother.hpp>
76#include "cuda_profiler_api.h"
83 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
89 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
95 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
98 if (list.isType<std::string>(
"parameterlist: syntax") && list.get<std::string>(
"parameterlist: syntax") ==
"ml") {
99 list.remove(
"parameterlist: syntax");
100 Teuchos::ParameterList newList;
109 newList.sublist(
"maxwell1: 22list").set(
"use kokkos refactor",
false);
111 newList.sublist(
"maxwell1: 11list").set(
"use kokkos refactor",
false);
112 newList.sublist(
"maxwell1: 11list").set(
"tentative: constant column sums",
false);
113 newList.sublist(
"maxwell1: 11list").set(
"tentative: calculate qr",
false);
115 newList.sublist(
"maxwell1: 11list").set(
"aggregation: use ml scaling of drop tol",
true);
116 newList.sublist(
"maxwell1: 22list").set(
"aggregation: use ml scaling of drop tol",
true);
119 if(list.isParameter(
"aggregation: damping factor") && list.get<
double>(
"aggregation: damping factor") == 0.0)
120 newList.sublist(
"maxwell1: 11list").set(
"multigrid algorithm",
"unsmoothed reitzinger");
122 newList.sublist(
"maxwell1: 11list").set(
"multigrid algorithm",
"smoothed reitzinger");
123 newList.sublist(
"maxwell1: 11list").set(
"aggregation: type",
"uncoupled");
125 newList.sublist(
"maxwell1: 22list").set(
"multigrid algorithm",
"unsmoothed");
126 newList.sublist(
"maxwell1: 22list").set(
"aggregation: type",
"uncoupled");
128 if (newList.sublist(
"maxwell1: 22list").isType<std::string>(
"verbosity"))
129 newList.set(
"verbosity", newList.sublist(
"maxwell1: 22list").get<std::string>(
"verbosity"));
132 std::vector<std::string> convert = {
"coarse:",
"smoother:",
"smoother: pre",
"smoother: post"};
133 for (
auto it = convert.begin(); it != convert.end(); ++it) {
134 if (newList.sublist(
"maxwell1: 22list").isType<std::string>(*it +
" type")) {
135 newList.sublist(
"maxwell1: 11list").set(*it+
" type", newList.sublist(
"maxwell1: 22list").get<std::string>(*it+
" type"));
136 newList.sublist(
"maxwell1: 22list").remove(*it+
" type");
138 if (newList.sublist(
"maxwell1: 22list").isSublist(*it+
" params")) {
139 newList.sublist(
"maxwell1: 11list").set(*it+
" params", newList.sublist(
"maxwell1: 22list").sublist(*it+
" params"));
140 newList.sublist(
"maxwell1: 22list").remove(*it+
" params");
144 newList.sublist(
"maxwell1: 22list").set(
"smoother: type",
"none");
145 newList.sublist(
"maxwell1: 22list").set(
"coarse: type",
"none");
147 newList.set(
"maxwell1: nodal smoother fix zero diagonal threshold",1e-10);
148 newList.sublist(
"maxwell1: 22list").set(
"rap: fix zero diagonals",
true);
149 newList.sublist(
"maxwell1: 22list").set(
"rap: fix zero diagonals threshold",1e-10);
155 applyBCsTo22_ = list.get(
"maxwell1: apply BCs to 22",
false);
159 Teuchos::ParameterList defaultSmootherList;
160 defaultSmootherList.set(
"smoother: type",
"CHEBYSHEV");
161 defaultSmootherList.sublist(
"smoother: params").set(
"chebyshev: degree",2);
162 defaultSmootherList.sublist(
"smoother: params").set(
"chebyshev: ratio eigenvalue",7.0);
163 defaultSmootherList.sublist(
"smoother: params").set(
"chebyshev: eigenvalue max iterations",30);
166 std::string verbosity = list.get(
"verbosity",
"high");
175 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"Must use mode 'standard', 'refmaxwell', 'edge only', or use the GMHD constructor.");
181 if(list.isSublist(
"maxwell1: 22list"))
183 else if(list.isSublist(
"refmaxwell: 22list"))
187 else if(!
precList22_.isType<std::string>(
"Preconditioner Type") &&
188 !
precList22_.isType<std::string>(
"smoother: type") &&
189 !
precList22_.isType<std::string>(
"smoother: pre type") &&
190 !
precList22_.isType<std::string>(
"smoother: post type")) {
199 if(list.isSublist(
"maxwell1: 11list"))
201 else if(list.isSublist(
"refmaxwell: 11list"))
208 if(!
precList11_.isType<std::string>(
"Preconditioner Type") &&
209 !
precList11_.isType<std::string>(
"smoother: type") &&
210 !
precList11_.isType<std::string>(
"smoother: pre type") &&
211 !
precList11_.isType<std::string>(
"smoother: post type")) {
217 precList11_.sublist(
"hiptmair: smoother type 1",
"CHEBYSHEV");
218 precList11_.sublist(
"hiptmair: smoother type 2",
"CHEBYSHEV");
219 precList11_.sublist(
"hiptmair: smoother list 1") = defaultSmootherList;
220 precList11_.sublist(
"hiptmair: smoother list 2") = defaultSmootherList;
227 !
precList11_.isType<std::string>(
"Preconditioner Type") &&
231 !
precList22_.isType<std::string>(
"Preconditioner Type") &&
237# ifdef HAVE_MUELU_SERIAL
238 if (
typeid(
Node).name() ==
typeid(Tpetra::KokkosCompat::KokkosSerialWrapperNode).name())
241# ifdef HAVE_MUELU_OPENMP
242 if (
typeid(
Node).name() ==
typeid(Tpetra::KokkosCompat::KokkosOpenMPWrapperNode).name())
245# ifdef HAVE_MUELU_CUDA
246 if (
typeid(
Node).name() ==
typeid(Tpetra::KokkosCompat::KokkosCudaWrapperNode).name())
255 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
257 Teuchos::ParameterList precListGmhd;
264 TEUCHOS_TEST_FOR_EXCEPTION( !List.isSublist(
"maxwell1: Gmhdlist"),
Exceptions::RuntimeError,
"Must provide maxwell1: Gmhdlist for GMHD setup");
265 precListGmhd = List.sublist(
"maxwell1: Gmhdlist");
266 precListGmhd.set(
"coarse: max size",1);
274 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
289#ifdef HAVE_MUELU_CUDA
290 if (
parameterList_.get<
bool>(
"maxwell1: cuda profile setup",
false)) cudaProfilerStart();
293 std::string timerLabel;
295 timerLabel =
"MueLu Maxwell1: compute (reuse)";
297 timerLabel =
"MueLu Maxwell1: compute";
298 RCP<Teuchos::TimeMonitor> tmCompute =
getTimer(timerLabel);
302 bool have_generated_Kn =
false;
305 GetOStream(
Runtime0) <<
"Maxwell1::compute(): Kn not provided. Generating." << std::endl;
307 have_generated_Kn =
true;
309 else if (
parameterList_.get<
bool>(
"rap: fix zero diagonals",
true)) {
313 Teuchos::ScalarTraits<double>::eps());
315 threshold = Teuchos::as<magnitudeType>(
parameterList_.get<
double>(
"rap: fix zero diagonals threshold",
316 Teuchos::ScalarTraits<double>::eps()));
317 Scalar replacement = Teuchos::as<Scalar>(
parameterList_.get<
double>(
"rap: fix zero diagonals replacement",
334 if(
precList22_.isParameter(
"repartition: enable")) {
335 bool repartition =
precList22_.get<
bool>(
"repartition: enable");
336 precList11_.set(
"repartition: enable",repartition);
340 precList22_.set(
"repartition: rebalance P and R",
true);
342 if (
precList22_.isParameter(
"repartition: use subcommunicators")) {
343 precList11_.set(
"repartition: use subcommunicators",
precList22_.get<
bool>(
"repartition: use subcommunicators"));
347 if(
precList11_.get<
bool>(
"repartition: use subcommunicators")==
true)
348 precList11_.set(
"repartition: use subcommunicators in place",
true);
352 precList11_.set(
"repartition: use subcommunicators",
true);
353 precList22_.set(
"repartition: use subcommunicators",
true);
357 precList11_.set(
"repartition: use subcommunicators in place",
true);
424 if (
D0_Matrix_->getRowMap()->lib() == Xpetra::UseEpetra)
425 replaceWith= Teuchos::ScalarTraits<SC>::eps();
427 replaceWith = Teuchos::ScalarTraits<SC>::zero();
430 GetOStream(
Runtime0) <<
"Maxwell1::compute(): nuking BC rows/cols of D0" << std::endl;
457 RCP<Matrix> Kn_Smoother_0;
458 if(have_generated_Kn) {
468 RCP<Matrix> OldSmootherMatrix;
469 RCP<Level> OldEdgeLevel;
474 RCP<Operator> NodeOp = NodeL->Get<RCP<Operator> >(
"A");
475 RCP<Matrix> NodeAggMatrix = rcp_dynamic_cast<Matrix>(NodeOp);
482 EdgeL->Set(
"NodeAggMatrix",NodeAggMatrix);
483 EdgeL->Set(
"NodeMatrix",Kn_Smoother_0);
484 OldSmootherMatrix = Kn_Smoother_0;
485 OldEdgeLevel = EdgeL;
492 auto NodalP = NodeL->Get<RCP<Matrix> >(
"P");
495 EdgeL->Set(
"Pnodal",NodalP_ones);
499 if(!NodeAggMatrix.is_null()) {
500 EdgeL->Set(
"NodeAggMatrix",NodeAggMatrix);
501 if(!have_generated_Kn) {
511 Teuchos::ParameterList RAPlist;
512 RAPlist.set(
"rap: fix zero diagonals",
false);
514 EdgeL->Set(
"NodeMatrix",NewKn);
517 double thresh =
parameterList_.get(
"maxwell1: nodal smoother fix zero diagonal threshold",1e-10);
519 printf(
"CMS: Reparing diagonal after next level generation\n");
520 Scalar replacement = Teuchos::ScalarTraits<Scalar>::one();
521 Xpetra::MatrixUtils<SC,LO,GO,NO>::CheckRepairMainDiagonal(OldSmootherMatrix,
true,
GetOStream(
Warnings1), thresh, replacement);
523 OldEdgeLevel->Set(
"NodeMatrix",OldSmootherMatrix);
525 OldSmootherMatrix = NewKn;
529 EdgeL->Set(
"NodeMatrix",NodeAggMatrix);
534 EdgeL->Set(
"NodeMatrix",NodeOp);
535 EdgeL->Set(
"NodeAggMatrix",NodeOp);
538 OldEdgeLevel = EdgeL;
543 if(NodeL->IsAvailable(
"Importer")) {
544 auto importer = NodeL->Get<RCP<const Import> >(
"Importer");
545 EdgeL->Set(
"NodeImporter",importer);
552 std::string fine_smoother =
precList11_.get<std::string>(
"smoother: type");
558 const bool refmaxwellCoarseSolve = (
precList11_.get<std::string>(
"coarse: type",
560 if (refmaxwellCoarseSolve) {
561 GetOStream(
Runtime0) <<
"Maxwell1::compute(): Will set up RefMaxwell coarse solver" << std::endl;
566 Teuchos::ParameterList nonSerialList11, processedPrecList11;
575 if (refmaxwellCoarseSolve) {
576 GetOStream(
Runtime0) <<
"Maxwell1::compute(): Setting up RefMaxwell coarse solver" << std::endl;
580 coarseSolver->Setup(*coarseLvl);
581 coarseLvl->Set(
"PreSmoother",
582 rcp_dynamic_cast<SmootherBase>(coarseSolver,
true));
588 P11_ = EdgeL->Get<RCP<Matrix> >(
"P");
600#ifdef MUELU_MAXWELL1_DEBUG
603 RCP<Matrix> EdgeMatrix = rcp_dynamic_cast<Matrix>(L->Get<RCP<Operator> >(
"A"));
604 RCP<Matrix> NodeMatrix = rcp_dynamic_cast<Matrix>(L->Get<RCP<Operator> >(
"NodeMatrix"));
605 RCP<Matrix> NodeAggMatrix = rcp_dynamic_cast<Matrix>(L->Get<RCP<Operator> >(
"NodeAggMatrix"));
606 RCP<Matrix> D0 =rcp_dynamic_cast<Matrix>( L->Get<RCP<Operator> >(
"D0"));
608 auto nrmE = EdgeMatrix->getFrobeniusNorm();
609 auto nrmN = NodeMatrix->getFrobeniusNorm();
610 auto nrmNa = NodeAggMatrix->getFrobeniusNorm();
611 auto nrmD0= D0->getFrobeniusNorm();
613 std::cout<<
"DEBUG: Norms on Level "<<i<<
" E/N/NA/D0 = "<<nrmE<<
" / "<<nrmN <<
" / "<<nrmNa<<
" / "<< nrmD0 <<std::endl;
614 std::cout<<
"DEBUG: NNZ on Level "<<i<<
" E/N/NA/D0 = "<<
615 EdgeMatrix->getGlobalNumEntries()<<
" / "<<
616 NodeMatrix->getGlobalNumEntries()<<
" / "<<
617 NodeAggMatrix->getGlobalNumEntries()<<
" / "<<
618 D0->getGlobalNumEntries()<<std::endl;
625 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
629 Teuchos::ParameterList RAPlist;
630 RAPlist.set(
"rap: fix zero diagonals",
false);
632 std::string labelstr =
"NodeMatrix (Level 0)";
639 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
642 RCP<Teuchos::TimeMonitor> tmAlloc =
getTimer(
"MueLu Maxwell1: Allocate MVs");
648 RCP<Matrix> A = EdgeL->Get<RCP<Matrix> >(
"A");
649 residual11c_ = MultiVectorFactory::Build(A->getRangeMap(), numVectors);
650 update11c_ = MultiVectorFactory::Build(A->getDomainMap(), numVectors);
663 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
667 Xpetra::IO<SC, LO, GO, NO>::Write(name, A);
672 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
676 Xpetra::IO<SC, LO, GO, NO>::Write(name, X);
681 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
685 Xpetra::IO<coordinateType, LO, GO, NO>::Write(name, X);
690 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
694 std::ofstream out(name);
695 for (
size_t i = 0; i < Teuchos::as<size_t>(v.size()); i++)
700 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
704 std::ofstream out(name);
705 auto vH = Kokkos::create_mirror_view (v);
706 Kokkos::deep_copy(vH , v);
707 for (
size_t i = 0; i < vH.size(); i++)
708 out << vH[i] <<
"\n";
712 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
716 return Teuchos::rcp(
new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(name)));
719 return Teuchos::rcp(
new Teuchos::SyncTimeMonitor(*Teuchos::TimeMonitor::getNewTimer(name),
SM_Matrix_->getRowMap()->getComm().ptr()));
721 return Teuchos::rcp(
new Teuchos::SyncTimeMonitor(*Teuchos::TimeMonitor::getNewTimer(name), comm.ptr()));
724 return Teuchos::null;
730 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
740 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
743 const SC one = Teuchos::ScalarTraits<SC>::one();
751 if (Fine->IsAvailable(
"PreSmoother")) {
752 RCP<Teuchos::TimeMonitor> tmRes =
getTimer(
"MueLu Maxwell1: PreSmoother");
753 RCP<SmootherBase> preSmoo = Fine->Get< RCP<SmootherBase> >(
"PreSmoother");
754 preSmoo->Apply(X, RHS,
true);
759 RCP<Teuchos::TimeMonitor> tmRes =
getTimer(
"MueLu Maxwell1: residual calculation");
764 if(!
P11_.is_null()) {
765 RCP<Teuchos::TimeMonitor> tmRes =
getTimer(
"MueLu Maxwell1: (1,1) correction");
772 RCP<Teuchos::TimeMonitor> tmRes =
getTimer(
"MueLu Maxwell1: (2,2) correction");
779 RCP<Teuchos::TimeMonitor> tmRes =
getTimer(
"MueLu Maxwell1: Orolongation");
787 if (Fine->IsAvailable(
"PostSmoother")) {
788 RCP<Teuchos::TimeMonitor> tmRes =
getTimer(
"MueLu Maxwell1: PostSmoother");
789 RCP<SmootherBase> postSmoo = Fine->Get< RCP<SmootherBase> >(
"PostSmoother");
790 postSmoo->Apply(X, RHS,
false);
796 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
801 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
806 RCP<Teuchos::TimeMonitor> tm =
getTimer(
"MueLu Maxwell1: solve");
814 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"Must use mode 'standard', 'refmaxwell' or 'edge only' when not doing GMHD.");
819 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
825 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
827 initialize(
const Teuchos::RCP<Matrix> & D0_Matrix,
828 const Teuchos::RCP<Matrix> & Kn_Matrix,
829 const Teuchos::RCP<MultiVector> & Nullspace,
830 const Teuchos::RCP<RealValuedMultiVector> & Coords,
831 Teuchos::ParameterList& List)
834 TEUCHOS_ASSERT(D0_Matrix!=Teuchos::null);
836#ifdef HAVE_MUELU_DEBUG
837 if(!Kn_Matrix.is_null()) {
838 TEUCHOS_ASSERT(Kn_Matrix->getDomainMap()->isSameAs(*D0_Matrix->getDomainMap()));
839 TEUCHOS_ASSERT(Kn_Matrix->getRangeMap()->isSameAs(*D0_Matrix->getDomainMap()));
843 TEUCHOS_ASSERT(D0_Matrix->getRangeMap()->isSameAs(*D0_Matrix->getRowMap()));
864 if (D0_Matrix->getRowMap()->lib() == Xpetra::UseTpetra) {
869 RCP<Matrix> D0copy = MatrixFactory::Build(D0_Matrix->getRowMap(), D0_Matrix->getColMap(), 0);
870 RCP<CrsMatrix> D0copyCrs = rcp_dynamic_cast<CrsMatrixWrap>(D0copy,
true)->getCrsMatrix();
871 ArrayRCP<const size_t> D0rowptr_RCP;
872 ArrayRCP<const LO> D0colind_RCP;
873 ArrayRCP<const SC> D0vals_RCP;
874 rcp_dynamic_cast<CrsMatrixWrap>(D0_Matrix,
true)->getCrsMatrix()->getAllValues(D0rowptr_RCP,
878 ArrayRCP<size_t> D0copyrowptr_RCP;
879 ArrayRCP<LO> D0copycolind_RCP;
880 ArrayRCP<SC> D0copyvals_RCP;
881 D0copyCrs->allocateAllValues(D0vals_RCP.size(),D0copyrowptr_RCP,D0copycolind_RCP,D0copyvals_RCP);
882 D0copyrowptr_RCP.deepCopy(D0rowptr_RCP());
883 D0copycolind_RCP.deepCopy(D0colind_RCP());
884 D0copyvals_RCP.deepCopy(D0vals_RCP());
885 D0copyCrs->setAllValues(D0copyrowptr_RCP,
888 D0copyCrs->expertStaticFillComplete(D0_Matrix->getDomainMap(), D0_Matrix->getRangeMap(),
889 rcp_dynamic_cast<CrsMatrixWrap>(D0_Matrix,
true)->getCrsMatrix()->getCrsGraph()->getImporter(),
890 rcp_dynamic_cast<CrsMatrixWrap>(D0_Matrix,
true)->getCrsMatrix()->getCrsGraph()->getExporter());
893 D0_Matrix_ = MatrixFactory::BuildCopy(D0_Matrix);
908 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
910 describe(Teuchos::FancyOStream& out,
const Teuchos::EVerbosityLevel )
const {
912 std::ostringstream oss;
914 RCP<const Teuchos::Comm<int> > comm =
SM_Matrix_->getDomainMap()->getComm();
919 root = comm->getRank();
924 reduceAll(*comm, Teuchos::REDUCE_MAX, root, Teuchos::ptr(&actualRoot));
929 oss <<
"\n--------------------------------------------------------------------------------\n" <<
930 "--- Maxwell1 Summary ---\n"
931 "--------------------------------------------------------------------------------" << std::endl;
937 SM_Matrix_->getRowMap()->getComm()->barrier();
942 Xpetra::global_size_t tt = numRows;
943 int rowspacer = 3;
while (tt != 0) { tt /= 10; rowspacer++; }
945 int nnzspacer = 2;
while (tt != 0) { tt /= 10; nnzspacer++; }
947 oss <<
"block " << std::setw(rowspacer) <<
" rows " << std::setw(nnzspacer) <<
" nnz " << std::setw(9) <<
" nnz/row" << std::endl;
948 oss <<
"(1, 1)" << std::setw(rowspacer) << numRows << std::setw(nnzspacer) << nnz << std::setw(9) << as<double>(nnz) / numRows << std::endl;
955 oss <<
"(2, 2)" << std::setw(rowspacer) << numRows << std::setw(nnzspacer) << nnz << std::setw(9) << as<double>(nnz) / numRows << std::endl;
961 std::string outstr = oss.str();
964 RCP<const Teuchos::MpiComm<int> > mpiComm = rcp_dynamic_cast<const Teuchos::MpiComm<int> >(comm);
965 MPI_Comm rawComm = (*mpiComm->getRawMpiComm())();
967 int strLength = outstr.size();
968 MPI_Bcast(&strLength, 1, MPI_INT, root, rawComm);
969 if (comm->getRank() != root)
970 outstr.resize(strLength);
971 MPI_Bcast(&outstr[0], strLength, MPI_CHAR, root, rawComm);
987 std::ostringstream oss2;
989 oss2 <<
"Sub-solver distribution over ranks" << std::endl;
990 oss2 <<
"( (1,1) block only is indicated by '1', (2,2) block only by '2', and both blocks by 'B' and none by '.')" << std::endl;
992 int numProcs = comm->getSize();
994 RCP<const Teuchos::MpiComm<int> > tmpic = rcp_dynamic_cast<const Teuchos::MpiComm<int> >(comm);
996 RCP<const Teuchos::OpaqueWrapper<MPI_Comm> > rawMpiComm = tmpic->getRawMpiComm();
1002 std::vector<char> states(numProcs, 0);
1004 MPI_Gather(&status, 1, MPI_CHAR, &states[0], 1, MPI_CHAR, 0, *rawMpiComm);
1006 states.push_back(status);
1009 int rowWidth = std::min(Teuchos::as<int>(ceil(sqrt(numProcs))), 100);
1010 for (
int proc = 0; proc < numProcs; proc += rowWidth) {
1011 for (
int j = 0; j < rowWidth; j++)
1012 if (proc + j < numProcs)
1013 if (states[proc+j] == 0)
1015 else if (states[proc+j] == 1)
1017 else if (states[proc+j] == 2)
1024 oss2 <<
" " << proc <<
":" << std::min(proc + rowWidth, numProcs) - 1 << std::endl;
1037#define MUELU_MAXWELL1_SHORT
Various adapters that will create a MueLu preconditioner that is an Xpetra::Matrix.
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Exception throws to report errors in the internal logical of the program.
static void AddNonSerializableDataToHierarchy(HierarchyManager &HM, Hierarchy &H, const ParameterList &nonSerialList)
Add non-serializable data to Hierarchy.
static void CopyBetweenHierarchies(Hierarchy &fromHierarchy, Hierarchy &toHierarchy, const std::string fromLabel, const std::string toLabel, const std::string dataType)
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
static std::string translate(Teuchos::ParameterList ¶mList, const std::string &defaultVals="")
: Translate ML parameters to MueLu parameter XML string
static const T & getDefault(const std::string &name)
Returns default value on the "master" list for a parameter with the specified name and type.
Xpetra::MultiVector< coordinateType, LO, GO, NO > RealValuedMultiVector
bool useKokkos_
Some options.
Teuchos::RCP< Matrix > generate_kn() const
Generates the Kn matrix.
Teuchos::RCP< Hierarchy > Hierarchy11_
Two hierarchies: one for the (1,1)-block, another for the (2,2)-block.
Teuchos::RCP< Hierarchy > HierarchyGmhd_
Teuchos::RCP< MultiVector > residualFine_
Teuchos::ArrayRCP< bool > BCcols_
Teuchos::ArrayRCP< bool > BCrows_
Teuchos::RCP< Matrix > SM_Matrix_
Various matrices.
Teuchos::RCP< Hierarchy > Hierarchy22_
Teuchos::RCP< const Map > getDomainMap() const
Returns the Xpetra::Map object associated with the domain of this operator.
Teuchos::RCP< const Map > getRangeMap() const
Returns the Xpetra::Map object associated with the range of this operator.
void compute(bool reuse=false)
Setup the preconditioner.
void GMHDSetupHierarchy(Teuchos::ParameterList &List) const
Sets up hiearchy for GMHD matrices that include generalized Ohms law equations.
Teuchos::ParameterList parameterList_
ParameterLists.
Teuchos::RCP< MultiVector > residual22_
Teuchos::RCP< RealValuedMultiVector > Coords_
Coordinates.
Teuchos::RCP< Matrix > D0_Matrix_
Teuchos::ScalarTraits< Scalar >::magnitudeType magnitudeType
void applyInverseRefMaxwellAdditive(const MultiVector &RHS, MultiVector &X) const
apply RefMaxwell additive 2x2 style cycle
Teuchos::RCP< MultiVector > Nullspace_
Nullspace.
Kokkos::View< bool *, typename Node::device_type > BCdomainKokkos_
Teuchos::RCP< MultiVector > update11c_
Kokkos::View< bool *, typename Node::device_type > BCcolsKokkos_
void applyInverseStandard(const MultiVector &RHS, MultiVector &X) const
apply standard Maxwell1 cycle
void initialize(const Teuchos::RCP< Matrix > &D0_Matrix, const Teuchos::RCP< Matrix > &Kn_Matrix, const Teuchos::RCP< MultiVector > &Nullspace, const Teuchos::RCP< RealValuedMultiVector > &Coords, Teuchos::ParameterList &List)
RCP< Matrix > P11_
Temporary memory (cached vectors for RefMaxwell-style).
void dumpCoords(const RealValuedMultiVector &X, std::string name) const
dump out real-valued multivector
Teuchos::RCP< MultiVector > update22_
Teuchos::ArrayRCP< bool > BCdomain_
Teuchos::ParameterList precList11_
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_HIGH) const
Teuchos::RCP< Matrix > GmhdA_Matrix_
void dump(const Matrix &A, std::string name) const
dump out matrix
Teuchos::ParameterList precList22_
void resetMatrix(Teuchos::RCP< Matrix > SM_Matrix_new, bool ComputePrec=true)
Reset system matrix.
Teuchos::RCP< Matrix > Kn_Matrix_
Teuchos::RCP< MultiVector > residual11c_
bool hasTransposeApply() const
Indicates whether this operator supports applying the adjoint operator.
Kokkos::View< bool *, typename Node::device_type > BCrowsKokkos_
Vectors for BCs.
Teuchos::RCP< Teuchos::TimeMonitor > getTimer(std::string name, RCP< const Teuchos::Comm< int > > comm=Teuchos::null) const
get a (synced) timer
void setParameters(Teuchos::ParameterList &list)
Set parameters.
void apply(const MultiVector &X, MultiVector &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
void allocateMemory(int numVectors) const
allocate multivectors for solve
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > PtAPWrapper(const RCP< Matrix > &A, const RCP< Matrix > &P, Teuchos::ParameterList ¶ms, std::string &label)
Performs an P^T AP.
static void detectBoundaryConditionsSM(RCP< Matrix > &SM_Matrix, RCP< Matrix > &D0_Matrix, magnitudeType rowSumTol, bool useKokkos_, Kokkos::View< bool *, typename Node::device_type > &BCrowsKokkos, Kokkos::View< bool *, typename Node::device_type > &BCcolsKokkos, Kokkos::View< bool *, typename Node::device_type > &BCdomainKokkos, int &BCedges, int &BCnodes, Teuchos::ArrayRCP< bool > &BCrows, Teuchos::ArrayRCP< bool > &BCcols, Teuchos::ArrayRCP< bool > &BCdomain, bool &allEdgesBoundary, bool &allNodesBoundary)
Detect Dirichlet boundary conditions.
Class that encapsulates Operator smoothers.
static void ZeroDirichletRows(Teuchos::RCP< Xpetra::Matrix< Scalar, DefaultLocalOrdinal, DefaultGlobalOrdinal, DefaultNode > > &A, const std::vector< DefaultLocalOrdinal > &dirichletRows, Scalar replaceWith=Teuchos::ScalarTraits< Scalar >::zero())
static void ZeroDirichletCols(Teuchos::RCP< Matrix > &A, const Teuchos::ArrayRCP< const bool > &dirichletCols, Scalar replaceWith=Teuchos::ScalarTraits< Scalar >::zero())
static RCP< Xpetra::Matrix< Scalar, DefaultLocalOrdinal, DefaultGlobalOrdinal, DefaultNode > > ReplaceNonZerosWithOnes(const RCP< Matrix > &original)
static RCP< MultiVector > Residual(const Xpetra::Operator< Scalar, DefaultLocalOrdinal, DefaultGlobalOrdinal, DefaultNode > &Op, const MultiVector &X, const MultiVector &RHS)
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
VerbLevel GetVerbLevel() const
Get the verbosity level.
bool IsPrint(MsgType type, int thisProcRankOnly=-1) const
Find out whether we need to print out information for a specific message type.
static void SetDefaultVerbLevel(const VerbLevel defaultVerbLevel)
Set the default (global) verbosity level.
Namespace for MueLu classes and methods.
long ExtractNonSerializableData(const Teuchos::ParameterList &inList, Teuchos::ParameterList &serialList, Teuchos::ParameterList &nonSerialList)
Extract non-serializable data from level-specific sublists and move it to a separate parameter list.
@ Warnings0
Important warning messages (one line).
@ Statistics2
Print even more statistics.
@ Runtime0
One-liner description of what is happening.
@ Warnings1
Additional warnings.
@ Timings
Print all timing information.
MsgType toVerbLevel(const std::string &verbLevelStr)
Teuchos::RCP< MueLu::Hierarchy< Scalar, LocalOrdinal, GlobalOrdinal, Node > > CreateXpetraPreconditioner(Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > op, const Teuchos::ParameterList &inParamList)
Helper function to create a MueLu preconditioner that can be used by Xpetra.Given an Xpetra::Matrix,...