CMS 3D CMS Logo

HarmBasis3DCyl.h
Go to the documentation of this file.
1 #ifndef HarmBasis3DCyl_h
2 #define HarmBasis3DCyl_h
3 
4 #include "rz_harm_poly.h"
5 
6 namespace magfieldparam {
7 
8  typedef std::vector<rz_harm_poly> harm_poly_vec;
9  typedef std::vector<harm_poly_vec> harm_poly_arr;
10 
12  // //
13  // HarmBasis3DCyl: set of basis harmonic polynomials in cylindrical CS //
14  // //
16 
18  private:
19  unsigned Dim; //Dimension of the basis
20  unsigned Len; //Length of the basis, accounting negative M's
21 
22  int *L_k, *M_k; //Translation arrays from linear to (L,M) address;
23  double *P_k, *Br_k, *Bz_k, *Bphi_k; //Calculated values for (r,z) terms
24 
25  harm_poly_arr PtB; //Potential basis
26  harm_poly_arr BrB; //Br basis
27  harm_poly_arr BzB; //Bz basis
28  harm_poly_arr BphiB; //phi basis
29 
30  void EvalRZ(harm_poly_arr &B, double *val);
31  double GetVal(double *coeff, double *basis);
32 
33  void Print(harm_poly_arr &B, std::ostream &out = std::cout);
34 
35  public:
36  HarmBasis3DCyl(const unsigned N = 18); //The only legal constructor
37  virtual ~HarmBasis3DCyl();
38 
39  unsigned GetDim() { return Dim; }
40  unsigned GetLen() { return Len; }
41  void GetLM(const unsigned j, int &Lj, int &Mj) {
42  Lj = L_k[j];
43  Mj = M_k[j];
44  }
45 
46  //Sets point for the basis components evaluation
47  void SetPoint(const double r, const double z, const double phi) { rz_harm_poly::SetPoint(r, z, phi); }
48 
49  //Fill tables with the basis component values. SetPoint(r,z,phi)
50  //must be called before EvalXXX() calls.
51  void EvalPtn() { EvalRZ(PtB, P_k); }
52  void EvalBr() { EvalRZ(BrB, Br_k); }
53  void EvalBz() { EvalRZ(BzB, Bz_k); }
54  void EvalBphi();
55 
56  //Return the basis component value for the linear address k.
57  //EvalXXX() must be called before GetXXX_k() call
58  double GetPtn_k(const unsigned k) { return P_k[k]; }
59  double GetBr_k(const unsigned k) { return Br_k[k]; }
60  double GetBz_k(const unsigned k) { return Bz_k[k]; }
61  double GetBphi_k(const unsigned k) { return Bphi_k[k]; }
62 
63  //Return the the potential and the field component values
64  //resulted by the basis expansion with coefficients in <coeff>
65  //EvalXXX() must be called before GetXXX() call
66  double GetPtn(double *coeff) { return GetVal(coeff, P_k); }
67  double GetBr(double *coeff) { return GetVal(coeff, Br_k); }
68  double GetBz(double *coeff) { return GetVal(coeff, Bz_k); }
69  double GetBphi(double *coeff) { return GetVal(coeff, Bphi_k); }
70 
71  void PrintPtB(std::ostream &out = std::cout) { Print(PtB, out); }
72  void PrintBrB(std::ostream &out = std::cout) { Print(BrB, out); }
73  void PrintBzB(std::ostream &out = std::cout) { Print(BzB, out); }
74  void PrintBphiB(std::ostream &out = std::cout) { Print(BphiB, out); }
75  void Print(std::ostream &out = std::cout);
76 
77  }; //class HarmBasis3DCyl
78 } // namespace magfieldparam
79 
80 #endif
double GetBphi(double *coeff)
double GetBr_k(const unsigned k)
double GetBr(double *coeff)
Definition: APVGainStruct.h:7
void PrintBrB(std::ostream &out=std::cout)
void PrintBphiB(std::ostream &out=std::cout)
HarmBasis3DCyl(const unsigned N=18)
double GetPtn(double *coeff)
double GetBz_k(const unsigned k)
double GetBphi_k(const unsigned k)
double GetPtn_k(const unsigned k)
static void SetPoint(const double r, const double z, const double phi)
Definition: rz_harm_poly.h:62
std::vector< harm_poly_vec > harm_poly_arr
Definition: HarmBasis3DCyl.h:9
std::vector< rz_harm_poly > harm_poly_vec
Definition: HarmBasis3DCyl.h:8
#define N
Definition: blowfish.cc:9
void Print(harm_poly_arr &B, std::ostream &out=std::cout)
void EvalRZ(harm_poly_arr &B, double *val)
void GetLM(const unsigned j, int &Lj, int &Mj)
void SetPoint(const double r, const double z, const double phi)
void PrintBzB(std::ostream &out=std::cout)
void PrintPtB(std::ostream &out=std::cout)
double GetVal(double *coeff, double *basis)
double GetBz(double *coeff)