Rythmos_extractStateAndSens.hpp

00001 //@HEADER
00002 // ***********************************************************************
00003 //
00004 //                     Rythmos Package
00005 //                 Copyright (2006) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Todd S. Coffey (tscoffe@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 //@HEADER
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 } // namespace Rythmos
00070 
00071 
00072 //
00073 // Implementations
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

Generated on Tue Oct 20 12:46:07 2009 for Rythmos - Transient Integration for Differential Equations by doxygen 1.4.7