MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_FlatOperator_decl.hpp
Go to the documentation of this file.
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_FLATOPERATOR_DECL_HPP
11#define MUELU_FLATOPERATOR_DECL_HPP
12
13#include "MueLu_Constraint.hpp"
14#include "Teuchos_RCP.hpp"
15#include "Xpetra_Map.hpp"
16#include "Xpetra_MapFactory.hpp"
17#include "Xpetra_MatrixMatrix.hpp"
18#include "Xpetra_MultiVector.hpp"
19#include "Xpetra_Operator.hpp"
20
22
23namespace MueLu {
24
26
37template <class Scalar,
38 class LocalOrdinal,
39 class GlobalOrdinal,
40 class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
42 : public Xpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
43 public VerboseObject {
44 public:
46
48 virtual const Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> getDomainMap() const {
49 return map_;
50 }
51
53 virtual const Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> getRangeMap() const {
54 return map_;
55 }
56
58
63 virtual void
64 apply(const Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &X,
65 Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &Y,
66 Teuchos::ETransp mode = Teuchos::NO_TRANS,
67 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
68 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
69
71 virtual bool hasTransposeApply() const {
72 return false;
73 }
74
76
78
79
81 std::string description() const {
82 return mat_->description();
83 }
84
86 void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const {
87 mat_->describe(out, verbLevel);
88 }
89
91
93
94
95 FlatOperator() = default;
96
98 FlatOperator(const Teuchos::RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> mat,
100
101 void CheckMaps() {
102 }
103
105 if (tempMat_.is_null()) {
106 auto pattern = constraint_->GetPattern();
107 tempMat_ = Xpetra::MatrixFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build(pattern);
108 tempMat_->fillComplete();
109 }
110 }
111
113 void residual(const Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &X,
114 const Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &B,
115 Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &R) const {
116 const auto one = Teuchos::ScalarTraits<Scalar>::one();
117 const auto zero = Teuchos::ScalarTraits<Scalar>::zero();
118
119 apply(X, R, Teuchos::NO_TRANS, one, zero);
120 R.update(one, B, -one);
121 }
122
124
125 private:
126 RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> mat_;
127 RCP<MueLu::Constraint<Scalar, LocalOrdinal, GlobalOrdinal, Node>> constraint_;
128 RCP<Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> map_;
129 mutable RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> tempMat_;
130
131}; // FlatOperator class
132
133} // namespace MueLu
134
135#define MUELU_FLATOPERATOR_SHORT
136#endif
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
Constraint space information for the potential prolongator.
Interprets a matrix as an operator that acts on a vector of nonzeros via SpGEMM.
virtual void apply(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Computes the operator-multivector application.
RCP< Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > map_
std::string description() const
A simple one-line description of this object.
virtual const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
The Map associated with the domain of this operator, which must be compatible with X....
RCP< MueLu::Constraint< Scalar, LocalOrdinal, GlobalOrdinal, Node > > constraint_
virtual bool hasTransposeApply() const
Whether this operator supports applying the transpose or conjugate transpose.
FlatOperator()=default
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with the given verbosity level to a FancyOStream.
virtual const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
The Map associated with the range of this operator, which must be compatible with Y....
RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > mat_
void residual(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const
Compute a residual R = B - (*this) * X.
RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > tempMat_
Verbose class for MueLu classes.
Namespace for MueLu classes and methods.