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_MultiVector.hpp"
17#include "Xpetra_Operator.hpp"
18
20
21namespace MueLu {
22
24
35template <class Scalar,
36 class LocalOrdinal,
37 class GlobalOrdinal,
38 class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
40 : public Xpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
41 public VerboseObject {
42 public:
44
46 virtual const Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> getDomainMap() const {
47 return map_;
48 }
49
51 virtual const Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> getRangeMap() const {
52 return map_;
53 }
54
56
61 virtual void
62 apply(const Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &X,
63 Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &Y,
64 Teuchos::ETransp mode = Teuchos::NO_TRANS,
65 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
66 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
67
69 virtual bool hasTransposeApply() const {
70 return false;
71 }
72
74
76
77
79 std::string description() const {
80 return mat_->description();
81 }
82
84 void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const {
85 mat_->describe(out, verbLevel);
86 }
87
89
91
92
93 FlatOperator() = default;
94
96 FlatOperator(const Teuchos::RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> mat,
98
99 void CheckMaps() {
100 }
101
103 if (tempMat_.is_null()) {
104 auto pattern = constraint_->GetPattern();
105 tempMat_ = Xpetra::MatrixFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build(pattern);
106 tempMat_->fillComplete();
107 }
108 }
109
111 void residual(const Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &X,
112 const Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &B,
113 Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &R) const {
114 const auto one = Teuchos::ScalarTraits<Scalar>::one();
115 const auto zero = Teuchos::ScalarTraits<Scalar>::zero();
116
117 apply(X, R, Teuchos::NO_TRANS, one, zero);
118 R.update(one, B, -one);
119 }
120
122
123 private:
124 RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> mat_;
125 RCP<MueLu::Constraint<Scalar, LocalOrdinal, GlobalOrdinal, Node>> constraint_;
126 RCP<Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> map_;
127 mutable RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> tempMat_;
128
129}; // FlatOperator class
130
131} // namespace MueLu
132
133#define MUELU_FLATOPERATOR_SHORT
134#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.