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 <base/utilities.h>
32 #include <lac/vector.h>
33 #include <lac/block_vector_base.h>
34 #include <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 
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;
108  const dealii::Vector<double>& GetSpacialVectorCopy() const;
114  void operator=(double value);
121  void operator=(const StateVector<VECTOR>& dq);
130  void operator+=(const StateVector<VECTOR>& dq);
137  void operator*=(double a);
145  double operator*(const StateVector<VECTOR>& dq) const;
155  void add(double s, const StateVector<VECTOR>& dq);
163  void equ(double s, const StateVector<VECTOR>& dq);
164 
170  void PrintInfos(std::stringstream& out);
174  void UnLockCopy() const
175  {
176  lock_ = false;
177  }
191  {
192  return behavior_;
193  }
198  {
199  return STH_;
200  }
205  void ReInit();
206 
207  private:
208  struct SpatialVectorInfos
209  {
210  int size_;
211  bool on_disc_;
212 
213  SpatialVectorInfos(int size = -1, bool on_disc = false)
214  {
215  size_ = size;
216  on_disc_ = on_disc;
217  }
218  ;
219  };
224  void ReSizeSpace(unsigned int ndofs, const std::vector<unsigned int>& dofs_per_block) const;
225 
231  void MakeName(unsigned int time_point) const;
237  void StoreOnDisc() const;
247  void FetchFromDisc(unsigned int time_point, VECTOR & vector) const;
255  bool FileExists(unsigned int time_point) const;
261  void SwapPtr(VECTOR* & a,VECTOR* & b ) const;
262 
267  void ComputeLocalVectors(const TimeIterator& interval) const;
268 
272  void ResizeLocalVectors(unsigned int size) const;
273 
274  mutable std::vector<VECTOR*> state_;
275  mutable std::vector<SpatialVectorInfos> state_information_;
276 
277  mutable VECTOR local_state_;
278  mutable dealii::Vector<double> copy_state_;
279  mutable int accessor_;
280 
281  mutable bool lock_;
282 
283  //Needed in the store_on_disc case for read/write operations on the hard disc
284  mutable std::string filename_;
285  mutable std::fstream filestream_;
286 
287  //Needed in the only_recent case to decide if the operation is allowed.
288  mutable unsigned int current_dof_number_;
289 
290  //pointer to the dofs in the actual interval. Is only used if the interval is set!
291  mutable std::vector<VECTOR*> local_vectors_;
292 
293 
294  //Map: global time dof index - local time DoF index
295  mutable std::map<unsigned int, unsigned int> global_to_local_;
296  //the index of the interval, to which the vectors stored in local_vectors belong
297  mutable int accessor_index_;
298 
300  std::string tmp_dir_;
301  unsigned int sfh_ticket_;
302 
303  const SpaceTimeHandlerBase<VECTOR>* STH_;
304  const unsigned int unique_id_;
305 
306  static unsigned int id_counter_;
307  static unsigned int num_active_;
308 };
309 
310 }
311 #endif
const dealii::Vector< double > & GetSpacialVectorCopy() const
Definition: statevector.cc:448
void operator+=(const StateVector< VECTOR > &dq)
Definition: statevector.cc:879
void operator=(double value)
Definition: statevector.cc:708
VECTOR & GetSpacialVector()
Definition: statevector.cc:383
double operator*(const StateVector< VECTOR > &dq) const
Definition: statevector.cc:997
Definition: parameterreader.h:36
void ReInit()
Definition: statevector.cc:127
void add(double s, const StateVector< VECTOR > &dq)
Definition: statevector.cc:1073
Definition: spacetimehandler_base.h:48
Definition: timeiterator.h:63
void SetTime(double t, const TimeIterator &interval) const
Definition: statevector.cc:368
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:1143
void operator*=(double a)
Definition: statevector.cc:947
Definition: statevector.h:50
DOpEtypes::VectorStorageType GetBehavior() const
Definition: statevector.h:190
VectorStorageType
Definition: dopetypes.h:120
const SpaceTimeHandlerBase< VECTOR > * GetSpaceTimeHandler() const
Definition: statevector.h:197
void PrintInfos(std::stringstream &out)
Definition: statevector.cc:1211
void SetTimeDoFNumber(unsigned int dof_number, const TimeIterator &interval) const
Definition: statevector.cc:263
void UnLockCopy() const
Definition: statevector.h:174