DOpE
statevector.h
Go to the documentation of this file.
1 
24 #ifndef STATE_VECTOR_H_
25 #define STATE_VECTOR_H_
26 
27 #include "spacetimehandler_base.h"
28 #include "parameterreader.h"
29 #include "dopetypes.h"
30 
31 #include <deal.II/base/utilities.h>
32 #include <deal.II/lac/vector.h>
33 #include <deal.II/lac/block_vector_base.h>
34 #include <deal.II/lac/block_vector.h>
35 
36 #include <vector>
37 #include <iostream>
38 #include <sstream>
39 #include <fstream>
40 
41 namespace DOpE
42 {
49 template<typename VECTOR>
51 {
52  public:
53  //FIXME this is not a real copyconstructor, it just
54  //uses the information of ref about size and so on. Is this correct?
55  StateVector(const StateVector<VECTOR>& ref);
58  ParameterReader &param_reader);
59  ~StateVector();
60 
71  void SetTimeDoFNumber(unsigned int dof_number,
72  const TimeIterator& interval) const;
73 
74 // /**
75 // * Sets the time in the vector for interpolation. This Function or SetTimeDoFNumber
76 // * or SetTimeDoFNumber must be called before calling GetSpacialVector
77 // * in order to load the required data.
78 // *
79 // * @param t A double containing the time we are interested in.
80 // *
81 // * @param interval An TimeIterator. The interval containing t.
82 // *
83 // */
84 // void SetTime(double t, const TimeIterator& interval) const;
93  void SetTimeDoFNumber(unsigned int time_point) const;
97  VECTOR& GetSpacialVector();
101  const VECTOR& GetSpacialVector() const;
105  VECTOR& GetNextSpacialVector();
109  const VECTOR& GetNextSpacialVector() const;
113  VECTOR& GetPreviousSpacialVector();
117  const VECTOR& GetPreviousSpacialVector() const;
124  const dealii::Vector<double>& GetSpacialVectorCopy() const;
130  void operator=(double value);
137  void operator=(const StateVector<VECTOR>& dq);
146  void operator+=(const StateVector<VECTOR>& dq);
153  void operator*=(double a);
161  double operator*(const StateVector<VECTOR>& dq) const;
171  void add(double s, const StateVector<VECTOR>& dq);
179  void equ(double s, const StateVector<VECTOR>& dq);
180 
186  void PrintInfos(std::stringstream& out);
190  void UnLockCopy() const
191  {
192  lock_ = false;
193  }
207  {
208  return behavior_;
209  }
214  {
215  return STH_;
216  }
221  void ReInit();
222 
223  private:
224  struct SpatialVectorInfos
225  {
226  int size_;
227  bool on_disc_;
228 
229  SpatialVectorInfos(int size = -1, bool on_disc = false)
230  {
231  size_ = size;
232  on_disc_ = on_disc;
233  }
234  ;
235  };
240  void ReSizeSpace(unsigned int ndofs, const std::vector<unsigned int>& dofs_per_block) const;
241 
247  void MakeName(unsigned int time_point) const;
253  void StoreOnDisc() const;
263  void FetchFromDisc(unsigned int time_point, VECTOR & vector) const;
271  bool FileExists(unsigned int time_point) const;
277  void SwapPtr(VECTOR* & a,VECTOR* & b ) const;
278 
283  void ComputeLocalVectors(const TimeIterator& interval) const;
284 
288  void ResizeLocalVectors(unsigned int size) const;
289 
290  mutable std::vector<VECTOR*> state_;
291  mutable std::vector<SpatialVectorInfos> state_information_;
292 
293  mutable VECTOR local_state_;
294  mutable dealii::Vector<double> copy_state_;
295  mutable int accessor_;
296 
297  mutable bool lock_;
298 
299  //Needed in the store_on_disc case for read/write operations on the hard disc
300  mutable std::string filename_;
301  mutable std::fstream filestream_;
302 
303  //Needed in the only_recent case to decide if the operation is allowed.
304  mutable unsigned int current_dof_number_;
305 
306  //pointer to the dofs in the actual interval. Is only used if the interval is set!
307  mutable std::vector<VECTOR*> local_vectors_;
308 
309 
310  //Map: global time dof index - local time DoF index
311  mutable std::map<unsigned int, unsigned int> global_to_local_;
312  //the index of the interval, to which the vectors stored in local_vectors belong
313  mutable int accessor_index_;
314 
316  std::string tmp_dir_;
317  unsigned int sfh_ticket_;
318 
319  const SpaceTimeHandlerBase<VECTOR>* STH_;
320  const unsigned int unique_id_;
321 
322  static unsigned int id_counter_;
323  static unsigned int num_active_;
324 };
325 
326 }
327 #endif
const dealii::Vector< double > & GetSpacialVectorCopy() const
Definition: statevector.cc:587
void operator+=(const StateVector< VECTOR > &dq)
Definition: statevector.cc:1018
void operator=(double value)
Definition: statevector.cc:847
VECTOR & GetSpacialVector()
Definition: statevector.cc:383
double operator*(const StateVector< VECTOR > &dq) const
Definition: statevector.cc:1136
Definition: parameterreader.h:36
void ReInit()
Definition: statevector.cc:127
void add(double s, const StateVector< VECTOR > &dq)
Definition: statevector.cc:1212
Definition: spacetimehandler_base.h:48
Definition: timeiterator.h:62
VECTOR & GetPreviousSpacialVector()
Definition: statevector.cc:518
StateVector(const StateVector< VECTOR > &ref)
Definition: statevector.cc:48
~StateVector()
Definition: statevector.cc:210
void equ(double s, const StateVector< VECTOR > &dq)
Definition: statevector.cc:1282
VECTOR & GetNextSpacialVector()
Definition: statevector.cc:448
void operator*=(double a)
Definition: statevector.cc:1086
Definition: statevector.h:50
DOpEtypes::VectorStorageType GetBehavior() const
Definition: statevector.h:206
VectorStorageType
Definition: dopetypes.h:120
const SpaceTimeHandlerBase< VECTOR > * GetSpaceTimeHandler() const
Definition: statevector.h:213
void PrintInfos(std::stringstream &out)
Definition: statevector.cc:1350
void SetTimeDoFNumber(unsigned int dof_number, const TimeIterator &interval) const
Definition: statevector.cc:263
void UnLockCopy() const
Definition: statevector.h:190