Rythmos - Transient Integration for Differential Equations  Version of the Day
 All Classes Functions Variables Typedefs Pages
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 #include <list>
36 
37 namespace Rythmos {
38 
39 template<class Scalar>
40 class DataStore : virtual public Teuchos::Describable
41 {
42 
43  public:
44 
45  typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
46 
48  ~DataStore() {};
49 
51  DataStore();
52 
54  // This is a shallow copy constructor, use clone for a deep copy
55  DataStore(Scalar& time_
56  ,const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& x_
57  ,const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& xdot_
58  ,ScalarMag& accuracy_);
59 
61  // This is a shallow copy constructor, use clone for a deep copy
62  DataStore(const DataStore<Scalar>& ds_in);
63 
65  // This is a deep clone and copies the underlying vectors
66  RCP<DataStore<Scalar> > clone() const;
67 
69  Scalar time;
70 
72  Teuchos::RCP<const Thyra::VectorBase<Scalar> > x;
73 
75  Teuchos::RCP<const Thyra::VectorBase<Scalar> > xdot;
76 
78  ScalarMag accuracy;
79 
81  bool operator< (const DataStore<Scalar>& ds) const;
82 
84  bool operator<= (const DataStore<Scalar>& ds) const;
85 
87  bool operator< (const Scalar& t) const;
88 
90  bool operator<= (const Scalar& t) const;
91 
93  bool operator> (const DataStore<Scalar>& ds) const;
94 
96  bool operator>= (const DataStore<Scalar>& ds) const;
97 
99  bool operator> (const Scalar& t) const;
100 
102  bool operator>= (const Scalar& t) const;
103 
105  bool operator== (const DataStore<Scalar>& ds) const;
106 
108  bool operator== (const Scalar& t) const;
109 
111  typedef Array<DataStore<Scalar> > DataStoreVector_t;
112 
114  typedef Array<const DataStore<Scalar> > constDataStoreVector_t;
115 
117  typedef std::list<DataStore<Scalar> > DataStoreList_t;
118 
120  typedef std::list<const DataStore<Scalar> > constDataStoreList_t;
121 
123 
124  std::string description() const;
125 
128  void describe(
129  Teuchos::FancyOStream &out
130  ,const Teuchos::EVerbosityLevel verbLevel
131  ) const;
132 };
133 
134 
135 // This is a helper function to convert a vector of DataStore objects to vectors of t,x,xdot,accuracy
136 template<class Scalar>
137 void dataStoreVectorToVector(
138  const typename DataStore<Scalar>::DataStoreVector_t &ds
139  ,Array<Scalar> *time_vec
140  ,Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > *x_vec
141  ,Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > *xdot_vec
142  ,Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> *accuracy_vec);
143 
144 // This is a helper function to convert vectors of t,x,xdot,accuracy to a vector of DataStore objects
145 template<class Scalar>
146 void vectorToDataStoreVector(
147  const Array<Scalar> &time_vec
148  ,const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > &x_vec
149  ,const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > &xdot_vec
150  ,const Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &accuracy_vec
151  ,typename DataStore<Scalar>::DataStoreVector_t *ds);
152 
153 // This is a helper function to convert vectors of t,x,xdot,[accuracy] to a list of DataStore objects
154 template<class Scalar>
155 void vectorToDataStoreList(
156  const Array<Scalar> &time_vec
157  ,const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > &x_vec
158  ,const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > &xdot_vec
159  ,const Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &accuracy_vec
160  ,typename DataStore<Scalar>::DataStoreList_t *ds);
161 
162 template<class Scalar>
163 void vectorToDataStoreList(
164  const Array<Scalar> &time_vec
165  ,const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > &x_vec
166  ,const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > > &xdot_vec
167  ,typename DataStore<Scalar>::DataStoreList_t *ds);
168 
169 } // namespace Rythmos
170 
171 #endif // Rythmos_DATA_STORE_DECL_H
172