Rythmos - Transient Integration for Differential Equations  Version of the Day
Rythmos_DataStore_decl.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_DATA_STORE_DECL_H
30 #define Rythmos_DATA_STORE_DECL_H
31 
32 #include "Rythmos_Types.hpp"
33 #include "Thyra_VectorBase.hpp"
34 #include "Teuchos_Describable.hpp"
35 
36 namespace Rythmos {
37 
38 template<class Scalar>
39 class DataStore : virtual public Teuchos::Describable
40 {
41 
42  public:
43 
44  typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
45 
47  ~DataStore() {};
48 
50  DataStore();
51 
53  // This is a shallow copy constructor, use clone for a deep copy
54  DataStore(Scalar& time_
55  ,const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& x_
56  ,const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& xdot_
57  ,ScalarMag& accuracy_);
58 
60  // This is a shallow copy constructor, use clone for a deep copy
61  DataStore(const DataStore<Scalar>& ds_in);
62 
64  // This is a deep clone and copies the underlying vectors
65  RCP<DataStore<Scalar> > clone() const;
66 
68  Scalar time;
69 
71  Teuchos::RCP<const Thyra::VectorBase<Scalar> > x;
72 
74  Teuchos::RCP<const Thyra::VectorBase<Scalar> > xdot;
75 
77  ScalarMag accuracy;
78 
80  bool operator< (const DataStore<Scalar>& ds) const;
81 
83  bool operator<= (const DataStore<Scalar>& ds) const;
84 
86  bool operator< (const Scalar& t) const;
87 
89  bool operator<= (const Scalar& t) const;
90 
92  bool operator> (const DataStore<Scalar>& ds) const;
93 
95  bool operator>= (const DataStore<Scalar>& ds) const;
96 
98  bool operator> (const Scalar& t) const;
99 
101  bool operator>= (const Scalar& t) const;
102 
104  bool operator== (const DataStore<Scalar>& ds) const;
105 
107  bool operator== (const Scalar& t) const;
108 
110  typedef Array<DataStore<Scalar> > DataStoreVector_t;
111 
113  typedef Array<const DataStore<Scalar> > constDataStoreVector_t;
114 
116  typedef std::list<DataStore<Scalar> > DataStoreList_t;
117 
119  typedef std::list<const DataStore<Scalar> > constDataStoreList_t;
120 
122 
123  std::string description() const;
124 
127  void describe(
128  Teuchos::FancyOStream &out
129  ,const Teuchos::EVerbosityLevel verbLevel
130  ) const;
131 };
132 
133 
134 // This is a helper function to convert a vector of DataStore objects to vectors of t,x,xdot,accuracy
135 template<class Scalar>
136 void dataStoreVectorToVector(
137  const typename DataStore<Scalar>::DataStoreVector_t &ds
138  ,Array<Scalar> *time_vec
139  ,Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > *x_vec
140  ,Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > *xdot_vec
141  ,Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> *accuracy_vec);
142 
143 // This is a helper function to convert vectors of t,x,xdot,accuracy to a vector of DataStore objects
144 template<class Scalar>
145 void vectorToDataStoreVector(
146  const Array<Scalar> &time_vec
147  ,const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > &x_vec
148  ,const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > &xdot_vec
149  ,const Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &accuracy_vec
150  ,typename DataStore<Scalar>::DataStoreVector_t *ds);
151 
152 // This is a helper function to convert vectors of t,x,xdot,[accuracy] to a list of DataStore objects
153 template<class Scalar>
154 void vectorToDataStoreList(
155  const Array<Scalar> &time_vec
156  ,const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > &x_vec
157  ,const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > &xdot_vec
158  ,const Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &accuracy_vec
159  ,typename DataStore<Scalar>::DataStoreList_t *ds);
160 
161 template<class Scalar>
162 void vectorToDataStoreList(
163  const Array<Scalar> &time_vec
164  ,const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > &x_vec
165  ,const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > &xdot_vec
166  ,typename DataStore<Scalar>::DataStoreList_t *ds);
167 
168 } // namespace Rythmos
169 
170 #endif // Rythmos_DATA_STORE_DECL_H
171