// @HEADER // ***************************************************************************** // MueLu: A package for multigrid based preconditioning // // Copyright 2012 NTESS and the MueLu contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef MUELU_NULLSPACEFACTORY_DECL_HPP #define MUELU_NULLSPACEFACTORY_DECL_HPP #include "MueLu_ConfigDefs.hpp" #include "Xpetra_MultiVector_fwd.hpp" #include "MueLu_NullspaceFactory_fwd.hpp" #include "MueLu_Level_fwd.hpp" #include "MueLu_SingleLevelFactoryBase.hpp" namespace MueLu { /*! @class NullspaceFactory class. @brief Factory for generating nullspace The NullspaceFactory is meant to generate a default approximation for the fine level nullspace (Level 0 only). For all other levels it is used only to act as "generating factory" for the "Nullspace", which is actually handled by the TentativePFactory. Constructor: \code{.cpp} NullspaceFactory(const std::string & nspName = "Nullspace") \endcode This constructor uses the variable with the variable nspName on the finest level as null space for the finest multigrid level. Currently, the only accepted names for the null space vectors are "Nullspace" (default) or, in case of multiphysics problems, "Nullspace1" and "Nullspace2" @ingroup MueLuTransferClasses ## Input/output of NullspaceFactory ## ### User parameters of NullspaceFactory ### Parameter | type | default | master.xml | validated | requested | description ----------|------|---------|:----------:|:---------:|:---------:|------------ Fine level nullspace | string | "Nullspace" | | * | * | Name of the variable containing the MultiVector with the near null space vectors on the finest level (level 0) provided by the user. A | Factory | null | | * | * | Generating factory of the matrix A. Note that "A" is only requested, if the user does not provide a fine level null space information and NullspaceFactory is meant to provide a default set of fine level null space vectors. Then, the information of "A" is used to create constant null space vectors compatible with the row map of A. Nullspace | Factory | null | | * | * | Generating factory of the fine nullspace vectors (of type "MultiVector"). In the default case the same instance of the TentativePFactory is also the generating factory for the null space vectors (on the next coarser levels). Therefore, it is recommended to declare the TentativePFactory 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. 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 NullspaceFactory::GetValidParameters).
The * in the @c requested column states that the data is requested as input with all dependencies (see NullspaceFactory::DeclareInput). ### Variables provided by NullspaceFactory ### After NullspaceFactory::Build the following data is available (if requested) Parameter | generated by | description ----------|--------------|------------ | Nullspace | NullspaceFactory | MultiVector containing the near null space vectors. On the finest level it can be a user-provided set of null space vectors. Otherwise a default set of constant near nullspace vectors is provided. On the coarser levels the null space vectors generated by the TentativePFactory (generating factory of "Nullspace") is provided as variable "Nullspace" in the level class. Note that the output variable is always "Nullspace" even if the parameter "Fine level nullspace" is different than "Nullspace". This way, the user can use any name for the fine level null space vectors, but the factories which need "Nullspace" information are guaranteed to get a null space. */ template class NullspaceFactory : public SingleLevelFactoryBase { public: typedef LocalOrdinal local_ordinal_type; typedef GlobalOrdinal global_ordinal_type; typedef typename Node::execution_space execution_space; typedef Kokkos::RangePolicy range_type; typedef Node node_type; private: #undef MUELU_NULLSPACEFACTORY_SHORT #include "MueLu_UseShortNames.hpp" public: //! @name Constructors/Destructors. //@{ //! Constructor NullspaceFactory(const std::string& nspName = "Nullspace") { SetParameter("Fine level nullspace", ParameterEntry(nspName)); } //! Destructor virtual ~NullspaceFactory() {} //@} //! @name Input //@{ /*! @brief Define valid parameters for internal factory parameters */ RCP GetValidParameterList() const; /*! @brief Specifies the data that this class needs, and the factories that generate that data. If the Build method of this class requires some data, but the generating factory is not specified in DeclareInput, then this class will fall back to the settings in FactoryManager. */ void DeclareInput(Level& currentLevel) const; //@} //! @name Build methods. //@{ //! Build an object with this factory. void Build(Level& currentLevel) const; //@} private: using coordinate_type = typename Teuchos::ScalarTraits::coordinateType; using RealValuedMultiVector = Xpetra::MultiVector; using CoordsType = typename RealValuedMultiVector::dual_view_type::t_dev_const_um; using MeanCoordsType = Kokkos::View; void fillNullspaceVector(const RCP& nullspace, LocalOrdinal numPDEs, LocalOrdinal nullspaceDim, CoordsType coordsView, MeanCoordsType meanView) const; mutable bool calculateRotations_ = false; }; } // namespace MueLu #define MUELU_NULLSPACEFACTORY_SHORT #endif // MUELU_NULLSPACEFACTORY_DECL_HPP