// @HEADER // ***************************************************************************** // MueLu: A package for multigrid based preconditioning // // Copyright 2012 NTESS and the MueLu contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef MUELU_BLACKBOXPFACTORY_DECL_HPP #define MUELU_BLACKBOXPFACTORY_DECL_HPP #include #include #include #include "MueLu_ConfigDefs.hpp" #include "MueLu_PFactory.hpp" #include "MueLu_BlackBoxPFactory_fwd.hpp" #include "MueLu_Level_fwd.hpp" namespace MueLuTests { // Forward declaration of friend tester class used to UnitTest BlackBoxPFactory template class BlackBoxPFactoryTester; } // namespace MueLuTests namespace MueLu { /*! @class BlackBoxPFactory @ingroup MueLuTransferClasses @brief Prolongator factory performing geometric coarsening. The geometric algorithm assumes the underlying mesh is reasonably structured. Any rate of coarsening can be applied, and the rate is automatically decrease along an edge if the number of element is not divisible by the coarsening rate. The coarsening rate is allowed to be different in all direction which means that semi-coarsening can be achieved within this algorithm in 1 or 2 directions. The main difficulty is to obtain the number of elements/nodes in each directions to identify coarse nodes and fine nodes. ## Input/output of BlackBoxPFactory ## ### User parameters of SemiCoarsenPFactory ### | Parameter | type | default | master.xml | validated | requested | description | | ------------|---------|-----------|:----------:|:---------:|:---------:|----------------------------------------------------------------------------------| | Coarsen | string | -1 | | | | A string that specify the coarsening rate, if it is a single character, it will | | | | | | | | indicate a unique coarsening rate in each direction, if it is longer, it will be | | | | | | | | processed as a vector with 3 entries, one for each spatial direction | | A | Factory | null | | * | * | Generating factory of the matrix A used during the prolongator smoothing process | | Nullspace | Factory | null | | * | * | Generating factory of the nullspace. The GeneralGeometricPFactory provides | | | | | | | | a coarse version of the given Nullspace. | | Coordinates | Factory | NoFactory | | * | * | Generating factory for coorindates. The coordinates are expected to be provided | | | | | | | | on the finest level using the NoFactory mechanism. The coordinates are used to | | | | | | | | compute the coarsening stencil and coarse coordinates are generated for the next | | | | | | | | level. | 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 BlackBoxPFactory::GetValidParameters).
The * in the @c requested column states that the data is requested as input with all dependencies (see BlackBoxPFactory::DeclareInput). ### Variables provided by BlackBoxPFactory ### After BlackBoxPFactory::Build the following data is available (if requested) | Parameter | generated by | description |-------------------|--------------------------|------------------------------------------------------------------------------------------------------------------| | P | BlackBoxPFactory | Prolongator | | Nullspace | BlackBoxPFactory | Coarse nullspace (the fine level nullspace information is coarsened using P to generate a coarse version | | | | of the nullspace. No scaling is applied. | | coarseCoordinates | BlackBoxPFactory | coarseCoordinates are to be picked up on the coarse level by the coordinates transfer factory and renamed | | | | coordinates so that on coarser levels coordinates are available in case another factory needs them. | */ template class BlackBoxPFactory : public PFactory { #undef MUELU_BLACKBOXPFACTORY_SHORT #include "MueLu_UseShortNames.hpp" public: friend class MueLuTests::BlackBoxPFactoryTester; //! @name Constructors/Destructors. //@{ //! Constructor BlackBoxPFactory() {} //! Destructor. virtual ~BlackBoxPFactory() {} //@} 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; //@} private: struct NodesIDs { // This small struct just carries basic data associated with coarse nodes that is needed // to compute colMapP and to fillComplete P, Array GIDs, coarseGIDs; Array PIDs; Array LIDs; std::vector colInds; }; struct NodeID { // This small struct is similar to the one above but only for one node. // It is used to create a vector of NodeID that can easily be sorted GO GID; int PID; LO LID, lexiInd; }; void GetGeometricData(RCP::magnitudeType, LO, GO, NO> >& coordinates, const Array coarseRate, const Array gFineNodesPerDir, const Array lFineNodesPerDir, const LO BlkSize, Array& gIndices, Array& myOffset, Array& ghostInterface, Array& endRate, Array& gCoarseNodesPerDir, Array& lCoarseNodesPerDir, Array& glCoarseNodesPerDir, Array& ghostGIDs, Array& coarseNodesGIDs, Array& colGIDs, GO& gNumCoarseNodes, LO& lNumCoarseNodes, ArrayRCP::magnitudeType> > coarseNodes, Array& boundaryFlags, RCP ghostedCoarseNodes) const; void ComputeLocalEntries(const RCP& Aghost, const Array coarseRate, const Array endRate, const LO BlkSize, const Array elemInds, const Array lCoarseElementsPerDir, const LO numDimensions, const Array lFineNodesPerDir, const Array gFineNodesPerDir, const Array gIndices, const Array lCoarseNodesPerDir, const Array ghostInterface, const Array elementFlags, const std::string stencilType, const std::string blockStrategy, const Array elementNodesPerDir, const LO numNodesInElement, const Array colGIDs, Teuchos::SerialDenseMatrix& Pi, Teuchos::SerialDenseMatrix& Pf, Teuchos::SerialDenseMatrix& Pe, Array& dofType, Array& lDofInd) const; void CollapseStencil(const int type, const int orientation, const int collapseFlags[3], Array& stencil) const; void FormatStencil(const LO BlkSize, const Array ghostInterface, const LO ie, const LO je, const LO ke, const ArrayView rowValues, const Array elementNodesPerDir, const int collapseFlags[3], const std::string stencilType, Array& stencil) const; void GetNodeInfo(const LO ie, const LO je, const LO ke, const Array elementNodesPerDir, int* type, LO& ind, int* orientation) const; void sh_sort_permute( const typename Teuchos::Array::iterator& first1, const typename Teuchos::Array::iterator& last1, const typename Teuchos::Array::iterator& first2, const typename Teuchos::Array::iterator& last2) const; }; // class BlackBoxPFactory } // namespace MueLu #define MUELU_BLACKBOXPFACTORY_SHORT #endif // MUELU_BLACKBOXPFACTORY_DECL_HPP