MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_TentativePFactory_def.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // MueLu: A package for multigrid based preconditioning
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef MUELU_TENTATIVEPFACTORY_DEF_HPP
47 #define MUELU_TENTATIVEPFACTORY_DEF_HPP
48 
49 #include <Xpetra_MapFactory.hpp>
50 #include <Xpetra_Map.hpp>
51 #include <Xpetra_CrsMatrix.hpp>
52 #include <Xpetra_Matrix.hpp>
53 #include <Xpetra_MultiVector.hpp>
55 #include <Xpetra_VectorFactory.hpp>
56 #include <Xpetra_Import.hpp>
57 #include <Xpetra_ImportFactory.hpp>
58 #include <Xpetra_CrsMatrixWrap.hpp>
59 #include <Xpetra_StridedMap.hpp>
61 
63 
64 #include "MueLu_Aggregates.hpp"
65 #include "MueLu_AmalgamationFactory.hpp"
66 #include "MueLu_AmalgamationInfo.hpp"
67 #include "MueLu_CoarseMapFactory.hpp"
68 #include "MueLu_MasterList.hpp"
69 #include "MueLu_Monitor.hpp"
70 #include "MueLu_NullspaceFactory.hpp"
71 #include "MueLu_PerfUtils.hpp"
72 #include "MueLu_Utilities.hpp"
73 
74 namespace MueLu {
75 
76  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
78  RCP<ParameterList> validParamList = rcp(new ParameterList());
79 
80 #define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
81  SET_VALID_ENTRY("tentative: calculate qr");
82  SET_VALID_ENTRY("tentative: build coarse coordinates");
83 #undef SET_VALID_ENTRY
84 
85  validParamList->set< RCP<const FactoryBase> >("A", Teuchos::null, "Generating factory of the matrix A");
86  validParamList->set< RCP<const FactoryBase> >("Aggregates", Teuchos::null, "Generating factory of the aggregates");
87  validParamList->set< RCP<const FactoryBase> >("Nullspace", Teuchos::null, "Generating factory of the nullspace");
88  validParamList->set< RCP<const FactoryBase> >("UnAmalgamationInfo", Teuchos::null, "Generating factory of UnAmalgamationInfo");
89  validParamList->set< RCP<const FactoryBase> >("CoarseMap", Teuchos::null, "Generating factory of the coarse map");
90  validParamList->set< RCP<const FactoryBase> >("Coordinates", Teuchos::null, "Generating factory of the coordinates");
91  validParamList->set< RCP<const FactoryBase> >("Node Comm", Teuchos::null, "Generating factory of the node level communicator");
92 
93  // Make sure we don't recursively validate options for the matrixmatrix kernels
94  ParameterList norecurse;
95  norecurse.disableRecursiveValidation();
96  validParamList->set<ParameterList> ("matrixmatrix: kernel params", norecurse, "MatrixMatrix kernel parameters");
97 
98  return validParamList;
99  }
100 
101  template <class Scalar,class LocalOrdinal, class GlobalOrdinal, class Node>
103 
104  const ParameterList& pL = GetParameterList();
105 
106  Input(fineLevel, "A");
107  Input(fineLevel, "Aggregates");
108  Input(fineLevel, "Nullspace");
109  Input(fineLevel, "UnAmalgamationInfo");
110  Input(fineLevel, "CoarseMap");
111  if( fineLevel.GetLevelID() == 0 &&
112  fineLevel.IsAvailable("Coordinates", NoFactory::get()) && // we have coordinates (provided by user app)
113  pL.get<bool>("tentative: build coarse coordinates") ) { // and we want coordinates on other levels
114  bTransferCoordinates_ = true; // then set the transfer coordinates flag to true
115  Input(fineLevel, "Coordinates");
116  } else if (bTransferCoordinates_) {
117  Input(fineLevel, "Coordinates");
118  }
119  }
120 
121  template <class Scalar,class LocalOrdinal, class GlobalOrdinal, class Node>
123  return BuildP(fineLevel, coarseLevel);
124  }
125 
126  template <class Scalar,class LocalOrdinal, class GlobalOrdinal, class Node>
128  FactoryMonitor m(*this, "Build", coarseLevel);
129  typedef typename Teuchos::ScalarTraits<Scalar>::coordinateType coordinate_type;
130  typedef Xpetra::MultiVector<coordinate_type,LO,GO,NO> RealValuedMultiVector;
131  typedef Xpetra::MultiVectorFactory<coordinate_type,LO,GO,NO> RealValuedMultiVectorFactory;
132 
133  RCP<Matrix> A = Get< RCP<Matrix> > (fineLevel, "A");
134  RCP<Aggregates> aggregates = Get< RCP<Aggregates> > (fineLevel, "Aggregates");
135  RCP<AmalgamationInfo> amalgInfo = Get< RCP<AmalgamationInfo> > (fineLevel, "UnAmalgamationInfo");
136  RCP<MultiVector> fineNullspace = Get< RCP<MultiVector> > (fineLevel, "Nullspace");
137  RCP<const Map> coarseMap = Get< RCP<const Map> > (fineLevel, "CoarseMap");
138  RCP<RealValuedMultiVector> fineCoords;
139  if(bTransferCoordinates_) {
140  fineCoords = Get< RCP<RealValuedMultiVector> >(fineLevel, "Coordinates");
141  }
142 
143  // FIXME: We should remove the NodeComm on levels past the threshold
144  if(fineLevel.IsAvailable("Node Comm")) {
145  RCP<const Teuchos::Comm<int> > nodeComm = Get<RCP<const Teuchos::Comm<int> > >(fineLevel,"Node Comm");
146  Set<RCP<const Teuchos::Comm<int> > >(coarseLevel, "Node Comm", nodeComm);
147  }
148 
149  TEUCHOS_TEST_FOR_EXCEPTION(A->getRowMap()->getNodeNumElements() != fineNullspace->getMap()->getNodeNumElements(),
150  Exceptions::RuntimeError,"MueLu::TentativePFactory::MakeTentative: Size mismatch between A and Nullspace");
151 
152  RCP<Matrix> Ptentative;
153  RCP<MultiVector> coarseNullspace;
154  RCP<RealValuedMultiVector> coarseCoords;
155 
156  if(bTransferCoordinates_) {
157  //*** Create the coarse coordinates ***
158  // First create the coarse map and coarse multivector
159  ArrayView<const GO> elementAList = coarseMap->getNodeElementList();
160  LO blkSize = 1;
161  if (rcp_dynamic_cast<const StridedMap>(coarseMap) != Teuchos::null)
162  blkSize = rcp_dynamic_cast<const StridedMap>(coarseMap)->getFixedBlockSize();
163  GO indexBase = coarseMap->getIndexBase();
164  size_t numNodes = elementAList.size() / blkSize;
165  Array<GO> nodeList(numNodes);
166  const int numDimensions = fineCoords->getNumVectors();
167 
168  for (LO i = 0; i < Teuchos::as<LO>(numNodes); i++) {
169  nodeList[i] = (elementAList[i*blkSize]-indexBase)/blkSize + indexBase;
170  }
171  RCP<const Map> coarseCoordsMap = MapFactory::Build(fineCoords->getMap()->lib(),
173  nodeList,
174  indexBase,
175  fineCoords->getMap()->getComm());
176  coarseCoords = RealValuedMultiVectorFactory::Build(coarseCoordsMap, numDimensions);
177 
178  // Create overlapped fine coordinates to reduce global communication
179  RCP<RealValuedMultiVector> ghostedCoords;
180  if (aggregates->AggregatesCrossProcessors()) {
181  RCP<const Map> aggMap = aggregates->GetMap();
182  RCP<const Import> importer = ImportFactory::Build(fineCoords->getMap(), aggMap);
183 
184  ghostedCoords = RealValuedMultiVectorFactory::Build(aggMap, numDimensions);
185  ghostedCoords->doImport(*fineCoords, *importer, Xpetra::INSERT);
186  } else {
187  ghostedCoords = fineCoords;
188  }
189 
190  // Get some info about aggregates
191  int myPID = coarseCoordsMap->getComm()->getRank();
192  LO numAggs = aggregates->GetNumAggregates();
193  ArrayRCP<LO> aggSizes = aggregates->ComputeAggregateSizes();
194  const ArrayRCP<const LO> vertex2AggID = aggregates->GetVertex2AggId()->getData(0);
195  const ArrayRCP<const LO> procWinner = aggregates->GetProcWinner()->getData(0);
196 
197  // Fill in coarse coordinates
198  for (int dim = 0; dim < numDimensions; ++dim) {
199  ArrayRCP<const coordinate_type> fineCoordsData = ghostedCoords->getData(dim);
200  ArrayRCP<coordinate_type> coarseCoordsData = coarseCoords->getDataNonConst(dim);
201 
202  for (LO lnode = 0; lnode < Teuchos::as<LO>(numNodes); lnode++) {
203  if (procWinner[lnode] == myPID &&
204  lnode < vertex2AggID.size() &&
205  lnode < fineCoordsData.size() &&
206  vertex2AggID[lnode] < coarseCoordsData.size() &&
207  Teuchos::ScalarTraits<coordinate_type>::isnaninf(fineCoordsData[lnode]) == false) {
208  coarseCoordsData[vertex2AggID[lnode]] += fineCoordsData[lnode];
209  }
210  }
211  for (LO agg = 0; agg < numAggs; agg++) {
212  coarseCoordsData[agg] /= aggSizes[agg];
213  }
214  }
215  }
216 
217  if (!aggregates->AggregatesCrossProcessors())
218  BuildPuncoupled(A, aggregates, amalgInfo, fineNullspace, coarseMap, Ptentative, coarseNullspace,coarseLevel.GetLevelID());
219  else
220  BuildPcoupled (A, aggregates, amalgInfo, fineNullspace, coarseMap, Ptentative, coarseNullspace);
221 
222  // If available, use striding information of fine level matrix A for range
223  // map and coarseMap as domain map; otherwise use plain range map of
224  // Ptent = plain range map of A for range map and coarseMap as domain map.
225  // NOTE:
226  // The latter is not really safe, since there is no striding information
227  // for the range map. This is not really a problem, since striding
228  // information is always available on the intermedium levels and the
229  // coarsest levels.
230  if (A->IsView("stridedMaps") == true)
231  Ptentative->CreateView("stridedMaps", A->getRowMap("stridedMaps"), coarseMap);
232  else
233  Ptentative->CreateView("stridedMaps", Ptentative->getRangeMap(), coarseMap);
234 
235  if(bTransferCoordinates_) {
236  Set(coarseLevel, "Coordinates", coarseCoords);
237  }
238  Set(coarseLevel, "Nullspace", coarseNullspace);
239  Set(coarseLevel, "P", Ptentative);
240 
241  if (IsPrint(Statistics2)) {
242  RCP<ParameterList> params = rcp(new ParameterList());
243  params->set("printLoadBalancingInfo", true);
244  GetOStream(Statistics2) << PerfUtils::PrintMatrixInfo(*Ptentative, "Ptent", params);
245  }
246  }
247 
248  template <class Scalar,class LocalOrdinal, class GlobalOrdinal, class Node>
251  RCP<const Map> coarseMap, RCP<Matrix>& Ptentative, RCP<MultiVector>& coarseNullspace, const int levelID) const {
252  RCP<const Map> rowMap = A->getRowMap();
253  RCP<const Map> colMap = A->getColMap();
254 
255  const size_t numRows = rowMap->getNodeNumElements();
256 
257  typedef Teuchos::ScalarTraits<SC> STS;
258  typedef typename STS::magnitudeType Magnitude;
259  const SC zero = STS::zero();
260  const SC one = STS::one();
261  const LO INVALID = Teuchos::OrdinalTraits<LO>::invalid();
262 
263  const GO numAggs = aggregates->GetNumAggregates();
264  const size_t NSDim = fineNullspace->getNumVectors();
265 
266  // Aggregates map is based on the amalgamated column map
267  // We can skip global-to-local conversion if LIDs in row map are
268  // same as LIDs in column map
269  bool goodMap = isGoodMap(*rowMap, *colMap);
270 
271  // Create a lookup table to determine the rows (fine DOFs) that belong to a given aggregate.
272  // aggStart is a pointer into aggToRowMapLO
273  // aggStart[i]..aggStart[i+1] are indices into aggToRowMapLO
274  // aggToRowMapLO[aggStart[i]]..aggToRowMapLO[aggStart[i+1]-1] are the DOFs in aggregate i
275  ArrayRCP<LO> aggStart;
276  ArrayRCP<LO> aggToRowMapLO;
277  ArrayRCP<GO> aggToRowMapGO;
278  if (goodMap) {
279  amalgInfo->UnamalgamateAggregatesLO(*aggregates, aggStart, aggToRowMapLO);
280  GetOStream(Runtime1) << "Column map is consistent with the row map, good." << std::endl;
281 
282  } else {
283  amalgInfo->UnamalgamateAggregates(*aggregates, aggStart, aggToRowMapGO);
284  GetOStream(Warnings0) << "Column map is not consistent with the row map\n"
285  << "using GO->LO conversion with performance penalty" << std::endl;
286  }
287 
288  coarseNullspace = MultiVectorFactory::Build(coarseMap, NSDim);
289 
290  const ParameterList& pL = GetParameterList();
291  const bool &doQRStep = pL.get<bool>("tentative: calculate qr");
292 
293  // Pull out the nullspace vectors so that we can have random access.
294  ArrayRCP<ArrayRCP<const SC> > fineNS (NSDim);
295  ArrayRCP<ArrayRCP<SC> > coarseNS(NSDim);
296  for (size_t i = 0; i < NSDim; i++) {
297  fineNS[i] = fineNullspace->getData(i);
298  if (coarseMap->getNodeNumElements() > 0)
299  coarseNS[i] = coarseNullspace->getDataNonConst(i);
300  }
301 
302  size_t nnzEstimate = numRows * NSDim;
303 
304  // Time to construct the matrix and fill in the values
305  Ptentative = rcp(new CrsMatrixWrap(rowMap, coarseMap, 0, Xpetra::StaticProfile));
306  RCP<CrsMatrix> PtentCrs = rcp_dynamic_cast<CrsMatrixWrap>(Ptentative)->getCrsMatrix();
307 
308  ArrayRCP<size_t> iaPtent;
309  ArrayRCP<LO> jaPtent;
310  ArrayRCP<SC> valPtent;
311 
312  PtentCrs->allocateAllValues(nnzEstimate, iaPtent, jaPtent, valPtent);
313 
314  ArrayView<size_t> ia = iaPtent();
315  ArrayView<LO> ja = jaPtent();
316  ArrayView<SC> val = valPtent();
317 
318  ia[0] = 0;
319  for (size_t i = 1; i <= numRows; i++)
320  ia[i] = ia[i-1] + NSDim;
321 
322  for (size_t j = 0; j < nnzEstimate; j++) {
323  ja [j] = INVALID;
324  val[j] = zero;
325  }
326 
327 
328  if (doQRStep) {
330  // Standard aggregate-wise QR //
332  for (GO agg = 0; agg < numAggs; agg++) {
333  LO aggSize = aggStart[agg+1] - aggStart[agg];
334 
335  Xpetra::global_size_t offset = agg*NSDim;
336 
337  // Extract the piece of the nullspace corresponding to the aggregate, and
338  // put it in the flat array, "localQR" (in column major format) for the
339  // QR routine.
340  Teuchos::SerialDenseMatrix<LO,SC> localQR(aggSize, NSDim);
341  if (goodMap) {
342  for (size_t j = 0; j < NSDim; j++)
343  for (LO k = 0; k < aggSize; k++)
344  localQR(k,j) = fineNS[j][aggToRowMapLO[aggStart[agg]+k]];
345  } else {
346  for (size_t j = 0; j < NSDim; j++)
347  for (LO k = 0; k < aggSize; k++)
348  localQR(k,j) = fineNS[j][rowMap->getLocalElement(aggToRowMapGO[aggStart[agg]+k])];
349  }
350 
351  // Test for zero columns
352  for (size_t j = 0; j < NSDim; j++) {
353  bool bIsZeroNSColumn = true;
354 
355  for (LO k = 0; k < aggSize; k++)
356  if (localQR(k,j) != zero)
357  bIsZeroNSColumn = false;
358 
359  TEUCHOS_TEST_FOR_EXCEPTION(bIsZeroNSColumn == true, Exceptions::RuntimeError,
360  "MueLu::TentativePFactory::MakeTentative: fine level NS part has a zero column");
361  }
362 
363  // Calculate QR decomposition (standard)
364  // NOTE: Q is stored in localQR and R is stored in coarseNS
365  if (aggSize >= Teuchos::as<LO>(NSDim)) {
366 
367  if (NSDim == 1) {
368  // Only one nullspace vector, calculate Q and R by hand
369  Magnitude norm = STS::magnitude(zero);
370  for (size_t k = 0; k < Teuchos::as<size_t>(aggSize); k++)
371  norm += STS::magnitude(localQR(k,0)*localQR(k,0));
373 
374  // R = norm
375  coarseNS[0][offset] = norm;
376 
377  // Q = localQR(:,0)/norm
378  for (LO i = 0; i < aggSize; i++)
379  localQR(i,0) /= norm;
380 
381  } else {
383  qrSolver.setMatrix(Teuchos::rcp(&localQR, false));
384  qrSolver.factor();
385 
386  // R = upper triangular part of localQR
387  for (size_t j = 0; j < NSDim; j++)
388  for (size_t k = 0; k <= j; k++)
389  coarseNS[j][offset+k] = localQR(k,j); //TODO is offset+k the correct local ID?!
390 
391  // Calculate Q, the tentative prolongator.
392  // The Lapack GEQRF call only works for myAggsize >= NSDim
393  qrSolver.formQ();
395  for (size_t j = 0; j < NSDim; j++)
396  for (size_t i = 0; i < Teuchos::as<size_t>(aggSize); i++)
397  localQR(i,j) = (*qFactor)(i,j);
398  }
399 
400  } else {
401  // Special handling for aggSize < NSDim (i.e. single node aggregates in structural mechanics)
402 
403  // The local QR decomposition is not possible in the "overconstrained"
404  // case (i.e. number of columns in localQR > number of rows), which
405  // corresponds to #DOFs in Aggregate < NSDim. For usual problems this
406  // is only possible for single node aggregates in structural mechanics.
407  // (Similar problems may arise in discontinuous Galerkin problems...)
408  // We bypass the QR decomposition and use an identity block in the
409  // tentative prolongator for the single node aggregate and transfer the
410  // corresponding fine level null space information 1-to-1 to the coarse
411  // level null space part.
412 
413  // NOTE: The resulting tentative prolongation operator has
414  // (aggSize*DofsPerNode-NSDim) zero columns leading to a singular
415  // coarse level operator A. To deal with that one has the following
416  // options:
417  // - Use the "RepairMainDiagonal" flag in the RAPFactory (default:
418  // false) to add some identity block to the diagonal of the zero rows
419  // in the coarse level operator A, such that standard level smoothers
420  // can be used again.
421  // - Use special (projection-based) level smoothers, which can deal
422  // with singular matrices (very application specific)
423  // - Adapt the code below to avoid zero columns. However, we do not
424  // support a variable number of DOFs per node in MueLu/Xpetra which
425  // makes the implementation really hard.
426 
427  // R = extended (by adding identity rows) localQR
428  for (size_t j = 0; j < NSDim; j++)
429  for (size_t k = 0; k < NSDim; k++)
430  if (k < as<size_t>(aggSize))
431  coarseNS[j][offset+k] = localQR(k,j);
432  else
433  coarseNS[j][offset+k] = (k == j ? one : zero);
434 
435  // Q = I (rectangular)
436  for (size_t i = 0; i < as<size_t>(aggSize); i++)
437  for (size_t j = 0; j < NSDim; j++)
438  localQR(i,j) = (j == i ? one : zero);
439  }
440 
441 
442  // Process each row in the local Q factor
443  // FIXME: What happens if maps are blocked?
444  for (LO j = 0; j < aggSize; j++) {
445  LO localRow = (goodMap ? aggToRowMapLO[aggStart[agg]+j] : rowMap->getLocalElement(aggToRowMapGO[aggStart[agg]+j]));
446 
447  size_t rowStart = ia[localRow];
448  for (size_t k = 0, lnnz = 0; k < NSDim; k++) {
449  // Skip zeros (there may be plenty of them, i.e., NSDim > 1 or boundary conditions)
450  if (localQR(j,k) != zero) {
451  ja [rowStart+lnnz] = offset + k;
452  val[rowStart+lnnz] = localQR(j,k);
453  lnnz++;
454  }
455  }
456  }
457  }
458 
459  } else {
460  GetOStream(Runtime1) << "TentativePFactory : bypassing local QR phase" << std::endl;
461  if (NSDim>1)
462  GetOStream(Warnings0) << "TentativePFactor : for nontrivial nullspace, this may degrade performance" << std::endl;
464  // "no-QR" option //
466  // Local Q factor is just the fine nullspace support over the current aggregate.
467  // Local R factor is the identity.
468  // TODO I have not implemented any special handling for aggregates that are too
469  // TODO small to locally support the nullspace, as is done in the standard QR
470  // TODO case above.
471  if (goodMap) {
472  for (GO agg = 0; agg < numAggs; agg++) {
473  const LO aggSize = aggStart[agg+1] - aggStart[agg];
474  Xpetra::global_size_t offset = agg*NSDim;
475 
476  // Process each row in the local Q factor
477  // FIXME: What happens if maps are blocked?
478  for (LO j = 0; j < aggSize; j++) {
479 
480  //TODO Here I do not check for a zero nullspace column on the aggregate.
481  // as is done in the standard QR case.
482 
483  const LO localRow = aggToRowMapLO[aggStart[agg]+j];
484 
485  const size_t rowStart = ia[localRow];
486 
487  for (size_t k = 0, lnnz = 0; k < NSDim; k++) {
488  // Skip zeros (there may be plenty of them, i.e., NSDim > 1 or boundary conditions)
489  const SC qr_jk = fineNS[k][aggToRowMapLO[aggStart[agg]+j]];
490  if (qr_jk != zero) {
491  ja [rowStart+lnnz] = offset + k;
492  val[rowStart+lnnz] = qr_jk;
493  lnnz++;
494  }
495  }
496  }
497  for (size_t j = 0; j < NSDim; j++)
498  coarseNS[j][offset+j] = one;
499  } //for (GO agg = 0; agg < numAggs; agg++)
500 
501  } else {
502  for (GO agg = 0; agg < numAggs; agg++) {
503  const LO aggSize = aggStart[agg+1] - aggStart[agg];
504  Xpetra::global_size_t offset = agg*NSDim;
505  for (LO j = 0; j < aggSize; j++) {
506 
507  const LO localRow = rowMap->getLocalElement(aggToRowMapGO[aggStart[agg]+j]);
508 
509  const size_t rowStart = ia[localRow];
510 
511  for (size_t k = 0, lnnz = 0; k < NSDim; k++) {
512  // Skip zeros (there may be plenty of them, i.e., NSDim > 1 or boundary conditions)
513  const SC qr_jk = fineNS[k][rowMap->getLocalElement(aggToRowMapGO[aggStart[agg]+j])];
514  if (qr_jk != zero) {
515  ja [rowStart+lnnz] = offset + k;
516  val[rowStart+lnnz] = qr_jk;
517  lnnz++;
518  }
519  }
520  }
521  for (size_t j = 0; j < NSDim; j++)
522  coarseNS[j][offset+j] = one;
523  } //for (GO agg = 0; agg < numAggs; agg++)
524 
525  } //if (goodmap) else ...
526 
527  } //if doQRStep ... else
528 
529  // Compress storage (remove all INVALID, which happen when we skip zeros)
530  // We do that in-place
531  size_t ia_tmp = 0, nnz = 0;
532  for (size_t i = 0; i < numRows; i++) {
533  for (size_t j = ia_tmp; j < ia[i+1]; j++)
534  if (ja[j] != INVALID) {
535  ja [nnz] = ja [j];
536  val[nnz] = val[j];
537  nnz++;
538  }
539  ia_tmp = ia[i+1];
540  ia[i+1] = nnz;
541  }
542  if (rowMap->lib() == Xpetra::UseTpetra) {
543  // - Cannot resize for Epetra, as it checks for same pointers
544  // - Need to resize for Tpetra, as it check ().size() == ia[numRows]
545  // NOTE: these invalidate ja and val views
546  jaPtent .resize(nnz);
547  valPtent.resize(nnz);
548  }
549 
550  GetOStream(Runtime1) << "TentativePFactory : aggregates do not cross process boundaries" << std::endl;
551 
552  PtentCrs->setAllValues(iaPtent, jaPtent, valPtent);
553 
554 
555  // Managing labels & constants for ESFC
556  RCP<ParameterList> FCparams;
557  if(pL.isSublist("matrixmatrix: kernel params"))
558  FCparams=rcp(new ParameterList(pL.sublist("matrixmatrix: kernel params")));
559  else
560  FCparams= rcp(new ParameterList);
561  // By default, we don't need global constants for TentativeP
562  FCparams->set("compute global constants",FCparams->get("compute global constants",false));
563  std::string levelIDs = toString(levelID);
564  FCparams->set("Timer Label",std::string("MueLu::TentativeP-")+levelIDs);
565  RCP<const Export> dummy_e;
566  RCP<const Import> dummy_i;
567 
568  PtentCrs->expertStaticFillComplete(coarseMap, A->getDomainMap(),dummy_i,dummy_e,FCparams);
569  }
570 
571  template <class Scalar,class LocalOrdinal, class GlobalOrdinal, class Node>
574  RCP<const Map> coarseMap, RCP<Matrix>& Ptentative, RCP<MultiVector>& coarseNullspace) const {
575  typedef Teuchos::ScalarTraits<SC> STS;
576  typedef typename STS::magnitudeType Magnitude;
577  const SC zero = STS::zero();
578  const SC one = STS::one();
579 
580  // number of aggregates
581  GO numAggs = aggregates->GetNumAggregates();
582 
583  // Create a lookup table to determine the rows (fine DOFs) that belong to a given aggregate.
584  // aggStart is a pointer into aggToRowMap
585  // aggStart[i]..aggStart[i+1] are indices into aggToRowMap
586  // aggToRowMap[aggStart[i]]..aggToRowMap[aggStart[i+1]-1] are the DOFs in aggregate i
587  ArrayRCP<LO> aggStart;
588  ArrayRCP< GO > aggToRowMap;
589  amalgInfo->UnamalgamateAggregates(*aggregates, aggStart, aggToRowMap);
590 
591  // find size of the largest aggregate
592  LO maxAggSize=0;
593  for (GO i=0; i<numAggs; ++i) {
594  LO sizeOfThisAgg = aggStart[i+1] - aggStart[i];
595  if (sizeOfThisAgg > maxAggSize) maxAggSize = sizeOfThisAgg;
596  }
597 
598  // dimension of fine level nullspace
599  const size_t NSDim = fineNullspace->getNumVectors();
600 
601  // index base for coarse Dof map (usually 0)
602  GO indexBase=A->getRowMap()->getIndexBase();
603 
604  const RCP<const Map> nonUniqueMap = amalgInfo->ComputeUnamalgamatedImportDofMap(*aggregates);
605  const RCP<const Map> uniqueMap = A->getDomainMap();
606  RCP<const Import> importer = ImportFactory::Build(uniqueMap, nonUniqueMap);
607  RCP<MultiVector> fineNullspaceWithOverlap = MultiVectorFactory::Build(nonUniqueMap,NSDim);
608  fineNullspaceWithOverlap->doImport(*fineNullspace,*importer,Xpetra::INSERT);
609 
610  // Pull out the nullspace vectors so that we can have random access.
611  ArrayRCP< ArrayRCP<const SC> > fineNS(NSDim);
612  for (size_t i=0; i<NSDim; ++i)
613  fineNS[i] = fineNullspaceWithOverlap->getData(i);
614 
615  //Allocate storage for the coarse nullspace.
616  coarseNullspace = MultiVectorFactory::Build(coarseMap, NSDim);
617 
618  ArrayRCP< ArrayRCP<SC> > coarseNS(NSDim);
619  for (size_t i=0; i<NSDim; ++i)
620  if (coarseMap->getNodeNumElements() > 0) coarseNS[i] = coarseNullspace->getDataNonConst(i);
621 
622  //This makes the rowmap of Ptent the same as that of A->
623  //This requires moving some parts of some local Q's to other processors
624  //because aggregates can span processors.
625  RCP<const Map > rowMapForPtent = A->getRowMap();
626  const Map& rowMapForPtentRef = *rowMapForPtent;
627 
628  // Set up storage for the rows of the local Qs that belong to other processors.
629  // FIXME This is inefficient and could be done within the main loop below with std::vector's.
630  RCP<const Map> colMap = A->getColMap();
631 
632  RCP<const Map > ghostQMap;
633  RCP<MultiVector> ghostQvalues;
634  Array<RCP<Xpetra::Vector<GO,LO,GO,Node> > > ghostQcolumns;
635  RCP<Xpetra::Vector<GO,LO,GO,Node> > ghostQrowNums;
636  ArrayRCP< ArrayRCP<SC> > ghostQvals;
637  ArrayRCP< ArrayRCP<GO> > ghostQcols;
638  ArrayRCP< GO > ghostQrows;
639 
640  Array<GO> ghostGIDs;
641  for (LO j=0; j<numAggs; ++j) {
642  for (LO k=aggStart[j]; k<aggStart[j+1]; ++k) {
643  if (rowMapForPtentRef.isNodeGlobalElement(aggToRowMap[k]) == false) {
644  ghostGIDs.push_back(aggToRowMap[k]);
645  }
646  }
647  }
648  ghostQMap = MapFactory::Build(A->getRowMap()->lib(),
650  ghostGIDs,
651  indexBase, A->getRowMap()->getComm()); //JG:Xpetra::global_size_t>?
652  //Vector to hold bits of Q that go to other processors.
653  ghostQvalues = MultiVectorFactory::Build(ghostQMap,NSDim);
654  //Note that Epetra does not support MultiVectors templated on Scalar != double.
655  //So to work around this, we allocate an array of Vectors. This shouldn't be too
656  //expensive, as the number of Vectors is NSDim.
657  ghostQcolumns.resize(NSDim);
658  for (size_t i=0; i<NSDim; ++i)
659  ghostQcolumns[i] = Xpetra::VectorFactory<GO,LO,GO,Node>::Build(ghostQMap);
660  ghostQrowNums = Xpetra::VectorFactory<GO,LO,GO,Node>::Build(ghostQMap);
661  if (ghostQvalues->getLocalLength() > 0) {
662  ghostQvals.resize(NSDim);
663  ghostQcols.resize(NSDim);
664  for (size_t i=0; i<NSDim; ++i) {
665  ghostQvals[i] = ghostQvalues->getDataNonConst(i);
666  ghostQcols[i] = ghostQcolumns[i]->getDataNonConst(0);
667  }
668  ghostQrows = ghostQrowNums->getDataNonConst(0);
669  }
670 
671  //importer to handle moving Q
672  importer = ImportFactory::Build(ghostQMap, A->getRowMap());
673 
674  // Dense QR solver
676 
677  //Allocate temporary storage for the tentative prolongator.
678  Array<GO> globalColPtr(maxAggSize*NSDim,0);
679  Array<LO> localColPtr(maxAggSize*NSDim,0);
680  Array<SC> valPtr(maxAggSize*NSDim,0.);
681 
682  //Create column map for Ptent, estimate local #nonzeros in Ptent, and create Ptent itself.
683  const Map& coarseMapRef = *coarseMap;
684 
685  // For the 3-arrays constructor
686  ArrayRCP<size_t> ptent_rowptr;
687  ArrayRCP<LO> ptent_colind;
688  ArrayRCP<Scalar> ptent_values;
689 
690  // Because ArrayRCPs are slow...
691  ArrayView<size_t> rowptr_v;
692  ArrayView<LO> colind_v;
693  ArrayView<Scalar> values_v;
694 
695  // For temporary usage
696  Array<size_t> rowptr_temp;
697  Array<LO> colind_temp;
698  Array<Scalar> values_temp;
699 
700  RCP<CrsMatrix> PtentCrs;
701 
702  RCP<CrsMatrixWrap> PtentCrsWrap = rcp(new CrsMatrixWrap(rowMapForPtent, NSDim, Xpetra::StaticProfile));
703  PtentCrs = PtentCrsWrap->getCrsMatrix();
704  Ptentative = PtentCrsWrap;
705 
706  //*****************************************************************
707  //Loop over all aggregates and calculate local QR decompositions.
708  //*****************************************************************
709  GO qctr=0; //for indexing into Ptent data vectors
710  const Map& nonUniqueMapRef = *nonUniqueMap;
711 
712  size_t total_nnz_count=0;
713 
714  for (GO agg=0; agg<numAggs; ++agg)
715  {
716  LO myAggSize = aggStart[agg+1]-aggStart[agg];
717  // For each aggregate, extract the corresponding piece of the nullspace and put it in the flat array,
718  // "localQR" (in column major format) for the QR routine.
719  Teuchos::SerialDenseMatrix<LO,SC> localQR(myAggSize, NSDim);
720  for (size_t j=0; j<NSDim; ++j) {
721  bool bIsZeroNSColumn = true;
722  for (LO k=0; k<myAggSize; ++k)
723  {
724  // aggToRowMap[aggPtr[i]+k] is the kth DOF in the ith aggregate
725  // fineNS[j][n] is the nth entry in the jth NS vector
726  try{
727  SC nsVal = fineNS[j][ nonUniqueMapRef.getLocalElement(aggToRowMap[aggStart[agg]+k]) ]; // extract information from fine level NS
728  localQR(k,j) = nsVal;
729  if (nsVal != zero) bIsZeroNSColumn = false;
730  }
731  catch(...) {
732  GetOStream(Runtime1,-1) << "length of fine level nsp: " << fineNullspace->getGlobalLength() << std::endl;
733  GetOStream(Runtime1,-1) << "length of fine level nsp w overlap: " << fineNullspaceWithOverlap->getGlobalLength() << std::endl;
734  GetOStream(Runtime1,-1) << "(local?) aggId=" << agg << std::endl;
735  GetOStream(Runtime1,-1) << "aggSize=" << myAggSize << std::endl;
736  GetOStream(Runtime1,-1) << "agg DOF=" << k << std::endl;
737  GetOStream(Runtime1,-1) << "NS vector j=" << j << std::endl;
738  GetOStream(Runtime1,-1) << "j*myAggSize + k = " << j*myAggSize + k << std::endl;
739  GetOStream(Runtime1,-1) << "aggToRowMap["<<agg<<"][" << k << "] = " << aggToRowMap[aggStart[agg]+k] << std::endl;
740  GetOStream(Runtime1,-1) << "id aggToRowMap[agg][k]=" << aggToRowMap[aggStart[agg]+k] << " is global element in nonUniqueMap = " <<
741  nonUniqueMapRef.isNodeGlobalElement(aggToRowMap[aggStart[agg]+k]) << std::endl;
742  GetOStream(Runtime1,-1) << "colMap local id aggToRowMap[agg][k]=" << nonUniqueMapRef.getLocalElement(aggToRowMap[aggStart[agg]+k]) << std::endl;
743  GetOStream(Runtime1,-1) << "fineNS...=" << fineNS[j][ nonUniqueMapRef.getLocalElement(aggToRowMap[aggStart[agg]+k]) ] << std::endl;
744  GetOStream(Errors,-1) << "caught an error!" << std::endl;
745  }
746  } //for (LO k=0 ...
747  TEUCHOS_TEST_FOR_EXCEPTION(bIsZeroNSColumn == true, Exceptions::RuntimeError, "MueLu::TentativePFactory::MakeTentative: fine level NS part has a zero column. Error.");
748  } //for (LO j=0 ...
749 
750  Xpetra::global_size_t offset=agg*NSDim;
751 
752  if(myAggSize >= Teuchos::as<LocalOrdinal>(NSDim)) {
753  // calculate QR decomposition (standard)
754  // R is stored in localQR (size: myAggSize x NSDim)
755 
756  // Householder multiplier
757  SC tau = localQR(0,0);
758 
759  if (NSDim == 1) {
760  // Only one nullspace vector, so normalize by hand
761  Magnitude dtemp=0;
762  for (size_t k = 0; k < Teuchos::as<size_t>(myAggSize); ++k) {
763  Magnitude tmag = STS::magnitude(localQR(k,0));
764  dtemp += tmag*tmag;
765  }
767  tau = localQR(0,0);
768  localQR(0,0) = dtemp;
769  } else {
770  qrSolver.setMatrix( Teuchos::rcp(&localQR, false) );
771  qrSolver.factor();
772  }
773 
774  // Extract R, the coarse nullspace. This is stored in upper triangular part of localQR.
775  // Note: coarseNS[i][.] is the ith coarse nullspace vector, which may be counter to your intuition.
776  // This stores the (offset+k)th entry only if it is local according to the coarseMap.
777  for (size_t j=0; j<NSDim; ++j) {
778  for (size_t k=0; k<=j; ++k) {
779  try {
780  if (coarseMapRef.isNodeLocalElement(offset+k)) {
781  coarseNS[j][offset+k] = localQR(k, j); //TODO is offset+k the correct local ID?!
782  }
783  }
784  catch(...) {
785  GetOStream(Errors,-1) << "caught error in coarseNS insert, j="<<j<<", offset+k = "<<offset+k<<std::endl;
786  }
787  }
788  }
789 
790  // Calculate Q, the tentative prolongator.
791  // The Lapack GEQRF call only works for myAggsize >= NSDim
792 
793  if (NSDim == 1) {
794  // Only one nullspace vector, so calculate Q by hand
795  Magnitude dtemp = Teuchos::ScalarTraits<SC>::magnitude(localQR(0,0));
796  localQR(0,0) = tau;
797  dtemp = 1 / dtemp;
798  for (LocalOrdinal i=0; i<myAggSize; ++i) {
799  localQR(i,0) *= dtemp ;
800  }
801  } else {
802  qrSolver.formQ();
803  Teuchos::RCP<Teuchos::SerialDenseMatrix<LO,SC> > qFactor = qrSolver.getQ();
804  for (size_t j=0; j<NSDim; j++) {
805  for (size_t i = 0; i < Teuchos::as<size_t>(myAggSize); i++) {
806  localQR(i,j) = (*qFactor)(i,j);
807  }
808  }
809  }
810 
811  // end default case (myAggSize >= NSDim)
812  } else { // special handling for myAggSize < NSDim (i.e. 1pt nodes)
813  // See comments for the uncoupled case
814 
815  // R = extended (by adding identity rows) localQR
816  for (size_t j = 0; j < NSDim; j++)
817  for (size_t k = 0; k < NSDim; k++) {
818  TEUCHOS_TEST_FOR_EXCEPTION(!coarseMapRef.isNodeLocalElement(offset+k), Exceptions::RuntimeError,
819  "Caught error in coarseNS insert, j=" << j << ", offset+k = " << offset+k);
820 
821  if (k < as<size_t>(myAggSize))
822  coarseNS[j][offset+k] = localQR(k,j);
823  else
824  coarseNS[j][offset+k] = (k == j ? one : zero);
825  }
826 
827  // Q = I (rectangular)
828  for (size_t i = 0; i < as<size_t>(myAggSize); i++)
829  for (size_t j = 0; j < NSDim; j++)
830  localQR(i,j) = (j == i ? one : zero);
831  } // end else (special handling for 1pt aggregates)
832 
833  //Process each row in the local Q factor. If the row is local to the current processor
834  //according to the rowmap, insert it into Ptentative. Otherwise, save it in ghostQ
835  //to be communicated later to the owning processor.
836  //FIXME -- what happens if maps are blocked?
837  for (GO j=0; j<myAggSize; ++j) {
838  //This loop checks whether row associated with current DOF is local, according to rowMapForPtent.
839  //If it is, the row is inserted. If not, the row number, columns, and values are saved in
840  //MultiVectors that will be sent to other processors.
841  GO globalRow = aggToRowMap[aggStart[agg]+j];
842 
843  //TODO is the use of Xpetra::global_size_t below correct?
844  if (rowMapForPtentRef.isNodeGlobalElement(globalRow) == false ) {
845  ghostQrows[qctr] = globalRow;
846  for (size_t k=0; k<NSDim; ++k) {
847  ghostQcols[k][qctr] = coarseMapRef.getGlobalElement(agg*NSDim+k);
848  ghostQvals[k][qctr] = localQR(j,k);
849  }
850  ++qctr;
851  } else {
852  size_t nnz=0;
853  for (size_t k=0; k<NSDim; ++k) {
854  try{
855  if (localQR(j,k) != Teuchos::ScalarTraits<SC>::zero()) {
856  localColPtr[nnz] = agg * NSDim + k;
857  globalColPtr[nnz] = coarseMapRef.getGlobalElement(localColPtr[nnz]);
858  valPtr[nnz] = localQR(j,k);
859  ++total_nnz_count;
860  ++nnz;
861  }
862  }
863  catch(...) {
864  GetOStream(Errors,-1) << "caught error in colPtr/valPtr insert, current index="<<nnz<<std::endl;
865  }
866  } //for (size_t k=0; k<NSDim; ++k)
867 
868  try{
869  Ptentative->insertGlobalValues(globalRow,globalColPtr.view(0,nnz),valPtr.view(0,nnz));
870  }
871  catch(...) {
872  GetOStream(Errors,-1) << "pid " << A->getRowMap()->getComm()->getRank()
873  << "caught error during Ptent row insertion, global row "
874  << globalRow << std::endl;
875  }
876  }
877  } //for (GO j=0; j<myAggSize; ++j)
878 
879  } // for (LO agg=0; agg<numAggs; ++agg)
880 
881 
882  // ***********************************************************
883  // ************* end of aggregate-wise QR ********************
884  // ***********************************************************
885  GetOStream(Runtime1) << "TentativePFactory : aggregates may cross process boundaries" << std::endl;
886  // Import ghost parts of Q factors and insert into Ptentative.
887  // First import just the global row numbers.
889  targetQrowNums->putScalar(-1);
890  targetQrowNums->doImport(*ghostQrowNums,*importer,Xpetra::INSERT);
891  ArrayRCP< GO > targetQrows = targetQrowNums->getDataNonConst(0);
892 
893  // Now create map based on just the row numbers imported.
894  Array<GO> gidsToImport;
895  gidsToImport.reserve(targetQrows.size());
896  for (typename ArrayRCP<GO>::iterator r=targetQrows.begin(); r!=targetQrows.end(); ++r) {
897  if (*r > -1) {
898  gidsToImport.push_back(*r);
899  }
900  }
901  RCP<const Map > reducedMap = MapFactory::Build( A->getRowMap()->lib(),
903  gidsToImport, indexBase, A->getRowMap()->getComm() );
904 
905  // Import using the row numbers that this processor will receive.
906  importer = ImportFactory::Build(ghostQMap, reducedMap);
907 
908  Array<RCP<Xpetra::Vector<GO,LO,GO,Node> > > targetQcolumns(NSDim);
909  for (size_t i=0; i<NSDim; ++i) {
910  targetQcolumns[i] = Xpetra::VectorFactory<GO,LO,GO,Node>::Build(reducedMap);
911  targetQcolumns[i]->doImport(*(ghostQcolumns[i]),*importer,Xpetra::INSERT);
912  }
913  RCP<MultiVector> targetQvalues = MultiVectorFactory::Build(reducedMap,NSDim);
914  targetQvalues->doImport(*ghostQvalues,*importer,Xpetra::INSERT);
915 
916  ArrayRCP< ArrayRCP<SC> > targetQvals;
917  ArrayRCP<ArrayRCP<GO> > targetQcols;
918  if (targetQvalues->getLocalLength() > 0) {
919  targetQvals.resize(NSDim);
920  targetQcols.resize(NSDim);
921  for (size_t i=0; i<NSDim; ++i) {
922  targetQvals[i] = targetQvalues->getDataNonConst(i);
923  targetQcols[i] = targetQcolumns[i]->getDataNonConst(0);
924  }
925  }
926 
927  valPtr = Array<SC>(NSDim,0.);
928  globalColPtr = Array<GO>(NSDim,0);
929  for (typename Array<GO>::iterator r=gidsToImport.begin(); r!=gidsToImport.end(); ++r) {
930  if (targetQvalues->getLocalLength() > 0) {
931  for (size_t j=0; j<NSDim; ++j) {
932  valPtr[j] = targetQvals[j][reducedMap->getLocalElement(*r)];
933  globalColPtr[j] = targetQcols[j][reducedMap->getLocalElement(*r)];
934  }
935  Ptentative->insertGlobalValues(*r, globalColPtr.view(0,NSDim), valPtr.view(0,NSDim));
936  } //if (targetQvalues->getLocalLength() > 0)
937  }
938 
939  Ptentative->fillComplete(coarseMap, A->getDomainMap());
940  }
941 
942  template <class Scalar,class LocalOrdinal, class GlobalOrdinal, class Node>
943  bool TentativePFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::isGoodMap(const Map& rowMap, const Map& colMap) const {
944  ArrayView<const GO> rowElements = rowMap.getNodeElementList();
945  ArrayView<const GO> colElements = colMap.getNodeElementList();
946 
947  const size_t numElements = rowElements.size();
948 
949  bool goodMap = true;
950  for (size_t i = 0; i < numElements; i++)
951  if (rowElements[i] != colElements[i]) {
952  goodMap = false;
953  break;
954  }
955 
956  return goodMap;
957  }
958 
959 } //namespace MueLu
960 
961 // TODO ReUse: If only P or Nullspace is missing, TentativePFactory can be smart and skip part of the computation.
962 
963 #define MUELU_TENTATIVEPFACTORY_SHORT
964 #endif // MUELU_TENTATIVEPFACTORY_DEF_HPP
void BuildPuncoupled(RCP< Matrix > A, RCP< Aggregates > aggregates, RCP< AmalgamationInfo > amalgInfo, RCP< MultiVector > fineNullspace, RCP< const Map > coarseMap, RCP< Matrix > &Ptentative, RCP< MultiVector > &coarseNullspace, const int levelID) const
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
Important warning messages (one line)
void reserve(size_type n)
int setMatrix(const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &A)
void BuildPcoupled(RCP< Matrix > A, RCP< Aggregates > aggregates, RCP< AmalgamationInfo > amalgInfo, RCP< MultiVector > fineNullspace, RCP< const Map > coarseMap, RCP< Matrix > &Ptentative, RCP< MultiVector > &coarseNullspace) const
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
GlobalOrdinal GO
T & get(const std::string &name, T def_value)
void UnamalgamateAggregates(const Aggregates &aggregates, Teuchos::ArrayRCP< LocalOrdinal > &aggStart, Teuchos::ArrayRCP< GlobalOrdinal > &aggToRowMap) const
UnamalgamateAggregates.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
ArrayView< T > view(size_type offset, size_type size)
static T squareroot(T x)
Timer to be used in factories. Similar to Monitor but with additional timers.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
size_type size() const
void UnamalgamateAggregatesLO(const Aggregates &aggregates, Teuchos::ArrayRCP< LocalOrdinal > &aggStart, Teuchos::ArrayRCP< LO > &aggToRowMap) const
LocalOrdinal LO
size_type size() const
static const NoFactory * get()
Print even more statistics.
#define SET_VALID_ENTRY(name)
void resize(const size_type n, const T &val=T())
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:99
Teuchos::RCP< Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > ComputeUnamalgamatedImportDofMap(const Aggregates &aggregates) const
ComputeUnamalgamatedImportDofMap build overlapping dof row map from aggregates needed for overlapping...
bool isSublist(const std::string &name) const
LO GetNumAggregates() const
returns the number of aggregates of the current processor. Note: could/should be renamed to GetNumLoc...
void resize(size_type new_size, const value_type &x=value_type())
static std::string PrintMatrixInfo(const Matrix &A, const std::string &msgTag, RCP< const Teuchos::ParameterList > params=Teuchos::null)
size_t global_size_t
static bool isnaninf(const T &x)
static RCP< Vector > Build(const Teuchos::RCP< const Map > &map, bool zeroOut=true)
bool isGoodMap(const Map &rowMap, const Map &colMap) const
iterator end()
static magnitudeType magnitude(T a)
void push_back(const value_type &x)
Scalar SC
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
int GetLevelID() const
Return level number.
Definition: MueLu_Level.cpp:76
RCP< SerialDenseMatrix< OrdinalType, ScalarType > > getQ() const
Exception throws to report errors in the internal logical of the program.
iterator end() const
void BuildP(Level &fineLevel, Level &coarseLevel) const
Abstract Build method.
Description of what is happening (more verbose)
iterator begin()
iterator begin() const
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need&#39;s value has been saved.