Tempus
Version of the Day
Time Integration
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Thyra_ScaledIdentityLinearOpWithSolve.hpp
Go to the documentation of this file.
1
// @HEADER
2
// ****************************************************************************
3
// Tempus: Copyright (2017) Sandia Corporation
4
//
5
// Distributed under BSD 3-clause license (See accompanying file Copyright.txt)
6
// ****************************************************************************
7
// @HEADER
8
9
#ifndef Thyra_ScaledIdentityLinearOpWithSolve_hpp
10
#define Thyra_ScaledIdentityLinearOpWithSolve_hpp
11
12
#include "Thyra_LinearOpWithSolveBase.hpp"
13
#include "Thyra_MultiVectorStdOps.hpp"
14
15
namespace
Thyra
{
16
21
template
<
class
Scalar>
22
class
ScaledIdentityLinearOpWithSolve
:
23
virtual
public
LinearOpWithSolveBase
<Scalar>
24
{
25
public
:
26
29
31
ScaledIdentityLinearOpWithSolve
() {}
32
33
void
initialize
(
const
RCP<
const
VectorSpaceBase<Scalar> >&
space
,
34
const
Scalar& s)
35
{
36
validateInitialize
(
space
);
37
space_
=
space
;
38
s_
= s;
39
}
40
41
void
uninitialize
()
42
{
43
space_
= Teuchos::null;
44
}
45
46
RCP< const VectorSpaceBase<Scalar> >
space
()
const
{
return
space_
; }
47
Scalar
scale
()
const
{
return
s_
; }
48
void
setScale
(
const
Scalar& s) {
s_
= s; }
49
51
54
55
RCP< const VectorSpaceBase<Scalar> >
range
()
const
{
return
space_
; }
56
57
RCP< const VectorSpaceBase<Scalar> >
domain
()
const
{
return
space_
; }
58
59
RCP<const LinearOpBase<Scalar> >
clone
()
const
60
{
61
RCP<ScaledIdentityLinearOpWithSolve<Scalar> > op =
62
rcp(
new
ScaledIdentityLinearOpWithSolve<Scalar>
());
63
op->initialize(
space_
,
s_
);
64
return
op;
65
}
66
67
68
protected
:
69
72
bool
opSupportedImpl
(EOpTransp
/* M_trans */
)
const
{
return
true
; }
73
74
void
applyImpl
(
const
EOpTransp M_trans,
75
const
MultiVectorBase<Scalar>
& X,
76
const
Ptr<
MultiVectorBase<Scalar>
>& Y,
77
const
Scalar alpha,
78
const
Scalar beta)
const
79
{
80
typedef
Teuchos::ScalarTraits<Scalar> ST;
81
Thyra::scale(beta, Y);
82
if
(M_trans == CONJ || M_trans == CONJTRANS)
83
V_StVpV(Y, ST::conjugate(
s_
)*alpha, X, *Y);
84
else
85
V_StVpV(Y,
s_
*alpha, X, *Y);
86
}
87
88
91
bool
solveSupportsImpl
(EOpTransp
/* M_trans */
)
const
{
return
true
; }
92
93
bool
solveSupportsNewImpl
(
94
EOpTransp
/* M_trans */
,
95
const
Ptr<
const
SolveCriteria< Scalar > >
/* solveCriteria */
)
const
96
{
return
true
; }
97
98
bool
solveSupportsSolveMeasureTypeImpl
(
99
EOpTransp
/* M_trans */
,
100
const
SolveMeasureType &
/* solveMeasureType */
)
const
101
{
return
true
; }
102
103
SolveStatus< Scalar >
solveImpl
(
104
const
EOpTransp M_trans,
105
const
MultiVectorBase<Scalar>
& B,
106
const
Ptr<
MultiVectorBase<Scalar>
>& X,
107
const
Ptr<
const
SolveCriteria< Scalar > >
/* solveCriteria */
)
const
108
{
109
typedef
Teuchos::ScalarTraits<Scalar> ST;
110
assign(X, ST::zero());
111
if
(M_trans == CONJ || M_trans == CONJTRANS)
112
V_StVpV(X, ST::one()/ST::conjugate(
s_
), B, *X);
113
else
114
V_StVpV(X, ST::one()/
s_
, B, *X);
115
SolveStatus<Scalar> solveStatus;
116
solveStatus.solveStatus = SOLVE_STATUS_CONVERGED;
117
return
solveStatus;
118
}
119
120
121
private
:
122
123
// //////////////////////////////
124
// Private data members
125
126
RCP<const VectorSpaceBase<Scalar> >
space_
;
127
Scalar
s_
;
128
129
// //////////////////////////////
130
// Private member functions
131
132
static
void
validateInitialize
(
133
const
RCP<
const
VectorSpaceBase<Scalar> >&
space
) {
134
#ifdef TEUCHOS_DEBUG
135
TEUCHOS_TEST_FOR_EXCEPT(is_null(
space
));
136
#else
137
(void)
space
;
138
#endif
139
}
140
141
};
142
147
template
<
class
Scalar>
148
RCP<ScaledIdentityLinearOpWithSolve<Scalar> >
149
scaledIdentity
()
150
{
151
return
Teuchos::rcp(
new
ScaledIdentityLinearOpWithSolve<Scalar>
());
152
}
153
158
template
<
class
Scalar>
159
RCP<ScaledIdentityLinearOpWithSolve<Scalar> >
160
scaledIdentity
(
const
RCP<
const
VectorSpaceBase<Scalar> >&
space
,
161
const
Scalar& s)
162
{
163
RCP<ScaledIdentityLinearOpWithSolve<Scalar> >
164
op = Teuchos::rcp(
new
ScaledIdentityLinearOpWithSolve<Scalar>
());
165
op->initialize(
space
, s);
166
return
op;
167
}
168
169
}
// end namespace Thyra
170
171
172
#endif
Thyra::LinearOpWithSolveBase
Thyra::MultiVectorBase
Thyra::ScaledIdentityLinearOpWithSolve::space_
RCP< const VectorSpaceBase< Scalar > > space_
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:126
Thyra::ScaledIdentityLinearOpWithSolve::solveSupportsSolveMeasureTypeImpl
bool solveSupportsSolveMeasureTypeImpl(EOpTransp, const SolveMeasureType &) const
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:98
Thyra::ScaledIdentityLinearOpWithSolve::setScale
void setScale(const Scalar &s)
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:48
Thyra::ScaledIdentityLinearOpWithSolve::initialize
void initialize(const RCP< const VectorSpaceBase< Scalar > > &space, const Scalar &s)
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:33
Thyra::ScaledIdentityLinearOpWithSolve::opSupportedImpl
bool opSupportedImpl(EOpTransp) const
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:72
Thyra::ScaledIdentityLinearOpWithSolve::space
RCP< const VectorSpaceBase< Scalar > > space() const
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:46
Thyra::ScaledIdentityLinearOpWithSolve::s_
Scalar s_
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:127
Thyra::ScaledIdentityLinearOpWithSolve::scale
Scalar scale() const
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:47
Thyra::ScaledIdentityLinearOpWithSolve::solveImpl
SolveStatus< Scalar > solveImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > >) const
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:103
Thyra::ScaledIdentityLinearOpWithSolve::scaledIdentity
RCP< ScaledIdentityLinearOpWithSolve< Scalar > > scaledIdentity(const RCP< const VectorSpaceBase< Scalar > > &space, const Scalar &s)
Nonmember constructor function.
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:160
Thyra::ScaledIdentityLinearOpWithSolve::validateInitialize
static void validateInitialize(const RCP< const VectorSpaceBase< Scalar > > &space)
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:132
Thyra::ScaledIdentityLinearOpWithSolve::scaledIdentity
RCP< ScaledIdentityLinearOpWithSolve< Scalar > > scaledIdentity()
Nonmember constructor function.
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:149
Thyra::ScaledIdentityLinearOpWithSolve::applyImpl
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:74
Thyra::ScaledIdentityLinearOpWithSolve::ScaledIdentityLinearOpWithSolve
ScaledIdentityLinearOpWithSolve()
Construct to uninitialized.
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:31
Thyra::ScaledIdentityLinearOpWithSolve::clone
RCP< const LinearOpBase< Scalar > > clone() const
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:59
Thyra::ScaledIdentityLinearOpWithSolve::solveSupportsImpl
bool solveSupportsImpl(EOpTransp) const
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:91
Thyra::ScaledIdentityLinearOpWithSolve::domain
RCP< const VectorSpaceBase< Scalar > > domain() const
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:57
Thyra::ScaledIdentityLinearOpWithSolve::range
RCP< const VectorSpaceBase< Scalar > > range() const
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:55
Thyra::ScaledIdentityLinearOpWithSolve::uninitialize
void uninitialize()
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:41
Thyra::ScaledIdentityLinearOpWithSolve::solveSupportsNewImpl
bool solveSupportsNewImpl(EOpTransp, const Ptr< const SolveCriteria< Scalar > >) const
Definition
Thyra_ScaledIdentityLinearOpWithSolve.hpp:93
Thyra
Definition
Thyra_AdjointLinearOpWithSolveFactory.hpp:19
Generated by
1.17.0