diff --git a/packages/muelu/src/CMakeLists.txt b/packages/muelu/src/CMakeLists.txt index acf6369d4b9d..8c0a76f2f45b 100644 --- a/packages/muelu/src/CMakeLists.txt +++ b/packages/muelu/src/CMakeLists.txt @@ -50,6 +50,7 @@ INCLUDE_DIRECTORIES(${DIR}/Transfers/Energy-Minimization/Solvers) INCLUDE_DIRECTORIES(${DIR}/Transfers/GeneralGeometric) INCLUDE_DIRECTORIES(${DIR}/Transfers/Generic) INCLUDE_DIRECTORIES(${DIR}/Transfers/Geometric-Interpolation) +INCLUDE_DIRECTORIES(${DIR}/Transfers/Matrix-Free) INCLUDE_DIRECTORIES(${DIR}/Transfers/Petrov-Galerkin-SA) INCLUDE_DIRECTORIES(${DIR}/Transfers/SemiCoarsen) INCLUDE_DIRECTORIES(${DIR}/Transfers/Smoothed-Aggregation) @@ -397,6 +398,7 @@ TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${DIR}/Transfers/Energy-Minimization NOS TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${DIR}/Transfers/Energy-Minimization/Solvers NOSIERRABJAM) TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${DIR}/Transfers/GeneralGeometric NOSIERRABJAM) TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${DIR}/Transfers/Geometric-Interpolation NOSIERRABJAM) +TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${DIR}/Transfers/Matrix-Free NOSIERRABJAM) TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${DIR}/Transfers/Petrov-Galerkin-SA NOSIERRABJAM) TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${DIR}/Transfers/Smoothed-Aggregation NOSIERRABJAM) TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${DIR}/Transfers/User NOSIERRABJAM) diff --git a/packages/muelu/src/Headers/MueLu_UseShortNamesScalar.hpp b/packages/muelu/src/Headers/MueLu_UseShortNamesScalar.hpp index c02e5d38f574..4ae79cd90fd8 100644 --- a/packages/muelu/src/Headers/MueLu_UseShortNamesScalar.hpp +++ b/packages/muelu/src/Headers/MueLu_UseShortNamesScalar.hpp @@ -338,6 +338,12 @@ typedef MueLu::TentativePFactory Tentati #ifdef MUELU_TENTATIVEPFACTORY_KOKKOS_SHORT typedef MueLu::TentativePFactory_kokkos TentativePFactory_kokkos; #endif +#ifdef MUELU_MATRIXFREETENTATIVEP_KOKKOS_SHORT +typedef MueLu::MatrixFreeTentativeP_kokkos MatrixFreeTentativeP_kokkos; +#endif +#ifdef MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_SHORT +typedef MueLu::MatrixFreeTentativePFactory_kokkos MatrixFreeTentativePFactory_kokkos; +#endif #ifdef MUELU_THRESHOLDAFILTERFACTORY_SHORT typedef MueLu::ThresholdAFilterFactory ThresholdAFilterFactory; #endif diff --git a/packages/muelu/src/Interface/CMakeLists.txt b/packages/muelu/src/Interface/CMakeLists.txt index 1a179f30619d..b4f27fb1f2cb 100644 --- a/packages/muelu/src/Interface/CMakeLists.txt +++ b/packages/muelu/src/Interface/CMakeLists.txt @@ -38,6 +38,7 @@ INCLUDE_DIRECTORIES(${DIR}/../Transfers/Energy-Minimization) INCLUDE_DIRECTORIES(${DIR}/../Transfers/Energy-Minimization/Solvers) INCLUDE_DIRECTORIES(${DIR}/../Transfers/GeneralGeometric) INCLUDE_DIRECTORIES(${DIR}/../Transfers/Geometric-Interpolation) +INCLUDE_DIRECTORIES(${DIR}/../Transfers/Matrix-Free) INCLUDE_DIRECTORIES(${DIR}/../Transfers/Smoothed-Aggregation) INCLUDE_DIRECTORIES(${DIR}/../Transfers/Petrov-Galerkin-SA) INCLUDE_DIRECTORIES(${DIR}/../Transfers/User) diff --git a/packages/muelu/src/Interface/MueLu_FactoryFactory_decl.hpp b/packages/muelu/src/Interface/MueLu_FactoryFactory_decl.hpp index 1c5d9e4a75a5..e72814f826e8 100644 --- a/packages/muelu/src/Interface/MueLu_FactoryFactory_decl.hpp +++ b/packages/muelu/src/Interface/MueLu_FactoryFactory_decl.hpp @@ -170,6 +170,7 @@ #include "MueLu_SemiCoarsenPFactory_kokkos.hpp" #include "MueLu_StructuredAggregationFactory_kokkos.hpp" #include "MueLu_TentativePFactory_kokkos.hpp" +#include "MueLu_MatrixFreeTentativePFactory_kokkos.hpp" #include "MueLu_UncoupledAggregationFactory_kokkos.hpp" #endif @@ -320,6 +321,7 @@ namespace MueLu { if (factoryName == "SemiCoarsenPFactory_kokkos") return Build2 (paramList, factoryMapIn, factoryManagersIn); if (factoryName == "StructuredAggregationFactory_kokkos") return Build2 (paramList, factoryMapIn, factoryManagersIn); if (factoryName == "TentativePFactory_kokkos") return Build2 (paramList, factoryMapIn, factoryManagersIn); + if (factoryName == "MatrixFreeTentativePFactory_kokkos") return Build2 (paramList, factoryMapIn, factoryManagersIn); if (factoryName == "UncoupledAggregationFactory_kokkos") return Build2 (paramList, factoryMapIn, factoryManagersIn); #endif diff --git a/packages/muelu/src/Transfers/Matrix-Free/MueLu_MatrixFreeTentativePFactory_kokkos_decl.hpp b/packages/muelu/src/Transfers/Matrix-Free/MueLu_MatrixFreeTentativePFactory_kokkos_decl.hpp new file mode 100644 index 000000000000..fdeb00f175bb --- /dev/null +++ b/packages/muelu/src/Transfers/Matrix-Free/MueLu_MatrixFreeTentativePFactory_kokkos_decl.hpp @@ -0,0 +1,157 @@ +// @HEADER +// +// *********************************************************************** +// +// MueLu: A package for multigrid based preconditioning +// Copyright 2012 Sandia Corporation +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the Corporation nor the names of the +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact +// Jonathan Hu (jhu@sandia.gov) +// Andrey Prokopenko (aprokop@sandia.gov) +// Ray Tuminaro (rstumin@sandia.gov) +// +// *********************************************************************** +// +// @HEADER +#ifndef MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_DECL_HPP +#define MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_DECL_HPP + +#include "MueLu_ConfigDefs.hpp" +#ifdef HAVE_MUELU_KOKKOS_REFACTOR + +#include "MueLu_MatrixFreeTentativePFactory_kokkos_fwd.hpp" + +#include + +#include "Teuchos_ScalarTraits.hpp" + +#include "MueLu_Aggregates_kokkos_fwd.hpp" +#include "MueLu_AmalgamationFactory_kokkos_fwd.hpp" +#include "MueLu_AmalgamationInfo_kokkos_fwd.hpp" +#include "MueLu_Level_fwd.hpp" +#include "MueLu_PerfUtils_fwd.hpp" +#include "MueLu_PFactory.hpp" +#include "MueLu_Utilities_kokkos_fwd.hpp" + +namespace MueLu { + + /*! + @class MatrixFreeTentativePFactory class. + @brief Factory for building the matrix-free tentative restrictor. + + Factory for creating the matrix-free tentative restrictor. Nullspace vectors are split across aggregates so that they + have local support. The vectors with local support are factored via LAPACK QR. The Q becomes the + tentative prolongator, and the R becomes the coarse nullspace. + + Note that the MatrixFreeTentativePFactory also creates the coarse null space vectors, that is, it serves as generating + factory for the Nullspace vectors on the coarse levels. To feed in the near null space vectors on the finest + level one has to use the NullspaceFactory. + + @ingroup MueLuTransferClasses + + ## Input/output of MatrixFreeTentativePFactory ## + + ### User parameters of MatrixFreeTentativePFactory ### + Parameter | type | default | master.xml | validated | requested | description + ----------|------|---------|:----------:|:---------:|:---------:|------------ + Aggregates | Factory | null | | * | * | Generating factory of the aggregates (of type "Aggregates" produced, e.g., by the UncoupledAggregationFactory) + Nullspace | Factory | null | | * | * | Generating factory of the fine nullspace vectors (of type "MultiVector"). In the default case the same instance of the MatrixFreeTentativePFactory is also the generating factory for the null space vectors (on the next coarser levels). Therefore, it is recommended to declare the MatrixFreeTentativePFactory to be the generating factory of the "Nullspace" variable globally using the FactoryManager object! For defining the near null space vectors on the finest level one should use the NullspaceFactory. + UnAmalgamationInfo | Factory | null | | * | * | Generating factory of UnAmalgamationInfo. This data (of type "AmalgamationInfo") is produced by the AmalgamationFactory class. The default option should be fine for most standard cases though. + CoarseMap | Factory | null | | * | * | Generating factory of the coarse map. The map generates the coarse domain map of the prolongation operator. The default choice should be fine as long as you do not wish some offset in the domain map (e.g. for block operators in multiphysics problems). The data is generated by the CoarseMapFactory. + + The * in the @c master.xml column denotes that the parameter is defined in the @c master.xml file.
+ The * in the @c validated column means that the parameter is declared in the list of valid input parameters (see MatrixFreeTentativePFactory::GetValidParameters).
+ The * in the @c requested column states that the data is requested as input with all dependencies (see MatrixFreeTentativePFactory::DeclareInput). + + ### Variables provided by MatrixFreeTentativePFactory ### + + After MatrixFreeTentativePFactory::Build the following data is available (if requested) + + Parameter | generated by | description + ----------|--------------|------------ + | R | MatrixFreeTentativePFactory | Non-smoothed "tentative" prolongation operator (with piece-wise constant transfer operator basis functions) + | Nullspace | MatrixFreeTentativePFactory | Coarse near null space vectors. Please also check the documentation of the NullspaceFactory for the special dependency tree of the "Nullspace" variable throughout all multigrid levels. + */ + template + class MatrixFreeTentativePFactory_kokkos; + + template + class MatrixFreeTentativePFactory_kokkos > : public PFactory { + public: + typedef LocalOrdinal local_ordinal_type; + typedef GlobalOrdinal global_ordinal_type; + typedef typename DeviceType::execution_space execution_space; + typedef Kokkos::RangePolicy range_type; + typedef Kokkos::Compat::KokkosDeviceWrapperNode node_type; + typedef typename Teuchos::ScalarTraits::coordinateType real_type; + + private: + // For compatibility + typedef node_type Node; +#undef MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_SHORT +#include "MueLu_UseShortNames.hpp" + + public: + //! @name Constructors/Destructors. + //@{ + + //! Constructor + MatrixFreeTentativePFactory_kokkos() { } + + //! Destructor. + virtual ~MatrixFreeTentativePFactory_kokkos() { } + //@} + + RCP GetValidParameterList() const; + + //! Input + //@{ + + void DeclareInput(Level& fineLevel, Level& coarseLevel) const; + + //@} + + //! @name Build methods. + //@{ + + void Build (Level& fineLevel, Level& coarseLevel) const; + void BuildP(Level& fineLevel, Level& coarseLevel) const; + + //@} + }; + +} //namespace MueLu + +#define MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_SHORT +#endif // HAVE_MUELU_KOKKOS_REFACTOR +#endif // MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_DECL_HPP diff --git a/packages/muelu/src/Transfers/Matrix-Free/MueLu_MatrixFreeTentativePFactory_kokkos_def.hpp b/packages/muelu/src/Transfers/Matrix-Free/MueLu_MatrixFreeTentativePFactory_kokkos_def.hpp new file mode 100644 index 000000000000..5e5d6ee4a18e --- /dev/null +++ b/packages/muelu/src/Transfers/Matrix-Free/MueLu_MatrixFreeTentativePFactory_kokkos_def.hpp @@ -0,0 +1,141 @@ +// @HEADER +// +// *********************************************************************** +// +// MueLu: A package for multigrid based preconditioning +// Copyright 2012 Sandia Corporation +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the Corporation nor the names of the +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact +// Jonathan Hu (jhu@sandia.gov) +// Andrey Prokopenko (aprokop@sandia.gov) +// Ray Tuminaro (rstumin@sandia.gov) +// +// *********************************************************************** +// +// @HEADER +#ifndef MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_DEF_HPP +#define MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_DEF_HPP + +#ifdef HAVE_MUELU_KOKKOS_REFACTOR + +#include "Kokkos_UnorderedMap.hpp" + +#include "MueLu_MatrixFreeTentativePFactory_kokkos_decl.hpp" + +#include "MueLu_Aggregates_kokkos.hpp" +#include "MueLu_AmalgamationFactory_kokkos.hpp" +#include "MueLu_AmalgamationInfo_kokkos.hpp" +#include "MueLu_CoarseMapFactory_kokkos.hpp" +#include "MueLu_MasterList.hpp" +#include "MueLu_NullspaceFactory_kokkos.hpp" +#include "MueLu_PerfUtils.hpp" +#include "MueLu_Monitor.hpp" +#include "MueLu_MatrixFreeTentativeP_kokkos.hpp" +#include "MueLu_Utilities_kokkos.hpp" + +namespace MueLu { + + template + RCP MatrixFreeTentativePFactory_kokkos>::GetValidParameterList() const { + RCP validParamList = rcp(new ParameterList()); + + validParamList->set< RCP >("A", Teuchos::null, "Generating factory of the matrix A"); + validParamList->set< RCP >("Aggregates", Teuchos::null, "Generating factory of the aggregates"); + validParamList->set< RCP >("Nullspace", Teuchos::null, "Generating factory of the nullspace"); + validParamList->set< RCP >("Scaled Nullspace", Teuchos::null, "Generating factory of the scaled nullspace"); + validParamList->set< RCP >("UnAmalgamationInfo", Teuchos::null, "Generating factory of UnAmalgamationInfo"); + validParamList->set< RCP >("CoarseMap", Teuchos::null, "Generating factory of the coarse map"); + validParamList->set< RCP >("Coordinates", Teuchos::null, "Generating factory of the coordinates"); + + // Make sure we don't recursively validate options for the matrixmatrix kernels + ParameterList norecurse; + norecurse.disableRecursiveValidation(); + validParamList->set ("matrixmatrix: kernel params", norecurse, "MatrixMatrix kernel parameters"); + + return validParamList; + } + + template + void MatrixFreeTentativePFactory_kokkos>::DeclareInput(Level& fineLevel, Level& /* coarseLevel */) const { + + const ParameterList& pL = GetParameterList(); + // NOTE: This guy can only either be 'Nullspace' or 'Scaled Nullspace' or else the validator above will cause issues + std::string nspName = "Nullspace"; + if(pL.isParameter("Nullspace name")) nspName = pL.get("Nullspace name"); + + Input(fineLevel, "Aggregates"); + Input(fineLevel, nspName); + Input(fineLevel, "UnAmalgamationInfo"); + Input(fineLevel, "CoarseMap"); + } + + template + void MatrixFreeTentativePFactory_kokkos>::Build(Level& fineLevel, Level& coarseLevel) const { + return BuildP(fineLevel, coarseLevel); + } + + template + void MatrixFreeTentativePFactory_kokkos>::BuildP(Level& fineLevel, Level& coarseLevel) const { + FactoryMonitor m(*this, "Build", coarseLevel); + + typedef typename Teuchos::ScalarTraits::coordinateType coordinate_type; + typedef Xpetra::MultiVectorFactory RealValuedMultiVectorFactory; + const ParameterList& pL = GetParameterList(); + std::string nspName = "Nullspace"; + if(pL.isParameter("Nullspace name")) nspName = pL.get("Nullspace name"); + + auto aggregates = Get< RCP > (fineLevel, "Aggregates"); + auto amalgInfo = Get< RCP > (fineLevel, "UnAmalgamationInfo"); + auto fineNullspace = Get< RCP > (fineLevel, nspName); + auto coarseMap = Get< RCP > (fineLevel, "CoarseMap"); + Teuchos::RCP fineMap = fineNullspace->getMap(); + + // Matrix-free should never run with aggregates that cross processors + if (aggregates->AggregatesCrossProcessors()) + TEUCHOS_TEST_FOR_EXCEPTION(true,Exceptions::RuntimeError,"MatrixFreeTentativePFactory does not support aggregates that cross processors!"); + + size_t NSDim = fineNullspace->getNumVectors(); + RCP coarseNullspace = MultiVectorFactory::Build(coarseMap, NSDim); + + Teuchos::RCP P = Teuchos::rcp(new MatrixFreeTentativeP_kokkos>(coarseMap, fineMap, aggregates)); + P->apply(*fineNullspace,*coarseNullspace,Teuchos::TRANS,1.0,0.0); // coarse = alpha*R*fine + beta*coarse + + Set(coarseLevel, "Nullspace", coarseNullspace); + Set(coarseLevel, "P", P); + } + +} //namespace MueLu + +#define MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_SHORT +#endif // HAVE_MUELU_KOKKOS_REFACTOR +#endif // MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_DEF_HPP diff --git a/packages/muelu/src/Transfers/Matrix-Free/MueLu_MatrixFreeTentativeP_kokkos_decl.hpp b/packages/muelu/src/Transfers/Matrix-Free/MueLu_MatrixFreeTentativeP_kokkos_decl.hpp new file mode 100644 index 000000000000..ba4b1b768701 --- /dev/null +++ b/packages/muelu/src/Transfers/Matrix-Free/MueLu_MatrixFreeTentativeP_kokkos_decl.hpp @@ -0,0 +1,141 @@ +// @HEADER +// +// *********************************************************************** +// +// MueLu: A package for multigrid based preconditioning +// Copyright 2012 Sandia Corporation +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the Corporation nor the names of the +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact +// Jonathan Hu (jhu@sandia.gov) +// Andrey Prokopenko (aprokop@sandia.gov) +// Ray Tuminaro (rstumin@sandia.gov) +// +// *********************************************************************** +// +// @HEADER +#ifndef MUELU_MATRIXFREETENTATIVEP_KOKKOS_DECL_HPP +#define MUELU_MATRIXFREETENTATIVEP_KOKKOS_DECL_HPP + +#include "MueLu_ConfigDefs.hpp" +#ifdef HAVE_MUELU_KOKKOS_REFACTOR + +#include "MueLu_MatrixFreeTentativeP_kokkos_fwd.hpp" + +#include + +#include "Teuchos_ScalarTraits.hpp" + +#include "MueLu_Aggregates_kokkos_fwd.hpp" +#include "MueLu_PerfUtils_fwd.hpp" +#include "Xpetra_Operator.hpp" +#include "MueLu_Utilities_kokkos_fwd.hpp" + +namespace MueLu { + + /*! + @class MatrixFreeTentativeP class. + @brief Matrix-free tentative restrictor operator. + */ + // template + // class MatrixFreeTentativeP_kokkos; + + template + class MatrixFreeTentativeP_kokkos> : public Xpetra::Operator> { + public: + typedef LocalOrdinal local_ordinal_type; + typedef GlobalOrdinal global_ordinal_type; + typedef typename DeviceType::execution_space execution_space; + typedef Kokkos::RangePolicy range_type; + typedef Kokkos::MDRangePolicy> md_range_type; + typedef Kokkos::Compat::KokkosDeviceWrapperNode node_type; + typedef typename Teuchos::ScalarTraits::coordinateType real_type; + + private: + // For compatibility + typedef node_type Node; +#undef MUELU_MATRIXFREETENTATIVEP_KOKKOS_SHORT +#include "MueLu_UseShortNames.hpp" + + public: + //! @name Constructors/Destructors. + //@{ + + //! Constructor + MatrixFreeTentativeP_kokkos(Teuchos::RCP coarse_map, Teuchos::RCP fine_map, Teuchos::RCP aggregates) + : fine_map_(fine_map), + coarse_map_(coarse_map), + aggregates_(aggregates) + { } + + //! Destructor. + ~MatrixFreeTentativeP_kokkos() = default; + //@} + + // compute the apply operator, Y = alpha*R*X + beta*Y + void apply(const MultiVector &X, MultiVector &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits::one(), Scalar beta=Teuchos::ScalarTraits::zero()) const override; + + // compute the residual + void residual (const MultiVector &X, const MultiVector &B, MultiVector &R) const override; + + // get the range map + Teuchos::RCP getRangeMap() const override { + return fine_map_; + } + + // get the domain map + Teuchos::RCP getDomainMap() const override { + return coarse_map_; + } + + // get the aggregates + Teuchos::RCP getAggregates() const { + return aggregates_; + } + + private: + + // the fine map + const Teuchos::RCP fine_map_; + + // the coarse map + const Teuchos::RCP coarse_map_; + + // the aggregates required for the grid transfer + const Teuchos::RCP aggregates_; + }; + +} //namespace MueLu + +#define MUELU_MATRIXFREETENTATIVEP_KOKKOS_SHORT +#endif // HAVE_MUELU_KOKKOS_REFACTOR +#endif // MUELU_MATRIXFREETENTATIVEP_KOKKOS_DECL_HPP diff --git a/packages/muelu/src/Transfers/Matrix-Free/MueLu_MatrixFreeTentativeP_kokkos_def.hpp b/packages/muelu/src/Transfers/Matrix-Free/MueLu_MatrixFreeTentativeP_kokkos_def.hpp new file mode 100644 index 000000000000..2277e38dad60 --- /dev/null +++ b/packages/muelu/src/Transfers/Matrix-Free/MueLu_MatrixFreeTentativeP_kokkos_def.hpp @@ -0,0 +1,124 @@ +// @HEADER +// +// *********************************************************************** +// +// MueLu: A package for multigrid based preconditioning +// Copyright 2012 Sandia Corporation +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the Corporation nor the names of the +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact +// Jonathan Hu (jhu@sandia.gov) +// Andrey Prokopenko (aprokop@sandia.gov) +// Ray Tuminaro (rstumin@sandia.gov) +// +// *********************************************************************** +// +// @HEADER +#ifndef MUELU_MATRIXFREETENTATIVEP_KOKKOS_DEF_HPP +#define MUELU_MATRIXFREETENTATIVEP_KOKKOS_DEF_HPP + +#ifdef HAVE_MUELU_KOKKOS_REFACTOR + +#include "MueLu_MatrixFreeTentativeP_kokkos_decl.hpp" + +#include "MueLu_Aggregates_kokkos.hpp" +#include "MueLu_Level.hpp" +#include "MueLu_MasterList.hpp" +#include "MueLu_PerfUtils.hpp" +#include "MueLu_PFactory.hpp" +#include "MueLu_Monitor.hpp" +#include "MueLu_Utilities_kokkos.hpp" + +#include + +#include "Teuchos_ScalarTraits.hpp" + +namespace MueLu { + + // compute Y = alpha*R*X + beta*Y + template + void MatrixFreeTentativeP_kokkos>::apply(const MultiVector &X, + MultiVector &Y, + Teuchos::ETransp mode, + Scalar alpha, + Scalar beta) const { + + // Step 1: Y*=beta*Y, setup necessary structures + Y.scale(beta); + + // TODO: probably smarter to sqrt the whole aggSizes once, but may be slower if it's done in a separate kernel launch? + typename Aggregates_kokkos::aggregates_sizes_type::const_type aggSizes = aggregates_->ComputeAggregateSizes(); + + auto kokkos_view_X = X.getDeviceLocalView(Xpetra::Access::ReadOnly); + auto kokkos_view_Y = Y.getDeviceLocalView(Xpetra::Access::ReadWrite); + LO numCols = kokkos_view_X.extent(1); + + if(mode == Teuchos::TRANS) { // if we're in restrictor mode + auto vertex2AggId = aggregates_->GetVertex2AggId(); + auto vertex2AggIdView = vertex2AggId->getDeviceLocalView(Xpetra::Access::ReadOnly); + LO numNodes = kokkos_view_X.extent(0); + + // Step 2: Compute Y=Y+alpha*R*X + // recall R*X is an average of X over aggregates + Kokkos::parallel_for("MueLu:MatrixFreeTentativeR_kokkos:apply", md_range_type({0,0},{numCols,numNodes}), + KOKKOS_LAMBDA(const int colIdx, const int NodeIdx) { + LO aggIdx = vertex2AggIdView(NodeIdx,0); + if(aggIdx != -1) { // depending on maps, vertex2agg + Kokkos::atomic_add(&kokkos_view_Y(aggIdx,colIdx),alpha*kokkos_view_X(NodeIdx,colIdx)/Kokkos::sqrt(aggSizes(aggIdx))); + } + }); + } else { // if we're in prolongator mode + const auto vertex2Agg = aggregates_->GetVertex2AggId(); + auto vertex2AggView = vertex2Agg->getDeviceLocalView(Xpetra::Access::ReadOnly); + LO numNodes = kokkos_view_Y.extent(0); + + // Step 2: Compute Y=Y+alpha*P*X + // recall P*X is essentially injection of X, but sum if a node belongs to multiple aggregates + Kokkos::parallel_for("MueLu:MatrixFreeTentativeP_kokkos:apply", md_range_type({0,0},{numCols,numNodes}), + KOKKOS_LAMBDA(const int colIdx, const int fineIdx) { + LO aggIdx = vertex2AggView(fineIdx,0); + kokkos_view_Y(fineIdx,colIdx) += alpha*kokkos_view_X(aggIdx,colIdx)/Kokkos::sqrt(aggSizes(aggIdx)); + }); + } + } + + // I don't care + template + void MatrixFreeTentativeP_kokkos>::residual(const MultiVector &X, const MultiVector &B, MultiVector &R) const { + TEUCHOS_TEST_FOR_EXCEPTION(true,Exceptions::RuntimeError,"MatrixFreeTentativeP residual would make no sense as the operator is not square!"); + } + +} //namespace MueLu + +#define MUELU_MATRIXFREETENTATIVEP_KOKKOS_SHORT +#endif // HAVE_MUELU_KOKKOS_REFACTOR +#endif // MUELU_MATRIXFREETENTATIVEP_KOKKOS_DEF_HPP diff --git a/packages/muelu/src/Utils/ClassList/SC-LO-GO-NO.classList b/packages/muelu/src/Utils/ClassList/SC-LO-GO-NO.classList index 1572e3b9a611..98681afae500 100644 --- a/packages/muelu/src/Utils/ClassList/SC-LO-GO-NO.classList +++ b/packages/muelu/src/Utils/ClassList/SC-LO-GO-NO.classList @@ -110,6 +110,8 @@ SubBlockAFactory TekoSmoother - #ifdef HAVE_MUELU_TEKO TentativePFactory TentativePFactory_kokkos - #if defined(HAVE_MUELU_KOKKOS_REFACTOR) +MatrixFreeTentativeP_kokkos - #if defined(HAVE_MUELU_KOKKOS_REFACTOR) +MatrixFreeTentativePFactory_kokkos - #if defined(HAVE_MUELU_KOKKOS_REFACTOR) ThresholdAFilterFactory ToggleCoordinatesTransferFactory TogglePFactory diff --git a/packages/muelu/src/Utils/ExplicitInstantiation/ETI_SC_LO_GO_NO_classes.cmake b/packages/muelu/src/Utils/ExplicitInstantiation/ETI_SC_LO_GO_NO_classes.cmake index cec2c3ae81a8..181a0fc9789b 100644 --- a/packages/muelu/src/Utils/ExplicitInstantiation/ETI_SC_LO_GO_NO_classes.cmake +++ b/packages/muelu/src/Utils/ExplicitInstantiation/ETI_SC_LO_GO_NO_classes.cmake @@ -104,6 +104,8 @@ APPEND_SET(MUELU_SC_LO_GO_NO_ETI_CLASSES MueLu::SubBlockAFactory ) APPEND_SET(MUELU_SC_LO_GO_NO_ETI_CLASSES MueLu::TekoSmoother-.?ifdef.HAVE_MUELU_TEKO ) APPEND_SET(MUELU_SC_LO_GO_NO_ETI_CLASSES MueLu::TentativePFactory ) APPEND_SET(MUELU_SC_LO_GO_NO_ETI_CLASSES MueLu::TentativePFactory_kokkos-.?if.defined[HAVE_MUELU_KOKKOS_REFACTOR] ) +APPEND_SET(MUELU_SC_LO_GO_NO_ETI_CLASSES MueLu::MatrixFreeTentativeP_kokkos-.?if.defined[HAVE_MUELU_KOKKOS_REFACTOR] ) +APPEND_SET(MUELU_SC_LO_GO_NO_ETI_CLASSES MueLu::MatrixFreeTentativePFactory_kokkos-.?if.defined[HAVE_MUELU_KOKKOS_REFACTOR] ) APPEND_SET(MUELU_SC_LO_GO_NO_ETI_CLASSES MueLu::ThresholdAFilterFactory ) APPEND_SET(MUELU_SC_LO_GO_NO_ETI_CLASSES MueLu::ToggleCoordinatesTransferFactory ) APPEND_SET(MUELU_SC_LO_GO_NO_ETI_CLASSES MueLu::TogglePFactory ) diff --git a/packages/muelu/src/Utils/ForwardDeclaration/MueLu_MatrixFreeTentativePFactory_kokkos_fwd.hpp b/packages/muelu/src/Utils/ForwardDeclaration/MueLu_MatrixFreeTentativePFactory_kokkos_fwd.hpp new file mode 100644 index 000000000000..a84717cff758 --- /dev/null +++ b/packages/muelu/src/Utils/ForwardDeclaration/MueLu_MatrixFreeTentativePFactory_kokkos_fwd.hpp @@ -0,0 +1,63 @@ +// @HEADER +// +// *********************************************************************** +// +// MueLu: A package for multigrid based preconditioning +// Copyright 2012 Sandia Corporation +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the Corporation nor the names of the +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact +// Jonathan Hu (jhu@sandia.gov) +// Andrey Prokopenko (aprokop@sandia.gov) +// Ray Tuminaro (rstumin@sandia.gov) +// +// *********************************************************************** +// +// @HEADER +#ifndef MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_FWD_HPP +#define MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_FWD_HPP + +#include "MueLu_ConfigDefs.hpp" +#if defined(HAVE_MUELU_KOKKOS_REFACTOR) + +namespace MueLu { + template + class MatrixFreeTentativePFactory_kokkos; +} + +#ifndef MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_SHORT +#define MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_SHORT +#endif + +#endif + +#endif // MUELU_MATRIXFREETENTATIVEPFACTORY_KOKKOS_FWD_HPP diff --git a/packages/muelu/src/Utils/ForwardDeclaration/MueLu_MatrixFreeTentativeP_kokkos_fwd.hpp b/packages/muelu/src/Utils/ForwardDeclaration/MueLu_MatrixFreeTentativeP_kokkos_fwd.hpp new file mode 100644 index 000000000000..d4480489e660 --- /dev/null +++ b/packages/muelu/src/Utils/ForwardDeclaration/MueLu_MatrixFreeTentativeP_kokkos_fwd.hpp @@ -0,0 +1,63 @@ +// @HEADER +// +// *********************************************************************** +// +// MueLu: A package for multigrid based preconditioning +// Copyright 2012 Sandia Corporation +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the Corporation nor the names of the +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact +// Jonathan Hu (jhu@sandia.gov) +// Andrey Prokopenko (aprokop@sandia.gov) +// Ray Tuminaro (rstumin@sandia.gov) +// +// *********************************************************************** +// +// @HEADER +#ifndef MUELU_MATRIXFREETENTATIVEP_KOKKOS_FWD_HPP +#define MUELU_MATRIXFREETENTATIVEP_KOKKOS_FWD_HPP + +#include "MueLu_ConfigDefs.hpp" +#if defined(HAVE_MUELU_KOKKOS_REFACTOR) + +namespace MueLu { + template + class MatrixFreeTentativeP_kokkos; +} + +#ifndef MUELU_MATRIXFREETENTATIVEP_KOKKOS_SHORT +#define MUELU_MATRIXFREETENTATIVEP_KOKKOS_SHORT +#endif + +#endif + +#endif // MUELU_MATRIXFREETENTATIVEP_KOKKOS_FWD_HPP diff --git a/packages/muelu/test/unit_tests_kokkos/CMakeLists.txt b/packages/muelu/test/unit_tests_kokkos/CMakeLists.txt index bd350a9c93dd..50d98c74d9b9 100644 --- a/packages/muelu/test/unit_tests_kokkos/CMakeLists.txt +++ b/packages/muelu/test/unit_tests_kokkos/CMakeLists.txt @@ -3,6 +3,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/utils) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../src) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../src/Transfers) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../src/Transfers/BlockedTransfers) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../src/Transfers/Matrix-Free) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../src/Smoothers) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../src/Smoothers/BlockedSmoothers) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../gallery) @@ -22,6 +23,7 @@ APPEND_SET(SOURCES CoarseMapFactory_kokkos.cpp IndexManager_kokkos.cpp LWGraph_kokkos.cpp + MatrixFree_kokkos.cpp MueLu_TestHelpers_kokkos.cpp MueLu_UnitTests_kokkos.cpp NotayAggregationFactory.cpp diff --git a/packages/muelu/test/unit_tests_kokkos/MatrixFree_kokkos.cpp b/packages/muelu/test/unit_tests_kokkos/MatrixFree_kokkos.cpp new file mode 100644 index 000000000000..7813c73d8942 --- /dev/null +++ b/packages/muelu/test/unit_tests_kokkos/MatrixFree_kokkos.cpp @@ -0,0 +1,531 @@ +// @HEADER +// +// *********************************************************************** +// +// MueLu: A package for multigrid based preconditioning +// Copyright 2012 Sandia Corporation +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the Corporation nor the names of the +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact +// Jonathan Hu (jhu@sandia.gov) +// Andrey Prokopenko (aprokop@sandia.gov) +// Ray Tuminaro (rstumin@sandia.gov) +// +// *********************************************************************** +// +// @HEADER +#include +#include + +#include +#include + +#include "MueLu_TestHelpers_kokkos.hpp" +#include "MueLu_Version.hpp" + +#include "MueLu_AmalgamationFactory_kokkos.hpp" +#include "MueLu_CoalesceDropFactory_kokkos.hpp" +#include "MueLu_CoarseMapFactory_kokkos.hpp" +#include "MueLu_TentativePFactory_kokkos.hpp" +#include "MueLu_MatrixFreeTentativePFactory_kokkos.hpp" +#include "MueLu_UncoupledAggregationFactory_kokkos.hpp" +#include "MueLu_NullspaceFactory_kokkos.hpp" + +namespace MueLuTests { + + TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(MatrixFreeTentativePFactory_kokkos, Constructor, Scalar, LocalOrdinal, GlobalOrdinal, Node) + { +#include "MueLu_UseShortNames.hpp" + MUELU_TESTING_SET_OSTREAM; + MUELU_TESTING_LIMIT_SCOPE(Scalar,GlobalOrdinal,NO); + if (TestHelpers_kokkos::Parameters::getLib() == Xpetra::UseEpetra) { + out << "skipping test for linAlgebra==UseEpetra" << std::endl; + return; + } + out << "version: " << MueLu::Version() << std::endl; + + RCP MFtentPFact = rcp(new MatrixFreeTentativePFactory_kokkos); + TEST_EQUALITY(MFtentPFact != Teuchos::null, true); + } + + TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(MatrixFreeTentativePFactory_kokkos, MakeTentative, Scalar, LocalOrdinal, GlobalOrdinal, Node) + { +#include "MueLu_UseShortNames.hpp" + MUELU_TESTING_SET_OSTREAM; + MUELU_TESTING_LIMIT_SCOPE(SC,GO,NO); + + using STS = Teuchos::ScalarTraits; + using magnitude_type = typename Teuchos::ScalarTraits::magnitudeType; + using TMT = Teuchos::ScalarTraits; + + if (TestHelpers_kokkos::Parameters::getLib() == Xpetra::UseEpetra) { + out << "skipping test for linAlgebra==UseEpetra" << std::endl; + return; + } + + RCP > comm = Teuchos::DefaultComm::getComm(); + + out << "version: " << MueLu::Version() << std::endl; + out << "Test with user-supplied nullspace" << std::endl; + + Level fineLevel, coarseLevel; + TestHelpers_kokkos::TestFactory::createTwoLevelHierarchy(fineLevel, coarseLevel); + + fineLevel .SetFactoryManager(Teuchos::null); // factory manager is not used on this test + coarseLevel.SetFactoryManager(Teuchos::null); + + RCP A = TestHelpers_kokkos::TestFactory::Build1DPoisson(199); + fineLevel.Request("A"); + fineLevel.Set ("A", A); + + // Only one NS vector -> exercises manual orthogonalization + LO NSdim = 1; + RCP nullSpace = MultiVectorFactory::Build(A->getRowMap(), NSdim); + nullSpace->putScalar(1.0); + fineLevel.Set("Nullspace", nullSpace); + + RCP amalgFact = rcp(new AmalgamationFactory_kokkos()); + + RCP dropFact = rcp(new CoalesceDropFactory_kokkos()); + dropFact->SetFactory("UnAmalgamationInfo", amalgFact); + + RCP aggFact = rcp(new UncoupledAggregationFactory_kokkos()); + ParameterList aggParams; + aggParams.set("aggregation: ordering", "natural"); + aggParams.set("aggregation: deterministic", true); + aggParams.set("aggregation: min agg size", 3); + aggParams.set("aggregation: max selected neighbors", 0); + aggFact->SetParameterList(aggParams); + aggFact->SetFactory("DofsPerNode", dropFact); + aggFact->SetFactory("Graph", dropFact); + + RCP coarseMapFact = rcp(new CoarseMapFactory_kokkos()); + coarseMapFact->SetFactory("Aggregates", aggFact); + + RCP MFTentativePFact = rcp(new MatrixFreeTentativePFactory_kokkos()); + MFTentativePFact->SetFactory("Aggregates", aggFact); + MFTentativePFact->SetFactory("UnAmalgamationInfo", amalgFact); + MFTentativePFact->SetFactory("CoarseMap", coarseMapFact); + + coarseLevel.Request("P", MFTentativePFact.get()); // request Ptent + coarseLevel.Request("Nullspace", MFTentativePFact.get()); + coarseLevel.Request(*MFTentativePFact); + MFTentativePFact->Build(fineLevel, coarseLevel); + + RCP Ptent; + coarseLevel.Get("P", Ptent, MFTentativePFact.get()); + + RCP coarseNullspace = coarseLevel.Get >("Nullspace", MFTentativePFact.get()); + + // Check interpolation by computing ||fineNS - P*coarseNS|| + // PtN = P*coarseNS + RCP PtN = MultiVectorFactory::Build(Ptent->getRangeMap(), NSdim); + Ptent->apply(*coarseNullspace, *PtN, Teuchos::NO_TRANS, 1.0, 0.0); + + RCP diff = MultiVectorFactory::Build(A->getRowMap(), NSdim); + diff->putScalar(0.0); + + coarseLevel.Release("P", MFTentativePFact.get()); // release Ptent + coarseLevel.Release("Nullspace", MFTentativePFact.get()); + + // diff = fineNS - PtN = fineNS - P*coarseNS + diff->update(1.0, *nullSpace, -1.0, *PtN, 0.0); + + Array::magnitudeType> norms(NSdim); + diff->norm2(norms); + for (LO i = 0; i < NSdim; ++i) { + out << "||diff_" << i << "||_2 = " << norms[i] << std::endl; + TEST_COMPARE_CONST(norms[i], <, 100*TMT::eps()); + } + + } // MakeTentative + + TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(MatrixFreeTentativePFactory_kokkos, MakeTentativeVectorBasedUsingDefaultNullspace, Scalar, LocalOrdinal, GlobalOrdinal, Node) + { +# include "MueLu_UseShortNames.hpp" + MUELU_TESTING_SET_OSTREAM; + MUELU_TESTING_LIMIT_SCOPE(SC,GO,NO); + + using STS = Teuchos::ScalarTraits; + using magnitude_type = typename Teuchos::ScalarTraits::magnitudeType; + using TMT = Teuchos::ScalarTraits; + + if (TestHelpers_kokkos::Parameters::getLib() == Xpetra::UseEpetra) { + out << "skipping test for linAlgebra==UseEpetra" << std::endl; + return; + } + + out << "version: " << MueLu::Version() << std::endl; + out << "Test when nullspace isn't supplied by user" << std::endl; + + Level fineLevel, coarseLevel; + TestHelpers_kokkos::TestFactory::createTwoLevelHierarchy(fineLevel, coarseLevel); + + auto A = TestHelpers_kokkos::TestFactory::Build1DPoisson(200); + + A->SetFixedBlockSize(2); + + fineLevel.Set("A", A); + + auto amalgFact = rcp(new AmalgamationFactory_kokkos()); + + auto dropFact = rcp(new CoalesceDropFactory_kokkos()); + dropFact->SetFactory("UnAmalgamationInfo", amalgFact); + + auto aggFact = rcp(new UncoupledAggregationFactory_kokkos()); + ParameterList aggParams; + aggParams.set("aggregation: ordering", "natural"); + aggParams.set("aggregation: deterministic", true); + aggParams.set("aggregation: min agg size", 3); + aggParams.set("aggregation: max selected neighbors", 0); + aggFact->SetParameterList(aggParams); + aggFact->SetFactory("DofsPerNode", dropFact); + aggFact->SetFactory("Graph", dropFact); + + auto coarseMapFact = rcp(new CoarseMapFactory_kokkos()); + coarseMapFact->SetFactory("Aggregates", aggFact); + + auto MFTentativePFact = rcp(new MatrixFreeTentativePFactory_kokkos()); + MFTentativePFact->SetFactory("Aggregates", aggFact); + MFTentativePFact->SetFactory("UnAmalgamationInfo", amalgFact); + MFTentativePFact->SetFactory("CoarseMap", coarseMapFact); + + + coarseLevel.Request("P",MFTentativePFact.get()); // request Ptent + coarseLevel.Request("Nullspace", MFTentativePFact.get()); // request coarse nullspace + coarseLevel.Request(*MFTentativePFact); + MFTentativePFact->Build(fineLevel,coarseLevel); + + RCP Ptent; + coarseLevel.Get("P",Ptent,MFTentativePFact.get()); + + auto coarseNullspace = coarseLevel.Get >("Nullspace", MFTentativePFact.get()); + + size_t NSdim = coarseNullspace->getNumVectors(); + TEST_EQUALITY(NSdim, 2); + + //coarseNullspace->describe(out, Teuchos::VERB_EXTREME); + + // Check interpolation by computing ||fineNS - P*coarseNS|| + auto PtN = MultiVectorFactory::Build(Ptent->getRangeMap(), NSdim); + //Ptent->apply(*coarseNullspace, *PtN, Teuchos::NO_TRANS, 1.0, 0.0); // TODO: don't support strides :) + + auto diff = MultiVectorFactory::Build(A->getRowMap(), NSdim); + diff->putScalar(0.0); + + coarseLevel.Release("P", MFTentativePFact.get()); // release Ptent + coarseLevel.Release("Nullspace", MFTentativePFact.get()); + + auto nspFact = Teuchos::rcp(new NullspaceFactory_kokkos()); + fineLevel.Request("Nullspace",nspFact.get()); + + nspFact->Build(fineLevel); + + auto fineNullspace = fineLevel.Get >("Nullspace", nspFact.get()); + + TEST_EQUALITY(fineNullspace->getNumVectors(), 2); + + // diff = fineNS - (P*coarseNS) + diff->update(1.0, *fineNullspace, -1.0, *PtN, 0.0); + + Array norms(NSdim); + diff->norm2(norms); + // for (decltype(NSdim) i = 0; i < NSdim; ++i) + // TEST_COMPARE_CONST(norms[i], <, 100*TMT::eps()); + } + + TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(MatrixFreeTentativePFactory_kokkos, MakeTentativeUsingDefaultNullspace, Scalar, LocalOrdinal, GlobalOrdinal, Node) + { +# include "MueLu_UseShortNames.hpp" + MUELU_TESTING_SET_OSTREAM; + MUELU_TESTING_LIMIT_SCOPE(SC,GO,NO); + + using STS = Teuchos::ScalarTraits; + using magnitude_type = typename Teuchos::ScalarTraits::magnitudeType; + using TMT = Teuchos::ScalarTraits; + + if (TestHelpers_kokkos::Parameters::getLib() == Xpetra::UseEpetra) { + out << "skipping test for linAlgebra==UseEpetra" << std::endl; + return; + } + + out << "version: " << MueLu::Version() << std::endl; + out << "Test when nullspace isn't supplied by user" << std::endl; + + Level fineLevel, coarseLevel; + TestHelpers_kokkos::TestFactory::createTwoLevelHierarchy(fineLevel, coarseLevel); + + auto A = TestHelpers_kokkos::TestFactory::Build1DPoisson(199); + + fineLevel.Set("A", A); + + auto amalgFact = rcp(new AmalgamationFactory_kokkos()); + + auto dropFact = rcp(new CoalesceDropFactory_kokkos()); + dropFact->SetFactory("UnAmalgamationInfo", amalgFact); + + auto aggFact = rcp(new UncoupledAggregationFactory_kokkos()); + ParameterList aggParams; + aggParams.set("aggregation: ordering", "natural"); + aggParams.set("aggregation: deterministic", true); + aggParams.set("aggregation: min agg size", 3); + aggParams.set("aggregation: max selected neighbors", 0); + aggFact->SetParameterList(aggParams); + aggFact->SetFactory("DofsPerNode", dropFact); + aggFact->SetFactory("Graph", dropFact); + + auto coarseMapFact = rcp(new CoarseMapFactory_kokkos()); + coarseMapFact->SetFactory("Aggregates", aggFact); + + auto MFTentativePFact = rcp(new MatrixFreeTentativePFactory_kokkos()); + MFTentativePFact->SetFactory("Aggregates", aggFact); + MFTentativePFact->SetFactory("UnAmalgamationInfo", amalgFact); + MFTentativePFact->SetFactory("CoarseMap", coarseMapFact); + + + coarseLevel.Request("P",MFTentativePFact.get()); // request Ptent + coarseLevel.Request("Nullspace", MFTentativePFact.get()); // request coarse nullspace + coarseLevel.Request(*MFTentativePFact); + MFTentativePFact->Build(fineLevel,coarseLevel); + + RCP Ptent; + coarseLevel.Get("P",Ptent,MFTentativePFact.get()); + + auto coarseNullspace = coarseLevel.Get >("Nullspace",MFTentativePFact.get()); + + coarseLevel.Release("P",MFTentativePFact.get()); // release Ptent + coarseLevel.Release("Nullspace",MFTentativePFact.get()); // release coarse nullspace + + //grab default fine level nullspace (vector of all ones) + auto nullSpace = MultiVectorFactory::Build(A->getRowMap(), 1); + nullSpace->putScalar(1.0); + + //check interpolation + LO NSdim = 1; + auto PtN = MultiVectorFactory::Build(A->getRowMap(),NSdim); + Ptent->apply(*coarseNullspace,*PtN,Teuchos::NO_TRANS,1.0,0.0); + + auto diff = MultiVectorFactory::Build(A->getRowMap(),NSdim); + diff->putScalar(0.0); + + //diff = fineNS + (-1.0)*(P*coarseNS) + 0*diff + diff->update(1.0,*nullSpace,-1.0,*PtN,0.0); + + Teuchos::Array norms(NSdim); + diff->norm2(norms); + for (LO i=0; i; + using magnitude_type = typename Teuchos::ScalarTraits::magnitudeType; + using TMT = Teuchos::ScalarTraits; + + if (TestHelpers_kokkos::Parameters::getLib() == Xpetra::UseEpetra) { + out << "skipping test for linAlgebra==UseEpetra" << std::endl; + return; + } + + RCP > comm = Teuchos::DefaultComm::getComm(); + + out << "version: " << MueLu::Version() << std::endl; + out << "Test matvec speed in matrix and matrix-free versions and compare results" << std::endl; + + unsigned int numMatVecs = 100; + + RCP A = TestHelpers_kokkos::TestFactory::Build1DPoisson(199); + RCP X = MultiVectorFactory::Build(A->getDomainMap(), 1); + RCP Xcoarse; + RCP MFXcoarse; + RCP diff; + X->randomize(); + + // Matrix version + { + Level fineLevel, coarseLevel; + TestHelpers_kokkos::TestFactory::createTwoLevelHierarchy(fineLevel, coarseLevel); + + fineLevel .SetFactoryManager(Teuchos::null); // factory manager is not used on this test + coarseLevel.SetFactoryManager(Teuchos::null); + fineLevel.Request("A"); + fineLevel.Set ("A", A); + + // Only one NS vector -> exercises manual orthogonalization + LO NSdim = 1; + RCP nullSpace = MultiVectorFactory::Build(A->getRowMap(), NSdim); + nullSpace->putScalar(1.0); + fineLevel.Set("Nullspace", nullSpace); + + RCP amalgFact = rcp(new AmalgamationFactory_kokkos()); + + RCP dropFact = rcp(new CoalesceDropFactory_kokkos()); + dropFact->SetFactory("UnAmalgamationInfo", amalgFact); + + RCP aggFact = rcp(new UncoupledAggregationFactory_kokkos()); + ParameterList aggParams; + aggParams.set("aggregation: ordering", "natural"); + aggParams.set("aggregation: deterministic", true); + aggParams.set("aggregation: min agg size", 3); + aggParams.set("aggregation: max selected neighbors", 0); + aggFact->SetParameterList(aggParams); + aggFact->SetFactory("DofsPerNode", dropFact); + aggFact->SetFactory("Graph", dropFact); + + RCP coarseMapFact = rcp(new CoarseMapFactory_kokkos()); + coarseMapFact->SetFactory("Aggregates", aggFact); + + RCP TentativePFact = rcp(new TentativePFactory_kokkos()); + TentativePFact->SetFactory("Aggregates", aggFact); + TentativePFact->SetFactory("UnAmalgamationInfo", amalgFact); + TentativePFact->SetFactory("CoarseMap", coarseMapFact); + + coarseLevel.Request("P", TentativePFact.get()); // request Ptent + coarseLevel.Request("Nullspace", TentativePFact.get()); + coarseLevel.Request(*TentativePFact); + TentativePFact->Build(fineLevel, coarseLevel); + + RCP Ptent; + coarseLevel.Get("P", Ptent, TentativePFact.get()); + Xcoarse = MultiVectorFactory::Build(Ptent->getDomainMap(),1); + Ptent->apply(*X,*Xcoarse,Teuchos::TRANS); + + RCP coarseNullspace = coarseLevel.Get >("Nullspace", TentativePFact.get()); + RCP PtN = MultiVectorFactory::Build(Ptent->getRangeMap(), NSdim); + + // warm-up apply operations + for(unsigned int i=0; i<5; ++i) + Ptent->apply(*coarseNullspace, *PtN, Teuchos::NO_TRANS, 1.0, 0.0); + + { + RCP tm = rcp(new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer("MatVec original"))); + for(unsigned int i=0; iapply(*coarseNullspace, *PtN, Teuchos::NO_TRANS, 1.0, 0.0); + } + } + + // Matrix-free version + { + Level fineLevel, coarseLevel; + TestHelpers_kokkos::TestFactory::createTwoLevelHierarchy(fineLevel, coarseLevel); + + fineLevel .SetFactoryManager(Teuchos::null); // factory manager is not used on this test + coarseLevel.SetFactoryManager(Teuchos::null); + fineLevel.Request("A"); + fineLevel.Set ("A", A); + + // Only one NS vector -> exercises manual orthogonalization + LO NSdim = 1; + RCP nullSpace = MultiVectorFactory::Build(A->getRowMap(), NSdim); + nullSpace->putScalar(1.0); + fineLevel.Set("Nullspace", nullSpace); + + RCP amalgFact = rcp(new AmalgamationFactory_kokkos()); + + RCP dropFact = rcp(new CoalesceDropFactory_kokkos()); + dropFact->SetFactory("UnAmalgamationInfo", amalgFact); + + RCP aggFact = rcp(new UncoupledAggregationFactory_kokkos()); + ParameterList aggParams; + aggParams.set("aggregation: ordering", "natural"); + aggParams.set("aggregation: deterministic", true); + aggParams.set("aggregation: min agg size", 3); + aggParams.set("aggregation: max selected neighbors", 0); + aggFact->SetParameterList(aggParams); + aggFact->SetFactory("DofsPerNode", dropFact); + aggFact->SetFactory("Graph", dropFact); + + RCP coarseMapFact = rcp(new CoarseMapFactory_kokkos()); + coarseMapFact->SetFactory("Aggregates", aggFact); + + RCP MFTentativePFact = rcp(new MatrixFreeTentativePFactory_kokkos()); + MFTentativePFact->SetFactory("Aggregates", aggFact); + MFTentativePFact->SetFactory("UnAmalgamationInfo", amalgFact); + MFTentativePFact->SetFactory("CoarseMap", coarseMapFact); + + coarseLevel.Request("P", MFTentativePFact.get()); // request Ptent + coarseLevel.Request("Nullspace", MFTentativePFact.get()); + coarseLevel.Request(*MFTentativePFact); + MFTentativePFact->Build(fineLevel, coarseLevel); + + RCP MFPtent; + coarseLevel.Get("P", MFPtent, MFTentativePFact.get()); + MFXcoarse = MultiVectorFactory::Build(MFPtent->getDomainMap(),1); + MFPtent->apply(*X,*MFXcoarse,Teuchos::TRANS); + + RCP coarseNullspace = coarseLevel.Get >("Nullspace", MFTentativePFact.get()); + RCP PtN = MultiVectorFactory::Build(MFPtent->getRangeMap(), NSdim); + // warm-up apply operations + for(unsigned int i=0; i<5; ++i) + MFPtent->apply(*coarseNullspace, *PtN, Teuchos::NO_TRANS, 1.0, 0.0); + + { + RCP tm = rcp(new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer("MatVec matrix-free"))); + for(unsigned int i=0; iapply(*coarseNullspace, *PtN, Teuchos::NO_TRANS, 1.0, 0.0); + } + + // need scope + diff = MultiVectorFactory::Build(MFPtent->getDomainMap(), 1); + diff->putScalar(0.0); + } + + Teuchos::TimeMonitor::summarize(A->getRowMap()->getComm().ptr(), std::cout, false, true, false, Teuchos::Union, "", true); + Teuchos::TimeMonitor::zeroOutTimers(); + + // Compare Xcoarse and MFXcoarse (diff = Xcoarse - MFXcoarse + 0*diff) + diff->update(1.0, *Xcoarse, -1.0, *MFXcoarse, 0.0); + Array::magnitudeType> norms(1); + diff->norm2(norms); + out << "||diff||_2 = " << norms[0] << std::endl; + TEST_COMPARE_CONST(norms[0], <, 100*TMT::eps()); + + } // MatrixVsMatrixFree + +#define MUELU_ETI_GROUP(SC, LO, GO, NO) \ + TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(MatrixFreeTentativePFactory_kokkos, Constructor, SC, LO, GO, NO) \ + TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(MatrixFreeTentativePFactory_kokkos, MakeTentative, SC, LO, GO, NO) \ + TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(MatrixFreeTentativePFactory_kokkos, MakeTentativeUsingDefaultNullspace, SC, LO, GO, NO) \ + TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(MatrixFreeTentativePFactory_kokkos, MatrixVsMatrixFree, SC, LO, GO, NO) + + + +#include + +} // namespace MueLuTests diff --git a/packages/muelu/test/unit_tests_kokkos/TentativePFactory_kokkos.cpp b/packages/muelu/test/unit_tests_kokkos/TentativePFactory_kokkos.cpp index abd4e9027c1d..a1cacd18166f 100644 --- a/packages/muelu/test/unit_tests_kokkos/TentativePFactory_kokkos.cpp +++ b/packages/muelu/test/unit_tests_kokkos/TentativePFactory_kokkos.cpp @@ -131,11 +131,11 @@ namespace MueLuTests { RCP Ptent; coarseLevel.Get("P",Ptent,TentativePFact.get()); - RCP coarseNullSpace = coarseLevel.Get >("Nullspace", TentativePFact.get()); + RCP coarseNullspace = coarseLevel.Get >("Nullspace", TentativePFact.get()); //check interpolation RCP PtN = MultiVectorFactory::Build(Ptent->getRangeMap(),NSdim); - Ptent->apply(*coarseNullSpace,*PtN,Teuchos::NO_TRANS,1.0,0.0); + Ptent->apply(*coarseNullspace,*PtN,Teuchos::NO_TRANS,1.0,0.0); RCP diff = MultiVectorFactory::Build(A->getRowMap(),NSdim); diff->putScalar(0.0); @@ -153,8 +153,8 @@ namespace MueLuTests { TEST_COMPARE_CONST(norms[i], <, 100*TMT::eps()); } - Teuchos::ArrayRCP col1 = coarseNullSpace->getData(0); - Teuchos::ArrayRCP col2 = coarseNullSpace->getData(1); + Teuchos::ArrayRCP col1 = coarseNullspace->getData(0); + Teuchos::ArrayRCP col2 = coarseNullspace->getData(1); TEST_EQUALITY(col1.size() == col2.size(), true); } // MakeTentative Lapack QR @@ -226,11 +226,11 @@ namespace MueLuTests { RCP Ptent; coarseLevel.Get("P", Ptent, TentativePFact.get()); - RCP coarseNullSpace = coarseLevel.Get >("Nullspace", TentativePFact.get()); + RCP coarseNullspace = coarseLevel.Get >("Nullspace", TentativePFact.get()); // Check interpolation by computing ||fineNS - P*coarseNS|| RCP PtN = MultiVectorFactory::Build(Ptent->getRangeMap(), NSdim); - Ptent->apply(*coarseNullSpace, *PtN, Teuchos::NO_TRANS, 1.0, 0.0); + Ptent->apply(*coarseNullspace, *PtN, Teuchos::NO_TRANS, 1.0, 0.0); RCP diff = MultiVectorFactory::Build(A->getRowMap(), NSdim); diff->putScalar(0.0); @@ -262,7 +262,7 @@ namespace MueLuTests { TEST_EQUALITY(PtentTPtent->getGlobalNumEntries(), diagVec->getGlobalLength()); } // MakeTentative - TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(TentativePFactory_kokkos, MakeTentativeVectorBasedUsingDefaultNullSpace, Scalar, LocalOrdinal, GlobalOrdinal, Node) + TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(TentativePFactory_kokkos, MakeTentativeVectorBasedUsingDefaultNullspace, Scalar, LocalOrdinal, GlobalOrdinal, Node) { # include "MueLu_UseShortNames.hpp" MUELU_TESTING_SET_OSTREAM; @@ -320,16 +320,16 @@ namespace MueLuTests { RCP Ptent; coarseLevel.Get("P",Ptent,TentativePFact.get()); - auto coarseNullSpace = coarseLevel.Get >("Nullspace", TentativePFact.get()); + auto coarseNullspace = coarseLevel.Get >("Nullspace", TentativePFact.get()); - size_t NSdim = coarseNullSpace->getNumVectors(); + size_t NSdim = coarseNullspace->getNumVectors(); TEST_EQUALITY(NSdim, 2); - //coarseNullSpace->describe(out, Teuchos::VERB_EXTREME); + //coarseNullspace->describe(out, Teuchos::VERB_EXTREME); // Check interpolation by computing ||fineNS - P*coarseNS|| auto PtN = MultiVectorFactory::Build(Ptent->getRangeMap(), NSdim); - Ptent->apply(*coarseNullSpace, *PtN, Teuchos::NO_TRANS, 1.0, 0.0); + Ptent->apply(*coarseNullspace, *PtN, Teuchos::NO_TRANS, 1.0, 0.0); auto diff = MultiVectorFactory::Build(A->getRowMap(), NSdim); diff->putScalar(0.0); @@ -342,12 +342,12 @@ namespace MueLuTests { nspFact->Build(fineLevel); - auto fineNullSpace = fineLevel.Get >("Nullspace", nspFact.get()); + auto fineNullspace = fineLevel.Get >("Nullspace", nspFact.get()); - TEST_EQUALITY(fineNullSpace->getNumVectors(), 2); + TEST_EQUALITY(fineNullspace->getNumVectors(), 2); // diff = fineNS - (P*coarseNS) - diff->update(1.0, *fineNullSpace, -1.0, *PtN, 0.0); + diff->update(1.0, *fineNullspace, -1.0, *PtN, 0.0); Array norms(NSdim); diff->norm2(norms); @@ -365,9 +365,9 @@ namespace MueLuTests { if (STS::name().find("complex") == std::string::npos) //skip check for Scalar=complex TEST_FLOATING_EQUALITY(STS::magnitude(diagVec->meanValue()), TMT::one(), 100*TMT::eps()); TEST_EQUALITY(PtentTPtent->getGlobalNumEntries(), diagVec->getGlobalLength()); - } // MakeTentativeVectorBasedUsingDefaultNullSpace + } // MakeTentativeVectorBasedUsingDefaultNullspace - TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(TentativePFactory_kokkos, MakeTentativeUsingDefaultNullSpace, Scalar, LocalOrdinal, GlobalOrdinal, Node) + TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(TentativePFactory_kokkos, MakeTentativeUsingDefaultNullspace, Scalar, LocalOrdinal, GlobalOrdinal, Node) { # include "MueLu_UseShortNames.hpp" MUELU_TESTING_SET_OSTREAM; @@ -424,7 +424,7 @@ namespace MueLuTests { RCP Ptent; coarseLevel.Get("P",Ptent,TentativePFact.get()); - auto coarseNullSpace = coarseLevel.Get >("Nullspace",TentativePFact.get()); + auto coarseNullspace = coarseLevel.Get >("Nullspace",TentativePFact.get()); coarseLevel.Release("P",TentativePFact.get()); // release Ptent coarseLevel.Release("Nullspace",TentativePFact.get()); // release coarse nullspace @@ -436,7 +436,7 @@ namespace MueLuTests { //check interpolation LO NSdim = 1; auto PtN = MultiVectorFactory::Build(A->getRowMap(),NSdim); - Ptent->apply(*coarseNullSpace,*PtN,Teuchos::NO_TRANS,1.0,0.0); + Ptent->apply(*coarseNullspace,*PtN,Teuchos::NO_TRANS,1.0,0.0); auto diff = MultiVectorFactory::Build(A->getRowMap(),NSdim); diff->putScalar(0.0); @@ -449,7 +449,7 @@ namespace MueLuTests { for (LO i=0; i