CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rz_harm_poly.h
Go to the documentation of this file.
1 #ifndef rz_harm_poly_h
2 #define rz_harm_poly_h
3 
4 #include <cmath>
5 #include "poly2d_base.h"
6 
8 // //
9 // Pair (Cos(phi),Sin(Phi)). Intended for internal use by rz_harm_poly. //
10 // //
12 
13 //_______________________________________________________________________________
14 namespace magfieldparam {
15  struct trig_pair {
16  double CosPhi;
17  double SinPhi;
18 
19  trig_pair() : CosPhi(1.), SinPhi(0.) {}
21  trig_pair(const double C, const double S) : CosPhi(C), SinPhi(S) {}
22  trig_pair(const double phi) : CosPhi(cos(phi)), SinPhi(sin(phi)) {}
23 
24  //Return trig_pair fo angle increased by angle of tp.
26  return trig_pair(this->CosPhi * tp.CosPhi - this->SinPhi * tp.SinPhi,
27  this->SinPhi * tp.CosPhi + this->CosPhi * tp.SinPhi);
28  }
29  };
30 
32  // //
33  // Harmonic homogeneous polynomial in cylindrical system. //
34  // //
36 
37  //_______________________________________________________________________________
38  class rz_harm_poly : public poly2d_base {
39  private:
40  unsigned L;
41  int M;
42 
43  static unsigned Cnt; //Number of the "rz_harm_poly" objects
44  static double phival; //Last phi value used
45  static bool phi_set; //TRUE if phi value is set
46  static unsigned MaxM; //Max. M among "rz_harm_poly" objects
47 
48  static unsigned TASize; //TrigArr size
49  static trig_pair *TrigArr; //Array with angular data
50 
51  static void SetTrigArrSize(const unsigned N);
52  static void FillTrigArr(const double phi);
53 
54  void PrintLM(std::ostream &out = std::cout) {
55  out << "L=" << std::setw(3) << std::left << L << ", M=" << std::setw(3) << std::left << M << "; ";
56  }
57 
58  public:
59  static int GetMaxM(); //return Max. M for the class
60  static unsigned ParentCount() { return poly2d_base::Count(); }
61  static unsigned Count() { return Cnt; }
62  static void SetPhi(const double phi);
63  static void SetPoint(const double r, const double z, const double phi) {
65  SetPhi(phi);
66  }
67 
68  rz_harm_poly() : poly2d_base(), L(0), M(0) { ++Cnt; }
69  rz_harm_poly(const poly2d_base &S) : poly2d_base(S), L(0), M(0) { ++Cnt; }
70  rz_harm_poly(const rz_harm_poly &S) : poly2d_base(S), L(S.L), M(S.M) { ++Cnt; }
71  rz_harm_poly(const unsigned N);
72  ~rz_harm_poly() override;
73 
74  bool IsPhiSet() { return phi_set; }
75 
76  rz_harm_poly GetDiff(int nvar) {
77  rz_harm_poly R(*this);
78  R.Diff(nvar);
79  return R;
80  }
81  rz_harm_poly GetInt(int nvar) {
82  rz_harm_poly R(*this);
83  R.Int(nvar);
84  return R;
85  }
86  rz_harm_poly GetIncPow(int nvar) {
87  rz_harm_poly R(*this);
88  R.IncPow(nvar);
89  return R;
90  }
91  rz_harm_poly GetDecPow(int nvar) {
92  rz_harm_poly R(*this);
93  R.DecPow(nvar);
94  return R;
95  }
96 
99 
100  unsigned GetL() { return L; }
101  int GetM() { return M; }
102 
103  //Next functions return value of angular terms.
104  //No check is made, wheither the TrigArr is initialized.
105  //User can check if IsPhiSet() == true
106  double GetCos() { return TrigArr[M].CosPhi; }
107  double GetSin() { return TrigArr[M].SinPhi; }
108 
109  void CheatL(const unsigned newL) { L = newL; }
110  void Print(std::ostream &out = std::cout, const std::streamsize prec = 5) {
111  PrintLM(out);
112  poly2d_base::Print(out, prec);
113  }
114 
115  static void PrintTrigArr(std::ostream &out = std::cout, const std::streamsize prec = 5);
116 
117  }; //class rz_harm_poly
118 } // namespace magfieldparam
119 
120 #endif
static void FillTrigArr(const double phi)
void Print(std::ostream &out=std::cout, const std::streamsize prec=5)
Definition: poly2d_base.cc:214
trig_pair Add(const trig_pair &tp)
Definition: rz_harm_poly.h:25
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static unsigned Count()
Definition: rz_harm_poly.h:61
static void SetPhi(const double phi)
Definition: rz_harm_poly.cc:86
static trig_pair * TrigArr
Definition: rz_harm_poly.h:49
static void SetPoint(const double r, const double z)
Definition: poly2d_base.cc:151
rz_harm_poly GetInt(int nvar)
Definition: rz_harm_poly.h:81
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static void SetPoint(const double r, const double z, const double phi)
Definition: rz_harm_poly.h:63
rz_harm_poly GetIncPow(int nvar)
Definition: rz_harm_poly.h:86
trig_pair(const double phi)
Definition: rz_harm_poly.h:22
rz_harm_poly GetDecPow(int nvar)
Definition: rz_harm_poly.h:91
#define N
Definition: blowfish.cc:9
rz_harm_poly GetDiff(int nvar)
Definition: rz_harm_poly.h:76
trig_pair(const double C, const double S)
Definition: rz_harm_poly.h:21
rz_harm_poly(const rz_harm_poly &S)
Definition: rz_harm_poly.h:70
static void PrintTrigArr(std::ostream &out=std::cout, const std::streamsize prec=5)
void PrintLM(std::ostream &out=std::cout)
Definition: rz_harm_poly.h:54
rz_harm_poly(const poly2d_base &S)
Definition: rz_harm_poly.h:69
tuple cout
Definition: gather_cfg.py:144
void CheatL(const unsigned newL)
Definition: rz_harm_poly.h:109
static unsigned ParentCount()
Definition: rz_harm_poly.h:60
void Print(std::ostream &out=std::cout, const std::streamsize prec=5)
Definition: rz_harm_poly.h:110
static void SetTrigArrSize(const unsigned N)
trig_pair(const trig_pair &tp)
Definition: rz_harm_poly.h:20
static unsigned Count()
Definition: poly2d_base.h:78