Thyra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
support
operator_solve
client_support
Thyra_DefaultDiagonalLinearOpWithSolve_def.hpp
1
// @HEADER
2
// *****************************************************************************
3
// Thyra: Interfaces and Support for Abstract Numerical Algorithms
4
//
5
// Copyright 2004 NTESS and the Thyra contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef THYRA_DIAGONAL_LINEAR_OP_WITH_SOLVE_HPP
11
#define THYRA_DIAGONAL_LINEAR_OP_WITH_SOLVE_HPP
12
13
#include "Thyra_DefaultDiagonalLinearOpWithSolve_decl.hpp"
14
#include "Thyra_DefaultDiagonalLinearOp.hpp"
15
#include "Thyra_MultiVectorStdOps.hpp"
16
#include "Thyra_VectorBase.hpp"
17
#include "Thyra_TestingTools.hpp"
// ToDo: I need to have a better way to get eps()!
18
#include "Teuchos_Assert.hpp"
19
20
21
namespace
Thyra {
22
23
24
// Constructors/initializers/accessors
25
26
27
template
<
class
Scalar>
28
DefaultDiagonalLinearOpWithSolve<Scalar>::DefaultDiagonalLinearOpWithSolve
()
29
{}
30
31
32
template
<
class
Scalar>
33
DefaultDiagonalLinearOpWithSolve<Scalar>::DefaultDiagonalLinearOpWithSolve
(
34
const
RCP
<
const
VectorBase<Scalar>
> &diag
35
)
36
{
37
this->
initialize
(diag);
38
}
39
40
41
// protected
42
43
44
// Overridden from LinearOpWithSolveBase
45
46
47
template
<
class
Scalar>
48
bool
49
DefaultDiagonalLinearOpWithSolve<Scalar>::solveSupportsImpl
(
50
EOpTransp M_trans)
const
51
{
52
typedef
Teuchos::ScalarTraits<Scalar>
ST;
53
return
(ST::isComplex ? M_trans==
NOTRANS
|| M_trans==TRANS :
true
);
54
}
55
56
57
template
<
class
Scalar>
58
bool
59
DefaultDiagonalLinearOpWithSolve<Scalar>::solveSupportsSolveMeasureTypeImpl
(
60
EOpTransp M_trans,
const
SolveMeasureType
&
/* solveMeasureType */
)
const
61
{
62
return
this->
solveSupportsImpl
(M_trans);
// I am a direct solver!
63
}
64
65
66
template
<
class
Scalar>
67
SolveStatus<Scalar>
68
DefaultDiagonalLinearOpWithSolve<Scalar>::solveImpl
(
69
const
EOpTransp transp,
70
const
MultiVectorBase<Scalar>
&B,
71
const
Ptr
<
MultiVectorBase<Scalar>
> &X,
72
const
Ptr
<
const
SolveCriteria<Scalar>
> solveCriteria
73
)
const
74
{
75
76
#ifdef THYRA_DEBUG
77
TEUCHOS_ASSERT
(this->
solveSupportsImpl
(transp));
78
#else
79
(void)transp;
80
#endif
81
82
typedef
Teuchos::ScalarTraits<Scalar>
ST;
83
84
assign
(X, ST::zero());
85
86
const
Ordinal numCols = B.
domain
()->dim();
87
SolveStatus<Scalar>
overallSolveStatus;
88
89
for
(Ordinal col_j = 0; col_j < numCols; ++col_j) {
90
91
const
RCP<const VectorBase<Scalar>
> b = B.
col
(col_j);
92
const
RCP<VectorBase<Scalar>
> x = X->col(col_j);
93
94
ele_wise_divide
( ST::one(), *b, *this->
getDiag
(), x.
ptr
() );
95
96
}
97
98
SolveStatus<Scalar>
solveStatus;
99
solveStatus.
solveStatus
=
100
(nonnull(solveCriteria) && !solveCriteria->solveMeasureType.useDefault()
101
?
SOLVE_STATUS_CONVERGED
:
SOLVE_STATUS_UNKNOWN
);
102
solveStatus.
achievedTol
=
SolveStatus<Scalar>::unknownTolerance
();
103
return
solveStatus;
104
105
}
106
107
108
}
// end namespace Thyra
109
110
111
#endif
// THYRA_DIAGONAL_LINEAR_OP_WITH_SOLVE_HPP
Teuchos::Ptr
Teuchos::RCP
Teuchos::RCP::ptr
Ptr< T > ptr() const
Thyra::DefaultDiagonalLinearOp::initialize
void initialize(const RCP< const VectorSpaceBase< Scalar > > &space)
Initialize given a vector space which allocates a vector internally.
Definition
Thyra_DefaultDiagonalLinearOp_def.hpp:60
Thyra::DefaultDiagonalLinearOp::getDiag
RCP< const VectorBase< Scalar > > getDiag() const
Definition
Thyra_DefaultDiagonalLinearOp_def.hpp:116
Thyra::DefaultDiagonalLinearOpWithSolve::solveSupportsSolveMeasureTypeImpl
bool solveSupportsSolveMeasureTypeImpl(EOpTransp M_trans, const SolveMeasureType &solveMeasureType) const
Definition
Thyra_DefaultDiagonalLinearOpWithSolve_def.hpp:59
Thyra::DefaultDiagonalLinearOpWithSolve::solveImpl
SolveStatus< Scalar > solveImpl(const EOpTransp transp, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > > solveCriteria) const
Definition
Thyra_DefaultDiagonalLinearOpWithSolve_def.hpp:68
Thyra::DefaultDiagonalLinearOpWithSolve::solveSupportsImpl
bool solveSupportsImpl(EOpTransp M_trans) const
Definition
Thyra_DefaultDiagonalLinearOpWithSolve_def.hpp:49
Thyra::DefaultDiagonalLinearOpWithSolve::DefaultDiagonalLinearOpWithSolve
DefaultDiagonalLinearOpWithSolve()
Constructs to uninitialized.
Definition
Thyra_DefaultDiagonalLinearOpWithSolve_def.hpp:28
Thyra::LinearOpBase::domain
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
Thyra::MultiVectorBase
Interface for a collection of column vectors called a multi-vector.
Definition
Thyra_MultiVectorBase_decl.hpp:464
Thyra::MultiVectorBase::assign
void assign(const Ptr< MultiVectorBase< Scalar > > &V, Scalar alpha)
V = alpha.
Definition
Thyra_MultiVectorStdOps_def.hpp:122
Thyra::MultiVectorBase::col
RCP< const VectorBase< Scalar > > col(Ordinal j) const
Calls colImpl().
Definition
Thyra_MultiVectorBase_decl.hpp:609
Thyra::VectorBase
Abstract interface for finite-dimensional dense vectors.
Definition
Thyra_VectorBase.hpp:115
Thyra::VectorBase::ele_wise_divide
void ele_wise_divide(const Scalar &alpha, const VectorBase< Scalar > &x, const VectorBase< Scalar > &v, const Ptr< VectorBase< Scalar > > &y)
Element-wise division update: y(i) += alpha * x(i) / v(i), i = 0...y->space()->dim()-1.
Definition
Thyra_VectorStdOps_def.hpp:276
TEUCHOS_ASSERT
#define TEUCHOS_ASSERT(assertion_test)
Thyra::SOLVE_STATUS_CONVERGED
@ SOLVE_STATUS_CONVERGED
The requested solution criteria has likely been achieved.
Definition
Thyra_SolveSupportTypes.hpp:361
Thyra::SOLVE_STATUS_UNKNOWN
@ SOLVE_STATUS_UNKNOWN
The final solution status is unknown but he solve did not totally fail.
Definition
Thyra_SolveSupportTypes.hpp:363
Thyra::NOTRANS
NOTRANS
Type for the dimension of a vector space. `**/ typedef Teuchos::Ordinal Ordinal;.
Definition
Thyra_OperatorVectorTypes.hpp:130
Teuchos::ScalarTraits
Thyra::SolveCriteria
Simple struct that defines the requested solution criteria for a solve.
Definition
Thyra_SolveSupportTypes.hpp:280
Thyra::SolveMeasureType
Solve tolerance type.
Definition
Thyra_SolveSupportTypes.hpp:80
Thyra::SolveStatus
Simple struct for the return status from a solve.
Definition
Thyra_SolveSupportTypes.hpp:391
Thyra::SolveStatus::unknownTolerance
static ScalarMag unknownTolerance()
Definition
Thyra_SolveSupportTypes.hpp:395
Thyra::SolveStatus::solveStatus
ESolveStatus solveStatus
The return status of the solve.
Definition
Thyra_SolveSupportTypes.hpp:397
Thyra::SolveStatus::achievedTol
ScalarMag achievedTol
The maximum final tolerance actually achieved by the (block) linear solve. A value of unknownToleranc...
Definition
Thyra_SolveSupportTypes.hpp:401
Generated by
1.17.0