Class documentation of Concepts

Loading...
Searching...
No Matches
vectorFormula.hh
Go to the documentation of this file.
1
8#ifndef vectorformula_hh
9#define vectorformula_hh
10
11#include <vector>
13#include "elementFormula.hh"
14
15namespace concepts {
16
17
18 // ********************************************************* VectorFormula **
19
24 template<typename F, int dim>
25 class VectorFormula : public Formula< Point<F, dim> >
26 {
27 public:
30
31 VectorFormula<F,dim>() : formulas_()
32 {
33 for(int i=0; i < dim; ++i)
34 formulas_.push_back(EntryFormulaRCP());
35 }
36
41 VectorFormula<F,dim>(const std::vector< EntryFormulaRCP >& formulas)
42 : formulas_(formulas)
43 {
44 conceptsAssert(formulas_.size() == dim, concepts::Assertion());
45 }
46
51 Point<F, dim> operator() (const Real p, const Real t = 0.0) const
52 {
54 for (int i=0; i < dim; ++i) {
55 ret[i] = formulas_[i] ? (*formulas_[i])(p, t) : F(0);
56 }
57 return ret;
58 }
59
60 Point<F, dim> operator() (const Real2d& p, const Real t = 0.0) const
61 {
63 for (int i=0; i < dim; ++i) {
64 ret[i] = formulas_[i] ? (*formulas_[i])(p, t) : F(0);
65 }
66 return ret;
67 }
68
69 Point<F, dim> operator() (const Real3d& p, const Real t = 0.0) const
70 {
72 for (int i=0; i < dim; ++i) {
73 ret[i] = formulas_[i] ? (*formulas_[i])(p, t) : F(0);
74 }
75 return ret;
76 }
77
79 virtual VectorFormula<F,dim>* clone() const
80 {
81 return new VectorFormula<F, dim>(*this);
82 }
83
84#if 0
86 : formulas_(other.formulas_)
87 { }
88#endif
89
90 virtual ~VectorFormula() { }
91
92 const std::vector< EntryFormulaRCP >& getFormulas()
93 {
94 return formulas_;
95 }
96
97 EntryFormulaRCP& operator[](int i)
98 {
100
101 return formulas_[i];
102 }
103
104 protected:
105 std::vector< EntryFormulaRCP > formulas_;
106
107 virtual std::ostream& info(std::ostream& os) const {
108 os << concepts::typeOf(*this) << "([";
109 for (int i=0; i < dim; ++i) {
110 if (formulas_[i])
111 os << *formulas_[i];
112 else
113 os << "0";
114 if (i < dim - 1)
115 os << ", ";
116 }
117 return os << "])";
118 }
119 };
120
121
122} // namespace concepts
123
124
125#endif // vectorformula_hh
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Point< F, dim > operator()(const Real p, const Real t=0.0) const
virtual VectorFormula< F, dim > * clone() const
Virtual copy constructor.
#define conceptsAssert(cond, exc)
std::string typeOf(const T &t)
Definition output.hh:43
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320