46 #ifndef MUELU_COALESCEDROPFACTORY_KOKKOS_DEF_HPP 47 #define MUELU_COALESCEDROPFACTORY_KOKKOS_DEF_HPP 49 #include <Kokkos_CrsMatrix.hpp> 53 #include "MueLu_AmalgamationInfo.hpp" 56 #include "MueLu_LWGraph_kokkos.hpp" 59 #include "MueLu_Utilities_kokkos.hpp" 63 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
64 RCP<const ParameterList> CoalesceDropFactory_kokkos<Scalar, LocalOrdinal, GlobalOrdinal, Node>::GetValidParameterList()
const {
65 RCP<ParameterList> validParamList = rcp(
new ParameterList());
67 #define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name)) 72 typedef Teuchos::StringToIntegralParameterEntryValidator<int> validatorType;
73 validParamList->getEntry(
"aggregation: drop scheme").setValidator(
74 rcp(
new validatorType(Teuchos::tuple<std::string>(
"classical",
"distance laplacian"),
"aggregation: drop scheme")));
76 #undef SET_VALID_ENTRY 77 validParamList->set<
bool > (
"lightweight wrap",
true,
"Experimental option for lightweight graph access");
79 validParamList->set< RCP<const FactoryBase> >(
"A", Teuchos::null,
"Generating factory of the matrix A");
80 validParamList->set< RCP<const FactoryBase> >(
"UnAmalgamationInfo", Teuchos::null,
"Generating factory for UnAmalgamationInfo");
81 validParamList->set< RCP<const FactoryBase> >(
"Coordinates", Teuchos::null,
"Generating factory for Coordinates");
83 return validParamList;
86 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
87 void CoalesceDropFactory_kokkos<Scalar, LocalOrdinal, GlobalOrdinal, Node>::DeclareInput(Level ¤tLevel)
const {
88 Input(currentLevel,
"A");
89 Input(currentLevel,
"UnAmalgamationInfo");
91 const ParameterList& pL = GetParameterList();
92 if (pL.get<
bool>(
"lightweight wrap") ==
true) {
93 if (pL.get<std::string>(
"aggregation: drop scheme") ==
"distance laplacian")
94 Input(currentLevel,
"Coordinates");
98 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
99 void CoalesceDropFactory_kokkos<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build(Level& currentLevel)
const {
100 FactoryMonitor m(*
this,
"Build", currentLevel);
102 typedef Teuchos::ScalarTraits<SC> STS;
103 SC zero = STS::zero(), one = STS::one();
105 RCP<Matrix> A = Get< RCP<Matrix> >(currentLevel,
"A");
106 RCP<AmalgamationInfo> amalInfo = Get< RCP<AmalgamationInfo> >(currentLevel,
"UnAmalgamationInfo");
108 const ParameterList& pL = GetParameterList();
111 GetOStream(
Warnings0) <<
"lightweight wrap is deprecated" << std::endl;
113 std::string algo = pL.get<std::string>(
"aggregation: drop scheme");
115 SC threshold = as<SC>(pL.get<
double>(
"aggregation: drop tol"));
116 GetOStream(
Runtime0) <<
"algorithm = \"" << algo <<
"\": threshold = " << threshold <<
", blocksize = " << A->GetFixedBlockSize() << std::endl;
118 Set(currentLevel,
"Filtering", (threshold != STS::zero()));
120 const typename STS::magnitudeType dirichletThreshold = STS::magnitude(as<SC>(pL.get<
double>(
"aggregation: Dirichlet threshold")));
122 GO numDropped = 0, numTotal = 0;
123 std::string graphType =
"unamalgamated";
125 if (algo ==
"classical") {
126 if (A->GetFixedBlockSize() == 1 && threshold == STS::zero()) {
130 RCP<LWGraph_kokkos> graph = rcp(
new LWGraph_kokkos(A->getLocalMatrix().graph, A->getDomainMap(), A->getRangeMap(),
"graph of A"));
133 ArrayRCP<const bool> boundaryNodes = Utils_kokkos::DetectDirichletRows(*A, dirichletThreshold);
134 graph->SetBoundaryNodeMap(boundaryNodes);
136 numTotal = A->getNodeNumEntries();
139 GO numLocalBoundaryNodes = 0;
140 GO numGlobalBoundaryNodes = 0;
142 if (boundaryNodes[i])
144 }, numLocalBoundaryNodes,
"CoalesceDropF:Build:case1_bnd");
146 RCP<const Teuchos::Comm<int> > comm = A->getRowMap()->getComm();
147 MueLu_sumAll(comm, numLocalBoundaryNodes, numGlobalBoundaryNodes);
148 GetOStream(
Statistics0) <<
"Detected " << numGlobalBoundaryNodes <<
" Dirichlet nodes" << std::endl;
151 Set(currentLevel,
"DofsPerNode", 1);
152 Set(currentLevel,
"Graph", graph);
159 #endif // MUELU_COALESCEDROPFACTORY_KOKKOS_DEF_HPP Important warning messages (one line)
One-liner description of what is happening.
Namespace for MueLu classes and methods.
void parallel_reduce(const ExecPolicy &policy, const FunctorType &functor, const std::string &str="", typename Impl::enable_if< !Impl::is_integral< ExecPolicy >::value >::type *=0)
Print statistics that do not involve significant additional computation.
#define MueLu_sumAll(rcpComm, in, out)
#define SET_VALID_ENTRY(name)