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);
154 std::string mode_string = list.get(
"maxwell1: mode", MasterList::getDefault<std::string>(
"maxwell1: mode"));
155 applyBCsTo22_ = list.get(
"maxwell1: apply BCs to 22",
false);
156 dump_matrices_ = list.get(
"maxwell1: dump matrices", MasterList::getDefault<bool>(
"maxwell1: dump matrices"));
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");
170 if(mode_ != MODE_GMHD_STANDARD) {
171 if(mode_string ==
"standard") mode_ = MODE_STANDARD;
172 else if(mode_string ==
"refmaxwell") mode_ = MODE_REFMAXWELL;
173 else if(mode_string ==
"edge only") mode_ = MODE_EDGE_ONLY;
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"))
182 precList22_ = list.sublist(
"maxwell1: 22list");
183 else if(list.isSublist(
"refmaxwell: 22list"))
184 precList22_ = list.sublist(
"refmaxwell: 22list");
185 if(mode_ == MODE_EDGE_ONLY || mode_ == MODE_STANDARD || mode_ == MODE_GMHD_STANDARD)
186 precList22_.set(
"smoother: pre or post",
"none");
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")) {
191 precList22_ = defaultSmootherList;
193 precList22_.set(
"verbosity",precList22_.get(
"verbosity",verbosity));
199 if(list.isSublist(
"maxwell1: 11list"))
200 precList11_ = list.sublist(
"maxwell1: 11list");
201 else if(list.isSublist(
"refmaxwell: 11list"))
202 precList11_ = list.sublist(
"refmaxwell: 11list");
204 if(mode_ == MODE_GMHD_STANDARD) {
205 precList11_.set(
"smoother: pre or post",
"none");
206 precList11_.set(
"smoother: type",
"none");
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")) {
212 if(mode_ == MODE_EDGE_ONLY || mode_ == MODE_REFMAXWELL) {
213 precList11_ = defaultSmootherList;
215 if (mode_ == MODE_STANDARD) {
216 precList11_.set(
"smoother: type",
"HIPTMAIR");
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;
223 precList11_.set(
"verbosity",precList11_.get(
"verbosity",verbosity));
227 !precList11_.isType<std::string>(
"Preconditioner Type") &&
228 !precList11_.isParameter(
"reuse: type"))
229 precList11_.set(
"reuse: type",
"full");
231 !precList22_.isType<std::string>(
"Preconditioner Type") &&
232 !precList22_.isParameter(
"reuse: type"))
233 precList22_.set(
"reuse: type",
"full");
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())
249 useKokkos_ = list.get(
"use kokkos refactor",useKokkos_);
251 parameterList_ = list;
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;
303 if(Kn_Matrix_.is_null()) {
305 GetOStream(
Runtime0) <<
"Maxwell1::compute(): Kn not provided. Generating." << std::endl;
306 Kn_Matrix_ = generate_kn();
307 have_generated_Kn =
true;
309 else if (parameterList_.get<
bool>(
"rap: fix zero diagonals",
true)) {
311 if (parameterList_.isType<
magnitudeType>(
"rap: fix zero diagonals threshold"))
312 threshold = parameterList_.get<
magnitudeType>(
"rap: fix zero diagonals threshold",
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",
318 MasterList::getDefault<double>(
"rap: fix zero diagonals replacement")));
319 Xpetra::MatrixUtils<SC,LO,GO,NO>::CheckRepairMainDiagonal(Kn_Matrix_,
true, GetOStream(
Warnings1), threshold, replacement);
325 Kn_Matrix_->setObjectLabel(
"Maxwell1 (2,2)");
328 if (!Coords_.is_null())
329 precList22_.sublist(
"user data").set(
"Coordinates",Coords_);
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);
362 precList11_.remove(
"repartition: enable",
false);
383 magnitudeType rowSumTol = precList11_.get(
"aggregation: row sum drop tol",-1.0);
385 useKokkos_,BCrowsKokkos_,BCcolsKokkos_,BCdomainKokkos_,
386 BCedges_,BCnodes_,BCrows_,BCcols_,BCdomain_,
387 allEdgesBoundary_,allNodesBoundary_);
389 GetOStream(
Statistics2) <<
"MueLu::Maxwell1::compute(): Detected " << BCedges_ <<
" BC rows and " << BCnodes_ <<
" BC columns." << std::endl;
393 if (allEdgesBoundary_) {
396 GetOStream(
Warnings0) <<
"All edges are detected as boundary edges!" << std::endl;
397 mode_ = MODE_EDGE_ONLY;
400 precList22_.set(
"max levels", 1);
404 if (allNodesBoundary_) {
407 GetOStream(
Warnings0) <<
"All nodes are detected as boundary nodes!" << std::endl;
408 mode_ = MODE_EDGE_ONLY;
411 precList22_.set(
"max levels", 1);
422 D0_Matrix_->resumeFill();
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;
438 GetOStream(
Runtime0) <<
"Maxwell1::compute(): nuking BC rows of D0" << std::endl;
446 D0_Matrix_->fillComplete(D0_Matrix_->getDomainMap(),D0_Matrix_->getRangeMap());
457 RCP<Matrix> Kn_Smoother_0;
458 if(have_generated_Kn) {
459 Kn_Smoother_0 = Kn_Matrix_;
462 Kn_Smoother_0 = generate_kn();
467 Hierarchy11_ = rcp(
new Hierarchy(
"Maxwell1 (1,1)"));
468 RCP<Matrix> OldSmootherMatrix;
469 RCP<Level> OldEdgeLevel;
470 for(
int i=0; i<Hierarchy22_->GetNumLevels(); i++) {
471 Hierarchy11_->AddNewLevel();
472 RCP<Level> NodeL = Hierarchy22_->GetLevel(i);
473 RCP<Level> EdgeL = Hierarchy11_->GetLevel(i);
474 RCP<Operator> NodeOp = NodeL->Get<RCP<Operator> >(
"A");
475 RCP<Matrix> NodeAggMatrix = rcp_dynamic_cast<Matrix>(NodeOp);
479 EdgeL->Set(
"A", SM_Matrix_);
480 EdgeL->Set(
"D0", D0_Matrix_);
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");
554 SM_Matrix_->setObjectLabel(
"A(1,1)");
555 precList11_.set(
"coarse: max size",1);
556 precList11_.set(
"max levels",Hierarchy22_->GetNumLevels());
558 const bool refmaxwellCoarseSolve = (precList11_.get<std::string>(
"coarse: type",
559 MasterList::getDefault<std::string>(
"coarse: type")) ==
"RefMaxwell");
560 if (refmaxwellCoarseSolve) {
561 GetOStream(
Runtime0) <<
"Maxwell1::compute(): Will set up RefMaxwell coarse solver" << std::endl;
562 precList11_.set(
"coarse: type",
"none");
566 Teuchos::ParameterList nonSerialList11, processedPrecList11;
569 Hierarchy11_->setlib(SM_Matrix_->getDomainMap()->lib());
570 Hierarchy11_->SetProcRankVerbose(SM_Matrix_->getDomainMap()->getComm()->getRank());
573 mueLuFactory->SetupHierarchy(*Hierarchy11_);
575 if (refmaxwellCoarseSolve) {
576 GetOStream(
Runtime0) <<
"Maxwell1::compute(): Setting up RefMaxwell coarse solver" << std::endl;
577 auto coarseLvl = Hierarchy11_->GetLevel(Hierarchy11_->GetNumLevels()-1);
579 precList11_.sublist(
"coarse: params")));
580 coarseSolver->Setup(*coarseLvl);
581 coarseLvl->Set(
"PreSmoother",
582 rcp_dynamic_cast<SmootherBase>(coarseSolver,
true));
585 if(mode_ == MODE_REFMAXWELL) {
586 if(Hierarchy11_->GetNumLevels() > 1) {
587 RCP<Level> EdgeL = Hierarchy11_->GetLevel(1);
588 P11_ = EdgeL->Get<RCP<Matrix> >(
"P");
600#ifdef MUELU_MAXWELL1_DEBUG
601 for(
int i=0; i<Hierarchy11_->GetNumLevels(); i++) {
602 RCP<Level> L = Hierarchy11_->GetLevel(i);
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;
743 const SC one = Teuchos::ScalarTraits<SC>::one();
744 if (!allEdgesBoundary_ && X.getNumVectors() != residualFine_->getNumVectors())
745 allocateMemory(X.getNumVectors());
747 TEUCHOS_TEST_FOR_EXCEPTION(Hierarchy11_.is_null() || Hierarchy11_->GetNumLevels() == 0,
Exceptions::RuntimeError,
"(1,1) Hiearchy is null.");
750 RCP<Level> Fine = Hierarchy11_->GetLevel(0);
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");
766 P11_->apply(*residualFine_,*residual11c_,Teuchos::TRANS);
767 Hierarchy11_->Iterate(*residual11c_,*update11c_,
true,1);
771 if (!allNodesBoundary_) {
772 RCP<Teuchos::TimeMonitor> tmRes = getTimer(
"MueLu Maxwell1: (2,2) correction");
773 D0_Matrix_->apply(*residualFine_,*residual22_,Teuchos::TRANS);
774 Hierarchy22_->Iterate(*residual22_,*update22_,
true,0);
779 RCP<Teuchos::TimeMonitor> tmRes = getTimer(
"MueLu Maxwell1: Orolongation");
781 P11_->apply(*update11c_,X,Teuchos::NO_TRANS,one,one);
782 if (!allNodesBoundary_)
783 D0_Matrix_->apply(*update22_,X,Teuchos::NO_TRANS,one,one);
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);
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()));
846 Hierarchy11_ = Teuchos::null;
847 Hierarchy22_ = Teuchos::null;
848 HierarchyGmhd_ = Teuchos::null;
849 if (mode_ != MODE_GMHD_STANDARD) mode_ = MODE_STANDARD;
853 allEdgesBoundary_=
false;
854 allNodesBoundary_=
false;
855 dump_matrices_ =
false;
858 applyBCsTo22_ =
false;
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);
896 Kn_Matrix_ = Kn_Matrix;
898 Nullspace_ = Nullspace;
900 if(!Kn_Matrix_.is_null()) dump(*Kn_Matrix_,
"Kn.m");
901 if (!Nullspace_.is_null()) dump(*Nullspace_,
"nullspace.m");
902 if (!Coords_.is_null()) dumpCoords(*Coords_,
"coords.m");
910 describe(Teuchos::FancyOStream& out,
const Teuchos::EVerbosityLevel )
const {
912 std::ostringstream oss;
914 RCP<const Teuchos::Comm<int> > comm = SM_Matrix_->getDomainMap()->getComm();
918 if (!Kn_Matrix_.is_null())
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();
939 numRows = SM_Matrix_->getGlobalNumRows();
940 nnz = SM_Matrix_->getGlobalNumEntries();
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;
950 if (!Kn_Matrix_.is_null()) {
952 numRows = Kn_Matrix_->getGlobalNumRows();
953 nnz = Kn_Matrix_->getGlobalNumEntries();
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);
976 if (!Hierarchy11_.is_null())
977 Hierarchy11_->describe(out, GetVerbLevel());
979 if (!Hierarchy22_.is_null())
980 Hierarchy22_->describe(out, GetVerbLevel());
982 if (!HierarchyGmhd_.is_null())
983 HierarchyGmhd_->describe(out, GetVerbLevel());
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();
1000 if (!Kn_Matrix_.is_null())
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;
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.