FLAME  devel
 All Classes Functions Variables Typedefs Enumerations Pages
linear.h
1 #ifndef FLAME_LINEAR_H
2 #define FLAME_LINEAR_H
3 
4 #include <ostream>
5 #include <math.h>
6 
7 #include <boost/numeric/ublas/vector.hpp>
8 #include <boost/numeric/ublas/matrix.hpp>
9 #include <boost/numeric/ublas/io.hpp>
10 
11 #include "base.h"
12 
18 template<typename State>
20 {
21  typedef State state_t;
22 
23  LinearElementBase(const Config& c)
24  :ElementVoid(c)
25  ,transfer(boost::numeric::ublas::identity_matrix<double>(state_t::maxsize))
26  {}
27  virtual ~LinearElementBase() {}
28 
29  virtual void advance(StateBase& s)
30  {
31  State& ST = static_cast<State&>(s);
32  advanceT(ST);
33  }
34 
35  virtual void show(std::ostream& strm, int level) const
36  {
37  ElementVoid::show(strm, level);
38  strm<<"Transfer: "<<transfer<<"\n";
39  }
40 
41  typedef boost::numeric::ublas::matrix<double> value_t;
42 
43  value_t transfer;
44 
45  virtual void assign(const ElementVoid *other)
46  {
47  const LinearElementBase *O = static_cast<const LinearElementBase*>(other);
48  transfer = O->transfer;
49  ElementVoid::assign(other);
50  }
51 
52 private:
53  void advanceT(State& s)
54  {
55  using boost::numeric::ublas::prod;
56  s.pos += length;
57  s.state = prod(transfer, s.state);
58  }
59 };
60 
61 #endif // FLAME_LINEAR_H
ElementVoid(const Config &conf)
Construct this element using the provided Config.
Definition: base.cpp:54
Base class for all simulated elements.
Definition: base.h:166
double length
Longitudual length of this element (added to StateBase::pos)
Definition: base.h:196
The abstract base class for all simulation state objects.
Definition: base.h:28
virtual void assign(const ElementVoid *other)=0
Definition: base.cpp:72
Associative configuration container.
Definition: config.h:66
An Element based on a simple Transfer matrix.
Definition: linear.h:19
virtual void advance(StateBase &s)
Propogate the given State through this Element.
Definition: linear.h:29
virtual void show(std::ostream &strm, int level) const
Definition: linear.h:35
virtual void assign(const ElementVoid *other)
Definition: linear.h:45
value_t transfer
The transfer matrix.
Definition: linear.h:43
virtual void show(std::ostream &, int level) const
Definition: base.cpp:67