MueLu Version of the Day
Loading...
Searching...
No Matches
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
24namespace MueLu {
25
26template <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
38template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
42
43template <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
#define SET_VALID_ENTRY(name)
Timer to be used in factories. Similar to Monitor but with additional timers.
void Input(Level &level, const std::string &varName) const
T Get(Level &level, const std::string &varName) const
void Set(Level &level, const std::string &varName, const T &data) const
void Build(Level &currentLevel) const
Build an object with this factory.
void DeclareInput(Level &currentLevel) const
Specifies the data that this class needs, and the factories that generate that data.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
Class that holds all level-specific information.
virtual const Teuchos::ParameterList & GetParameterList() const
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
Namespace for MueLu classes and methods.
@ Statistics1
Print more statistics.