Rythmos_CubicSplineInterpolator_decl.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_CUBIC_SPLINE_INTERPOLATOR_DECL_H
00030 #define Rythmos_CUBIC_SPLINE_INTERPOLATOR_DECL_H
00031 
00032 #include "Rythmos_InterpolatorBase.hpp"
00033 #include "Rythmos_Types.hpp"
00034 
00035 
00036 namespace Rythmos {
00037 
00038 using Teuchos::Ptr;
00039 
00040 template<class Scalar>
00041 class CubicSplineCoeff {
00042   public:
00043     Array<Scalar> t;
00044     Array<RCP<Thyra::VectorBase<Scalar> > > a;
00045     Array<RCP<Thyra::VectorBase<Scalar> > > b;
00046     Array<RCP<Thyra::VectorBase<Scalar> > > c;
00047     Array<RCP<Thyra::VectorBase<Scalar> > > d;
00048 };
00049 
00050 
00054 template<class Scalar>
00055 class CubicSplineInterpolator : virtual public InterpolatorBase<Scalar>
00056 {
00057 public:
00058 
00060   ~CubicSplineInterpolator() {};
00061 
00063   CubicSplineInterpolator();
00064 
00066   bool supportsCloning() const;
00067 
00069   RCP<InterpolatorBase<Scalar> > cloneInterpolator() const;
00070 
00072   void setNodes(
00073     const RCP<const typename DataStore<Scalar>::DataStoreVector_t> & nodes
00074     );
00075 
00077   void interpolate(
00078     const Array<Scalar> &t_values,
00079     typename DataStore<Scalar>::DataStoreVector_t *data_out
00080     ) const;
00081 
00083   int order() const; 
00084 
00086   std::string description() const;
00087 
00089   void describe(
00090     FancyOStream &out,
00091     const Teuchos::EVerbosityLevel verbLevel
00092     ) const;
00093 
00095   void setParameterList(RCP<ParameterList> const& paramList);
00096 
00098   RCP<ParameterList> getNonconstParameterList();
00099 
00101   RCP<ParameterList> unsetParameterList();
00102 
00104   RCP<const Teuchos::ParameterList> getValidParameters() const;
00105 
00106 private:
00107 
00108 
00109   RCP<const typename DataStore<Scalar>::DataStoreVector_t> nodes_;
00110 #ifdef RYTHMOS_DEBUG
00111   RCP<typename DataStore<Scalar>::DataStoreVector_t> nodes_copy_;
00112 #endif // RYTHMOS_DEBUG
00113 
00114   mutable CubicSplineCoeff<Scalar> splineCoeff_;
00115   mutable bool splineCoeffComputed_;
00116   bool nodesSet_;
00117 
00118   RCP<ParameterList> parameterList_;
00119 
00120 };
00121 
00122 // non-member constructor
00123 template<class Scalar>
00124 RCP<CubicSplineInterpolator<Scalar> > cubicSplineInterpolator();
00125 
00126 // Non-member helper function
00127 // Algorithm from "CRC Standard Mathematical Tables and Formulae" by Daniel
00128 // Zwillinger, 31st Edition, pg 738, natural cubic splines
00129 // input:  n, {x_0, x_1, ..., x_n}
00130 //         a_0 = f(x_0), a_1 = f(x_1), ... a_n = f(x_n)
00131 // output: {a_j,b_j,c_j,d_j}, j=0..n-1
00132 template<class Scalar>
00133 void computeCubicSplineCoeff(
00134     const typename DataStore<Scalar>::DataStoreVector_t & data,
00135     const Ptr<CubicSplineCoeff<Scalar> > & coeffPtr
00136     );
00137 
00138 template<class Scalar>
00139 void validateCubicSplineCoeff(const CubicSplineCoeff<Scalar>& coeff);
00140 
00141 // Non-member helper function
00142 // Evaluate cubic spline 
00143 template<class Scalar>
00144 void evaluateCubicSpline(
00145     const CubicSplineCoeff<Scalar>& coeff,
00146     unsigned int j, 
00147     const Scalar& t,
00148     const Ptr<Thyra::VectorBase<Scalar> >& S,
00149     const Ptr<Thyra::VectorBase<Scalar> >& Sp = Teuchos::null, 
00150     const Ptr<Thyra::VectorBase<Scalar> >& Spp = Teuchos::null
00151     );
00152 
00153 
00154 } // namespace Rythmos
00155 
00156 
00157 #endif // Rythmos_CUBIC_SPLINE_INTERPOLATOR_DECL_H

Generated on Wed May 12 21:25:42 2010 for Rythmos - Transient Integration for Differential Equations by  doxygen 1.4.7