43 #ifndef __Panzer_TpetraLinearObjContainer_hpp__
44 #define __Panzer_TpetraLinearObjContainer_hpp__
46 #include "PanzerDiscFE_config.hpp"
51 #include "Tpetra_Vector.hpp"
52 #include "Tpetra_CrsMatrix.hpp"
54 #include "Thyra_TpetraThyraWrappers.hpp"
64 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT=panzer::TpetraNodeType>
72 typedef Tpetra::Vector<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>
VectorType;
73 typedef Tpetra::CrsMatrix<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>
CrsMatrixType;
74 typedef Tpetra::CrsGraph<LocalOrdinalT,GlobalOrdinalT,NodeT>
CrsGraphType;
75 typedef Tpetra::Map<LocalOrdinalT,GlobalOrdinalT,NodeT>
MapType;
76 typedef Tpetra::Import<LocalOrdinalT,GlobalOrdinalT,NodeT>
ImportType;
77 typedef Tpetra::Export<LocalOrdinalT,GlobalOrdinalT,NodeT>
ExportType;
80 const Teuchos::RCP<
const Tpetra::Map<LocalOrdinalT,GlobalOrdinalT,NodeT> > & range)
82 domainSpace = Thyra::createVectorSpace<ScalarT>(domain);
83 rangeSpace = Thyra::createVectorSpace<ScalarT>(range);
88 if(
get_x()!=Teuchos::null)
get_x()->putScalar(0.0);
90 if(
get_f()!=Teuchos::null)
get_f()->putScalar(0.0);
91 if(
get_A()!=Teuchos::null) {
94 mat->setAllToScalar(0.0);
102 set_x(Teuchos::null);
104 set_f(Teuchos::null);
105 set_A(Teuchos::null);
123 A->setAllToScalar(value);
129 if(in==Teuchos::null) {
x = Teuchos::null;
return; }
132 = TOE::getConstTpetraVector(in);
133 x = Teuchos::rcp_const_cast<Tpetra::Vector<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> >(x_const);
136 {
return (
x==Teuchos::null) ? Teuchos::null : Thyra::createVector(
x,
domainSpace); }
140 if(in==Teuchos::null) {
dxdt = Teuchos::null;
return; }
143 = TOE::getConstTpetraVector(in);
144 dxdt = Teuchos::rcp_const_cast<Tpetra::Vector<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> >(dxdt_const);
150 {
f = (in==Teuchos::null) ? Teuchos::null : TOE::getTpetraVector(in); }
152 {
return (
f==Teuchos::null) ? Teuchos::null : Thyra::createVector(
f,
rangeSpace); }
155 {
A = (in==Teuchos::null) ? Teuchos::null : Teuchos::rcp_dynamic_cast<CrsMatrixType>(TOE::getTpetraOperator(in),
true); }
157 {
return (
A==Teuchos::null) ? Teuchos::null : Thyra::createLinearOp<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>(
A,
rangeSpace,
domainSpace); }
160 typedef Thyra::TpetraOperatorVectorExtraction<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>
TOE;
TpetraLinearObjContainer(const Teuchos::RCP< const Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > > &domain, const Teuchos::RCP< const Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > > &range)
const Teuchos::RCP< CrsMatrixType > get_A() const
const Teuchos::RCP< VectorType > get_x() const
Teuchos::RCP< Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > > f
Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > VectorType
Teuchos::RCP< Tpetra::CrsMatrix< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > > A
Tpetra::Map< LocalOrdinalT, GlobalOrdinalT, NodeT > MapType
void clear()
Wipe out stored data.
virtual void set_A_th(const Teuchos::RCP< Thyra::LinearOpBase< ScalarT > > &in)
const Teuchos::RCP< VectorType > get_dxdt() const
virtual Teuchos::RCP< Thyra::VectorBase< ScalarT > > get_x_th() const
Teuchos::RCP< const Thyra::VectorSpaceBase< ScalarT > > domainSpace
Tpetra::Export< LocalOrdinalT, GlobalOrdinalT, NodeT > ExportType
Tpetra::CrsMatrix< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > CrsMatrixType
virtual Teuchos::RCP< Thyra::VectorBase< ScalarT > > get_dxdt_th() const
void set_x(const Teuchos::RCP< VectorType > &in)
virtual void set_dxdt_th(const Teuchos::RCP< Thyra::VectorBase< ScalarT > > &in)
Tpetra::CrsGraph< LocalOrdinalT, GlobalOrdinalT, NodeT > CrsGraphType
Teuchos::RCP< Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > > x
Tpetra::Import< LocalOrdinalT, GlobalOrdinalT, NodeT > ImportType
void set_dxdt(const Teuchos::RCP< VectorType > &in)
Teuchos::RCP< Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > > dxdt
virtual void set_f_th(const Teuchos::RCP< Thyra::VectorBase< ScalarT > > &in)
virtual Teuchos::RCP< Thyra::LinearOpBase< ScalarT > > get_A_th() const
void set_A(const Teuchos::RCP< CrsMatrixType > &in)
Teuchos::RCP< const Thyra::VectorSpaceBase< ScalarT > > rangeSpace
void set_f(const Teuchos::RCP< VectorType > &in)
Thyra::TpetraOperatorVectorExtraction< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > TOE
LinearObjContainer::Members Members
virtual void set_x_th(const Teuchos::RCP< Thyra::VectorBase< ScalarT > > &in)
const Teuchos::RCP< VectorType > get_f() const
void initializeMatrix(ScalarT value)
Put a particular scalar in the matrix.
virtual void initialize()
virtual Teuchos::RCP< Thyra::VectorBase< ScalarT > > get_f_th() const
TpetraLinearObjContainer()