| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// MueLu: A package for multigrid based preconditioning |
| 4 |
// |
| 5 |
// Copyright 2012 NTESS and the MueLu contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#ifndef MUELU_SEMICOARSENPFACTORY_DECL_HPP |
| 11 |
#define MUELU_SEMICOARSENPFACTORY_DECL_HPP |
| 12 |
|
| 13 |
#include <Xpetra_Matrix_fwd.hpp> |
| 14 |
|
| 15 |
#include "MueLu_ConfigDefs.hpp" |
| 16 |
#include "MueLu_PFactory.hpp" |
| 17 |
#include "MueLu_SemiCoarsenPFactory_fwd.hpp" |
| 18 |
|
| 19 |
#include "MueLu_Level_fwd.hpp" |
| 20 |
|
| 21 |
#define VERTICAL 1 |
| 22 |
#define HORIZONTAL 2 |
| 23 |
#define GRID_SUPPLIED -1 |
| 24 |
#define NUM_ZPTS 0 |
| 25 |
#define ORIENTATION 1 |
| 26 |
|
| 27 |
namespace MueLu { |
| 28 |
|
| 29 |
/*! |
| 30 |
@class SemiCoarsenPFactory |
| 31 |
@ingroup MueLuTransferClasses |
| 32 |
@brief Prolongator factory performing semi-coarsening. |
| 33 |
|
| 34 |
The semi-coarsening is performed along user-provided "vertical lines" (in z-direction). |
| 35 |
The line detection algorithm can be found in the LineDetectionFactory. |
| 36 |
Usually, the SemiCoarsenPFactory is used together with the TogglePFactory and a |
| 37 |
second TentativePFactory which allows to dynamically switch from semi-coarsening to |
| 38 |
aggregation-based coarsening (or any other compatible coarsening algorithm). |
| 39 |
|
| 40 |
## Input/output of SemiCoarsenPFactory ## |
| 41 |
|
| 42 |
### User parameters of SemiCoarsenPFactory ### |
| 43 |
Parameter | type | default | master.xml | validated | requested | description |
| 44 |
----------|------|---------|:----------:|:---------:|:---------:|------------ |
| 45 |
| A | Factory | null | | * | * | Generating factory of the matrix A used during the prolongator smoothing process | |
| 46 |
| Nullspace | Factory | null | | * | * | Generating factory of the nullspace. The SemiCoarsenPFactory provides a coarse version of the given Nullspace. | |
| 47 |
| 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 determine the number of z-layers if not otherwise provided by the user. | |
| 48 |
| LineDetection_VertLineIds | Factory | null | | * | * | Generating factory for LineDetection information. Usually provided by the LineDetectionFactory. Array with vertical line ids for all nodes on current processor. | |
| 49 |
| LineDetection_Layers | Factory | null | | * | * | Generating factory for LineDetection information. Usually provided by the LineDetectionFactory. Array with layer id for all nodes on current processor. | |
| 50 |
| CoarseNumZLayers | Factory | null | | * | * | Generating factory for LineDetection information. Usually provided by the LineDetectionFactory. Number of remaining z-layers after semi-coarsening. | |
| 51 |
| semicoarsen: coarsen rate | int | * | * | | Coarsening rate along vertical lines (2 corresponds to classical semicoarsening. Values > 2 for more aggressive coarsening). | |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
The * in the @c master.xml column denotes that the parameter is defined in the @c master.xml file.<br> |
| 56 |
The * in the @c validated column means that the parameter is declared in the list of valid input parameters (see SemiCoarsenPFactory::GetValidParameters).<br> |
| 57 |
The * in the @c requested column states that the data is requested as input with all dependencies (see SemiCoarsenPFactory::DeclareInput). |
| 58 |
|
| 59 |
### Variables provided by SemiCoarsenPFactory ### |
| 60 |
|
| 61 |
After SemiCoarsenPFactory::Build the following data is available (if requested) |
| 62 |
|
| 63 |
Parameter | generated by | description |
| 64 |
----------|--------------|------------ |
| 65 |
| P | SemiCoarsenPFactory | Prolongator |
| 66 |
| Nullspace | SemiCoarsenPFactory | Coarse nullspace (the fine level nullspace information is coarsened using P to generate a coarse version of the nullspace. No scaling is applied. |
| 67 |
| NumZLayers | NoFactory | Number of z layers after coarsening. Necessary input for LineDetectionFactory. Useful input for TogglePFactory. |
| 68 |
|
| 69 |
*/ |
| 70 |
template <class Scalar = DefaultScalar, |
| 71 |
class LocalOrdinal = DefaultLocalOrdinal, |
| 72 |
class GlobalOrdinal = DefaultGlobalOrdinal, |
| 73 |
class Node = DefaultNode> |
| 74 |
class SemiCoarsenPFactory : public PFactory { |
| 75 |
#undef MUELU_SEMICOARSENPFACTORY_SHORT |
| 76 |
#include "MueLu_UseShortNames.hpp" |
| 77 |
|
| 78 |
public: |
| 79 |
//! @name Constructors/Destructors. |
| 80 |
//@{ |
| 81 |
|
| 82 |
//! Constructor |
| 83 |
SemiCoarsenPFactory() |
| 84 |
: bTransferCoordinates_(false) {} |
| 85 |
|
| 86 |
//! Destructor. |
| 87 |
virtual ~SemiCoarsenPFactory() {} |
| 88 |
//@} |
| 89 |
|
| 90 |
RCP<const ParameterList> GetValidParameterList() const; |
| 91 |
|
| 92 |
//! Input |
| 93 |
//@{ |
| 94 |
|
| 95 |
void DeclareInput(Level& fineLevel, Level& coarseLevel) const; |
| 96 |
|
| 97 |
//@} |
| 98 |
|
| 99 |
//! @name Build methods. |
| 100 |
//@{ |
| 101 |
|
| 102 |
void Build(Level& fineLevel, Level& coarseLevel) const; |
| 103 |
void BuildP(Level& fineLevel, Level& coarseLevel) const; |
| 104 |
|
| 105 |
//@} |
| 106 |
|
| 107 |
private: |
| 108 |
LO FindCpts(LO const PtsPerLine, LO const CoarsenRate, LO const Thin, LO** LayerCpts) const; |
| 109 |
LO MakeSemiCoarsenP(LO const Ntotal, LO const nz, LO const CoarsenRate, LO const LayerId[], |
| 110 |
LO const VertLineId[], LO const DofsPerNode, RCP<Matrix>& Amat, |
| 111 |
RCP<Matrix>& P, RCP<const Map>& coarseMap, |
| 112 |
const RCP<MultiVector> fineNullspace, RCP<MultiVector>& coarseNullspace, RCP<Matrix>& R, bool buildRestriction, bool doLinear) const; |
| 113 |
void RevertToPieceWiseConstant(RCP<Matrix>& P, LO BlkSize) const; |
| 114 |
|
| 115 |
mutable bool bTransferCoordinates_; //< boolean which is true if coordinate information is available to be transferred to coarse coordinate information |
| 116 |
}; // class SemiCoarsenPFactory |
| 117 |
|
| 118 |
} // namespace MueLu |
| 119 |
|
| 120 |
#define MUELU_SEMICOARSENPFACTORY_SHORT |
| 121 |
#endif // MUELU_SEMICOARSENPFACTORY_DECL_HPP |