MueLu
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
MueLu_MatrixFreeTentativePFactory_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_MATRIXFREETENTATIVEPFACTORY_DEF_HPP
11
#define MUELU_MATRIXFREETENTATIVEPFACTORY_DEF_HPP
12
13
#include "Kokkos_UnorderedMap.hpp"
14
15
#include "
MueLu_MatrixFreeTentativePFactory_decl.hpp
"
16
17
#include "MueLu_Aggregates.hpp"
18
#include "MueLu_AmalgamationInfo.hpp"
19
#include "
MueLu_Monitor.hpp
"
20
#include "MueLu_MatrixFreeTentativeP.hpp"
21
22
namespace
MueLu
{
23
24
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
25
RCP<const ParameterList>
MatrixFreeTentativePFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::GetValidParameterList
()
const
{
26
RCP<ParameterList> validParamList = rcp(
new
ParameterList());
27
28
validParamList->set<RCP<const FactoryBase>>(
"A"
, Teuchos::null,
"Generating factory of the matrix A"
);
29
validParamList->set<RCP<const FactoryBase>>(
"Aggregates"
, Teuchos::null,
"Generating factory of the aggregates"
);
30
validParamList->set<RCP<const FactoryBase>>(
"Nullspace"
, Teuchos::null,
"Generating factory of the nullspace"
);
31
validParamList->set<RCP<const FactoryBase>>(
"Scaled Nullspace"
, Teuchos::null,
"Generating factory of the scaled nullspace"
);
32
validParamList->set<RCP<const FactoryBase>>(
"UnAmalgamationInfo"
, Teuchos::null,
"Generating factory of UnAmalgamationInfo"
);
33
validParamList->set<RCP<const FactoryBase>>(
"CoarseMap"
, Teuchos::null,
"Generating factory of the coarse map"
);
34
validParamList->set<RCP<const FactoryBase>>(
"Coordinates"
, Teuchos::null,
"Generating factory of the coordinates"
);
35
36
// Make sure we don't recursively validate options for the matrixmatrix kernels
37
ParameterList norecurse;
38
norecurse.disableRecursiveValidation();
39
validParamList->set<ParameterList>(
"matrixmatrix: kernel params"
, norecurse,
"MatrixMatrix kernel parameters"
);
40
41
return
validParamList;
42
}
43
44
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
45
void
MatrixFreeTentativePFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::DeclareInput
(
Level
& fineLevel,
Level
&
/* coarseLevel */
)
const
{
46
const
ParameterList& pL =
GetParameterList
();
47
// NOTE: This guy can only either be 'Nullspace' or 'Scaled Nullspace' or else the validator above will cause issues
48
std::string nspName =
"Nullspace"
;
49
if
(pL.isParameter(
"Nullspace name"
)) nspName = pL.get<std::string>(
"Nullspace name"
);
50
51
Input
(fineLevel,
"Aggregates"
);
52
Input
(fineLevel, nspName);
53
Input
(fineLevel,
"UnAmalgamationInfo"
);
54
Input
(fineLevel,
"CoarseMap"
);
55
}
56
57
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
58
void
MatrixFreeTentativePFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build
(
Level
& fineLevel,
Level
& coarseLevel)
const
{
59
return
BuildP
(fineLevel, coarseLevel);
60
}
61
62
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
63
void
MatrixFreeTentativePFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::BuildP
(
Level
& fineLevel,
Level
& coarseLevel)
const
{
64
FactoryMonitor
m(*
this
,
"Build"
, coarseLevel);
65
66
const
ParameterList& pL =
GetParameterList
();
67
std::string nspName =
"Nullspace"
;
68
if
(pL.isParameter(
"Nullspace name"
)) nspName = pL.get<std::string>(
"Nullspace name"
);
69
70
auto
aggregates =
Get<RCP<Aggregates>
>(fineLevel,
"Aggregates"
);
71
auto
amalgInfo =
Get<RCP<AmalgamationInfo>
>(fineLevel,
"UnAmalgamationInfo"
);
72
auto
fineNullspace =
Get<RCP<MultiVector>
>(fineLevel, nspName);
73
auto
coarseMap =
Get<RCP<const Map>
>(fineLevel,
"CoarseMap"
);
74
Teuchos::RCP<const Map> fineMap = fineNullspace->getMap();
75
76
// Matrix-free should never run with aggregates that cross processors
77
if
(aggregates->AggregatesCrossProcessors())
78
TEUCHOS_TEST_FOR_EXCEPTION(
true
,
Exceptions::RuntimeError
,
"MatrixFreeTentativePFactory does not support aggregates that cross processors!"
);
79
80
size_t
NSDim = fineNullspace->getNumVectors();
81
RCP<MultiVector> coarseNullspace = MultiVectorFactory::Build(coarseMap, NSDim);
82
83
Teuchos::RCP<Operator> P = Teuchos::rcp(
new
MatrixFreeTentativeP<Scalar, LocalOrdinal, GlobalOrdinal, Node>
(coarseMap, fineMap, aggregates));
84
P->apply(*fineNullspace, *coarseNullspace, Teuchos::TRANS, 1.0, 0.0);
// coarse = alpha*R*fine + beta*coarse
85
86
Set
(coarseLevel,
"Nullspace"
, coarseNullspace);
87
Set
(coarseLevel,
"P"
, P);
88
}
89
90
}
// namespace MueLu
91
92
#define MUELU_MATRIXFREETENTATIVEPFACTORY_SHORT
93
#endif
// MUELU_MATRIXFREETENTATIVEPFACTORY_DEF_HPP
MueLu_MatrixFreeTentativePFactory_decl.hpp
MueLu_Monitor.hpp
MueLu::Exceptions::RuntimeError
Exception throws to report errors in the internal logical of the program.
Definition
MueLu_Exceptions.hpp:36
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::Level
Class that holds all level-specific information.
Definition
MueLu_Level.hpp:63
MueLu::MatrixFreeTentativePFactory::Build
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
Definition
MueLu_MatrixFreeTentativePFactory_def.hpp:58
MueLu::MatrixFreeTentativePFactory::DeclareInput
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
Definition
MueLu_MatrixFreeTentativePFactory_def.hpp:45
MueLu::MatrixFreeTentativePFactory::BuildP
void BuildP(Level &fineLevel, Level &coarseLevel) const
Abstract Build method.
Definition
MueLu_MatrixFreeTentativePFactory_def.hpp:63
MueLu::MatrixFreeTentativePFactory::GetValidParameterList
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
Definition
MueLu_MatrixFreeTentativePFactory_def.hpp:25
MueLu::MatrixFreeTentativeP
Matrix-free tentative restrictor operator.
Definition
MueLu_MatrixFreeTentativeP_decl.hpp:37
MueLu::ParameterListAcceptorImpl::GetParameterList
virtual const Teuchos::ParameterList & GetParameterList() const
Definition
MueLu_ParameterListAcceptor.cpp:50
MueLu
Namespace for MueLu classes and methods.
Definition
MueLu_BrickAggregationFactory_decl.hpp:42
src
Transfers
Matrix-Free
MueLu_MatrixFreeTentativePFactory_def.hpp
Generated by
1.17.0