00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef RYTHMOS_EXTRACT_STATE_AND_SENS_HPP
00030 #define RYTHMOS_EXTRACT_STATE_AND_SENS_HPP
00031
00032
00033 #include "Rythmos_Types.hpp"
00034 #include "Thyra_DefaultMultiVectorProductVector.hpp"
00035 #include "Thyra_ProductVectorBase.hpp"
00036
00037
00038 namespace Rythmos {
00039
00040
00058 template<class Scalar>
00059 void extractStateAndSens(
00060 const RCP<const Thyra::VectorBase<Scalar> > &x_bar,
00061 const RCP<const Thyra::VectorBase<Scalar> > &x_bar_dot,
00062 RCP<const Thyra::VectorBase<Scalar> > *x,
00063 RCP<const Thyra::MultiVectorBase<Scalar> > *S,
00064 RCP<const Thyra::VectorBase<Scalar> > *x_dot,
00065 RCP<const Thyra::MultiVectorBase<Scalar> > *S_dot
00066 );
00067
00068
00069 }
00070
00071
00072
00073
00074
00075
00076
00077 template<class Scalar>
00078 void Rythmos::extractStateAndSens(
00079 const RCP<const Thyra::VectorBase<Scalar> > &x_bar,
00080 const RCP<const Thyra::VectorBase<Scalar> > &x_bar_dot,
00081 RCP<const Thyra::VectorBase<Scalar> > *x,
00082 RCP<const Thyra::MultiVectorBase<Scalar> > *S,
00083 RCP<const Thyra::VectorBase<Scalar> > *x_dot,
00084 RCP<const Thyra::MultiVectorBase<Scalar> > *S_dot
00085 )
00086 {
00087
00088 using Teuchos::rcp_dynamic_cast;
00089
00090 TEST_FOR_EXCEPT(is_null(x_bar));
00091 TEST_FOR_EXCEPT(is_null(x_bar_dot));
00092 TEST_FOR_EXCEPT(0==x);
00093 TEST_FOR_EXCEPT(0==S);
00094 TEST_FOR_EXCEPT(0==x_dot);
00095 TEST_FOR_EXCEPT(0==S_dot);
00096
00097 RCP<const Thyra::ProductVectorBase<Scalar> >
00098 x_bar_pv = Thyra::productVectorBase<Scalar>(x_bar),
00099 x_bar_dot_pv = Thyra::productVectorBase<Scalar>(x_bar_dot);
00100 RCP<const Thyra::DefaultMultiVectorProductVector<Scalar> >
00101 s_bar = rcp_dynamic_cast<const Thyra::DefaultMultiVectorProductVector<Scalar> >(
00102 x_bar_pv->getVectorBlock(1).assert_not_null(), true
00103 ),
00104 s_bar_dot = rcp_dynamic_cast<const Thyra::DefaultMultiVectorProductVector<Scalar> >(
00105 x_bar_dot_pv->getVectorBlock(1).assert_not_null(), true
00106 );
00107 *x = x_bar_pv->getVectorBlock(0);
00108 *S = s_bar->getMultiVector();
00109 *x_dot = x_bar_dot_pv->getVectorBlock(0);
00110 *S_dot = s_bar_dot->getMultiVector();
00111
00112 }
00113
00114
00115 #endif //RYTHMOS_EXTRACT_STATE_AND_SENS_HPP