Rythmos - Transient Integration for Differential Equations  Version of the Day
 All Classes Functions Variables Typedefs Pages
Rythmos_SmartInterpolationBufferAppender.hpp
1 //@HEADER
2 // ***********************************************************************
3 //
4 // Rythmos Package
5 // Copyright (2006) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact Todd S. Coffey (tscoffe@sandia.gov)
25 //
26 // ***********************************************************************
27 //@HEADER
28 
29 #ifndef RYTHMOS_SMART_INTERPOLATION_BUFFER_APPENDER_HPP
30 #define RYTHMOS_SMART_INTERPOLATION_BUFFER_APPENDER_HPP
31 
32 #include "Rythmos_InterpolationBufferAppenderBase.hpp"
33 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
34 
35 
36 namespace Rythmos {
37 
38 
40 template<class Scalar>
42  : virtual public InterpolationBufferAppenderBase<Scalar>,
43  virtual public Teuchos::ParameterListAcceptorDefaultBase
44 {
45  public:
50  void append(
51  const InterpolationBufferBase<Scalar>& interpBuffSource,
52  const TimeRange<Scalar>& range,
53  const Ptr<InterpolationBufferBase<Scalar> > &interpBuffSink
54  );
55 
58 
60  void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
61 
63  RCP<const Teuchos::ParameterList> getValidParameters() const;
64 
66 };
67 
68 
69 //
70 // Implementations
71 //
72 
73 
74 template<class Scalar>
76  const InterpolationBufferBase<Scalar>& interpBuffSource,
77  const TimeRange<Scalar>& range,
78  const Ptr<InterpolationBufferBase<Scalar> > &interpBuffSink
79  )
80 {
81  TEUCHOS_TEST_FOR_EXCEPTION(
82  true, std::logic_error,
83  "This class has never been tested before and should not be used\n"
84  "until it is"
85  );
86  // 2007/12/05: rabartl: This code has not been tested so don't use this
87  // until a test has been writen for this!
88 #ifdef HAVE_RYTHMOS_DEBUG
89  this->assertAppendPreconditions(interpBuffSource,range,*interpBuffSink);
90 #endif // HAVE_RYTHMOS_DEBUG
91  if (interpBuffSink->getOrder() >= interpBuffSource.getOrder()) {
92  // The incoming interpolation buffer's order of interpolation is lower than
93  // the base interpolation buffer's order of interpolation. In this case,
94  // we just copy the data over.
96  defaultAppender.append(interpBuffSink,interpBuffSource,range);
97  } else {
98  // In this case, the incoming interpolation buffer's order of interpolation
99  // is higher than the base interpolation buffer's, so we'll ask it to
100  // interpolate points before inserting into the base interpolation buffer.
101  TEUCHOS_TEST_FOR_EXCEPTION(
102  true,std::logic_error,
103  "Error, the smart interpolation buffer appender is not implemented\n"
104  "for appending interpolation buffers with higher order interpolation\n"
105  "into interpolation buffers with a lower order of interpolation yet!"
106  );
107  // 08/09/07 tscoffe: Note: you can't use selectPointsInTimeRange
108  // immediately because you may need to interpolate points before the first
109  // node inside the range. I.e. interpBuffSource.getNodes = [... , range.lower(), ... , range.upper(), ... ]
110  }
111 }
112 
113 template<class Scalar>
114 void SmartInterpolationBufferAppender<Scalar>::setParameterList(RCP<Teuchos::ParameterList> const& paramList)
115 {
116  TEUCHOS_TEST_FOR_EXCEPT( is_null(paramList) );
117  paramList->validateParameters(*this->getValidParameters());
118  setMyParamList(paramList);
119  Teuchos::readVerboseObjectSublist(&*paramList,this);
120 }
121 
122 template<class Scalar>
123 RCP<const Teuchos::ParameterList> SmartInterpolationBufferAppender<Scalar>::getValidParameters() const
124 {
125  static RCP<Teuchos::ParameterList> validPL;
126  if (is_null(validPL)) {
127  RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
128  Teuchos::setupVerboseObjectSublist(&*pl);
129  validPL = pl;
130  }
131  return (validPL);
132 }
133 
134 } // namespace Rythmos
135 
136 
137 #endif //RYTHMOS_SMART_INTERPOLATION_BUFFER_APPENDER_HPP
Concrete InterplationBufferAppender subclass that just transfers notes without any regard for accurac...
void append(const InterpolationBufferBase< Scalar > &interpBuffSource, const TimeRange< Scalar > &range, const Ptr< InterpolationBufferBase< Scalar > > &interpBuffSink)
Concrete implementation that simply copies the nodal points between the interpolation buffers...
RCP< const Teuchos::ParameterList > getValidParameters() const
void append(const InterpolationBufferBase< Scalar > &interpBuffSource, const TimeRange< Scalar > &range, const Ptr< InterpolationBufferBase< Scalar > > &interpBuffSink)
Concrete implementation that attempts to use the order of interpolation between the two interpolation...
Base class for an interpolation buffer.
Base class for strategy objects that append data from one InterplationBufferBase object to another...
void setParameterList(RCP< Teuchos::ParameterList > const &paramList)
virtual int getOrder() const =0
Get order of interpolation.