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
// ***********************************************************************
4
//
5
// MueLu: A package for multigrid based preconditioning
6
// Copyright 2012 Sandia Corporation
7
//
8
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9
// the U.S. Government retains certain rights in this software.
10
//
11
// Redistribution and use in source and binary forms, with or without
12
// modification, are permitted provided that the following conditions are
13
// met:
14
//
15
// 1. Redistributions of source code must retain the above copyright
16
// notice, this list of conditions and the following disclaimer.
17
//
18
// 2. Redistributions in binary form must reproduce the above copyright
19
// notice, this list of conditions and the following disclaimer in the
20
// documentation and/or other materials provided with the distribution.
21
//
22
// 3. Neither the name of the Corporation nor the names of the
23
// contributors may be used to endorse or promote products derived from
24
// this software without specific prior written permission.
25
//
26
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
//
38
// Questions? Contact
39
// Jonathan Hu (jhu@sandia.gov)
40
// Andrey Prokopenko (aprokop@sandia.gov)
41
// Ray Tuminaro (rstumin@sandia.gov)
42
//
43
// ***********************************************************************
44
//
45
// @HEADER
46
#ifndef MUELU_MATRIXFREETENTATIVEPFACTORY_DEF_HPP
47
#define MUELU_MATRIXFREETENTATIVEPFACTORY_DEF_HPP
48
49
#include "Kokkos_UnorderedMap.hpp"
50
51
#include "
MueLu_MatrixFreeTentativePFactory_decl.hpp
"
52
53
#include "MueLu_Aggregates.hpp"
54
#include "MueLu_AmalgamationInfo.hpp"
55
#include "
MueLu_Monitor.hpp
"
56
#include "MueLu_MatrixFreeTentativeP.hpp"
57
58
namespace
MueLu
{
59
60
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
DeviceType>
61
RCP<const ParameterList>
MatrixFreeTentativePFactory<Scalar,LocalOrdinal,GlobalOrdinal,Tpetra::KokkosCompat::KokkosDeviceWrapperNode<DeviceType>
>
::GetValidParameterList
()
const
{
62
RCP<ParameterList> validParamList = rcp(
new
ParameterList());
63
64
validParamList->set< RCP<const FactoryBase> >(
"A"
, Teuchos::null,
"Generating factory of the matrix A"
);
65
validParamList->set< RCP<const FactoryBase> >(
"Aggregates"
, Teuchos::null,
"Generating factory of the aggregates"
);
66
validParamList->set< RCP<const FactoryBase> >(
"Nullspace"
, Teuchos::null,
"Generating factory of the nullspace"
);
67
validParamList->set< RCP<const FactoryBase> >(
"Scaled Nullspace"
, Teuchos::null,
"Generating factory of the scaled nullspace"
);
68
validParamList->set< RCP<const FactoryBase> >(
"UnAmalgamationInfo"
, Teuchos::null,
"Generating factory of UnAmalgamationInfo"
);
69
validParamList->set< RCP<const FactoryBase> >(
"CoarseMap"
, Teuchos::null,
"Generating factory of the coarse map"
);
70
validParamList->set< RCP<const FactoryBase> >(
"Coordinates"
, Teuchos::null,
"Generating factory of the coordinates"
);
71
72
// Make sure we don't recursively validate options for the matrixmatrix kernels
73
ParameterList norecurse;
74
norecurse.disableRecursiveValidation();
75
validParamList->set<ParameterList> (
"matrixmatrix: kernel params"
, norecurse,
"MatrixMatrix kernel parameters"
);
76
77
return
validParamList;
78
}
79
80
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
DeviceType>
81
void
MatrixFreeTentativePFactory<Scalar,LocalOrdinal,GlobalOrdinal,Tpetra::KokkosCompat::KokkosDeviceWrapperNode<DeviceType>
>
::DeclareInput
(
Level
& fineLevel,
Level
&
/* coarseLevel */
)
const
{
82
83
const
ParameterList& pL =
GetParameterList
();
84
// NOTE: This guy can only either be 'Nullspace' or 'Scaled Nullspace' or else the validator above will cause issues
85
std::string nspName =
"Nullspace"
;
86
if
(pL.isParameter(
"Nullspace name"
)) nspName = pL.get<std::string>(
"Nullspace name"
);
87
88
Input
(fineLevel,
"Aggregates"
);
89
Input
(fineLevel, nspName);
90
Input
(fineLevel,
"UnAmalgamationInfo"
);
91
Input
(fineLevel,
"CoarseMap"
);
92
}
93
94
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
DeviceType>
95
void
MatrixFreeTentativePFactory<Scalar,LocalOrdinal,GlobalOrdinal,Tpetra::KokkosCompat::KokkosDeviceWrapperNode<DeviceType>
>
::Build
(
Level
& fineLevel,
Level
& coarseLevel)
const
{
96
return
BuildP
(fineLevel, coarseLevel);
97
}
98
99
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
DeviceType>
100
void
MatrixFreeTentativePFactory<Scalar,LocalOrdinal,GlobalOrdinal,Tpetra::KokkosCompat::KokkosDeviceWrapperNode<DeviceType>
>
::BuildP
(
Level
& fineLevel,
Level
& coarseLevel)
const
{
101
FactoryMonitor
m(*
this
,
"Build"
, coarseLevel);
102
103
const
ParameterList& pL =
GetParameterList
();
104
std::string nspName =
"Nullspace"
;
105
if
(pL.isParameter(
"Nullspace name"
)) nspName = pL.get<std::string>(
"Nullspace name"
);
106
107
auto
aggregates =
Get< RCP<Aggregates>
> (fineLevel,
"Aggregates"
);
108
auto
amalgInfo =
Get< RCP<AmalgamationInfo>
> (fineLevel,
"UnAmalgamationInfo"
);
109
auto
fineNullspace =
Get< RCP<MultiVector>
> (fineLevel, nspName);
110
auto
coarseMap =
Get< RCP<const Map>
> (fineLevel,
"CoarseMap"
);
111
Teuchos::RCP<const Map> fineMap = fineNullspace->getMap();
112
113
// Matrix-free should never run with aggregates that cross processors
114
if
(aggregates->AggregatesCrossProcessors())
115
TEUCHOS_TEST_FOR_EXCEPTION(
true
,
Exceptions::RuntimeError
,
"MatrixFreeTentativePFactory does not support aggregates that cross processors!"
);
116
117
size_t
NSDim = fineNullspace->getNumVectors();
118
RCP<MultiVector> coarseNullspace = MultiVectorFactory::Build(coarseMap, NSDim);
119
120
Teuchos::RCP<Operator> P = Teuchos::rcp(
new
MatrixFreeTentativeP
<
Scalar
,
LocalOrdinal
,
GlobalOrdinal
,Tpetra::KokkosCompat::KokkosDeviceWrapperNode<DeviceType>>(coarseMap, fineMap, aggregates));
121
P->apply(*fineNullspace,*coarseNullspace,Teuchos::TRANS,1.0,0.0);
// coarse = alpha*R*fine + beta*coarse
122
123
Set
(coarseLevel,
"Nullspace"
, coarseNullspace);
124
Set
(coarseLevel,
"P"
, P);
125
}
126
127
}
//namespace MueLu
128
129
#define MUELU_MATRIXFREETENTATIVEPFACTORY_SHORT
130
#endif
// MUELU_MATRIXFREETENTATIVEPFACTORY_DEF_HPP
MueLu_MatrixFreeTentativePFactory_decl.hpp
MueLu_Monitor.hpp
LocalOrdinal
MueLu::DefaultLocalOrdinal LocalOrdinal
Definition
MueLu_UseDefaultTypes.hpp:50
Scalar
MueLu::DefaultScalar Scalar
Definition
MueLu_UseDefaultTypes.hpp:49
GlobalOrdinal
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Definition
MueLu_UseDefaultTypes.hpp:51
MueLu::Exceptions::RuntimeError
Exception throws to report errors in the internal logical of the program.
Definition
MueLu_Exceptions.hpp:70
MueLu::FactoryMonitor
Timer to be used in factories. Similar to Monitor but with additional timers.
Definition
MueLu_Monitor.hpp:202
MueLu::Factory::Input
void Input(Level &level, const std::string &varName) const
Definition
MueLu_Factory.hpp:146
MueLu::Factory::Get
T Get(Level &level, const std::string &varName) const
Definition
MueLu_Factory.hpp:155
MueLu::Factory::Set
void Set(Level &level, const std::string &varName, const T &data) const
Definition
MueLu_Factory.hpp:165
MueLu::Level
Class that holds all level-specific information.
Definition
MueLu_Level.hpp:99
MueLu::MatrixFreeTentativePFactory< Scalar, LocalOrdinal, GlobalOrdinal, Tpetra::KokkosCompat::KokkosDeviceWrapperNode< DeviceType > >::MatrixFreeTentativePFactory
MatrixFreeTentativePFactory()
Constructor.
Definition
MueLu_MatrixFreeTentativePFactory_decl.hpp:125
MueLu::MatrixFreeTentativePFactory< Scalar, LocalOrdinal, GlobalOrdinal, Tpetra::KokkosCompat::KokkosDeviceWrapperNode< DeviceType > >::Build
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
Definition
MueLu_MatrixFreeTentativePFactory_def.hpp:95
MueLu::MatrixFreeTentativePFactory< Scalar, LocalOrdinal, GlobalOrdinal, Tpetra::KokkosCompat::KokkosDeviceWrapperNode< DeviceType > >::DeclareInput
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
Definition
MueLu_MatrixFreeTentativePFactory_def.hpp:81
MueLu::MatrixFreeTentativePFactory< Scalar, LocalOrdinal, GlobalOrdinal, Tpetra::KokkosCompat::KokkosDeviceWrapperNode< DeviceType > >::GetValidParameterList
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
Definition
MueLu_MatrixFreeTentativePFactory_def.hpp:61
MueLu::MatrixFreeTentativePFactory< Scalar, LocalOrdinal, GlobalOrdinal, Tpetra::KokkosCompat::KokkosDeviceWrapperNode< DeviceType > >::BuildP
void BuildP(Level &fineLevel, Level &coarseLevel) const
Abstract Build method.
Definition
MueLu_MatrixFreeTentativePFactory_def.hpp:100
MueLu::MatrixFreeTentativeP
Matrix-free tentative restrictor operator.
Definition
MueLu_MatrixFreeTentativeP_fwd.hpp:54
MueLu::ParameterListAcceptorImpl::GetParameterList
virtual const Teuchos::ParameterList & GetParameterList() const
Definition
MueLu_ParameterListAcceptor.cpp:41
MueLu
Namespace for MueLu classes and methods.
Definition
MueLu_BrickAggregationFactory_decl.hpp:78
src
Transfers
Matrix-Free
MueLu_MatrixFreeTentativePFactory_def.hpp
Generated by
1.17.0