46 #ifndef MUELU_MHDRAPFACTORY_DEF_HPP
47 #define MUELU_MHDRAPFACTORY_DEF_HPP
51 #include <Xpetra_Map.hpp>
52 #include <Xpetra_MapFactory.hpp>
53 #include <Xpetra_Matrix.hpp>
54 #include <Xpetra_CrsMatrixWrap.hpp>
55 #include <Xpetra_Vector.hpp>
56 #include <Xpetra_VectorFactory.hpp>
59 #include "MueLu_Utilities.hpp"
64 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
66 : implicitTranspose_(true) { }
68 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
71 if (implicitTranspose_ ==
false)
73 Input(coarseLevel,
"R" );
74 Input(coarseLevel,
"RV");
75 Input(coarseLevel,
"RP");
76 Input(coarseLevel,
"RM");
79 Input(fineLevel,
"A" );
80 Input(fineLevel,
"A00");
81 Input(fineLevel,
"A01");
82 Input(fineLevel,
"A02");
83 Input(fineLevel,
"A10");
84 Input(fineLevel,
"A11");
85 Input(fineLevel,
"A12");
86 Input(fineLevel,
"A20");
87 Input(fineLevel,
"A21");
88 Input(fineLevel,
"A22");
90 Input(coarseLevel,
"P" );
91 Input(coarseLevel,
"PV");
92 Input(coarseLevel,
"PP");
93 Input(coarseLevel,
"PM");
97 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
111 RCP<Matrix> A = Get< RCP<Matrix> >(fineLevel,
"A" );
112 RCP<Matrix> A00 = Get< RCP<Matrix> >(fineLevel,
"A00");
113 RCP<Matrix> A01 = Get< RCP<Matrix> >(fineLevel,
"A01");
114 RCP<Matrix> A02 = Get< RCP<Matrix> >(fineLevel,
"A02");
115 RCP<Matrix> A10 = Get< RCP<Matrix> >(fineLevel,
"A10");
116 RCP<Matrix> A11 = Get< RCP<Matrix> >(fineLevel,
"A11");
117 RCP<Matrix> A12 = Get< RCP<Matrix> >(fineLevel,
"A12");
118 RCP<Matrix> A20 = Get< RCP<Matrix> >(fineLevel,
"A20");
119 RCP<Matrix> A21 = Get< RCP<Matrix> >(fineLevel,
"A21");
120 RCP<Matrix> A22 = Get< RCP<Matrix> >(fineLevel,
"A22");
122 RCP<Matrix> P = Get< RCP<Matrix> >(coarseLevel,
"P" );
123 RCP<Matrix> PV = Get< RCP<Matrix> >(coarseLevel,
"PV");
124 RCP<Matrix> PP = Get< RCP<Matrix> >(coarseLevel,
"PP");
125 RCP<Matrix> PM = Get< RCP<Matrix> >(coarseLevel,
"PM");
145 AP = Utils::Multiply(*A ,
false, *P ,
false, AP, GetOStream(
Statistics2));
146 AP00 = Utils::Multiply(*A00,
false, *PV,
false, AP00, GetOStream(
Statistics2));
147 AP01 = Utils::Multiply(*A01,
false, *PP,
false, AP01, GetOStream(
Statistics2));
148 AP02 = Utils::Multiply(*A02,
false, *PM,
false, AP02, GetOStream(
Statistics2));
149 AP10 = Utils::Multiply(*A10,
false, *PV,
false, AP10, GetOStream(
Statistics2));
150 AP11 = Utils::Multiply(*A11,
false, *PP,
false, AP11, GetOStream(
Statistics2));
151 AP12 = Utils::Multiply(*A12,
false, *PM,
false, AP12, GetOStream(
Statistics2));
152 AP20 = Utils::Multiply(*A20,
false, *PV,
false, AP20, GetOStream(
Statistics2));
153 AP21 = Utils::Multiply(*A21,
false, *PP,
false, AP21, GetOStream(
Statistics2));
154 AP22 = Utils::Multiply(*A22,
false, *PM,
false, AP22, GetOStream(
Statistics2));
168 if (implicitTranspose_)
172 Ac = Utils::Multiply(*P ,
true, *AP ,
false, Ac, GetOStream(
Statistics2));
173 Ac00 = Utils::Multiply(*PV,
true, *AP00,
false, Ac00, GetOStream(
Statistics2));
174 Ac01 = Utils::Multiply(*PV,
true, *AP01,
false, Ac01, GetOStream(
Statistics2));
175 Ac02 = Utils::Multiply(*PV,
true, *AP02,
false, Ac02, GetOStream(
Statistics2));
176 Ac10 = Utils::Multiply(*PP,
true, *AP10,
false, Ac10, GetOStream(
Statistics2));
177 Ac11 = Utils::Multiply(*PP,
true, *AP11,
false, Ac11, GetOStream(
Statistics2));
178 Ac12 = Utils::Multiply(*PP,
true, *AP12,
false, Ac12, GetOStream(
Statistics2));
179 Ac20 = Utils::Multiply(*PM,
true, *AP20,
false, Ac20, GetOStream(
Statistics2));
180 Ac21 = Utils::Multiply(*PM,
true, *AP21,
false, Ac21, GetOStream(
Statistics2));
181 Ac22 = Utils::Multiply(*PM,
true, *AP22,
false, Ac22, GetOStream(
Statistics2));
189 RCP<Matrix> R = Get< RCP<Matrix> >(coarseLevel,
"R" );
190 RCP<Matrix> RV = Get< RCP<Matrix> >(coarseLevel,
"RV");
191 RCP<Matrix> RP = Get< RCP<Matrix> >(coarseLevel,
"RP");
192 RCP<Matrix> RM = Get< RCP<Matrix> >(coarseLevel,
"RM");
194 Ac = Utils::Multiply(*R ,
false, *AP ,
false, Ac, GetOStream(
Statistics2));
195 Ac00 = Utils::Multiply(*RV,
false, *AP00,
false, Ac00, GetOStream(
Statistics2));
196 Ac01 = Utils::Multiply(*RV,
false, *AP01,
false, Ac01, GetOStream(
Statistics2));
197 Ac02 = Utils::Multiply(*RV,
false, *AP02,
false, Ac02, GetOStream(
Statistics2));
198 Ac10 = Utils::Multiply(*RP,
false, *AP10,
false, Ac10, GetOStream(
Statistics2));
199 Ac11 = Utils::Multiply(*RP,
false, *AP11,
false, Ac11, GetOStream(
Statistics2));
200 Ac12 = Utils::Multiply(*RP,
false, *AP12,
false, Ac12, GetOStream(
Statistics2));
201 Ac20 = Utils::Multiply(*RM,
false, *AP20,
false, Ac20, GetOStream(
Statistics2));
202 Ac21 = Utils::Multiply(*RM,
false, *AP21,
false, Ac21, GetOStream(
Statistics2));
203 Ac22 = Utils::Multiply(*RM,
false, *AP22,
false, Ac22, GetOStream(
Statistics2));
208 Set(coarseLevel,
"A" , Ac );
209 Set(coarseLevel,
"A00", Ac00);
210 Set(coarseLevel,
"A01", Ac01);
211 Set(coarseLevel,
"A02", Ac02);
212 Set(coarseLevel,
"A10", Ac10);
213 Set(coarseLevel,
"A11", Ac11);
214 Set(coarseLevel,
"A12", Ac12);
215 Set(coarseLevel,
"A20", Ac20);
216 Set(coarseLevel,
"A21", Ac21);
217 Set(coarseLevel,
"A22", Ac22);
238 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
240 std::stringstream ss(std::stringstream::out);
246 size_t numMyNnz = Ac.getNodeNumEntries();
251 MueLu_minAll(comm, (GO)((numMyNnz > 0) ? numMyNnz : maxNnz), minNnz);
252 double imbalance = ((double) maxNnz) / minNnz;
254 size_t numMyRows = Ac.getNodeNumRows();
256 GO numActiveProcesses=0;
257 MueLu_sumAll(comm, (GO)((numMyRows > 0) ? 1 : 0), numActiveProcesses);
260 GO minNumRows, maxNumRows;
263 MueLu_minAll(comm, (GO)((numMyRows > 0) ? numMyRows : maxNumRows), minNumRows);
264 assert(numActiveProcesses > 0);
265 avgNumRows = Ac.getGlobalNumRows() / numActiveProcesses;
267 ss << msgTag <<
" # processes with rows = " << numActiveProcesses << std::endl;
268 ss << msgTag <<
" min # rows per proc = " << minNumRows <<
", max # rows per proc = " << maxNumRows <<
", avg # rows per proc = " << avgNumRows << std::endl;
269 ss << msgTag <<
" nonzero imbalance = " << imbalance << std::endl;
277 #define MUELU_MHDRAPFACTORY_SHORT
278 #endif // MUELU_MHDRAPFACTORY_DEF_HPP
#define MueLu_sumAll(rcpComm, in, out)
#define MueLu_maxAll(rcpComm, in, out)
Timer to be used in factories. Similar to Monitor but with additional timers.
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
#define MueLu_minAll(rcpComm, in, out)
Print even more statistics.
Class that holds all level-specific information.
static std::string PrintLoadBalancingInfo(const Matrix &Ac, const std::string &msgTag)
Timer to be used in factories. Similar to SubMonitor but adds a timer level by level.
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.