MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node > Class Template Referenceabstract

Constraint space information for the potential prolongator. More...

#include <MueLu_Constraint_decl.hpp>

Inheritance diagram for MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >:
MueLu::BaseClass MueLu::VerboseObject MueLu::Describable MueLu::DenseConstraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >

Public Types

using MagnitudeType = typename Teuchos::ScalarTraits< Scalar >::magnitudeType
 

Public Member Functions

 Constraint ()=default
 
virtual MagnitudeType ResidualNorm (const RCP< const Matrix > P) const =0
 
virtual const RCP< const Map > getDomainMap () const
 The Map associated with the domain of this operator, which must be compatible with X.getMap().
 
virtual const RCP< const Map > getRangeMap () const
 The Map associated with the range of this operator, which must be compatible with Y.getMap().
 
- Public Member Functions inherited from MueLu::BaseClass
virtual ~BaseClass ()
 Destructor.
 
- Public Member Functions inherited from MueLu::VerboseObject
 VerboseObject ()
 
virtual ~VerboseObject ()
 Destructor.
 
VerbLevel GetVerbLevel () const
 Get the verbosity level.
 
void SetVerbLevel (const VerbLevel verbLevel)
 Set the verbosity level of this object.
 
int GetProcRankVerbose () const
 Get proc rank used for printing. Do not use this information for any other purpose.
 
int SetProcRankVerbose (int procRank) const
 Set proc rank used for printing.
 
bool IsPrint (MsgType type, int thisProcRankOnly=-1) const
 Find out whether we need to print out information for a specific message type.
 
Teuchos::FancyOStream & GetOStream (MsgType type, int thisProcRankOnly=0) const
 Get an output stream for outputting the input message type.
 
Teuchos::FancyOStream & GetBlackHole () const
 
- Public Member Functions inherited from MueLu::Describable
virtual ~Describable ()
 Destructor.
 
virtual void describe (Teuchos::FancyOStream &out_arg, const VerbLevel verbLevel=Default) const
 
virtual std::string description () const
 Return a simple one-line description of this object.
 
