// @HEADER // ***************************************************************************** // MueLu: A package for multigrid based preconditioning // // Copyright 2012 NTESS and the MueLu contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef MUELU_BLOCKEDCOARSEMAPFACTORY_DEF_HPP_ #define MUELU_BLOCKEDCOARSEMAPFACTORY_DEF_HPP_ #include #include #include #include "MueLu_BlockedCoarseMapFactory_decl.hpp" #include "MueLu_Level.hpp" #include "MueLu_Aggregates.hpp" #include "MueLu_Monitor.hpp" #include "MueLu_Factory.hpp" namespace MueLu { template RCP BlockedCoarseMapFactory::GetValidParameterList() const { RCP validParamList = rcp(new ParameterList()); validParamList->set>("Aggregates", Teuchos::null, "Generating factory for aggregates."); validParamList->set>("Nullspace", Teuchos::null, "Generating factory for null space."); validParamList->set>("CoarseMap", Teuchos::null, "Generating factory of previous coarse map. (must be set by user!)."); // do we need this? validParamList->set("Striding info", "{}", "Striding information"); validParamList->set("Strided block id", -1, "Strided block id"); return validParamList; } template void BlockedCoarseMapFactory::DeclareInput(Level ¤tLevel) const { this->Input(currentLevel, "Aggregates"); this->Input(currentLevel, "Nullspace"); // Get CoarseMap from previously defined block RCP prevCoarseMapFact = this->GetFactory("CoarseMap"); TEUCHOS_TEST_FOR_EXCEPTION(prevCoarseMapFact == Teuchos::null, Exceptions::RuntimeError, "MueLu::BlockedCoarseMapFactory::getDomainMapOffset: user did not specify CoarseMap of previous block. Do not forget to set the CoarseMap factory."); currentLevel.DeclareInput("CoarseMap", prevCoarseMapFact.get(), this); } template void BlockedCoarseMapFactory::Build(Level ¤tLevel) const { FactoryMonitor m(*this, "Build", currentLevel); GlobalOrdinal domainGIDOffset = GetDomainGIDOffset(currentLevel); CoarseMapFactory::BuildCoarseMap(currentLevel, domainGIDOffset); } template GlobalOrdinal BlockedCoarseMapFactory::GetDomainGIDOffset( Level ¤tLevel) const { RCP prevCoarseMapFact = this->GetFactory("CoarseMap"); RCP subPDomainMap = currentLevel.Get>("CoarseMap", prevCoarseMapFact.get()); GlobalOrdinal maxGlobalIndex = subPDomainMap->getMaxAllGlobalIndex(); return maxGlobalIndex + Teuchos::ScalarTraits::one(); } } // namespace MueLu #endif /* MUELU_BLOCKEDCOARSEMAPFACTORY_DEF_HPP_ */