29 #ifndef RYTHMOS_EXTRACT_STATE_AND_SENS_HPP
30 #define RYTHMOS_EXTRACT_STATE_AND_SENS_HPP
33 #include "Rythmos_Types.hpp"
34 #include "Thyra_DefaultMultiVectorProductVector.hpp"
35 #include "Thyra_ProductVectorBase.hpp"
58 template<
class Scalar>
59 void extractStateAndSens(
60 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar,
61 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar_dot,
62 RCP<
const Thyra::VectorBase<Scalar> > *x,
63 RCP<
const Thyra::MultiVectorBase<Scalar> > *S,
64 RCP<
const Thyra::VectorBase<Scalar> > *x_dot,
65 RCP<
const Thyra::MultiVectorBase<Scalar> > *S_dot
71 template<
class Scalar>
73 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar,
74 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar_dot,
75 RCP<
const Thyra::VectorBase<Scalar> > *x,
76 RCP<
const Thyra::VectorBase<Scalar> > *x_dot
82 template<
class Scalar>
84 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar,
85 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar_dot,
86 RCP<
const Thyra::MultiVectorBase<Scalar> > *S,
87 RCP<
const Thyra::MultiVectorBase<Scalar> > *S_dot
104 template<
class Scalar>
105 void downcastStateAndSens(
106 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar,
107 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar_dot,
108 RCP<
const Thyra::ProductVectorBase<Scalar> > &x_bar_pv,
109 RCP<
const Thyra::ProductVectorBase<Scalar> > &x_bar_dot_pv
112 using Teuchos::rcp_dynamic_cast;
114 TEUCHOS_TEST_FOR_EXCEPT(is_null(x_bar));
115 x_bar_pv = Thyra::productVectorBase<Scalar>(x_bar);
117 TEUCHOS_TEST_FOR_EXCEPT(is_null(x_bar_dot));
118 x_bar_dot_pv = Thyra::productVectorBase<Scalar>(x_bar_dot);
122 template<
class Scalar>
123 void extractStateBlock(
124 const RCP<
const Thyra::ProductVectorBase<Scalar> > &x_bar_pv,
125 const RCP<
const Thyra::ProductVectorBase<Scalar> > &x_bar_dot_pv,
126 RCP<
const Thyra::VectorBase<Scalar> > *x,
127 RCP<
const Thyra::VectorBase<Scalar> > *x_dot
130 TEUCHOS_TEST_FOR_EXCEPT(0==x);
131 *x = x_bar_pv->getVectorBlock(0);
133 TEUCHOS_TEST_FOR_EXCEPT(0==x_dot);
134 *x_dot = x_bar_dot_pv->getVectorBlock(0);
138 template<
class Scalar>
139 void extractSensBlock(
140 const RCP<
const Thyra::ProductVectorBase<Scalar> > &x_bar_pv,
141 const RCP<
const Thyra::ProductVectorBase<Scalar> > &x_bar_dot_pv,
142 RCP<
const Thyra::MultiVectorBase<Scalar> > *S,
143 RCP<
const Thyra::MultiVectorBase<Scalar> > *S_dot)
145 using Teuchos::rcp_dynamic_cast;
147 TEUCHOS_TEST_FOR_EXCEPT(0==S);
148 const RCP<const Thyra::DefaultMultiVectorProductVector<Scalar> >
149 s_bar = rcp_dynamic_cast<
const Thyra::DefaultMultiVectorProductVector<Scalar> >(
150 x_bar_pv->getVectorBlock(1).assert_not_null(), true
152 *S = s_bar->getMultiVector();
154 TEUCHOS_TEST_FOR_EXCEPT(0==S_dot);
155 const RCP<const Thyra::DefaultMultiVectorProductVector<Scalar> >
156 s_bar_dot = rcp_dynamic_cast<
const Thyra::DefaultMultiVectorProductVector<Scalar> >(
157 x_bar_dot_pv->getVectorBlock(1).assert_not_null(), true
159 *S_dot = s_bar_dot->getMultiVector();
168 template<
class Scalar>
169 void Rythmos::extractStateAndSens(
170 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar,
171 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar_dot,
172 RCP<
const Thyra::VectorBase<Scalar> > *x,
173 RCP<
const Thyra::MultiVectorBase<Scalar> > *S,
174 RCP<
const Thyra::VectorBase<Scalar> > *x_dot,
175 RCP<
const Thyra::MultiVectorBase<Scalar> > *S_dot
178 RCP<const Thyra::ProductVectorBase<Scalar> > x_bar_pv, x_bar_dot_pv;
179 downcastStateAndSens(x_bar, x_bar_dot, x_bar_pv, x_bar_dot_pv);
181 extractStateBlock(x_bar_pv, x_bar_dot_pv, x, x_dot);
182 extractSensBlock(x_bar_pv, x_bar_dot_pv, S, S_dot);
186 template<
class Scalar>
187 void Rythmos::extractState(
188 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar,
189 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar_dot,
190 RCP<
const Thyra::VectorBase<Scalar> > *x,
191 RCP<
const Thyra::VectorBase<Scalar> > *x_dot
194 RCP<const Thyra::ProductVectorBase<Scalar> > x_bar_pv, x_bar_dot_pv;
195 downcastStateAndSens(x_bar, x_bar_dot, x_bar_pv, x_bar_dot_pv);
197 extractStateBlock(x_bar_pv, x_bar_dot_pv, x, x_dot);
201 template<
class Scalar>
202 void Rythmos::extractSens(
203 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar,
204 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar_dot,
205 RCP<
const Thyra::MultiVectorBase<Scalar> > *S,
206 RCP<
const Thyra::MultiVectorBase<Scalar> > *S_dot
209 RCP<const Thyra::ProductVectorBase<Scalar> > x_bar_pv, x_bar_dot_pv;
210 downcastStateAndSens(x_bar, x_bar_dot, x_bar_pv, x_bar_dot_pv);
212 extractSensBlock(x_bar_pv, x_bar_dot_pv, S, S_dot);
217 #endif //RYTHMOS_EXTRACT_STATE_AND_SENS_HPP