29 #ifndef Rythmos_INTERPOLATOR_BASE_HELPERS_H
30 #define Rythmos_INTERPOLATOR_BASE_HELPERS_H
32 #include "Rythmos_InterpolatorBase.hpp"
38 template<
class Scalar>
40 InterpolatorBase<Scalar>& interp,
41 const RCP<
const typename DataStore<Scalar>::DataStoreVector_t> & nodes,
42 const Array<Scalar> &t_values,
43 typename DataStore<Scalar>::DataStoreVector_t *data_out
46 interp.setNodes(nodes);
47 interp.interpolate(t_values,data_out);
52 template<
class Scalar>
54 const typename DataStore<Scalar>::DataStoreVector_t &data_in,
55 const Array<Scalar> &t_values,
56 typename DataStore<Scalar>::DataStoreVector_t *data_out
59 TEUCHOS_TEST_FOR_EXCEPTION(
60 data_in.size()==0, std::logic_error,
61 "Error, data_in.size() == 0!\n"
63 Array<Scalar> time_vec;
64 dataStoreVectorToVector<Scalar>(data_in, &time_vec, 0, 0, 0);
65 assertTimePointsAreSorted<Scalar>(time_vec);
66 assertTimePointsAreSorted<Scalar>(t_values);
67 if (data_in.size() == 1) {
68 TEUCHOS_TEST_FOR_EXCEPTION(
69 t_values.size()>1, std::logic_error,
70 "Error, data_in.size() == 1, but t_values.size() > 1!\n"
72 TEUCHOS_TEST_FOR_EXCEPTION(
73 compareTimeValues(t_values[0],data_in[0].time)!=0, std::logic_error,
74 "Error, data_in.size) == 1, but t_values[0] = " <<
75 t_values[0] <<
" != " << data_in[0].time <<
" = data_in[0].time!\n"
79 for (
int i=0; i<Teuchos::as<int>(t_values.size()) ; ++i) {
80 TEUCHOS_TEST_FOR_EXCEPTION(
81 !range.isInRange(t_values[i]), std::out_of_range,
82 "Error, t_values[" << i <<
"] = " << t_values[i] <<
83 " is not in range of data_in = " << range <<
"!\n"
86 TEUCHOS_TEST_FOR_EXCEPTION(
87 data_out == 0, std::logic_error,
88 "Error, data_out = NULL!\n"
93 template<
class Scalar>
94 void assertNodesUnChanged(
95 const typename DataStore<Scalar>::DataStoreVector_t & nodes,
96 const typename DataStore<Scalar>::DataStoreVector_t & nodes_copy
99 typedef Teuchos::ScalarTraits<Scalar> ST;
100 int N = nodes.size();
101 int Ncopy = nodes_copy.size();
102 TEUCHOS_TEST_FOR_EXCEPTION( N != Ncopy, std::logic_error,
103 "Error! The number of nodes passed in through setNodes has changed!"
106 RCP<Thyra::VectorBase<Scalar> > xdiff = nodes[0].x->clone_v();
107 RCP<Thyra::VectorBase<Scalar> > xdotdiff = xdiff->clone_v();
108 V_S(outArg(*xdiff),ST::one());
109 V_S(outArg(*xdotdiff),ST::one());
110 for (
int i=0 ; i<N ; ++i) {
111 V_StVpStV(outArg(*xdiff),ST::one(),*nodes[i].x,-ST::one(),*nodes_copy[i].x);
112 if ((!Teuchos::is_null(nodes[i].xdot)) && (!Teuchos::is_null(nodes_copy[i].xdot))) {
113 V_StVpStV(outArg(*xdotdiff),ST::one(),*nodes[i].xdot,-ST::one(),*nodes_copy[i].xdot);
114 }
else if (Teuchos::is_null(nodes[i].xdot) && Teuchos::is_null(nodes_copy[i].xdot)) {
115 V_S(outArg(*xdotdiff),ST::zero());
117 Scalar xdiffnorm = norm_inf(*xdiff);
118 Scalar xdotdiffnorm = norm_inf(*xdotdiff);
119 TEUCHOS_TEST_FOR_EXCEPTION(
120 ( ( nodes[i].time != nodes_copy[i].time ) ||
121 ( xdiffnorm != ST::zero() ) ||
122 ( xdotdiffnorm != ST::zero() ) ||
123 ( nodes[i].accuracy != nodes_copy[i].accuracy ) ),
125 "Error! The data in the nodes passed through setNodes has changed!"
135 #endif // Rythmos_INTERPOLATOR_BASE_HELPERS_H
void assertBaseInterpolatePreconditions(const typename DataStore< Scalar >::DataStoreVector_t &data_in, const Array< Scalar > &t_values, typename DataStore< Scalar >::DataStoreVector_t *data_out)