Rythmos_InterpolatorBase.hpp
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_INTERPOLATOR_BASE_H
00030 #define Rythmos_INTERPOLATOR_BASE_H
00031
00032 #include "Rythmos_DataStore.hpp"
00033 #include "Rythmos_InterpolationBufferHelpers.hpp"
00034
00035
00036 namespace Rythmos {
00037
00038
00043 template<class Scalar>
00044 class InterpolatorBase
00045 : virtual public Teuchos::Describable
00046 , virtual public Teuchos::ParameterListAcceptor
00047 , virtual public Teuchos::VerboseObject<InterpolatorBase<Scalar> >
00048 {
00049 public:
00050
00058 virtual bool supportsCloning() const;
00059
00072 virtual Teuchos::RCP<InterpolatorBase<Scalar> > cloneInterpolator() const;
00073
00099 virtual void interpolate(
00100 const typename DataStore<Scalar>::DataStoreVector_t &data_in,
00101 const Array<Scalar> &t_values,
00102 typename DataStore<Scalar>::DataStoreVector_t *data_out
00103 ) const =0;
00104
00109 virtual int order() const =0;
00110
00111 };
00112
00113
00115 template<class Scalar>
00116 void assertBaseInterpolatePreconditions(
00117 const typename DataStore<Scalar>::DataStoreVector_t &data_in,
00118 const Array<Scalar> &t_values,
00119 typename DataStore<Scalar>::DataStoreVector_t *data_out
00120 );
00121
00122
00123
00124
00125
00126
00127 template<class Scalar>
00128 bool InterpolatorBase<Scalar>::supportsCloning() const
00129 {
00130 return false;
00131 }
00132
00133
00134 template<class Scalar>
00135 Teuchos::RCP<InterpolatorBase<Scalar> >
00136 InterpolatorBase<Scalar>::cloneInterpolator() const
00137 {
00138 return Teuchos::null;
00139 }
00140
00141
00142 }
00143
00144
00145 template<class Scalar>
00146 void Rythmos::assertBaseInterpolatePreconditions(
00147 const typename DataStore<Scalar>::DataStoreVector_t &data_in,
00148 const Array<Scalar> &t_values,
00149 typename DataStore<Scalar>::DataStoreVector_t *data_out
00150 )
00151 {
00152 TEST_FOR_EXCEPTION(
00153 data_in.size()==0, std::logic_error,
00154 "Error, data_in.size() == 0!\n"
00155 );
00156 Array<Scalar> time_vec;
00157 dataStoreVectorToVector<Scalar>(data_in, &time_vec, 0, 0, 0);
00158 assertTimePointsAreSorted<Scalar>(time_vec);
00159 assertTimePointsAreSorted<Scalar>(t_values);
00160 if (data_in.size() == 1) {
00161 TEST_FOR_EXCEPTION(
00162 t_values.size()>1, std::logic_error,
00163 "Error, data_in.size() == 1, but t_values.size() > 1!\n"
00164 );
00165 TEST_FOR_EXCEPTION(
00166 t_values[0]!=data_in[0].time, std::logic_error,
00167 "Error, data_in.size) == 1, but t_values[0] = " <<
00168 t_values[0] << " != " << data_in[0].time << " = data_in[0].time!\n"
00169 );
00170 }
00171 TimeRange<Scalar> range(data_in.front().time,data_in.back().time);
00172 for (int i=0; i<Teuchos::as<int>(t_values.size()) ; ++i) {
00173 TEST_FOR_EXCEPTION(
00174 !range.isInRange(t_values[i]), std::logic_error,
00175 "Error, t_values[" << i << "] = " << t_values[i] <<
00176 " is not in range of data_in = " << range << "!\n"
00177 );
00178 }
00179 TEST_FOR_EXCEPTION(
00180 data_out == 0, std::logic_error,
00181 "Error, data_out = NULL!\n"
00182 );
00183 for (int i=0; i<Teuchos::as<int>(data_in.size()) ; ++i) {
00184 TEST_FOR_EXCEPTION(
00185 data_in[i].x == Teuchos::null, std::logic_error,
00186 "Error, data_in[" << i << "].x == Teuchos::null.\n"
00187 );
00188 }
00189 }
00190
00191
00192
00193
00194
00195 #endif //Rythmos_INTERPOLATOR_BASE_H