46 #ifndef MUELU_FACTORYMANAGER_DEF_HPP
47 #define MUELU_FACTORYMANAGER_DEF_HPP
49 #include <Teuchos_ParameterList.hpp>
52 #include "MueLu_AmalgamationFactory.hpp"
53 #include "MueLu_CoalesceDropFactory.hpp"
54 #include "MueLu_CoarseMapFactory.hpp"
55 #include "MueLu_ConstraintFactory.hpp"
56 #include "MueLu_CoordinatesTransferFactory.hpp"
57 #include "MueLu_DirectSolver.hpp"
58 #include "MueLu_LineDetectionFactory.hpp"
61 #include "MueLu_NullspaceFactory.hpp"
62 #include "MueLu_PatternFactory.hpp"
63 #include "MueLu_RAPFactory.hpp"
64 #include "MueLu_RepartitionHeuristicFactory.hpp"
65 #include "MueLu_RepartitionFactory.hpp"
66 #include "MueLu_SaPFactory.hpp"
67 #include "MueLu_ScaledNullspaceFactory.hpp"
68 #include "MueLu_SmootherFactory.hpp"
69 #include "MueLu_TentativePFactory.hpp"
70 #include "MueLu_TransPFactory.hpp"
71 #include "MueLu_TrilinosSmoother.hpp"
72 #include "MueLu_UncoupledAggregationFactory.hpp"
73 #include "MueLu_HybridAggregationFactory.hpp"
74 #include "MueLu_ZoltanInterface.hpp"
76 #ifdef HAVE_MUELU_KOKKOS_REFACTOR
77 #include "MueLu_AmalgamationFactory_kokkos.hpp"
78 #include "MueLu_CoalesceDropFactory_kokkos.hpp"
79 #include "MueLu_CoarseMapFactory_kokkos.hpp"
80 #include "MueLu_CoordinatesTransferFactory_kokkos.hpp"
81 #include "MueLu_NullspaceFactory_kokkos.hpp"
82 #include "MueLu_SaPFactory_kokkos.hpp"
83 #include "MueLu_TentativePFactory_kokkos.hpp"
84 #include "MueLu_UncoupledAggregationFactory_kokkos.hpp"
92 #ifndef HAVE_MUELU_KOKKOS_REFACTOR
93 #define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \
94 SetAndReturnDefaultFactory(varName, rcp(new oldFactory()));
96 #define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \
97 (!useKokkos_) ? SetAndReturnDefaultFactory(varName, rcp(new oldFactory())) : \
98 SetAndReturnDefaultFactory(varName, rcp(new newFactory()));
101 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
103 factoryTable_[varName] = factory;
106 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
108 if (factoryTable_.count(varName)) {
110 return factoryTable_.find(varName)->second;
114 return GetDefaultFactory(varName);
117 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
119 return Teuchos::rcp_const_cast<FactoryBase>(GetFactory(varName));
122 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
124 if (factoryTable_.count(varName))
return true;
128 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
130 if (defaultFactoryTable_.count(varName)) {
132 return defaultFactoryTable_.find(varName)->second;
136 if (varName ==
"A")
return SetAndReturnDefaultFactory(varName, rcp(
new RAPFactory()));
137 if (varName ==
"RAP Pattern")
return GetFactory(
"A");
138 if (varName ==
"AP Pattern")
return GetFactory(
"A");
140 if (varName ==
"P") {
142 RCP<Factory> factory;
143 #ifdef HAVE_MUELU_KOKKOS_REFACTOR
145 factory = rcp(
new SaPFactory_kokkos());
149 factory->SetFactory(
"P", GetFactory(
"Ptent"));
150 return SetAndReturnDefaultFactory(varName, factory);
152 if (varName ==
"Nullspace") {
154 RCP<Factory> factory;
155 #ifdef HAVE_MUELU_KOKKOS_REFACTOR
157 factory = rcp(
new NullspaceFactory_kokkos());
161 factory->SetFactory(
"Nullspace", GetFactory(
"Ptent"));
162 return SetAndReturnDefaultFactory(varName, factory);
164 if (varName ==
"Scaled Nullspace")
return SetAndReturnDefaultFactory(varName, rcp(
new ScaledNullspaceFactory()));
166 if (varName ==
"Coordinates")
return GetFactory(
"Ptent");
167 if (varName ==
"Node Comm")
return GetFactory(
"Ptent");
169 if (varName ==
"R")
return SetAndReturnDefaultFactory(varName, rcp(
new TransPFactory()));
170 #if defined(HAVE_MUELU_ZOLTAN) && defined(HAVE_MPI)
171 if (varName ==
"Partition")
return SetAndReturnDefaultFactory(varName, rcp(
new ZoltanInterface()));
174 if (varName ==
"Importer") {
181 if (varName ==
"number of partitions") {
188 if (varName ==
"repartition: heuristic target rows per process")
return GetFactory(
"number of partitions");
194 if (varName ==
"DofsPerNode")
return GetFactory(
"Graph");
195 if (varName ==
"Filtering")
return GetFactory(
"Graph");
196 if (varName ==
"LineDetection_VertLineIds")
return SetAndReturnDefaultFactory(varName, rcp(
new LineDetectionFactory()));
197 if (varName ==
"LineDetection_Layers")
return GetFactory(
"LineDetection_VertLineIds");
198 if (varName ==
"CoarseNumZLayers")
return GetFactory(
"LineDetection_VertLineIds");
201 if (varName ==
"K")
return GetFactory(
"A");
202 if (varName ==
"M")
return GetFactory(
"A");
203 if (varName ==
"Mdiag")
return GetFactory(
"A");
204 if (varName ==
"cfl-based shift array")
return GetFactory(
"A");
207 if (varName ==
"PreSmoother")
return GetFactory(
"Smoother");
208 if (varName ==
"PostSmoother")
return GetFactory(
"Smoother");
210 if (varName ==
"Ppattern") {
212 PpFact->SetFactory(
"P", GetFactory(
"Ptent"));
213 return SetAndReturnDefaultFactory(varName, PpFact);
215 if (varName ==
"Constraint")
return SetAndReturnDefaultFactory(varName, rcp(
new ConstraintFactory()));
217 if (varName ==
"Smoother") {
218 Teuchos::ParameterList smootherParamList;
219 smootherParamList.set(
"relaxation: type",
"Symmetric Gauss-Seidel");
220 smootherParamList.set(
"relaxation: sweeps", Teuchos::OrdinalTraits<LO>::one());
221 smootherParamList.set(
"relaxation: damping factor", Teuchos::ScalarTraits<Scalar>::one());
224 if (varName ==
"CoarseSolver")
return SetAndReturnDefaultFactory(varName, rcp(
new SmootherFactory(rcp(
new DirectSolver()), Teuchos::null)));
226 #ifdef HAVE_MUELU_INTREPID2
228 if (varName ==
"pcoarsen: element to node map")
return GetFactory(
"P");
231 TEUCHOS_TEST_FOR_EXCEPTION(
true,
MueLu::Exceptions::RuntimeError,
"MueLu::FactoryManager::GetDefaultFactory(): No default factory available for building '" + varName +
"'.");
235 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
237 TEUCHOS_TEST_FOR_EXCEPTION(factory.is_null(),
Exceptions::RuntimeError,
"The default factory for building '" << varName <<
"' is null");
239 GetOStream(
Runtime1) <<
"Using default factory (" << factory->ShortClassName() <<
"["<<factory->GetID()<<
"] "<<
") for building '" << varName <<
"'." << std::endl;
241 defaultFactoryTable_[varName] = factory;
243 return defaultFactoryTable_[varName];
246 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
248 std::map<std::string, RCP<const FactoryBase> >::const_iterator it;
250 Teuchos::FancyOStream& fancy = GetOStream(
Debug);
252 fancy <<
"Users factory table (factoryTable_):" << std::endl;
253 for (it = factoryTable_.begin(); it != factoryTable_.end(); it++) {
254 fancy <<
" " << it->first <<
" -> ";
256 else if (!it->second.get()) fancy<<
"NULL";
258 fancy << it->second.get()->ShortClassName()<<
"["<<it->second.get()->GetID()<<
"]";
259 #ifdef HAVE_MUELU_DEBUG
266 fancy <<
"Default factory table (defaultFactoryTable_):" << std::endl;
267 for (it = defaultFactoryTable_.begin(); it != defaultFactoryTable_.end(); it++) {
268 fancy <<
" " << it->first <<
" -> ";
270 else if (!it->second.get()) fancy<<
"NULL";
272 fancy << it->second.get()->ShortClassName()<<
"["<<it->second.get()->GetID()<<
"]";
273 #ifdef HAVE_MUELU_DEBUG
282 #ifdef HAVE_MUELU_DEBUG
283 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
285 std::map<std::string, RCP<const FactoryBase> >::const_iterator it;
287 for (it = factoryTable_.begin(); it != factoryTable_.end(); it++)
288 if (!it->second.is_null())
289 it->second->ResetDebugData();
291 for (it = defaultFactoryTable_.begin(); it != defaultFactoryTable_.end(); it++)
292 if (!it->second.is_null())
293 it->second->ResetDebugData();
298 #undef MUELU_KOKKOS_FACTORY
#define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory)
AmalgamationFactory for subblocks of strided map based amalgamation data.
Factory for creating a graph base on a given matrix.
Factory for generating coarse level map. Used by TentativePFactory.
Factory for building the constraint operator.
Class that encapsulates direct solvers. Autoselection of AmesosSmoother or Amesos2Smoother according ...
Exception throws to report errors in the internal logical of the program.
This class specifies the default factory that should generate some data on a Level if the data does n...
const RCP< const FactoryBase > GetDefaultFactory(const std::string &varName) const
const RCP< const FactoryBase > SetAndReturnDefaultFactory(const std::string &varName, const RCP< const FactoryBase > &factory) const
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Set Factory.
bool hasFactory(const std::string &varName) const
Check.
const RCP< const FactoryBase > GetFactory(const std::string &varName) const
Get factory associated with a particular data name.
const RCP< FactoryBase > GetFactoryNonConst(const std::string &varName)
Get factory associated with a particular data name (NONCONST version)
Factory for building line detection information.
static const NoFactory * get()
static const RCP< const NoFactory > getRCP()
Static Get() functions.
Factory for generating nullspace.
Factory for building nonzero patterns for energy minimization.
Factory for building coarse matrices.
Factory for building permutation matrix that can be be used to shuffle data (matrices,...
Factory for determing the number of partitions for rebalancing.
Factory for building Smoothed Aggregation prolongators.
Factory for generating a very special nullspace.
Generic Smoother Factory for generating the smoothers of the MG hierarchy.
Factory for building tentative prolongator.
Factory for building restriction operators.
Class that encapsulates external library smoothers.
Factory for building uncoupled aggregates.
Interface to Zoltan library.
Namespace for MueLu classes and methods.
@ Debug
Print additional debugging information.
@ Runtime1
Description of what is happening (more verbose)
std::string toString(const T &what)
Little helper function to convert non-string types to strings.