MueLu
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
MueLu_GenericRFactory_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_GENERICRFACTORY_DEF_HPP
11
#define MUELU_GENERICRFACTORY_DEF_HPP
12
13
#include <Xpetra_Matrix.hpp>
14
15
#include "
MueLu_GenericRFactory_decl.hpp
"
16
17
#include "
MueLu_FactoryBase.hpp
"
18
#include "MueLu_PFactory.hpp"
19
#include "
MueLu_FactoryManagerBase.hpp
"
20
#include "
MueLu_DisableMultipleCallCheck.hpp
"
21
#include "
MueLu_Monitor.hpp
"
22
23
namespace
MueLu
{
24
25
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
26
RCP<const ParameterList>
GenericRFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::GetValidParameterList
()
const
{
27
RCP<ParameterList> validParamList = rcp(
new
ParameterList());
28
validParamList->set<RCP<const FactoryBase> >(
"P"
, Teuchos::null,
"Generating factory of the matrix P"
);
29
return
validParamList;
30
}
31
32
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
33
void
GenericRFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::DeclareInput
(
Level
&
/* fineLevel */
,
Level
&coarseLevel)
const
{
34
RCP<const FactoryBase> PFact1 =
GetFactory
(
"P"
);
35
if
(PFact1 == Teuchos::null) {
36
PFact1 = coarseLevel.
GetFactoryManager
()->GetFactory(
"P"
);
37
}
38
RCP<PFactory> PFact = Teuchos::rcp_const_cast<PFactory>(rcp_dynamic_cast<const PFactory>(PFact1));
39
;
40
41
bool
rmode = PFact->isRestrictionModeSet();
42
PFact->setRestrictionMode(
true
);
// set restriction mode
43
44
// Force request call for PFact
45
// In general, Request is only called once for each factory, since we
46
// can reuse data generated by the factory. However, here we have to
47
// run the code in PFact.Build again, so we have to request the
48
// dependencies of PFact first! Thedependencies are (automatically)
49
// cleaned up after the second run of PFact.Build in
50
// coarseLevel.Get<RCP<Matrix> >("R",PFact.get())!
51
coarseLevel.
DeclareDependencies
(PFact.get());
52
53
coarseLevel.
DeclareInput
(
"R"
, PFact.get(),
this
);
// we expect the prolongation operator factory to produce "R" as output
54
// call declareInput is called within DeclareInput call
55
PFact->setRestrictionMode(rmode);
// reset restriciton mode flag
56
}
57
58
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
59
void
GenericRFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build
(
Level
&
/* fineLevel */
,
Level
&coarseLevel)
const
{
60
FactoryMonitor
m(*
this
,
"Call prolongator factory for calculating restrictor"
, coarseLevel);
61
62
RCP<const FactoryBase> PFact1 =
GetFactory
(
"P"
);
63
if
(PFact1 == Teuchos::null) {
64
PFact1 = coarseLevel.
GetFactoryManager
()->GetFactory(
"P"
);
65
}
66
RCP<PFactory> PFact = Teuchos::rcp_const_cast<PFactory>(rcp_dynamic_cast<const PFactory>(PFact1));
67
;
68
MueLu::DisableMultipleCallCheck
check(PFact);
69
70
// BuildR
71
bool
rmode = PFact->isRestrictionModeSet();
72
PFact->setRestrictionMode(
true
);
// switch prolongator factory to restriction mode
73
74
// PFact->Build(fineLevel, coarseLevel); // call PFactory::Build explicitely
75
RCP<Matrix> R = coarseLevel.
Get
<RCP<Matrix> >(
"R"
, PFact.get());
76
77
PFact->setRestrictionMode(rmode);
// reset restriction mode flag
78
79
Set
(coarseLevel,
"R"
, R);
80
81
}
// BuildR
82
83
}
// namespace MueLu
84
85
#define MUELU_GENERICRFACTORY_SHORT
86
#endif
// MUELU_GENERICRFACTORY_DEF_HPP
MueLu_DisableMultipleCallCheck.hpp
MueLu_FactoryBase.hpp
MueLu_FactoryManagerBase.hpp
MueLu_GenericRFactory_decl.hpp
MueLu_Monitor.hpp
MueLu::DisableMultipleCallCheck
An exception safe way to call the method TwoLevelFactoryBase::DisableMultipleCallCheck.
Definition
MueLu_DisableMultipleCallCheck.hpp:20
MueLu::Factory::Set
void Set(Level &level, const std::string &varName, const T &data) const
Definition
MueLu_Factory.hpp:80
MueLu::Factory::GetFactory
const RCP< const FactoryBase > GetFactory(const std::string &varName) const
Default implementation of FactoryAcceptor::GetFactory().
Definition
MueLu_Factory.cpp:30
MueLu::FactoryMonitor
Timer to be used in factories. Similar to Monitor but with additional timers.
Definition
MueLu_Monitor.hpp:165
MueLu::GenericRFactory::GetValidParameterList
RCP< const ParameterList > GetValidParameterList() const
Input.
Definition
MueLu_GenericRFactory_def.hpp:26
MueLu::GenericRFactory::Build
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
Definition
MueLu_GenericRFactory_def.hpp:59
MueLu::GenericRFactory::DeclareInput
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
Definition
MueLu_GenericRFactory_def.hpp:33
MueLu::Level
Class that holds all level-specific information.
Definition
MueLu_Level.hpp:63
MueLu::Level::DeclareInput
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput().
Definition
MueLu_Level.cpp:156
MueLu::Level::GetFactoryManager
const RCP< const FactoryManagerBase > GetFactoryManager()
returns the current factory manager
Definition
MueLu_Level.cpp:73
MueLu::Level::Get
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access)....
Definition
MueLu_Level.hpp:154
MueLu::Level::DeclareDependencies
void DeclareDependencies(const FactoryBase *factory, bool bRequestOnly=false, bool bReleaseOnly=false)
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput() to declare factory depe...
Definition
MueLu_Level.cpp:183
MueLu
Namespace for MueLu classes and methods.
Definition
MueLu_BrickAggregationFactory_decl.hpp:42
src
Transfers
Generic
MueLu_GenericRFactory_def.hpp
Generated by
1.17.0