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_AggregateQualityEstimateFactory.hpp" 57 #include "MueLu_CoordinatesTransferFactory.hpp" 58 #include "MueLu_DirectSolver.hpp" 59 #include "MueLu_InitialBlockNumberFactory.hpp" 60 #include "MueLu_LineDetectionFactory.hpp" 63 #include "MueLu_NullspaceFactory.hpp" 64 #include "MueLu_PatternFactory.hpp" 65 #include "MueLu_RAPFactory.hpp" 66 #include "MueLu_RepartitionHeuristicFactory.hpp" 67 #include "MueLu_RepartitionFactory.hpp" 68 #include "MueLu_SaPFactory.hpp" 69 #include "MueLu_ScaledNullspaceFactory.hpp" 70 #include "MueLu_SmootherFactory.hpp" 71 #include "MueLu_TentativePFactory.hpp" 72 #include "MueLu_TransPFactory.hpp" 73 #include "MueLu_TrilinosSmoother.hpp" 74 #include "MueLu_UncoupledAggregationFactory.hpp" 75 #include "MueLu_StructuredAggregationFactory.hpp" 76 #include "MueLu_HybridAggregationFactory.hpp" 77 #include "MueLu_ZoltanInterface.hpp" 78 #include "MueLu_InterfaceMappingTransferFactory.hpp" 79 #include "MueLu_InterfaceAggregationFactory.hpp" 81 #ifdef HAVE_MUELU_KOKKOS_REFACTOR 82 #include "MueLu_AmalgamationFactory_kokkos.hpp" 83 #include "MueLu_CoalesceDropFactory_kokkos.hpp" 84 #include "MueLu_CoarseMapFactory_kokkos.hpp" 85 #include "MueLu_CoordinatesTransferFactory_kokkos.hpp" 86 #include "MueLu_NullspaceFactory_kokkos.hpp" 87 #include "MueLu_SaPFactory_kokkos.hpp" 88 #include "MueLu_TentativePFactory_kokkos.hpp" 89 #include "MueLu_UncoupledAggregationFactory_kokkos.hpp" 97 #ifndef HAVE_MUELU_KOKKOS_REFACTOR 98 #define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \ 99 SetAndReturnDefaultFactory(varName, rcp(new oldFactory())); 101 #define MUELU_KOKKOS_FACTORY(varName, oldFactory, newFactory) \ 102 (!useKokkos_) ? SetAndReturnDefaultFactory(varName, rcp(new oldFactory())) : \ 103 SetAndReturnDefaultFactory(varName, rcp(new newFactory())); 106 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
108 factoryTable_[varName] = factory;
111 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
113 if (factoryTable_.count(varName)) {
115 return factoryTable_.find(varName)->second;
119 return GetDefaultFactory(varName);
122 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
124 return Teuchos::rcp_const_cast<
FactoryBase>(GetFactory(varName));
127 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
129 if (factoryTable_.count(varName))
return true;
133 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
135 if (defaultFactoryTable_.count(varName)) {
137 return defaultFactoryTable_.find(varName)->second;
141 if (varName ==
"A")
return SetAndReturnDefaultFactory(varName, rcp(
new RAPFactory()));
142 if (varName ==
"RAP Pattern")
return GetFactory(
"A");
143 if (varName ==
"AP Pattern")
return GetFactory(
"A");
145 if (varName ==
"P") {
147 RCP<Factory> factory;
148 #ifdef HAVE_MUELU_KOKKOS_REFACTOR 150 factory = rcp(
new SaPFactory_kokkos());
154 factory->SetFactory(
"P", GetFactory(
"Ptent"));
155 return SetAndReturnDefaultFactory(varName, factory);
157 if (varName ==
"Nullspace") {
159 RCP<Factory> factory;
160 #ifdef HAVE_MUELU_KOKKOS_REFACTOR 162 factory = rcp(
new NullspaceFactory_kokkos());
166 factory->SetFactory(
"Nullspace", GetFactory(
"Ptent"));
167 return SetAndReturnDefaultFactory(varName, factory);
169 if (varName ==
"Scaled Nullspace")
return SetAndReturnDefaultFactory(varName, rcp(
new ScaledNullspaceFactory()));
171 if (varName ==
"Coordinates")
return GetFactory(
"Ptent");
172 if (varName ==
"Node Comm")
return GetFactory(
"Ptent");
174 if (varName ==
"R")
return SetAndReturnDefaultFactory(varName, rcp(
new TransPFactory()));
175 #if defined(HAVE_MUELU_ZOLTAN) && defined(HAVE_MPI) 176 if (varName ==
"Partition")
return SetAndReturnDefaultFactory(varName, rcp(
new ZoltanInterface()));
177 #endif //ifdef HAVE_MPI 179 if (varName ==
"Importer") {
186 if (varName ==
"number of partitions") {
193 if (varName ==
"repartition: heuristic target rows per process")
return GetFactory(
"number of partitions");
200 if (varName ==
"DofsPerNode")
return GetFactory(
"Graph");
201 if (varName ==
"Filtering")
return GetFactory(
"Graph");
203 if (varName ==
"LineDetection_VertLineIds")
return SetAndReturnDefaultFactory(varName, rcp(
new LineDetectionFactory()));
204 if (varName ==
"LineDetection_Layers")
return GetFactory(
"LineDetection_VertLineIds");
205 if (varName ==
"CoarseNumZLayers")
return GetFactory(
"LineDetection_VertLineIds");
211 if (varName ==
"K")
return GetFactory(
"A");
212 if (varName ==
"M")
return GetFactory(
"A");
213 if (varName ==
"Mdiag")
return GetFactory(
"A");
214 if (varName ==
"cfl-based shift array")
return GetFactory(
"A");
217 if (varName ==
"PreSmoother")
return GetFactory(
"Smoother");
218 if (varName ==
"PostSmoother")
return GetFactory(
"Smoother");
220 if (varName ==
"Ppattern") {
222 PpFact->SetFactory(
"P", GetFactory(
"Ptent"));
223 return SetAndReturnDefaultFactory(varName, PpFact);
225 if (varName ==
"Constraint")
return SetAndReturnDefaultFactory(varName, rcp(
new ConstraintFactory()));
227 if (varName ==
"Smoother") {
228 Teuchos::ParameterList smootherParamList;
229 smootherParamList.set(
"relaxation: type",
"Symmetric Gauss-Seidel");
230 smootherParamList.set(
"relaxation: sweeps", Teuchos::OrdinalTraits<LO>::one());
231 smootherParamList.set(
"relaxation: damping factor", Teuchos::ScalarTraits<Scalar>::one());
234 if (varName ==
"CoarseSolver")
return SetAndReturnDefaultFactory(varName, rcp(
new SmootherFactory(rcp(
new DirectSolver()), Teuchos::null)));
237 if (varName ==
"CoarseDualNodeID2PrimalNodeID")
return SetAndReturnDefaultFactory(varName, rcp(
new InterfaceAggregationFactory()));
238 #ifdef HAVE_MUELU_INTREPID2 240 if (varName ==
"pcoarsen: element to node map")
return GetFactory(
"P");
243 TEUCHOS_TEST_FOR_EXCEPTION(
true,
MueLu::Exceptions::RuntimeError,
"MueLu::FactoryManager::GetDefaultFactory(): No default factory available for building '" + varName +
"'.");
247 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
249 TEUCHOS_TEST_FOR_EXCEPTION(factory.is_null(),
Exceptions::RuntimeError,
"The default factory for building '" << varName <<
"' is null");
251 GetOStream(
Runtime1) <<
"Using default factory (" << factory->ShortClassName() <<
"["<<factory->GetID()<<
"] "<<
") for building '" << varName <<
"'." << std::endl;
253 defaultFactoryTable_[varName] = factory;
255 return defaultFactoryTable_[varName];
258 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
260 std::map<std::string, RCP<const FactoryBase> >::const_iterator it;
261 Teuchos::FancyOStream& fancy = GetOStream(
Debug);
265 fancy <<
"Users factory table (factoryTable_):" << std::endl;
266 for (it = factoryTable_.begin(); it != factoryTable_.end(); it++) {
267 fancy <<
" " << it->first <<
" -> ";
269 else if (!it->second.get()) fancy<<
"NULL";
271 fancy << it->second.get()->ShortClassName()<<
"["<<it->second.get()->GetID()<<
"]";
272 #ifdef HAVE_MUELU_DEBUG 279 fancy <<
"Default factory table (defaultFactoryTable_):" << std::endl;
280 for (it = defaultFactoryTable_.begin(); it != defaultFactoryTable_.end(); it++) {
281 fancy <<
" " << it->first <<
" -> ";
283 else if (!it->second.get()) fancy<<
"NULL";
285 fancy << it->second.get()->ShortClassName()<<
"["<<it->second.get()->GetID()<<
"]";
286 #ifdef HAVE_MUELU_DEBUG 295 #ifdef HAVE_MUELU_DEBUG 296 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
298 std::map<std::string, RCP<const FactoryBase> >::const_iterator it;
300 for (it = factoryTable_.begin(); it != factoryTable_.end(); it++)
301 if (!it->second.is_null())
302 it->second->ResetDebugData();
304 for (it = defaultFactoryTable_.begin(); it != defaultFactoryTable_.end(); it++)
305 if (!it->second.is_null())
306 it->second->ResetDebugData();
311 #undef MUELU_KOKKOS_FACTORY 320 #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 building aggregates on structured grids.
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.
Class for generating an initial LocalOrdinal-type BlockNumber vector, based on an input paraemter for...
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...
static const NoFactory * get()
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.
Transfer mapping data for interface aggregation to the coarse level.
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 generating a very special nullspace.
Factory for building aggregates for Lagrange multipliers in surface-coupled problems.
Factory for creating a graph based 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.
An factory which assigns each aggregate a quality estimate. Originally developed by Napov and Notay i...
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.