Rythmos_IntegratorBase.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_INTEGRATOR_BASE_H
00030 #define Rythmos_INTEGRATOR_BASE_H
00031 
00032 #include "Rythmos_InterpolationBufferBase.hpp"
00033 #include "Rythmos_StepperBase.hpp"
00034 #include "Teuchos_as.hpp"
00035 
00036 
00037 namespace Rythmos {
00038 
00039 
00040 namespace Exceptions {
00041 
00042 
00046 class GetFwdPointsFailed : public ::Rythmos::Exceptions::ExceptionBase
00047 {public: GetFwdPointsFailed(const std::string &what):ExceptionBase(what) {}};
00048 
00049 
00050 } // namespace Exceptions
00051 
00052 
00061 template<class Scalar> 
00062 class IntegratorBase : virtual public InterpolationBufferBase<Scalar>
00063 {
00064 public:
00065   
00067   typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
00068 
00070   virtual RCP<IntegratorBase<Scalar> > cloneIntegrator() const
00071     { return Teuchos::null; }
00072 
00074   virtual bool acceptsTrailingInterpolationBuffer() const 
00075     { return false; }
00076 
00078   virtual void setTrailingInterpolationBuffer(
00079     const RCP<InterpolationBufferBase<Scalar> > &trailingInterpBuffer
00080     ) 
00081     { TEST_FOR_EXCEPT(true); }
00082 
00084   virtual RCP<InterpolationBufferBase<Scalar> >
00085   getTrailingInterpolationBuffer()
00086     { return Teuchos::null; }
00087 
00089   virtual RCP<const InterpolationBufferBase<Scalar> >
00090   getTrailingInterpolationBuffer() const
00091     { return Teuchos::null; }
00092 
00122   virtual void setStepper(
00123     const RCP<StepperBase<Scalar> > &stepper,
00124     const Scalar &finalTime,
00125     const bool landOnFinalTime = true
00126     ) =0;
00127 
00133   virtual Teuchos::RCP<const StepperBase<Scalar> > getStepper() const =0;
00134 
00143   virtual RCP<StepperBase<Scalar> > unSetStepper() =0;
00144 
00187   virtual void getFwdPoints(
00188     const Array<Scalar>& time_vec,
00189     Array<RCP<const Thyra::VectorBase<Scalar> > >* x_vec,
00190     Array<RCP<const Thyra::VectorBase<Scalar> > >* xdot_vec,
00191     Array<ScalarMag>* accuracy_vec
00192     ) =0;
00193 
00202   virtual TimeRange<Scalar> getFwdTimeRange() const =0;
00203 
00204 };
00205 
00206 
00207 // 2007/09/14: rabartl: ToDo: Below, Move these functions into a file
00208 // Rythmos_IntegratorBaseHelpers.hpp.
00209 
00210 
00215 template<class Scalar> 
00216 RCP<const Thyra::VectorBase<Scalar> >
00217 get_fwd_x( IntegratorBase<Scalar>& integrator, const Scalar t )
00218 {
00219   Array<Scalar> time_vec;
00220   time_vec.push_back(t);
00221   Array<RCP<const Thyra::VectorBase<Scalar> > > x_vec;
00222   integrator.getFwdPoints(time_vec,&x_vec,0,0);
00223   return x_vec[0];
00224 }
00225 
00226 
00251 template<class Scalar> 
00252 void get_fwd_x_and_x_dot(
00253   IntegratorBase<Scalar>& integrator,
00254   const Scalar t,
00255   RCP<const Thyra::VectorBase<Scalar> > *x,
00256   RCP<const Thyra::VectorBase<Scalar> > *x_dot
00257   )
00258 {
00259   Array<Scalar> time_vec;
00260   time_vec.push_back(t);
00261   Array<RCP<const Thyra::VectorBase<Scalar> > > x_vec;
00262   Array<RCP<const Thyra::VectorBase<Scalar> > > x_dot_vec;
00263   integrator.getFwdPoints(
00264     time_vec,
00265     x ? &x_vec : 0,
00266     x_dot ? &x_dot_vec : 0,
00267     0
00268     );
00269   if (x) *x = x_vec[0];
00270   if (x_dot) *x_dot = x_dot_vec[0];
00271 }
00272 
00273  
00274 } // namespace Rythmos
00275 
00276 
00277 #endif // Rythmos_INTEGRATOR_BASE_H
00278 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends

Generated on Tue Oct 20 10:24:09 2009 for Rythmos - Transient Integration for Differential Equations by  doxygen 1.6.1