Rythmos - Transient Integration for Differential Equations  Version of the Day
 All Classes Functions Variables Typedefs Pages
Rythmos_InterpolationBufferAppenderBase.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_INTERPOLATION_BUFFER_APPENDER_BASE_HPP
30 #define RYTHMOS_INTERPOLATION_BUFFER_APPENDER_BASE_HPP
31 
32 #include "Rythmos_InterpolationBufferBase.hpp"
33 #include "Rythmos_Types.hpp"
34 #include "Thyra_VectorBase.hpp"
35 #include "Teuchos_Describable.hpp"
36 #include "Teuchos_ParameterListAcceptor.hpp"
37 #include "Teuchos_VerboseObject.hpp"
38 #include "Teuchos_RCP.hpp"
39 #include "Teuchos_implicit_cast.hpp"
40 #include "Teuchos_Assert.hpp"
41 
42 
43 namespace Rythmos {
44 
45 
49 template<class Scalar>
51  : virtual public Teuchos::Describable
52  , virtual public Teuchos::ParameterListAcceptor
53  , virtual public Teuchos::VerboseObject<InterpolationBufferAppenderBase<Scalar> >
54 {
55 public:
56 
82  virtual void append(
83  const InterpolationBufferBase<Scalar>& interpBuffSource,
84  const TimeRange<Scalar>& range,
85  const Ptr<InterpolationBufferBase<Scalar> > &interpBuffSink
86  ) =0;
87 
88 protected:
89 
92  const InterpolationBufferBase<Scalar>& interpBuffSource,
93  const TimeRange<Scalar>& range,
94  const InterpolationBufferBase<Scalar>& interpBuffSink
95  ) const;
96 
97 };
98 
99 
100 template<class Scalar>
102  const InterpolationBufferBase<Scalar>& interpBuffSource,
103  const TimeRange<Scalar>& appendRange,
104  const InterpolationBufferBase<Scalar>& interpBuffSink
105  ) const
106 {
107  // If the time range of interpBuffSink is invalid, then its just empty
108  if (interpBuffSink.getTimeRange().isValid()) {
109  // Allow the appendRange to sit completely outside the sink range (04/22/09 tscoffe)
110  // appendRange overlaps at lower end of sink range:
111  TEUCHOS_TEST_FOR_EXCEPTION(
112  ( compareTimeValues(appendRange.lower(),interpBuffSink.getTimeRange().lower()) < 0 &&
113  compareTimeValues(appendRange.upper(),interpBuffSink.getTimeRange().lower()) > 0 ),
114  std::logic_error,
115  "Error, import range = [" << appendRange.lower() << "," << appendRange.upper() << "] is not a prepend "
116  "of the base range = [" << interpBuffSink.getTimeRange().lower() << "," << interpBuffSink.getTimeRange().upper() << "] "
117  "interpolation buffer.\n"
118  );
119  // appendRange overlaps at upper end of sink range:
120  TEUCHOS_TEST_FOR_EXCEPTION(
121  ( compareTimeValues(appendRange.lower(),interpBuffSink.getTimeRange().upper()) < 0 &&
122  compareTimeValues(appendRange.upper(),interpBuffSink.getTimeRange().upper()) > 0 ),
123  std::logic_error,
124  "Error, import range = [" << appendRange.lower() << "," << appendRange.upper() << "] is not an append "
125  "of the base range = [" << interpBuffSink.getTimeRange().lower() << "," << interpBuffSink.getTimeRange().upper() << "] "
126  "interpolation buffer.\n"
127  );
128  }
129  TEUCHOS_TEST_FOR_EXCEPTION(
130  compareTimeValues(appendRange.lower(),interpBuffSource.getTimeRange().lower())<0,
131  std::logic_error,
132  "Error, append range's lower bound = " << appendRange.lower() << " does not sit inside incoming"
133  " interpolation buffer's time range = "
134  "[" << interpBuffSource.getTimeRange().lower() << "," << interpBuffSource.getTimeRange().upper() << "].\n"
135  );
136  TEUCHOS_TEST_FOR_EXCEPTION(
137  compareTimeValues(interpBuffSource.getTimeRange().upper(),appendRange.upper())<0,
138  std::logic_error,
139  "Error, append range's upper bound = " << appendRange.upper() << "does not sit inside incoming"
140  " interpolation buffer's time range = "
141  "[" << interpBuffSource.getTimeRange().lower() << "," << interpBuffSource.getTimeRange().upper() << "].\n"
142  );
143 }
144 
145 
146 } // namespace Rythmos
147 
148 
149 #endif //RYTHMOS_INTERPOLATION_BUFFER_APPENDER_BASE_HPP
void assertAppendPreconditions(const InterpolationBufferBase< Scalar > &interpBuffSource, const TimeRange< Scalar > &range, const InterpolationBufferBase< Scalar > &interpBuffSink) const
Base class for an interpolation buffer.
Base class for strategy objects that append data from one InterplationBufferBase object to another...
virtual TimeRange< Scalar > getTimeRange() const =0
Return the range of time values where interpolation calls can be performed.
virtual void append(const InterpolationBufferBase< Scalar > &interpBuffSource, const TimeRange< Scalar > &range, const Ptr< InterpolationBufferBase< Scalar > > &interpBuffSink)=0
Append or Prepend data from one interpolation buffer into another.