MueLu
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
MueLu_ThresholdAFilterFactory_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_THRESHOLDAFILTERFACTORY_DEF_HPP
11
#define MUELU_THRESHOLDAFILTERFACTORY_DEF_HPP
12
13
#include <Xpetra_Matrix.hpp>
14
#include <Xpetra_CrsMatrixWrap.hpp>
15
16
#include "
MueLu_ThresholdAFilterFactory_decl.hpp
"
17
18
#include "
MueLu_Level.hpp
"
19
#include "
MueLu_Monitor.hpp
"
20
21
namespace
MueLu
{
22
23
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
24
ThresholdAFilterFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::ThresholdAFilterFactory
(
const
std::string& ename,
const
magnitudeType
threshold,
const
bool
keepDiagonal,
const
GlobalOrdinal
expectedNNZperRow)
25
:
varName_
(ename)
26
,
threshold_
(threshold)
27
,
keepDiagonal_
(keepDiagonal)
28
,
expectedNNZperRow_
(expectedNNZperRow) {}
29
30
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
31
void
ThresholdAFilterFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::DeclareInput
(
Level
& currentLevel)
const
{
32
Input
(currentLevel,
varName_
);
33
}
34
35
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
36
void
ThresholdAFilterFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
37
Build
(
Level
& currentLevel)
const
{
38
FactoryMonitor
m(*
this
,
"A filter (thresholding)"
, currentLevel);
39
40
RCP<Matrix> Ain =
Get<RCP<Matrix>
>(currentLevel,
varName_
);
41
RCP<CrsMatrixWrap> Aout =
42
MueLu::Utilities<Scalar, LocalOrdinal, GlobalOrdinal, Node>::GetThresholdedMatrix
(Ain,
threshold_
,
keepDiagonal_
,
expectedNNZperRow_
);
43
44
GetOStream
(
Statistics0
) <<
"Nonzeros in "
<<
varName_
<<
"(input): "
<< Ain->getGlobalNumEntries() <<
", Nonzeros after filtering "
<<
varName_
<<
" (parameter: "
<<
threshold_
<<
"): "
<< Aout->getGlobalNumEntries() << std::endl;
45
currentLevel.
Set
(
varName_
, Teuchos::rcp_dynamic_cast<Matrix>(Aout),
this
);
46
}
47
48
}
// namespace MueLu
49
50
#endif
// MUELU_THRESHOLDAFILTERFACTORY_DEF_HPP
MueLu_Level.hpp
MueLu_Monitor.hpp
MueLu_ThresholdAFilterFactory_decl.hpp
GlobalOrdinal
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Definition
MueLu_UseDefaultTypes.hpp:14
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::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::Level::Set
void Set(const std::string &ename, const T &entry, const FactoryBase *factory=NoFactory::get())
Definition
MueLu_Level.hpp:120
MueLu::ThresholdAFilterFactory::Build
void Build(Level ¤tLevel) const
Build an object with this factory.
Definition
MueLu_ThresholdAFilterFactory_def.hpp:37
MueLu::ThresholdAFilterFactory::DeclareInput
void DeclareInput(Level ¤tLevel) const
Input.
Definition
MueLu_ThresholdAFilterFactory_def.hpp:31
MueLu::ThresholdAFilterFactory::threshold_
const magnitudeType threshold_
threshold parameter
Definition
MueLu_ThresholdAFilterFactory_decl.hpp:67
MueLu::ThresholdAFilterFactory::varName_
std::string varName_
name of input and output variable
Definition
MueLu_ThresholdAFilterFactory_decl.hpp:66
MueLu::ThresholdAFilterFactory::expectedNNZperRow_
const GlobalOrdinal expectedNNZperRow_
Definition
MueLu_ThresholdAFilterFactory_decl.hpp:69
MueLu::ThresholdAFilterFactory::keepDiagonal_
const bool keepDiagonal_
Definition
MueLu_ThresholdAFilterFactory_decl.hpp:68
MueLu::ThresholdAFilterFactory::ThresholdAFilterFactory
ThresholdAFilterFactory(const std::string &ename, const magnitudeType threshold, const bool keepDiagonal=true, const GlobalOrdinal expectedNNZperRow=-1)
Constructor.
Definition
MueLu_ThresholdAFilterFactory_def.hpp:24
MueLu::ThresholdAFilterFactory::magnitudeType
typename Teuchos::ScalarTraits< Scalar >::magnitudeType magnitudeType
Definition
MueLu_ThresholdAFilterFactory_decl.hpp:41
MueLu::UtilitiesBase< Scalar, DefaultLocalOrdinal, DefaultGlobalOrdinal, DefaultNode >::GetThresholdedMatrix
static RCP< CrsMatrixWrap > GetThresholdedMatrix(const RCP< Matrix > &Ain, const Magnitude threshold, const bool keepDiagonal=true, const DefaultGlobalOrdinal expectedNNZperRow=-1)
Definition
MueLu_UtilitiesBase_def.hpp:90
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::Statistics0
@ Statistics0
Print statistics that do not involve significant additional computation.
Definition
MueLu_VerbosityLevel.hpp:33
src
Misc
MueLu_ThresholdAFilterFactory_def.hpp
Generated by
1.17.0