DOpE
controlvector.h
Go to the documentation of this file.
1 
24 #ifndef CONTROL_VECTOR_H_
25 #define CONTROL_VECTOR_H_
26 
27 #include "spacetimehandler_base.h"
28 #include "dopetypes.h"
29 
30 #include <lac/vector.h>
31 #include <lac/block_vector_base.h>
32 #include <lac/block_vector.h>
33 
34 #include <vector>
35 #include <iostream>
36 #include <sstream>
37 
38 
39 namespace DOpE
40 {
41 
48 template<typename VECTOR>
50  {
51  public:
52  //TODO: Currently we only consider one fixed control
53  // for all timesteps, if more is desired one needs to augment the
54  // Spacetimehandler to have a time discretization for the control,
55  // Then one can update this vector similar to the statevector
56  // with different meshes for Vectors.
57  // Note that this requires to keep track of the interpolation
58  // between state and control time points...
59  ControlVector(const ControlVector& ref);
62 
74  void SetTime(double t, const TimeIterator& interval) const;
83  void SetTimeDoFNumber(unsigned int time_point) const;
89  VECTOR& GetSpacialVector();
93  const VECTOR& GetSpacialVector() const;
100  const dealii::Vector<double>& GetSpacialVectorCopy() const;
101 
107  void operator=(double value);
114  void operator=(const ControlVector& dq);
122  void operator+=(const ControlVector& dq);
128  void operator*=(double a);
136  double operator*(const ControlVector& dq) const;
145  void add(double s, const ControlVector& dq);
152  void equ(double s, const ControlVector& dq);
160  void max(const ControlVector& dq);
168  void min(const ControlVector& dq);
169 
173  void comp_mult(const ControlVector& dq);
174 
178  void comp_invert();
179 
188  void init_by_sign(double smaller, double larger, double unclear, double TOL = 1.e-10);
189 
195  void PrintInfos(std::stringstream& out);
199  void UnLockCopy() const { lock_ = false; }
200 
210  DOpEtypes::VectorStorageType GetBehavior() const { return behavior_; }
211 
215  const SpaceTimeHandlerBase<VECTOR>* GetSpaceTimeHandler() const { return STH_; }
216 
221  void ReInit();
222 
231  double Norm(std::string name,std::string restriction = "all") const;
232 
233  private:
238  void ReSizeSpace(unsigned int ndofs, const std::vector<unsigned int>& dofs_per_block);
243  void ComputeLocalVectors(const TimeIterator& interval) const;
244 
245  std::vector<VECTOR* > control_;
246  mutable VECTOR local_control_;
247  mutable dealii::Vector<double> copy_control_;
248 
249  //pointer to the dofs in the actual interval. Is only used if the interval is set!
250  mutable std::vector<VECTOR*> local_vectors_;
251  //Map: global time dof index - local time DoF index
252  mutable std::map<unsigned int, unsigned int> global_to_local_;
253  //the index of the interval, to which the vectors stored in local_vectors belong
254  mutable int accessor_index_;
255 
256  mutable int accessor_;
257  mutable bool lock_;
258 
259  const SpaceTimeHandlerBase<VECTOR>* STH_;
261  DOpEtypes::ControlType c_type_;
262  unsigned int sfh_ticket_;
263  };
264 
265 
266 }
267 #endif
void PrintInfos(std::stringstream &out)
Definition: controlvector.cc:897
void UnLockCopy() const
Definition: controlvector.h:199
const dealii::Vector< double > & GetSpacialVectorCopy() const
Definition: controlvector.cc:277
void init_by_sign(double smaller, double larger, double unclear, double TOL=1.e-10)
Definition: controlvector.cc:857
~ControlVector()
Definition: controlvector.cc:143
void operator+=(const ControlVector &dq)
Definition: controlvector.cc:533
ControlType
Definition: dopetypes.h:103
Definition: spacetimehandler_base.h:48
void operator*=(double a)
Definition: controlvector.cc:568
Definition: timeiterator.h:63
Definition: controlvector.h:49
void SetTimeDoFNumber(unsigned int time_point) const
Definition: controlvector.cc:161
DOpEtypes::VectorStorageType GetBehavior() const
Definition: controlvector.h:210
void add(double s, const ControlVector &dq)
Definition: controlvector.cc:630
void ReInit()
Definition: controlvector.cc:96
double operator*(const ControlVector &dq) const
Definition: controlvector.cc:593
void comp_invert()
Definition: controlvector.cc:828
const SpaceTimeHandlerBase< VECTOR > * GetSpaceTimeHandler() const
Definition: controlvector.h:215
VECTOR & GetSpacialVector()
Definition: controlvector.cc:205
void min(const ControlVector &dq)
Definition: controlvector.cc:745
void operator=(double value)
Definition: controlvector.cc:449
ControlVector(const ControlVector &ref)
Definition: controlvector.cc:37
VectorStorageType
Definition: dopetypes.h:120
void comp_mult(const ControlVector &dq)
Definition: controlvector.cc:786
double Norm(std::string name, std::string restriction="all") const
Definition: controlvector.cc:936
void equ(double s, const ControlVector &dq)
Definition: controlvector.cc:666
void max(const ControlVector &dq)
Definition: controlvector.cc:702
void SetTime(double t, const TimeIterator &interval) const
Definition: controlvector.cc:187