46 #ifndef MUELU_FACTORYMANAGER_DEF_HPP
47 #define MUELU_FACTORYMANAGER_DEF_HPP
52 #include "MueLu_AmalgamationFactory.hpp"
53 #include "MueLu_CoalesceDropFactory.hpp"
54 #include "MueLu_CoarseMapFactory.hpp"
55 #include "MueLu_ConstraintFactory.hpp"
56 #include "MueLu_AggregateQualityEstimateFactory.hpp"
57 #include "MueLu_CoordinatesTransferFactory.hpp"
58 #include "MueLu_DirectSolver.hpp"
59 #include "MueLu_LineDetectionFactory.hpp"
62 #include "MueLu_NullspaceFactory.hpp"
63 #include "MueLu_PatternFactory.hpp"
64 #include "MueLu_RAPFactory.hpp"
65 #include "MueLu_RepartitionHeuristicFactory.hpp"
66 #include "MueLu_RepartitionFactory.hpp"
67 #include "MueLu_SaPFactory.hpp"
68 #include "MueLu_ScaledNullspaceFactory.hpp"
69 #include "MueLu_SmootherFactory.hpp"
70 #include "MueLu_TentativePFactory.hpp"
71 #include "MueLu_TransPFactory.hpp"
72 #include "MueLu_TrilinosSmoother.hpp"
73 #include "MueLu_UncoupledAggregationFactory.hpp"
74 #include "MueLu_HybridAggregationFactory.hpp"
75 #include "MueLu_ZoltanInterface.hpp"
76 #include "MueLu_InterfaceMappingTransferFactory.hpp"
77 #include "MueLu_InterfaceAggregationFactory.hpp"
79 #ifdef HAVE_MUELU_KOKKOS_REFACTOR
80 #include "MueLu_AmalgamationFactory_kokkos.hpp"
81 #include "MueLu_CoalesceDropFactory_kokkos.hpp"
82 #include "MueLu_CoarseMapFactory_kokkos.hpp"
83 #include "MueLu_CoordinatesTransferFactory_kokkos.hpp"
84 #include "MueLu_NullspaceFactory_kokkos.hpp"
85 #include "MueLu_SaPFactory_kokkos.hpp"
86 #include "MueLu_TentativePFactory_kokkos.hpp"
87 #include "MueLu_UncoupledAggregationFactory_kokkos.hpp"
95 #ifndef HAVE_MUELU_KOKKOS_REFACTOR
96 #define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \
97 SetAndReturnDefaultFactory(varName, rcp(new oldFactory()));
99 #define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \
100 (!useKokkos_) ? SetAndReturnDefaultFactory(varName, rcp(new oldFactory())) : \
101 SetAndReturnDefaultFactory(varName, rcp(new newFactory()));
104 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
106 factoryTable_[varName] = factory;
109 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
111 if (factoryTable_.count(varName)) {
113 return factoryTable_.find(varName)->second;
117 return GetDefaultFactory(varName);
120 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
122 return Teuchos::rcp_const_cast<
FactoryBase>(GetFactory(varName));
125 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
127 if (factoryTable_.count(varName))
return true;
131 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
133 if (defaultFactoryTable_.count(varName)) {
135 return defaultFactoryTable_.find(varName)->second;
139 if (varName ==
"A")
return SetAndReturnDefaultFactory(varName,
rcp(
new RAPFactory()));
140 if (varName ==
"RAP Pattern")
return GetFactory(
"A");
141 if (varName ==
"AP Pattern")
return GetFactory(
"A");
143 if (varName ==
"P") {
146 #ifdef HAVE_MUELU_KOKKOS_REFACTOR
148 factory =
rcp(
new SaPFactory_kokkos());
152 factory->
SetFactory(
"P", GetFactory(
"Ptent"));
153 return SetAndReturnDefaultFactory(varName, factory);
155 if (varName ==
"Nullspace") {
158 #ifdef HAVE_MUELU_KOKKOS_REFACTOR
160 factory =
rcp(
new NullspaceFactory_kokkos());
164 factory->
SetFactory(
"Nullspace", GetFactory(
"Ptent"));
165 return SetAndReturnDefaultFactory(varName, factory);
169 if (varName ==
"Coordinates")
return GetFactory(
"Ptent");
170 if (varName ==
"Node Comm")
return GetFactory(
"Ptent");
172 if (varName ==
"R")
return SetAndReturnDefaultFactory(varName,
rcp(
new TransPFactory()));
173 #if defined(HAVE_MUELU_ZOLTAN) && defined(HAVE_MPI)
174 if (varName ==
"Partition")
return SetAndReturnDefaultFactory(varName,
rcp(
new ZoltanInterface()));
175 #endif //ifdef HAVE_MPI
177 if (varName ==
"Importer") {
184 if (varName ==
"number of partitions") {
191 if (varName ==
"repartition: heuristic target rows per process")
return GetFactory(
"number of partitions");
198 if (varName ==
"DofsPerNode")
return GetFactory(
"Graph");
199 if (varName ==
"Filtering")
return GetFactory(
"Graph");
200 if (varName ==
"LineDetection_VertLineIds")
return SetAndReturnDefaultFactory(varName,
rcp(
new LineDetectionFactory()));
201 if (varName ==
"LineDetection_Layers")
return GetFactory(
"LineDetection_VertLineIds");
202 if (varName ==
"CoarseNumZLayers")
return GetFactory(
"LineDetection_VertLineIds");
205 if (varName ==
"K")
return GetFactory(
"A");
206 if (varName ==
"M")
return GetFactory(
"A");
207 if (varName ==
"Mdiag")
return GetFactory(
"A");
208 if (varName ==
"cfl-based shift array")
return GetFactory(
"A");
211 if (varName ==
"PreSmoother")
return GetFactory(
"Smoother");
212 if (varName ==
"PostSmoother")
return GetFactory(
"Smoother");
214 if (varName ==
"Ppattern") {
217 return SetAndReturnDefaultFactory(varName, PpFact);
219 if (varName ==
"Constraint")
return SetAndReturnDefaultFactory(varName,
rcp(
new ConstraintFactory()));
221 if (varName ==
"Smoother") {
223 smootherParamList.
set(
"relaxation: type",
"Symmetric Gauss-Seidel");
232 #ifdef HAVE_MUELU_INTREPID2
234 if (varName ==
"pcoarsen: element to node map")
return GetFactory(
"P");
241 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
245 GetOStream(
Runtime1) <<
"Using default factory (" << factory->
ShortClassName() <<
"["<<factory->
GetID()<<
"] "<<
") for building '" << varName <<
"'." << std::endl;
247 defaultFactoryTable_[varName] = factory;
249 return defaultFactoryTable_[varName];
252 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
254 std::map<std::string, RCP<const FactoryBase> >::const_iterator it;
258 fancy <<
"Users factory table (factoryTable_):" << std::endl;
259 for (it = factoryTable_.begin(); it != factoryTable_.end(); it++) {
260 fancy <<
" " << it->first <<
" -> ";
262 else if (!it->second.get()) fancy<<
"NULL";
264 fancy << it->second.get()->ShortClassName()<<
"["<<it->second.get()->GetID()<<
"]";
265 #ifdef HAVE_MUELU_DEBUG
272 fancy <<
"Default factory table (defaultFactoryTable_):" << std::endl;
273 for (it = defaultFactoryTable_.begin(); it != defaultFactoryTable_.end(); it++) {
274 fancy <<
" " << it->first <<
" -> ";
276 else if (!it->second.get()) fancy<<
"NULL";
278 fancy << it->second.get()->ShortClassName()<<
"["<<it->second.get()->GetID()<<
"]";
279 #ifdef HAVE_MUELU_DEBUG
288 #ifdef HAVE_MUELU_DEBUG
289 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
291 std::map<std::string, RCP<const FactoryBase> >::const_iterator it;
293 for (it = factoryTable_.begin(); it != factoryTable_.end(); it++)
294 if (!it->second.is_null())
295 it->second->ResetDebugData();
297 for (it = defaultFactoryTable_.begin(); it != defaultFactoryTable_.end(); it++)
298 if (!it->second.is_null())
299 it->second->ResetDebugData();
304 #undef MUELU_KOKKOS_FACTORY
313 #endif // MUELU_FACTORYMANAGER_DEF_HPP
Generic Smoother Factory for generating the smoothers of the MG hierarchy.
This class specifies the default factory that should generate some data on a Level if the data does n...
Factory for determing the number of partitions for rebalancing.
Factory for generating coarse level map. Used by TentativePFactory.
Class that encapsulates external library smoothers.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Factory for building permutation matrix that can be be used to shuffle data (matrices, vectors) among processes.
Print additional debugging information.
const RCP< const FactoryBase > GetDefaultFactory(const std::string &varName) const
int GetID() const
return unique factory id
bool hasFactory(const std::string &varName) const
Check.
Interface to Zoltan library.This interface provides access to partitioning methods in Zoltan...
const RCP< const FactoryBase > GetFactory(const std::string &varName) const
Get factory associated with a particular data name.
static const NoFactory * get()
Factory for building tentative prolongator.
Class that encapsulates direct solvers. Autoselection of AmesosSmoother or Amesos2Smoother according ...
virtual std::string ShortClassName() const
Return the class name of the object, without template parameters and without namespace.
const RCP< const FactoryBase > SetAndReturnDefaultFactory(const std::string &varName, const RCP< const FactoryBase > &factory) const
Base class for factories (e.g., R, P, and A_coarse).
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Factory for building line detection information.
AmalgamationFactory for subblocks of strided map based amalgamation data.
Factory for building the constraint operator.
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Set Factory.
const RCP< FactoryBase > GetFactoryNonConst(const std::string &varName)
Get factory associated with a particular data name (NONCONST version)
Factory for generating a very special nullspace.
Factory for building aggregates for Lagrange multipliers.
Factory for creating a graph base on a given matrix.
virtual void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)=0
Configuration.
Factory for building nonzero patterns for energy minimization.
#define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory)
Factory for building restriction operators.
Exception throws to report errors in the internal logical of the program.
Description of what is happening (more verbose)
Factory for building coarse matrices.
An factory which assigns each aggregate a quality estimate. Originally developed by Napov and Notay i...
Factory for building Smoothed Aggregation prolongators.
Factory for building uncoupled aggregates.
std::string toString(const T &t)
Factory for generating nullspace.
static const RCP< const NoFactory > getRCP()
Static Get() functions.