// @HEADER // ***************************************************************************** // MueLu: A package for multigrid based preconditioning // // Copyright 2012 NTESS and the MueLu contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER /* * MueLu_PermutationFactory_def.hpp * * Created on: Nov 28, 2012 * Author: wiesner */ #ifndef MUELU_PERMUTATIONFACTORY_DEF_HPP_ #define MUELU_PERMUTATIONFACTORY_DEF_HPP_ #include #include #include "MueLu_PermutationFactory_decl.hpp" #include #include // for nDofsPerNode... #include #include #include #include #include #include #include #include #include "MueLu_Level.hpp" #include "MueLu_Monitor.hpp" #include "MueLu_AlgebraicPermutationStrategy.hpp" #include "MueLu_LocalPermutationStrategy.hpp" #undef DEBUG_OUTPUT namespace MueLu { template PermutationFactory::PermutationFactory() {} template PermutationFactory::~PermutationFactory() {} template RCP PermutationFactory::GetValidParameterList() const { RCP validParamList = rcp(new ParameterList()); validParamList->set >("A", Teuchos::null, "Generating factory of the matrix A to be permuted."); validParamList->set("PermutationRowMapName", "", "Name of input row map for which rows the permutation shall be done. (default='')"); validParamList->set >("PermutationRowMapFactory", Teuchos::null, "Generating factory of the input row map for the permutation."); validParamList->set("PermutationStrategy", "Algebraic", "Permutation strategy (default = 'Algebraic', 'Local'"); return validParamList; } template void PermutationFactory::DeclareInput(Level ¤tLevel) const { Input(currentLevel, "A"); const ParameterList &pL = GetParameterList(); std::string mapName = pL.get("PermutationRowMapName"); Teuchos::RCP mapFactory = GetFactory("PermutationRowMapFactory"); if (mapName.length() > 0) { currentLevel.DeclareInput(mapName, mapFactory.get(), this); } } template void PermutationFactory::Build(Level ¤tLevel) const { FactoryMonitor m(*this, "Permutation Factory ", currentLevel); Teuchos::RCP A = Get >(currentLevel, "A"); const ParameterList &pL = GetParameterList(); std::string mapName = pL.get("PermutationRowMapName"); Teuchos::RCP mapFactory = GetFactory("PermutationRowMapFactory"); Teuchos::RCP permRowMap = Teuchos::null; if (mapName.length() > 0) { permRowMap = currentLevel.Get >(mapName, mapFactory.get()); } else { permRowMap = A->getRowMap(); // use full row map of A } std::string strStrategy = pL.get("PermutationStrategy"); if (strStrategy == "Algebraic") { Teuchos::RCP permStrat = Teuchos::rcp(new AlgebraicPermutationStrategy()); permStrat->BuildPermutation(A, permRowMap, currentLevel, this); } else if (strStrategy == "Local") { Teuchos::RCP permStrat = Teuchos::rcp(new LocalPermutationStrategy()); permStrat->BuildPermutation(A, permRowMap, currentLevel, this); } else TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "`PermutationStrategy' has incorrect value (" << strStrategy << ") in input to PermutationFactory." << "Check the documentation for a list of valid choices"); GetOStream(Runtime0) << "Using " << strStrategy << " permutation strategy." << std::endl; } } // namespace MueLu #endif /* MUELU_PERMUTATIONFACTORY_DEF_HPP_ */