|
Rythmos - Transient Integration for Differential Equations
Version of the Day
|
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00023 // USA 00024 // Questions? Contact Todd S. Coffey (tscoffe@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 //@HEADER 00028 00029 #ifndef Rythmos_INTERPOLATION_BUFFER_BASE_H 00030 #define Rythmos_INTERPOLATION_BUFFER_BASE_H 00031 00032 #include "Rythmos_Types.hpp" 00033 #include "Rythmos_TimeRange.hpp" 00034 00035 #include "Thyra_VectorBase.hpp" 00036 00037 #include "Teuchos_Describable.hpp" 00038 #include "Teuchos_ParameterListAcceptor.hpp" 00039 #include "Teuchos_VerboseObject.hpp" 00040 #include "Teuchos_implicit_cast.hpp" 00041 #include "Teuchos_Assert.hpp" 00042 #include "Teuchos_as.hpp" 00043 00044 00045 namespace Rythmos { 00046 00047 00067 template<class Scalar> 00068 class InterpolationBufferBase 00069 : virtual public Teuchos::Describable 00070 , virtual public Teuchos::ParameterListAcceptor 00071 , virtual public Teuchos::VerboseObject<InterpolationBufferBase<Scalar> > 00072 { 00073 public: 00074 00076 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag; 00077 00087 virtual RCP<const Thyra::VectorSpaceBase<Scalar> > 00088 get_x_space() const =0; 00089 00125 /* 11/24/08 tscoffe: Proposed new interface for addPoints 00126 * virtual void addPoints( 00127 * const ArrayView<const Scalar>& time_vec, 00128 * const ArrayView<const Ptr<const Thyra::VectorBase<Scalar> > >& x_vec, 00129 * const ArrayView<const Ptr<const Thyra::VectorBase<Scalar> > >& xdot_vec 00130 ) = 0; 00131 */ 00132 00133 virtual void addPoints( 00134 const Array<Scalar>& time_vec, 00135 const Array<RCP<const Thyra::VectorBase<Scalar> > >& x_vec, 00136 const Array<RCP<const Thyra::VectorBase<Scalar> > >& xdot_vec 00137 ) = 0; 00138 00139 /* 00140 virtual void addPoints( 00141 const ArrayView<const Scalar>& time_vec, 00142 const ArrayView<const Ptr<const VectorBase<Scalar> > >& x_vec, 00143 const ArrayView<const Ptr<const VectorBase<Scalar> > >& xdot_vec 00144 ) =0; 00145 */ 00146 00147 00156 virtual TimeRange<Scalar> getTimeRange() const = 0; 00157 00184 /* 11/24/08 tscoffe: Proposed new interface for getPoints 00185 * virtual void getPoints( 00186 * const ArrayView<const Scalar>& time_vec, 00187 * const ArrayView<const Ptr<Thyra::VectorBase<Scalar> > >& x_vec, 00188 * const ArrayView<const Ptr<Thyra::VectorBase<Scalar> > >& xdot_vec, 00189 * const ArrayView<ScalarMag>& accuracy_vec 00190 * ) const = 0; 00191 */ 00192 virtual void getPoints( 00193 const Array<Scalar>& time_vec, 00194 Array<RCP<const Thyra::VectorBase<Scalar> > >* x_vec, 00195 Array<RCP<const Thyra::VectorBase<Scalar> > >* xdot_vec, 00196 Array<ScalarMag>* accuracy_vec 00197 ) const = 0; 00198 00199 /* 00200 virtual void getPoints( 00201 const ArrayView<const Scalar>& time_vec, 00202 const ArrayView<const Ptr<VectorBase<Scalar> > >& x_vec, 00203 const ArrayView<const Ptr<VectorBase<Scalar> > >& xdot_vec, 00204 const ArrayView<ScalarMag>& accuracy_vec 00205 ) const = 0; 00206 */ 00207 00217 // 11/24/08 tscoffe: Proposal: get rid of "getNodes" in abstract base interface 00218 virtual void getNodes(Array<Scalar>* time_vec) const = 0; 00219 00233 // 11/24/08 tscoffe: Proposal: get rid of "removeNodes" in abstract base interface 00234 virtual void removeNodes(Array<Scalar>& time_vec) =0; 00235 00236 00242 virtual int getOrder() const = 0; 00243 00244 }; 00245 00246 00251 template<class Scalar> 00252 RCP<const Thyra::VectorBase<Scalar> > 00253 get_x( const InterpolationBufferBase<Scalar> &interpBuffer, const Scalar &t ) 00254 { 00255 using Teuchos::implicit_cast; 00256 Array<Scalar> time_vec; 00257 time_vec.push_back(t); 00258 Array<RCP<const Thyra::VectorBase<Scalar> > > x_vec; 00259 interpBuffer.getPoints(time_vec,&x_vec,0,0); 00260 TEUCHOS_ASSERT( 1 == implicit_cast<int>(x_vec.size()) ); 00261 return x_vec[0]; 00262 } 00263 00264 /* 11/24/08 tscoffe: Proposed new get_x function: 00265 * template<class Scalar> 00266 * void get_x( const InterpolationBufferBase<Scalar> &interpBuffer, const Scalar &t, const Ptr<Thyra::VectorBase<Scalar> >& x_out ) 00267 * This will copy data into your vector and it won't be responsible for allocating new memory 00268 */ 00269 00270 00275 template<class Scalar> 00276 RCP<const Thyra::VectorBase<Scalar> > 00277 get_xdot( const InterpolationBufferBase<Scalar> &interpBuffer, const Scalar &t ) 00278 { 00279 using Teuchos::implicit_cast; 00280 Array<Scalar> time_vec; 00281 time_vec.push_back(t); 00282 Array<RCP<const Thyra::VectorBase<Scalar> > > xdot_vec; 00283 interpBuffer.getPoints(time_vec,0,&xdot_vec,0); 00284 TEUCHOS_ASSERT( 1 == implicit_cast<int>(xdot_vec.size()) ); 00285 return xdot_vec[0]; 00286 } 00287 00288 /* 11/24/08 tscoffe: Proposed new get_xdot function 00289 * template<class Scalar> 00290 * void get_xdot( const InterpolationBufferBase<Scalar> &interpBuffer, const Scalar &t, const Ptr<Thyra::VectorBase<Scalar> >& xdot_out ) 00291 * This will copy data into your vector and it won't be responsible for allocating new memory 00292 */ 00293 00298 template<class Scalar> 00299 void get_x_and_x_dot( 00300 const InterpolationBufferBase<Scalar> &interpBuffer, 00301 const Scalar t, 00302 const Ptr<RCP<const Thyra::VectorBase<Scalar> > > &x, 00303 const Ptr<RCP<const Thyra::VectorBase<Scalar> > > &x_dot 00304 ) 00305 { 00306 Array<Scalar> time_vec; 00307 time_vec.push_back(t); 00308 Array<RCP<const Thyra::VectorBase<Scalar> > > x_vec; 00309 Array<RCP<const Thyra::VectorBase<Scalar> > > x_dot_vec; 00310 interpBuffer.getPoints( 00311 time_vec, 00312 nonnull(x) ? &x_vec : 0, 00313 nonnull(x_dot) ? &x_dot_vec : 0, 00314 0 00315 ); 00316 if (nonnull(x)) *x = x_vec[0]; 00317 if (nonnull(x_dot)) *x_dot = x_dot_vec[0]; 00318 } 00319 00321 template<class Scalar> 00322 void get_x_and_x_dot( 00323 const InterpolationBufferBase<Scalar> &interpBuffer, 00324 const Scalar t, 00325 RCP<const Thyra::VectorBase<Scalar> > *x, 00326 RCP<const Thyra::VectorBase<Scalar> > *x_dot 00327 ) 00328 { 00329 get_x_and_x_dot(interpBuffer, t, Teuchos::ptr(x), Teuchos::ptr(x_dot)); 00330 } 00331 00332 /* 11/24/08 tscoffe: Proposed new get_x_and_xdot function: 00333 * template<class Scalar> 00334 * void get_x_and_xdot( const InterpolationBufferBase<Scalar> &interpBuffer, 00335 * const Scalar &t, 00336 * const Ptr<Thyra::VectorBase<Scalar> >& x_out, 00337 * const Ptr<Thyra::VectorBase<Scalar> >& xdot_out ) 00338 * This will copy data into your vector and it won't be responsible for allocating new memory 00339 */ 00340 00341 } // namespace Rythmos 00342 00343 00344 #endif //Rythmos_INTERPOLATION_BUFFER_BASE_H
1.7.6.1