void describe (Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
 Print the object with some verbosity level to an FancyOStream object.
 
virtual std::string ShortClassName () const
 Return the class name of the object, without template parameters and without namespace.
 

Apply methods.

using MV = Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >
 
using OP = Belos::OperatorT< MV >
 
RCP< Matrix > X_
 The constraints matrix.
 
RCP< const CrsGraph > Ppattern_
 Nonzero sparsity pattern.
 
std::string solverType_
 
RCP< Belos::LinearProblem< Scalar, MV, OP > > problem_
 
RCP< Belos::SolverManager< Scalar, MV, OP > > solver_
 
RCP< Matrix > invXXt_
 Inverse of X*X^T.
 
RCP< MultiVector > temp1_
 
RCP< MultiVector > temp2_
 
RCP< MultiVector > temp3_
 
virtual void apply (const MultiVector &P, MultiVector &Projected, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
 Apply constraint.
 
void residual (const MultiVector &X, const MultiVector &B, MultiVector &R) const
 Compute a residual R = B - (*this) * X.
 
RCP< const CrsGraph > GetPattern () const
 
void SetPattern (RCP< const CrsGraph > &Ppattern)
 
void SetConstraintsMatrix (RCP< Matrix > &X)
 
RCP< Matrix > GetConstraintMatrix ()
 
virtual CrsGraph::local_graph_type FindBlocks (RCP< const CrsGraph > &XXt)
 
void AssignMatrixEntriesToVector (const Matrix &P, const RCP< const CrsGraph > &pattern, MultiVector &vecP) const
 
void AssignMatrixEntriesToVector (const Matrix &P, MultiVector &vecP) const
 
RCP< Matrix > GetMatrixWithEntriesFromVector (MultiVector &vecP) const
 
void LeastSquaresSolve (const MultiVector &B, MultiVector &C) const
 
void PrepareLeastSquaresSolve (const std::string &solverType, bool detect_singular_blocks=false)
 
void PrepareLeastSquaresSolveBelos (bool detect_singular_blocks)
 Prepare least-squares solve using Belos.
 
void LeastSquaresSolveBelos (const MultiVector &B, MultiVector &C) const
 Perform least-squares solve using Belos.
 
void PrepareLeastSquaresSolveDirect (bool detect_singular_blocks)
 Prepare direct solution of least-squares problem.
 
void LeastSquaresSolveDirect (const MultiVector &B, MultiVector &C) const
 Direct solve of least-squares problem.
 

Additional Inherited Members

- Static Public Member Functions inherited from MueLu::VerboseObject
static void SetDefaultVerbLevel (const VerbLevel defaultVerbLevel)
 Set the default (global) verbosity level.
 
static VerbLevel GetDefaultVerbLevel ()
 Get the default (global) verbosity level.
 
static void SetMueLuOStream (const Teuchos::RCP< Teuchos::FancyOStream > &mueluOStream)
 
static void SetMueLuOFileStream (const std::string &filename)
 
static Teuchos::RCP< Teuchos::FancyOStream > GetMueLuOStream ()
 

Detailed Description

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
class MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >

Constraint space information for the potential prolongator.

This class implements an idea of the constrained space. In energy minimization, constrained space is used simultaneously with the iterative method to construct the final prolongator. The space has two different constraints.

Nonzero pattern constraint

Nonzero pattern constraint means that the final prolongator must have the provided nonzero pattern. This is achieved on each step of the iterative method by restricting the graph of the temporary prolongator to the desired pattern. It is implemented in the Apply function.

Note
We do not update the graph of the provided temporary prolongator as this is a very expensive procedure. Rather, we extract its values and replace some of the values of the matrix with the correct graph.

Coarse space approximation constraint

Generally, the coarse space constraint is presented by some matrix (X or Q) (see, for instance, the article by Mandel, Brezina and Vanek '99. It is well known that this matrix can be permuted to have a block diagonal form, where each block corresponds to a row in the prolongator. Specifically, let P be the prolongator, and Q be the constraint matrix. Then the constraint is generally written as \(Q P = B,\) where B is the fine nullspace multivector. Q is a block diagonal matrix, \(Q = diag(Q_1, ..., Q_n)\), where n is the number of rows in P. Each block Q_i is of size NSDim x nnz_i, where NSDim is the number of fine nullspace vectors, and nnz_i is the number of nonzero elements in the i-th row of P.

To constrain the potential prolongator (with correct sparsity pattern, i.e. after the application of the nonzero pattern constraint), one updates its values as

        \f[P = P - Q^H(QQ^H)^{-1}QP.\f]

Because of the block diagonal form of Q, this can be done row-by-row.

Note
For efficiency reasons, we store

\[(QQ^H)^{-1}\]

in the XXtInv_ array. These matrices are dense, but have small size (NSDim x NSDim).

Definition at line 78 of file MueLu_Constraint_decl.hpp.

Member Typedef Documentation

◆ MagnitudeType

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
using MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >::MagnitudeType = typename Teuchos::ScalarTraits<Scalar>::magnitudeType

Definition at line 89 of file MueLu_Constraint_decl.hpp.

◆ MV

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
using MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >::MV = Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>
private

Definition at line 149 of file MueLu_Constraint_decl.hpp.

◆ OP

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
using MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >::OP = Belos::OperatorT<MV>
private

Definition at line 150 of file MueLu_Constraint_decl.hpp.

Constructor & Destructor Documentation

◆ Constraint()

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >::Constraint ( )
default

Member Function Documentation

◆ ResidualNorm()

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
virtual MagnitudeType MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >::ResidualNorm ( const RCP< const Matrix >  P) const
pure virtual

◆ getDomainMap()

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > Constraint::getDomainMap ( ) const
virtual

The Map associated with the domain of this operator, which must be compatible with X.getMap().

Definition at line 335 of file MueLu_Constraint_def.hpp.

◆ getRangeMap()

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > Constraint::getRangeMap ( ) const
virtual

The Map associated with the range of this operator, which must be compatible with Y.getMap().

Definition at line 340 of file MueLu_Constraint_def.hpp.

◆ apply()

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Constraint::apply ( const MultiVector &  P,
MultiVector &  Projected,
Teuchos::ETransp  mode = Teuchos::NO_TRANS,
Scalar  alpha = Teuchos::ScalarTraits<Scalar>::one(),
Scalar  beta = Teuchos::ScalarTraits<Scalar>::zero() 
) const
virtual

Apply constraint.

Definition at line 629 of file MueLu_Constraint_def.hpp.

◆ residual()

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
void Constraint::residual ( const MultiVector &  X,
const MultiVector &  B,
MultiVector &  R 
) const

Compute a residual R = B - (*this) * X.

Definition at line 650 of file MueLu_Constraint_def.hpp.

◆ GetPattern()

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
RCP< const Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > Constraint::GetPattern ( ) const

Definition at line 661 of file MueLu_Constraint_def.hpp.

◆ SetPattern()

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Constraint::SetPattern ( RCP< const CrsGraph > &  Ppattern)

Definition at line 666 of file MueLu_Constraint_def.hpp.

◆ SetConstraintsMatrix()

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Constraint::SetConstraintsMatrix ( RCP< Matrix > &  X)

Definition at line 671 of file MueLu_Constraint_def.hpp.

◆ GetConstraintMatrix()

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Constraint::GetConstraintMatrix ( )

Definition at line 681 of file MueLu_Constraint_def.hpp.

◆ FindBlocks()

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::local_graph_type Constraint::FindBlocks ( RCP< const CrsGraph > &  XXt)
virtual

◆ AssignMatrixEntriesToVector() [1/2]

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Constraint::AssignMatrixEntriesToVector ( const Matrix &  P,
const RCP< const CrsGraph > &  pattern,
MultiVector &  vecP 
) const

Definition at line 686 of file MueLu_Constraint_def.hpp.

◆ AssignMatrixEntriesToVector() [2/2]

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Constraint::AssignMatrixEntriesToVector ( const Matrix &  P,
MultiVector &  vecP 
) const

Definition at line 727 of file MueLu_Constraint_def.hpp.

◆ GetMatrixWithEntriesFromVector()

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Constraint::GetMatrixWithEntriesFromVector ( MultiVector &  vecP) const

Definition at line 733 of file MueLu_Constraint_def.hpp.

◆ LeastSquaresSolve()

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Constraint::LeastSquaresSolve ( const MultiVector &  B,
MultiVector &  C 
) const

Definition at line 619 of file MueLu_Constraint_def.hpp.

◆ PrepareLeastSquaresSolve()

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Constraint::PrepareLeastSquaresSolve ( const std::string &  solverType,
bool  detect_singular_blocks = false 
)
protected

Definition at line 589 of file MueLu_Constraint_def.hpp.

◆ PrepareLeastSquaresSolveBelos()

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Constraint::PrepareLeastSquaresSolveBelos ( bool  detect_singular_blocks)
private

Prepare least-squares solve using Belos.

Definition at line 345 of file MueLu_Constraint_def.hpp.

◆ LeastSquaresSolveBelos()

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Constraint::LeastSquaresSolveBelos ( const MultiVector &  B,
MultiVector &  C 
) const
private

Perform least-squares solve using Belos.

Definition at line 600 of file MueLu_Constraint_def.hpp.

◆ PrepareLeastSquaresSolveDirect()

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Constraint::PrepareLeastSquaresSolveDirect ( bool  detect_singular_blocks)
private

Prepare direct solution of least-squares problem.

Definition at line 535 of file MueLu_Constraint_def.hpp.

◆ LeastSquaresSolveDirect()

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Constraint::LeastSquaresSolveDirect ( const MultiVector &  B,
MultiVector &  C 
) const
private

Direct solve of least-squares problem.

Definition at line 613 of file MueLu_Constraint_def.hpp.

Member Data Documentation

◆ X_

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
RCP<Matrix> MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >::X_
private

The constraints matrix.

Definition at line 141 of file MueLu_Constraint_decl.hpp.

◆ Ppattern_

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
RCP<const CrsGraph> MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >::Ppattern_
private

Nonzero sparsity pattern.

Definition at line 144 of file MueLu_Constraint_decl.hpp.

◆ solverType_

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
std::string MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >::solverType_
private

Definition at line 146 of file MueLu_Constraint_decl.hpp.

◆ problem_

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
RCP<Belos::LinearProblem<Scalar, MV, OP> > MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >::problem_
private

Definition at line 151 of file MueLu_Constraint_decl.hpp.

◆ solver_

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
RCP<Belos::SolverManager<Scalar, MV, OP> > MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >::solver_
private

Definition at line 152 of file MueLu_Constraint_decl.hpp.

◆ invXXt_

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
RCP<Matrix> MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >::invXXt_
private

Inverse of X*X^T.

Definition at line 162 of file MueLu_Constraint_decl.hpp.

◆ temp1_

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
RCP<MultiVector> MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >::temp1_
private

Definition at line 171 of file MueLu_Constraint_decl.hpp.

◆ temp2_

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
RCP<MultiVector> MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >::temp2_
private

Definition at line 171 of file MueLu_Constraint_decl.hpp.

◆ temp3_

template<class Scalar = DefaultScalar, class LocalOrdinal = DefaultLocalOrdinal, class GlobalOrdinal = DefaultGlobalOrdinal, class Node = DefaultNode>
RCP<MultiVector> MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node >::temp3_
private

Definition at line 171 of file MueLu_Constraint_decl.hpp.


The documentation for this class was generated from the following files: