Go to the documentation of this file.00001
00002
00003 #ifndef timestepVectors_hh
00004 #define timestepVectors_hh
00005
00006 #include "function/linearForm.hh"
00007 #include "function/vector.hh"
00008
00009
00010 #include "basics/debug.hh"
00011
00012 #define TimeVector_D 0
00013
00014 namespace concepts {
00015
00016
00017 template<class F>
00018 class Formula;
00019 }
00020
00021 namespace timestepping {
00022
00023 using concepts::Real;
00024
00025
00026
00027
00032 class TimeLinearForm : public concepts::LinearForm<Real> {
00033 public:
00034 TimeLinearForm() : time_(0) {}
00036 virtual void time(Real time) { time_ = time; }
00038 Real time() { return time_; }
00039 protected:
00041 Real time_;
00042 };
00043
00044
00045
00050 class TimeVector : public concepts::Vector<Real> {
00051 public:
00057 TimeVector(const concepts::Space<Real>& spc, TimeLinearForm& tlf)
00058 : concepts::Vector<Real>(spc, tlf), spc_(&spc), tlf_(&tlf)
00059 , time_(tlf.time()), frm_(0), template_(0) {}
00064 TimeVector(const concepts::Space<Real>& spc)
00065 : concepts::Vector<Real>(spc), spc_(&spc), tlf_(0)
00066 , time_(0), frm_(0), template_(0) {}
00071 TimeVector(const concepts::Vector<Real>& vec)
00072 : concepts::Vector<Real>(vec), spc_(0), tlf_(0)
00073 , time_(0), frm_(0), template_(0) {}
00079 TimeVector(const concepts::Vector<Real>& vec,
00080 const concepts::Formula<Real>& frm, const Real time = 0);
00081
00082 ~TimeVector() {if (template_) delete template_; }
00083
00085 Real time() const { return time_; }
00089 void time(Real time);
00090 private:
00092 const concepts::Space<Real>* spc_;
00094 TimeLinearForm* tlf_;
00096 Real time_;
00098 const concepts::Formula<Real>* frm_;
00100 const concepts::Vector<Real>* template_;
00101
00103 void updateEntries_() {
00104 conceptsAssert(tlf_, concepts::Assertion());
00105 if (time_ != tlf_->time()) {
00106 tlf_->time(time_);
00107 DEBUGL(TimeVector_D, "new time: " << tlf_->time() << std::endl);
00108 conceptsAssert(spc_, concepts::Assertion());
00109 fillEntries_(*spc_, *tlf_);
00110 DEBUGL(TimeVector_D, "new vector(1): " << *this << std::endl);
00111 }
00112 }
00113
00118 void set_(const concepts::Vector<Real>& vec);
00119 };
00120
00121 }
00122
00123 #endif // timestepVectors_hh