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 
30 #include <base/utilities.h>
31 #include <lac/vector.h>
32 #include <lac/block_vector_base.h>
33 #include <lac/block_vector.h>
34 
35 #include <vector>
36 #include <iostream>
37 #include <sstream>
38 #include <fstream>
39 
40 namespace DOpE
41 {
48 template<typename VECTOR>
50 {
51  public:
52  //FIXME this is not a real copyconstructor, it just
53  //uses the information of ref about size and so on. Is this correct?
54  StateVector(const StateVector<VECTOR>& ref);
55  StateVector(const SpaceTimeHandlerBase<VECTOR>* STH, std::string behavior,
56  ParameterReader &param_reader);
57  ~StateVector();
58 
69  void SetTimeDoFNumber(unsigned int dof_number,
70  const TimeIterator& interval) const;
71 
82  void SetTime(double t, const TimeIterator& interval) const;
91  void SetTimeDoFNumber(unsigned int time_point) const;
95  VECTOR& GetSpacialVector();
99  const VECTOR& GetSpacialVector() const;
106  const dealii::Vector<double>& GetSpacialVectorCopy() const;
112  void operator=(double value);
119  void operator=(const StateVector<VECTOR>& dq);
128  void operator+=(const StateVector<VECTOR>& dq);
135  void operator*=(double a);
143  double operator*(const StateVector<VECTOR>& dq) const;
153  void add(double s, const StateVector<VECTOR>& dq);
161  void equ(double s, const StateVector<VECTOR>& dq);
162 
168  void PrintInfos(std::stringstream& out);
172  void UnLockCopy() const
173  {
174  _lock = false;
175  }
188  std::string GetBehavior() const
189  {
190  return _behavior;
191  }
196  {
197  return _STH;
198  }
203  void ReInit();
204 
205  private:
206  struct SpatialVectorInfos
207  {
208  int _size;
209  bool _on_disc;
210 
211  SpatialVectorInfos(int size = -1, bool on_disc = false)
212  {
213  _size = size;
214  _on_disc = on_disc;
215  }
216  ;
217  };
222  void ReSizeSpace(unsigned int ndofs, const std::vector<unsigned int>& dofs_per_block);
223 
229  void MakeName(unsigned int time_point) const;
235  void StoreOnDisc() const;
245  void FetchFromDisc(unsigned int time_point, VECTOR & vector) const;
253  bool FileExists(unsigned int time_point) const;
259  void SwapPtr(VECTOR* & a,VECTOR* & b ) const;
260 
265  void ComputeLocalVectors(const TimeIterator& interval) const;
266 
270  void ResizeLocalVectors(unsigned int size) const;
271 
272  mutable std::vector<VECTOR*> _state;
273  mutable std::vector<SpatialVectorInfos> _state_information;
274 
275  mutable VECTOR _local_state;
276  mutable dealii::Vector<double> _copy_state;//FIXME why is this not of type VECTOR??
277  mutable int _accessor;
278 
279  mutable bool _lock;
280 
281  //Needed in the store_on_disc case for read/write operations on the hard disc
282  mutable std::string _filename;
283  mutable std::fstream _filestream;
284 
285  //pointer to the dofs in the actual interval. Is only used if the interval is set!
286  mutable std::vector<VECTOR*> _local_vectors;
287 
288 
289  //Map: global time dof index - local time DoF index
290  mutable std::map<unsigned int, unsigned int> _global_to_local;
291  //the index of the interval, to which the vectors stored in local_vectors belong
292  mutable int _accessor_index;
293 
294  std::string _behavior;
295  std::string _tmp_dir;
296  unsigned int _sfh_ticket;
297 
298  const SpaceTimeHandlerBase<VECTOR>* _STH;
299  const unsigned int _unique_id;
300 
301  static unsigned int _id_counter;
302  static unsigned int _num_active;
303 };
304 
305 }
306 #endif
const dealii::Vector< double > & GetSpacialVectorCopy() const
Definition: statevector.cc:392
void operator+=(const StateVector< VECTOR > &dq)
Definition: statevector.cc:799
std::string GetBehavior() const
Definition: statevector.h:188
void operator=(double value)
Definition: statevector.cc:649
VECTOR & GetSpacialVector()
Definition: statevector.cc:329
double operator*(const StateVector< VECTOR > &dq) const
Definition: statevector.cc:904
Definition: parameterreader.h:36
void ReInit()
Definition: statevector.cc:125
void add(double s, const StateVector< VECTOR > &dq)
Definition: statevector.cc:973
Definition: spacetimehandler_base.h:47
Definition: timeiterator.h:63
void SetTime(double t, const TimeIterator &interval) const
Definition: statevector.cc:314
StateVector(const StateVector< VECTOR > &ref)
Definition: statevector.cc:48
~StateVector()
Definition: statevector.cc:179
void equ(double s, const StateVector< VECTOR > &dq)
Definition: statevector.cc:1036
void operator*=(double a)
Definition: statevector.cc:860
Definition: statevector.h:49
const SpaceTimeHandlerBase< VECTOR > * GetSpaceTimeHandler() const
Definition: statevector.h:195
void PrintInfos(std::stringstream &out)
Definition: statevector.cc:1097
void SetTimeDoFNumber(unsigned int dof_number, const TimeIterator &interval) const
Definition: statevector.cc:231
void UnLockCopy() const
Definition: statevector.h:172