11 #include "Thyra_VectorStdOps.hpp"
12 #include "Thyra_ProductVectorSpaceBase.hpp"
13 #include "Thyra_TpetraLinearOp.hpp"
15 #include "Tpetra_CrsMatrix.hpp"
20 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
28 bool x_matches=
false, f_matches=
false, dxdt_matches=
false;
35 x_matches = range->isCompatible(*get_x()->space());
40 dxdt_matches = range->isCompatible(*get_dxdt()->space());
45 f_matches = range->isCompatible(*get_f()->space());
49 else if(get_x()!=null && get_dxdt()!=null) {
51 x_matches = get_x()->space()->isCompatible(*get_dxdt()->space());
52 dxdt_matches = x_matches;
55 f_matches = x_matches = dxdt_matches =
true;
58 return x_matches && dxdt_matches && f_matches;
61 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
66 using Thyra::PhysicallyBlockedLinearOpBase;
67 using Thyra::ProductVectorSpaceBase;
69 using Teuchos::rcp_dynamic_cast;
71 if(get_x()!=Teuchos::null) Thyra::assign<ScalarT>(x.ptr(),0.0);
72 if(get_dxdt()!=Teuchos::null) Thyra::assign<ScalarT>(get_dxdt().ptr(),0.0);
73 if(get_f()!=Teuchos::null) Thyra::assign<ScalarT>(get_f().ptr(),0.0);
74 if(get_A()!=Teuchos::null) {
76 = rcp_dynamic_cast<PhysicallyBlockedLinearOpBase<ScalarT> >(get_A(),
true);
81 for(
int i=0;i<range->numBlocks();i++) {
82 for(
int j=0;j<domain->numBlocks();j++) {
84 if(block!=Teuchos::null) {
86 rcp_dynamic_cast<Thyra::TpetraLinearOp<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> >(block,
true)->getTpetraOperator();
92 rcp_dynamic_cast<Tpetra::CrsMatrix<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> >(t_block,
true);
95 mat->setAllToScalar(0.0);
96 mat->fillComplete(map_j,map_i);
103 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
108 using Thyra::PhysicallyBlockedLinearOpBase;
109 using Thyra::ProductVectorSpaceBase;
111 using Teuchos::rcp_dynamic_cast;
113 if(get_A()!=Teuchos::null) {
115 = rcp_dynamic_cast<PhysicallyBlockedLinearOpBase<ScalarT> >(get_A(),
true);
120 for(
int i=0;i<range->numBlocks();i++) {
121 for(
int j=0;j<domain->numBlocks();j++) {
123 if(block!=Teuchos::null) {
125 rcp_dynamic_cast<Thyra::TpetraLinearOp<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> >(block,
true)->getTpetraOperator();
132 rcp_dynamic_cast<Tpetra::CrsMatrix<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> >(t_block,
true);
135 mat->setAllToScalar(value);
136 mat->fillComplete(map_j,map_i);
143 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
147 set_x(Teuchos::null);
148 set_dxdt(Teuchos::null);
149 set_f(Teuchos::null);
150 set_A(Teuchos::null);
153 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
158 using Thyra::PhysicallyBlockedLinearOpBase;
159 using Thyra::ProductVectorSpaceBase;
161 using Teuchos::rcp_dynamic_cast;
163 if(get_A()!=Teuchos::null) {
165 = rcp_dynamic_cast<PhysicallyBlockedLinearOpBase<ScalarT> >(get_A(),
true);
170 for(
int i=0;i<range->numBlocks();i++) {
171 for(
int j=0;j<domain->numBlocks();j++) {
173 if(block!=Teuchos::null) {
175 rcp_dynamic_cast<Thyra::TpetraLinearOp<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> >(block,
true)->getTpetraOperator();
178 rcp_dynamic_cast<Tpetra::CrsMatrix<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> >(t_block,
true);
187 template <
typename ScalarT,
typename LocalOrdinalT,
typename GlobalOrdinalT,
typename NodeT>
192 using Thyra::PhysicallyBlockedLinearOpBase;
193 using Thyra::ProductVectorSpaceBase;
195 using Teuchos::rcp_dynamic_cast;
197 if(get_A()!=Teuchos::null) {
199 = rcp_dynamic_cast<PhysicallyBlockedLinearOpBase<ScalarT> >(get_A(),
true);
204 for(
int i=0;i<range->numBlocks();i++) {
205 for(
int j=0;j<domain->numBlocks();j++) {
207 if(block!=Teuchos::null) {
209 rcp_dynamic_cast<Thyra::TpetraLinearOp<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> >(block,
true)->getTpetraOperator();
215 rcp_dynamic_cast<Tpetra::CrsMatrix<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> >(t_block,
true);
217 mat->fillComplete(map_j,map_i);
bool checkCompatibility() const
Make sure row and column spaces match up.
void initializeMatrix(ScalarT value)
Put a particular scalar in the matrix.
virtual void initialize()