Thyra Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
adapters
epetra
src
Thyra_DiagonalEpetraLinearOpWithSolveFactory.cpp
Go to the documentation of this file.
1
// @HEADER
2
// ***********************************************************************
3
//
4
// Thyra: Interfaces and Support for Abstract Numerical Algorithms
5
// Copyright (2004) Sandia Corporation
6
//
7
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8
// license for use of this work by or on behalf of the U.S. Government.
9
//
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
38
//
39
// ***********************************************************************
40
// @HEADER
41
42
#include "
Thyra_DiagonalEpetraLinearOpWithSolveFactory.hpp
"
43
#include "Thyra_DefaultDiagonalLinearOpWithSolve.hpp"
44
#include "
Thyra_EpetraLinearOp.hpp
"
45
#include "
Thyra_EpetraThyraWrappers.hpp
"
46
#include "
Teuchos_dyn_cast.hpp
"
47
48
#include "Epetra_RowMatrix.h"
49
#include "Epetra_Vector.h"
50
#include "Epetra_Map.h"
51
52
53
namespace
Thyra
{
54
55
56
bool
DiagonalEpetraLinearOpWithSolveFactory::isCompatible
(
57
const
LinearOpSourceBase<double> &fwdOpSrc
58
)
const
59
{
60
using
Teuchos::outArg;
61
RCP<const LinearOpBase<double>
>
62
fwdOp = fwdOpSrc.getOp();
63
const
EpetraLinearOpBase
*eFwdOp = NULL;
64
if
( ! (eFwdOp =
dynamic_cast<
const
EpetraLinearOpBase
*
>
(&*fwdOp)) )
65
return
false
;
66
RCP<const Epetra_Operator>
epetraFwdOp;
67
EOpTransp epetraFwdOpTransp;
68
EApplyEpetraOpAs
epetraFwdOpApplyAs;
69
EAdjointEpetraOp
epetraFwdOpAdjointSupport;
70
eFwdOp->
getEpetraOpView
(outArg(epetraFwdOp), outArg(epetraFwdOpTransp),
71
outArg(epetraFwdOpApplyAs), outArg(epetraFwdOpAdjointSupport) );
72
if
( !
dynamic_cast<
const
Epetra_RowMatrix*
>
(&*epetraFwdOp) )
73
return
false
;
74
return
true
;
75
}
76
77
78
RCP<LinearOpWithSolveBase<double>
>
79
DiagonalEpetraLinearOpWithSolveFactory::createOp
()
const
80
{
81
return
Teuchos::rcp
(
new
DefaultDiagonalLinearOpWithSolve<double>());
82
}
83
84
85
void
DiagonalEpetraLinearOpWithSolveFactory::initializeOp
(
86
const
RCP
<
const
LinearOpSourceBase<double> > &fwdOpSrc
87
,LinearOpWithSolveBase<double> *Op
88
,
const
ESupportSolveUse
/* supportSolveUse */
89
)
const
90
{
91
using
Teuchos::outArg;
92
TEUCHOS_TEST_FOR_EXCEPT
(Op==NULL);
93
TEUCHOS_TEST_FOR_EXCEPT
(fwdOpSrc.get()==NULL);
94
TEUCHOS_TEST_FOR_EXCEPT
(fwdOpSrc->getOp().get()==NULL);
95
RCP<const LinearOpBase<double>
> fwdOp = fwdOpSrc->getOp();
96
const
EpetraLinearOpBase
&eFwdOp =
Teuchos::dyn_cast<const EpetraLinearOpBase>
(*fwdOp);
97
RCP<const Epetra_Operator>
epetraFwdOp;
98
EOpTransp epetraFwdOpTransp;
99
EApplyEpetraOpAs
epetraFwdOpApplyAs;
100
EAdjointEpetraOp
epetraFwdOpAdjointSupport;
101
eFwdOp.
getEpetraOpView
(outArg(epetraFwdOp), outArg(epetraFwdOpTransp),
102
outArg(epetraFwdOpApplyAs), outArg(epetraFwdOpAdjointSupport) );
103
const
Epetra_RowMatrix &eRMOp =
104
Teuchos::dyn_cast<const Epetra_RowMatrix>
(*epetraFwdOp);
105
const
Epetra_Map &map = eRMOp.OperatorDomainMap();
106
RCP<Epetra_Vector>
107
e_diag =
Teuchos::rcp
(
new
Epetra_Vector(map));
108
eRMOp.ExtractDiagonalCopy(*e_diag);
109
RCP< const VectorSpaceBase<double>
>
110
space =
create_VectorSpace
(
Teuchos::rcp
(
new
Epetra_Map(map)));
111
RCP< const VectorBase<double>
>
112
diag =
create_Vector
(e_diag,space);
113
Teuchos::set_extra_data<RCP<const LinearOpSourceBase<double> > >(
114
fwdOpSrc,
"Thyra::DiagonalEpetraLinearOpWithSolveFactory::fwdOpSrc"
,
115
Teuchos::inOutArg(diag)
116
);
117
Teuchos::dyn_cast< DefaultDiagonalLinearOpWithSolve<double>
>(*Op).initialize(
118
Teuchos::rcp_implicit_cast<
const
VectorBase<double> >(diag)
119
);
120
// Above cast is questionable but should be okay based on use.
121
}
122
123
124
void
DiagonalEpetraLinearOpWithSolveFactory::uninitializeOp
(
125
LinearOpWithSolveBase<double> *Op
126
,
RCP
<
const
LinearOpSourceBase<double> > *fwdOpSrc
127
,
RCP
<
const
PreconditionerBase<double> > *prec
128
,
RCP
<
const
LinearOpSourceBase<double> > *approxFwdOpSrc
129
,ESupportSolveUse *
/* supportSolveUse */
130
)
const
131
{
132
using
Teuchos::get_extra_data;
133
TEUCHOS_TEST_FOR_EXCEPT
(Op==NULL);
134
DefaultDiagonalLinearOpWithSolve<double>
135
&diagOp =
Teuchos::dyn_cast<DefaultDiagonalLinearOpWithSolve<double>
>(*Op);
136
RCP< const VectorBase<double>
>
137
diag = diagOp.getDiag();
138
if
( fwdOpSrc ) {
139
if
(diag.
get
()) {
140
*fwdOpSrc =
141
get_extra_data<RCP<const LinearOpSourceBase<double> > >(
142
diag,
"Thyra::DiagonalEpetraLinearOpWithSolveFactory::fwdOpSrc"
143
);
144
}
145
}
146
else
{
147
*fwdOpSrc = Teuchos::null;
148
}
149
if
(prec) *prec = Teuchos::null;
// We never keep a preconditioner!
150
if
(approxFwdOpSrc) *approxFwdOpSrc = Teuchos::null;
// We never keep a preconditioner!
151
}
152
153
154
// Overridden from ParameterListAcceptor
155
156
157
void
DiagonalEpetraLinearOpWithSolveFactory::setParameterList
(
158
RCP<Teuchos::ParameterList>
const
&
/* paramList */
159
)
160
{}
161
162
163
RCP<Teuchos::ParameterList>
164
DiagonalEpetraLinearOpWithSolveFactory::getNonconstParameterList
()
165
{
166
return
Teuchos::null;
167
}
168
169
170
RCP<Teuchos::ParameterList>
171
DiagonalEpetraLinearOpWithSolveFactory::unsetParameterList
()
172
{
173
return
Teuchos::null;
174
}
175
176
177
RCP<const Teuchos::ParameterList>
178
DiagonalEpetraLinearOpWithSolveFactory::getParameterList
()
const
179
{
180
return
Teuchos::null;
181
}
182
183
184
RCP<const Teuchos::ParameterList>
185
DiagonalEpetraLinearOpWithSolveFactory::getValidParameters
()
const
186
{
187
return
Teuchos::null;
188
}
189
190
191
}
// namespace Thyra
Teuchos_dyn_cast.hpp
Thyra_DiagonalEpetraLinearOpWithSolveFactory.hpp
Thyra_EpetraLinearOp.hpp
Thyra_EpetraThyraWrappers.hpp
Teuchos::RCP
Teuchos::RCP::get
T * get() const
Thyra::DiagonalEpetraLinearOpWithSolveFactory::getNonconstParameterList
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
Definition
Thyra_DiagonalEpetraLinearOpWithSolveFactory.cpp:164
Thyra::DiagonalEpetraLinearOpWithSolveFactory::setParameterList
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const ¶mList)
Definition
Thyra_DiagonalEpetraLinearOpWithSolveFactory.cpp:157
Thyra::DiagonalEpetraLinearOpWithSolveFactory::initializeOp
void initializeOp(const Teuchos::RCP< const LinearOpSourceBase< double > > &fwdOpSrc, LinearOpWithSolveBase< double > *Op, const ESupportSolveUse supportSolveUse) const
Definition
Thyra_DiagonalEpetraLinearOpWithSolveFactory.cpp:85
Thyra::DiagonalEpetraLinearOpWithSolveFactory::isCompatible
bool isCompatible(const LinearOpSourceBase< double > &fwdOpSrc) const
Definition
Thyra_DiagonalEpetraLinearOpWithSolveFactory.cpp:56
Thyra::DiagonalEpetraLinearOpWithSolveFactory::getValidParameters
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Definition
Thyra_DiagonalEpetraLinearOpWithSolveFactory.cpp:185
Thyra::DiagonalEpetraLinearOpWithSolveFactory::uninitializeOp
void uninitializeOp(LinearOpWithSolveBase< double > *Op, Teuchos::RCP< const LinearOpSourceBase< double > > *fwdOpSrc, Teuchos::RCP< const PreconditionerBase< double > > *prec, Teuchos::RCP< const LinearOpSourceBase< double > > *approxFwdOpSrc, ESupportSolveUse *supportSolveUse) const
Definition
Thyra_DiagonalEpetraLinearOpWithSolveFactory.cpp:124
Thyra::DiagonalEpetraLinearOpWithSolveFactory::createOp
Teuchos::RCP< LinearOpWithSolveBase< double > > createOp() const
Definition
Thyra_DiagonalEpetraLinearOpWithSolveFactory.cpp:79
Thyra::DiagonalEpetraLinearOpWithSolveFactory::unsetParameterList
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
Definition
Thyra_DiagonalEpetraLinearOpWithSolveFactory.cpp:171
Thyra::DiagonalEpetraLinearOpWithSolveFactory::getParameterList
Teuchos::RCP< const Teuchos::ParameterList > getParameterList() const
Definition
Thyra_DiagonalEpetraLinearOpWithSolveFactory.cpp:178
Thyra::EpetraLinearOpBase
Abstract base class for all LinearOpBase objects that can return an Epetra_Operator view of themselve...
Definition
Thyra_EpetraLinearOpBase.hpp:69
Thyra::EpetraLinearOpBase::getEpetraOpView
virtual void getEpetraOpView(const Ptr< RCP< const Epetra_Operator > > &epetraOp, const Ptr< EOpTransp > &epetraOpTransp, const Ptr< EApplyEpetraOpAs > &epetraOpApplyAs, const Ptr< EAdjointEpetraOp > &epetraOpAdjointSupport) const =0
Return a smart pointer to a const Epetra_Operator view of this object and how the object is applied t...
Thyra::EApplyEpetraOpAs
EApplyEpetraOpAs
Determine how the apply an Epetra_Operator as a linear operator.
Definition
Thyra_EpetraTypes.hpp:93
Thyra::create_Vector
RCP< VectorBase< double > > create_Vector(const RCP< Epetra_Vector > &epetra_v, const RCP< const VectorSpaceBase< double > > &space=Teuchos::null)
Create a non-const VectorBase object from a non-const Epetra_Vector object.
Definition
Thyra_EpetraThyraWrappers.cpp:193
Thyra::create_VectorSpace
RCP< const VectorSpaceBase< double > > create_VectorSpace(const RCP< const Epetra_Map > &epetra_map)
Create an VectorSpaceBase object given an Epetra_Map object.
Definition
Thyra_EpetraThyraWrappers.cpp:139
Thyra::EAdjointEpetraOp
EAdjointEpetraOp
Determine if adjoints are supported on Epetra_Opeator or not.
Definition
Thyra_EpetraTypes.hpp:64
TEUCHOS_TEST_FOR_EXCEPT
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
Teuchos::rcp
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::dyn_cast
T_To & dyn_cast(T_From &from)
Thyra
Definition
Thyra_DiagonalEpetraLinearOpWithSolveFactory.cpp:53
Generated by
1.17.0