CMS 3D CMS Logo

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.) {}
20  trig_pair(const double C, const double S) : CosPhi(C), SinPhi(S) {}
21  trig_pair(const double phi) : CosPhi(cos(phi)), SinPhi(sin(phi)) {}
22 
23  //Return trig_pair fo angle increased by angle of tp.
25  return trig_pair(this->CosPhi * tp.CosPhi - this->SinPhi * tp.SinPhi,
26  this->SinPhi * tp.CosPhi + this->CosPhi * tp.SinPhi);
27  }
28  };
29 
31  // //
32  // Harmonic homogeneous polynomial in cylindrical system. //
33  // //
35 
36  //_______________________________________________________________________________
37  class rz_harm_poly : public poly2d_base {
38  private:
39  unsigned L;
40  int M;
41 
42  static unsigned Cnt; //Number of the "rz_harm_poly" objects
43  static double phival; //Last phi value used
44  static bool phi_set; //TRUE if phi value is set
45  static unsigned MaxM; //Max. M among "rz_harm_poly" objects
46 
47  static unsigned TASize; //TrigArr size
48  static trig_pair *TrigArr; //Array with angular data
49 
50  static void SetTrigArrSize(const unsigned N);
51  static void FillTrigArr(const double phi);
52 
53  void PrintLM(std::ostream &out = std::cout) {
54  out << "L=" << std::setw(3) << std::left << L << ", M=" << std::setw(3) << std::left << M << "; ";
55  }
56 
57  public:
58  static int GetMaxM(); //return Max. M for the class
59  static unsigned ParentCount() { return poly2d_base::Count(); }
60  static unsigned Count() { return Cnt; }
61  static void SetPhi(const double phi);
62  static void SetPoint(const double r, const double z, const double phi) {
64  SetPhi(phi);
65  }
66 
67  rz_harm_poly() : poly2d_base(), L(0), M(0) { ++Cnt; }
68  rz_harm_poly(const poly2d_base &S) : poly2d_base(S), L(0), M(0) { ++Cnt; }
69  rz_harm_poly(const rz_harm_poly &S) : poly2d_base(S), L(S.L), M(S.M) { ++Cnt; }
70  rz_harm_poly(const unsigned N);
71  ~rz_harm_poly() override;
72 
73  bool IsPhiSet() { return phi_set; }
74 
75  rz_harm_poly GetDiff(int nvar) {
76  rz_harm_poly R(*this);
77  R.Diff(nvar);
78  return R;
79  }
80  rz_harm_poly GetInt(int nvar) {
81  rz_harm_poly R(*this);
82  R.Int(nvar);
83  return R;
84  }
85  rz_harm_poly GetIncPow(int nvar) {
86  rz_harm_poly R(*this);
87  R.IncPow(nvar);
88  return R;
89  }
90  rz_harm_poly GetDecPow(int nvar) {
91  rz_harm_poly R(*this);
92  R.DecPow(nvar);
93  return R;
94  }
95 
98 
99  unsigned GetL() { return L; }
100  int GetM() { return M; }
101 
102  //Next functions return value of angular terms.
103  //No check is made, wheither the TrigArr is initialized.
104  //User can check if IsPhiSet() == true
105  double GetCos() { return TrigArr[M].CosPhi; }
106  double GetSin() { return TrigArr[M].SinPhi; }
107 
108  void CheatL(const unsigned newL) { L = newL; }
109  void Print(std::ostream &out = std::cout, const std::streamsize prec = 5) {
110  PrintLM(out);
111  poly2d_base::Print(out, prec);
112  }
113 
114  static void PrintTrigArr(std::ostream &out = std::cout, const std::streamsize prec = 5);
115 
116  }; //class rz_harm_poly
117 } // namespace magfieldparam
118 
119 #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:24
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static unsigned Count()
Definition: rz_harm_poly.h:60
static void SetPhi(const double phi)
Definition: rz_harm_poly.cc:86
static trig_pair * TrigArr
Definition: rz_harm_poly.h:48
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:80
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:62
rz_harm_poly GetIncPow(int nvar)
Definition: rz_harm_poly.h:85
trig_pair(const double phi)
Definition: rz_harm_poly.h:21
rz_harm_poly GetDecPow(int nvar)
Definition: rz_harm_poly.h:90
#define N
Definition: blowfish.cc:9
rz_harm_poly GetDiff(int nvar)
Definition: rz_harm_poly.h:75
trig_pair(const double C, const double S)
Definition: rz_harm_poly.h:20
rz_harm_poly(const rz_harm_poly &S)
Definition: rz_harm_poly.h:69
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:53
rz_harm_poly(const poly2d_base &S)
Definition: rz_harm_poly.h:68
void CheatL(const unsigned newL)
Definition: rz_harm_poly.h:108
static unsigned ParentCount()
Definition: rz_harm_poly.h:59
void Print(std::ostream &out=std::cout, const std::streamsize prec=5)
Definition: rz_harm_poly.h:109
static void SetTrigArrSize(const unsigned N)
static unsigned Count()
Definition: poly2d_base.h:78