MueLu
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
MueLu_TwoLevelFactoryBase.cpp
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
#include "
MueLu_TwoLevelFactoryBase.hpp
"
11
12
namespace
MueLu
{
13
14
TwoLevelFactoryBase::TwoLevelFactoryBase
() =
default
;
15
17
TwoLevelFactoryBase::~TwoLevelFactoryBase
() =
default
;
18
19
void
TwoLevelFactoryBase::CallDeclareInput
(
Level
& requestedLevel)
const
{
20
if
(requestedLevel.
GetPreviousLevel
() == Teuchos::null) {
21
std::ostringstream errStr;
22
errStr <<
"LevelID = "
<< requestedLevel.
GetLevelID
();
23
throw
Exceptions::DependencyError
(errStr.str());
24
}
25
DeclareInput
(*requestedLevel.
GetPreviousLevel
(), requestedLevel);
26
}
27
28
void
TwoLevelFactoryBase::CallBuild
(
Level
& requestedLevel)
const
{
29
int
levelID = requestedLevel.
GetLevelID
();
30
31
#ifdef HAVE_MUELU_DEBUG
32
// We cannot call Build method twice for the same level, but we can call it multiple times for different levels
33
TEUCHOS_TEST_FOR_EXCEPTION((multipleCallCheck_ == ENABLED) && (multipleCallCheckGlobal_ == ENABLED) && (lastLevelID_ == levelID),
34
Exceptions::RuntimeError
,
35
this->
ShortClassName
() <<
"::Build() called twice for the same level (levelID="
<< levelID
36
<<
"). This is likely due to a configuration error, or calling hierarchy setup multiple times "
37
<<
"without resetting debug info through FactoryManager::ResetDebugData()."
);
38
if
(multipleCallCheck_ == FIRSTCALL)
39
multipleCallCheck_ = ENABLED;
40
41
lastLevelID_ = levelID;
42
#endif
43
TEUCHOS_TEST_FOR_EXCEPTION(requestedLevel.
GetPreviousLevel
() == Teuchos::null,
Exceptions::RuntimeError
,
"LevelID = "
<< levelID);
44
45
RCP<const Teuchos::Comm<int> > comm = requestedLevel.
GetComm
();
46
if
(comm.is_null()) {
47
// Some factories are called before we constructed Ac, and therefore,
48
// before we set the level communicator. For such factories we can get
49
// the comm from the previous level, as all processes go there
50
RCP<Level>& prevLevel = requestedLevel.
GetPreviousLevel
();
51
if
(!prevLevel.is_null())
52
comm = prevLevel->GetComm();
53
}
54
55
int
oldRank = -1;
56
if
(!comm.is_null())
57
oldRank =
SetProcRankVerbose
(comm->getRank());
58
59
// Synchronization timer
60
std::string syncTimer = this->
ShortClassName
() +
": Build sync (level="
+
toString
(requestedLevel.
GetLevelID
()) +
")"
;
61
if
(this->
timerSync_
&& !comm.is_null()) {
62
TimeMonitor
timer(*
this
, syncTimer);
63
comm->barrier();
64
}
65
66
Build
(*requestedLevel.
GetPreviousLevel
(), requestedLevel);
67
68
if
(this->
timerSync_
&& !comm.is_null()) {
69
TimeMonitor
timer(*
this
, syncTimer);
70
comm->barrier();
71
}
72
73
if
(
IsPrint
(
Test1
))
74
GetOStream
(
Test1
) << *
RemoveFactoriesFromList
(
GetParameterList
()) << std::endl;
75
else
76
RemoveFactoriesFromList
(
GetParameterList
())->print(
GetOStream
(
Test0
), Teuchos::ParameterList::PrintOptions().indent(0).showFlags(
true
).showDefault(
false
));
77
78
if
(oldRank != -1)
79
SetProcRankVerbose
(oldRank);
80
}
81
82
}
// namespace MueLu
MueLu_TwoLevelFactoryBase.hpp
MueLu::Describable::ShortClassName
virtual std::string ShortClassName() const
Return the class name of the object, without template parameters and without namespace.
Definition
MueLu_Describable.cpp:38
MueLu::Exceptions::DependencyError
Exception throws to report data dependency problems between factories.
Definition
MueLu_Exceptions.hpp:57
MueLu::Exceptions::RuntimeError
Exception throws to report errors in the internal logical of the program.
Definition
MueLu_Exceptions.hpp:36
MueLu::Factory::timerSync_
static bool timerSync_
Definition
MueLu_Factory.hpp:96
MueLu::Factory::RemoveFactoriesFromList
RCP< ParameterList > RemoveFactoriesFromList(const ParameterList &list) const
Definition
MueLu_Factory.cpp:47
MueLu::Level
Class that holds all level-specific information.
Definition
MueLu_Level.hpp:63
MueLu::Level::GetPreviousLevel
RCP< Level > & GetPreviousLevel()
Previous level.
Definition
MueLu_Level.cpp:60
MueLu::Level::GetComm
RCP< const Teuchos::Comm< int > > GetComm() const
Definition
MueLu_Level.hpp:330
MueLu::Level::GetLevelID
int GetLevelID() const
Return level number.
Definition
MueLu_Level.cpp:51
MueLu::ParameterListAcceptorImpl::GetParameterList
virtual const Teuchos::ParameterList & GetParameterList() const
Definition
MueLu_ParameterListAcceptor.cpp:50
MueLu::TimeMonitor
Integrates Teuchos::TimeMonitor with MueLu verbosity system.
Definition
MueLu_TimeMonitor.hpp:31
MueLu::TwoLevelFactoryBase::CallDeclareInput
virtual void CallDeclareInput(Level &requestedLevel) const
Definition
MueLu_TwoLevelFactoryBase.cpp:19
MueLu::TwoLevelFactoryBase::CallBuild
virtual void CallBuild(Level &requestedLevel) const
Definition
MueLu_TwoLevelFactoryBase.cpp:28
MueLu::TwoLevelFactoryBase::Build
virtual void Build(Level &fineLevel, Level &coarseLevel) const =0
Build an object with this factory.
MueLu::TwoLevelFactoryBase::TwoLevelFactoryBase
TwoLevelFactoryBase()
Constructor.
MueLu::TwoLevelFactoryBase::DeclareInput
virtual void DeclareInput(Level &fineLevel, Level &coarseLevel) const =0
Input.
MueLu::TwoLevelFactoryBase::~TwoLevelFactoryBase
virtual ~TwoLevelFactoryBase()
Destructor.
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::VerboseObject::SetProcRankVerbose
int SetProcRankVerbose(int procRank) const
Set proc rank used for printing.
Definition
MueLu_VerboseObject.cpp:62
MueLu::VerboseObject::IsPrint
bool IsPrint(MsgType type, int thisProcRankOnly=-1) const
Find out whether we need to print out information for a specific message type.
Definition
MueLu_VerboseObject.cpp:68
MueLu
Namespace for MueLu classes and methods.
Definition
MueLu_BrickAggregationFactory_decl.hpp:42
MueLu::Test0
@ Test0
Print factory calls.
Definition
MueLu_VerbosityLevel.hpp:47
MueLu::Test1
@ Test1
Print used parameters.
Definition
MueLu_VerbosityLevel.hpp:48
MueLu::toString
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
Definition
MueLu_Utilities_decl.hpp:242
src
MueCentral
MueLu_TwoLevelFactoryBase.cpp
Generated by
1.17.0