Class documentation of Concepts

Loading...
Searching...
No Matches
parsedFormula.hh
Go to the documentation of this file.
1
6#ifndef parsedformula_hh
7#define parsedformula_hh
8
9#include "toolbox/sequence.hh"
10#include "formula.hh"
11
12
13namespace concepts {
14
15 // **************************************************** FormulaSyntaxError **
16
23 public:
27 FormulaSyntaxError(const std::string& errMsg) throw();
28 protected:
29 virtual std::ostream& info(std::ostream& os) const throw();
30 };
31
32 // ********************************************************* ParsedFormula **
33
59 template<uint dim>
61 public:
63
65 for(uint i = 0; i < dim; ++i) {
66 formula_[i] = "";
67 len_[i] = 0;
68 }
69 }
72 for(uint i = 0; i < dim; ++i) {
73 formula_[i] = frm.formula_[i];
74 pgm_[i] = frm.pgm_[i]; // copy the data
75 len_[i] = frm.len_[i];
76 }
77 }
79 void set(const std::string formula, uint i = 0,
80 RepSeq rep = RepSeq());
81 protected:
83 Real process_(const Real3d& p, const Real t=0.0, uint i=0) const;
85 std::string formula_[dim];
86 private:
88 Array<uchar> pgm_[dim];
90 uint len_[dim];
91 };
92
93 template<class F = Real>
94 class ParsedFormula {};
95
96 template<>
97 class ParsedFormula<Real> : public Formula<Real>, public ParsedFormulaBase<1> {
98 public:
100 ParsedFormula(const std::string formula);
101 virtual ~ParsedFormula();
102 virtual ParsedFormula<Real>* clone() const;
103
104 virtual Real operator() (const Real p, const Real t = 0.0) const;
105 virtual Real operator() (const Real2d& p, const Real t = 0.0) const;
106 virtual Real operator() (const Real3d& p, const Real t = 0.0) const;
107 protected:
108 virtual std::ostream& info(std::ostream& os) const;
109 };
110
111 template<>
112 class ParsedFormula<Cmplx> : public Formula<Cmplx>, public ParsedFormulaBase<2>
113 {
114 public:
116 ParsedFormula(const std::string formulaR, const std::string formulaI);
117 virtual ~ParsedFormula();
118 virtual ParsedFormula<Cmplx>* clone() const;
119
120 virtual Cmplx operator() (const Real p, const Real t = 0.0) const;
121 virtual Cmplx operator() (const Real2d& p, const Real t = 0.0) const;
122 virtual Cmplx operator() (const Real3d& p, const Real t = 0.0) const;
123 protected:
124 virtual std::ostream& info(std::ostream& os) const;
125 };
126
127 template<>
128 class ParsedFormula<Real2d> : public Formula<Real2d>,
129 public ParsedFormulaBase<2>
130 {
131 public:
133 ParsedFormula(const std::string formula1, const std::string formula2);
134 virtual ~ParsedFormula();
135 virtual ParsedFormula<Real2d>* clone() const;
136
137 virtual Real2d operator() (const Real p, const Real t = 0.0) const;
138 virtual Real2d operator() (const Real2d& p, const Real t = 0.0) const;
139 virtual Real2d operator() (const Real3d& p, const Real t = 0.0) const;
140 protected:
141 virtual std::ostream& info(std::ostream& os) const;
142 };
143
144
145} // namespace concepts
146
147#endif // parsedformula_hh
148
FormulaSyntaxError(const std::string &errMsg)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
ParsedFormulaBase(const ParsedFormulaBase< dim > &frm)
Copy constructor.
void set(const std::string formula, uint i=0, RepSeq rep=RepSeq())
Sets the i th formula.
std::string formula_[dim]
The original formula.
Real process_(const Real3d &p, const Real t=0.0, uint i=0) const
Processing the i th formula (with time-dependency variable)
virtual ParsedFormula< Cmplx > * clone() const
Virtual copy constructor.
ParsedFormula(const std::string formulaR, const std::string formulaI)
Constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
ParsedFormula(const std::string formula1, const std::string formula2)
Constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual ParsedFormula< Real2d > * clone() const
Virtual copy constructor.
virtual ParsedFormula< Real > * clone() const
Virtual copy constructor.
ParsedFormula(const std::string formula)
Constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320
std::complex< Real > Cmplx
Type for a complex number. It also depends on the setting of Real.
Definition typedefs.hh:42