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_SmootherFactory.hpp" 68 #include "MueLu_TentativePFactory.hpp" 69 #include "MueLu_TransPFactory.hpp" 70 #include "MueLu_TrilinosSmoother.hpp" 71 #include "MueLu_UncoupledAggregationFactory.hpp" 72 #include "MueLu_HybridAggregationFactory.hpp" 73 #include "MueLu_ZoltanInterface.hpp" 75 #ifdef HAVE_MUELU_KOKKOS_REFACTOR 76 #include "MueLu_CoalesceDropFactory_kokkos.hpp" 77 #include "MueLu_CoarseMapFactory_kokkos.hpp" 78 #include "MueLu_CoordinatesTransferFactory_kokkos.hpp" 79 #include "MueLu_NullspaceFactory_kokkos.hpp" 80 #include "MueLu_SaPFactory_kokkos.hpp" 81 #include "MueLu_TentativePFactory_kokkos.hpp" 82 #include "MueLu_UncoupledAggregationFactory_kokkos.hpp" 90 #ifndef HAVE_MUELU_KOKKOS_REFACTOR 91 #define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \ 92 SetAndReturnDefaultFactory(varName, rcp(new oldFactory())); 94 #define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \ 95 (!useKokkos_) ? SetAndReturnDefaultFactory(varName, rcp(new oldFactory())) : \ 96 SetAndReturnDefaultFactory(varName, rcp(new newFactory())); 99 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
101 factoryTable_[varName] = factory;
104 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
106 if (factoryTable_.count(varName)) {
108 return factoryTable_.find(varName)->second;
112 return GetDefaultFactory(varName);
115 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
117 return Teuchos::rcp_const_cast<
FactoryBase>(GetFactory(varName));
120 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
122 if (factoryTable_.count(varName))
return true;
126 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
128 if (defaultFactoryTable_.count(varName)) {
130 return defaultFactoryTable_.find(varName)->second;
134 if (varName ==
"A")
return SetAndReturnDefaultFactory(varName, rcp(
new RAPFactory()));
135 if (varName ==
"RAP Pattern")
return GetFactory(
"A");
136 if (varName ==
"AP Pattern")
return GetFactory(
"A");
138 if (varName ==
"P") {
140 RCP<Factory> factory;
141 #ifdef HAVE_MUELU_KOKKOS_REFACTOR 143 factory = rcp(
new SaPFactory_kokkos());
147 factory->SetFactory(
"P", GetFactory(
"Ptent"));
148 return SetAndReturnDefaultFactory(varName, factory);
150 if (varName ==
"Nullspace") {
152 RCP<Factory> factory;
153 #ifdef HAVE_MUELU_KOKKOS_REFACTOR 155 factory = rcp(
new NullspaceFactory_kokkos());
159 factory->SetFactory(
"Nullspace", GetFactory(
"Ptent"));
160 return SetAndReturnDefaultFactory(varName, factory);
162 if (varName ==
"Coordinates")
return GetFactory(
"Ptent");
164 if (varName ==
"R")
return SetAndReturnDefaultFactory(varName, rcp(
new TransPFactory()));
165 #if defined(HAVE_MUELU_ZOLTAN) && defined(HAVE_MPI) 166 if (varName ==
"Partition")
return SetAndReturnDefaultFactory(varName, rcp(
new ZoltanInterface()));
167 #endif //ifdef HAVE_MPI 169 if (varName ==
"Importer") {
176 if (varName ==
"number of partitions") {
185 if (varName ==
"UnAmalgamationInfo")
return SetAndReturnDefaultFactory(varName, rcp(
new AmalgamationFactory()));
188 if (varName ==
"DofsPerNode")
return GetFactory(
"Graph");
189 if (varName ==
"Filtering")
return GetFactory(
"Graph");
190 if (varName ==
"LineDetection_VertLineIds")
return SetAndReturnDefaultFactory(varName, rcp(
new LineDetectionFactory()));
191 if (varName ==
"LineDetection_Layers")
return GetFactory(
"LineDetection_VertLineIds");
192 if (varName ==
"CoarseNumZLayers")
return GetFactory(
"LineDetection_VertLineIds");
195 if (varName ==
"K")
return GetFactory(
"A");
196 if (varName ==
"M")
return GetFactory(
"A");
199 if (varName ==
"PreSmoother")
return GetFactory(
"Smoother");
200 if (varName ==
"PostSmoother")
return GetFactory(
"Smoother");
202 if (varName ==
"Ppattern") {
204 PpFact->SetFactory(
"P", GetFactory(
"Ptent"));
205 return SetAndReturnDefaultFactory(varName, PpFact);
207 if (varName ==
"Constraint")
return SetAndReturnDefaultFactory(varName, rcp(
new ConstraintFactory()));
209 if (varName ==
"Smoother") {
210 Teuchos::ParameterList smootherParamList;
211 smootherParamList.set(
"relaxation: type",
"Symmetric Gauss-Seidel");
212 smootherParamList.set(
"relaxation: sweeps", Teuchos::OrdinalTraits<LO>::one());
213 smootherParamList.set(
"relaxation: damping factor", Teuchos::ScalarTraits<Scalar>::one());
216 if (varName ==
"CoarseSolver")
return SetAndReturnDefaultFactory(varName, rcp(
new SmootherFactory(rcp(
new DirectSolver()), Teuchos::null)));
218 #ifdef HAVE_MUELU_INTREPID2 220 if (varName ==
"pcoarsen: element to node map")
return GetFactory(
"P");
223 TEUCHOS_TEST_FOR_EXCEPTION(
true,
MueLu::Exceptions::RuntimeError,
"MueLu::FactoryManager::GetDefaultFactory(): No default factory available for building '" + varName +
"'.");
227 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
229 TEUCHOS_TEST_FOR_EXCEPTION(factory.is_null(),
Exceptions::RuntimeError,
"The default factory for building '" << varName <<
"' is null");
231 GetOStream(
Runtime1) <<
"Using default factory (" << factory->description() <<
") for building '" << varName <<
"'." << std::endl;
233 defaultFactoryTable_[varName] = factory;
235 return defaultFactoryTable_[varName];
238 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
240 std::map<std::string, RCP<const FactoryBase> >::const_iterator it;
242 Teuchos::FancyOStream& fancy = GetOStream(
Debug);
244 fancy <<
"Users factory table (factoryTable_):" << std::endl;
245 for (it = factoryTable_.begin(); it != factoryTable_.end(); it++)
246 fancy <<
" " << it->first <<
" -> " <<
Teuchos::toString(it->second.get()) << std::endl;
248 fancy <<
"Default factory table (defaultFactoryTable_):" << std::endl;
249 for (it = defaultFactoryTable_.begin(); it != defaultFactoryTable_.end(); it++)
250 fancy <<
" " << it->first <<
" -> " <<
Teuchos::toString(it->second.get()) << std::endl;
253 #ifdef HAVE_MUELU_DEBUG 254 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
256 std::map<std::string, RCP<const FactoryBase> >::const_iterator it;
258 for (it = factoryTable_.begin(); it != factoryTable_.end(); it++)
259 if (!it->second.is_null())
260 it->second->ResetDebugData();
262 for (it = defaultFactoryTable_.begin(); it != defaultFactoryTable_.end(); it++)
263 if (!it->second.is_null())
264 it->second->ResetDebugData();
269 #undef MUELU_KOKKOS_FACTORY 278 #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.
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
bool hasFactory(const std::string &varName) const
Check.
Class that encapsulates external library smoothers.
Factory for building permutation matrix that can be be used to shuffle data (matrices, vectors) among processes.
Print additional debugging information.
Namespace for MueLu classes and methods.
Interface to Zoltan library.This interface provides access to partitioning methods in Zoltan...
Factory for building tentative prolongator.
Class that encapsulates direct solvers. Autoselection of AmesosSmoother or Amesos2Smoother according ...
Base class for factories (e.g., R, P, and A_coarse).
const RCP< const FactoryBase > SetAndReturnDefaultFactory(const std::string &varName, const RCP< const FactoryBase > &factory) const
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)
const RCP< const FactoryBase > GetFactory(const std::string &varName) const
Get factory associated with a particular data name.
Factory for creating a graph base on a given matrix.
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.
Factory for building Smoothed Aggregation prolongators.
const RCP< const FactoryBase > GetDefaultFactory(const std::string &varName) const
Factory for building uncoupled aggregates.
Factory for generating nullspace.
static const RCP< const NoFactory > getRCP()
Static Get() functions.