MueLu
Version of the Day
Toggle main menu visibility
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
18
#include "
MueLu_InitialBlockNumberFactory_decl.hpp
"
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>
27
RCP<const ParameterList>
InitialBlockNumberFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::GetValidParameterList
()
const
{
28
RCP<ParameterList> validParamList = rcp(
new
ParameterList());
29
30
#define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
31
SET_VALID_ENTRY
(
"aggregation: block diagonal: interleaved blocksize"
);
32
#undef SET_VALID_ENTRY
33
34
validParamList->set<RCP<const FactoryBase>>(
"A"
, Teuchos::null,
"Generating factory of the matrix A"
);
35
validParamList->set<RCP<const FactoryBase>>(
"BlockNumber"
, Teuchos::null,
"Generating factory of the BlockNumber vector"
);
36
37
return
validParamList;
38
}
39
40
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
41
void
InitialBlockNumberFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::DeclareInput
(
Level
& currentLevel)
const
{
42
Input
(currentLevel,
"A"
);
43
44
if
(currentLevel.
GetLevelID
() == 0 && currentLevel.
IsAvailable
(
"BlockNumber"
,
NoFactory::get
()))
45
Input
(currentLevel,
"BlockNumber"
);
46
}
47
48
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
49
void
InitialBlockNumberFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build
(
Level
& currentLevel)
const
{
50
FactoryMonitor
m(*
this
,
"Build"
, currentLevel);
51
const
ParameterList& pL =
GetParameterList
();
52
53
RCP<LocalOrdinalVector> BlockNumber;
54
55
if
(currentLevel.
IsAvailable
(
"BlockNumber"
,
NoFactory::get
())) {
56
// Set already provided BlockNumber
57
BlockNumber =
Get<RCP<LocalOrdinalVector>
>(currentLevel,
"BlockNumber"
);
58
GetOStream
(
Statistics1
) <<
"Use user-given blocknumber with length="
<< BlockNumber->getGlobalLength() << std::endl;
59
}
else
{
60
// Creating interleaved BlockNumber from scratch
61
RCP<Matrix> A =
Get<RCP<Matrix>
>(currentLevel,
"A"
);
62
LO blocksize = as<LO>(pL.get<
int
>(
"aggregation: block diagonal: interleaved blocksize"
));
63
64
GetOStream
(
Statistics1
) <<
"Generating new interleaved blocking with "
<< blocksize <<
" equations"
<< std::endl;
65
BlockNumber = LocalOrdinalVectorFactory::Build(A->getRowMap(),
false
);
66
Teuchos::ArrayRCP<LO> bn_data = BlockNumber->getDataNonConst(0);
67
for
(LO i = 0; i < (LO)A->getRowMap()->getLocalNumElements(); i++)
68
bn_data[i] = i % blocksize;
69
}
70
71
Set
(currentLevel,
"BlockNumber"
, BlockNumber);
72
}
73
74
}
// namespace MueLu
75
76
#endif
// MUELU_INITIALBLOCKNUMBER_FACTORY_DEF_HPP
SET_VALID_ENTRY
#define SET_VALID_ENTRY(name)
MueLu_InitialBlockNumberFactory_decl.hpp
MueLu_Level.hpp
MueLu_MasterList.hpp
MueLu_Monitor.hpp
MueLu::Factory::Input
void Input(Level &level, const std::string &varName) const
Definition
MueLu_Factory.cpp:72
MueLu::Factory::Get
T Get(Level &level, const std::string &varName) const
Definition
MueLu_Factory.hpp:69
MueLu::Factory::Set
void Set(Level &level, const std::string &varName, const T &data) const
Definition
MueLu_Factory.hpp:80
MueLu::FactoryMonitor
Timer to be used in factories. Similar to Monitor but with additional timers.
Definition
MueLu_Monitor.hpp:165
MueLu::InitialBlockNumberFactory::Build
void Build(Level ¤tLevel) const
Build an object with this factory.
Definition
MueLu_InitialBlockNumberFactory_def.hpp:49
MueLu::InitialBlockNumberFactory::DeclareInput
void DeclareInput(Level ¤tLevel) const
Specifies the data that this class needs, and the factories that generate that data.
Definition
MueLu_InitialBlockNumberFactory_def.hpp:41
MueLu::InitialBlockNumberFactory::GetValidParameterList
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
Definition
MueLu_InitialBlockNumberFactory_def.hpp:27
MueLu::Level
Class that holds all level-specific information.
Definition
MueLu_Level.hpp:63
MueLu::Level::IsAvailable
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.
Definition
MueLu_Level.cpp:281
MueLu::Level::GetLevelID
int GetLevelID() const
Return level number.
Definition
MueLu_Level.cpp:51
MueLu::NoFactory::get
static const NoFactory * get()
Definition
MueLu_NoFactory.cpp:34
MueLu::ParameterListAcceptorImpl::GetParameterList
virtual const Teuchos::ParameterList & GetParameterList() const
Definition
MueLu_ParameterListAcceptor.cpp:50
MueLu::VerboseObject::GetOStream
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
Definition
MueLu_VerboseObject.cpp:72
MueLu
Namespace for MueLu classes and methods.
Definition
MueLu_BrickAggregationFactory_decl.hpp:42
MueLu::Statistics1
@ Statistics1
Print more statistics.
Definition
MueLu_VerbosityLevel.hpp:34
src
Misc
MueLu_InitialBlockNumberFactory_def.hpp
Generated by
1.17.0