10#ifndef MUELU_MULTIPHYS_DEF_HPP
11#define MUELU_MULTIPHYS_DEF_HPP
16#include "Xpetra_Map.hpp"
17#include "Xpetra_CrsMatrixUtils.hpp"
18#include "Xpetra_MatrixUtils.hpp"
21#include "MueLu_SaPFactory.hpp"
22#include "MueLu_AggregationExportFactory.hpp"
23#include "MueLu_Utilities.hpp"
25#include "MueLu_Hierarchy.hpp"
26#include "MueLu_RAPFactory.hpp"
28#include "MueLu_PerfUtils.hpp"
29#include "MueLu_ParameterListInterpreter.hpp"
31#include <MueLu_HierarchyUtils.hpp>
37#include "cuda_profiler_api.h"
42template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
47template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
52template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
56 list.set(
"multigrid algorithm",
"combine");
57 list.set(
"combine: numBlks",
nBlks_);
60 std::string verbosity = list.get(
"verbosity",
"high");
64 for (
int i = 0; i <
nBlks_; i++) {
65 std::string listName =
"subblockList" + Teuchos::toString(i);
66 if (list.isSublist(listName)) {
83template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
96 std::string timerLabel;
98 timerLabel =
"MueLu MultiPhys: compute (reuse)";
100 timerLabel =
"MueLu MultiPhys: compute";
101 RCP<Teuchos::TimeMonitor> tmCompute =
getTimer(timerLabel);
106 for (
int iii = 0; iii <
nBlks_; iii++) {
111 bool wantToRepartition =
false;
117 arrayOfParamLists_[iii]->set(
"repartition: explicit via new copy rebalance P and R",
true);
130 for (
int i = 0; i <
nBlks_; i++) {
131 std::string operatorLabel =
"MultiPhys (" + Teuchos::toString(i) +
"," + Teuchos::toString(i) +
")";
135 if (tempNlevels < maxLevels) maxLevels = tempNlevels;
139 for (LO i = 0; i < maxLevels; i++) {
142 for (
int i = 0; i <
nBlks_; i++) {
143 std::string subblkName =
"Psubblock" + Teuchos::toString(i);
152 Teuchos::ParameterList nonSerialListMultiphysics, processedListMultiphysics;
157 Teuchos::ParameterList stripped;
158 for (ParameterList::ConstIterator inListEntry = processedListMultiphysics.begin(); inListEntry != processedListMultiphysics.end(); inListEntry++) {
159 const std::string& levelName = inListEntry->first;
160 if (levelName.find(
"subblockList") != 0) stripped.setEntry(inListEntry->first, inListEntry->second);
178template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
182 return Teuchos::rcp(
new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(name)));
185 return Teuchos::rcp(
new Teuchos::SyncTimeMonitor(*Teuchos::TimeMonitor::getNewTimer(name),
AmatMultiphysics_->getRowMap()->getComm().ptr()));
187 return Teuchos::rcp(
new Teuchos::SyncTimeMonitor(*Teuchos::TimeMonitor::getNewTimer(name), comm.ptr()));
190 return Teuchos::null;
193template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
197 if (ComputePrec)
compute(reuse);
200template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
205template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
210 RCP<Teuchos::TimeMonitor> tm =
getTimer(
"MueLu MultiPhys: solve");
214template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
219template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
221 initialize(
const Teuchos::RCP<Matrix>& AmatMultiPhysics,
222 const Teuchos::ArrayRCP<RCP<Matrix>> arrayOfAuxMatrices,
223 const Teuchos::ArrayRCP<Teuchos::RCP<MultiVector>> arrayOfNullspaces,
224 const Teuchos::ArrayRCP<Teuchos::RCP<RealValuedMultiVector>> arrayOfCoords,
226 Teuchos::ParameterList& List) {
240template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
242 describe(Teuchos::FancyOStream& out,
const Teuchos::EVerbosityLevel )
const {
243 std::ostringstream oss;
245 RCP<const Teuchos::Comm<int>> comm =
AmatMultiphysics_->getDomainMap()->getComm();
247 oss <<
"\n--------------------------------------------------------------------------------\n"
248 <<
"--- MultiPhysics Summary ---\n"
249 "--------------------------------------------------------------------------------"
258 for (
int i = 0; i <
nBlks_; i++) {
261 Xpetra::global_size_t tt = numRows;
274 oss <<
"block " << std::setw(rowspacer) <<
" rows " << std::setw(nnzspacer) <<
" nnz " << std::setw(9) <<
" nnz/row" << std::endl;
275 oss <<
"(" << Teuchos::toString(i) <<
", " << Teuchos::toString(i) <<
")" << std::setw(rowspacer) << numRows << std::setw(nnzspacer) << nnz << std::setw(9) << as<double>(nnz) / numRows << std::endl;
281 for (
int i = 0; i <
nBlks_; i++) {
289#define MUELU_MULTIPHYS_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.
Teuchos::RCP< Hierarchy > hierarchyMultiphysics_
const Teuchos::RCP< const Map > getRangeMap() const
Returns the Xpetra::Map object associated with the range of this operator.
Teuchos::RCP< Teuchos::TimeMonitor > getTimer(std::string name, RCP< const Teuchos::Comm< int > > comm=Teuchos::null) const
get a (synced) timer
Teuchos::ArrayRCP< Teuchos::RCP< Matrix > > arrayOfAuxMatrices_
void compute(bool reuse=false)
Setup the preconditioner.
void applyInverse(const MultiVector &RHS, MultiVector &X) const
apply standard MultiPhys cycle
void setParameters(Teuchos::ParameterList &list)
Set parameters.
void resetMatrix(Teuchos::RCP< Matrix > SM_Matrix_new, bool ComputePrec=true)
Reset system matrix.
Teuchos::RCP< Matrix > AmatMultiphysics_
Hierarchies: used to define P for (0,0)-block, .... (nBlks_-1,nBlks_-1) block.
const Teuchos::RCP< const Map > getDomainMap() const
Returns the Xpetra::Map object associated with the domain of this operator.
Teuchos::ArrayRCP< Teuchos::RCP< Hierarchy > > arrayOfHierarchies_
bool hasTransposeApply() const
Indicates whether this operator supports applying the adjoint operator.
Teuchos::RCP< Teuchos::ParameterList > paramListMultiphysics_
Teuchos::ArrayRCP< Teuchos::RCP< RealValuedMultiVector > > arrayOfCoords_
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_HIGH) const
void initialize(const Teuchos::RCP< Matrix > &AmatMultiPhysics, const Teuchos::ArrayRCP< RCP< Matrix > > arrayOfAuxMatrices, const Teuchos::ArrayRCP< Teuchos::RCP< MultiVector > > arrayOfNullspaces, const Teuchos::ArrayRCP< Teuchos::RCP< RealValuedMultiVector > > arrayOfCoords, const int nBlks, Teuchos::ParameterList &List)
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
Teuchos::ArrayRCP< Teuchos::RCP< Teuchos::ParameterList > > arrayOfParamLists_
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.
@ Runtime0
One-liner description of what is happening.
@ 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,...