MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_InitialBlockNumberFactory_def.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // MueLu: A package for multigrid based preconditioning
4 //
5 // Copyright 2012 NTESS and the MueLu contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef MUELU_INITIALBLOCKNUMBER_FACTORY_DEF_HPP
11 #define MUELU_INITIALBLOCKNUMBER_FACTORY_DEF_HPP
12 
13 #include "Xpetra_VectorFactory.hpp"
14 #include "Xpetra_Map.hpp"
15 #include "Xpetra_Matrix.hpp"
16 #include "Xpetra_IO.hpp"
17 
19 
20 #include "MueLu_MasterList.hpp"
21 #include "MueLu_Level.hpp"
22 #include "MueLu_Monitor.hpp"
23 
24 namespace MueLu {
25 
26 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
28  RCP<ParameterList> validParamList = rcp(new ParameterList());
29 #define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
30  SET_VALID_ENTRY("aggregation: block diagonal: interleaved blocksize");
31 #undef SET_VALID_ENTRY
32 
33  validParamList->set<RCP<const FactoryBase> >("A", Teuchos::null, "Generating factory of the matrix A");
34 
35  return validParamList;
36 }
37 
38 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
40  Input(currentLevel, "A");
41 }
42 
43 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
45  FactoryMonitor m(*this, "Build", currentLevel);
46  const ParameterList& pL = GetParameterList();
47 
48  RCP<Matrix> A = Get<RCP<Matrix> >(currentLevel, "A");
49  LO blocksize = as<LO>(pL.get<int>("aggregation: block diagonal: interleaved blocksize"));
50 
51  GetOStream(Statistics1) << "Generating interleaved blocking with " << blocksize << " equations" << std::endl;
52  RCP<LocalOrdinalVector> BlockNumber = LocalOrdinalVectorFactory::Build(A->getRowMap(), false);
53  Teuchos::ArrayRCP<LO> bn_data = BlockNumber->getDataNonConst(0);
54  for (LO i = 0; i < (LO)A->getRowMap()->getLocalNumElements(); i++)
55  bn_data[i] = i % blocksize;
56 
57  Set(currentLevel, "BlockNumber", BlockNumber);
58 }
59 
60 } // namespace MueLu
61 
62 #endif // MUELU_INITIALBLOCKNUMBER_FACTORY_DEF_HPP
void DeclareInput(Level &currentLevel) const
Specifies the data that this class needs, and the factories that generate that data.
#define SET_VALID_ENTRY(name)
T & get(const std::string &name, T def_value)
void Build(Level &currentLevel) const
Build an object with this factory.
Timer to be used in factories. Similar to Monitor but with additional timers.
Print more statistics.
LocalOrdinal LO
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:63
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.